Skip to content
Permalink
Browse files

Change method names; warning dialog is child of layout editor panel

  • Loading branch information...
dsand47 committed May 22, 2019
1 parent d448050 commit 7ba3d2d94edc7f4aad71491a970f5adf0683102b
@@ -881,7 +881,7 @@ public void actionPerformed(ActionEvent e) {
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (canRemoveTrackComponent() && layoutEditor.removeLayoutSlip(LayoutSlip.this)) {
if (canRemoveObject() && layoutEditor.removeLayoutSlip(LayoutSlip.this)) {
// Returned true if user did not cancel
remove();
dispose();
@@ -296,25 +296,25 @@ public String getTurnoutStateString(int turnoutState) {
/**
* Check for active block boundaries.
* <p>
* If any connection point of a track object has attached objects, such as signal
* masts, signal heads or NX sensors, the track component cannot be deleted.
* @return true if the track component can be deleted.
* If any connection point of a layout track object has attached objects, such as
* signal masts, signal heads or NX sensors, the layout track object cannot be deleted.
* @return true if the layout track item can be deleted.
*/
public abstract boolean canRemoveTrackComponent();
public abstract boolean canRemoveObject();

/**
* Display the attached items that prevent removing the component.
* Display the attached items that prevent removing the layout track item.
* @param itemList A list of the attached heads, masts and/or sensors.
* @param componentType The type such as Turnout, Level Crossing, etc.
* @param typeKey The object type such as Turnout, Level Crossing, etc.
*/
public void displayRemoveTrackComponentDialog(List<String> itemList, String typeKey) {
public void displayRemoveObjectDialog(List<String> itemList, String typeKey) {
itemList.sort(null);
StringBuilder msg = new StringBuilder(Bundle.getMessage("MakeLabel", // NOI18N
Bundle.getMessage("DeleteTrackItem", Bundle.getMessage(typeKey)))); // NOI18N
for (String item : itemList) {
msg.append("\n " + item); // NOI18N
}
javax.swing.JOptionPane.showMessageDialog(null,
javax.swing.JOptionPane.showMessageDialog(layoutEditor,
msg.toString(),
Bundle.getMessage("WarningTitle"), // NOI18N
javax.swing.JOptionPane.WARNING_MESSAGE);
@@ -735,10 +735,10 @@ public void removeBeanReference(jmri.NamedBean nb) {
* {@inheritDoc}
*/
@Override
public boolean canRemoveTrackComponent() {
public boolean canRemoveObject() {
ArrayList<String> beanReferences = getBeanReferences("All"); // NOI18N
if (!beanReferences.isEmpty()) {
displayRemoveTrackComponentDialog(beanReferences, "BeanNameTurnout"); // NOI18N
displayRemoveObjectDialog(beanReferences, "BeanNameTurnout"); // NOI18N
}
return beanReferences.isEmpty();
}
@@ -2748,7 +2748,7 @@ public void actionPerformed(ActionEvent e) {
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (canRemoveTrackComponent() && layoutEditor.removeLayoutTurnout(LayoutTurnout.this)) {
if (canRemoveObject() && layoutEditor.removeLayoutTurnout(LayoutTurnout.this)) {
// Returned true if user did not cancel
remove();
dispose();
@@ -1386,7 +1386,7 @@ public void setAllLayoutBlocks(LayoutBlock layoutBlock) {
* {@inheritDoc}
*/
@Override
public boolean canRemoveTrackComponent() {
public boolean canRemoveObject() {
return true;
}

@@ -1042,10 +1042,10 @@ public void setObjects(LayoutEditor p) {
* {@inheritDoc}
*/
@Override
public boolean canRemoveTrackComponent() {
public boolean canRemoveObject() {
ArrayList<String> beanReferences = getBeanReferences("All"); // NOI18N
if (!beanReferences.isEmpty()) {
displayRemoveTrackComponentDialog(beanReferences, "LevelCrossing"); // NOI18N
displayRemoveObjectDialog(beanReferences, "LevelCrossing"); // NOI18N
}
return beanReferences.isEmpty();
}
@@ -1196,7 +1196,7 @@ public void actionPerformed(ActionEvent e) {
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (canRemoveTrackComponent() && layoutEditor.removeLevelXing(LevelXing.this)) {
if (canRemoveObject() && layoutEditor.removeLevelXing(LevelXing.this)) {
// Returned true if user did not cancel
remove();
dispose();
@@ -1281,7 +1281,7 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e
) {
if (canRemoveTrackComponent() && layoutEditor.removePositionablePoint(PositionablePoint.this)) {
if (canRemoveObject() && layoutEditor.removePositionablePoint(PositionablePoint.this)) {
// user is serious about removing this point from the panel
remove();
dispose();
@@ -1429,7 +1429,7 @@ public void actionPerformed(ActionEvent event) {
* {@inheritDoc}
*/
@Override
public boolean canRemoveTrackComponent() {
public boolean canRemoveObject() {
List<String> itemList = new ArrayList<>();
// A has two track segments, EB has one, EC has one plus optional link

@@ -1464,7 +1464,7 @@ public boolean canRemoveTrackComponent() {
typeName = "Unknown type (" + type + ")"; // NOI18N
break;
}
displayRemoveTrackComponentDialog(itemList, typeName);
displayRemoveObjectDialog(itemList, typeName);
}
return itemList.isEmpty();
}
@@ -1586,7 +1586,7 @@ public void actionPerformed(ActionEvent e) {
popupMenu.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (canRemoveTrackComponent()) {
if (canRemoveObject()) {
layoutEditor.removeTrackSegment(TrackSegment.this);
remove();
dispose();
@@ -1669,7 +1669,7 @@ public void actionPerformed(ActionEvent e) {
* {@inheritDoc}
*/
@Override
public boolean canRemoveTrackComponent() {
public boolean canRemoveObject() {
List<String> itemList = new ArrayList<>();

int type1 = getType1();
@@ -1681,7 +1681,7 @@ public boolean canRemoveTrackComponent() {
itemList.addAll(getPointReferences(type2, conn2));

if (!itemList.isEmpty()) {
displayRemoveTrackComponentDialog(itemList, "TrackSegment"); // NOI18N
displayRemoveObjectDialog(itemList, "TrackSegment"); // NOI18N
}
return itemList.isEmpty();
}

0 comments on commit 7ba3d2d

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