Example #1
0
 public void checkBoxActionPerformed(java.awt.event.ActionEvent ae) {
   if (ae.getSource() == buildMsgBox) {
     trainManager.setBuildMessagesEnabled(buildMsgBox.isSelected());
   }
   if (ae.getSource() == buildReportBox) {
     trainManager.setBuildReportEnabled(buildReportBox.isSelected());
   }
   if (ae.getSource() == printPreviewBox) {
     trainManager.setPrintPreviewEnabled(printPreviewBox.isSelected());
     setPrintButtonText(); // set the button text for Print or Preview
   }
   if (ae.getSource() == openFileBox) {
     trainManager.setOpenFileEnabled(openFileBox.isSelected());
     runFileBox.setSelected(false);
     trainManager.setRunFileEnabled(false);
   }
   if (ae.getSource() == runFileBox) {
     trainManager.setRunFileEnabled(runFileBox.isSelected());
     openFileBox.setSelected(false);
     trainManager.setOpenFileEnabled(false);
   }
   if (ae.getSource() == showAllBox) {
     trainsModel.setShowAll(showAllBox.isSelected());
   }
 }
Example #2
0
 public void radioButtonActionPerformed(java.awt.event.ActionEvent ae) {
   log.debug("radio button activated");
   if (ae.getSource() == showId) {
     trainsModel.setSort(trainsModel.SORTBYID);
   }
   if (ae.getSource() == showTime) {
     trainsModel.setSort(trainsModel.SORTBYTIME);
   }
   if (ae.getSource() == moveRB) {
     trainManager.setTrainsFrameTrainAction(MOVE);
   }
   if (ae.getSource() == terminateRB) {
     trainManager.setTrainsFrameTrainAction(TERMINATE);
   }
   if (ae.getSource() == resetRB) {
     trainManager.setTrainsFrameTrainAction(RESET);
   }
   if (ae.getSource() == conductorRB) {
     trainManager.setTrainsFrameTrainAction(CONDUCTOR);
   }
 }
Example #3
0
 public void dispose() {
   /*
    * all JMRI window position and size are now saved in user preference file
    * trainManager.setTrainsFrameTableColumnWidths(getCurrentTableColumnWidths()); // save column widths
    * trainManager.setTrainsFrame(null);
    */
   trainsModel.dispose();
   trainManager.runShutDownScripts();
   trainManager.removePropertyChangeListener(this);
   Setup.removePropertyChangeListener(this);
   removePropertyChangeLocations();
   super.dispose();
 }
