* @param socketFigure The referred socket figure
*/
public static void addParamMenu(InteractionEvent ie, final Modeler modeler, final SocketFigure socketFigure)
{
// Popup menu item group
JaspiraAction group = null;
NodeSocket socket = socketFigure.getNodeSocket();
for (Iterator it = socket.getParams(); it.hasNext();)
{
final NodeParam param = (NodeParam) it.next();
// Create an action that toggles the parameter visibility
JaspiraAction action = new JaspiraAction(modeler, "modeler.edit.paramvisibility.prototype")
{
public void actionPerformed(ActionEvent e)
{
// Reinitialize the socket contents
modeler.startUndo("Show/hide Parameter");
modeler.getDrawingView().clearSelection();
// Toggle the parameter visibility
param.setVisible(!param.isVisible());
// Rebuild the parmeter list, displaying the visible parameters only
socketFigure.reinitParams(false);
modeler.endUndo();
modeler.getDrawingView().redraw();
}
};
// Provide the parameter name or display name as action title
String name;
if (DisplayObjectPlugin.getInstance().isTitleModeText())
name = param.getDisplayText();
else
name = param.getName();
action.setDisplayName(name);
// Enable the action only if we may hide the parameter
boolean canHide = !param.isVisible() || canHideParam(param);
action.setEnabled(canHide);
// The action selection state reflects the parameter visiblity
action.setSelected(param.isVisible());
// Add the action to the 'Parameters' group
if (group == null)
{
// TODO Feature 5 Add the 'show/hide all' menu items
// Create the 'Parameters' menu group
group = new JaspiraAction(modeler, "modeler.edit.paramvisibility");
}
group.addMenuChild(action);
}
if (group != null)