org.infai.emo.matcher.editor.pages
Class DifferencePage

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.infai.emo.matcher.editor.pages.DifferencePage
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class DifferencePage
extends org.eclipse.swt.widgets.Composite

This class describes the page of the ModelMatcherEditor that contains the mapping and the difference-model.
It consists of two trees at the top of the page that are connected with a canvas and a tree that contains the diff-model at the bottom.

Version:
1.0.0
Author:
Stanley Hillner
See Also:
Composite

Field Summary
private  org.eclipse.swt.widgets.Composite comp
          The Composite on which the GUI is placed.
private  org.eclipse.jface.viewers.TreeViewer differencesTreeV
          The TreeViewer which contains the diff-model.
private  DiffModel diffModel
          This model contains the differences of both input-models.
private  ModelMatcherEditor editor
          The editor that contains this page.
private  org.eclipse.swt.widgets.Tree leftTree
          The tree which contains the left model of the mapping.
private  org.eclipse.jface.viewers.TreeViewer leftTreeV
          The TreeViewer which contains the tree for the left model of the mapping.
private  int leftTreeV_OldVBarSelection
          The position of the vertical ScrollBar of the leftTreeV.
private  java.util.Vector<Line> lines
          This Vector contains all currently drawn mapping-lines from the sash.
private  MapModel mapModel
          The model that contains the mapping between both compared input-models.
private  org.eclipse.swt.widgets.Tree rightTree
          The tree which contains the right model of the mapping.
private  org.eclipse.jface.viewers.TreeViewer rightTreeV
          The TreeViewer which contains the tree for the right model of the mapping.
private  int rightTreeV_OldVBarSelection
          The position of the vertical ScrollBar of the rightTreeV.
private  org.eclipse.swt.widgets.Sash sash
          This is the sash that divides the mapping-part of this page.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
DifferencePage(org.eclipse.swt.widgets.Composite parent, int style, ModelMatcherEditor e)
          The constructor for creating a new DifferencePage.
 
Method Summary
private  void analyseGroup(Group group, org.eclipse.swt.widgets.TreeItem groupItem)
          Method analyzes a Group-element from the diff-model and builds its children in the tree.
private  org.eclipse.swt.widgets.TreeItem createDiffTreeItem(org.eclipse.swt.widgets.TreeItem parentItem, DiffElement element)
          This method creates a single element for the differencesTreeV.
private  java.lang.String createItemName(org.eclipse.emf.ecore.EObject item)
          Create a name for the given object.
private  boolean diffContainsGroups(org.eclipse.emf.common.util.EList<DiffElement> diffElements)
          Determines whether the diff-model contains any group-elements.
private  void drawLine(org.eclipse.emf.ecore.EObject leftElement, org.eclipse.emf.ecore.EObject rightElement, java.util.Vector<org.eclipse.swt.widgets.TreeItem> leftTreeItems, java.util.Vector<org.eclipse.swt.widgets.TreeItem> rightTreeItems)
          This method draws a line between two model-elements on the sash.
private  void drawLines(java.util.Vector<org.eclipse.swt.widgets.TreeItem> leftTreeItems, java.util.Vector<org.eclipse.swt.widgets.TreeItem> rightTreeItems)
          This method draws the lines between all mapped elements of the mapModel.
private  java.util.Vector<org.eclipse.swt.widgets.TreeItem> getAllTreeItems(org.eclipse.swt.widgets.TreeItem parent)
          This method reads out all TreeItems of this tree.
 DiffModel getDiffModel()
           
 MapModel getMappingModel()
           
 void initLeftTree(Model model, java.lang.String path)
          This method initializes the left tree with the given model that resulted of the path given for this model.
 void initMappingAndDiff()
          This method initializes the Mapping and the diff-model between the input-models.
 void initRightTree(Model model, java.lang.String path)
          This method initializes the right tree with the given model that resulted of the path given for this model.
private  void moveLines(int treeID, int amount)
          Method is called if one of the trees is scrolled vertically.
private  java.util.Vector<org.eclipse.swt.widgets.TreeItem> removeChildrenLines(org.eclipse.swt.widgets.TreeItem parent, java.util.Vector<org.eclipse.swt.widgets.TreeItem> treeItems)
          Method removes all mapping-lines that are of a lower-level than the parent-element.
 void removeLines()
          Mehtod removes all lines from the sash.
