Exemple #1
0
 private void editSchedule(int row) {
   log.debug("Edit schedule");
   if (sef != null) {
     sef.dispose();
   }
   Schedule sch = sysList.get(row);
   LocationTrackPair ltp = getLocationTrackPair(row);
   if (ltp == null) {
     log.debug("Need location track pair");
     JOptionPane.showMessageDialog(
         null,
         MessageFormat.format(Bundle.getMessage("AssignSchedule"), new Object[] {sch.getName()}),
         MessageFormat.format(
             Bundle.getMessage("CanNotSchedule"), new Object[] {Bundle.getMessage("Edit")}),
         JOptionPane.ERROR_MESSAGE);
     return;
   }
   // use invokeLater so new window appears on top
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           sef = new ScheduleEditFrame(sch, ltp.getTrack());
         }
       });
 }
Exemple #2
0
  /**
   * Creates a generic panel that holds the basic bean information System Name, User Name and
   * Comment
   */
  BeanItemPanel basicDetails() {
    BeanItemPanel basic = new BeanItemPanel();

    basic.setName(Bundle.getMessage("Basic"));
    basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS));

    basic.addItem(
        new BeanEditItem(
            new JLabel(bean.getSystemName()), Bundle.getMessage("ColumnSystemName"), null));

    basic.addItem(new BeanEditItem(userNameField, Bundle.getMessage("ColumnUserName"), null));

    basic.addItem(new BeanEditItem(commentFieldScroller, Bundle.getMessage("ColumnComment"), null));

    basic.setSaveItem(
        new AbstractAction() {
          /** */
          private static final long serialVersionUID = -1823311798750191527L;

          public void actionPerformed(ActionEvent e) {
            saveBasicItems(e);
          }
        });
    basic.setResetItem(
        new AbstractAction() {
          /** */
          private static final long serialVersionUID = 2590436299984618901L;

          public void actionPerformed(ActionEvent e) {
            resetBasicItems(e);
          }
        });
    bei.add(basic);
    return basic;
  }
 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();
     }
   }
 }
Exemple #4
0
  protected JPanel createProgrammerSelection() {
    JPanel pane3a = new JPanel();
    pane3a.setLayout(new BoxLayout(pane3a, BoxLayout.Y_AXIS));
    // create the programmer box
    JPanel progFormat = new JPanel();
    progFormat.setLayout(new BoxLayout(progFormat, BoxLayout.X_AXIS));
    progFormat.add(new JLabel(Bundle.getMessage("ProgrammerFormat")));
    progFormat.setAlignmentX(JLabel.RIGHT_ALIGNMENT);

    programmerBox = new JComboBox<String>(ProgDefault.findListOfProgFiles());
    programmerBox.setSelectedIndex(0);
    if (ProgDefault.getDefaultProgFile() != null) {
      programmerBox.setSelectedItem(ProgDefault.getDefaultProgFile());
    }
    progFormat.add(programmerBox);

    go2 = new JButton(Bundle.getMessage("OpenProgrammer"));
    go2.addActionListener(
        new ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            if (log.isDebugEnabled()) {
              log.debug("Open programmer pressed");
            }
            openButton();
          }
        });
    go2.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
    go2.setEnabled(false);
    go2.setToolTipText(Bundle.getMessage("SELECT A LOCOMOTIVE OR DECODER TO ENABLE"));
    pane3a.add(progFormat);
    pane3a.add(go2);
    return pane3a;
  }
 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();
   }
 }
 public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
   if (ae.getSource() == previousButton) {
     updateRouteLocation(BACK);
   }
   if (ae.getSource() == nextButton) {
     updateRouteLocation(FORWARD);
   }
   if (ae.getSource() == placeButton) {
     placeTestIcons();
   }
   if (ae.getSource() == applyButton) {
     if (value != JOptionPane.YES_OPTION) {
       value =
           JOptionPane.showConfirmDialog(
               null,
               MessageFormat.format(
                   Bundle.getMessage("UpdateTrainIconRoute"), new Object[] {_route.getName()}),
               Bundle.getMessage("DoYouWantThisRoute"),
               JOptionPane.YES_NO_OPTION);
     }
     if (value == JOptionPane.YES_OPTION) {
       saveButton.setEnabled(true);
     }
     updateTrainIconCoordinates();
   }
   if (ae.getSource() == saveButton) {
     RouteManagerXml.instance().writeOperationsFile();
     if (Setup.isCloseWindowOnSaveEnabled()) {
       dispose();
     }
   }
 }
