Search in sources :

Example 16 with LocationManager

use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.

the class ScheduleEditFrameGuiTest method testScheduleComboBoxes.

@Test
public void testScheduleComboBoxes() {
    LocationManager lm = LocationManager.instance();
    Location l = lm.newLocation("new test location");
    Track t = l.addTrack("track 1", Track.SPUR);
    ScheduleManager sm = ScheduleManager.instance();
    // clear out any previous schedules
    sm.dispose();
    sm = ScheduleManager.instance();
    Schedule s1 = sm.newSchedule("new schedule");
    Schedule s2 = sm.newSchedule("newer schedule");
    ScheduleItem i1 = s1.addItem("BoxCar");
    i1.setRoadName("new road");
    i1.setReceiveLoadName("new load");
    i1.setShipLoadName("new ship load");
    ScheduleItem i2 = s1.addItem("Caboose");
    i2.setRoadName("road");
    i2.setReceiveLoadName("load");
    i2.setShipLoadName("ship load");
    Assert.assertEquals("1 First schedule name", "new schedule", s1.getName());
    Assert.assertEquals("1 First schedule name", "newer schedule", s2.getName());
    List<Schedule> names = sm.getSchedulesByNameList();
    Assert.assertEquals("There should be 2 schedules", 2, names.size());
    Schedule sch1 = names.get(0);
    Schedule sch2 = names.get(1);
    Assert.assertEquals("2 First schedule name", "new schedule", sch1.getName());
    Assert.assertEquals("2 First schedule name", "newer schedule", sch2.getName());
    Assert.assertEquals("Schedule 1", sch1, sm.getScheduleByName("new schedule"));
    Assert.assertEquals("Schedule 2", sch2, sm.getScheduleByName("newer schedule"));
    JComboBox<Schedule> box = sm.getComboBox();
    Assert.assertEquals("3 First schedule name", null, box.getItemAt(0));
    Assert.assertEquals("3 First schedule name", sch1, box.getItemAt(1));
    Assert.assertEquals("3 First schedule name", sch2, box.getItemAt(2));
    JComboBox<LocationTrackPair> box2 = sm.getSpursByScheduleComboBox(s1);
    Assert.assertEquals("First siding name", null, box2.getItemAt(0));
    // now add a schedule to siding
    t.setScheduleId(sch1.getId());
    JComboBox<LocationTrackPair> box3 = sm.getSpursByScheduleComboBox(s1);
    LocationTrackPair ltp = box3.getItemAt(0);
    Assert.assertEquals("Location track pair location", l, ltp.getLocation());
    Assert.assertEquals("Location track pair track", t, ltp.getTrack());
    // remove all schedules
    sm.dispose();
    names = sm.getSchedulesByNameList();
    Assert.assertEquals("There should be no schedules", 0, names.size());
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location) Test(org.junit.Test)

Example 17 with LocationManager

use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.

the class ScheduleManagerTest method testScheduleManager.

