de.cau.cs.kieler.core.model.gmf.util
Class GmfModelingUtil

java.lang.Object
  extended by de.cau.cs.kieler.core.model.gmf.util.GmfModelingUtil

public final class GmfModelingUtil
extends Object

Utility class with static methods to handle EMF models and GEF EditParts.

Rating red

Method Summary
static Collection<EObject> getAllByType(EClassifier eObjectClass, EditPart rootEditPart)
          Get all objects that are direct or indirect children of the given root EObject corresponding to the given EditPart if they are of the specified type.
static EditPart getEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart dep, EObject theElement)
          Deprecated. use IGraphicalFrameworkBridge#getEditPart(IEditorPart, Object) instead
static EditPart getEditPart(EObject eObject)
          Deprecated. use IGraphicalFrameworkBridge#getEditPart(Object) instead
static EditPart getEditPart(EObject eObject, EditPart rootEditPart)
          Deprecated. use IGraphicalFrameworkBridge#getEditPart(IEditorPart, Object) instead
static EditPart getEditPart(IEditorPart editorPart, EObject element)
          Deprecated. use IGraphicalFrameworkBridge#getEditPart(IEditorPart, Object) instead
static List<EditPart> getEditParts(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart dep, EObject theElement)
          Finds ALL edit parts connected to the given semantic element.
static EditPart getLabel(IWorkbenchPart editorPart, EObject node)
          Returns the label edit part of the given node.
static List<EObject> getModelElementsFromSelection()
          Returns a list of the EObjects currently selected in the diagram.
static EObject getModelFromGmfEditor(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor diagramEditor)
          Get the model from a given GMF editor.
static
<T> Collection<T>
iterator2Collection(Iterator<T> iter)
          Convert an Iterator to a Collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getModelFromGmfEditor

public static EObject getModelFromGmfEditor(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor diagramEditor)
Get the model from a given GMF editor.

Parameters:
diagramEditor - the diagram editor
Returns:
the model

getEditPart

public static EditPart getEditPart(EObject eObject,
                                   EditPart rootEditPart)
Deprecated. use IGraphicalFrameworkBridge#getEditPart(IEditorPart, Object) instead

Find an GEF EditPart that corresponds to an semantic model EObject. EObjects are used to address objects that are exchanged between the plugins of the View Management as well as other plugins. EObjects provide the ability for semantical addressing of other objects such as children of an object or similar cases.

Parameters:
eObject - the semantic object
rootEditPart - the root EditPart so start the search. May be null, then the current active editor is used
Returns:
the corresponding EditPart

getEditParts

public static List<EditPart> getEditParts(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart dep,
                                          EObject theElement)
Finds ALL edit parts connected to the given semantic element.

Parameters:
dep - the root edit part
theElement - the element to look for
Returns:
the list of results, may be empty

getEditPart

public static EditPart getEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart dep,
                                   EObject theElement)
Deprecated. use IGraphicalFrameworkBridge#getEditPart(IEditorPart, Object) instead

Find an EditPart corresponding to the given EObject in the DiagramEditPart.

Parameters:
dep - the DiagramEditPart to search in
theElement - the EObject to find
Returns:
the EditPart, or null if none was found

getEditPart

public static EditPart getEditPart(IEditorPart editorPart,
                                   EObject element)
Deprecated. use IGraphicalFrameworkBridge#getEditPart(IEditorPart, Object) instead

Find an EditPart corresponding to the given EObject in an arbitrary editor. However, only GMF editors are supported at the moment.

Parameters:
editorPart - an editor part
element - the EObject to find
Returns:
the EditPart, or null if none was found

getAllByType

public static Collection<EObject> getAllByType(EClassifier eObjectClass,
                                               EditPart rootEditPart)
Get all objects that are direct or indirect children of the given root EObject corresponding to the given EditPart if they are of the specified type.

Parameters:
eObjectClass - The type of object
rootEditPart - The root object
Returns:
Collection of found EObject matching the type

iterator2Collection

public static <T> Collection<T> iterator2Collection(Iterator<T> iter)
Convert an Iterator to a Collection. Useful if some method returns only an iterator but some other method takes a Collection as input to iterate over that collection. However, it has linear runtime and many such transformations should be avoided.

Type Parameters:
T - the base type
Parameters:
iter - The input Iterator
Returns:
A Collection containing all elements of the Iterator.

getModelElementsFromSelection

public static List<EObject> getModelElementsFromSelection()
Returns a list of the EObjects currently selected in the diagram.

Returns:
A List of EObjects

getEditPart

public static EditPart getEditPart(EObject eObject)
Deprecated. use IGraphicalFrameworkBridge#getEditPart(Object) instead

Find an GEF EditPart that corresponds to an semantic model EObject. Needs to be called from the UI thread.

Parameters:
eObject - the semantic object
Returns:
the corresponding EditPart TODO: search of transition edit parts iterates all edit parts and will take linear time. You should improve this, by maybe build a local cache hash map

getLabel

public static EditPart getLabel(IWorkbenchPart editorPart,
                                EObject node)
Returns the label edit part of the given node.

Parameters:
editorPart - a workbench part
node - a node object
Returns:
the label edit part, or null if none is found