if (!modeler.getPluginComponent().isShowing())
{
return EVENT_IGNORED;
}
final WorkspaceDrawingView workspaceView = modeler.getDrawingView();
if (ie.getSourcePlugin() == modeler)
{
DataFlavor [] flavor = ie.getTransferDataFlavors();
JaspiraAction group = new JaspiraAction("popup", null, null, null, null, 100, JaspiraAction.TYPE_GROUP);
for (int i = 0; i < flavor.length; i++)
{
if (flavor [i].equals(ClientFlavors.MODEL_OBJECT))
{
ModelObject mo = (ModelObject) ie.getSafeTransferData(flavor [i]);
configuratorSupport.addConfiguratorMenuOptions(mo, group);
}
if (flavor [i].equals(ModelerFlavors.FIGURE))
{
Figure figure = (Figure) ie.getSafeTransferData(flavor [i]);
workspaceView.singleSelect(figure);
}
if (flavor [i].equals(ModelerFlavors.PARAM_FIGURE))
{
final ParamFigure paramFigure = (ParamFigure) ie.getSafeTransferData(flavor [i]);
final NodeParam nodeParam = paramFigure.getNodeParam();
SocketFigure socketFigure = (SocketFigure) paramFigure.getParent();
// Add the 'Parameter visibility' sub menu for all parameters of the socket if appropriate
ParamVisibilityHelper.addParamMenu(ie, modeler, socketFigure);
// 'Parameter Value Wizard' popup
final NodeFigure nodeFigure = (NodeFigure) socketFigure.getParent();
if (ParamValueWizard.isParameterValueWizardApplyable(modeler, nodeFigure, nodeParam.getSocket().getName()))
{
JaspiraAction wizardGroup = new JaspiraAction("popupwizard", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);
wizardGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.paramvaluewizard")
{
public void actionPerformed(ActionEvent e)
{
// Display parameter value wizard if appropriate
ParamValueWizard.displayParameterValueWizard(modeler, nodeFigure, nodeParam.getSocket().getName(), nodeParam.getName());
}
});
ie.add(wizardGroup);
}
// 'Create identical process variable' popup
String paramName = nodeParam.getName();
if (nodeParam.getProcess().getProcessVariableByName(paramName) == null)
{
JaspiraAction wizardGroup = new JaspiraAction("processvargroup", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);
wizardGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.createprocessvarfromparam")
{
public void actionPerformed(ActionEvent e)
{
// Forward to the process variables plugin
modeler.fireEvent("variables.createprocessvarfromparam", nodeParam);
}
});
ie.add(wizardGroup);
}
}
if (flavor [i].equals(ModelerFlavors.SOCKET_FIGURE))
{
final SocketFigure socketFigure = (SocketFigure) ie.getSafeTransferData(flavor [i]);
final NodeSocket socket = socketFigure.getNodeSocket();
// Add the 'Parameter visibility' sub menu if appropriate
ParamVisibilityHelper.addParamMenu(ie, modeler, socketFigure);
// 'Parameter Value Wizard' popup
final NodeFigure nodeFigure = (NodeFigure) socketFigure.getParent();
if (ParamValueWizard.isParameterValueWizardApplyable(modeler, nodeFigure, socket.getName()))
{
JaspiraAction wizardGroup = new JaspiraAction("popupwizard", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);
wizardGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.paramvaluewizard")
{
public void actionPerformed(ActionEvent e)
{
// Display parameter value wizard if appropriate
ParamValueWizard.displayParameterValueWizard(modeler, nodeFigure, socket.getName(), null);
}
});
ie.add(wizardGroup);
}
/* Currently unused, rathr leads to confusion
JaspiraAction socketToNodeGroup = new JaspiraAction("popupsockettonode", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);
// 'Create initial node' popup
socketToNodeGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.createentryfromsocket")
{
public void actionPerformed(ActionEvent e)
{
modeler.startUndo("Create Initial Node");
if (drawing.getProcess().getNodeByName(socket.getName()) != null)
{
// A node with this name already exists; issue a warning.
// The createFinalNodeFromSocket method will ensure that the new node
// has a unique name.
String msg = modeler.getPluginResourceCollection().getRequiredString("messages.nodealreadyexists");
JMsgBox.show(null, msg, JMsgBox.ICON_INFO);
}
// Create a node from the socket and add it to the process
NodeFigure nodeFigure = ModelerUtil.createInitialNodeFromSocket(socketFigure);
modeler.endUndo();
}
});
if (socket.isExitSocket())
{
// 'Create final node' popup
socketToNodeGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.createexitfromsocket")
{
public void actionPerformed(ActionEvent e)
{
modeler.startUndo("Create Final Node");
if (drawing.getProcess().getNodeByName(socket.getName()) != null)
{
// A node with this name already exists; issue a warning.
// The createFinalNodeFromSocket method will ensure that the new node
// has a unique name.
String msg = modeler.getPluginResourceCollection().getRequiredString("messages.nodealreadyexists");
JMsgBox.show(null, msg, JMsgBox.ICON_INFO);
}
// Create a node from the socket and add it to the process
NodeFigure nodeFigure = ModelerUtil.createFinalNodeFromSocket(socketFigure);
modeler.endUndo();
}
});
}
ie.add(socketToNodeGroup);
*/
}
if (flavor [i].equals(ModelerFlavors.NODE_FIGURE))
{
final NodeFigure nodeFigure = (NodeFigure) ie.getSafeTransferData(flavor [i]);
group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.mirrororientation")
{
public void actionPerformed(ActionEvent e)
{
modeler.startUndo("Flip Orientation");
nodeFigure.flipOrientation();
workspaceView.checkDamage();
modeler.endUndo();
}
});
group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.rotateorientationcw")
{
public void actionPerformed(ActionEvent e)
{
modeler.startUndo("Rotate Orientation");
nodeFigure.changeOrientation(NodeFigure.ROTATE_CW);
workspaceView.checkDamage();
modeler.endUndo();
}
});
group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.rotateorientationccw")
{
public void actionPerformed(ActionEvent e)
{
modeler.startUndo("Rotate Orientation");
nodeFigure.changeOrientation(NodeFigure.ROTATE_CCW);
workspaceView.checkDamage();
modeler.endUndo();
}
});
}
if (flavor [i].equals(ModelerFlavors.COLORIZABLE))
{
final Colorizable col = (Colorizable) ie.getSafeTransferData(flavor [i]);
// 'Reset color' popup
if (col.getFillColor() != null && !col.getFillColor().equals(col.getDefaultFillColor()))
{
group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.resetcolor")
{
public void actionPerformed(ActionEvent e)
{
modeler.startUndo("Reset Color");
// TODO Feature 6: Reset subordinate element color, too
col.setFillColor(col.getDefaultFillColor());
workspaceView.checkDamage();
modeler.endUndo();
}
});
}