{
// Double-clicking a placeholder w/o reference path means creating a reference to a process or process element.
// We may either create a new one or choose an existing one.
// Ask the user what he wants:
ResourceCollection res = getDrawing().getEditor().getPluginResourceCollection();
String title = res.getRequiredString("placeholder.referencedialog.title");
String text = res.getRequiredString("placeholder.referencedialog.text");
JMsgBox msgBox = new JMsgBox(null, title, text, JMsgBox.TYPE_YESNOCANCEL);
msgBox.setResource(res);
msgBox.setResourcePrefix("placeholder.referencedialog.");
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);