private  void showDifferences(DiffModel diffModel)
          This method fills the differencesTreeV with the calculated differences between both models.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, 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, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, 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, setRegion, 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, getListeners, 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
 

Field Detail

editor

private ModelMatcherEditor editor
The editor that contains this page.

See Also:
ModelMatcherEditor

comp

private org.eclipse.swt.widgets.Composite comp
The Composite on which the GUI is placed.

See Also:
Composite

leftTreeV

private org.eclipse.jface.viewers.TreeViewer leftTreeV
The TreeViewer which contains the tree for the left model of the mapping.

See Also:
TreeViewer, leftTree

rightTreeV

private org.eclipse.jface.viewers.TreeViewer rightTreeV
The TreeViewer which contains the tree for the right model of the mapping.

See Also:
TreeViewer, rightTree

differencesTreeV

private org.eclipse.jface.viewers.TreeViewer differencesTreeV
The TreeViewer which contains the diff-model.

See Also:
TreeViewer

leftTree

private org.eclipse.swt.widgets.Tree leftTree
The tree which contains the left model of the mapping.

See Also:
Tree

rightTree

private org.eclipse.swt.widgets.Tree rightTree
The tree which contains the right model of the mapping.

See Also:
Tree

sash

private org.eclipse.swt.widgets.Sash sash
This is the sash that divides the mapping-part of this page. It is place between leftTreeV and rightTreeV.
This sash is also used to display the mapping-lines between both models.

See Also:
Sash

lines

private java.util.Vector<Line> lines
This Vector contains all currently drawn mapping-lines from the sash.

See Also:
Vector, Sash, Line

leftTreeV_OldVBarSelection

private int leftTreeV_OldVBarSelection
The position of the vertical ScrollBar of the leftTreeV.
It is used to calculate the amount of change between the old and the new position for updating the matching-lines on the sash.


rightTreeV_OldVBarSelection

private int rightTreeV_OldVBarSelection
The position of the vertical ScrollBar of the rightTreeV.
It is used to calculate the amount of change between the old and the new position for updating the matching-lines on the sash.


mapModel

private MapModel mapModel
The model that contains the mapping between both compared input-models.

See Also:
MapModel

diffModel

private DiffModel diffModel
This model contains the differences of both input-models.

See Also:
DiffModel
Constructor Detail

DifferencePage

public DifferencePage(org.eclipse.swt.widgets.Composite parent,
                      int style,
                      ModelMatcherEditor e)
The constructor for creating a new DifferencePage.
This constructor initializes the GUI for the page.

Parameters:
parent - the composite on which the page shall be placed.
style - the style for the page.
e - the editor which contains this page
See Also:
Composite, SWT, ModelMatcherEditor
Method Detail

getMappingModel

public MapModel getMappingModel()
Returns:
the mapping of both input-models as a standalone EMF-model.

getDiffModel

public DiffModel getDiffModel()
Returns:
the structural differences between both input-models as a standalone EMF-model.

initMappingAndDiff

public void initMappingAndDiff()
This method initializes the Mapping and the diff-model between the input-models.
It calculates the mapping and the diff-model and initializes the mapping-lines and the visualization of the differences.


removeChildrenLines

private java.util.Vector<org.eclipse.swt.widgets.TreeItem> removeChildrenLines(org.eclipse.swt.widgets.TreeItem parent,
                                                                               java.util.Vector<org.eclipse.swt.widgets.TreeItem> treeItems)
Method removes all mapping-lines that are of a lower-level than the parent-element.

Parameters:
parent - the treeItem whichs mapping-lines shall be removed from the sash.
treeItems - the Vector that contains the tree from which the children can be determined.
Returns:
the new Vector that contains all items from the input-Vector without the children of parent.
See Also:
TreeItem, Vector

drawLine

private void drawLine(org.eclipse.emf.ecore.EObject leftElement,
                      org.eclipse.emf.ecore.EObject rightElement,
                      java.util.Vector<org.eclipse.swt.widgets.TreeItem> leftTreeItems,
                      java.util.Vector<org.eclipse.swt.widgets.TreeItem> rightTreeItems)