Example #4
0
  public TrainsTableFrame() {
    super();

    updateTitle();

    // create ShutDownTasks
    createShutDownTask();
    // always check for dirty operations files
    setModifiedFlag(true);

    // general GUI configuration
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    // Set up the jtable in a Scroll Pane..
    trainsModel = new TrainsTableModel();
    sorter = new TableSorter(trainsModel);
    trainsTable = new JTable(sorter);
    sorter.setTableHeader(trainsTable.getTableHeader());
    trainsPane = new JScrollPane(trainsTable);
    trainsModel.initTable(trainsTable, this);

    // Set up the control panel
    // row 1
    JPanel cp1 = new JPanel();
    cp1.setLayout(new BoxLayout(cp1, BoxLayout.X_AXIS));

    JPanel show = new JPanel();
    show.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ShowClickToSort")));
    show.add(showTime);
    show.add(showId);

    JPanel options = new JPanel();
    options.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
    options.add(showAllBox);
    options.add(buildMsgBox);
    options.add(buildReportBox);
    options.add(printPreviewBox);
    options.add(openFileBox);
    options.add(runFileBox);

    JPanel action = new JPanel();
    action.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Action")));
    action.add(moveRB);
    action.add(conductorRB);
    action.add(terminateRB);
    action.add(resetRB);

    cp1.add(show);
    cp1.add(options);
    cp1.add(action);

    // tool tips, see setPrintButtonText() for more tool tips
    addButton.setToolTipText(Bundle.getMessage("AddTrain"));
    buildButton.setToolTipText(Bundle.getMessage("BuildSelectedTip"));
    switchListsButton.setToolTipText(Bundle.getMessage("PreviewPrintSwitchLists"));

    terminateButton.setToolTipText(Bundle.getMessage("TerminateSelectedTip"));
    saveButton.setToolTipText(Bundle.getMessage("SaveBuildsTip"));
    openFileButton.setToolTipText(Bundle.getMessage("OpenFileButtonTip"));
    runFileButton.setToolTipText(Bundle.getMessage("RunFileButtonTip"));
    buildMsgBox.setToolTipText(Bundle.getMessage("BuildMessagesTip"));
    printPreviewBox.setToolTipText(Bundle.getMessage("PreviewTip"));
    openFileBox.setToolTipText(Bundle.getMessage("OpenFileTip"));
    runFileBox.setToolTipText(Bundle.getMessage("RunFileTip"));
    showAllBox.setToolTipText(Bundle.getMessage("ShowAllTrainsTip"));

    moveRB.setToolTipText(Bundle.getMessage("MoveTip"));
    terminateRB.setToolTipText(Bundle.getMessage("TerminateTip"));
    resetRB.setToolTipText(Bundle.getMessage("ResetTip"));

    // row 2
    JPanel addTrain = new JPanel();
    addTrain.setBorder(BorderFactory.createTitledBorder(""));
    addTrain.add(numTrains);
    addTrain.add(textTrains);
    addTrain.add(textSep1);
    addTrain.add(addButton);

    numTrains.setText(Integer.toString(trainManager.getNumEntries()));

    JPanel select = new JPanel();
    select.setBorder(BorderFactory.createTitledBorder(""));
    select.add(buildButton);
    select.add(printButton);
    select.add(openFileButton);
    select.add(runFileButton);
    select.add(switchListsButton);
    select.add(terminateButton);

    JPanel save = new JPanel();
    save.setBorder(BorderFactory.createTitledBorder(""));
    save.add(saveButton);

    JPanel cp2 = new JPanel();
    cp2.setLayout(new BoxLayout(cp2, BoxLayout.X_AXIS));
    cp2.add(addTrain);
    cp2.add(select);
    cp2.add(save);

    // place controls in scroll pane
    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS));
    controlPanel.add(cp1);
    controlPanel.add(cp2);

    JScrollPane controlPane = new JScrollPane(controlPanel);

    getContentPane().add(trainsPane);
    getContentPane().add(controlPane);

    // setup buttons
    addButtonAction(addButton);
    addButtonAction(buildButton);
    addButtonAction(printButton);
    addButtonAction(openFileButton);
    addButtonAction(runFileButton);
    addButtonAction(switchListsButton);
    addButtonAction(terminateButton);
    addButtonAction(saveButton);

    ButtonGroup showGroup = new ButtonGroup();
    showGroup.add(showTime);
    showGroup.add(showId);
    showTime.setSelected(true);

    ButtonGroup actionGroup = new ButtonGroup();
    actionGroup.add(moveRB);
    actionGroup.add(conductorRB);
    actionGroup.add(terminateRB);
    actionGroup.add(resetRB);

    addRadioButtonAction(showTime);
    addRadioButtonAction(showId);

    addRadioButtonAction(moveRB);
    addRadioButtonAction(terminateRB);
    addRadioButtonAction(resetRB);
    addRadioButtonAction(conductorRB);

    buildMsgBox.setSelected(trainManager.isBuildMessagesEnabled());
    buildReportBox.setSelected(trainManager.isBuildReportEnabled());
    printPreviewBox.setSelected(trainManager.isPrintPreviewEnabled());
    openFileBox.setSelected(trainManager.isOpenFileEnabled());
    runFileBox.setSelected(trainManager.isRunFileEnabled());
    showAllBox.setSelected(trainsModel.isShowAll());

    // show open files only if create csv is enabled
    updateRunAndOpenButtons();

    addCheckBoxAction(buildMsgBox);
    addCheckBoxAction(buildReportBox);
    addCheckBoxAction(printPreviewBox);
    addCheckBoxAction(showAllBox);
    addCheckBoxAction(openFileBox);
    addCheckBoxAction(runFileBox);

    // Set the button text to Print or Preview
    setPrintButtonText();
    // Set the train action button text to Move or Terminate
    setTrainActionButton();

    // build menu
    JMenuBar menuBar = new JMenuBar();
    JMenu toolMenu = new JMenu(Bundle.getMessage("Tools"));
    toolMenu.add(new OptionAction(Bundle.getMessage("TitleOptions")));
    toolMenu.add(new PrintOptionAction());
    toolMenu.add(new BuildReportOptionAction());
    toolMenu.add(new TrainsByCarTypeAction(Bundle.getMessage("TitleModifyTrains")));
    toolMenu.add(new TrainByCarTypeAction(Bundle.getMessage("MenuItemShowCarTypes"), null));
    toolMenu.add(new ChangeDepartureTimesAction(Bundle.getMessage("TitleChangeDepartureTime")));
    toolMenu.add(new TrainsTableSetColorAction());
    toolMenu.add(new TrainsScheduleAction(Bundle.getMessage("TitleTimeTableTrains")));
    toolMenu.add(new TrainCopyAction(Bundle.getMessage("TitleTrainCopy")));
    toolMenu.add(new TrainsScriptAction(Bundle.getMessage("MenuItemScripts"), this));
    toolMenu.add(
        new PrintSavedTrainManifestAction(Bundle.getMessage("MenuItemPrintSavedManifest"), false));
    toolMenu.add(
        new PrintSavedTrainManifestAction(Bundle.getMessage("MenuItemPreviewSavedManifest"), true));
    toolMenu.add(new SetupExcelProgramFrameAction(Bundle.getMessage("MenuItemSetupExcelProgram")));
    toolMenu.add(new ExportTrainRosterAction());
    toolMenu.add(
        new PrintTrainsAction(Bundle.getMessage("MenuItemPrint"), new Frame(), false, this));
    toolMenu.add(
        new PrintTrainsAction(Bundle.getMessage("MenuItemPreview"), new Frame(), true, this));

    menuBar.add(toolMenu);
    menuBar.add(new jmri.jmrit.operations.OperationsMenu());
    setJMenuBar(menuBar);

    // add help menu to window
    addHelpMenu("package.jmri.jmrit.operations.Operations_Trains", true); // NOI18N

    initMinimumSize();

    addHorizontalScrollBarKludgeFix(controlPane, controlPanel);

    // listen for timetable changes
    trainManager.addPropertyChangeListener(this);
    Setup.addPropertyChangeListener(this);
    // listen for location switch list changes
    addPropertyChangeLocations();

    // auto save
    new AutoSave();
  }