Modelers

org.topcased.modeler.editor.outline
Class ModelNavigator

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.topcased.modeler.editor.outline.ModelNavigator
All Implemented Interfaces:
org.eclipse.jface.action.IMenuListener, org.eclipse.swt.graphics.Drawable

public class ModelNavigator
extends org.eclipse.swt.widgets.Composite
implements org.eclipse.jface.action.IMenuListener

Model navigator :
Display the model as a tree and fill the contextual menu with diagrams and EMF actions.
creation : 30 mai 2005


Nested Class Summary
protected  class ModelNavigator.NavigatorAdapterFactoryContentProvider
          This content provider filters the event from graphical object to only refresh when it's needed.
 
Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
ModelNavigator(org.eclipse.swt.widgets.Composite parent, Modeler editor, org.eclipse.ui.part.IPageSite pageSite)
          Constructor
 
Method Summary
protected  void createContents(org.eclipse.swt.widgets.Composite parent)
          Create the contents of the widget
protected  void createContextMenu(org.eclipse.jface.viewers.StructuredViewer sViewer)
          This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
protected  org.eclipse.jface.action.IAction createDeleteAction()
          Since DeleteAction is internal, added this as a way for subclasses to hook different key listeners for the delete action.
protected  void createMultiSelectionMenu(org.eclipse.jface.action.IMenuManager manager, org.eclipse.jface.viewers.IStructuredSelection selection)
          Add to the MenuManager the actions for a multiple selection.
protected  void createSingleSelectionMenu(org.eclipse.jface.action.IMenuManager manager, java.lang.Object selection)
          Add to the MenuManager the actions for a single object.
 void dispose()
           
protected  Modeler getModeler()
          Returns the modeler
 org.eclipse.jface.viewers.TreeViewer getTreeViewer()
          Returns the TreeViewer used as navigator
protected  void hookKeyListeners()
          Add a key listener to the tree control.
protected  void hookListeners()
          Add listeners :
- on the model
protected  void initDragAndDrop()
          Add drag and drop ability between the outline to the editor.
protected  void initFilters()
          Set the tree filters for the outline
protected  void initProviders()
          Set the tree providers for the outline
protected  boolean isControlActionEnabledFor(EObject selectedObject)
          Subclasses should override this method to control enabling/disabling the control action for the current selection.
protected  boolean isDiagramsMenuEnabledFor(EObject selectedObject)
          Subclasses should override this method to control enabling/disabling the Diagrams menu for the current selection.
protected  boolean isEMFMenuEnabledFor(EObject selectedObject)
          Subclasses should override this method to control enabling/disabling the EMF menu for the current selection.
 void menuAboutToShow(org.eclipse.jface.action.IMenuManager menuManager)
          This implements IMenuListenerto help fill the context menus with contributions from the Edit menu.
protected  void refreshViewer()
          Rfersh the treeviewer in the UI thread if we are in a different thread
protected  void refreshViewer(boolean updateLabel)
          Rfersh the treeviewer in the UI thread if we are in a different thread
protected  void unhookListeners()
          Remove listeners
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, 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, 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, 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

ModelNavigator

public ModelNavigator(org.eclipse.swt.widgets.Composite parent,
                      Modeler editor,
                      org.eclipse.ui.part.IPageSite pageSite)
Constructor

Parameters:
parent - the parent composite
editor - the modeler to edit as tree
pageSite - the site
Method Detail

getModeler

protected Modeler getModeler()
Returns the modeler

Returns:
the modeler

getTreeViewer

public org.eclipse.jface.viewers.TreeViewer getTreeViewer()
Returns the TreeViewer used as navigator

Returns:
the navigable tree

createContents

protected void createContents(org.eclipse.swt.widgets.Composite parent)
Create the contents of the widget

Parameters:
parent - the current widget

initDragAndDrop

protected void initDragAndDrop()
Add drag and drop ability between the outline to the editor.


initProviders

protected void initProviders()
Set the tree providers for the outline


initFilters

protected void initFilters()
Set the tree filters for the outline


hookListeners

protected void hookListeners()
Add listeners :
- on the model


unhookListeners

protected void unhookListeners()
Remove listeners


hookKeyListeners

protected void hookKeyListeners()
Add a key listener to the tree control. When a key is released, the DELETE key is filtered to fire the action.


createContextMenu

protected void createContextMenu(org.eclipse.jface.viewers.StructuredViewer sViewer)
This creates a context menu for the viewer and adds a listener as well registering the menu for extension.

Parameters:
sViewer - the tree viewer

menuAboutToShow

public void menuAboutToShow(org.eclipse.jface.action.IMenuManager menuManager)
This implements IMenuListenerto help fill the context menus with contributions from the Edit menu.

Specified by:
menuAboutToShow in interface org.eclipse.jface.action.IMenuListener
Parameters:
menuManager - the menu to fill

createMultiSelectionMenu

protected void createMultiSelectionMenu(org.eclipse.jface.action.IMenuManager manager,
                                        org.eclipse.jface.viewers.IStructuredSelection selection)
Add to the MenuManager the actions for a multiple selection.

Parameters:
manager - The menu to fill
selection - the selection

createSingleSelectionMenu

protected void createSingleSelectionMenu(org.eclipse.jface.action.IMenuManager manager,
                                         java.lang.Object selection)
Add to the MenuManager the actions for a single object.

Parameters:
manager - The menu to fill
selection - the selected object

isDiagramsMenuEnabledFor

protected boolean isDiagramsMenuEnabledFor(EObject selectedObject)
Subclasses should override this method to control enabling/disabling the Diagrams menu for the current selection. Default returns true.

Parameters:
selection -
Returns:
wether the control action is enabled for the current selection or not.

isEMFMenuEnabledFor

protected boolean isEMFMenuEnabledFor(EObject selectedObject)
Subclasses should override this method to control enabling/disabling the EMF menu for the current selection. Default returns true.

Parameters:
selection -
Returns:
wether the control action is enabled for the current selection or not.

isControlActionEnabledFor

protected boolean isControlActionEnabledFor(EObject selectedObject)
Subclasses should override this method to control enabling/disabling the control action for the current selection. Default returns true.

Parameters:
selection -
Returns:
wether the control action is enabled for the current selection or not.

refreshViewer

protected final void refreshViewer()
Rfersh the treeviewer in the UI thread if we are in a different thread


refreshViewer

protected final void refreshViewer(boolean updateLabel)
Rfersh the treeviewer in the UI thread if we are in a different thread

Parameters:
updateLabel - true if the label must be refreshed

dispose

public void dispose()
Overrides:
dispose in class org.eclipse.swt.widgets.Widget
See Also:
Widget.dispose()

createDeleteAction

protected org.eclipse.jface.action.IAction createDeleteAction()
Since DeleteAction is internal, added this as a way for subclasses to hook different key listeners for the delete action.

Returns:

Modelers

Copyright (c) 2005 TOPCASED Contributors 2005 - 2007. All rights reserved.