Exemple #7
0
  BeanItemPanel usageDetails() {
    BeanItemPanel usage = new BeanItemPanel();

    usage.setName(Bundle.getMessage("Usage"));
    usage.setLayout(new BoxLayout(usage, BoxLayout.Y_AXIS));

    usage.addItem(
        new BeanEditItem(null, null, Bundle.getMessage("UsageText", bean.getDisplayName())));

    ArrayList<String> listeners = new ArrayList<String>();
    for (String ref : bean.getListenerRefs()) {
      if (!listeners.contains(ref)) {
        listeners.add(ref);
      }
    }

    Object[] strArray = new Object[listeners.size()];
    listeners.toArray(strArray);
    JList<Object> list = new JList<Object>(strArray);
    list.setLayoutOrientation(JList.VERTICAL);
    list.setVisibleRowCount(-1);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black)));
    usage.addItem(new BeanEditItem(listScroller, Bundle.getMessage("ColumnLocation"), null));

    bei.add(usage);
    return usage;
  }
Exemple #8
0
 protected void setButtonText() {
   if (isSetMode) {
     setButton.setText(Bundle.getMessage("Done"));
   } else {
     setButton.setText(Bundle.getMessage("Set"));
   }
 }
Exemple #9
0
  private boolean setPathLength(OPath path) {
    float f = 0.0f;
    try {
      String num = _length.getText();
      if (num == null || num.length() == 0) {
        num = "0.0";
      }
      f = Float.parseFloat(num);
      if (_units.isSelected()) {
        path.setLength(f * 25.4f);
      } else {
        path.setLength(f * 10f);
      }
    } catch (NumberFormatException nfe) {
      f = -1.0f;
    }
    if (f < 0.0f) {
      JOptionPane.showMessageDialog(
          this,
          Bundle.getMessage("MustBeFloat", _length.getText()),
          Bundle.getMessage("makePath"),
          JOptionPane.INFORMATION_MESSAGE);
      return false;
    }

    return true;
  }
Exemple #10
0
 private void changeUnits() {
   String len = _length.getText();
   if (len == null || len.length() == 0) {
     if (_block.isMetric()) {
       _units.setText("cm");
     } else {
       _units.setText("in");
     }
     return;
   }
   try {
     float f = Float.parseFloat(len);
     if (_units.isSelected()) {
       _length.setText(Float.toString(f / 2.54f));
       _units.setText("in");
     } else {
       _length.setText(Float.toString(f * 2.54f));
       _units.setText("cm");
     }
   } catch (NumberFormatException nfe) {
     JOptionPane.showMessageDialog(
         this,
         Bundle.getMessage("MustBeFloat", len),
         Bundle.getMessage("makePath"),
         JOptionPane.INFORMATION_MESSAGE);
   }
 }
Exemple #11
0
  /**
   * Create default File menu
   *
   * @param menuBar Menu bar to be populated
   * @param wi WindowInterface where this menu will appear as part of the menu bar
   */
  protected void fileMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    menuBar.add(fileMenu);

    fileMenu.add(
        new PrintDecoderListAction(
            Bundle.getMessage("MenuPrintDecoderDefinitions"), wi.getFrame(), false));
    fileMenu.add(
        new PrintDecoderListAction(
            Bundle.getMessage("MenuPrintPreviewDecoderDefinitions"), wi.getFrame(), true));

    // Use Mac OS X native Quit if using Aqua look and feel
    if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel())) {
      fileMenu.add(new JSeparator());
      fileMenu.add(
          new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
            /** */
            private static final long serialVersionUID = -3051429826192051394L;

            @Override
            public void actionPerformed(ActionEvent e) {
              handleQuit();
            }
          });
    }
  }
Exemple #12
0
 @Override
 public String getColumnName(int col) {
   switch (col) {
     case WARRANT_COLUMN:
       return Bundle.getMessage("Warrant");
     case ROUTE_COLUMN:
       return Bundle.getMessage("Route");
     case TRAIN_NAME_COLUMN:
       return Bundle.getMessage("TrainName");
     case ADDRESS_COLUMN:
       return Bundle.getMessage("DccAddress");
     case ALLOCATE_COLUMN:
       return Bundle.getMessage("Allocate");
     case DEALLOC_COLUMN:
       return Bundle.getMessage("Deallocate");
     case SET_COLUMN:
       return Bundle.getMessage("SetRoute");
     case AUTO_RUN_COLUMN:
       return Bundle.getMessage("ARun");
     case MANUAL_RUN_COLUMN:
       return Bundle.getMessage("MRun");
     case CONTROL_COLUMN:
       return Bundle.getMessage("Control");
   }
   return "";
 }