public void testScheduleManager() {
    LocationManager lm = LocationManager.instance();
    Location l = lm.newLocation("new test location");
    Track t = l.addTrack("track 1", Track.SPUR);
    ScheduleManager sm = ScheduleManager.instance();
    // clear out any previous schedules
    sm.dispose();
    sm = ScheduleManager.instance();
    Schedule s1 = sm.newSchedule("new schedule");
    Schedule s2 = sm.newSchedule("newer schedule");
    ScheduleItem i1 = s1.addItem("BoxCar");
    i1.setRoadName("new road");
    i1.setReceiveLoadName("new load");
    i1.setShipLoadName("new ship load");
    ScheduleItem i2 = s1.addItem("Caboose");
    i2.setRoadName("road");
    i2.setReceiveLoadName("load");
    i2.setShipLoadName("ship load");
    Assert.assertEquals("1 First schedule name", "new schedule", s1.getName());
    Assert.assertEquals("1 First schedule name", "newer schedule", s2.getName());
    List<Schedule> names = sm.getSchedulesByNameList();
    Assert.assertEquals("There should be 2 schedules", 2, names.size());
    Schedule sch1 = names.get(0);
    Schedule sch2 = names.get(1);
    Assert.assertEquals("2 First schedule name", "new schedule", sch1.getName());
    Assert.assertEquals("2 First schedule name", "newer schedule", sch2.getName());
    Assert.assertEquals("Schedule 1", sch1, sm.getScheduleByName("new schedule"));
    Assert.assertEquals("Schedule 2", sch2, sm.getScheduleByName("newer schedule"));
    // Remove references to swing
    // JComboBox box = sm.getComboBox();
    // Assert.assertEquals("3 First schedule name", "", box.getItemAt(0));
    // Assert.assertEquals("3 First schedule name", sch1, box.getItemAt(1));
    // Assert.assertEquals("3 First schedule name", sch2, box.getItemAt(2));
    //
    // JComboBox box2 = sm.getSidingsByScheduleComboBox(s1);
    // Assert.assertEquals("First siding name", null, box2.getItemAt(0));
    // now add a schedule to siding
    t.setScheduleId(sch1.getId());
    // JComboBox box3 = sm.getSidingsByScheduleComboBox(s1);
    // LocationTrackPair ltp = (LocationTrackPair)box3.getItemAt(0);
    // Assert.assertEquals("Location track pair location", l, ltp.getLocation());
    // Assert.assertEquals("Location track pair track", t, ltp.getTrack());
    Assert.assertEquals("1 Schedule Item 1 type", "BoxCar", i1.getTypeName());
    Assert.assertEquals("1 Schedule Item 1 road", "new road", i1.getRoadName());
    Assert.assertEquals("1 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
    Assert.assertEquals("1 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
    Assert.assertEquals("1 Schedule Item 2 type", "Caboose", i2.getTypeName());
    Assert.assertEquals("1 Schedule Item 2 road", "road", i2.getRoadName());
    Assert.assertEquals("1 Schedule Item 2 load", "load", i2.getReceiveLoadName());
    Assert.assertEquals("1 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
    sm.replaceRoad("new road", "replaced road");
    Assert.assertEquals("2 Schedule Item 1 type", "BoxCar", i1.getTypeName());
    Assert.assertEquals("2 Schedule Item 1 road", "replaced road", i1.getRoadName());
    Assert.assertEquals("2 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
    Assert.assertEquals("2 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
    Assert.assertEquals("2 Schedule Item 2 type", "Caboose", i2.getTypeName());
    Assert.assertEquals("2 Schedule Item 2 road", "road", i2.getRoadName());
    Assert.assertEquals("2 Schedule Item 2 load", "load", i2.getReceiveLoadName());
    Assert.assertEquals("2 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
    sm.replaceType("BoxCar", "replaced car type");
    Assert.assertEquals("3 Schedule Item 1 type", "replaced car type", i1.getTypeName());
    Assert.assertEquals("3 Schedule Item 1 road", "replaced road", i1.getRoadName());
    Assert.assertEquals("3 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
    Assert.assertEquals("3 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
    Assert.assertEquals("3 Schedule Item 2 type", "Caboose", i2.getTypeName());
    Assert.assertEquals("3 Schedule Item 2 road", "road", i2.getRoadName());
    Assert.assertEquals("3 Schedule Item 2 load", "load", i2.getReceiveLoadName());
    Assert.assertEquals("3 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
    sm.replaceType("Caboose", "BoxCar");
    Assert.assertEquals("4 Schedule Item 1 type", "replaced car type", i1.getTypeName());
    Assert.assertEquals("4 Schedule Item 1 road", "replaced road", i1.getRoadName());
    Assert.assertEquals("4 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
    Assert.assertEquals("4 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
    Assert.assertEquals("4 Schedule Item 2 type", "BoxCar", i2.getTypeName());
    Assert.assertEquals("4 Schedule Item 2 road", "road", i2.getRoadName());
    Assert.assertEquals("4 Schedule Item 2 load", "load", i2.getReceiveLoadName());
    Assert.assertEquals("4 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
    sm.replaceLoad("BoxCar", "load", "new load");
    Assert.assertEquals("5 Schedule Item 1 type", "replaced car type", i1.getTypeName());
    Assert.assertEquals("5 Schedule Item 1 road", "replaced road", i1.getRoadName());
    Assert.assertEquals("5 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
    Assert.assertEquals("5 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
    Assert.assertEquals("5 Schedule Item 2 type", "BoxCar", i2.getTypeName());
    Assert.assertEquals("5 Schedule Item 2 road", "road", i2.getRoadName());
    Assert.assertEquals("5 Schedule Item 2 load", "new load", i2.getReceiveLoadName());
    Assert.assertEquals("5 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
    sm.replaceLoad("BoxCar", "new load", "next load");
    Assert.assertEquals("6 Schedule Item 1 type", "replaced car type", i1.getTypeName());
    Assert.assertEquals("6 Schedule Item 1 road", "replaced road", i1.getRoadName());
    Assert.assertEquals("6 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
    Assert.assertEquals("6 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
    Assert.assertEquals("6 Schedule Item 2 type", "BoxCar", i2.getTypeName());
    Assert.assertEquals("6 Schedule Item 2 road", "road", i2.getRoadName());
    Assert.assertEquals("6 Schedule Item 2 load", "next load", i2.getReceiveLoadName());
    Assert.assertEquals("6 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
    // remove all schedules
    sm.dispose();
    names = sm.getSchedulesByNameList();
    Assert.assertEquals("There should be no schedules", 0, names.size());
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) ScheduleManager(jmri.jmrit.operations.locations.schedules.ScheduleManager) ScheduleItem(jmri.jmrit.operations.locations.schedules.ScheduleItem) Schedule(jmri.jmrit.operations.locations.schedules.Schedule) Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location)

Example 18 with LocationManager

use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.

the class ScheduleEditFrameGuiTest method testScheduleEditFrame.

@Test
public void testScheduleEditFrame() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    LocationManager lManager = LocationManager.instance();
    Location l2 = lManager.newLocation("Test Loc C");
    l2.setLength(1003);
    Location l = lManager.getLocationByName("Test Loc C");
    Assert.assertNotNull("Location exists", l);
    Track t = l.addTrack("3rd siding track", Track.SPUR);
    Assert.assertNotNull("Track exists", t);
    ScheduleEditFrame f = new ScheduleEditFrame(null, t);
    f.setTitle("Test Schedule Frame");
    f.scheduleNameTextField.setText("Test Schedule A");
    f.commentTextField.setText("Test Comment");
    enterClickAndLeave(f.addScheduleButton);
    // was the schedule created?
    ScheduleManager m = ScheduleManager.instance();
    Schedule s = m.getScheduleByName("Test Schedule A");
    Assert.assertNotNull("Test Schedule A exists", s);
    // now add some car types to the schedule
    f.typeBox.setSelectedItem("Boxcar");
    enterClickAndLeave(f.addTypeButton);
    f.typeBox.setSelectedItem("Flatcar");
    enterClickAndLeave(f.addTypeButton);
    f.typeBox.setSelectedItem("Coilcar");
    enterClickAndLeave(f.addTypeButton);
    // put Tank Food at start of list
    f.typeBox.setSelectedItem("Tank Food");
    enterClickAndLeave(f.addLocAtTop);
    enterClickAndLeave(f.addTypeButton);
    enterClickAndLeave(f.saveScheduleButton);
    List<ScheduleItem> list = s.getItemsBySequenceList();
    Assert.assertEquals("number of items", 4, list.size());
    ScheduleItem si = list.get(0);
    Assert.assertEquals("1st type", "Tank Food", si.getTypeName());
    si = list.get(1);
    Assert.assertEquals("2nd type", "Boxcar", si.getTypeName());
    si = list.get(2);
    Assert.assertEquals("3rd type", "Flatcar", si.getTypeName());
    si = list.get(3);
    Assert.assertEquals("3rd type", "Coilcar", si.getTypeName());
    enterClickAndLeave(f.deleteScheduleButton);
    // Yes to pop up
    pressDialogButton(f, Bundle.getMessage("DeleteSchedule?"), "Yes");
    s = m.getScheduleByName("Test Schedule A");
    Assert.assertNull("Test Schedule A exists", s);
    f.dispose();
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location) Test(org.junit.Test)

Example 19 with LocationManager

use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.

the class ScheduleEditFrameGuiTest method loadLocations.

private void loadLocations() {
    // create 5 locations
    LocationManager lManager = LocationManager.instance();
    Location l1 = lManager.newLocation("Test Loc E");
    l1.setLength(1001);
    Location l2 = lManager.newLocation("Test Loc D");
    l2.setLength(1002);
    Location l3 = lManager.newLocation("Test Loc C");
    l3.setLength(1003);
    Location l4 = lManager.newLocation("Test Loc B");
    l4.setLength(1004);
    Location l5 = lManager.newLocation("Test Loc A");
    l5.setLength(1005);
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) Location(jmri.jmrit.operations.locations.Location)

Example 20 with LocationManager

use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.

the class PoolTrackGuiTest method CreateTestLocations.

//final static int ALL = Track.EAST + Track.WEST + Track.NORTH + Track.SOUTH;
private void CreateTestLocations() {
    // Clear out any previous locations
    LocationManager.instance().dispose();
    // Create 5 locations
    LocationManager lManager = LocationManager.instance();
    Location l1 = lManager.newLocation("Test Loc E");
    l1.setLength(1001);
    Location l2 = lManager.newLocation("Test Loc D");
    l2.setLength(1002);
    Location l3 = lManager.newLocation("Test Loc C");
    l3.setLength(1003);
    Location l4 = lManager.newLocation("Test Loc B");
    l4.setLength(1004);
    Location l5 = lManager.newLocation("Test Loc A");
    l5.setLength(1005);
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) Location(jmri.jmrit.operations.locations.Location)

Aggregations

LocationManager (jmri.jmrit.operations.locations.LocationManager)45 Location (jmri.jmrit.operations.locations.Location)43 Track (jmri.jmrit.operations.locations.Track)33 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)28 Route (jmri.jmrit.operations.routes.Route)23 RouteManager (jmri.jmrit.operations.routes.RouteManager)21 Car (jmri.jmrit.operations.rollingstock.cars.Car)18 CarManager (jmri.jmrit.operations.rollingstock.cars.CarManager)18 Engine (jmri.jmrit.operations.rollingstock.engines.Engine)13 EngineManager (jmri.jmrit.operations.rollingstock.engines.EngineManager)13 CarTypes (jmri.jmrit.operations.rollingstock.cars.CarTypes)12 Consist (jmri.jmrit.operations.rollingstock.engines.Consist)10 Train (jmri.jmrit.operations.trains.Train)9 TrainManager (jmri.jmrit.operations.trains.TrainManager)9 Schedule (jmri.jmrit.operations.locations.schedules.Schedule)7 ScheduleItem (jmri.jmrit.operations.locations.schedules.ScheduleItem)7 ScheduleManager (jmri.jmrit.operations.locations.schedules.ScheduleManager)7 Test (org.junit.Test)7 CarRoads (jmri.jmrit.operations.rollingstock.cars.CarRoads)6 EngineTypes (jmri.jmrit.operations.rollingstock.engines.EngineTypes)6