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;
}
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);
}
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);
}
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--;
}
}
}
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;
}
Aggregations