Exemple #13
0
 @Override
 public synchronized Object getValueAt(int row, int col) {
   if (row >= getRowCount()) {
     return "ERROR row " + row; // NOI18N
   }
   Schedule schedule = sysList.get(row);
   if (schedule == null) {
     return "ERROR schedule unknown " + row; // NOI18N
   }
   switch (col) {
     case ID_COLUMN:
       return schedule.getId();
     case NAME_COLUMN:
       return schedule.getName();
     case SCHEDULE_STATUS_COLUMN:
       return getScheduleStatus(row);
     case SPUR_NUMBER_COLUMN:
       return scheduleManager.getSpursByScheduleComboBox(schedule).getItemCount();
     case SPUR_COLUMN:
       {
         return getComboBox(row, schedule);
       }
     case STATUS_COLUMN:
       return getSpurStatus(row);
     case MODE_COLUMN:
       return getSpurMode(row);
     case EDIT_COLUMN:
       return Bundle.getMessage("Edit");
     case DELETE_COLUMN:
       return Bundle.getMessage("Delete");
     default:
       return "unknown " + col; // NOI18N
   }
 }
Exemple #14
0
 @Test
 public void testLocaleMessageArg() {
   Assert.assertEquals(
       "Scambio", Bundle.getMessage(Locale.ITALY, "BeanNameTurnout", new Object[] {}));
   Assert.assertEquals(
       "Informazioni su Test", Bundle.getMessage(Locale.ITALY, "TitleAbout", "Test"));
 }
Exemple #15
0
  // add update button to  bottom1Panel
  private void addUpdateButtonToBottom(ActionListener doneAction) {

    _updateButton = new JButton(Bundle.getMessage("updateButton")); // custom Update text
    _updateButton.addActionListener(doneAction);
    _updateButton.setToolTipText(Bundle.getMessage("ToolTipPickFromTable"));
    _bottom1Panel.add(_updateButton);
  }
Exemple #16
0
 protected boolean newFamilyDialog() {
   String family =
       JOptionPane.showInputDialog(
           _paletteFrame,
           Bundle.getMessage("EnterFamilyName"),
           Bundle.getMessage("createNewIconSet", _itemType),
           JOptionPane.QUESTION_MESSAGE);
   if (family == null || family.trim().length() == 0) {
     // bail out
     return false;
   }
   Iterator<String> iter = ItemPalette.getFamilyMaps(_itemType).keySet().iterator();
   if (!jmri.util.ThreadingUtil.isGUIThread())
     log.error("Not on GUI thread", new Exception("traceback"));
   while (iter.hasNext()) {
     if (family.equals(iter.next())) {
       JOptionPane.showMessageDialog(
           _paletteFrame,
           Bundle.getMessage("DuplicateFamilyName", family, _itemType),
           Bundle.getMessage("WarningTitle"),
           JOptionPane.WARNING_MESSAGE);
       return false;
     }
   }
   _dialog = openDialog(_itemType, family, null);
   return true;
 }
Exemple #17
0
  /** Callback from acquireThrottle() when the throttle has become available. */
  public void notifyThrottleFound(DccThrottle throttle) {
    if (throttle == null) {
      abortWarrant("notifyThrottleFound: null throttle(?)!");
      firePropertyChange("throttleFail", null, Bundle.getMessage("noThrottle"));
      return;
    }
    if (_runMode == MODE_LEARN) {
      abortWarrant("notifyThrottleFound: No LEARN mode for SCWarrant");
      InstanceManager.throttleManagerInstance().releaseThrottle(throttle, this);
      firePropertyChange("throttleFail", null, Bundle.getMessage("noThrottle"));
      return;
    }
    if (log.isDebugEnabled()) {
      log.debug(
          _trainName
              + " notifyThrottleFound address= "
              + throttle.getLocoAddress().toString()
              + " _runMode= "
              + _runMode);
    }

    startupWarrant();
    _engineer = new Engineer(this, throttle);
    firePropertyChange("runMode", Integer.valueOf(MODE_NONE), Integer.valueOf(_runMode));
    runSignalControlledTrain();
  }
