use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class TrainEditFrame method updateLocationCheckboxes.
// the train's route shown as locations with checkboxes
private void updateLocationCheckboxes() {
locationCheckBoxes.clear();
locationPanelCheckBoxes.removeAll();
// vertical position in panel
int y = 0;
Route route = null;
// clear out previous status
textRouteStatus.setText(NONE);
if (_train != null) {
route = _train.getRoute();
}
if (route != null) {
if (!route.getStatus().equals(Route.OKAY)) {
textRouteStatus.setText(route.getStatus());
textRouteStatus.setForeground(Color.RED);
}
List<RouteLocation> routeList = route.getLocationsBySequenceList();
for (int i = 0; i < routeList.size(); i++) {
RouteLocation rl = routeList.get(i);
JCheckBox checkBox = new javax.swing.JCheckBox();
locationCheckBoxes.add(checkBox);
checkBox.setText(rl.toString());
checkBox.setName(rl.getId());
addItemLeft(locationPanelCheckBoxes, checkBox, 0, y++);
Location loc = LocationManager.instance().getLocationByName(rl.getName());
// does the location exist?
if (loc != null) {
// need to listen for name and direction changes
loc.removePropertyChangeListener(this);
loc.addPropertyChangeListener(this);
boolean services = false;
// does train direction service location?
if ((rl.getTrainDirection() & loc.getTrainDirections()) != 0) {
services = true;
} else // train must service last location or single location
if (i == routeList.size() - 1) {
services = true;
}
// check can drop and pick up, and moves > 0
if (services && (rl.isDropAllowed() || rl.isPickUpAllowed()) && rl.getMaxCarMoves() > 0) {
checkBox.setSelected(!_train.skipsLocation(rl.getId()));
} else {
checkBox.setEnabled(false);
}
addLocationCheckBoxAction(checkBox);
} else {
checkBox.setEnabled(false);
}
}
}
locationPanelCheckBoxes.revalidate();
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class TrainByCarTypeFrame method removeLocationAndTrackPropertyChange.
/**
* Remove property listeners for locations and tracks
*/
private void removeLocationAndTrackPropertyChange() {
for (Location loc : locationManager.getList()) {
loc.removePropertyChangeListener(this);
for (Track track : loc.getTrackList()) {
track.removePropertyChangeListener(this);
Schedule schedule = track.getSchedule();
if (schedule != null) {
schedule.removePropertyChangeListener(this);
}
}
}
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class PrintSavedTrainManifestAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
File file = getFile();
if (file == null || !file.exists()) {
log.debug("User didn't select a file");
return;
}
if (_isPreview && Setup.isManifestEditorEnabled()) {
TrainPrintUtilities.openDesktopEditor(file);
return;
}
String logoURL = Setup.NONE;
if (_train != null && !_train.getManifestLogoURL().equals(Train.NONE)) {
logoURL = FileUtil.getExternalFilename(_train.getManifestLogoURL());
} else if (!Setup.getManifestLogoURL().equals(Setup.NONE)) {
logoURL = FileUtil.getExternalFilename(Setup.getManifestLogoURL());
}
String printerName = Location.NONE;
if (_train != null) {
Location departs = LocationManager.instance().getLocationByName(_train.getTrainDepartsName());
if (departs != null) {
printerName = departs.getDefaultPrinterName();
}
}
TrainPrintUtilities.printReport(file, file.getName(), _isPreview, Setup.getFontName(), false, logoURL, printerName, Setup.getManifestOrientation(), Setup.getManifestFontSize());
return;
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class PrintSwitchListAction method doAction.
@Override
public void doAction() {
if (getAutomationItem() != null) {
setRunning(true);
TrainSwitchLists trainSwitchLists = new TrainSwitchLists();
for (Location location : LocationManager.instance().getLocationsByNameList()) {
if (location.isSwitchListEnabled()) {
trainSwitchLists.buildSwitchList(location);
trainSwitchLists.printSwitchList(location, TrainManager.instance().isPrintPreviewEnabled());
}
}
// set trains switch lists printed
TrainManager.instance().setTrainsSwitchListStatus(Train.PRINTED);
}
finishAction(true);
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class SchedulesByLoadFrame method updateLocations.
private void updateLocations() {
String type = (String) typesComboBox.getSelectedItem();
String load = (String) loadsComboBox.getSelectedItem();
log.debug("Update locations for type ({}) load ({})", type, load);
locationsPanel.removeAll();
int x = 0;
addItemLeft(locationsPanel, new JLabel(Bundle.getMessage("trackSchedule")), 1, x);
addItemLeft(locationsPanel, new JLabel(Bundle.getMessage("receiveTypeLoad")), 2, x);
addItemLeft(locationsPanel, new JLabel(Bundle.getMessage("shipLoad")), 3, x);
addItemLeft(locationsPanel, new JLabel(Bundle.getMessage("destinationTrack")), 4, x++);
for (Location location : locationManager.getLocationsByNameList()) {
// only spurs have schedules
if (!location.hasSpurs())
continue;
addItemLeft(locationsPanel, new JLabel(location.getName()), 0, x++);
// now look for a spur with a schedule
for (Track spur : location.getTrackByNameList(Track.SPUR)) {
Schedule sch = spur.getSchedule();
if (sch == null) {
continue;
}
// listen for changes
spur.removePropertyChangeListener(this);
spur.addPropertyChangeListener(this);
sch.removePropertyChangeListener(this);
sch.addPropertyChangeListener(this);
// determine if schedule is requesting car type and load
for (ScheduleItem si : sch.getItemsBySequenceList()) {
if ((allTypesCheckBox.isSelected() || si.getTypeName().equals(type)) && (allLoadsCheckBox.isSelected() || si.getReceiveLoadName().equals(load) || si.getReceiveLoadName().equals(ScheduleItem.NONE) || si.getShipLoadName().equals(load) || si.getShipLoadName().equals(ScheduleItem.NONE))) {
// is the schedule item valid?
String status = spur.checkScheduleValid();
if (!status.equals(Track.SCHEDULE_OKAY)) {
addItemLeft(locationsPanel, new JLabel(" " + status), 0, x);
}
addItemLeft(locationsPanel, new JLabel(spur.getName() + " (" + spur.getScheduleName() + ")"), 1, x);
// create string Receive(type, delivery, road, load)
String s = si.getTypeName();
if (!si.getSetoutTrainScheduleId().equals(ScheduleItem.NONE) && TrainScheduleManager.instance().getScheduleById(si.getSetoutTrainScheduleId()) != null) {
s = s + ", " + TrainScheduleManager.instance().getScheduleById(si.getSetoutTrainScheduleId()).getName();
} else {
s = s + ",";
}
if (!si.getRoadName().equals(ScheduleItem.NONE)) {
s = s + ", " + si.getRoadName();
} else {
s = s + ",";
}
s = s + ", " + si.getReceiveLoadName();
addItemLeft(locationsPanel, new JLabel(Bundle.getMessage("Receive") + " (" + s + ")"), 2, x);
// create string Ship(load, pickup)
s = "";
if (!si.getPickupTrainScheduleId().equals(ScheduleItem.NONE) && TrainScheduleManager.instance().getScheduleById(si.getPickupTrainScheduleId()) != null) {
s = ", " + TrainScheduleManager.instance().getScheduleById(si.getPickupTrainScheduleId()).getName();
}
addItemLeft(locationsPanel, new JLabel(Bundle.getMessage("Ship") + " (" + si.getShipLoadName() + s + ")"), 3, x++);
// now the destination and track
if (si.getDestination() != null) {
addItemLeft(locationsPanel, new JLabel(si.getDestinationName() + " (" + si.getDestinationTrackName() + ")"), 4, x - 1);
}
// report if spur can't service the selected load
if (!allLoadsCheckBox.isSelected() && si.getReceiveLoadName().equals(ScheduleItem.NONE) && !spur.acceptsLoad(load, type)) {
addItemLeft(locationsPanel, new JLabel(MessageFormat.format(Bundle.getMessage("spurNotTypeLoad"), new Object[] { spur.getName(), type, load })), 2, x++);
}
}
}
}
}
locationsPanel.revalidate();
revalidate();
repaint();
}
Aggregations