UML Modeling Layer

com.ibm.xtools.uml.ui.diagram
Interface IUMLDiagramHelper


public interface IUMLDiagramHelper

This class provides API for manipulating UML diagrams.


Method Summary
 boolean canCreateViews(Diagram diagram, List<?> objects)
          Returns whether views can be created for the objects specified by objects in the diagram specified by diagram
 Diagram createDiagram(Namespace container, UMLDiagramKind kind)
          Creates a UML diagram with a given kind and inserts it into a given container
 Diagram createDiagram(Namespace container, UMLDiagramKind kind, Element context)
          Creates a UML diagram with a given context and kind and inserts it into a given container
 Edge createEdge(View source, View target, Element element)
          Creates an edge for a given element and connects it between a given source and a given target
 Edge createEdge(View source, View target, String type)
          Creates an edge with a given type and connects it between a given source and a given target, basic edge types are "NoteAttachment"
 List<Edge> createEdges(Diagram diagram, Relationship element)
          Creates diagram edges between the related elements of a relationship
 Node createNode(View container, Element element)
          Creates a node for a given element and inserts it into a given container
 Node createNode(View container, String type)
          Creates a node with a given type and inserts it into a given container basic types are "Note" "Text" "DiagramName" "DiagramLink"
 List<View> createViews(Diagram diagram, List<?> objects)
          Creates views for the objects specified by objects in the diagram specified by diagram.
 void destroyView(View view)
          Destroys a given view
 Diagram findDiagram(Element root, String id, IProgressMonitor monitor)
          Finds diagram whose ID matches exactly the specified id.
 Diagram findDiagramById(Model model, String id, IProgressMonitor monitor)
          Deprecated. Since 7.5, use the IUMLDiagramHelper.findDiagram(Element, String, IProgressMonitor) method, instead.
 Set<Diagram> findDiagramByName(Element container, String name, IProgressMonitor monitor)
          Finds the diagrams whose name and type match exactly the specified name and type respectively.
 View getChildView(View container, String type)
          Gets the child view with a given type from a given view
 List<Diagram> getDiagrams(Namespace element)
          Gets a list of diagrams for a given element
 List<Diagram> getDiagrams(Namespace element, UMLDiagramKind kind)
          Gets a list of diagrams of a given kind for a given element
 org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNode getLayoutNode(Node node)
          getLayoutNode Gets the ILayoutNode in order to retrieve the actual size of the Node object irrespective of the autosize properties.
 Diagram getMainDiagram(Namespace element)
          Gets the main diagram of an element
 UMLDiagramKind getUmlDiagramKind(Diagram diagram)
          Retrieves the UMLDiagramKind of the specified diagram
 void layout(View view, String hint)
          layout Utility method to layout the children of a view container.
 void layoutNodes(List<? extends Node> nodes, String hint)
          layoutNodes Utility method to layout a list of Node children on a diagram.
 void openDiagramEditor(Diagram diagram)
          Opens an editor for a given diagram
 Image renderToAWTImage(Diagram diagram)
          renderToAWTImage Utility api to generate an AWT based image representation of the diagram contents.
 void renderToImageFile(Diagram diagram, String file, org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat format)
          renderToImageFile Utility api to render the diagram to a specified image formatation of the diagram contents.
 Image renderToSWTImage(Diagram diagram)
          renderToSWTImage Utility api to generate an SWT based image representation of the diagram contents.
 void setMainDiagram(Namespace element, Diagram diagram)
          Sets the main diagram of an element
 

Method Detail

createDiagram

Diagram createDiagram(Namespace container,
                      UMLDiagramKind kind)
Creates a UML diagram with a given kind and inserts it into a given container

Parameters:
container - The container namespace for the diagram
kind - The UML diagram kind
Returns:
a newly created Diagram

createDiagram

Diagram createDiagram(Namespace container,
                      UMLDiagramKind kind,
                      Element context)
Creates a UML diagram with a given context and kind and inserts it into a given container

Parameters:
container - The container namespace for the diagram
context - The UML diagram element context
kind - The UML diagram kind
Returns:
A newly created Diagram

