Beispiel #1
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"));
  }
  public void initComponents() {
    // set tips
    builtTextField.setToolTipText(Bundle.getMessage("buildDateTip"));
    rfidComboBox.setToolTipText(Bundle.getMessage("TipRfid"));
    editRoadButton.setToolTipText(
        MessageFormat.format(
            Bundle.getMessage("TipAddDeleteReplace"),
            new Object[] {Bundle.getMessage("Road").toLowerCase()}));
    editTypeButton.setToolTipText(
        MessageFormat.format(
            Bundle.getMessage("TipAddDeleteReplace"),
            new Object[] {Bundle.getMessage("Type").toLowerCase()}));
    editModelButton.setToolTipText(
        MessageFormat.format(
            Bundle.getMessage("TipAddDeleteReplace"),
            new Object[] {Bundle.getMessage("Model").toLowerCase()}));
    editLengthButton.setToolTipText(
        MessageFormat.format(
            Bundle.getMessage("TipAddDeleteReplace"),
            new Object[] {Bundle.getMessage("Length").toLowerCase()}));
    editOwnerButton.setToolTipText(
        MessageFormat.format(
            Bundle.getMessage("TipAddDeleteReplace"),
            new Object[] {Bundle.getMessage("Owner").toLowerCase()}));
    editConsistButton.setToolTipText(
        MessageFormat.format(
            Bundle.getMessage("TipAddDeleteReplace"),
            new Object[] {Bundle.getMessage("Consist").toLowerCase()}));
    bUnitCheckBox.setToolTipText(Bundle.getMessage("TipBoosterUnit"));

    // create panel
    JPanel pPanel = new JPanel();
    pPanel.setLayout(new BoxLayout(pPanel, BoxLayout.Y_AXIS));

    // Layout the panel by rows
    // row 1
    JPanel pRoad = new JPanel();
    pRoad.setLayout(new GridBagLayout());
    pRoad.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Road")));
    addItem(pRoad, roadComboBox, 1, 0);
    addItem(pRoad, editRoadButton, 2, 0);
    pPanel.add(pRoad);

    // row 2
    JPanel pRoadNumber = new JPanel();
    pRoadNumber.setLayout(new GridBagLayout());
    pRoadNumber.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("RoadNumber")));
    addItem(pRoadNumber, roadNumberTextField, 1, 0);
    addItem(pRoadNumber, clearRoadNumberButton, 2, 0);
    pPanel.add(pRoadNumber);

    // row 3
    JPanel pModel = new JPanel();
    pModel.setLayout(new GridBagLayout());
    pModel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Model")));
    addItem(pModel, modelComboBox, 1, 0);
    addItem(pModel, editModelButton, 2, 0);
    pPanel.add(pModel);

    // row 4
    JPanel pType = new JPanel();
    pType.setLayout(new GridBagLayout());
    pType.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Type")));
    addItem(pType, typeComboBox, 1, 0);
    addItem(pType, editTypeButton, 2, 0);
    addItem(pType, bUnitCheckBox, 1, 1);
    pPanel.add(pType);

    // row 5
    JPanel pLength = new JPanel();
    pLength.setLayout(new GridBagLayout());
    pLength.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Length")));
    addItem(pLength, lengthComboBox, 1, 0);
    addItem(pLength, editLengthButton, 2, 0);
    pPanel.add(pLength);

    // row 6
    JPanel pLocation = new JPanel();
    pLocation.setLayout(new GridBagLayout());
    pLocation.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LocationAndTrack")));
    addItem(pLocation, locationBox, 1, 0);
    addItem(pLocation, trackLocationBox, 2, 0);
    pPanel.add(pLocation);

    // optional panel
    JPanel pOptional = new JPanel();
    pOptional.setLayout(new BoxLayout(pOptional, BoxLayout.Y_AXIS));
    JScrollPane optionPane = new JScrollPane(pOptional);
    optionPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutOptional")));

    // row 11
    JPanel pWeightTons = new JPanel();
    pWeightTons.setLayout(new GridBagLayout());
    pWeightTons.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("WeightTons")));
    addItem(pWeightTons, weightTextField, 0, 0);
    pOptional.add(pWeightTons);

    // row 12
    JPanel pHp = new JPanel();
    pHp.setLayout(new GridBagLayout());
    pHp.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Hp")));
    addItem(pHp, hpTextField, 0, 0);
    pOptional.add(pHp);

    // row 13
    JPanel pConsist = new JPanel();
    pConsist.setLayout(new GridBagLayout());
    pConsist.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Consist")));
    addItem(pConsist, consistComboBox, 1, 0);
    addItem(pConsist, editConsistButton, 2, 0);
    pOptional.add(pConsist);

    // row 14
    JPanel pBuilt = new JPanel();
    pBuilt.setLayout(new GridBagLayout());
    pBuilt.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Built")));
    addItem(pBuilt, builtTextField, 1, 0);
    pOptional.add(pBuilt);

    // row 15
    JPanel pOwner = new JPanel();
    pOwner.setLayout(new GridBagLayout());
    pOwner.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Owner")));
    addItem(pOwner, ownerComboBox, 1, 0);
    addItem(pOwner, editOwnerButton, 2, 0);
    pOptional.add(pOwner);

    // row 18
    if (Setup.isValueEnabled()) {
      JPanel pValue = new JPanel();
      pValue.setLayout(new GridBagLayout());
      pValue.setBorder(BorderFactory.createTitledBorder(Setup.getValueLabel()));
      addItem(pValue, valueTextField, 1, 0);
      pOptional.add(pValue);
    }

    // row 20
    if (Setup.isRfidEnabled()) {
      JPanel pRfid = new JPanel();
      pRfid.setLayout(new GridBagLayout());
      pRfid.setBorder(BorderFactory.createTitledBorder(Setup.getRfidLabel()));
      addItem(pRfid, rfidComboBox, 1, 0);
      jmri.InstanceManager.getDefault(jmri.IdTagManager.class)
          .getNamedBeanList()
          .forEach((tag) -> rfidComboBox.addItem((jmri.IdTag) tag));
      pOptional.add(pRfid);
    }

    // row 22
    JPanel pComment = new JPanel();
    pComment.setLayout(new GridBagLayout());
    pComment.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Comment")));
    addItem(pComment, commentTextField, 1, 0);
    pOptional.add(pComment);

    // button panel
    JPanel pButtons = new JPanel();
    pButtons.setLayout(new GridBagLayout());
    addItem(pButtons, deleteButton, 0, 25);
    addItem(pButtons, addButton, 1, 25);
    addItem(pButtons, saveButton, 3, 25);

    // add panels
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    getContentPane().add(pPanel);
    getContentPane().add(optionPane);
    getContentPane().add(pButtons);

    // setup buttons
    addEditButtonAction(editRoadButton);
    addButtonAction(clearRoadNumberButton);
    addEditButtonAction(editModelButton);
    addEditButtonAction(editTypeButton);
    addEditButtonAction(editLengthButton);
    addEditButtonAction(editConsistButton);
    addEditButtonAction(editOwnerButton);

    addButtonAction(deleteButton);
    addButtonAction(addButton);
    addButtonAction(saveButton);
    addButtonAction(fillWeightButton);

    // setup combobox
    addComboBoxAction(modelComboBox);
    addComboBoxAction(locationBox);

    // setup checkbox
    // build menu
    // JMenuBar menuBar = new JMenuBar();
    // JMenu toolMenu = new JMenu(Bundle.getMessage("Tools"));
    // menuBar.add(toolMenu);
    // setJMenuBar(menuBar);
    addHelpMenu("package.jmri.jmrit.operations.Operations_LocomotivesAdd", true); // NOI18N

    // get notified if combo box gets modified
    CarRoads.instance().addPropertyChangeListener(this);
    engineModels.addPropertyChangeListener(this);
    engineTypes.addPropertyChangeListener(this);
    engineLengths.addPropertyChangeListener(this);
    CarOwners.instance().addPropertyChangeListener(this);
    locationManager.addPropertyChangeListener(this);
    manager.addPropertyChangeListener(this);

    pack();
    setMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight500));
    setVisible(true);
  }