msgBox.initDialog();
SwingUtil.show(msgBox);
int choice = msgBox.getUserChoice();
Model model = node.getOwningModel();
if (choice == JMsgBox.TYPE_YES)
{
// Yes means create a new process
final Item item = ItemCreationUtil.createItem(model, placeholderNode.getName(), placeholderNode.getDisplayName(), ItemTypes.PROCESS, null);
if (item != null)
{
assignPlaceholderReference(item);
// Open the new process
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
getDrawing().getEditor().fireEvent("plugin.association.open", new BasicTransferable(item));
}
});
}
}
else if (choice == JMsgBox.TYPE_NO)
{
// Yes means reference an existing process
ItemSelectionDialog dlg = new ItemSelectionDialog(ApplicationUtil.getActiveWindow(), true);
String dlgTitle = res.getRequiredString("placeholder.referencedialog.select");
dlg.setTitle(dlgTitle);
// We may select a single object only
dlg.setSelectionMode(ItemTree.SELECTION_SINGLE);
dlg.setShowGroups(false);
dlg.setSupportedItemTypes(new String [] { ItemTypes.MODEL, ItemTypes.PROCESS });
dlg.setSelectableItemTypes(new String [] { ItemTypes.PROCESS });
dlg.setSupportedObjectClasses(new Class [] { Node.class });
dlg.setSelectableObjectClasses(new Class [] { Node.class });
ItemTreeState state = new ItemTreeState();
state.addExpandedQualifier(model.getQualifier());
// Build the tree, expanding the first level and the currently selected item
dlg.rebuildTree();
dlg.expand(1);
dlg.restoreState(state);