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");