Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.rwi
Interface RwiModel

public interface RwiModel

`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:
  - the model's root packages
  - the model's imported root packages
  - the components' root packages

- `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.

This interface also provides methods for finding an `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`.

Author:
  TogetherSoft
See Also: RwiPropertyMap, RwiPackage, RwiDiagram, 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 `RwiDiagram`s 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

### applyPattern

    public RwiElement applyPattern(RwiElement element, String patternName)

  Applies the specified pattern to the given `RwiElement`. After applying, this method returns the modified `RwiElement`.
  Parameters:
    element - the `RwiElement`
    patternName - string with the name of the pattern being used. Some pattern names are defined in the `RwiPattern` interface.
  Returns: the modified `RwiElement`

### canApplyPattern

    public boolean canApplyPattern(RwiElement element, String patternName)

  Checks whether it is possible to apply the specified pattern to the given `RwiElement`.
  Parameters:
    element - the `RwiElement`
    patternName - string with the name of the pattern being used. Some pattern names are defined in the `RwiPattern` interface.
  Returns: `true` if the specified pattern can by applied to the given `RwiElement`, `false` otherwise

### diagramPrototypes

    public RwiDiagramEnumeration diagramPrototypes()

  Returns an enumeration of all possible `RwiDiagram`s 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;
       }

  Returns: `RwiDiagramEnumeration` consisting of fake `RwiDiagrams`
  See Also:
    IdeResourceManager

### diagramTypes

    public StringEnumeration diagramTypes()

  Returns an enumeration of shape types of the diagrams in the model.
  Returns: an enumeration of shape types of the diagrams in the model.
  See Also:
    RwiProperty.SHAPE_TYPE

### findDiagramFor

    public RwiDiagram findDiagramFor(RwiElement rwiElement)

  Finds `RwiDiagram` containing the primary reference to the specified `RwiElement`. The word "primary" means a non-imported reference, since several `RwiDiagram`s 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);
       }

  Parameters:
    rwiElement - `RwiElement`
  Returns: `RwiDiagram`, or `null` if it is not possible to find `RwiDiagram` containing the primary reference to the specified `RwiElement`

### findElement

    public RwiElement findElement(String uniqueName)

  Finds an element by its unique name. If there is no such element in the model, returns `null`.
  Parameters:
    uniqueName - the string with the unique name of an element which needs to be found
  Returns: an element by its unique name
  See Also:
    RwiDiagram.findReference(com.togethersoft.openapi.rwi.RwiElement), RwiElement.getUniqueName(), findDiagramFor(com.togethersoft.openapi.rwi.RwiElement)

### findLink

    public RwiLink findLink(Object codeElement)

  Returns `RwiLink` by given low-level API object representation. If it is not possible to find such a link, returns `null`.
  Parameters:
    codeElement - a low-level API object
  Returns: `RwiLink`, or `null`

### findLink

    public RwiLink findLink(Enumeration codeElements)

  Returns `RwiLink` by given enumeration of low-level API objects representing `RwiLink`. If it is not possible to find such a link, returns `null`.
  Parameters:
    codeElement - a low-level API object
  Returns: `RwiLink`, or `null`

### findMember

    public RwiMember findMember(Object codeElement)

  Returns `RwiMember` by given low-level API object representation. If it is not possible to find such a member, returns `null`.
  Parameters:
    codeElement - a low-level API object
  Returns: `RwiMember`, or `null`

### findMember

    public RwiMember findMember(Enumeration codeElements)

  Returns `RwiMember` by given enumeration of low-level API objects representing `RwiMember`. If it is not possible to find such a member, returns `null`.
  Parameters:
    codeElements - the enumeration of low-level API objects
  Returns: `RwiMember`, or `null`

### findNode

    public RwiNode findNode(Object codeElement)

  Returns `RwiNode` by given low-level API object representation. If it is not possible to find such a node, returns `null`.
  Parameters:
    codeElement - a low-level API object
  Returns: `RwiNode`, or `null`

### findPackage

    public RwiPackage findPackage(Object codeElement)

  Returns `RwiPackage` by given low-level API object representation. If it is not possible to find such a package, returns `null`.
  Parameters:
    codeElement - a low-level API object
  Returns: `RwiMember`, or `null`

### getExtensionManager

    public RwiExtensionManager getExtensionManager()

  Returns `RwiExtensionManager` object used by internal scripts.
  Returns: `RwiExtensionManager`

### markElementAsChanged

    public void markElementAsChanged(RwiElement element)

  Mark specified element as changed in order to it will repainted during next diagram update.
  Parameters:
    element - `RwiElement` to be marked.

### rootPackages

    public RwiPackageEnumeration rootPackages(String modelPart)

  Returns an enumeration of the root packages of the specific kind.
  - `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.
  For example: `

       RwiModel model = RwiModelAccess.getModel();
       RwiPackageEnumeration roots = model.rootPackages(RwiProperty.MODEL);
       while (roots.hasMoreElements()) {
           RwiPackage rootPackage=roots.nextRwiPackage();
           packageProcessing(rootPackage);
       }

  `
  Parameters:
    modelPart - the string whose value can be either `RwiProperty.MODEL`, `RwiProperty.IMPORT`, `RwiProperty.COMPONENT` or `null`
  Returns: an enumeration of the root packages
  See Also:
    RwiProperty.MODEL, RwiProperty.IMPORT, RwiProperty.COMPONENT

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD