| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
RwiDiagram
is a set of RwiReference derivatives referencing the model's elements.
Diagrams are kept in packages. Examples of diagrams are class diagrams, use case diagrams, sequence diagrams,
collaboration diagrams etc.
It is recommended to read description of the RwiPackage interface first.
The RwiReferences containing in this diagram are used as shortcuts in Windows - they are
only pointers to the real RwiElements.
If you have read the RwiPackage description you know that
each RwiDiagram has one or two (for physical package diagrams) associated RwiPackages.
If the RwiReference points an element belonging to this diagram's associated
RwiPackage this RwiReference is called
a primary reference. Otherwise it is called an imported reference.
RwiReference can be examined on whether it is an imported or a primary reference
using the method RwiReference.isImported -
for imported references it will return true.
When this RwiDiagram is displayed, elements referenced by imported references are shown
as shortcuts.

To add to this diagram a reference to an existing model's element, addReference method
can be used (the same happens when the user adds a shortcut to an element using the "Add shortcut" dialog).
In this case only a reference to an element will be added to this diagram's reference set, but the
referenced element will not be moved or copied.
This interface provides methods for creating new RwiElements. Basically they are similar
to the creational methods in the RwiPackage interface. The difference is that methods in this
interface automatically add a reference (primary or imported) to this diagram's reference set.
This is convenient when you would like to create a new element in the model and to add a
shortcut to this element to this diagram.
The methods in this interface for creating new elements
are useful only for non-physical package diagrams (see RwiPackage), because
if you create something in a package, its physical package diagram automatically reflects such a change.
For example, if this RwiDiagram is a use case diagram and you would like to
create a new class in the package containing this diagram and to add a reference (a shortcut) to
that class to this diagram, you would use method createNodeByPattern for this diagram.
The RwiReference has a useful method
setVisible(boolean) controlling the visibility
of the referenced element in the diagram (when the user invokes "Hide" command from the popup menu
Together uses this method for the corresponding RwiReference).
Only imported references can be deleted from this diagram (because if
it would be possible to delete primary references as well, the element could be "lost").
It can be done using
the RwiReference.delete method. (Note that this doesn't delete a referenced element -
only a reference to it from this diagram)
If you have a reference to some RwiElement, the method
findDiagramFor can be used to find a diagram
containing a primary reference to this element (the diagram in whose associated package the element
is stored).
RwiDiagrams are not directly displayed by Together on the screen. Together uses
IdeDiagrams to visualize RwiDiagrams
in order to
be able to work with the selection, to switch between active diagrams etc.
It is possible to get IdeDiagram corresponding to the
RwiDiagram using methods of
IdeDiagramManager. For example,
let's find and display a diagram containing someRwiElement:
import com.togethersoft.openapi.rwi.RwiModel;
import com.togethersoft.openapi.rwi.RwiModelAccess;
import com.togethersoft.openapi.rwi.RwiDiagram;
import com.togethersoft.openapi.ide.diagram.IdeDiagramManager;
import com.togethersoft.openapi.ide.diagram.IdeDiagramManagerAccess;
import com.togethersoft.openapi.ide.diagram.IdeDiagram;
...
public void showDiagram(RwiElement someRwiElement){
RwiModel model = RwiModelAccess.getModel();
RwiDiagram rwiDiagram = model.findDiagramFor(someRwiElement);
if (rwiDiagram==null) return;
IdeDiagramManager diagramManager= IdeDiagramManagerAccess.getDiagramManager();
IdeDiagram ideDiagram = diagramManager.openDiagram(rwiDiagram,true);
diagramManager.setActiveDiagram(ideDiagram);
}
Important thing to know about RwiDiagrams is that Together uses RwiDiagrams
to represent packages in a class diagram. For example, when you select a package icon in a class diagram,
the selected element is RwiDiagram representing the physical package diagram for that
package (not RwiPackage as you might expect).
To get the RwiPackage corresponding to the selected package icon, use the
getContainingPackage method for the selected
RwiDiagram.| Method Summary | |
RwiReference | addReference(RwiElement element)Creates a reference to model's element in this diagram. |
boolean | canAddReference(RwiElement element)Checks whether it is possible to create a reference to model's element in this diagram. |
boolean | canCreateDiagram(String shapeType)Checks whether it is possible to create a new diagram with the specified value of RwiProperty.SHAPE_TYPE property. |
boolean | canCreateNode(String shapeType)Checks whether it is possible to create a new node with the specified value of RwiProperty.SHAPE_TYPE property. |
boolean | canCreateNodeByPattern(String language, String patternName)Checks whether it is possible to create a new node using the specified pattern. |
boolean | canCreatePackage()Checks whether it is possible to create a new package. |
RwiDiagramReference | createDiagram(String shapeType)Creates a new diagram with the specified value of RwiProperty.SHAPE_TYPE property and returns an imported reference to that diagram. |
RwiNodeReference | createNode(String shapeType)Creates a new node with the specified value of RwiProperty.SHAPE_TYPE property and returns a primary reference to this node. |
RwiNodeReference | createNodeByPattern(String language, String patternName)Creates a new node using the specified pattern and returns a reference to this node. |
RwiDiagramReference | createPackage()Creates a new package and returns a reference to its physical package diagram. |
RwiDiagramReferenceEnumeration | diagramReferences()Returns an enumeration of references to other diagrams this diagram has. |
RwiReference | findReference(RwiElement element)Given the RwiElement returns a reference to it in this diagram. |
RwiReference | findReference(String uniqueName)Given the unique name of the RwiElement returns a reference to it in this diagram. |
RwiPackage | getDesignPackage()Returns the RwiPackage containing design elements for this diagram. |
String | getOption(String name)For this diagram, returns a string with the value of the specified string option. |
boolean | hasOption(String name)For this diagram, returns a boolean value of the specified bolean option. |
RwiNodeReferenceEnumeration | nodeReferences()Returns an enumeration of references to nodes this diagram has. |
RwiReferenceEnumeration | references()Returns an enumeration of all the references this diagram has. |
| Methods inherited from interface com.togethersoft.openapi.rwi.RwiContainer |
canPaste, elements, getContainingPackage, paste |
| Methods inherited from interface com.togethersoft.openapi.rwi.RwiElement |
accept, canCreateIncomingLink, canCreateOutgoingLink, canCreateOutgoingLink, canCreateOutgoingLinkByPattern, canCut, canDelete, codeElements, copy, createOutgoingLink, createOutgoingLinkByPattern, cut, delete, getCodeElement, getTimeStamp, getUniqueName, isDeleted, outgoingLinks |
| Methods inherited from interface com.togethersoft.openapi.rwi.RwiPropertyMap |
addProperty, canAddProperty, canSetProperty, canSetProperty, getProperty, hasProperty, isPropertyReadable, isPropertyWritable, properties, properties, setProperty, setProperty |
| Method Detail |
public RwiReference addReference(RwiElement element)
The returned reference is an imported reference (but if the element
belongs to this diagram (located in this diagram's associated package) this method
will return an existing primary reference to that element).
public boolean canAddReference(RwiElement element)
true if it is possible to create a reference, false otherwise.public boolean canCreateDiagram(String shapeType)
RwiProperty.SHAPE_TYPE property.SHAPE_TYPE property. Cannot be null.true if it is possible to create a new diagram, false otherwisepublic boolean canCreateNode(String shapeType)
RwiProperty.SHAPE_TYPE property.SHAPE_TYPE property. Cannot
be null.true if it is possible to create a new node, false otherwisepublic boolean canCreateNodeByPattern(String language, String patternName)
RwiPattern interface.true if it is possible to create a new nodepublic boolean canCreatePackage()
true if it is possible to create a new package.public RwiDiagramReference createDiagram(String shapeType)
RwiProperty.SHAPE_TYPE property and returns an imported reference to that diagram.
This method
also automatically adds that reference to this diagram's reference set (when this diagram is displayed the referenced diagram will be shown as a shortcut).
Note that the created reference is not a primary reference.
The created diagram will be placed in the package containing this diagram. This method works just like the method RwiPackage.createDiagram but it automatically creates a shortcut to the newly created diagram in this diagram.
For example, here is a script which creates a new use case diagram named "MyUseCase"
in the package containing the selected diagram:
Note that if you select a package icon and run this script it will create a use case diagram
in that package, not in the package the
currently visible diagram belongs to (remember, package icons are
public void run(IdeContext context){
RwiElement[] selectedRwiElements = context.getRwiElements();
RwiElement element = selectedRwiElements[0];
if ( ! (element instanceof RwiDiagram) ) {
return;
}
RwiDiagram diagram = (RwiDiagram)element;
RwiDiagramReference newDiagramReference = diagram.createDiagram(RwiShapeType.USE_CASE_DIAGRAM);
RwiDiagram newDiagram = newDiagramReference.getDiagram();
newDiagram.setProperty(RwiProperty.NAME, "MyUseCase");
... //here you can add actors etc.
}
RwiDiagrams - see RwiDiagram).
SHAPE_TYPE property. Cannot be null.public RwiNodeReference createNode(String shapeType)
RwiProperty.SHAPE_TYPE property and returns a primary reference to this node.
This method
also automatically adds that reference to this diagram's reference set (when this diagram is displayed the referenced element will not be shown as a shortcut).
Note that this method should not be used for creation of source code-based elements (classes, interfaces).
For that purposes the method createNodeByPattern is used.
The created node will be kept in the package containing design elements for this diagram (returned by the getDesignPackage method).
For example, this script creates a new actor named "CEO" in the selected diagram:
public void run(IdeContext context){
RwiElement[] selectedRwiElements = context.getRwiElements();
RwiElement element = selectedRwiElements[0];
if ( ! (element instanceof RwiDiagram) ) {
return;
}
RwiDiagram diagram = (RwiDiagram)element;
RwiNodeReference actorReference = diagram.createNode(RwiShapeType.ACTOR);
RwiNode actor = actorReference.getNode();
actor.setProperty(RwiProperty.NAME, "CEO");
}
SHAPE_TYPE property. Cannot
be null.public RwiNodeReference createNodeByPattern(String language, String patternName)
Node is created in the same
package where this diagram is stored. This package can be obtained using the
getContainingPackage method.
If this diagram is a physical package diagram then the returned reference will be a primary reference (the class/interface icon will not be shown as a shortcut), imported otherwise (the class/interface icon will be shown as a shortcut).
For example, this script creates a new class named "MyNewClass" and a new interface named
"MyNewInterface" in the package containing the selected diagram:
Note that if you select a package icon and run this script it will create a class and interface
in that package, not in the package the
currently visible diagram belongs to (remember, package icons are
public void run(IdeContext context){
RwiElement[] selectedRwiElements = context.getRwiElements();
RwiElement element = selectedRwiElements[0];
if ( ! (element instanceof RwiDiagram) ) {
return;
}
RwiDiagram diagram = (RwiDiagram)element;
RwiNodeReference newClassReference = diagram.createNodeByPattern(RwiLanguage.JAVA, RwiPattern.DEFAULT_CLASS); //creates a public class
RwiNode newClass = newClassReference.getNode();
newClass.setProperty(RwiProperty.NAME, "MyNewClass");
RwiNodeReference newInterfaceReference = diagram.createNodeByPattern(RwiLanguage.JAVA, RwiPattern.DEFAULT_INTERFACE); //creates a public interface
RwiNode newInterface = newInterfaceReference.getNode();
newInterface.setProperty(RwiProperty.NAME, "MyNewInterface");
}
RwiDiagrams - see RwiDiagram).
RwiPattern interface.public RwiDiagramReference createPackage()
getContainingPackage method).
If this diagram is a physical package diagram itself then the returned reference will be a primary reference (the package icon will not be shown as a shortcut), imported otherwise (the package icon will be shown as a shortcut).
For example, this script creates a new package "myNewPackage" in the package containing the selected diagram:
Note that if you select a package icon and run this script it will create a subpackage
in that package, not in the package the
currently visible diagram belongs to (remember, package icons are
public void run(IdeContext context){
RwiElement[] selectedRwiElements = context.getRwiElements();
RwiElement element = selectedRwiElements[0];
if ( ! (element instanceof RwiDiagram) ) {
return;
}
RwiDiagram diagram = (RwiDiagram)element;
RwiDiagramReference newPackagePhysicalDiagramReference = diagram.createPackage();
RwiPackage newPackage = newPackagePhysicalDiagramReference.getDiagram().getContainingPackage();
newPackage.setProperty(RwiProperty.NAME, "myNewPackage");
}
RwiDiagrams - see RwiDiagram).
It is better to use RwiPackage.createSubpackage method for creation of packages.
public RwiDiagramReferenceEnumeration diagramReferences()
public RwiReference findReference(RwiElement element)
RwiElement returns a reference to it in this diagram.element, null
if this diagram doesn't have a reference to this elementpublic RwiReference findReference(String uniqueName)
RwiElement returns a reference to it in this diagram.null
if this diagram doesn't have a reference to this elementpublic RwiPackage getDesignPackage()
RwiPackage containing design elements for this diagram. See
the RwiPackage interface description.public String getOption(String name)
null.
getOption("option.detail")
will return the value of the option.detail option (defined
in a config file).public boolean hasOption(String name)
false.
getOption("option.associationLinks.directed")
will return the value of the option.associationLinks.directed option (defined
in a config file).public RwiNodeReferenceEnumeration nodeReferences()
public RwiReferenceEnumeration references()
| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||