Class WAbstractItemDelegate

    • Constructor Detail

      • WAbstractItemDelegate

        public WAbstractItemDelegate()
        Constructor.
    • Method Detail

      • update

        public abstract WWidget update​(WWidget widget,
                                       WModelIndex index,
                                       java.util.EnumSet<ViewItemRenderFlag> flags)
        Creates or updates a widget that renders an item.

        The item is specified by its model index, which also indicates the model. If an existing widget already renders the item, but needs to be updated, it is passed as the widget parameter.

        When widget is null, a new widget needs to be created and returned.

        If you want to replace the widget with a new one, return the new widget. The old widget will be removed. Return null if you do not want to replace the widget.

        You can remove the widget from its parent for reuse with WWidget.removeFromParent().

        The returned widget should be a widget that responds properly to be given a height, width and style class. In practice, that means it cannot have a border or margin, and thus cannot be a WFormWidget since those widgets typically have built-in borders and margins. If you want to return a form widget (for editing the item), you should wrap it in a container widget.

        The flags parameter indicates options for rendering the item.

      • updateModelIndex

        public void updateModelIndex​(WWidget widget,
                                     WModelIndex anon2)
        Updates the model index of a widget.

        This method is invoked by the view when due to row/column insertions or removals, the index has shifted.

        You should reimplement this method only if you are storing the model index in the widget, to update the stored model index.

        The default implementation does nothing.

      • setEditState

        public void setEditState​(WWidget widget,
                                 WModelIndex anon2,
                                 java.lang.Object value)
        Sets the editor data from the editor state.

        When the View scrolls back into view an item that was being edited, he will use setEditState() to allow the editor to restore its current editor state.

        The default implementation assumes a read-only delegate and does nothing.

        See Also:
        getEditState(WWidget widget, WModelIndex anon2)
      • setModelData

        public void setModelData​(java.lang.Object editState,
                                 WAbstractItemModel model,
                                 WModelIndex anon3)
        Saves the edited data to the model.

        The View will use this method to save the edited value to the model. The editState is first fetched from the editor using getEditState().

        The default implementation assumes a read-only delegate does nothing.

      • closeEditor

        public Signal2<WWidget,​java.lang.Boolean> closeEditor()
        Signal which indicates that an editor needs to be closed.

        The delegate should emit this signal when it decides for itself that it should be closed (e.g. because the user confirmed the edited value or cancelled the editing). The View will then rerender the item if needed.

        The second boolean argument passed to the signal is a flag which indicates whether the editor feels that the value should be saved or cancelled.

        See Also:
        WAbstractItemView.closeEditor(WModelIndex index, boolean saveData)