roneditor.dialogs
Class AbstractMatchDialog

java.lang.Object
  extended by org.eclipse.swt.widgets.Dialog
      extended by roneditor.dialogs.AbstractMatchDialog
All Implemented Interfaces:
org.eclipse.emf.common.notify.Adapter, org.eclipse.gef.commands.CommandStackEventListener
Direct Known Subclasses:
MatchDialog

public abstract class AbstractMatchDialog
extends org.eclipse.swt.widgets.Dialog
implements org.eclipse.emf.common.notify.Adapter, org.eclipse.gef.commands.CommandStackEventListener

This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI Builder, which is free for non-commercial use. If Jigloo is being used commercially (ie, by a corporation, company or business for any purpose whatever) then you should purchase a license for each developer using Jigloo. Please visit www.cloudgarden.com for details. Use of Jigloo implies acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
org.eclipse.emf.common.notify.Adapter.Internal
 
Field Summary
private  org.eclipse.gef.ui.actions.ActionRegistry actionRegistry
          An action registry mainly for holding undo and redo action.
private  org.eclipse.swt.widgets.Button buttonAllCompletions
           
private  org.eclipse.swt.widgets.Button buttonApplyRule
           
private  org.eclipse.swt.widgets.Button buttonCancel
           
private  org.eclipse.swt.widgets.Button buttonNextMatch
           
private  org.eclipse.swt.widgets.Button buttonNextNet
           
private  org.eclipse.swt.widgets.Button buttonNextRule
           
private  org.eclipse.swt.widgets.Button buttonPreviousMatch
           
private  org.eclipse.swt.widgets.Button buttonPreviousNet
           
private  org.eclipse.swt.widgets.Button buttonPreviousRule
           
private  boolean canceled
          A switch to determine whether this dialog has been canceled.
private  org.eclipse.gef.GraphicalViewer codomainViewer
          A viewer showing a copy of the current object net.
private  org.eclipse.gef.commands.CommandStack commandStack
          A command stack for this dialog to perform undo and redo.
private  org.eclipse.swt.widgets.Composite compositeApplyLower
           
private  org.eclipse.swt.widgets.Composite compositeMatchMiddle
           
private  org.eclipse.swt.widgets.Composite compositeMiddle
           
private  org.eclipse.swt.widgets.Composite compositeNetMiddle
           
private  org.eclipse.swt.widgets.Composite compositeRulesUpper
           
private  ronmodel.Rule containerRule
          A rule that has a copy of the currentRule's LHS as LHS and the CurrentObjectNetCopy as RHS.
(package private)  int currentCompletionPos
          The position of the current match completion in the matchCompletions list.
private  ronmodel.RHS currentObjectNetCopy
          A copy of the currently selected object net.
private  int currentObjectNetPos
          The position of the current object net in the objectNets list.
private  ronmodel.Rule currentRule
          The rule of whose LHS a copy is being shown in the lhsViewer.
private  org.eclipse.swt.widgets.Shell dialogShell
           
private  org.eclipse.gef.EditDomain editDomain
          The edit domain handling the mapping tool and the graphical viewers.
private  org.eclipse.gef.EditPartFactory editPartFactory
           
private  ronmodel.HLPlace hlPlace
          The high level place which hosts the current object net.
private  boolean isAllCompletionsMode
          A switch to determine if computed completions that do not respect the actual partial match are being filtered out.
private  org.eclipse.gef.GraphicalViewer lhsViewer
          A viewer showing a copy of the current rule's LHS.
private  java.util.List<java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode>> matchCompletions
          If this is null we are in match completion mode!
private  java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> matchToApply
          A cache for the match between the current rule and object net that has been set in the viewers.
private  java.util.ArrayList<ronmodel.ObjectNet> objectNets
          The object nets that can be selected to apply rules on in this dialog.
private  java.util.ArrayList<ronmodel.Rule> rules
          The rules that can be selected to be applied in this dialog.
