private void updateLocations(){
  log.debug("update checkboxes");
  removePropertyChangeLocations();
  trackCheckBoxList.clear();
  int x=0;
  pLocations.removeAll();
  String type=(String)typeComboBox.getSelectedItem();
  String load=(String)loadComboBox.getSelectedItem();
  log.debug("Selected car type : ({}) load ({})",type,load);
  if (_location != null && locationManager.getLocationByName(_location.getName()) == null) {
    _location=null;
  }
  List<Location> locations=locationManager.getLocationsByNameList();
  for (  Location location : locations) {
    if (_location != null && _location != location) {
      continue;
    }
    location.addPropertyChangeListener(this);
    JLabel locationName=new JLabel(location.getName());
    addItemLeft(pLocations,locationName,0,x++);
    List<Track> tracks=location.getTrackByNameList(null);
    for (    Track track : tracks) {
      track.addPropertyChangeListener(this);
      JCheckBox cb=new JCheckBox(track.getName());
      cb.setName(track.getId() + "-" + "r");
      addCheckBoxAction(cb);
      trackCheckBoxList.add(cb);
      cb.setEnabled(track.acceptsTypeName(type));
      cb.setSelected(track.acceptsLoad(load,type));
      addItemLeft(pLocations,cb,1,x++);
      if (cb.isEnabled()) {
        cb.setToolTipText(MessageFormat.format(Bundle.getMessage("TipTrackCarLoad"),new Object[]{load}));
      }
 else {
        cb.setToolTipText(MessageFormat.format(Bundle.getMessage("TipTrackNotThisType"),new Object[]{type}));
      }
    }
    if (location.isStaging()) {
      JLabel ships=new JLabel(location.getName() + " (" + Bundle.getMessage("Ships")+ ")");
      addItemLeft(pLocations,ships,0,x++);
      for (      Track track : tracks) {
        JCheckBox cb=new JCheckBox(track.getName());
        cb.setName(track.getId() + "-" + "s");
        addCheckBoxAction(cb);
        trackCheckBoxList.add(cb);
        cb.setEnabled(track.acceptsTypeName(type));
        cb.setSelected(track.shipsLoad(load,type));
        addItemLeft(pLocations,cb,1,x++);
        if (cb.isEnabled()) {
          cb.setToolTipText(MessageFormat.format(Bundle.getMessage("TipTrackCarShipsLoad"),new Object[]{load}));
        }
 else {
          cb.setToolTipText(MessageFormat.format(Bundle.getMessage("TipTrackNotThisType"),new Object[]{type}));
        }
      }
    }
  }
  pLocations.revalidate();
  repaint();
}

private void updateLocations ( ) { log . debug ( "update checkboxes" ) ; removePropertyChangeLocations ( ) ; trackCheckBoxList . clear ( ) ; int x = 0 ; pLocations . removeAll ( ) ; String type = ( String ) typeComboBox . getSelectedItem ( ) ; String load = ( String ) loadComboBox . getSelectedItem ( ) ; log . debug ( "Selected car type : ({}) load ({})" , type , load ) ; if ( _location != null && locationManager . getLocationByName ( _location . getName ( ) ) == null ) { _location = null ; } List < Location > locations = locationManager . getLocationsByNameList ( ) ; for ( Location location : locations ) { if ( _location != null && _location != location ) { continue ; } location . addPropertyChangeListener ( this ) ; JLabel locationName = new JLabel ( location . getName ( ) ) ; addItemLeft ( pLocations , locationName , 0 , x ++ ) ; List < Track > tracks = location . getTrackByNameList ( null ) ; for ( Track track : tracks ) { track . addPropertyChangeListener ( this ) ; JCheckBox cb = new JCheckBox ( track . getName ( ) ) ; cb . setName ( track . getId ( ) + "-" + "r" ) ; addCheckBoxAction ( cb ) ; trackCheckBoxList . add ( cb ) ; cb . setEnabled ( track . acceptsTypeName ( type ) ) ; cb . setSelected ( track . acceptsLoad ( load , type ) ) ; addItemLeft ( pLocations , cb , 1 , x ++ ) ; if ( cb . isEnabled ( ) ) { cb . setToolTipText ( MessageFormat . format ( Bundle . getMessage ( "TipTrackCarLoad" ) , new Object [ ] { load } ) ) ; } else { cb . setToolTipText ( MessageFormat . format ( Bundle . getMessage ( "TipTrackNotThisType" ) , new Object [ ] { type } ) ) ; } } if ( location . isStaging ( ) ) { JLabel ships = new JLabel ( location . getName ( ) + " (" + Bundle . getMessage ( "Ships" ) + ")" ) ; addItemLeft ( pLocations , ships , 0 , x ++ ) ; for ( Track track : tracks ) { JCheckBox cb = new JCheckBox ( track . getName ( ) ) ; cb . setName ( track . getId ( ) + "-" + "s" ) ; addCheckBoxAction ( cb ) ; trackCheckBoxList . add ( cb ) ; cb . setEnabled ( track . acceptsTypeName ( type ) ) ; cb . setSelected ( track . shipsLoad ( load , type ) ) ; addItemLeft ( pLocations , cb , 1 , x ++ ) ; if ( cb . isEnabled ( ) ) { cb . setToolTipText ( MessageFormat . format ( Bundle . getMessage ( "TipTrackCarShipsLoad" ) , new Object [ ] { load } ) ) ; } else { cb . setToolTipText ( MessageFormat . format ( Bundle . getMessage ( "TipTrackNotThisType" ) , new Object [ ] { type } ) ) ; } } } } pLocations . revalidate ( ) ; repaint ( ) ; }
update tracks at locations based on car type serviced , or car loads serviced . if car loads , disable any tracks that don ' t service the car type selected .
