| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
RwiPackage contains model's data (nodes, members, diagrams, and other packages)
in a directory-like structure.
Provides a set of methods for creating and deleting nodes, diagrams
and subpackages.
It is possible to get a package contents as an enumeration of nodes, diagrams or subpackages using
nodes, diagrams or subpackages methods respectively.
RwiPackages are physically represented either by directories or files.
Each RwiPackage represented by a directory contains:
RwiNodes representing source code-based elements (classes,
interfaces etc).
RwiPackages
RwiDiagrams
RwiDiagram from the directory-RwiPackage contains any
design elements (RwiElements that can not be represented by source code elements.
For example, design elements are RwiNodes representing
notes, actors, use cases etc.) then that
directory-RwiPackage contains a subpackage (RwiPackage) which stores all
the design elements for the diagram. And this subpackage will not be a directory, it will be kept in
a file with the extension starting with "df".
To explain how Together uses these kinds of packages to keep model's data, let us suppose
in a new project a util package was created and in this package two classes and a note were created:



Suppose, that after that somebody created in the util package a new
Use Case diagram named "MyUseCase" with a note and an actor:


Now, the contents of the util directory on a disk will be the following:
util\
Class1.java
Class2.java
util.dfPackage
MyUseCase.dfUseCase
In the RWI model the util package is represented by the following
RwiElements:
RwiPackage (name is "util") (represents util directory)\
RwiNode (name is "Class1") (represents Class1)
RwiNode (name is "Class2") (represents Class2)
RwiDiagram (name is "util") (represents the class diagram of util package - it is a physical package diagram (see below))
RwiDiagram (name is "MyUseCase") (represents the use case diagram MyUseCase)
RwiPackage (name is "util.dfPackage") (this package is physically stored in util.dfPackage file)\
RwiNode (name is "Note1" (represents Note1 in the class diagram)
RwiPackage (name is "MyUseCase.dfPackage") (this package is physically stored in MyUseCase.dfPackage file)\
RwiNode (name is "Actor1") (represents the actor in the use case diagram)
RwiNode (name is "Note1") (represents Note1 in the use case diagram)
Note that both RwiDiagrams, RwiNodes representing notes and actor, physically are stored in the
files util.dfPackage and MyUseCase.dfPackage
An imported package is a package imported by the project. The root packages for the imported packages are specified in the "Search/Classpath" tab in the project properties dialog (Advanced mode).
Each non-imported directory-RwiPackage
(it is a model's package,
the root packages of the model's packages are specified in the
"Project Paths" tab in the project properties dialog (Advanced mode))
has an automatically
created and associated with it class diagram called
a physical package diagram. This physical package diagram is always
synchronized with the package's contents (if something added a class to the package, the diagram will
reflect this change and show that class). In our example, the util's physical package diagram
is "util" RwiDiagram.
For non-imported directory-RwiPackage it is possible to get its physical package diagram
using getPhysicalDiagram method.
For all the diagrams method RwiContainer.getContainingPackage
will return a directory-RwiPackage (in our example, for both class diagram and use diagram
this method will return RwiPackage representing util directory).
If it is needed to get RwiPackage containing the design elements for the
the diagram then RwiDiagram.getDesignPackage method should be used.
RwiPackage can be examined on whether it is a directory-RwiPackage using
hasProperty(RwiProperty.DIRECTORY_PACKAGE).
Summary
Each RwiDiagram has one or two associated RwiPackages:
RwiPackages:
RwiPackage with the source code-based elements this diagram reflects.
RwiPackage with the design elements for that diagram (notes etc). Such
package is created only when you add the first design element to the diagram (for example, when you
create the first note).
RwiPackage - the one that keeps the design
elements.
Note, that even if you create a new class diagram for the directory-RwiPackage
it will not become a physical package diagram (physical package diagram is created automatically).
Because of that if you create new classes in the package the newly created class diagram will
not be aware of
it. That is why it will have only one RwiPackage associated with it - the one that keeps
design elements of that diagram.
| Method Summary | |
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 | canCreateSubpackage()Checks whether it is possible to create a new subpackage of this package. |
RwiDiagram | createDiagram(String shapeType)Creates a new diagram with the specified value of RwiProperty.SHAPE_TYPE property |
RwiNode | createNode(String shapeType)Creates a new node in this package with the specified value of RwiProperty.SHAPE_TYPE property. |
RwiNode | createNodeByPattern(String language, String patternName)Creates a new node in this package using the specified pattern. |
RwiPackage | createSubpackage()Creates a new subpackage of this package. |
RwiDiagramEnumeration | diagrams()Returns an enumeration of diagrams within this package. |
RwiDiagram | getPhysicalDiagram()Returns the physical package diagram for this directory- RwiPackage. |
RwiNodeEnumeration | nodes()Returns an enumeration of nodes within this package. |
RwiPackageEnumeration | subpackages()Returns an enumeration of subpackages in this package. |
| 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 boolean canCreateDiagram(String shapeType)
RwiProperty.SHAPE_TYPE propertySHAPE_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 creates a new node, false otherwisepublic boolean canCreateNodeByPattern(String language, String patternName)
RwiPattern interface.true if is possible to create a new node, false otherwisepublic boolean canCreateSubpackage()
true if it is possible to create a new subpackage of this package,
false otherwisepublic RwiDiagram createDiagram(String shapeType)
RwiProperty.SHAPE_TYPE propertySHAPE_TYPE property. Cannot be
null.
For example, let us write a script which creates a new use case diagram with an actor named "CEO"
in the selected diagram's package:
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;
RwiDiagram newDiagram = diagram.getContainingPackage().createDiagram(RwiShapeType.USE_CASE_DIAGRAM);
RwiNodeReference actorReference = newDiagram.createNode(RwiShapeType.ACTOR);
RwiNode actor = actorReference.getNode();
actor.setProperty(RwiProperty.NAME, "CEO");
}
RwiDiagrams - see RwiDiagram).
public RwiNode createNode(String shapeType)
RwiProperty.SHAPE_TYPE property. This method should not be used for generation
of the source code-represented elements like new classes or interfaces (for example,
someRwiPackage.createNode(RwiShapeType.CLASS) will not create a new class).
See createNodeByPattern method.
Or, you wish to create a node for a non-source code-represented element (a note, actor etc.), it is be better to use RwiDiagram.createNode method for the diagram you want the node to be created in.
SHAPE_TYPE property. Cannot
be null.public RwiNode createNodeByPattern(String language, String patternName)
RwiPattern interface.
For example, here is a script which creates a new class named "MyNewClass" and a new interface
named "MyNewInterface" in the selected diagram's containing package:
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;
RwiPackage rwiPackage = diagram.getContainingPackage();
RwiNode newClass = rwiPackage.createNodeByPattern(RwiLanguage.JAVA, RwiPattern.DEFAULT_CLASS); //creates a public class
newClass.setProperty(RwiProperty.NAME, "MyNewClass");
RwiNode newInterface = rwiPackage.createNodeByPattern(RwiLanguage.JAVA, RwiPattern.DEFAULT_INTERFACE); //creates a public interface
newInterface.setProperty(RwiProperty.NAME, "MyNewInterface");
}
RwiDiagrams - see RwiDiagram).
public RwiPackage createSubpackage()
public void run(IdeContext context){
RwiElement[] selectedRwiElements = context.getRwiElements();
RwiElement element = selectedRwiElements[0];
if ( ! (element instanceof RwiDiagram) ) {
return;
}
RwiDiagram diagram = (RwiDiagram)element;
RwiPackage subpackage = diagram.getContainingPackage().createSubpackage();
subpackage.setProperty(RwiProperty.NAME, "mySubpackage");
... //work with subpackage
}
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 RwiDiagrams - see RwiDiagram).public RwiDiagramEnumeration diagrams()
public RwiDiagram getPhysicalDiagram()
RwiPackage. For other kinds
of packages returns null.RwiPackagepublic RwiNodeEnumeration nodes()
public RwiPackageEnumeration subpackages()
getContainingPackage() method.
| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||