private  org.eclipse.swt.custom.SashForm sashForm
           
private  org.eclipse.emf.common.notify.Notifier target
          Needed for Adapter implementation.
private  org.eclipse.swt.widgets.Text textMessage
           
private  org.eclipse.swt.widgets.ToolBar toolBar
           
private  org.eclipse.jface.action.ToolBarManager toolBarManager
           
 
Constructor Summary
AbstractMatchDialog(java.util.ArrayList<ronmodel.Rule> rules, java.util.ArrayList<ronmodel.ObjectNet> objectNets)
          Main constructor for this dialog.
 
Method Summary
private  void applyMatchCompletion(int newCompletionPos)
           
protected abstract  org.eclipse.gef.commands.Command buildCreateMappingCommand(ronmodel.Codomain codomain, ronmodel.ONNode source, ronmodel.ONNode target)
           
protected abstract  org.eclipse.gef.commands.Command buildDeleteMappingCommand(ronmodel.Mapping mapping)
           
(package private)  void buttonAllCompletionsMouseUp()
          Handler method for setting "All completions" switch.
(package private)  void buttonApplyRuleMouseUp()
           
(package private)  void buttonCancelMouseUp()
           
(package private)  void buttonNextMatchMouseUp()
           
(package private)  void buttonNextNetMouseUp(org.eclipse.swt.events.MouseEvent evt)
           
(package private)  void buttonNextRuleMouseUp(org.eclipse.swt.events.MouseEvent evt)
           
(package private)  void buttonPreviousMatchMouseUp()
           
(package private)  void buttonPreviousNetMouseUp(org.eclipse.swt.events.MouseEvent evt)
           
(package private)  void buttonPreviousRuleMouseUp(org.eclipse.swt.events.MouseEvent evt)
           
private  void cacheCurrentMatch()
           
private  boolean checkCurrentMatch()
           
private  void closeDialog()
           
private  java.util.Vector<java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode>> computeMatchCompletions()
           
private  boolean containsCurrentMatch(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> completion)
           
protected abstract  org.eclipse.jface.action.MenuManager createContextMenuProvider(org.eclipse.gef.GraphicalViewer viewer, org.eclipse.gef.ui.actions.ActionRegistry actionRegistry2)
           
protected abstract  org.eclipse.gef.EditPartFactory createEditPartFactory()
           
private  org.eclipse.gef.GraphicalViewer createGraphicalViewer()
           
protected abstract  org.eclipse.gef.Tool createMappingTool()
           
private  void createToolBar()
          This method creates a tool bar with special undo and redo actions working on te dialog's command stack.
(package private)  org.eclipse.gef.commands.CommandStack getCommandStack()
           
 ronmodel.Rule getCurrentRule()
           
private  org.eclipse.gef.EditDomain getEditDomain()
           
private  org.eclipse.gef.EditPartFactory getEditPartFactory()
           
 ronmodel.HLPlace getHLPlace()
           
 java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> getMatchToApply()
           
 ronmodel.ObjectNet getObjectNet()
           
 ronmodel.Codomain getObjectNetCopy()
           
 org.eclipse.emf.common.notify.Notifier getTarget()
           
private  void init()
          Initialize some fields, create graphical viewers and container rule, set first rule and object net, configure buttons' status and reset match completion related stuff.
 boolean isAdapterForType(java.lang.Object type)
           
 boolean isCanceled()
           
private  boolean isMatchToApplyComplete()
          Helper method for checkCurrentMatch().
 void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
          If a change of mappings happens on the current object net copy the "Apply" button will be set according to the current match and the match completion mechanism will be reset.
 void open()
          Builds the dialog by creating the widget hierarchy and calling init().
private  void resetMatchCompletion()
           
private  void setCurrentCodomain(int objectNetPos)
           