Exemple #18
0
  public LocationCopyFrame() {

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

    // Set up the panels
    // Layout the panel by rows
    // row 1
    JPanel pName = new JPanel();
    pName.setLayout(new GridBagLayout());
    pName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LocationName")));
    addItem(pName, loctionNameTextField, 0, 0);

    // row 2
    JPanel pCopy = new JPanel();
    pCopy.setLayout(new GridBagLayout());
    pCopy.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("SelectLocationToCopy")));
    addItem(pCopy, locationBox, 0, 0);

    // row 3
    JPanel pOptions = new JPanel();
    pOptions.setLayout(new GridBagLayout());
    pOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
    addItemLeft(pOptions, moveRollingStockCheckBox, 0, 1);
    addItemLeft(pOptions, deleteTrackCheckBox, 0, 2);

    // row 4
    JPanel pButton = new JPanel();
    pButton.setLayout(new GridBagLayout());
    addItem(pButton, copyButton, 0, 0);
    addItem(pButton, saveButton, 1, 0);

    getContentPane().add(pName);
    getContentPane().add(pCopy);
    getContentPane().add(pOptions);
    getContentPane().add(pButton);

    // set the checkbox states
    moveRollingStockCheckBox.setSelected(moveRollingStock);
    deleteTrackCheckBox.setSelected(deleteTrack);
    deleteTrackCheckBox.setEnabled(moveRollingStockCheckBox.isSelected());

    // get notified if combo box gets modified
    locationManager.addPropertyChangeListener(this);

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

    pack();
    setMinimumSize(new Dimension(Control.panelWidth400, Control.panelHeight400));

    // setup buttons
    addButtonAction(copyButton);
    addButtonAction(saveButton);

    addCheckBoxAction(moveRollingStockCheckBox);

    setTitle(Bundle.getMessage("MenuItemCopyLocation"));
  }
 void handleCreateException(String sysName) {
   javax.swing.JOptionPane.showMessageDialog(
       addFrame,
       java.text.MessageFormat.format(
           Bundle.getMessage("ErrorBlockAddFailed"), new Object[] {sysName}),
       Bundle.getMessage("ErrorTitle"),
       javax.swing.JOptionPane.ERROR_MESSAGE);
 }
Exemple #20
0
  public void init() {
    makeMenus();
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout(10, 10));
    _controlPanel = new JPanel();
    _controlPanel.setLayout(new BoxLayout(_controlPanel, BoxLayout.PAGE_AXIS));
    _controlPanel.add(Box.createVerticalGlue());
    _controlPanel.add(makeBlockPanels());
    _controlPanel.add(searchDepthPanel(false));

    _maxSpeedBox.addActionListener(
        (ActionEvent e) -> {
          getBoxData();
        });
    _autoRunPanel =
        makeAutoRunPanel(jmri.InstanceManager.getDefault(SignalSpeedMap.class).getInterpretation());

    _controlPanel.add(_autoRunPanel);
    _controlPanel.add(Box.createVerticalStrut(STRUT_SIZE));

    _forward.setSelected(true);
    _stageEStop.setSelected(false);
    _haltStartBox.setSelected(_haltStart);
    _calibrateBox.setSelected(false);
    _rampInterval.setText(Float.toString(_intervalTime / 1000));
    JPanel p = new JPanel();
    p.add(Box.createGlue());
    JButton button = new JButton(Bundle.getMessage("ButtonRunNX"));
    button.addActionListener(
        (ActionEvent e) -> {
          makeAndRunWarrant();
        });
    p.add(button);
    p.add(Box.createHorizontalStrut(2 * STRUT_SIZE));
    button = new JButton(Bundle.getMessage("ButtonCancel"));
    button.addActionListener(
        (ActionEvent e) -> {
          closeFrame();
        });
    p.add(button);
    p.add(Box.createGlue());
    _controlPanel.add(p);

    _controlPanel.add(Box.createVerticalStrut(STRUT_SIZE));
    _controlPanel.add(makeSwitchPanel());

    mainPanel.add(_controlPanel);
    getContentPane().add(mainPanel);
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          @Override
          public void windowClosing(java.awt.event.WindowEvent e) {
            closeFrame();
          }
        });
    setAlwaysOnTop(true);
    pack();
  }
