public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
   if (ae.getSource() == saveButton) {
     // confirm that factor is between 0 and 1000
     try {
       int factor = Integer.parseInt(factorTextField.getText());
       if (factor < 0 || factor > 1000) {
         JOptionPane.showMessageDialog(
             this,
             Bundle.getMessage("FactorMustBeNumber"),
             Bundle.getMessage("ErrorFactor"),
             JOptionPane.ERROR_MESSAGE);
         return;
       }
     } catch (NumberFormatException e) {
       JOptionPane.showMessageDialog(
           this,
           Bundle.getMessage("FactorMustBeNumber"),
           Bundle.getMessage("ErrorFactor"),
           JOptionPane.ERROR_MESSAGE);
       return;
     }
     _track.setReservationFactor(Integer.parseInt(factorTextField.getText()));
     if (trackBox.getSelectedItem() != null && !trackBox.getSelectedItem().equals(Location.NONE)) {
       _track.setAlternateTrack((Track) trackBox.getSelectedItem());
     } else {
       _track.setAlternateTrack(null);
     }
     OperationsXml.save();
     if (Setup.isCloseWindowOnSaveEnabled()) {
       dispose();
     }
   }
 }
 protected void handleModified() {
   if (Setup.isAutoSaveEnabled()) {
     storeValues();
     return;
   }
   if (OperationsXml.areFilesDirty()) {
     int result =
         javax.swing.JOptionPane.showOptionDialog(
             this,
             Bundle.getMessage("PromptQuitWindowNotWritten"),
             Bundle.getMessage("PromptSaveQuit"),
             javax.swing.JOptionPane.YES_NO_OPTION,
             javax.swing.JOptionPane.WARNING_MESSAGE,
             null, // icon
             new String[] {
               ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnYesSave"), // NOI18N
               ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnNoClose")
             }, // NOI18N
             ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnYesSave"));
     if (result == javax.swing.JOptionPane.NO_OPTION) {
       return;
     }
     // user wants to save
     storeValues();
   }
 }
 protected void storeValues() {
   // Save comment
   TrainSchedule ts = trainScheduleManager.getScheduleById(getSelectedScheduleId());
   if (ts != null) {
     ts.setComment(commentTextArea.getText());
   }
   //        updateControlPanel();
   saveTableDetails(trainsScheduleTable);
   OperationsXml.save();
 }
 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
     value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
 protected void save() {
   checkForErrors();
   _track.setHoldCarsWithCustomLoadsEnabled(holdCars.isSelected());
   // save the last state of the "Use car type and load" checkbox
   loadAndType = loadAndTypeCheckBox.isSelected();
   shipLoadAndType = shipLoadAndTypeCheckBox.isSelected();
   // save location file
   OperationsXml.save();
 }
Exemple #5
0
 private void deleteSchedule(int row) {
   log.debug("Delete schedule");
   Schedule s = sysList.get(row);
   if (JOptionPane.showConfirmDialog(
           null,
           MessageFormat.format(
               Bundle.getMessage("DoYouWantToDeleteSchedule"), new Object[] {s.getName()}),
           Bundle.getMessage("DeleteSchedule?"),
           JOptionPane.YES_NO_OPTION)
       == JOptionPane.YES_OPTION) {
     scheduleManager.deregister(s);
     OperationsXml.save();
   }
 }
 // add, find or save button
 public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
   // log.debug("car button activated");
   if (ae.getSource() == findButton) {
     int rowindex = carsTableModel.findCarByRoadNumber(findCarTextBox.getText());
     if (rowindex < 0) {
       JOptionPane.showMessageDialog(
           this,
           MessageFormat.format(
               Bundle.getMessage("carWithRoadNumNotFound"),
               new Object[] {findCarTextBox.getText()}),
           Bundle.getMessage("carCouldNotFind"),
           JOptionPane.INFORMATION_MESSAGE);
       return;
     }
     // clear any sorts by column
     clearTableSort(carsTable);
     carsTable.changeSelection(rowindex, 0, false, false);
     return;
   }
   if (ae.getSource() == addButton) {
     if (f != null) {
       f.dispose();
     }
     f = new CarEditFrame();
     f.initComponents();
     f.setTitle(Bundle.getMessage("TitleCarAdd"));
   }
   if (ae.getSource() == saveButton) {
     if (carsTable.isEditing()) {
       log.debug("cars table edit true");
       carsTable.getCellEditor().stopCellEditing();
     }
     OperationsXml.save();
     saveTableDetails(carsTable);
     if (Setup.isCloseWindowOnSaveEnabled()) {
       dispose();
     }
   }
 }
 /**
  * Need to also write the location and train files if a road name was deleted. Need to also write
  * files if car type was changed.
  */
 private void writeFiles() {
   OperationsXml.save(); // save engine file
 }
Exemple #8
0
  @Override
  @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
      value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
      justification = "GUI ease of use")
  protected void buttonActionPerformed(java.awt.event.ActionEvent ae) {
    if (ae.getSource() == copyButton) {
      log.debug("copy location button activated");
      if (!checkName()) {
        return;
      }

      if (locationBox.getSelectedItem() == null) {
        JOptionPane.showMessageDialog(
            this,
            Bundle.getMessage("SelectLocationToCopy"),
            MessageFormat.format(
                Bundle.getMessage("CanNotLocation"), new Object[] {Bundle.getMessage("Copy")}),
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      Location location = (Location) locationBox.getSelectedItem();
      // check to see if there are cars scheduled for pickup or set out
      if (moveRollingStockCheckBox.isSelected()) {
        for (Track track : location.getTrackList()) {
          if (track.getPickupRS() > 0) {
            JOptionPane.showMessageDialog(
                this,
                MessageFormat.format(
                    Bundle.getMessage("FoundRollingStockPickUp"),
                    new Object[] {track.getPickupRS()}),
                MessageFormat.format(
                    Bundle.getMessage("TrainsServicingTrack"), new Object[] {track.getName()}),
                JOptionPane.WARNING_MESSAGE);
            return; // can't move rolling stock, some are scheduled for a pick up
          }
          if (track.getDropRS() > 0) {
            JOptionPane.showMessageDialog(
                this,
                MessageFormat.format(
                    Bundle.getMessage("FoundRollingStockDrop"), new Object[] {track.getDropRS()}),
                MessageFormat.format(
                    Bundle.getMessage("TrainsServicingTrack"), new Object[] {track.getName()}),
                JOptionPane.WARNING_MESSAGE);
            return; // can't move rolling stock, some are scheduled for drops
          }
        }
      }
      // now copy all of the tracks
      Location newLocation = locationManager.newLocation(loctionNameTextField.getText());
      location.copyLocation(newLocation);

      // does the user want the cars to also move to the new tracks?
      if (moveRollingStockCheckBox.isSelected()) {
        for (Track track : location.getTrackList()) {
          moveRollingStock(track, newLocation.getTrackByName(track.getName(), null));
          if (deleteTrackCheckBox.isSelected()) {
            location.deleteTrack(track);
          }
        }
      }
    }
    if (ae.getSource() == saveButton) {
      log.debug("save track button activated");
      // save checkbox states
      moveRollingStock = moveRollingStockCheckBox.isSelected();
      deleteTrack = deleteTrackCheckBox.isSelected();
      // save location file
      OperationsXml.save();
    }
  }