Skip to content
Permalink
Browse files

Use point names instead of integers, removed slip specific code, repl…

…aced the trailing space for ProtectingBlock that some dialogs rely on
  • Loading branch information...
dsand47 committed May 20, 2019
1 parent 8c136b4 commit e603b0014cf478bfa86576cd50217bc26ffc70cb
@@ -851,5 +851,5 @@ TunnelFloorWidthMenuItemToolTip = Select this menu to change the tunnel floor wi
TunnelEntranceWidthMenuItemTitle = Entrance Width
TunnelEntranceWidthMenuItemToolTip = Select this menu to change the tunnel entrance width

ProtectingBlock = Protecting Block :
ProtectingBlock = Protecting Block :
EndOfBlock = End of Block
@@ -881,7 +881,7 @@ public void actionPerformed(ActionEvent e) {
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (canDeleteSlip() && layoutEditor.removeLayoutSlip(LayoutSlip.this)) {
if (canDeleteTurnout() && layoutEditor.removeLayoutSlip(LayoutSlip.this)) {
// Returned true if user did not cancel
remove();
dispose();
@@ -997,29 +997,6 @@ public void actionPerformed(ActionEvent event) {
return popup;
} // showPopup

/**
* Check the connection points for object assignments. Notify user if there
* are assigned objects.
* @return true if ok to delete
*/
public boolean canDeleteSlip() {
ArrayList<String> beanReferences = getBeanReferences("All");
if (!beanReferences.isEmpty()) {
// The slip currently has sensors, heads, and/or masts assigned.
beanReferences.sort(null);
StringBuilder msg = new StringBuilder(Bundle.getMessage("MakeLabel", // NOI18N
Bundle.getMessage("DeleteTrackItem", Bundle.getMessage("SlipTurnout")))); // NOI18N
for (String item : beanReferences) {
msg.append("\n " + item); // NOI18N
}
javax.swing.JOptionPane.showMessageDialog(null,
msg.toString(),
Bundle.getMessage("WarningTitle"), // NOI18N
javax.swing.JOptionPane.WARNING_MESSAGE);
}
return beanReferences.isEmpty();
}

@Override
public String[] getBlockBoundaries() {
final String[] boundaryBetween = new String[4];
@@ -1702,7 +1702,7 @@ public boolean canRemoveTrackSegment(TrackSegment ts) {
public ArrayList<String> getPointReferences(int type, LayoutTrack conn) {
ArrayList<String> items = new ArrayList<>();

if (type == 1 && conn instanceof PositionablePoint) {
if (type == POS_POINT && conn instanceof PositionablePoint) {
PositionablePoint pt = (PositionablePoint) conn;
if (!pt.getEastBoundSignal().isEmpty()) items.add(pt.getEastBoundSignal());
if (!pt.getWestBoundSignal().isEmpty()) items.add(pt.getWestBoundSignal());
@@ -1716,27 +1716,27 @@ public boolean canRemoveTrackSegment(TrackSegment ts) {
return items;
}

if (type > 1 && type < 6 && conn instanceof LayoutTurnout) {
if ((type == TURNOUT_A || type == TURNOUT_B || type == TURNOUT_C || type == TURNOUT_D) && conn instanceof LayoutTurnout) {
LayoutTurnout lt = (LayoutTurnout) conn;
if (type == 2) return lt.getBeanReferences("A"); // NOI18N
if (type == 3) return lt.getBeanReferences("B"); // NOI18N
if (type == 4) return lt.getBeanReferences("C"); // NOI18N
if (type == TURNOUT_A) return lt.getBeanReferences("A"); // NOI18N
if (type == TURNOUT_B) return lt.getBeanReferences("B"); // NOI18N
if (type == TURNOUT_C) return lt.getBeanReferences("C"); // NOI18N
return lt.getBeanReferences("D"); // NOI18N
}

if (type > 5 && type < 10 && conn instanceof LevelXing) {
if ((type == LEVEL_XING_A || type == LEVEL_XING_B || type == LEVEL_XING_C || type == LEVEL_XING_D) && conn instanceof LevelXing) {
LevelXing lx = (LevelXing) conn;
if (type == 6) return lx.getBeanReferences("A"); // NOI18N
if (type == 7) return lx.getBeanReferences("B"); // NOI18N
if (type == 8) return lx.getBeanReferences("C"); // NOI18N
if (type == LEVEL_XING_A) return lx.getBeanReferences("A"); // NOI18N
if (type == LEVEL_XING_B) return lx.getBeanReferences("B"); // NOI18N
if (type == LEVEL_XING_C) return lx.getBeanReferences("C"); // NOI18N
return lx.getBeanReferences("D"); // NOI18N
}

if (type > 20 && type < 25 && conn instanceof LayoutSlip) {
if ((type == SLIP_A || type == SLIP_B || type == SLIP_C || type == SLIP_D) && conn instanceof LayoutSlip) {
LayoutSlip ls = (LayoutSlip) conn;
if (type == 21) return ls.getBeanReferences("A"); // NOI18N
if (type == 22) return ls.getBeanReferences("B"); // NOI18N
if (type == 23) return ls.getBeanReferences("C"); // NOI18N
if (type == SLIP_A) return ls.getBeanReferences("A"); // NOI18N
if (type == SLIP_B) return ls.getBeanReferences("B"); // NOI18N
if (type == SLIP_C) return ls.getBeanReferences("C"); // NOI18N
return ls.getBeanReferences("D"); // NOI18N
}

0 comments on commit e603b00

Please sign in to comment.
You can’t perform that action at this time.