public void eventOccured(GUIEvent event) {
String command = event.getName();
try {
if (command.equals("tree.popup")) {
TreeItem items[] = (TreeItem[]) dataModel.getValue("tree.selected");
if (items.length > 0) {
boolean notRoot = items.length > 1 || (items.length == 1 && items[0] != rootNode);
boolean moveUp =
items.length == 1
&& items[0] != rootNode
&& (items[0].getParentWidget().getChildIndex(items[0]) > 0);
boolean moveDown =
items.length == 1
&& items[0] != rootNode
&& (items[0].getParentWidget().getChildIndex(items[0])
< items[0].getParentWidget().getChildCount() - 1);
treePopupMenu.getWidget("Delete").setEnabled(notRoot);
treePopupMenu.getWidget("MoveUp").setEnabled(moveUp);
treePopupMenu.getWidget("MoveDown").setEnabled(moveDown);
treePopupMenu.popup(event);
}
} else if (command.equals("property.popup")) {
propertyPopupMenu.popup(event);
} else if (command.equals("delete")) {
TreeItem items[] = (TreeItem[]) dataModel.getValue("tree.selected");
for (int i = 0; i < items.length; i++) {
if (items[i] != rootNode)
doDelete(items[i]);
}
} else if (command.equals("add_property")) {
TreeItem items[] = (TreeItem[]) dataModel.getValue("tree.selected");
if (items.length == 1 && items[0] != rootNode) {
new AddPropertyDialog(frame, (WidgetUserObject) items[0].getUserObject());
}
} else if (command.equals("delete_property")) {
TableRow rows[] = (TableRow[]) dataModel.getValue("property.value");
for (int i = 0; i < rows.length; i++) {
if (rows[i] instanceof PropertyTableRow) {
doDeleteProperty((PropertyTableRow) rows[i]);
Builder.markModified();
}
}
} else if (command.equals("events")) {
TreeItem items[] = (TreeItem[]) dataModel.getValue("tree.selected");
if (items.length == 1 && items[0] != rootNode) {
new EventDialog(this, frame, (WidgetUserObject) items[0].getUserObject());
}
} else if (command.equals("move_up")) {
TreeItem items[] = (TreeItem[]) dataModel.getValue("tree.selected");
if (items.length == 1 && items[0] != rootNode) {
doMove(items[0], true);
}
} else if (command.equals("move_down")) {
TreeItem items[] = (TreeItem[]) dataModel.getValue("tree.selected");
if (items.length == 1 && items[0] != rootNode) {
doMove(items[0], false);
}
}