Class MultiReferenceSWTRenderer

    • Method Detail

      • updateTableViewerInputList

        protected final org.eclipse.core.databinding.observable.list.IObservableList<?> updateTableViewerInputList()
                                                                                                            throws DatabindingFailedException
        Updates the table viewer's input observable list. Call this method in sub classes if you detect a change to the domain model which requires the re-resolvement of the input list.

        Note: This method only updates the input list but does not trigger button enablement etc.

        Returns:
        returns the new input list; might be empty but never null
        Throws:
        DatabindingFailedException - if the new list cannot be resolved
      • showAddExistingButton

        protected boolean showAddExistingButton()
        Returns true if the 'AddExisting' button is shown, false otherwise.
        Returns:
        true if the 'AddExisting' button is shown, false otherwise
      • showAddNewButton

        protected boolean showAddNewButton()
        Returns true if the 'AddNew' button is shown, false otherwise.
        Returns:
        true if the 'AddNew' button is shown, false otherwise
      • showDeleteButton

        protected boolean showDeleteButton()
        Returns true if the 'Delete' button is shown, false otherwise.
        Returns:
        true if the 'Delete' button is shown, false otherwise
      • showMoveUpButton

        protected boolean showMoveUpButton()
        Returns true if the 'MoveUp' button is shown, false otherwise. Returning true will disable any sorting behavior.
        Returns:
        true if the 'MoveUp' button is shown, false otherwise
      • showMoveDownButton

        protected boolean showMoveDownButton()
        Returns true if the 'MoveDown' button is shown, false otherwise. Returning true will disable any sorting behavior.
        Returns:
        true if the 'MoveDown' button is shown, false otherwise
      • getEStructuralFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getEStructuralFeature()
                                                                          throws DatabindingFailedException
        Returns the observed EStructuralFeature.
        Returns:
        the observed EStructuralFeature.
        Throws:
        DatabindingFailedException - when databinding fails.
      • getContainer

        protected java.util.Optional<org.eclipse.emf.ecore.EObject> getContainer()
        Returns the EObject that contains the elements rendered in this multi reference.
        Returns:
        The EObject containing the elements rendered in this multi reference or nothing if the container couldn't be computed.
      • createControlComposite

        protected org.eclipse.swt.widgets.Composite createControlComposite​(org.eclipse.swt.widgets.Composite composite)
        Creates the composite which will be the parent for the table.
        Parameters:
        composite - the parent composite
        Returns:
        the table composite
      • getTableHeightHint

        protected int getTableHeightHint()
        Returns the height for the table that will be created.
        Returns:
        the height hint
      • getTableViewer

        protected org.eclipse.jface.viewers.TableViewer getTableViewer()
        Gives access to the tableViewer used to display the attributes.
        Returns:
        the viewer
      • createErrorLabel

        protected org.eclipse.swt.widgets.Control createErrorLabel​(org.eclipse.swt.widgets.Composite parent,
                                                                   java.lang.Exception ex)
        Creates an error label for the given Exception.
        Parameters:
        parent - The parent of the Label
        ex - The Exception causing the error
        Returns:
        The error Label
      • createAdapterFactory

        protected org.eclipse.emf.common.notify.AdapterFactory createAdapterFactory()
        Creates a new AdapterFactory.
        Returns:
        the newly created AdapterFactory.
      • getAdapterFactory

        protected final org.eclipse.emf.common.notify.AdapterFactory getAdapterFactory()
        Returns the AdapterFactory used by this renderer. To customize the used AdapterFactory override createAdapterFactory().
        Returns:
        The AdapterFactory used by this renderer
        See Also:
        createAdapterFactory()
      • createLabelProvider

        protected org.eclipse.jface.viewers.ILabelProvider createLabelProvider()
        Creates a new ILabelProvider for the table viewer.
        Returns:
        the newly created ILabelProvider.
      • createMoveUpButton

        protected org.eclipse.swt.widgets.Button createMoveUpButton​(org.eclipse.swt.widgets.Composite parent,
                                                                    org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Creates a button that enables reordering the references by the given EStructuralFeature.
        Parameters:
        parent - The parent of the created Button
        structuralFeature - The EStructuralFeature which's references are moved up.
        Returns:
        The newly created Button
      • createMoveDownButton

        protected org.eclipse.swt.widgets.Button createMoveDownButton​(org.eclipse.swt.widgets.Composite parent,
                                                                      org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Creates a button that enables reordering the references by the given EStructuralFeature.
        Parameters:
        parent - The parent of the created Button
        structuralFeature - The EStructuralFeature which's references are moved down.
        Returns:
        The newly created Button
      • createAddExistingButton

        protected org.eclipse.swt.widgets.Button createAddExistingButton​(org.eclipse.swt.widgets.Composite parent,
                                                                         org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Creates a button that enables the addition of existing references to the given EStructuralFeature.
        Parameters:
        parent - The parent of the created Button
        structuralFeature - The EStructuralFeature to which references are added
        Returns:
        The newly created Button
      • createAddNewButton

        protected org.eclipse.swt.widgets.Button createAddNewButton​(org.eclipse.swt.widgets.Composite parent,
                                                                    org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Creates a button that enables the addition of newly created references to the given EStructuralFeature.
        Parameters:
        parent - The parent of the created Button
        structuralFeature - The EStructuralFeature to which references are added
        Returns:
        The newly created Button
      • createDeleteButton

        protected org.eclipse.swt.widgets.Button createDeleteButton​(org.eclipse.swt.widgets.Composite parent,
                                                                    org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Creates a button that enables the removal of existing references from the given EStructuralFeature.
        Parameters:
        parent - The parent of the newly created Button
        structuralFeature - The EStructuralFeature from which references are removed
        Returns:
        The newly created Button
      • updateButtons

        protected void updateButtons()
        Updates button visibility and enablement.
      • updateButtonEnabling

        protected void updateButtonEnabling()
        Updates the enablement of 'addExisting', 'addNew', 'delete', 'moveUp' and 'moveDown' buttons according to the bound input.
      • updateButtonVisibility

        protected void updateButtonVisibility()
        Updates the visibility of 'addExisting', 'addNew', 'delete', 'moveUp' and 'moveDown' buttons according to the bound input.
      • createButtonComposite

        protected org.eclipse.swt.widgets.Composite createButtonComposite​(org.eclipse.swt.widgets.Composite parent)
                                                                   throws DatabindingFailedException
        Adds a composite with the buttons 'AddExisting', 'AddNew' and 'Delete' to the given Composite if necessary.
        Parameters:
        parent - The parent of the created Composite
        Returns:
        the created Composite
        Throws:
        DatabindingFailedException - thrown if the databinding could not be executed successfully
      • createTitleComposite

        protected void createTitleComposite​(org.eclipse.swt.widgets.Composite parent)
                                     throws DatabindingFailedException
        Creates a composite with a label, a validation icon and a button composite.
        Parameters:
        parent - The parent of the created Composite
        Throws:
        DatabindingFailedException - thrown if the databinding could not be executed successfully
      • getImage

        protected org.eclipse.swt.graphics.Image getImage​(java.lang.String path)
        Returns an Image from the image registry.
        Parameters:
        path - the path to the image
        Returns:
        the image
      • getReferenceDisplayName

        protected java.lang.String getReferenceDisplayName()
        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.16
      • handleDoubleClick

        protected void handleDoubleClick​(org.eclipse.emf.ecore.EObject selectedObject)
        Method for handling a double click.
        Parameters:
        selectedObject - the selected EObject
      • handleAddExisting

        protected void handleAddExisting​(org.eclipse.jface.viewers.TableViewer tableViewer,
                                         org.eclipse.emf.ecore.EObject eObject,
                                         org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Method for adding an existing element.
        Parameters:
        tableViewer - the TableViewer
        eObject - The EObject to add to
        structuralFeature - The corresponding EStructuralFeature
      • handleAddNew

        protected void handleAddNew​(org.eclipse.jface.viewers.TableViewer tableViewer,
                                    org.eclipse.emf.ecore.EObject eObject,
                                    org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Method for adding a new element.
        Parameters:
        tableViewer - the TableViewer
        eObject - The EObject to add to
        structuralFeature - The corresponding EStructuralFeature
      • getReferenceService

        protected ReferenceService getReferenceService()
        Override to customize linking and creation of EObjects in this renderer's EReference.
        Returns:
        The ReferenceService used to link and create new EObjects in this renderer's reference.
      • handleDelete

        protected void handleDelete​(org.eclipse.jface.viewers.TableViewer tableViewer,
                                    org.eclipse.emf.ecore.EObject eObject,
                                    org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Method for deleting elements.
        Parameters:
        tableViewer - the TableViewer
        eObject - The EObject to delete from
        structuralFeature - The corresponding EStructuralFeature
      • handleMoveUp

        protected void handleMoveUp​(org.eclipse.jface.viewers.TableViewer tableViewer,
                                    org.eclipse.emf.ecore.EObject eObject,
                                    org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Method for moving up elements.
        Parameters:
        tableViewer - the TableViewer
        eObject - The EObject to delete from
        structuralFeature - The corresponding EStructuralFeature
      • handleMoveDown

        protected void handleMoveDown​(org.eclipse.jface.viewers.TableViewer tableViewer,
                                      org.eclipse.emf.ecore.EObject eObject,
                                      org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
        Method for moving down elements.
        Parameters:
        tableViewer - the TableViewer
        eObject - The EObject to delete from
        structuralFeature - The corresponding EStructuralFeature
      • getReferencedElementsList

        protected org.eclipse.core.databinding.observable.list.IObservableList<?> getReferencedElementsList()
                                                                                                     throws DatabindingFailedException
        Computes and returns the observable list of the referenced elements shown by this renderer.
        Returns:
        The IObservableList of the referenced elements
        Throws:
        DatabindingFailedException - If computing the list failed due to failed databinding
      • compare

        protected int compare​(int direction,
                              java.lang.Object object1,
                              java.lang.Object object2)

        Sorts two objects based on their labels and the given sorting direction.

        Override this method to provide a custom sorting algorithm for the objects shown in this control's table.

        Parameters:
        direction - The sorting direction: 0 == NONE, 1 == UP, 2 == DOWN
        object1 - The first object of the comparison
        object2 - The second object of the comparison
        Returns:
        0 if both objects are equal, -1 if object1 will appear higher in the table, 1 if object2 will appear higher in the table
      • getLabelProvider

        protected org.eclipse.jface.viewers.ILabelProvider getLabelProvider()
        Returns the ILabelProvider used by this renderer.
        Returns:
        the ILabelProvider