Class SaveableCompareEditorInput

    • Constructor Detail

      • SaveableCompareEditorInput

        public SaveableCompareEditorInput​(CompareConfiguration configuration,
                                          IWorkbenchPage page)
        Creates a LocalResourceCompareEditorInput which is initialized with the given compare configuration. The compare configuration is passed to subsequently created viewers.
        Parameters:
        configuration - the compare configuration
        page - the workbench page that will contain the editor
    • Method Detail

      • createFileElement

        public static ITypedElement createFileElement​(IFile file)
        Returns a typed element that represents a local file. If the element returned from this method is used as the left contributor of the compare input for a SaveableCompareEditorInput, then the file will be properly saved when the compare editor input or viewers are saved.
        Parameters:
        file - the file
        Returns:
        a typed element that represents a local file.
      • contentsCreated

        protected void contentsCreated()
        Description copied from class: CompareEditorInput
        Callback that occurs after the control for the input has been created. If this method gets invoked then CompareEditorInput.handleDispose() will be invoked when the control is disposed. Subclasses may extend this method to register any listeners that need to be de-registered when the input is disposed.
        Overrides:
        contentsCreated in class CompareEditorInput
      • prepareInput

        protected Object prepareInput​(IProgressMonitor monitor)
                               throws InvocationTargetException,
                                      InterruptedException
        Prepares the compare input of this editor input. This method is not intended to be overridden of extended by subclasses (but is not final for backwards compatibility reasons). The implementation of this method in this class delegates the creation of the compare input to the prepareCompareInput(IProgressMonitor) method which subclasses must implement.
        Specified by:
        prepareInput in class CompareEditorInput
        Parameters:
        monitor - the progress monitor to use to display progress and receive requests for cancellation
        Returns:
        the result of the compare operation, or null if there are no differences
        Throws:
        InvocationTargetException - if the prepareInput method must propagate a checked exception, it should wrap it inside an InvocationTargetException; runtime exceptions are automatically wrapped in an InvocationTargetException by the calling context
        InterruptedException - if the operation detects a request to cancel, using IProgressMonitor.isCanceled(), it should exit by throwing InterruptedException
        See Also:
        CompareEditorInput.prepareInput(IProgressMonitor)
      • getCompareInput

        protected final ICompareInput getCompareInput()
        Returns the compare input of this editor input.
        Returns:
        the compare input of this editor input
      • fireInputChange

        protected abstract void fireInputChange()
        Callback from the resource saveable that is invoked when the resource is saved so that this input can fire a change event for its input. Subclasses only need this method if the left side of their compare input is an element returned from createFileElement(IFile).
      • closeEditor

        protected boolean closeEditor​(boolean checkForUnsavedChanges)
        Close the editor if it is not dirty. If it is still dirty, let the content merge viewer handle the compare input change.
        Parameters:
        checkForUnsavedChanges - whether to check for unsaved changes
        Returns:
        true if the editor was closed (note that the close may be asynchronous)
      • createSaveable

        protected Saveable createSaveable()
        Create the saveable that provides the save behavior for this compare editor input. By default, a saveable that handles local files is returned.
        Returns:
        the saveable that provides the save behavior for this compare editor input
      • getActiveSaveables

        public Saveable[] getActiveSaveables()
        Description copied from interface: ISaveablesSource
        Returns the saveables currently active in the workbench part.

        Certain workbench actions, such as Save, target only the active saveables in the active part. For example, the active saveables could be determined based on the current selection in the part.

        Specified by:
        getActiveSaveables in interface ISaveablesSource
        Returns:
        the saveables currently active in the workbench part
      • getAdapter

        public <T> T getAdapter​(Class<T> adapter)
        Description copied from class: PlatformObject
        Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

        This implementation of the method declared by IAdaptable passes the request along to the platform's adapter manager; roughly Platform.getAdapterManager().getAdapter(this, adapter). Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

        Specified by:
        getAdapter in interface IAdaptable
        Overrides:
        getAdapter in class CompareEditorInput
        Type Parameters:
        T - the class type
        Parameters:
        adapter - the class to adapt to
        Returns:
        the adapted object or null
        See Also:
        IAdaptable.getAdapter(Class)
      • getTitleImage

        public Image getTitleImage()
        Description copied from class: CompareEditorInput
        Returns the title image which will be used in the compare editor's title bar. Returns the title image which will be used when presenting the compare result. This implementation returns a generic compare icon. Subclasses can override.
        Overrides:
        getTitleImage in class CompareEditorInput
        Returns:
        the title image, or null if none
      • getImageDescriptor

        public ImageDescriptor getImageDescriptor()
        Description copied from interface: IEditorInput
        Returns the image descriptor for this input.

        Note: although a null return value has never been permitted from this method, there are many known buggy implementations that return null. Clients that need the image for an editor are advised to use IWorkbenchPart.getImage() instead of IEditorInput.getImageDescriptor(), or to recover from a null return value in a manner that records the ID of the problematic editor input. Implementors that have been returning null from this method should pick some other default return value (such as ImageDescriptor.getMissingImageDescriptor()).

        Specified by:
        getImageDescriptor in interface IEditorInput
        Overrides:
        getImageDescriptor in class CompareEditorInput
        Returns:
        the image descriptor for this input; may be null if there is no image.
      • findContentViewer

        public Viewer findContentViewer​(Viewer oldViewer,
                                        ICompareInput input,
                                        Composite parent)
        Description copied from class: CompareEditorInput
        Implements the dynamic viewer switching for content viewers. The method must return a compare viewer based on the old (or current) viewer and a new input object. If the old viewer is suitable for showing the new input the old viewer can be returned. Otherwise a new viewer must be created under the given parent composite or null can be returned to indicate that no viewer could be found.

        This implementation forwards the request to CompareUI.findContentViewer.

        Subclasses may override to implement a different strategy.

        Overrides:
        findContentViewer in class CompareEditorInput
        Parameters:
        oldViewer - a new viewer is only created if this old viewer cannot show the given input
        input - the input object for which to find a structure viewer
        parent - the SWT parent composite under which the new viewer is created
        Returns:
        a compare viewer which is suitable for the given input object or null
      • isDirty

        public boolean isDirty()
        Description copied from class: CompareEditorInput
        Returns true if there are unsaved changes. The method should be called by any parts or dialogs that contain the input. By default, this method calls CompareEditorInput.isSaveNeeded() but subclasses may extend.
        Overrides:
        isDirty in class CompareEditorInput
        Returns:
        true if there are unsaved changes