partPopupMenu.add(GemCutter.makeNewMenuItem(getIntellicutAction(part)));
partPopupMenu.add(separator);
}
if (part instanceof DisplayedPartInput) {
DisplayedPartInput inputPart = (DisplayedPartInput) part;
if (!inputPart.isConnected()) {
partPopupMenu.add(GemCutter.makeNewMenuItem(getConnectValueGemAction(inputPart)));
if (!(inputPart.getPartInput().getGem() instanceof CollectorGem)) {
if (inputPart.getPartInput().isBurnt()) {
partPopupMenu.add(GemCutter.makeNewMenuItem(getUnburnAction(inputPart)));
} else {
partPopupMenu.add(GemCutter.makeNewMenuItem(getBurnAction(inputPart)));
}
}
}
// Create popup menu item for retargeting inputs.
final JMenu retargetInputMenu = GemCutter.makeNewMenu(GemCutter.getResourceString("PopItem_RetargetInput"));
partPopupMenu.add(retargetInputMenu);
// Get the targetable collectors, enable the menu item if not empty and if the input is not connected.
List<CollectorGem> targetableCollectorList = getTargetableCollectors(inputPart.getPartInput());
retargetInputMenu.setEnabled(!targetableCollectorList.isEmpty() && !inputPart.isConnected());
CollectorGem currentArgTarget = GemGraph.getInputArgumentTarget(inputPart.getPartInput());
// Create submenu items for retargeting to an enclosing collector.
for (final CollectorGem targetableCollector : targetableCollectorList) {
// Make the new menu item.
JMenuItem newMenuItem = GemCutter.makeNewMenuItem(getRetargetInputArgumentAction(inputPart.getPartInput(), targetableCollector));
// Enable if its not already targeted to this collector.
newMenuItem.setEnabled(targetableCollector != currentArgTarget);
// Add the menu item.