Exemple #21
0
 @Override
 public void setValueAt(Object value, int row, int col) {
   switch (col) {
     case USERNAMECOL:
       // Directly changing the username should only be possible if the username was previously
       // null or ""
       // check to see if user name already exists
       if (((String) value).equals("")) {
         value = null;
       } else {
         NamedBean nB = getByUserName((String) value);
         if (nB != null) {
           log.error("User name is not unique " + value);
           String msg = Bundle.getMessage("WarningUserName", new Object[] {("" + value)});
           JOptionPane.showMessageDialog(
               null, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
           return;
         }
       }
       NamedBean nBean = getBySystemName(sysNameList.get(row));
       nBean.setUserName((String) value);
       if (nbMan.inUse(sysNameList.get(row), nBean)) {
         String msg =
             Bundle.getMessage(
                 "UpdateToUserName", new Object[] {getBeanType(), value, sysNameList.get(row)});
         int optionPane =
             JOptionPane.showConfirmDialog(
                 null, msg, Bundle.getMessage("UpdateToUserNameTitle"), JOptionPane.YES_NO_OPTION);
         if (optionPane == JOptionPane.YES_OPTION) {
           // This will update the bean reference from the systemName to the userName
           try {
             nbMan.updateBeanFromSystemToUser(nBean);
           } catch (JmriException ex) {
             // We should never get an exception here as we already check that the username is not
             // valid
           }
         }
       }
       fireTableRowsUpdated(row, row);
       break;
     case COMMENTCOL:
       getBySystemName(sysNameList.get(row)).setComment((String) value);
       fireTableRowsUpdated(row, row);
       break;
     case VALUECOL:
       // button fired, swap state
       NamedBean t = getBySystemName(sysNameList.get(row));
       clickOn(t);
       break;
     case DELETECOL:
       // button fired, delete Bean
       deleteBean(row, col);
       break;
     default:
       break;
   }
 }
Exemple #22
0
  /*
   * Set actions of radioButtons to change family
   */
  protected JPanel makeFamilyButtons(Iterator<String> it, boolean setDefault) {
    JPanel familyPanel = new JPanel();
    familyPanel.setLayout(new BoxLayout(familyPanel, BoxLayout.Y_AXIS));
    String txt = Bundle.getMessage("IconFamiliesLabel", Bundle.getMessage(_itemType));
    JPanel p = new JPanel(new FlowLayout());
    p.add(new JLabel(txt));
    familyPanel.add(p);
    _familyButtonGroup = new ButtonGroup();
    JPanel buttonPanel = new JPanel(new FlowLayout());
    String family = null;
    JRadioButton button = null;
    int count = 0;
    while (it.hasNext()) {
      family = it.next();
      count++;
      button = new JRadioButton(ItemPalette.convertText(family));
      button.addActionListener(
          new ActionListener() {
            String fam;

            public void actionPerformed(ActionEvent e) {
              setFamily(fam);
            }

            ActionListener init(String f) {
              fam = f;
              if (log.isDebugEnabled()) {
                log.debug(
                    "ActionListener.init : for type \"" + _itemType + "\", family \"" + fam + "\"");
              }
              return this;
            }
          }.init(family));
      if (family.equals(_family)) {
        button.setSelected(true);
      }
      if (count > 4) {
        count = 0;
        familyPanel.add(buttonPanel);
        buttonPanel = new JPanel(new FlowLayout());
        buttonPanel.setLayout(new FlowLayout()); // new BoxLayout(p, BoxLayout.Y_AXIS)
      }
      buttonPanel.add(button);
      _familyButtonGroup.add(button);
    }
    familyPanel.add(buttonPanel);
    if (setDefault && !family.equals(_family)) {
      _family = family; // let last family be the selected one
      if (button != null) {
        button.setSelected(true);
      } else {
        log.warn("null button after setting family");
      }
    }
    familyPanel.add(buttonPanel);
    return familyPanel;
  }
 // Modifies button text and tool tips
 private void setPrintButtonText() {
   if (trainManager.isPrintPreviewEnabled()) {
     printButton.setText(Bundle.getMessage("Preview"));
     printButton.setToolTipText(Bundle.getMessage("PreviewSelectedTip"));
   } else {
     printButton.setText(Bundle.getMessage("Print"));
     printButton.setToolTipText(Bundle.getMessage("PrintSelectedTip"));
   }
 }
 private void setSwitchListButtonText() {
   if (!Setup.isSwitchListRealTime()) {
     switchListsButton.setText(Bundle.getMessage("Update"));
   } else if (trainManager.isPrintPreviewEnabled()) {
     switchListsButton.setText(Bundle.getMessage("PreviewSwitchLists"));
   } else {
     switchListsButton.setText(Bundle.getMessage("PrintSwitchLists"));
   }
 }
Exemple #25
0
  public void actionPerformed(ActionEvent e) {
    if (bean == null) {
      log.error("No bean set so unable to edit a null bean"); // IN18N
      return;
    }
    if (f == null) {
      f = new JmriJFrame("Edit " + getBeanType() + " " + bean.getDisplayName(), false, false);
      f.addHelpMenu(helpTarget(), true);
      java.awt.Container containerPanel = f.getContentPane();
      initPanelsFirst();
      initPanels();
      initPanelsLast();

      for (BeanItemPanel bi : bei) {
        addToPanel(bi, bi.getListOfItems());
        detailsTab.addTab(bi.getName(), bi);
      }

      containerPanel.add(detailsTab, BorderLayout.CENTER);
      JPanel buttons = new JPanel();
      JButton applyBut = new JButton(Bundle.getMessage("ButtonApply"));
      applyBut.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              applyButtonAction(e);
            }
          });
      JButton okBut = new JButton(Bundle.getMessage("ButtonOK"));
      okBut.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              applyButtonAction(e);
              f.dispose();
            }
          });
      JButton cancelBut = new JButton(Bundle.getMessage("ButtonCancel"));
      cancelBut.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              cancelButtonAction(e);
            }
          });
      buttons.add(applyBut);
      buttons.add(okBut);
      buttons.add(cancelBut);
      containerPanel.add(buttons, BorderLayout.SOUTH);
    }
    for (BeanItemPanel bi : bei) {
      bi.resetField();
    }
    if (selectedTab != null) {
      detailsTab.setSelectedComponent(selectedTab);
    }
    f.pack();
    f.setVisible(true);
  }
