Eclipse Platform
2.0

org.eclipse.compare.structuremergeviewer
Class StructureDiffViewer

java.lang.Object
  |
  +--org.eclipse.jface.viewers.Viewer
        |
        +--org.eclipse.jface.viewers.ContentViewer
              |
              +--org.eclipse.jface.viewers.StructuredViewer
                    |
                    +--org.eclipse.jface.viewers.AbstractTreeViewer
                          |
                          +--org.eclipse.jface.viewers.TreeViewer
                                |
                                +--org.eclipse.compare.structuremergeviewer.DiffTreeViewer
                                      |
                                      +--org.eclipse.compare.structuremergeviewer.StructureDiffViewer
All Implemented Interfaces:
IInputProvider, IInputSelectionProvider, ISelectionProvider

public class StructureDiffViewer
extends DiffTreeViewer

A diff tree viewer that can be configured with a IStructureCreator to retrieve a hierarchical structure from the input object (an ICompareInput) and perform a two-way or three-way compare on it.

This class may be instantiated; it is not intended to be subclassed outside this package.

See Also:
IStructureCreator, ICompareInput

Field Summary
 
Fields inherited from class org.eclipse.jface.viewers.AbstractTreeViewer
ALL_LEVELS
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Constructor Summary
StructureDiffViewer(Composite parent, CompareConfiguration configuration)
          Creates a new viewer under the given SWT parent with the specified configuration.
StructureDiffViewer(Tree tree, CompareConfiguration configuration)
          Creates a new viewer for the given SWT tree control with the specified configuration.
 
Method Summary
protected  void compareInputChanged(ICompareInput input)
          Recreates the comparable structures for the input sides.
protected  void contentChanged(IContentChangeNotifier changed)
          Calls diff whenever the byte contents changes.
protected  void copySelected(boolean leftToRight)
          Overridden to call the save method on the structure creator after nodes have been copied from one side to the other side of an input object.
protected  void diff()
          Runs the difference engine and refreshes the tree.
protected  Object getRoot()
          Overridden because the input of this viewer is not identical to the root of the tree.
 IStructureCreator getStructureCreator()
          Returns the structure creator or null if no structure creator has been set with setStructureCreator.
 String getTitle()
          Reimplemented to get the descriptive title for this viewer from the IStructureCreator.
protected  void handleDispose(DisposeEvent event)
          Called on the viewer disposal.
protected  void initialSelection()
          This hook method is called from within inputChanged after a new input has been set but before any controls are updated.
protected  void inputChanged(Object input, Object oldInput)
          Overridden to create the comparable structures from the input object and to feed them through the differencing engine.
protected  void postDiffHook(Differencer differencer, IDiffContainer root)
          This method is called from within diff() after the difference tree has been built.
protected  void preDiffHook(IStructureComparator ancestor, IStructureComparator left, IStructureComparator right)
          This method is called from within diff() before the difference tree is being built.
protected  void propertyChange(PropertyChangeEvent event)
          Tracks property changes of the configuration object.
 void setStructureCreator(IStructureCreator structureCreator)
          Configures the StructureDiffViewer with a structure creator.
 
Methods inherited from class org.eclipse.compare.structuremergeviewer.DiffTreeViewer
copyOne, createToolItems, dontExpand, expandSelection, fillContextMenu, getBundle, getCompareConfiguration, internalExpandToLevel, navigate
 
Methods inherited from class org.eclipse.jface.viewers.TreeViewer
addTreeListener, doUpdateItem, getChildren, getControl, getExpanded, getItem, getItemCount, getItemCount, getItems, getLabelProvider, getParentItem, getSelection, getTree, newItem, removeAll, setExpanded, setLabelProvider, setSelection, showItem
 
Methods inherited from class org.eclipse.jface.viewers.AbstractTreeViewer
add, add, addSelectionListener, addTreeListener, collapseAll, collapseToLevel, createChildren, createTreeItem, disassociate, doFindInputItem, doFindItem, doUpdateItem, expandAll, expandToLevel, expandToLevel, fireTreeCollapsed, fireTreeExpanded, getAutoExpandLevel, getExpandedElements, getExpandedState, getNextItem, getPreviousItem, getRawChildren, getSelectionFromWidget, getVisibleExpandedElements, handleTreeCollapse, handleTreeExpand, hookControl, internalCollapseToLevel, internalExpand, internalRefresh, isExpandable, labelProviderChanged, remove, remove, removeTreeListener, reveal, scrollDown, scrollUp, setAutoExpandLevel, setContentProvider, setExpandedElements, setExpandedState, setSelectionToWidget, updateChildren, updatePlus
 
