Search in sources :

Example 16 with Location

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

the class ScheduleTableModel method getTrackComboBox.

private JComboBox<Track> getTrackComboBox(ScheduleItem si) {
    // log.debug("getTrackComboBox for ScheduleItem "+si.getType());
    JComboBox<Track> cb = new JComboBox<>();
    if (si.getDestination() != null) {
        Location dest = si.getDestination();
        dest.updateComboBox(cb);
        filterTracks(dest, cb, si.getTypeName(), si.getRoadName(), si.getShipLoadName());
        cb.setSelectedItem(si.getDestinationTrack());
        if (si.getDestinationTrack() != null && cb.getSelectedIndex() == -1) {
            // user deleted track at destination, this is self correcting, when user restarts program, track
            // assignment will be gone.
            cb.addItem(si.getDestinationTrack());
            cb.setSelectedItem(si.getDestinationTrack());
        }
    }
    return cb;
}
Also used : JComboBox(javax.swing.JComboBox) Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location)

Example 17 with Location

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

the class ScheduleItem method setDestination.

public void setDestination(Location destination) {
    Location old = _destination;
    _destination = destination;
    // NOI18N
    String oldName = "null";
    if (old != null) {
        oldName = old.getName();
    }
    // NOI18N
    String newName = "null";
    if (_destination != null) {
        newName = _destination.getName();
    }
    firePropertyChange(DESTINATION_CHANGED_PROPERTY, oldName, newName);
}
Also used : Location(jmri.jmrit.operations.locations.Location)

Example 18 with Location

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

the class ScheduleTableModel method setDestination.

private void setDestination(Object value, int row) {
    ScheduleItem si = _list.get(row);
    si.setDestinationTrack(null);
    Location dest = (Location) ((JComboBox<?>) value).getSelectedItem();
    si.setDestination(dest);
    fireTableCellUpdated(row, TRACK_COLUMN);
}
Also used : Location(jmri.jmrit.operations.locations.Location)

Example 19 with Location

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

the class ScheduleTableModel method filterDestinations.

// remove destinations that don't service the car's type
private void filterDestinations(JComboBox<Location> cb, String carType) {
    for (int i = 1; i < cb.getItemCount(); i++) {
        Location dest = cb.getItemAt(i);
        if (!dest.acceptsTypeName(carType)) {
            cb.removeItem(dest);
            i--;
        }
    }
}
Also used : Location(jmri.jmrit.operations.locations.Location)

Example 20 with Location

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

the class PrintLocationsAction method getTrackLengthAcceptType.

private int getTrackLengthAcceptType(List<Location> locations, String carType, String trackType) throws IOException {
    int trackLength = 0;
    for (Location location : locations) {
        if (_location != null && location != _location) {
            continue;
        }
        List<Track> tracks = location.getTrackByNameList(trackType);
        for (Track track : tracks) {
            if (track.acceptsTypeName(carType)) {
                trackLength = trackLength + track.getLength();
                writer.write(SPACE + SPACE + MessageFormat.format(Bundle.getMessage("LocationTrackLength"), new Object[] { location.getName(), track.getName(), track.getLength(), Setup.getLengthUnit().toLowerCase() }) + NEW_LINE);
            }
        }
    }
    return trackLength;
}
Also used : Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location)

Aggregations

Location (jmri.jmrit.operations.locations.Location)186 Track (jmri.jmrit.operations.locations.Track)108 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)82 Route (jmri.jmrit.operations.routes.Route)51 LocationManager (jmri.jmrit.operations.locations.LocationManager)43 Car (jmri.jmrit.operations.rollingstock.cars.Car)41 Engine (jmri.jmrit.operations.rollingstock.engines.Engine)29 RouteManager (jmri.jmrit.operations.routes.RouteManager)21 CarManager (jmri.jmrit.operations.rollingstock.cars.CarManager)20 Consist (jmri.jmrit.operations.rollingstock.engines.Consist)19 Test (org.junit.Test)18 JCheckBox (javax.swing.JCheckBox)13 EngineManager (jmri.jmrit.operations.rollingstock.engines.EngineManager)13 Train (jmri.jmrit.operations.trains.Train)13 CarTypes (jmri.jmrit.operations.rollingstock.cars.CarTypes)12 Schedule (jmri.jmrit.operations.locations.schedules.Schedule)11 EngineTypes (jmri.jmrit.operations.rollingstock.engines.EngineTypes)10 File (java.io.File)9 ScheduleItem (jmri.jmrit.operations.locations.schedules.ScheduleItem)9 TrainManager (jmri.jmrit.operations.trains.TrainManager)8