Exemple #26
0
 /** @return true if name entered OK and isn't too long */
 protected boolean checkName() {
   if (loctionNameTextField.getText().trim().equals("")) {
     JOptionPane.showMessageDialog(
         this,
         Bundle.getMessage("MustEnterName"),
         MessageFormat.format(
             Bundle.getMessage("CanNotLocation"), new Object[] {Bundle.getMessage("Copy")}),
         JOptionPane.ERROR_MESSAGE);
     return false;
   }
   if (TrainCommon.splitString(loctionNameTextField.getText()).length()
       > Control.max_len_string_location_name) {
     JOptionPane.showMessageDialog(
         this,
         MessageFormat.format(
             Bundle.getMessage("LocationNameLengthMax"),
             new Object[] {Integer.toString(Control.max_len_string_location_name + 1)}),
         MessageFormat.format(
             Bundle.getMessage("CanNotLocation"), new Object[] {Bundle.getMessage("Copy")}),
         JOptionPane.ERROR_MESSAGE);
     return false;
   }
   Location check = locationManager.getLocationByName(loctionNameTextField.getText());
   if (check != null) {
     JOptionPane.showMessageDialog(
         this,
         Bundle.getMessage("LocationAlreadyExists"),
         MessageFormat.format(
             Bundle.getMessage("CanNotLocation"), new Object[] {Bundle.getMessage("Copy")}),
         JOptionPane.ERROR_MESSAGE);
     return false;
   }
   return true;
 }