createNode

Node createNode(View container,
                Element element)
Creates a node for a given element and inserts it into a given container

Parameters:
container - The node view container
element - The node view element context
Returns:
A newly created Node

createNode

Node createNode(View container,
                String type)
Creates a node with a given type and inserts it into a given container basic types are

Parameters:
container - The node view container
type - The node view type
Returns:
A newly created Node

createEdge

Edge createEdge(View source,
                View target,
                Element element)
Creates an edge for a given element and connects it between a given source and a given target

Parameters:
source - The edge's source view
target - The edge's target view
element - The edge view element context
Returns:
A newly created Edge

createEdge

Edge createEdge(View source,
                View target,
                String type)
Creates an edge with a given type and connects it between a given source and a given target, basic edge types are

Parameters:
source - The edge's source view
target - The edge's target view
type - The edge view type
Returns:
A newly created Edge

destroyView

void destroyView(View view)
Destroys a given view

Parameters:
view - The view to be destroyed

openDiagramEditor

void openDiagramEditor(Diagram diagram)
Opens an editor for a given diagram

Parameters:
diagram - The diagram to be opened

getDiagrams

List<Diagram> getDiagrams(Namespace element)
Gets a list of diagrams for a given element

Parameters:
element - The namespace element
Returns:
A list of Diagram s

getDiagrams

List<Diagram> getDiagrams(Namespace element,
                          UMLDiagramKind kind)
Gets a list of diagrams of a given kind for a given element

Parameters:
element - The namespace element
kind - The diagram kind
Returns:
A list of Diagram s

getMainDiagram

Diagram getMainDiagram(Namespace element)
Gets the main diagram of an element

Parameters:
element - The namespace element
Returns:
The main Diagram

setMainDiagram

void setMainDiagram(Namespace element,
                    Diagram diagram)
Sets the main diagram of an element

Parameters:
element - The namespace element
diagram - The main diagram

getChildView

View getChildView(View container,
                  String type)
Gets the child view with a given type from a given view

Parameters:
container - The container view
type - The type of the child view
Returns:
a child View

getUmlDiagramKind

UMLDiagramKind getUmlDiagramKind(Diagram diagram)
Retrieves the UMLDiagramKind of the specified diagram

Parameters:
diagram - The diagram to retrieve the UMLDiagramKind for
Returns:
The UMLDiagramKind

renderToImageFile

void renderToImageFile(Diagram diagram,
                       String file,
                       org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat format)
renderToImageFile Utility api to render the diagram to a specified image formatation of the diagram contents.

Parameters:
diagram - The Diagram to render the image from.
file - String that is the image file path to write to.
format - ImageFileFormat enumeration of valid file formats
Throws:
NullPointerException - diagram is null
NullPointerException - file is null
NullPointerException - format is null
IllegalArgumentException - file is an empty string
UnsupportedOperationException - Unable to render diagram to format

renderToAWTImage

Image renderToAWTImage(Diagram diagram)
renderToAWTImage Utility api to generate an AWT based image representation of the diagram contents.

Parameters:
diagram - The Diagram to render the image from.
Returns:
java.awt.Image that is the bitmap representation of the diagram contents.
Throws:
NullPointerException - diagram is null

renderToSWTImage

Image renderToSWTImage(Diagram diagram)
renderToSWTImage Utility api to generate an SWT based image representation of the diagram contents.

Parameters:
diagram - The Diagram to render the image from.
Returns:
org.eclipse.swt.graphics.Image that is the bitmap representation of the diagram contents. Caller is responsible for calling dispose() on the return image.
Throws:
NullPointerException - diagram is null

getLayoutNode

org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNode getLayoutNode(Node node)
getLayoutNode Gets the ILayoutNode in order to retrieve the actual size of the Node object irrespective of the autosize properties.

Parameters:
node - Node to get the layout node equivalent from
Returns:
ILayoutNode object
Throws:
NullPointerException - node is null

layout

void layout(View view,
            String hint)
layout Utility method to layout the children of a view container.

