return;
int enteredNumber = Integer.parseInt(enteredNumberAsString);
System.out.println(enteredNumber);
Turnout turnout;
try {
RoutePersistenceIface routePersistence = AdHocRailway
.getInstance().getRoutePersistence();
TurnoutPersistenceIface turnoutPersistence = AdHocRailway
.getInstance().getTurnoutPersistence();
turnout = turnoutPersistence.getTurnoutByNumber(enteredNumber);
System.out.println(turnout);
if (turnout == null) {
JOptionPane
.showMessageDialog(
RouteConfig.this,
"Turnout " + enteredNumber
+ " does not exist",
"Error",
JOptionPane.ERROR_MESSAGE,
ImageTools
.createImageIcon("messagebox_critical.png"));
} else {
SRCPTurnoutState routedState = null;
if (this instanceof CurvedLeftAction) {
// ThreeWay LEFT
routedState = SRCPTurnoutState.LEFT;
} else if (this instanceof StraightAction) {
// ThreeWay STRAIGHT
routedState = SRCPTurnoutState.STRAIGHT;
} else if (this instanceof CurvedRightAction) {
// ThreeWay RIGHT
routedState = SRCPTurnoutState.RIGHT;
} else if (this instanceof EnableRouteAction) {
// CURVED
if (!turnout.isThreeWay()) {
switch (turnout.getDefaultStateEnum()) {
case STRAIGHT:
routedState = SRCPTurnoutState.LEFT;
break;
case LEFT:
routedState = SRCPTurnoutState.STRAIGHT;
break;
}
} else {
routedState = SRCPTurnoutState.LEFT;
}
} else if (this instanceof DisableRouteAction) {
// STRAIGHT
routedState = turnout.getDefaultStateEnum();
}
RouteItem itemToRemove = null;
SortedSet<RouteItem> itemsOfRoute = route.getRouteItems();
for (RouteItem item : itemsOfRoute) {
if (item.getTurnout().equals(turnout)) {
itemToRemove = item;
break;
}
}
if (itemToRemove != null) {
routePersistence.deleteRouteItem(itemToRemove);
}
RouteItem i = new RouteItem();
i.setRoute(route);
i.setRoutedStateEnum(routedState);
i.setTurnout(turnout);
try {
routePersistence.addRouteItem(i);
List<RouteItem> routeItems = new ArrayList<RouteItem>(
route.getRouteItems());
routeItemModel.setList(routeItems);
} catch (RoutePersistenceException e1) {
e1.printStackTrace();