Class TableControlSWTRenderer

    • Field Detail

      • FIXED_COLUMNS

        protected static final java.lang.String FIXED_COLUMNS
        Since:
        1.10
        See Also:
        Constant Field Values
      • TABLE_CUSTOM_VARIANT

        protected static final java.lang.String TABLE_CUSTOM_VARIANT
        Since:
        1.10
        See Also:
        Constant Field Values
      • VALIDATION_PREFERRED_SIZE

        protected static final org.eclipse.swt.graphics.Point VALIDATION_PREFERRED_SIZE
        Since:
        1.17
    • Method Detail

      • getKeyBindingsForAction

        protected java.lang.String[] getKeyBindingsForAction​(java.lang.String actionId,
                                                             java.lang.String... defaultKeybindings)
        Helper to extract the configured key bindings form the view template model.
        Parameters:
        actionId - the ID of the action to extract the key bindings for
        defaultKeybindings - the default key bindings to use in case there are no bindings configured
        Returns:
        an array of key bindings
        Since:
        1.18
      • createTableViewerSWTBuilder

        protected TableViewerSWTBuilder createTableViewerSWTBuilder​(org.eclipse.swt.widgets.Composite parent,
                                                                    org.eclipse.core.databinding.observable.list.IObservableList list,
                                                                    org.eclipse.core.databinding.observable.value.IObservableValue labelText,
                                                                    org.eclipse.core.databinding.observable.value.IObservableValue labelTooltipText,
                                                                    TableViewerCompositeBuilder compositeBuilder,
                                                                    org.eclipse.jface.databinding.viewers.ObservableListContentProvider cp,
                                                                    org.eclipse.jface.viewers.ViewerComparator comparator,
                                                                    TableActionBar<? extends org.eclipse.jface.viewers.AbstractTableViewer> actionBar)
        Creates a new TableViewerSWTBuilder.
        Parameters:
        parent - the parent Composite
        list - the input object
        labelText - the title
        labelTooltipText - the tooltip
        compositeBuilder - the TableViewerCompositeBuilder
        cp - the content provider
        comparator - the ViewerComparator; has no effect if move up/down functionality is enabled
        actionBar - the ActionBar
        Returns:
        the TableViewerSWTBuilder
        Since:
        1.22
      • addAdditionalColumns

        protected int addAdditionalColumns​(TableViewerSWTBuilder tableViewerSWTBuilder)
        Override this method to add additional static columns at the beginning of the table.
        Parameters:
        tableViewerSWTBuilder - the builder
        Returns:
        the number of columns added
        Since:
        1.9
      • getSelectionIndex

        protected int getSelectionIndex()
        Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.
        Returns:
        the index of the selected item
        Since:
        1.10
      • getColumns

        protected org.eclipse.swt.widgets.Item[] getColumns()
        Returns an array of items which are the columns in the table.
        Returns:
        the columns of the table
        Since:
        1.10
      • getHorizontalBar

        protected org.eclipse.swt.widgets.ScrollBar getHorizontalBar()
        Returns the receiver's horizontal scroll bar if it has one, and null if it does not.
        Returns:
        the horizontal scroll bar (or null)
        Since:
        1.10
      • getVerticalBar

        protected org.eclipse.swt.widgets.ScrollBar getVerticalBar()
        Returns the receiver's vertical scroll bar if it has one, and null if it does not.
        Returns:
        the vertical scroll bar (or null)
        Since:
        1.10
      • addButtonsToButtonBar

        protected int addButtonsToButtonBar​(org.eclipse.swt.widgets.Composite buttonComposite)
        Allows to add additional buttons to the button bar of the table control.

        The default implementation does not add additional buttons.

        Parameters:
        buttonComposite - the composite where the buttons are added
        Returns:
        the total number of buttons added
      • createControlComposite

        protected org.eclipse.swt.widgets.Composite createControlComposite​(org.eclipse.swt.widgets.Composite composite)
        Creates and returns the composite which will be the parent for the table viewer.
        Parameters:
        composite - the parent composite including the title/button bar
        Returns:
        the parent for the table viewer
      • getTableHeightHint

        protected int getTableHeightHint()
        Returns the preferred height for the table. This will be passed to the layoutdata.
        Returns:
        the height in px
      • computeRequiredHeight

        protected int computeRequiredHeight​(java.lang.Integer visibleLines)
        Returns the height in pixels required to display the given number of table items. If the visible items are not specified, the height required to display all the table items is returned.
        Parameters:
        visibleLines - the number of visible table items
        Returns:
        the required height
        Since:
        1.13
      • getTableViewer

        protected org.eclipse.jface.viewers.AbstractTableViewer getTableViewer()
        Returns the table viewer.
        Returns:
        the viewer
        Since:
        1.10
      • setTableViewer

        protected void setTableViewer​(org.eclipse.jface.viewers.AbstractTableViewer tableViewer)
        Sets the table viewer.
        Parameters:
        tableViewer - the viewer
        Since:
        1.10
      • viewerSelectionChanged

        protected void viewerSelectionChanged​(org.eclipse.jface.viewers.SelectionChangedEvent event)
        This method gets called when the selection on the TableViewer (see getTableViewer()) has changed.

        If you override this method make sure to call super.

        Parameters:
        event - the SelectionChangedEvent
      • getImage

        protected org.eclipse.swt.graphics.Image getImage​(java.net.URL url)
        Retrieve images from the ImageRegistryService using an URL.
        Parameters:
        url - The URL pointing to the image
        Returns:
        The retrieved Image
        Since:
        1.6
      • getImage

        protected org.eclipse.swt.graphics.Image getImage​(java.lang.String path)
        Retrieve images from the ImageRegistryService using a bundle relative path.
        Parameters:
        path - The bundle relative path pointing to the image
        Returns:
        The retrieved Image
        Since:
        1.6
      • getSWTColor

        protected org.eclipse.swt.graphics.Color getSWTColor​(java.lang.String colorHex)
        Returns the Color specified by the provided String.
        Parameters:
        colorHex - the Hex String describing the color
        Returns:
        the Color
        Since:
        1.10
      • getColumnDomainModelReferences

        protected org.eclipse.emf.common.util.EList<VDomainModelReference> getColumnDomainModelReferences()
        Retrieves this table's column DMRs from the table DMR.
        Returns:
        The domain model references defining the columns of this table.
        Since:
        1.19
      • createCellEditor

        protected org.eclipse.jface.viewers.CellEditor createCellEditor​(org.eclipse.emf.ecore.EObject tempInstance,
                                                                        org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                        org.eclipse.swt.widgets.Composite table)
        This is called in order to setup the editing support for a table column.
        Parameters:
        tempInstance - the temporary input instance of the table
        feature - the feature of the column
        table - the table/parent
        Returns:
        the cell editor
        Since:
        1.10
      • deleteRowUserConfirmDialog

        @Deprecated
        protected void deleteRowUserConfirmDialog​(java.util.List<org.eclipse.emf.ecore.EObject> deletionList,
                                                  org.eclipse.emf.ecore.EObject eObject,
                                                  org.eclipse.emf.ecore.EStructuralFeature structuralFeature,
                                                  org.eclipse.swt.widgets.Button addButton,
                                                  org.eclipse.swt.widgets.Button removeButton)
        Deprecated.
        this method will be moved to RemoveRowAction in the future
        This method shows a user confirmation dialog when the user attempts to delete a row in the table.
        Parameters:
        deletionList - the list of selected EObjects to delete
        eObject - The containment reference EObject
        structuralFeature - The containment reference EStructuralFeature
        addButton - the add button
        removeButton - the remove button
        Since:
        1.6
      • deleteRows

        @Deprecated
        protected void deleteRows​(java.util.List<org.eclipse.emf.ecore.EObject> deletionList,
                                  org.eclipse.emf.ecore.EObject eObject,
                                  org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Deprecated.
        this method will be moved to RemoveRowAction in the future
        This is called by #deleteRowUserConfirmDialog(List) after the user confirmed to delete the selected elements.
        Parameters:
        deletionList - the list of EObjects to delete
        eObject - The containment reference EObject
        structuralFeature - The containment reference EStructuralFeature
        Since:
        1.6
      • addRow

        @Deprecated
        protected void addRow​(org.eclipse.emf.ecore.EClass clazz,
                              org.eclipse.emf.ecore.EObject eObject,
                              org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Deprecated.
        this method will be move to AddRowAction in the future
        This method is called to add a new entry in the domain model and thus to create a new row in the table. The element to create is defined by the provided class. You can override this method but you have to call super nonetheless.
        Parameters:
        clazz - the EClass defining the EObject to create
        eObject - The containment reference EObject
        structuralFeature - The containment reference EStructuralFeature
        Since:
        1.6
      • postRefresh

        protected void postRefresh​(java.lang.Runnable refreshRunnable)
        Post a refresh request on the asynchronous refresh manager.
        Parameters:
        refreshRunnable - the refresh operation to execute
        Since:
        1.21
        See Also:
        ViewerRefreshManager
      • getAddButton

        @Deprecated
        protected org.eclipse.swt.widgets.Button getAddButton()
        Deprecated.
        Returns the add button created by the framework.
        Returns:
        the addButton
        Since:
        1.6
      • getRemoveButton

        @Deprecated
        protected org.eclipse.swt.widgets.Button getRemoveButton()
        Deprecated.
        Returns the remove button created by the framework.
        Returns:
        the removeButton
        Since:
        1.6
      • getControlForAction

        public Optional<org.eclipse.swt.widgets.Control> getControlForAction​(java.lang.String actionId)
        Returns the control created to trigger a certain action.
        Parameters:
        actionId - the action ID of the action that is bound to the control
        Returns:
        an optional for the control of the given action ID
        Since:
        1.18
      • getSettingFromObservable

        protected Optional<org.eclipse.emf.ecore.EStructuralFeature.Setting> getSettingFromObservable​(VDomainModelReference dmr,
                                                                                                      org.eclipse.emf.ecore.EObject eObject)
        Helper method which uses an EMFForms observable value to get the setting for the given VDomainModelReference.
        Parameters:
        dmr - the VDomainModelReference
        eObject - the EObject to get the setting for
        Returns:
        an Optional
        Since:
        1.17
      • updateActionBar

        protected void updateActionBar()
        Update this table control's action bar if it is present.
        Since:
        1.20
      • compare

        protected int compare​(org.eclipse.jface.viewers.Viewer viewer,
                              java.lang.Object left,
                              java.lang.Object right,
                              int direction,
                              int propertyIndex)
        Get called by the TableControlSWTRenderer.ECPTableViewerComparator in order to compare the given objects.
        Parameters:
        viewer - the table viewer
        left - the first object of the comparison
        right - the second object of the comparison
        propertyIndex - index of the selection column. the index is aligned with the index of the associated column domain model reference
        direction - 0 (no sorting = insertion order := SWT.NONE), 1 (ascending := SWT.DOWN) or 2 (descending := SWT.UP) according to the indication displayed at the table column.
        Returns:
        a negative number if the first element is less than the second element; the value 0 if the first element is equal to the second element; and a positive number if the first element is greater than the second element
        Since:
        1.8
      • canEditObject

        protected boolean canEditObject​(java.lang.Object element)
        Checks whether an element is editable or not.
        Parameters:
        element - The list entry to be checked
        Returns:
        True if the element can be edited, false otherwise
        Since:
        1.11
      • shouldCreateCellEditor

        protected boolean shouldCreateCellEditor​(java.lang.Object element)
        Defined whether a cell editor should be created or not.
        Parameters:
        element - The table entry to be checked
        Returns:
        True if a CellEditor should be created, false otherwise
        Since:
        1.12
      • createCellLabelProvider

        protected org.eclipse.jface.viewers.CellLabelProvider createCellLabelProvider​(org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                                      org.eclipse.jface.viewers.CellEditor cellEditor,
                                                                                      org.eclipse.core.databinding.observable.map.IObservableMap attributeMap,
                                                                                      VTableControl vTableControl,
                                                                                      VDomainModelReference dmr,
                                                                                      org.eclipse.swt.widgets.Control table)
        Parameters:
        feature - the feature of the column
        cellEditor - the cell editor for the column
        attributeMap - the attribute map displayed in the table
        vTableControl - the table view model element
        dmr - the domain model reference of the column
        table - the table control
        Returns:
        the CellLabelProvider of the column
        Since:
        1.12
      • getEnumeratorComparator

        protected FeatureAwareComparator<org.eclipse.emf.common.util.Enumerator> getEnumeratorComparator()
        Returns:
        The FeatureAwareComparator used to compare enum values when sorting the table
        Since:
        1.22
      • reveal

        public boolean reveal​(java.lang.Object object)
        Reeveal the given object in my table.
        Parameters:
        object - an object to reveal
        Returns:
        whether I succeeded in revealing it
        Since:
        1.22
      • formatTooltipText

        protected java.lang.String formatTooltipText​(org.eclipse.emf.ecore.EClass eClass,
                                                     java.lang.String messageKey)
        Localize the message.
        Parameters:
        eClass - The EClass of the table setting.
        messageKey - key of the string
        Returns:
        tooltip.
        Since:
        1.26
      • getSortColumnFeature

        protected java.util.Optional<org.eclipse.emf.ecore.EStructuralFeature> getSortColumnFeature()
        Returns the current sort column feature.
        Returns:
        an Optional containing the feature used for sorting
        Since:
        1.22
      • setSortColumnFeature

        protected void setSortColumnFeature​(org.eclipse.emf.ecore.EStructuralFeature sortColumnFeature)
        Set the column to use for sorting.
        Parameters:
        sortColumnFeature - an optional containing the feature to use for sorting
        Since:
        1.22
      • getColumnFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getColumnFeature​(int propertyIndex)
        Find the feature for a specific index.
        Parameters:
        propertyIndex - The index to find the feature for
        Returns:
        The EStructuralFeature for the provided index
        Since:
        1.22
      • getReferenceDisplayName

        protected java.lang.String getReferenceDisplayName​(org.eclipse.emf.ecore.EClassifier type)
        Obtains a user-presentable name for the reference that I edit, to be used for example in button tool-tips.
        Returns:
        the reference display name
        Since:
        1.25