Class ModelParticipantAction

    • Constructor Detail

      • ModelParticipantAction

        public ModelParticipantAction​(String text,
                                      ISynchronizePageConfiguration configuration)
        Create the model participant action.
        Parameters:
        text - the label of the action or null
        configuration - the configuration for the page that is surfacing the action
    • Method Detail

      • selectionChanged

        public void selectionChanged​(ISelection selection)
        Set the selection of this action to the given selection
        Parameters:
        selection - the selection
      • updateSelection

        protected boolean updateSelection​(IStructuredSelection selection)
        Description copied from class: BaseSelectionListenerAction
        Updates this action in response to the given selection.

        The BaseSelectionListenerAction implementation of this method returns true. Subclasses may extend to react to selection changes; however, if the super method returns false, the overriding method must also return false.

        Overrides:
        updateSelection in class BaseSelectionListenerAction
        Parameters:
        selection - the new selection
        Returns:
        true if the action should be enabled for this selection, and false otherwise
      • isEnabledForSelection

        protected abstract boolean isEnabledForSelection​(IStructuredSelection selection)
        Return whether the action is enabled for the given selection
        Parameters:
        selection - the selection
        Returns:
        whether the action is enabled for the given selection
      • getSynchronizationContext

        protected ISynchronizationContext getSynchronizationContext()
        Return the synchronization context associated with this action.
        Returns:
        the synchronization context associated with this action
      • isVisible

        protected boolean isVisible​(IDiff node)
        Return whether the given node is visible in the page based on the mode in the configuration.
        Parameters:
        node - a diff node
        Returns:
        whether the given node is visible in the page
      • handleTargetSaveableChange

        public static void handleTargetSaveableChange​(Shell shell,
                                                      SaveableComparison targetSaveable,
                                                      SaveableComparison activeSaveable,
                                                      boolean allowCancel,
                                                      IProgressMonitor monitor)
                                               throws CoreException,
                                                      InterruptedException
        Convenience method that prompts if the currently active saveable is dirty and either saves or reverts the saveable depending on the users input.
        Parameters:
        shell - a parent shell
        targetSaveable - the new saveable
        activeSaveable - the current saveable
        allowCancel - whether canceling the action is an option
        monitor - a progress monitor
        Throws:
        CoreException
        InterruptedException
      • promptToSaveChanges

        public static boolean promptToSaveChanges​(Shell shell,
                                                  SaveableComparison saveable,
                                                  boolean allowCancel)
                                           throws InterruptedException
        Convenience method that prompts to save changes in the given dirty model.
        Parameters:
        shell - a shell
        saveable - a dirty saveable model
        allowCancel - whether canceling the action is an option
        Returns:
        whether the user choose to save (true) or revert (false() the model
        Throws:
        InterruptedException - thrown if the user choose to cancel
      • getActiveSaveable

        protected SaveableComparison getActiveSaveable()
        Return the currently active saveable. By default, the active saveable is obtained from the synchronization page configuration.
        Returns:
        the currently active saveable (or null if no buffer is active).
      • setActiveSaveable

        protected void setActiveSaveable​(SaveableComparison saveable)
        Set the active saveable. By default to active saveable is stored with the synchronize page configuration.
        Parameters:
        saveable - the saveable that is now active (or null if no saveable is active).
      • getTargetSaveable

        protected SaveableComparison getTargetSaveable()
        Return the saveable that is the target of this operation. By default, null is returned.
        Returns:
        the saveable that is the target of this operation
      • updateEnablement

        public void updateEnablement()
        Method called when the action is about to be shown in a context menu. This method recalculates the enablement for the current selection and uses that to set the enablement.