use of jmri.jmrit.display.layoutEditor.blockRoutingTable.LayoutBlockRouteTableAction in project JMRI by JMRI.
the class LayoutTurnout method showPopUp.
/**
* Display popup menu for information and editing
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
if (layoutEditor.isEditable()) {
JMenuItem jmi = null;
switch(getTurnoutType()) {
case RH_TURNOUT:
jmi = popup.add(Bundle.getMessage("RightTurnout"));
break;
case LH_TURNOUT:
jmi = popup.add(Bundle.getMessage("LeftTurnout"));
break;
case WYE_TURNOUT:
jmi = popup.add(rb.getString("WYETurnout"));
break;
case DOUBLE_XOVER:
jmi = popup.add(rb.getString("DoubleCrossOver"));
break;
case RH_XOVER:
jmi = popup.add(Bundle.getMessage("RightCrossOver"));
break;
case LH_XOVER:
jmi = popup.add(Bundle.getMessage("LeftCrossOver"));
break;
default:
break;
}
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
if (getTurnout() == null) {
jmi = popup.add(rb.getString("NoTurnout"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameTurnout") + ": " + turnoutName);
}
jmi.setEnabled(false);
if (blockName.equals("")) {
jmi = popup.add(rb.getString("NoBlock"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameBlock") + ": " + getLayoutBlock().getID());
}
jmi.setEnabled(false);
if ((type == DOUBLE_XOVER) || (type == RH_XOVER) || (type == LH_XOVER)) {
// check if extra blocks have been entered
if (blockB != null) {
jmi = popup.add(Bundle.getMessage("Block_ID", 2) + ": " + blockBName);
jmi.setEnabled(false);
}
if (blockC != null) {
jmi = popup.add(Bundle.getMessage("Block_ID", 3) + ": " + blockCName);
jmi.setEnabled(false);
}
if (blockD != null) {
jmi = popup.add(Bundle.getMessage("Block_ID", 4) + ": " + blockDName);
jmi.setEnabled(false);
}
}
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
// Rotate if there are no track connections
if ((connectA == null) && (connectB == null) && (connectC == null) && (connectD == null)) {
JMenuItem rotateItem = new JMenuItem(rb.getString("Rotate") + "...");
popup.add(rotateItem);
rotateItem.addActionListener((ActionEvent event) -> {
boolean entering = true;
boolean error = false;
String newAngle = "";
while (entering) {
// prompt for rotation angle
error = false;
newAngle = JOptionPane.showInputDialog(layoutEditor, rb.getString("EnterRotation") + " :");
if (newAngle.length() < 1) {
// cancelled
return;
}
double rot = 0.0;
try {
rot = Double.parseDouble(newAngle);
} catch (Exception e1) {
JOptionPane.showMessageDialog(layoutEditor, rb.getString("Error3") + " " + e1, Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
error = true;
newAngle = "";
}
if (!error) {
entering = false;
if (rot != 0.0) {
rotateCoords(rot);
layoutEditor.redrawPanel();
}
}
}
});
}
if (disableItem == null) {
disableItem = new JCheckBoxMenuItem(Bundle.getMessage("Disabled"));
}
disableItem.setSelected(disabled);
popup.add(disableItem);
disableItem.addActionListener((java.awt.event.ActionEvent e2) -> {
disabled = disableItem.isSelected();
});
if (disableWhenOccupiedItem == null) {
disableWhenOccupiedItem = new JCheckBoxMenuItem(rb.getString("DisabledWhenOccupied"));
}
disableWhenOccupiedItem.setSelected(disableWhenOccupied);
popup.add(disableWhenOccupiedItem);
disableWhenOccupiedItem.addActionListener((java.awt.event.ActionEvent e3) -> {
disableWhenOccupied = disableWhenOccupiedItem.isSelected();
});
popup.add(new AbstractAction(rb.getString("UseSizeAsDefault")) {
@Override
public void actionPerformed(ActionEvent e) {
setUpDefaultSize();
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editLayoutTurnout();
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutEditor.removeLayoutTurnout(instance)) {
// Returned true if user did not cancel
remove();
dispose();
}
}
});
if (getTurnout() != null) {
popup.add(new AbstractAction(rb.getString("SetSignals")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
if ((getTurnoutType() == DOUBLE_XOVER) || (getTurnoutType() == RH_XOVER) || (getTurnoutType() == LH_XOVER)) {
tools.setSignalsAtXoverTurnoutFromMenu(instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == NO_LINK) {
tools.setSignalsAtTurnoutFromMenu(instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == THROAT_TO_THROAT) {
tools.setThroatToThroatFromMenu(instance, linkedTurnoutName, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == FIRST_3_WAY) {
tools.set3WayFromMenu(turnoutName, linkedTurnoutName, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == SECOND_3_WAY) {
tools.set3WayFromMenu(linkedTurnoutName, turnoutName, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
}
}
});
}
if (!blockName.equals("")) {
final String[] boundaryBetween = getBlockBoundaries();
boolean blockBoundaries = false;
for (int i = 0; i < 4; i++) {
if (boundaryBetween[i] != null) {
blockBoundaries = true;
}
}
if (InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled()) {
if (blockBName.equals("") && blockCName.equals("") && blockDName.equals("")) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
routeTableAction.actionPerformed(e);
}
});
} else {
JMenu viewRouting = new JMenu(rb.getString("ViewBlockRouting"));
viewRouting.add(new AbstractAction(blockName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockName, getLayoutBlock());
routeTableAction.actionPerformed(e);
}
});
if (!blockBName.equals("") && !blockBName.equals(blockName)) {
viewRouting.add(new AbstractAction(blockBName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockBName, getLayoutBlockB());
routeTableAction.actionPerformed(e);
}
});
}
if (!blockCName.equals("") && !blockCName.equals(blockName) && !blockCName.equals(blockBName)) {
viewRouting.add(new AbstractAction(blockCName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockCName, getLayoutBlockC());
routeTableAction.actionPerformed(e);
}
});
}
if (!blockDName.equals("") && !blockDName.equals(blockName) && !blockDName.equals(blockBName) && !blockDName.equals(blockCName)) {
viewRouting.add(new AbstractAction(blockDName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockDName, getLayoutBlockD());
routeTableAction.actionPerformed(e);
}
});
}
popup.add(viewRouting);
}
}
if (blockBoundaries) {
popup.add(new AbstractAction(rb.getString("SetSignalMasts")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSignalMastsAtTurnoutFromMenu(instance, boundaryBetween);
}
});
popup.add(new AbstractAction(rb.getString("SetSensors")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSensorsAtTurnoutFromMenu(instance, boundaryBetween, layoutEditor.sensorIconEditor, layoutEditor.sensorFrame);
}
});
}
}
setAdditionalEditPopUpMenu(popup);
layoutEditor.setShowAlignmentMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
} else if (!viewAdditionalMenu.isEmpty()) {
setAdditionalViewPopUpMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
use of jmri.jmrit.display.layoutEditor.blockRoutingTable.LayoutBlockRouteTableAction in project JMRI by JMRI.
the class LevelXing method showPopUp.
/**
* Display popup menu for information and editing
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
if (layoutEditor.isEditable()) {
JMenuItem jmi = popup.add(rb.getString("LevelCrossing"));
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
boolean blockACAssigned = false;
boolean blockBDAssigned = false;
if ((blockNameAC == null) || (blockNameAC.equals(""))) {
jmi = popup.add(Bundle.getMessage("NoBlockX", 1));
} else {
jmi = popup.add(Bundle.getMessage("Block_ID", 1) + ": " + getLayoutBlockAC().getID());
blockACAssigned = true;
}
jmi.setEnabled(false);
if ((blockNameBD == null) || (blockNameBD.equals(""))) {
jmi = popup.add(Bundle.getMessage("NoBlockX", 2));
} else {
jmi = popup.add(Bundle.getMessage("Block_ID", 2) + ": " + getLayoutBlockBD().getID());
blockBDAssigned = true;
}
jmi.setEnabled(false);
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editLevelXing(instance);
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutEditor.removeLevelXing(instance)) {
// Returned true if user did not cancel
remove();
dispose();
}
}
});
if (blockACAssigned && blockBDAssigned) {
popup.add(new AbstractAction(rb.getString("SetSignals")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
// bring up signals at level crossing tool dialog
tools.setSignalsAtLevelXingFromMenu(instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
}
});
}
final String[] boundaryBetween = getBlockBoundaries();
boolean blockBoundaries = false;
if (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled()) {
if (blockACAssigned && !blockBDAssigned) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlockAC());
routeTableAction.actionPerformed(e);
}
});
} else if (!blockACAssigned && blockBDAssigned) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlockBD());
routeTableAction.actionPerformed(e);
}
});
} else if (blockACAssigned && blockBDAssigned) {
JMenu viewRouting = new JMenu(rb.getString("ViewBlockRouting"));
viewRouting.add(new AbstractAction(blockNameAC) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockNameAC, getLayoutBlockAC());
routeTableAction.actionPerformed(e);
}
});
viewRouting.add(new AbstractAction(blockNameBD) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockNameBD, getLayoutBlockBD());
routeTableAction.actionPerformed(e);
}
});
popup.add(viewRouting);
}
}
for (int i = 0; i < 4; i++) {
if (boundaryBetween[i] != null) {
blockBoundaries = true;
}
}
if (blockBoundaries) {
popup.add(new AbstractAction(rb.getString("SetSignalMasts")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSignalMastsAtLevelXingFromMenu(instance, boundaryBetween, layoutEditor.signalFrame);
}
});
popup.add(new AbstractAction(rb.getString("SetSensors")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSensorsAtLevelXingFromMenu(instance, boundaryBetween, layoutEditor.sensorIconEditor, layoutEditor.sensorFrame);
}
});
}
layoutEditor.setShowAlignmentMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
} else if (!viewAdditionalMenu.isEmpty()) {
setAdditionalViewPopUpMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
use of jmri.jmrit.display.layoutEditor.blockRoutingTable.LayoutBlockRouteTableAction in project JMRI by JMRI.
the class TrackSegment method showPopUp.
/**
* Display popup menu for information and editing.
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
String info = rb.getString("TrackSegment");
if (getArc()) {
if (getCircle()) {
info = info + " (" + Bundle.getMessage("Circle") + ")";
} else {
info = info + " (" + Bundle.getMessage("Ellipse") + ")";
}
} else if (getBezier()) {
info = info + " (" + Bundle.getMessage("Bezier") + ")";
} else {
info = info + " (" + Bundle.getMessage("Line") + ")";
}
JMenuItem jmi = popup.add(info);
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
if (!dashed) {
jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Solid"));
} else {
jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Dashed"));
}
jmi.setEnabled(false);
if (!mainline) {
jmi = popup.add(rb.getString("NotMainline"));
} else {
jmi = popup.add(rb.getString("Mainline"));
}
jmi.setEnabled(false);
if (blockName.equals("")) {
jmi = popup.add(rb.getString("NoBlock"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameBlock") + ": " + getLayoutBlock().getID());
}
jmi.setEnabled(false);
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editTrackSegment();
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
layoutEditor.removeTrackSegment(instance);
remove();
dispose();
}
});
JMenu lineType = new JMenu(rb.getString("ChangeTo"));
lineType.add(new AbstractAction(Bundle.getMessage("Line")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(0);
}
});
lineType.add(new AbstractAction(Bundle.getMessage("Circle")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(1);
}
});
lineType.add(new AbstractAction(Bundle.getMessage("Ellipse")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(2);
}
});
lineType.add(new AbstractAction(Bundle.getMessage("Bezier")) {
@Override
public void actionPerformed(ActionEvent e) {
changeType(3);
}
});
popup.add(lineType);
if (getArc()) {
popup.add(new AbstractAction(rb.getString("FlipAngle")) {
@Override
public void actionPerformed(ActionEvent e) {
flipAngle();
}
});
}
if (getArc() || getBezier()) {
if (hideConstructionLines()) {
popup.add(new AbstractAction(rb.getString("ShowConstruct")) {
@Override
public void actionPerformed(ActionEvent e) {
hideConstructionLines(SHOWCON);
}
});
} else {
popup.add(new AbstractAction(rb.getString("HideConstruct")) {
@Override
public void actionPerformed(ActionEvent e) {
hideConstructionLines(HIDECON);
}
});
}
}
if ((!blockName.equals("")) && (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled())) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
routeTableAction.actionPerformed(e);
}
});
}
popup.show(e.getComponent(), e.getX(), e.getY());
}
use of jmri.jmrit.display.layoutEditor.blockRoutingTable.LayoutBlockRouteTableAction in project JMRI by JMRI.
the class LayoutSlip method showPopUp.
/**
* Display popup menu for information and editing
*/
@Override
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
if (layoutEditor.isEditable()) {
JMenuItem jmi = null;
switch(type) {
case SINGLE_SLIP:
{
jmi = popup.add(rb.getString("LayoutSingleSlip"));
break;
}
case DOUBLE_SLIP:
{
jmi = popup.add(rb.getString("LayoutDoubleSlip"));
break;
}
}
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
if (getTurnout() == null) {
jmi = popup.add(rb.getString("NoTurnout"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameTurnout") + ": " + turnoutName);
}
jmi.setEnabled(false);
if (getTurnoutB() == null) {
jmi = popup.add(rb.getString("NoTurnout"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameTurnout") + ": " + turnoutBName);
}
jmi.setEnabled(false);
boolean blockAssigned = false;
if ((blockName == null) || (blockName.equals(""))) {
jmi = popup.add(rb.getString("NoBlock"));
} else {
jmi = popup.add(rb.getString("BlockID") + ": " + getLayoutBlock().getID());
blockAssigned = true;
}
jmi.setEnabled(false);
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editLayoutSlip(instance);
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutEditor.removeLayoutSlip(instance)) {
// Returned true if user did not cancel
remove();
dispose();
}
}
});
if ((connectA == null) && (connectB == null) && (connectC == null) && (connectD == null)) {
JMenuItem rotateItem = new JMenuItem(rb.getString("Rotate") + "...");
popup.add(rotateItem);
rotateItem.addActionListener((ActionEvent event) -> {
boolean entering = true;
boolean error = false;
String newAngle = "";
while (entering) {
// prompt for rotation angle
error = false;
newAngle = JOptionPane.showInputDialog(layoutEditor, rb.getString("EnterRotation") + " :");
if (newAngle.length() < 1) {
// cancelled
return;
}
double rot = 0.0;
try {
rot = Double.parseDouble(newAngle);
} catch (Exception e1) {
JOptionPane.showMessageDialog(layoutEditor, rb.getString("Error3") + " " + e1, Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
error = true;
newAngle = "";
}
if (!error) {
entering = false;
if (rot != 0.0) {
rotateCoords(rot);
layoutEditor.redrawPanel();
}
}
}
});
}
if (blockAssigned) {
popup.add(new AbstractAction(rb.getString("SetSignals")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSlipFromMenu((LayoutSlip) instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
}
});
}
final String[] boundaryBetween = getBlockBoundaries();
boolean blockBoundaries = false;
for (int i = 0; i < 4; i++) {
if (boundaryBetween[i] != null) {
blockBoundaries = true;
}
}
if (blockBoundaries) {
popup.add(new AbstractAction(rb.getString("SetSignalMasts")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSignalMastsAtSlipFromMenu((LayoutSlip) instance, boundaryBetween, layoutEditor.signalFrame);
}
});
popup.add(new AbstractAction(rb.getString("SetSensors")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSensorsAtSlipFromMenu((LayoutSlip) instance, boundaryBetween, layoutEditor.sensorIconEditor, layoutEditor.sensorFrame);
}
});
}
if (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled()) {
if (blockAssigned) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent event) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
routeTableAction.actionPerformed(event);
}
});
}
}
setAdditionalEditPopUpMenu(popup);
layoutEditor.setShowAlignmentMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
} else if (!viewAdditionalMenu.isEmpty()) {
setAdditionalViewPopUpMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
Aggregations