Class CompareViewerSwitchingPane

All Implemented Interfaces:
IAdaptable, IDoubleClickListener, IOpenListener, ISelectionChangedListener, ISelectionProvider, Drawable
Direct Known Subclasses:
CompareContentViewerSwitchingPane, CompareStructureViewerSwitchingPane

public abstract class CompareViewerSwitchingPane extends CompareViewerPane
A custom CompareViewerPane that supports dynamic viewer switching.

Clients must implement the viewer switching strategy by implementing the getViewer(Viewer, Object) method.

If a property with the name CompareUI.COMPARE_VIEWER_TITLE is set on the top level SWT control of a viewer, it is used as a title in the CompareViewerPane's title bar.

Since:
2.0
  • Constructor Details

    • CompareViewerSwitchingPane

      public CompareViewerSwitchingPane(Composite parent, int style)
      Creates a CompareViewerSwitchingPane as a child of the given parent and with the specified SWT style bits.
      Parameters:
      parent - a widget which will be the parent of the new instance (cannot be null)
      style - the style of widget to construct
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
    • CompareViewerSwitchingPane

      public CompareViewerSwitchingPane(Composite parent, int style, boolean visibility)
      Creates a CompareViewerSwitchingPane as a child of the given parent and with the specified SWT style bits.
      Parameters:
      parent - a widget which will be the parent of the new instance (cannot be null)
      style - the style of widget to construct
      visibility - the initial visibility of the CompareViewerSwitchingPane
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • Method Details

    • getViewer

      public Viewer getViewer()
      Returns the current viewer.
      Returns:
      the current viewer
    • getTitleArgument

      public String getTitleArgument()
      Returns the optional title argument that has been set with setTitelArgument or null if no optional title argument has been set.
      Returns:
      the optional title argument or null
      Restriction:
      This method is for internal use only. Clients should not call this method.
      Restriction:
      This method is not intended to be re-implemented or extended by clients.
    • isEmpty

      public boolean isEmpty()
      Returns true if no viewer is installed or if the current viewer is a NullViewer.
      Returns:
      true if no viewer is installed or if the current viewer is a NullViewer
    • getSelection

      public ISelection getSelection()
      Description copied from interface: ISelectionProvider
      Returns the current selection for this provider.
      Specified by:
      getSelection in interface ISelectionProvider
      Overrides:
      getSelection in class CompareViewerPane
      Returns:
      the current selection
    • setSelection

      public void setSelection(ISelection s)
      Description copied from interface: ISelectionProvider
      Sets the current selection for this selection provider.
      Specified by:
      setSelection in interface ISelectionProvider
      Overrides:
      setSelection in class CompareViewerPane
      Parameters:
      s - the new selection
    • inputChanged

      protected boolean inputChanged(Object input)
      Parameters:
      input - the input
      Returns:
      true, if the input is considered as changed
      Restriction:
      This method is not intended to be referenced by clients.
      Restriction:
      This method is not intended to be re-implemented or extended by clients.
    • setInput

      public void setInput(Object input)
      Sets the input object of this pane. For this input object a suitable viewer is determined by calling the abstract method getViewer(Viewer, Object). If the returned viewer differs from the current one, the old viewer is disposed and the new one installed. Then the input object is fed into the newly installed viewer by calling its setInput(Object) method. If new and old viewer don't differ no new viewer is installed but just setInput(Object) is called. If the input is null the pane is cleared, that is the current viewer is disposed.
      Overrides:
      setInput in class CompareViewerPane
      Parameters:
      input - the new input object or null
    • setTitleArgument

      public void setTitleArgument(String argument)
      Sets an additional and optional argument for the pane's title.
      Parameters:
      argument - an optional argument for the pane's title
      Restriction:
      This method is for internal use only. Clients should not call this method.
      Restriction:
      This method is not intended to be re-implemented or extended by clients.
    • getAdapter

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

      Clients may implement this method but should generally call Adapters.adapt(Object, Class, boolean) rather than invoking it directly.

      Specified by:
      getAdapter in interface IAdaptable
      Overrides:
      getAdapter in class CompareViewerPane
      Type Parameters:
      T - the class type
      Parameters:
      adapter - the adapter class to look up
      Returns:
      a object of the given class, or null if this object does not have an adapter for the given class
    • setFocus

      public boolean setFocus()
      Description copied from class: Control
      Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it. Focus reassignment will respect applicable platform constraints.
      Overrides:
      setFocus in class Composite
      Returns:
      true if the control got focus, and false if it was unable to.
      See Also:
    • getViewer

      protected abstract Viewer getViewer(Viewer oldViewer, Object input)
      Returns a viewer which is able to display the given input. If no viewer can be found, null is returned. The additional argument oldViewer represents the viewer currently installed in the pane (or null if no viewer is installed). It can be returned from this method if the current viewer can deal with the input (and no new viewer must be created).
      Parameters:
      oldViewer - the currently installed viewer or null
      input - the input object for which a viewer must be determined or null
      Returns:
      a viewer for the given input, or null if no viewer can be determined