// add, build, print, switch lists, terminate, and save buttons
 public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
   log.debug("button activated");
   if (ae.getSource() == clearButton) {
     updateCheckboxes(false);
   }
   if (ae.getSource() == selectButton) {
     updateCheckboxes(true);
   }
   if (ae.getSource() == applyButton) {
     applySchedule();
   }
   if (ae.getSource() == buildButton) {
     switchListsButton.setEnabled(false);
     // uses a thread which allows table updates during build
     trainManager.buildSelectedTrains(getSortByList());
   }
   if (ae.getSource() == printButton) {
     trainManager.printSelectedTrains(getSortByList());
   }
   if (ae.getSource() == switchListsButton) {
     trainScheduleManager.buildSwitchLists();
   }
   if (ae.getSource() == terminateButton) {
     trainManager.terminateSelectedTrains(getSortByList());
   }
   if (ae.getSource() == activateButton) {
     trainManager.setTrainSecheduleActiveId(getSelectedScheduleId());
     activateButton.setEnabled(false);
   }
   if (ae.getSource() == saveButton) {
     storeValues();
     if (Setup.isCloseWindowOnSaveEnabled()) {
       dispose();
     }
   }
 }
Example #2
0
  // add, build, print, switch lists, terminate, and save buttons
  public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
    // log.debug("train button activated");
    if (ae.getSource() == addButton) {
      new TrainEditFrame(null);
    }
    if (ae.getSource() == buildButton) {
      // uses a thread which allows table updates during build
      trainManager.buildSelectedTrains(getSortByList());
    }
    if (ae.getSource() == printButton) {
      trainManager.printSelectedTrains(getSortByList());
    }
    if (ae.getSource() == openFileButton) {
      // open the csv files
      List<Train> trains = getSortByList();
      for (Train train : trains) {
        if (train.isBuildEnabled()) {
          if (!train.isBuilt() && trainManager.isBuildMessagesEnabled()) {
            JOptionPane.showMessageDialog(
                this,
                MessageFormat.format(
                    Bundle.getMessage("NeedToBuildBeforeOpenFile"),
                    new Object[] {
                      train.getName(),
                      (trainManager.isPrintPreviewEnabled()
                          ? Bundle.getMessage("preview")
                          : Bundle.getMessage("print"))
                    }),
                MessageFormat.format(
                    Bundle.getMessage("CanNotPrintManifest"),
                    new Object[] {
                      trainManager.isPrintPreviewEnabled()
                          ? Bundle.getMessage("preview")
                          : Bundle.getMessage("print")
                    }),
                JOptionPane.ERROR_MESSAGE);
          } else if (train.isBuilt()) {
            train.openFile();
          }
        }
      }
    }
    if (ae.getSource() == runFileButton) {
      // Processes the CSV Manifest files using an external custom program.
      if (!TrainCustomManifest.manifestCreatorFileExists()) {
        log.warn(
            "Manifest creator file not found!, directory name: "
                + TrainCustomManifest.getDirectoryName()
                + ", file name: "
                + TrainCustomManifest.getFileName()); // NOI18N
        JOptionPane.showMessageDialog(
            this,
            MessageFormat.format(
                Bundle.getMessage("LoadDirectoryNameFileName"),
                new Object[] {
                  TrainCustomManifest.getDirectoryName(), TrainCustomManifest.getFileName()
                }),
            Bundle.getMessage("ManifestCreatorNotFound"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }
      List<Train> trains = getSortByList();
      for (Train train : trains) {
        if (train.isBuildEnabled()) {
          if (!train.isBuilt() && trainManager.isBuildMessagesEnabled()) {
            JOptionPane.showMessageDialog(
                this,
                MessageFormat.format(
                    Bundle.getMessage("NeedToBuildBeforeRunFile"),
                    new Object[] {
                      train.getName(),
                      (trainManager.isPrintPreviewEnabled()
                          ? Bundle.getMessage("preview")
                          : Bundle.getMessage("print"))
                    }),
                MessageFormat.format(
                    Bundle.getMessage("CanNotPrintManifest"),
                    new Object[] {
                      trainManager.isPrintPreviewEnabled()
                          ? Bundle.getMessage("preview")
                          : Bundle.getMessage("print")
                    }),
                JOptionPane.ERROR_MESSAGE);
          } else if (train.isBuilt()) {
            // Make sure our csv manifest file exists for this Train.
            File csvFile = train.createCSVManifestFile();
            // Add it to our collection to be processed.
            TrainCustomManifest.addCVSFile(csvFile);
          }
        }
      }

      // Now run the user specified custom Manifest processor program
      TrainCustomManifest.process();
    }
    if (ae.getSource() == switchListsButton) {
      if (tslef != null) {
        tslef.dispose();
      }
      tslef = new TrainSwitchListEditFrame();
      tslef.initComponents();
    }
    if (ae.getSource() == terminateButton) {
      trainManager.terminateSelectedTrains(getSortByList());
    }
    if (ae.getSource() == saveButton) {
      storeValues();
    }
  }