public AddLocomotiveAction() {
super("Add", ImageTools.createImageIcon("add.png"));
}
public void actionPerformed(ActionEvent e) {
LocomotiveGroup selectedLocomotiveGroup = (LocomotiveGroup) (locomotiveGroupList
.getSelectedValue());
Locomotive newLocomotive = new Locomotive();
newLocomotive.setLocomotiveGroup(selectedLocomotiveGroup);
selectedLocomotiveGroup.getLocomotives().add(newLocomotive);
LocomotiveConfig locomotiveConfig = new LocomotiveConfig(
LocomotiveConfigurationDialog.this, newLocomotive);
if (locomotiveConfig.isOkPressed()) {
selectedLocomotiveGroup.getLocomotives().add(newLocomotive);
LocomotivePersistenceIface locomotivePersistence = AdHocRailway
.getInstance().getLocomotivePersistence();
locomotivePersistence.addLocomotive(newLocomotive);
}
List<Locomotive> locomotives = new ArrayList<Locomotive>(
selectedLocomotiveGroup.getLocomotives());
locomotiveModel.setList(locomotives);
}