private  void setCurrentRule(int rulePos)
           
 void setTarget(org.eclipse.emf.common.notify.Notifier newTarget)
           
 void stackChanged(org.eclipse.gef.commands.CommandStackEvent event)
          Updates all actions if the command stack changes.
private  void undoCommandStack()
          Undoes all actions on the command stack, flushes it and updates all actions.
private  void updateActions()
          Updates all actions in the action registry, mainly undo and redo.
 
Methods inherited from class org.eclipse.swt.widgets.Dialog
checkSubclass, getParent, getStyle, getText, setText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canceled

private boolean canceled
A switch to determine whether this dialog has been canceled.


isAllCompletionsMode

private boolean isAllCompletionsMode
A switch to determine if computed completions that do not respect the actual partial match are being filtered out.


rules

private final java.util.ArrayList<ronmodel.Rule> rules
The rules that can be selected to be applied in this dialog.


objectNets

private final java.util.ArrayList<ronmodel.ObjectNet> objectNets
The object nets that can be selected to apply rules on in this dialog.


editDomain

private org.eclipse.gef.EditDomain editDomain
The edit domain handling the mapping tool and the graphical viewers.


actionRegistry

private org.eclipse.gef.ui.actions.ActionRegistry actionRegistry
An action registry mainly for holding undo and redo action.


commandStack

private org.eclipse.gef.commands.CommandStack commandStack
A command stack for this dialog to perform undo and redo.


lhsViewer

private org.eclipse.gef.GraphicalViewer lhsViewer
A viewer showing a copy of the current rule's LHS.


codomainViewer

private org.eclipse.gef.GraphicalViewer codomainViewer
A viewer showing a copy of the current object net.


matchToApply

private java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> matchToApply
A cache for the match between the current rule and object net that has been set in the viewers.


currentRule

private ronmodel.Rule currentRule
The rule of whose LHS a copy is being shown in the lhsViewer.


currentObjectNetCopy

private ronmodel.RHS currentObjectNetCopy
A copy of the currently selected object net.


currentObjectNetPos

private int currentObjectNetPos
The position of the current object net in the objectNets list. This is stored because we are working on copies.


matchCompletions

private java.util.List<java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode>> matchCompletions
If this is null we are in match completion mode! Otherwise it hold the (filtered) completions returned by AGG.


currentCompletionPos

int currentCompletionPos
The position of the current match completion in the matchCompletions list. This is stored to be able to restore the right completion with undo and redo.


hlPlace

private ronmodel.HLPlace hlPlace
The high level place which hosts the current object net.


containerRule

private ronmodel.Rule containerRule
A rule that has a copy of the currentRule's LHS as LHS and the CurrentObjectNetCopy as RHS. Its purpose is to ease the integration of the MatchDialog to existing RONEditors, especially to display mappings like in an ordinary rule view.


dialogShell

private org.eclipse.swt.widgets.Shell dialogShell

textMessage

private org.eclipse.swt.widgets.Text textMessage

buttonAllCompletions

private org.eclipse.swt.widgets.Button buttonAllCompletions

buttonCancel

private org.eclipse.swt.widgets.Button buttonCancel

buttonApplyRule

private org.eclipse.swt.widgets.Button buttonApplyRule

compositeApplyLower

private org.eclipse.swt.widgets.Composite compositeApplyLower

buttonNextMatch

private org.eclipse.swt.widgets.Button buttonNextMatch

buttonPreviousMatch

private org.eclipse.swt.widgets.Button buttonPreviousMatch

compositeMatchMiddle

private org.eclipse.swt.widgets.Composite compositeMatchMiddle

buttonNextNet

private org.eclipse.swt.widgets.Button buttonNextNet

buttonPreviousNet

private org.eclipse.swt.widgets.Button buttonPreviousNet

compositeNetMiddle

private org.eclipse.swt.widgets.Composite compositeNetMiddle

compositeMiddle

private org.eclipse.swt.widgets.Composite compositeMiddle

sashForm