This method draws a line between two model-elements on the sash.

Parameters:
leftElement - the element that is the left ending for the line.
rightElement - the element that is the right ending for the line.
leftTreeItems - the vector which contains all tree-items of the left model.
rightTreeItems - the vector which contains all tree-items of the right model.
See Also:
EObject, Vector

drawLines

private void drawLines(java.util.Vector<org.eclipse.swt.widgets.TreeItem> leftTreeItems,
                       java.util.Vector<org.eclipse.swt.widgets.TreeItem> rightTreeItems)
This method draws the lines between all mapped elements of the mapModel.
Therefore it iterates over the set of mapped elements and calls the method drawLine(EObject, EObject, Vector, Vector) for each pair of elements.

Parameters:
leftTreeItems - the vector which contains all tree-items of the left model.
rightTreeItems - the vector which contains all tree-items of the right model.
See Also:
Vector

moveLines

private void moveLines(int treeID,
                       int amount)
Method is called if one of the trees is scrolled vertically.
This method moves one ending of all drawn lines up or down.

Parameters:
treeID - the ID of the tree that was scrolled. This influences the ending of the lines which will be moved.
amount - the scroll-value for the tree.
See Also:
ModelMatcherTreeViewer.getTreeID()

getAllTreeItems

private java.util.Vector<org.eclipse.swt.widgets.TreeItem> getAllTreeItems(org.eclipse.swt.widgets.TreeItem parent)
This method reads out all TreeItems of this tree.
Therefore this method calls itself recursively.

Parameters:
parent - the TreeItem that shall be the entry-point for tree.
This item doesn't have to be the first element of the tree you can also begin reading the items i.e. from a level-3-item.
Returns:
a vector containing all the items in a fixed order determined by the trees structure.
See Also:
TreeItem, Vector

initLeftTree

public void initLeftTree(Model model,
                         java.lang.String path)
This method initializes the left tree with the given model that resulted of the path given for this model.

Parameters:
model - the model from which the tree will be built.
path - the path of the file out of which the model was read.
See Also:
Model

initRightTree

public void initRightTree(Model model,
                          java.lang.String path)
This method initializes the right tree with the given model that resulted of the path given for this model.

Parameters:
model - the model from which the tree will be built.
path - the path of the file out of which the model was read.
See Also:
Model

removeLines

public void removeLines()
Mehtod removes all lines from the sash.


showDifferences

private void showDifferences(DiffModel diffModel)
This method fills the differencesTreeV with the calculated differences between both models.

Parameters:
diffModel - the model that contains the differences.
See Also:
DiffModel

analyseGroup

private void analyseGroup(Group group,
                          org.eclipse.swt.widgets.TreeItem groupItem)
Method analyzes a Group-element from the diff-model and builds its children in the tree.

Parameters:
group - the group that has to be calculated.
groupItem - the treeItem that represents the group in the differencesTreeV.
See Also:
Group, TreeItem

createDiffTreeItem

private org.eclipse.swt.widgets.TreeItem createDiffTreeItem(org.eclipse.swt.widgets.TreeItem parentItem,
                                                            DiffElement element)
This method creates a single element for the differencesTreeV.

Parameters:
parentItem - the item which will be the parent for the created item in the tree-notation.
element - the element from the difference-model which contains all information about the change.
Returns:
the created treeItem.
See Also:
TreeItem, DiffElement

createItemName

private java.lang.String createItemName(org.eclipse.emf.ecore.EObject item)
Create a name for the given object. This name depends on the name-feature of EMF.
If there is no name-feature or the name is not set then the name for the element equals the name of the EClass.

Parameters:
item - the item to create the name for.
Returns:
the name for the TreeItem.
See Also:
EClass, EStructuralFeature, EObject

diffContainsGroups

private boolean diffContainsGroups(org.eclipse.emf.common.util.EList<DiffElement> diffElements)
Determines whether the diff-model contains any group-elements.

Parameters:
diffElements - a list that contains all diff-elements.
Returns:
true if there are any groups within the list.
See Also:
Group, EList, DiffElement