| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
RwiModel interface provides a set of starting-point methods for working with the
model.
The RwiModel instance can be obtained only via static
RwiModelAccess.getModel method.
RwiModel model = RwiModelAccess.getModel();
RwiPackageEnumeration roots = model.rootPackages(RwiProperty.MODEL);
while (roots.hasMoreElements()) {
RwiPackage rootPackage=roots.nextRwiPackage();
packageProcessing(rootPackage);
}
Once the model object is obtained,
it can be used for accessing the model's data:
rootPackages(String) method returns an enumeration of root packages of the specific kind:
diagramTypes method returns an enumeration of shape types of the diagrams in the model
(see RwiProperty.SHAPE_TYPE property).
findElement method finds an element by its unique name.
RwiElement by its low-level API object
representation. This is useful when you have gotten a low-level API object (
via RwiElement.getCodeElement method) representing some
RwiElement, performed some actions using low-level API techniques, obtained the
result in the form of the low-level API object, and finally wish to return to the RWI API and to get
the RWI equivalent of that low-level object:
import com.togethersoft.openapi.sci.SciClass;
...
public RwiNode findClassWithTheSameNumberOfMethods(RwiNode rwiNodeRepresentingAClass){
if (rwiNodeRepresentingAClass.getCodeElement() instanceof SciClass){
SciClass sciClass = (SciClass)rwiNodeRepresentingAClass.getCodeElement();
SciClass resultSciClass = findSciClassWithTheSameNumberOfMethods(sciClass);
RwiModel model = RwiModelAccess.getModel();
return model.findNode(resultSciClass);
}
return null;
}
private SciClass findSciClassWithTheSameNumberOfMethods(SciClass theTemplateSciClass){
...
}
The findDiagramFor(RwiElement) method returns RwiDiagram
containing the primary reference to the specified RwiElement.
| Method Summary | |
RwiElement | applyPattern(RwiElement element, String patternName)Applies the specified pattern to the given RwiElement. |
boolean | canApplyPattern(RwiElement element, String patternName)Checks whether it is possible to apply the specified pattern to the given RwiElement. |
RwiDiagramEnumeration | diagramPrototypes()Returns an enumeration of all possible RwiDiagrams valid for this project. |
StringEnumeration | diagramTypes()Returns an enumeration of shape types of the diagrams in the model. |
RwiDiagram | findDiagramFor(RwiElement rwiElement)Finds RwiDiagram containing the primary reference to the specified RwiElement. |
RwiElement | findElement(String uniqueName)Finds an element by its unique name. |
RwiLink | findLink(Object codeElement)Returns RwiLink by given low-level API object representation. |
RwiLink | findLink(Enumeration codeElements)Returns RwiLink by given enumeration of low-level API objects representing
RwiLink. |
RwiMember | findMember(Object codeElement)Returns RwiMember by given low-level API object representation. |
RwiMember | findMember(Enumeration codeElements)Returns RwiMember by given enumeration of low-level API objects representing
RwiMember. |
RwiNode | findNode(Object codeElement)Returns RwiNode by given low-level API object representation. |
RwiPackage | findPackage(Object codeElement)Returns RwiPackage by given low-level API object representation. |
RwiExtensionManager | getExtensionManager()Returns RwiExtensionManager object used by internal scripts. |
void | markElementAsChanged(RwiElement element)Mark specified element as changed in order to it will repainted during next diagram update. |
RwiPackageEnumeration | rootPackages(String modelPart)Returns an enumeration of the root packages of the specific kind. |
| Method Detail |
public RwiElement applyPattern(RwiElement element, String patternName)
RwiElement. After applying, this
method returns the modified RwiElement.RwiElementRwiPattern interface.RwiElementpublic boolean canApplyPattern(RwiElement element, String patternName)
RwiElement.RwiElementRwiPattern interface.true if the specified pattern can by applied to the given RwiElement,
false otherwisepublic RwiDiagramEnumeration diagramPrototypes()
RwiDiagrams valid for this project.
The returned diagrams are not model diagrams - they can be used only to get some
information about different types of diagrams
via methods of IdeResourceManager.
For example, it is possible to get an icon of a class diagram:
import com.togethersoft.openapi.ide.resource.IdeResourceManager;
import com.togethersoft.openapi.ide.resource.IdeResourceManagerAccess;
import com.togethersoft.openapi.ide.resource.IdeResourceIconType;
import com.togethersoft.openapi.rwi.RwiModel;
import com.togethersoft.openapi.rwi.RwiModelAccess;
import com.togethersoft.openapi.rwi.RwiDiagram;
import com.togethersoft.openapi.rwi.enum.*;
import javax.swing.Icon;
...
public Icon getClassDiagramIcon(){
RwiModel model = RwiModelAccess.getModel();
RwiDiagramEnumeration fakeDiagrams = model.diagramPrototypes();
while (fakeDiagrams.hasMoreElements()){
RwiDiagram nextDiagram= fakeDiagrams.nextRwiDiagram();
if (!RwiShapeType.CLASS_DIAGRAM.equals(nextDiagram.getProperty(RwiProperty.SHAPE_TYPE))) continue;
return IdeResourceManagerAccess.getResourceManager().getIcon(nextDiagram, IdeResourceIconType.SMALL);
}
return null;
}RwiDiagramEnumeration consisting of fake RwiDiagramspublic StringEnumeration diagramTypes()
public RwiDiagram findDiagramFor(RwiElement rwiElement)
RwiDiagram containing the primary reference to the specified RwiElement.
The word "primary" means a non-imported reference, since several RwiDiagrams can
have references to the same RwiElement, but only one will contain a non-imported reference.
See the description of RwiDiagram interface for an explanation about primary
and imported references.
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);
}RwiElementRwiDiagram, or null if it is not possible to find RwiDiagram
containing the primary reference to the specified RwiElementpublic RwiElement findElement(String uniqueName)
null.public RwiLink findLink(Object codeElement)
RwiLink by given low-level API object representation. If it is not
possible to find such a link, returns null.RwiLink, or nullpublic RwiLink findLink(Enumeration codeElements)
RwiLink by given enumeration of low-level API objects representing
RwiLink. If it is not
possible to find such a link, returns null.RwiLink, or nullpublic RwiMember findMember(Object codeElement)
RwiMember by given low-level API object representation. If it is not
possible to find such a member, returns null.RwiMember, or nullpublic RwiMember findMember(Enumeration codeElements)
RwiMember by given enumeration of low-level API objects representing
RwiMember. If it is not
possible to find such a member, returns null.RwiMember, or nullpublic RwiNode findNode(Object codeElement)
RwiNode by given low-level API object representation. If it is not
possible to find such a node, returns null.RwiNode, or nullpublic RwiPackage findPackage(Object codeElement)
RwiPackage by given low-level API object representation. If it is not
possible to find such a package, returns null.RwiMember, or nullpublic RwiExtensionManager getExtensionManager()
RwiExtensionManager object used by internal scripts.RwiExtensionManagerpublic void markElementAsChanged(RwiElement element)
RwiElement to be marked.public RwiPackageEnumeration rootPackages(String modelPart)
rootPackages(RwiProperty.MODEL) returns an enumeration of the model's root packages.
These are packages composing the model itself, they contain its data (they are specified in the
"Project Paths" tab in the project properties dialog (Advanced mode)).
Normally you would use the method only with RwiProperty.MODEL parameter when working
with the model.
rootPackages(RwiProperty.IMPORT) returns an enumeration of the model's imported root packages.
These are packages specified in the "Search/Classpath" tab in the project properties dialog (Advanced mode)).
rootPackages(RwiProperty.COMPONENT) returns an enumeration of the components' root packages.
Components can be added to the project by checking the "Include Components" checkbox in the project properties dialog.
Note that components' packages are considered imported packages as well and they will be included in
the enumeration of packages returned by rootPackages(RwiProperty.IMPORT) call.
rootPackages(null) returns an enumeration of packages which is a join of enumerations
returned by the rootPackages(RwiProperty.MODEL) and
rootPackages(RwiProperty.IMPORT) methods.
RwiModel model = RwiModelAccess.getModel();
RwiPackageEnumeration roots = model.rootPackages(RwiProperty.MODEL);
while (roots.hasMoreElements()) {
RwiPackage rootPackage=roots.nextRwiPackage();
packageProcessing(rootPackage);
}RwiProperty.MODEL,
RwiProperty.IMPORT, RwiProperty.COMPONENT or null
| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||