Exemple #27
0
  /** Generic method to change the user name of a Bean */
  public void renameBean(String _newName) {
    NamedBean nBean = bean;
    String oldName = nBean.getUserName();

    String value = _newName;

    if (value.equals(oldName)) {
      // name not changed.
      return;
    } else {
      NamedBean nB = getByUserName(value);
      if (nB != null) {
        log.error("User name is not unique " + value); // NOI18N
        String msg;
        msg =
            java.text.MessageFormat.format(
                Bundle.getMessage("WarningUserName"), new Object[] {("" + value)});
        JOptionPane.showMessageDialog(
            null, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
        return;
      }
    }

    nBean.setUserName(value);
    if (!value.equals("")) {
      if (oldName == null || oldName.equals("")) {
        if (!nbMan.inUse(nBean.getSystemName(), nBean)) {
          return;
        }
        String msg =
            java.text.MessageFormat.format(
                Bundle.getMessage("UpdateToUserName"),
                new Object[] {getBeanType(), value, nBean.getSystemName()});
        int optionPane =
            JOptionPane.showConfirmDialog(
                null, msg, Bundle.getMessage("UpdateToUserNameTitle"), JOptionPane.YES_NO_OPTION);
        if (optionPane == JOptionPane.YES_OPTION) {
          // This will update the bean reference from the systemName to the userName
          try {
            nbMan.updateBeanFromSystemToUser(nBean);
          } catch (jmri.JmriException ex) {
            // We should never get an exception here as we already check that the username is not
            // valid
          }
        }

      } else {
        nbMan.renameBean(oldName, value, nBean);
      }

    } else {
      // This will update the bean reference from the old userName to the SystemName
      nbMan.updateBeanFromUserToSystem(nBean);
    }
  }
Exemple #28
0
 @Override
 public String getColumnName(int col) {
   switch (col) {
     case ID_COLUMN:
       return Bundle.getMessage("Id");
     case NAME_COLUMN:
       return Bundle.getMessage("Name");
     case SCHEDULE_STATUS_COLUMN:
       return Bundle.getMessage("Status");
     case SPUR_NUMBER_COLUMN:
       return Bundle.getMessage("Number");
     case SPUR_COLUMN:
       return Bundle.getMessage("Spurs");
     case STATUS_COLUMN:
       return Bundle.getMessage("StatusSpur");
     case MODE_COLUMN:
       return Bundle.getMessage("ScheduleMode");
     case EDIT_COLUMN:
       return Bundle.getMessage("Edit");
     case DELETE_COLUMN:
       return Bundle.getMessage("Delete");
     default:
       return "unknown"; // NOI18N
   }
 }
Exemple #29
0
  /**
   * Create the panel used to select an existing entry
   *
   * @return a JPanel for handling the entry-selection GUI
   */
  protected JPanel layoutRosterSelection() {
    JPanel pane2a = new JPanel();
    pane2a.setLayout(new BoxLayout(pane2a, BoxLayout.X_AXIS));
    pane2a.add(new JLabel(Bundle.getMessage("USE LOCOMOTIVE SETTINGS FOR: ")));
    locoBox.setNonSelectedItem(Bundle.getMessage("<NONE - NEW LOCO>"));
    Roster.getDefault().addPropertyChangeListener(this);
    pane2a.add(locoBox);
    locoBox.addPropertyChangeListener(
        RosterEntrySelector.SELECTED_ROSTER_ENTRIES,
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent pce) {
            if (locoBox.getSelectedRosterEntries().length != 0) {
              // reset and disable decoder selection
              setDecoderSelectionFromLoco(locoBox.getSelectedRosterEntries()[0].titleString());
              go2.setEnabled(true);
              go2.setRequestFocusEnabled(true);
              go2.requestFocus();
              go2.setToolTipText(Bundle.getMessage("CLICK TO OPEN THE PROGRAMMER"));
            } else {
              go2.setEnabled(false);
              go2.setToolTipText(Bundle.getMessage("SELECT A LOCOMOTIVE OR DECODER TO ENABLE"));
            }
          }
        });
    idloco = new JToggleButton(Bundle.getMessage("IDENT"));
    idloco.setToolTipText(
        Bundle.getMessage(
            "READ THE LOCOMOTIVE'S ADDRESS AND ATTEMPT TO SELECT THE RIGHT SETTINGS"));
    if (jmri.InstanceManager.getNullableDefault(jmri.ProgrammerManager.class) != null
        && jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer()
            != null
        && !jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class)
            .getGlobalProgrammer()
            .getCanRead()) {
      // can't read, disable the button
      idloco.setEnabled(false);
      idloco.setToolTipText(
          Bundle.getMessage("BUTTON DISABLED BECAUSE CONFIGURED COMMAND STATION CAN'T READ CVS"));
    }
    idloco.addActionListener(
        new ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            if (log.isDebugEnabled()) {
              log.debug("Identify locomotive pressed");
            }
            startIdentifyLoco();
          }
        });
    pane2a.add(idloco);
    pane2a.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
    return pane2a;
  }
Exemple #30
0
 private String getSpurMode(int row) {
   LocationTrackPair ltp = getLocationTrackPair(row);
   if (ltp == null) {
     return "";
   }
   String mode = Bundle.getMessage("Sequential");
   if (ltp.getTrack().getScheduleMode() == Track.MATCH) {
     mode = Bundle.getMessage("Match");
   }
   return mode;
 }