Question & Answer
Question
How do you apply diagram properties to existing diagram elements using Java script in IBM Rational Rhapsody?
Cause
To automate the manual operation of applying the diagram properties for existing diagram elements
Answer
The following Java script can be used to apply diagram properties for existing diagram elements:
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
---|
import com.telelogic.rhapsody.core.*;
public class updateTagDisplay {
public static void main(String[] args) {
IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPProject prj = app.activeProject();
for (Object obj : prj.getNestedElementsRecursive().toList())
if(obj instanceof IRPObjectModelDiagram)
{
IRPObjectModelDiagram myOMD = (IRPObjectModelDiagram) obj;
String grPrp = myOMD.getPropertyValue("ObjectModelGe.Tag.ShowName");
for(Object obj1 : myOMD.getGraphicalElements().toList())
if(obj1 instanceof IRPGraphNode)
{
IRPGraphNode myNode = (IRPGraphNode) obj1;
String eleType = myNode.getModelObject().getMetaClass();
if(eleType.equals("Tag"))
myNode.setGraphicalProperty("ShowName", grPrp);
}
}
}
}
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21455896