com.togethersoft.openapi.rwi
Interface RwiContainer

All Known Subinterfaces:
RwiDiagram, RwiNode, RwiPackage

public interface RwiContainer
extends RwiElement

A top-level representative of a container of elements. RwiContainter's derivatives collect
elements into spesific
logical structures. These derivatives are RwiPackage, RwiDiagram and
RwiNode, which allow working with the model from different angles
of view and levels of detalization.


This interface defines the paste method which allows to paste RwiElement
into this container:



someRwiNode.paste(rwiElementToPaste, null, false);


The elements() method gives an enumeration of all elements this container has:



RwiElementEnumeration elementsEnum=someContainer.elements();
while (elementsEnum.hasMoreElements()){
RwiElement nextRwiElement=elements.nextRwiElement();
System.out.println("The name of the element is :"+nextRwiElement.getProperty(RwiProperty.NAME));
}

Normally the method elements will rarely be used since SciContainer's derivatives
contain more specific and useful methods for working with the elements in this container (see
RwiPackage.subpackages,
RwiPackage.nodes,
RwiPackage.diagrams,
RwiDiagram.nodeReferences,
RwiDiagram.diagramReferences,
RwiNode.members and
RwiNode.subnodes).


All new elements created by the methods in the derivatives of this intrface are not written instantly to
the disk. That is they are created, but are written to the disk only when Together automatically
flushes all the data to the disk (when it loses the focus etc).


For example, if you create a new subpackage
for certain RwiPackage using the method RwiPackage.createSubpackage,
the newly created package is fully functional for the script, it is already a part of the model etc,
but it is kept in some virtual space. The directory is physically created only when
you switch to another applications, close the project, close Together etc.
If your script needs to have the directory created instantly,
you must explicitly call the IdeManager.saveAll method:


RwiPackage newPackage = someRwiPackage.createSubpackage();
//Once again: the newPackage is fully functional, it is a first-class part of the model,
//except that the directory physically is not created yet.
//Note that if you create new nodes/diagrams/packages in the newPackage, they also are
//kept in the virtual space, yet they are also fully functional - you can
//change their names, contents etc.
//
//the following line is needed only if you want the directory (and its contents) to be created "right now"
IdeAccess.getIdeManager().saveAll();

Do not worry, if your script creates something it will certainly be written - when you close
the project, Together session, switch to another application or when the script is finished.

Author:
TogetherSoft
Since: Together 3.0

Method Summary
 booleancanPaste(RwiElement element, RwiElement anchor, boolean before)
          Returns true if the element can be pasted in the specified place,
false otherwise.
 RwiElementEnumerationelements()
          Returns an enumeration of all elements in this container
 RwiPackagegetContainingPackage()
          Returns the package this element belongs to.
 RwiElementpaste(RwiElement element, RwiElement anchor, boolean before)
          Pastes the element into this containter.

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

canPaste

public boolean canPaste(RwiElement element, RwiElement anchor, boolean before)
Returns true if the element can be pasted in the specified place,
false otherwise. false can be returned either if
element can't be pasted at all, or if it can't be pasted in the specified place.
Parameters:
element the RwiElement to check whether it can be pasted
anchor the RwiElement before or after the element
will be pasted
before The boolean flag. If true, then new element will be
pasted before the anchor. If false - after. If anchor
is null, then the value of this parameter does not matter.
Returns: true if the element can be pasted, false otherwise

elements

public RwiElementEnumeration elements()
Returns an enumeration of all elements in this container
Returns: an enumeration of all elements in this container

getContainingPackage

public RwiPackage getContainingPackage()
Returns the package this element belongs to. For root packages returns null.
Returns: the package this element belongs to

paste

public RwiElement paste(RwiElement element, RwiElement anchor, boolean before)
Pastes the element into this containter.
Parameters:
element the RwiElement which needs be to pasted
anchor The RwiElement before or after the element
will be pasted. If anchor is null, then this container will paste
the element in the valid place choosen by this container.
before The boolean flag. If true, then new element will be
pasted before the anchor. If false - after. If anchor
is null, then the value of this parameter does not matter.
Returns: new just pasted element into this container