private org.eclipse.swt.custom.SashForm sashForm

buttonNextRule

private org.eclipse.swt.widgets.Button buttonNextRule

buttonPreviousRule

private org.eclipse.swt.widgets.Button buttonPreviousRule

compositeRulesUpper

private org.eclipse.swt.widgets.Composite compositeRulesUpper

toolBar

private org.eclipse.swt.widgets.ToolBar toolBar

toolBarManager

private org.eclipse.jface.action.ToolBarManager toolBarManager

editPartFactory

private org.eclipse.gef.EditPartFactory editPartFactory

target

private org.eclipse.emf.common.notify.Notifier target
Needed for Adapter implementation.

Constructor Detail

AbstractMatchDialog

public AbstractMatchDialog(java.util.ArrayList<ronmodel.Rule> rules,
                           java.util.ArrayList<ronmodel.ObjectNet> objectNets)
Main constructor for this dialog.

Parameters:
rules - The rules that can be switched through for match-setting. Must contain at least 1 rule.
objectNets - The target object nets that can be switched through for match-setting. Must contain at least 1 object net.
Method Detail

open

public void open()
Builds the dialog by creating the widget hierarchy and calling init().

See Also:
init()

createToolBar

private void createToolBar()
This method creates a tool bar with special undo and redo actions working on te dialog's command stack.


init

private void init()
Initialize some fields, create graphical viewers and container rule, set first rule and object net, configure buttons' status and reset match completion related stuff.


checkCurrentMatch

private boolean checkCurrentMatch()
Returns:
true if the match currently defined between the actually shown LHS and ObjectNet is complete and applicable.
See Also:
cacheCurrentMatch(), isMatchToApplyComplete()

isMatchToApplyComplete

private boolean isMatchToApplyComplete()
Helper method for checkCurrentMatch().

Returns:
true if for each ONNode in the current LHS a Mapping exists.

createGraphicalViewer

private org.eclipse.gef.GraphicalViewer createGraphicalViewer()
Returns:
A newly created and configured ScrollingGraphicalViewer on the sashForm.
See Also:
getEditDomain(), getEditPartFactory()

createContextMenuProvider

protected abstract org.eclipse.jface.action.MenuManager createContextMenuProvider(org.eclipse.gef.GraphicalViewer viewer,
                                                                                  org.eclipse.gef.ui.actions.ActionRegistry actionRegistry2)
Parameters:
viewer -
actionRegistry2 -
Returns:

getEditDomain

private org.eclipse.gef.EditDomain getEditDomain()
Returns:
A lazily created EditDomain that works on this dialog's command stack with a Tool for creating Mappings as default tool.
See Also:
getCommandStack()

createMappingTool

protected abstract org.eclipse.gef.Tool createMappingTool()
Returns:

getEditPartFactory

private org.eclipse.gef.EditPartFactory getEditPartFactory()
Returns:
An lazily created EditPartFactory for the GraphicalViewers created in createGraphicalViewer().

createEditPartFactory

protected abstract org.eclipse.gef.EditPartFactory createEditPartFactory()
Returns:

getCommandStack

org.eclipse.gef.commands.CommandStack getCommandStack()
Returns:
A lazily created CommandStack to which the dialog is listening.
See Also:
stackChanged(CommandStackEvent)

setCurrentRule

private void setCurrentRule(int rulePos)
Parameters:
rulePos -

setCurrentCodomain

private void setCurrentCodomain(int objectNetPos)
Parameters:
objectNet -

undoCommandStack

private void undoCommandStack()
Undoes all actions on the command stack, flushes it and updates all actions. The current object net copy won't be notified about mapping changes as it will be deregistered as listener for model changes during execution of this method.


updateActions

private void updateActions()
Updates all actions in the action registry, mainly undo and redo.


resetMatchCompletion

private void resetMatchCompletion()

buttonPreviousMatchMouseUp

void buttonPreviousMatchMouseUp()

buttonNextMatchMouseUp

void buttonNextMatchMouseUp()

computeMatchCompletions

private java.util.Vector<java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode>> computeMatchCompletions()

cacheCurrentMatch

private void cacheCurrentMatch()

containsCurrentMatch

private boolean containsCurrentMatch(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> completion)

applyMatchCompletion

private void applyMatchCompletion(int newCompletionPos)
Parameters:
matchCompletion -

buildDeleteMappingCommand

protected abstract org.eclipse.gef.commands.Command buildDeleteMappingCommand(ronmodel.Mapping mapping)
Parameters:
mapping -
Returns:

buildCreateMappingCommand

protected abstract org.eclipse.gef.commands.Command buildCreateMappingCommand(ronmodel.Codomain codomain,
                                                                              ronmodel.ONNode source,
                                                                              ronmodel.ONNode target)
Parameters:
codomain -
source -
target -
Returns:

buttonPreviousRuleMouseUp

void buttonPreviousRuleMouseUp(org.eclipse.swt.events.MouseEvent evt)
Parameters:
evt -

buttonNextRuleMouseUp

void buttonNextRuleMouseUp(org.eclipse.swt.events.MouseEvent evt)
Parameters:
evt -

buttonPreviousNetMouseUp

void buttonPreviousNetMouseUp(org.eclipse.swt.events.MouseEvent evt)
Parameters:
evt -

buttonNextNetMouseUp

void buttonNextNetMouseUp(org.eclipse.swt.events.MouseEvent evt)
Parameters:
evt -

buttonCancelMouseUp

void buttonCancelMouseUp()

buttonApplyRuleMouseUp

void buttonApplyRuleMouseUp()

closeDialog

private void closeDialog()

buttonAllCompletionsMouseUp

void buttonAllCompletionsMouseUp()
Handler method for setting "All completions" switch.


stackChanged

public void stackChanged(org.eclipse.gef.commands.CommandStackEvent event)
Updates all actions if the command stack changes.

Specified by:
stackChanged in interface org.eclipse.gef.commands.CommandStackEventListener
See Also:
CommandStackEventListener.stackChanged(org.eclipse.gef.commands.CommandStackEvent), updateActions()

getMatchToApply

public java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> getMatchToApply()
Returns:
the match being cached 1. by pushing apply button 2. for current match checking 3. for computing match completions
See Also:
cacheCurrentMatch()

getObjectNetCopy

public ronmodel.Codomain getObjectNetCopy()
Returns:
the objectNetCopy
See Also:
setCurrentCodomain(int)

getObjectNet

public ronmodel.ObjectNet getObjectNet()
Returns:

getCurrentRule

public ronmodel.Rule getCurrentRule()
Returns:
the currentRule
See Also:
setCurrentRule(int)

getHLPlace

public ronmodel.HLPlace getHLPlace()
Returns:
The hlPlace that hosts the currently selected object net.

isCanceled

public boolean isCanceled()
Returns:
true if this dialog has been canceled.

notifyChanged

public void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
If a change of mappings happens on the current object net copy the "Apply" button will be set according to the current match and the match completion mechanism will be reset.

Specified by:
notifyChanged in interface org.eclipse.emf.common.notify.Adapter
See Also:
Adapter.notifyChanged(org.eclipse.emf.common.notify.Notification), checkCurrentMatch(), resetMatchCompletion()

setTarget

public void setTarget(org.eclipse.emf.common.notify.Notifier newTarget)
Specified by:
setTarget in interface org.eclipse.emf.common.notify.Adapter

getTarget

public org.eclipse.emf.common.notify.Notifier getTarget()
Specified by:
getTarget in interface org.eclipse.emf.common.notify.Adapter

isAdapterForType

public boolean isAdapterForType(java.lang.Object type)
Specified by:
isAdapterForType in interface org.eclipse.emf.common.notify.Adapter