Methods inherited from class org.eclipse.jface.viewers.StructuredViewer
addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, associate, filter, findItem, fireDoubleClick, fireOpen, firePostSelectionChanged, getFilteredChildren, getFilters, getSelection, getSortedChildren, getSorter, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, internalRefresh, mapElement, needsRefilter, preservingSelection, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setInput, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMap
 
Methods inherited from class org.eclipse.jface.viewers.ContentViewer
getContentProvider, getInput
 
Methods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructureDiffViewer

public StructureDiffViewer(Tree tree,
                           CompareConfiguration configuration)
Creates a new viewer for the given SWT tree control with the specified configuration.

Parameters:
tree - the tree control
configuration - the configuration for this viewer

StructureDiffViewer

public StructureDiffViewer(Composite parent,
                           CompareConfiguration configuration)
Creates a new viewer under the given SWT parent with the specified configuration.

Parameters:
parent - the SWT control under which to create the viewer
configuration - the configuration for this viewer
Method Detail

setStructureCreator

public void setStructureCreator(IStructureCreator structureCreator)
Configures the StructureDiffViewer with a structure creator. The structure creator is used to create a hierarchical structure for each side of the viewer's input element of type ICompareInput.

Parameters:
structureCreator - the new structure creator

getStructureCreator

public IStructureCreator getStructureCreator()
Returns the structure creator or null if no structure creator has been set with setStructureCreator.

Returns:
the structure creator or null

getTitle

public String getTitle()
Reimplemented to get the descriptive title for this viewer from the IStructureCreator.

Overrides:
getTitle in class DiffTreeViewer
Returns:
the viewer's name

getRoot

protected Object getRoot()
Overridden because the input of this viewer is not identical to the root of the tree. The tree's root is a IDiffContainer that was returned from the method diff.

Overrides:
getRoot in class StructuredViewer
Returns:
the root of the diff tree produced by method diff

inputChanged

protected void inputChanged(Object input,
                            Object oldInput)
Overridden to create the comparable structures from the input object and to feed them through the differencing engine. Note: for this viewer the value from getInput is not identical to getRoot.

Overrides:
inputChanged in class DiffTreeViewer
Parameters:
input - the new input of this viewer, or null if none
oldInput - the old input element or null if there was previously no input

initialSelection

protected void initialSelection()
Description copied from class: DiffTreeViewer
This hook method is called from within inputChanged after a new input has been set but before any controls are updated. This default implementation calls navigate(true) to select and expand the first leaf node. Clients can override this method and are free to decide whether they want to call the inherited method.

Overrides:
initialSelection in class DiffTreeViewer

handleDispose

protected void handleDispose(DisposeEvent event)
Description copied from class: DiffTreeViewer
Called on the viewer disposal. Unregisters from the compare configuration. Clients may extend if they have to do additional cleanup.

Overrides:
handleDispose in class DiffTreeViewer
Parameters:
event - a dispose event

compareInputChanged

protected void compareInputChanged(ICompareInput input)
Recreates the comparable structures for the input sides.


contentChanged

protected void contentChanged(IContentChangeNotifier changed)
Calls diff whenever the byte contents changes.


preDiffHook

protected void preDiffHook(IStructureComparator ancestor,
                           IStructureComparator left,
                           IStructureComparator right)
This method is called from within diff() before the difference tree is being built. Clients may override this method to perform their own pre-processing. This default implementation does nothing.

Parameters:
ancestor - the ancestor input to the differencing operation
left - the left input to the differencing operation
right - the right input to the differencing operation
Since:
2.0

diff

protected void diff()
Runs the difference engine and refreshes the tree.


postDiffHook

protected void postDiffHook(Differencer differencer,
                            IDiffContainer root)
This method is called from within diff() after the difference tree has been built. Clients may override this method to perform their own post-processing. This default implementation does nothing.

Parameters:
differencer - the differencer used to perform the differencing
root - the non-null root node of the difference tree
Since:
2.0

propertyChange

protected void propertyChange(PropertyChangeEvent event)
Tracks property changes of the configuration object. Clients may override to track their own property changes. In this case they must call the inherited method.

Overrides:
propertyChange in class DiffTreeViewer

copySelected

protected void copySelected(boolean leftToRight)
Overridden to call the save method on the structure creator after nodes have been copied from one side to the other side of an input object.

Overrides:
copySelected in class DiffTreeViewer
Parameters:
leftToRight - if true the left side is copied to the right side. If false the right side is copied to the left side

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.