Eclipse Platform
Release 3.3

org.eclipse.compare
Class CompareViewerSwitchingPane

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.eclipse.swt.custom.ViewForm
                      extended byorg.eclipse.compare.CompareViewerPane
                          extended byorg.eclipse.compare.CompareViewerSwitchingPane
All Implemented Interfaces:
Drawable, IAdaptable, IDoubleClickListener, IOpenListener, ISelectionChangedListener, ISelectionProvider

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

Field Summary
 
Fields inherited from class org.eclipse.swt.custom.ViewForm
borderInsideRGB, borderMiddleRGB, borderOutsideRGB, horizontalSpacing, marginHeight, marginWidth, verticalSpacing
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
CompareViewerSwitchingPane(Composite parent, int style)
          Creates a CompareViewerSwitchingPane as a child of the given parent and with the specified SWT style bits.
CompareViewerSwitchingPane(Composite parent, int style, boolean visibility)
          Creates a CompareViewerSwitchingPane as a child of the given parent and with the specified SWT style bits.
 
Method Summary
 Object getAdapter(Class adapter)
          
 ISelection getSelection()
          Returns the current selection for this provider.
 String getTitleArgument()
          Returns the optional title argument that has been set with setTitelArgument or null if no optional title argument has been set.
 Viewer getViewer()
          Returns the current viewer.
protected abstract  Viewer getViewer(Viewer oldViewer, Object input)
          Returns a viewer which is able to display the given input.
 boolean isEmpty()
          Returns true if no viewer is installed or if the current viewer is a NullViewer.
 boolean setFocus()
          Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it.
 void setInput(Object input)
          Sets the input object of this pane.
 void setSelection(ISelection s)
          Sets the current selection for this selection provider.
 void setTitleArgument(String argument)
          Sets an additional and optional argument for the pane's title.
 
Methods inherited from class org.eclipse.compare.CompareViewerPane
addDoubleClickListener, addOpenListener, addSelectionChangedListener, clearToolBar, doubleClick, getInput, getToolBarManager, open, removeDoubleClickListener, removeOpenListener, removeSelectionChangedListener, selectionChanged, setImage, setText
 
Methods inherited from class org.eclipse.swt.custom.ViewForm
computeTrim, getClientArea, getContent, getTopCenter, getTopLeft, getTopRight, setBorderVisible, setContent, setLayout, setTopCenter, setTopCenterSeparate, setTopLeft, setTopRight
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 -
SWTException -

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 -
SWTException -
Method Detail

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.

Note: this method is for internal use only. Clients should not call this method.

Returns:
the optional title argument or null

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

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

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. Note: this method is for internal use only. Clients should not call this method.

Parameters:
argument - an optional argument for the pane's title

getAdapter

public Object getAdapter(Class adapter)

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class CompareViewerPane
Since:
3.3
See Also:
IAdaptable.getAdapter(java.lang.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

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

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.