Parameters:
view - View object that is the container whose children will be laid out. Typically this would be the Diagram notation element.
hint - String representing a hint for what kind of layout will be applied. Value can be one of
Throws:
NullPointerException - view is null
NullPointerException - hint is null
See Also:
LayoutType.DEFAULT, Other values would have to understand by custom providers., ILayoutNodeProvider

layoutNodes

void layoutNodes(List<? extends Node> nodes,
                 String hint)
layoutNodes Utility method to layout a list of Node children on a diagram.

Parameters:
nodes - List of Node objects
hint - String representing a hint for what kind of layout will be applied. Value can be one of
Throws:
NullPointerException - nodes is null
IllegalArgumentException - nodes is an empty list
NullPointerException - hint is null
IllegalArgumentException - Argument nodes contains objects which aren't of type Node
IllegalArgumentException - Argument nodes contains objects which have a different parent containment
See Also:
LayoutType.DEFAULT, Other values would have to understand by custom providers., ILayoutNodeProvider

createViews

List<View> createViews(Diagram diagram,
                       List<?> objects)
Creates views for the objects specified by objects in the diagram specified by diagram.

Parameters:
diagram - The diagram where to add views to
objects - The objects to add views for
Returns:
The notation elements added to the diagram
Throws:
NullPointerException - diagram or object is null
IllegalArgumentException - diagram has no associated edit part (internal error)

canCreateViews

boolean canCreateViews(Diagram diagram,
                       List<?> objects)
Returns whether views can be created for the objects specified by objects in the diagram specified by diagram

Parameters:
diagram - The diagram where to add a views to
objects - The objects to add views for
Returns:
true if at least one object can be viewed in the specified diagram
Throws:
NullPointerException - diagram or objects is null

findDiagramById

@Deprecated
Diagram findDiagramById(Model model,
                                   String id,
                                   IProgressMonitor monitor)
                        throws InterruptedException
Deprecated. Since 7.5, use the IUMLDiagramHelper.findDiagram(Element, String, IProgressMonitor) method, instead.

Finds diagram whose ID matches exactly the specified id. The search is performed in the model specified by model

Parameters:
model - The UML model where to perform the search
id - The ID of the diagram to match
Returns:
The diagram with the specified id, null if not found
Throws:
InterruptedException - The query operation was interrupted
IllegalArgumentException - is is an empty string
ClassCastException - is if the element associated with the specified id is not a diagram
See Also:
com.ibm.xtools.emf.index.IIndexSearchManager

findDiagram

Diagram findDiagram(Element root,
                    String id,
                    IProgressMonitor monitor)
                    throws InterruptedException
Finds diagram whose ID matches exactly the specified id. The search is performed in the model specified by model

Parameters:
root - The root element of the UML model where to perform the search
id - The ID of the diagram to match
Returns:
The diagram with the specified id, null if not found
Throws:
InterruptedException - The query operation was interrupted
IllegalArgumentException - is is an empty string
ClassCastException - is if the element associated with the specified id is not a diagram
Since:
7.5
See Also:
com.ibm.xtools.emf.index.IIndexSearchManager

findDiagramByName

Set<Diagram> findDiagramByName(Element container,
                               String name,
                               IProgressMonitor monitor)
                               throws InterruptedException
Finds the diagrams whose name and type match exactly the specified name and type respectively. The search begins at the element specified by container and recurses within its owned elements

Parameters:
container - The root Element where to perform the search
name - The name of the Diagram to match
monitor - The monitor to use to display progress and/or cancel operation
Returns:
The set of Diagrams matching the specified criteria
Throws:
InterruptedException - The query operation was interrupted
IllegalArgumentException - name is an empty string
NullPointerException - One of the passed parameters was null
See Also:
com.ibm.xtools.emf.index.IIndexSearchManager

createEdges

List<Edge> createEdges(Diagram diagram,
                       Relationship element)
Creates diagram edges between the related elements of a relationship

Parameters:
diagram - The diagram to created edges in
element - The relationship element
Returns:
The list of created Edge s

UML Modeling Layer

© Copyright IBM Corp. 2009. All rights reserved.