FileDocCategorySizeDatePackage
Lesson2.javaAPI DocExample3098Thu Feb 17 20:00:56 GMT 2000com.togethersoft.modules.tutorial

Lesson2

public class Lesson2 extends Object implements com.togethersoft.openapi.ide.IdeScript
This script goes through the selection and outputs the names and shapetypes of elements. The shapetype property is one of the most important properties in RWI - you will see how it is used in the next lessons. For now it is useful just to run this script several times to see the shapetypes of the elements in a diagram. See RwiProperty interface description in the API docs for information about RwiProperty.SHAPE_TYPE property.
author
TogetherSoft LLC

Fields Summary
Constructors Summary
Methods Summary
public voidrun(com.togethersoft.openapi.ide.IdeContext context)

        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Lesson2 script: started");
        //checking if project is opened.
        if (IdeProjectManagerAccess.getProjectManager().getActiveProject() == null) {
            IdeMessageManagerAccess.printMessage(IdeMessageType.ERROR_MODAL, "No open project");
            IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Lesson2 script: finished");
            return;
        }
        //now let's work with the selection.
        //the array of selected RwiElements
        RwiElement[] selectedRwiElements = context.getRwiElements();
        if (selectedRwiElements == null || selectedRwiElements.length == 0) {
            IdeMessageManagerAccess.printMessage(IdeMessageType.ERROR_MODAL, "No selection was made.");
            IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Lesson2 script: finished");
            return;
        }
        IdeMessageManagerAccess.getMessageManager().setPaneVisible(true); //making the message pane visible
        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Selection contains the following elements:");
        //iterating the selection
        for (int i = 0; i < selectedRwiElements.length; i++) {
            RwiElement rwiElement = selectedRwiElements[i];
            IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION,
                "ShapeType: " + rwiElement.getProperty(RwiProperty.SHAPE_TYPE) + ", full name: " +
                rwiElement.getProperty(RwiProperty.FULL_NAME));
        }
        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Lesson2 script: finished");