Search in sources :

Example 1 with ValueWithUnitEditBox

use of net.parostroj.timetable.gui.components.ValueWithUnitEditBox in project grafikon by jub77.

the class EditTrainDialog method initComponents.

private void initComponents() {
    javax.swing.JLabel typeLabel = new javax.swing.JLabel();
    typeComboBox = new javax.swing.JComboBox<>();
    numberTextField = new javax.swing.JTextField();
    javax.swing.JLabel numberLabel = new javax.swing.JLabel();
    descriptionTextField = new javax.swing.JTextField();
    javax.swing.JLabel descLabel = new javax.swing.JLabel();
    speedTextField = new javax.swing.JTextField();
    javax.swing.JLabel speedLabel = new javax.swing.JLabel();
    weightTextField = new javax.swing.JTextField();
    routeEditBox = new net.parostroj.timetable.gui.components.TextTemplateEditBox();
    javax.swing.JLabel weightLabel = new javax.swing.JLabel();
    javax.swing.JLabel routeLabel = new javax.swing.JLabel();
    javax.swing.JButton okButton = new javax.swing.JButton();
    javax.swing.JButton cancelButton = new javax.swing.JButton();
    // NOI18N
    setTitle(ResourceLoader.getString("edit.train"));
    // NOI18N
    typeLabel.setText(ResourceLoader.getString("create.train.type"));
    numberTextField.setColumns(20);
    // NOI18N
    numberLabel.setText(ResourceLoader.getString("create.train.number"));
    descriptionTextField.setColumns(30);
    // NOI18N
    descLabel.setText(ResourceLoader.getString("create.train.description"));
    speedTextField.setColumns(10);
    // NOI18N
    speedLabel.setText(ResourceLoader.getString("create.train.speed"));
    // NOI18N
    weightLabel.setText(ResourceLoader.getString("edit.train.weight"));
    // NOI18N
    routeLabel.setText(ResourceLoader.getString("edit.train.route"));
    // NOI18N
    okButton.setText(ResourceLoader.getString("button.ok"));
    okButton.addActionListener(this::okButtonActionPerformed);
    // NOI18N
    cancelButton.setText(ResourceLoader.getString("button.cancel"));
    cancelButton.addActionListener(this::cancelButtonActionPerformed);
    groupsComboBox = new GroupsComboBox(false);
    JLabel groupLabel = new JLabel(ResourceLoader.getString("create.train.group"));
    JPanel optionsPanel = new JPanel();
    JPanel routeEditPanel = new JPanel();
    JPanel techTimesPanel = new JPanel();
    techTimesPanel.setBorder(BorderFactory.createEmptyBorder());
    JPanel connectedTrainsPanel = new JPanel();
    connectedTrainsPanel.setBorder(BorderFactory.createEmptyBorder());
    FlowLayout flTechTimesPanel = (FlowLayout) techTimesPanel.getLayout();
    flTechTimesPanel.setHgap(0);
    flTechTimesPanel.setAlignOnBaseline(true);
    flTechTimesPanel.setAlignment(FlowLayout.LEFT);
    flTechTimesPanel.setVgap(0);
    JPanel weightLimitPanel = new JPanel();
    JLabel weightLimitLabel = new JLabel(ResourceLoader.getString("edit.train.weight.limit") + ":");
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(Alignment.TRAILING).addComponent(techTimesPanel, GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE).addComponent(connectedTrainsPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(okButton).addPreferredGap(ComponentPlacement.RELATED).addComponent(cancelButton)).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(routeLabel).addComponent(weightLabel).addComponent(weightLimitLabel).addComponent(speedLabel).addComponent(descLabel).addComponent(numberLabel).addComponent(groupLabel).addComponent(typeLabel)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(routeEditPanel, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(optionsPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(descriptionTextField, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(weightTextField, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(numberTextField, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(typeComboBox, 0, 301, Short.MAX_VALUE).addComponent(routeEditBox, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(groupsComboBox, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(weightLimitPanel, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE).addComponent(speedTextField, GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)))).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(typeLabel).addComponent(typeComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.RELATED).addComponent(optionsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(groupsComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(groupLabel)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(numberLabel).addComponent(numberTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(descriptionTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(descLabel)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(speedTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(speedLabel)).addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED).addComponent(weightLimitPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGroup(layout.createSequentialGroup().addGap(10).addComponent(weightLimitLabel))).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(weightTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(weightLabel)).addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED).addComponent(routeEditBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(routeEditPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGroup(layout.createSequentialGroup().addGap(10).addComponent(routeLabel))).addPreferredGap(ComponentPlacement.RELATED).addComponent(techTimesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(connectedTrainsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(cancelButton).addComponent(okButton)).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    GridBagLayout gblConnectedTrainsPanel = new GridBagLayout();
    connectedTrainsPanel.setLayout(gblConnectedTrainsPanel);
    JLabel joinedTrainsLabel = new JLabel(ResourceLoader.getString("edit.train.joined"));
    GridBagConstraints gbcJoinedTrainsLabel = new GridBagConstraints();
    gbcJoinedTrainsLabel.fill = GridBagConstraints.HORIZONTAL;
    gbcJoinedTrainsLabel.anchor = GridBagConstraints.WEST;
    gbcJoinedTrainsLabel.gridwidth = 2;
    gbcJoinedTrainsLabel.insets = new Insets(0, 0, 5, 5);
    gbcJoinedTrainsLabel.gridx = 0;
    gbcJoinedTrainsLabel.gridy = 0;
    connectedTrainsPanel.add(joinedTrainsLabel, gbcJoinedTrainsLabel);
    JLabel previousTrainLabel = new JLabel(ResourceLoader.getString("edit.train.joined.previous") + ": ");
    GridBagConstraints gbcPreviousTrainLabel = new GridBagConstraints();
    gbcPreviousTrainLabel.anchor = GridBagConstraints.WEST;
    gbcPreviousTrainLabel.insets = new Insets(0, 10, 5, 5);
    gbcPreviousTrainLabel.gridx = 0;
    gbcPreviousTrainLabel.gridy = 1;
    connectedTrainsPanel.add(previousTrainLabel, gbcPreviousTrainLabel);
    JComboBox<Wrapper<Train>> previousTrainComboBox = new JComboBox<>();
    previousTrainModel = new WrapperListModel<>(true);
    previousTrainComboBox.setModel(previousTrainModel);
    GridBagConstraints gbcPreviousTrainComboBox = new GridBagConstraints();
    gbcPreviousTrainComboBox.insets = new Insets(0, 0, 5, 0);
    gbcPreviousTrainComboBox.weightx = 1.0;
    gbcPreviousTrainComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbcPreviousTrainComboBox.anchor = GridBagConstraints.NORTHWEST;
    gbcPreviousTrainComboBox.gridx = 1;
    gbcPreviousTrainComboBox.gridy = 1;
    connectedTrainsPanel.add(previousTrainComboBox, gbcPreviousTrainComboBox);
    JLabel nextTrainLabel = new JLabel(ResourceLoader.getString("edit.train.joined.next") + ": ");
    GridBagConstraints gbcNextTrainLabel = new GridBagConstraints();
    gbcNextTrainLabel.anchor = GridBagConstraints.WEST;
    gbcNextTrainLabel.insets = new Insets(0, 10, 0, 5);
    gbcNextTrainLabel.gridx = 0;
    gbcNextTrainLabel.gridy = 2;
    connectedTrainsPanel.add(nextTrainLabel, gbcNextTrainLabel);
    JComboBox<Wrapper<Train>> nextTrainComboBox = new JComboBox<>();
    nextTrainModel = new WrapperListModel<>(true);
    nextTrainComboBox.setModel(nextTrainModel);
    GridBagConstraints gbcNextTrainComboBox = new GridBagConstraints();
    gbcNextTrainComboBox.weightx = 1.0;
    gbcNextTrainComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbcNextTrainComboBox.anchor = GridBagConstraints.NORTHWEST;
    gbcNextTrainComboBox.gridx = 1;
    gbcNextTrainComboBox.gridy = 2;
    connectedTrainsPanel.add(nextTrainComboBox, gbcNextTrainComboBox);
    layout.linkSize(SwingConstants.HORIZONTAL, typeLabel, numberLabel, descLabel, speedLabel, weightLabel, routeLabel, groupLabel, weightLimitLabel);
    GridBagLayout gblWeightLimitPanel = new GridBagLayout();
    gblWeightLimitPanel.columnWeights = new double[] { 0.0, 0.0 };
    gblWeightLimitPanel.rowWeights = new double[] { 0.0 };
    weightLimitPanel.setLayout(gblWeightLimitPanel);
    weightLimitCheckBox = new JCheckBox();
    weightLimitCheckBox.addItemListener(e -> weightLimitEditBox.setEnabled(e.getStateChange() == ItemEvent.SELECTED));
    GridBagConstraints gbcWeightLimitCheckBox = new GridBagConstraints();
    gbcWeightLimitCheckBox.anchor = GridBagConstraints.WEST;
    gbcWeightLimitCheckBox.gridx = 1;
    gbcWeightLimitCheckBox.gridy = 0;
    weightLimitPanel.add(weightLimitCheckBox, gbcWeightLimitCheckBox);
    weightLimitEditBox = new ValueWithUnitEditBox();
    weightLimitEditBox.setUnits(Arrays.asList(WeightUnit.values()));
    weightLimitEditBox.setUnit(WeightUnit.T);
    GridBagConstraints gbcWeightLimitEditBox = new GridBagConstraints();
    gbcWeightLimitEditBox.weightx = 1.0;
    gbcWeightLimitEditBox.fill = GridBagConstraints.HORIZONTAL;
    gbcWeightLimitEditBox.anchor = GridBagConstraints.NORTHWEST;
    gbcWeightLimitEditBox.gridx = 0;
    gbcWeightLimitEditBox.gridy = 0;
    weightLimitPanel.add(weightLimitEditBox, gbcWeightLimitEditBox);
    javax.swing.JLabel techTimesLabel = new javax.swing.JLabel();
    techTimesPanel.add(techTimesLabel);
    techTimesLabel.setText(ResourceLoader.getString("create.train.technological.time"));
    Component delimiterStrut1 = Box.createHorizontalStrut(5);
    techTimesPanel.add(delimiterStrut1);
    javax.swing.JLabel beforeLabel = new javax.swing.JLabel();
    techTimesPanel.add(beforeLabel);
    beforeLabel.setText(ResourceLoader.getString("create.train.time.before"));
    Component delimiterStrut2 = Box.createHorizontalStrut(5);
    techTimesPanel.add(delimiterStrut2);
    timeBeforeTextField = new javax.swing.JTextField();
    techTimesPanel.add(timeBeforeTextField);
    timeBeforeTextField.setColumns(6);
    Component delimiterStrut3 = Box.createHorizontalStrut(5);
    techTimesPanel.add(delimiterStrut3);
    javax.swing.JLabel afterLabel = new javax.swing.JLabel();
    techTimesPanel.add(afterLabel);
    afterLabel.setText(ResourceLoader.getString("create.train.time.after"));
    Component delimiterStrut4 = Box.createHorizontalStrut(5);
    techTimesPanel.add(delimiterStrut4);
    timeAfterTextField = new javax.swing.JTextField();
    techTimesPanel.add(timeAfterTextField);
    timeAfterTextField.setColumns(6);
    GridBagLayout gblRouteEditPanel = new GridBagLayout();
    routeEditPanel.setLayout(gblRouteEditPanel);
    javax.swing.JLabel routeInsertLabel = new javax.swing.JLabel();
    GridBagConstraints gbcRouteInsertLabel = new GridBagConstraints();
    gbcRouteInsertLabel.anchor = GridBagConstraints.WEST;
    gbcRouteInsertLabel.insets = new Insets(0, 0, 0, 5);
    gbcRouteInsertLabel.gridx = 0;
    gbcRouteInsertLabel.gridy = 0;
    routeEditPanel.add(routeInsertLabel, gbcRouteInsertLabel);
    routeInsertLabel.setText(ResourceLoader.getString("edit.train.insert.node"));
    fromNodeButton = new javax.swing.JButton();
    GridBagConstraints gbcFromNodeButton = new GridBagConstraints();
    gbcFromNodeButton.weightx = 1.0;
    gbcFromNodeButton.fill = GridBagConstraints.HORIZONTAL;
    gbcFromNodeButton.anchor = GridBagConstraints.WEST;
    gbcFromNodeButton.insets = new Insets(0, 0, 0, 5);
    gbcFromNodeButton.gridx = 1;
    gbcFromNodeButton.gridy = 0;
    routeEditPanel.add(fromNodeButton, gbcFromNodeButton);
    fromNodeButton.addActionListener(this::fromNodeButtonActionPerformed);
    toNodeButton = new javax.swing.JButton();
    GridBagConstraints gbcToNodeButton = new GridBagConstraints();
    gbcToNodeButton.weightx = 1.0;
    gbcToNodeButton.fill = GridBagConstraints.HORIZONTAL;
    gbcToNodeButton.anchor = GridBagConstraints.WEST;
    gbcToNodeButton.insets = new Insets(0, 0, 0, 5);
    gbcToNodeButton.gridx = 2;
    gbcToNodeButton.gridy = 0;
    routeEditPanel.add(toNodeButton, gbcToNodeButton);
    toNodeButton.addActionListener(this::toNodeButtonActionPerformed);
    stationsComboBox = new javax.swing.JComboBox<>();
    GridBagConstraints gbcStationsComboBox = new GridBagConstraints();
    gbcStationsComboBox.weightx = 1.0;
    gbcStationsComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbcStationsComboBox.anchor = GridBagConstraints.NORTHWEST;
    gbcStationsComboBox.insets = new Insets(0, 0, 0, 5);
    gbcStationsComboBox.gridx = 3;
    gbcStationsComboBox.gridy = 0;
    routeEditPanel.add(stationsComboBox, gbcStationsComboBox);
    javax.swing.JButton insertButton = new javax.swing.JButton();
    GridBagConstraints gbcInsertButton = new GridBagConstraints();
    gbcInsertButton.anchor = GridBagConstraints.EAST;
    gbcInsertButton.gridx = 4;
    gbcInsertButton.gridy = 0;
    routeEditPanel.add(insertButton, gbcInsertButton);
    insertButton.setText("^");
    insertButton.addActionListener(this::insertButtonActionPerformed);
    GridBagLayout gblOptionsPanel = new GridBagLayout();
    gblOptionsPanel.columnWeights = new double[] { 0.0, 0.0 };
    gblOptionsPanel.rowWeights = new double[] { 0.0, 0.0, 0.0 };
    optionsPanel.setLayout(gblOptionsPanel);
    dieselCheckBox = new javax.swing.JCheckBox();
    GridBagConstraints gbcDieselCheckBox = new GridBagConstraints();
    gbcDieselCheckBox.anchor = GridBagConstraints.WEST;
    gbcDieselCheckBox.insets = new Insets(0, 0, 5, 5);
    gbcDieselCheckBox.gridx = 0;
    gbcDieselCheckBox.gridy = 0;
    optionsPanel.add(dieselCheckBox, gbcDieselCheckBox);
    // NOI18N
    dieselCheckBox.setText(ResourceLoader.getString("create.train.diesel"));
    dieselCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    dieselCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    emptyCheckBox = new javax.swing.JCheckBox();
    GridBagConstraints gbcEmptyCheckBox = new GridBagConstraints();
    gbcEmptyCheckBox.weightx = 1.0;
    gbcEmptyCheckBox.anchor = GridBagConstraints.WEST;
    gbcEmptyCheckBox.fill = GridBagConstraints.HORIZONTAL;
    gbcEmptyCheckBox.insets = new Insets(0, 0, 5, 0);
    gbcEmptyCheckBox.gridx = 1;
    gbcEmptyCheckBox.gridy = 0;
    optionsPanel.add(emptyCheckBox, gbcEmptyCheckBox);
    // NOI18N
    emptyCheckBox.setText(ResourceLoader.getString("create.train.empty"));
    emptyCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    emptyCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    electricCheckBox = new javax.swing.JCheckBox();
    GridBagConstraints gbcElectricCheckBox = new GridBagConstraints();
    gbcElectricCheckBox.anchor = GridBagConstraints.WEST;
    gbcElectricCheckBox.insets = new Insets(0, 0, 5, 5);
    gbcElectricCheckBox.gridx = 0;
    gbcElectricCheckBox.gridy = 1;
    optionsPanel.add(electricCheckBox, gbcElectricCheckBox);
    // NOI18N
    electricCheckBox.setText(ResourceLoader.getString("create.train.electric"));
    electricCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    electricCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    showLengthCheckBox = new javax.swing.JCheckBox();
    GridBagConstraints gbcShowLengthCheckBox = new GridBagConstraints();
    gbcShowLengthCheckBox.insets = new Insets(0, 0, 5, 0);
    gbcShowLengthCheckBox.weightx = 1.0;
    gbcShowLengthCheckBox.anchor = GridBagConstraints.WEST;
    gbcShowLengthCheckBox.fill = GridBagConstraints.HORIZONTAL;
    gbcShowLengthCheckBox.gridx = 1;
    gbcShowLengthCheckBox.gridy = 1;
    optionsPanel.add(showLengthCheckBox, gbcShowLengthCheckBox);
    // NOI18N
    showLengthCheckBox.setText(ResourceLoader.getString("create.train.show.station.length"));
    showLengthCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    showLengthCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    // NOI18N
    managedFreightCheckBox = new javax.swing.JCheckBox(ResourceLoader.getString("edit.train.managed.freight"));
    managedFreightCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    managedFreightCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    GridBagConstraints gbcManagedFreightCheckBox = new GridBagConstraints();
    gbcManagedFreightCheckBox.weightx = 1.0;
    gbcManagedFreightCheckBox.anchor = GridBagConstraints.NORTHWEST;
    gbcManagedFreightCheckBox.fill = GridBagConstraints.HORIZONTAL;
    gbcManagedFreightCheckBox.insets = new Insets(0, 0, 5, 5);
    gbcManagedFreightCheckBox.gridx = 0;
    gbcManagedFreightCheckBox.gridy = 2;
    optionsPanel.add(managedFreightCheckBox, gbcManagedFreightCheckBox);
    // NOI18N
    optionalCheckBox = new javax.swing.JCheckBox(ResourceLoader.getString("edit.train.optional.train"));
    GridBagConstraints gbcCheckBox = new GridBagConstraints();
    optionalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    optionalCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    gbcCheckBox.weightx = 1.0;
    gbcCheckBox.anchor = GridBagConstraints.WEST;
    gbcCheckBox.fill = GridBagConstraints.HORIZONTAL;
    gbcCheckBox.gridx = 1;
    gbcCheckBox.gridy = 2;
    optionsPanel.add(optionalCheckBox, gbcCheckBox);
    getContentPane().setLayout(layout);
    pack();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ValueWithUnitEditBox(net.parostroj.timetable.gui.components.ValueWithUnitEditBox) GroupsComboBox(net.parostroj.timetable.gui.components.GroupsComboBox) GroupLayout(javax.swing.GroupLayout) Component(java.awt.Component) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) JCheckBox(javax.swing.JCheckBox)

Example 2 with ValueWithUnitEditBox

use of net.parostroj.timetable.gui.components.ValueWithUnitEditBox in project grafikon by jub77.

the class EditNodeDialog method initComponents.

private void initComponents() {
    javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
    nameTextField = new javax.swing.JTextField();
    nameTextField.setColumns(40);
    javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
    abbrTextField = new javax.swing.JTextField();
    javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
    typeComboBox = new javax.swing.JComboBox<>();
    javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
    trackList = new javax.swing.JList<>();
    newTrackButton = GuiComponentUtils.createButton(GuiIcon.ADD, 1);
    renameTrackButton = GuiComponentUtils.createButton(GuiIcon.EDIT, 1);
    deleteTrackButton = GuiComponentUtils.createButton(GuiIcon.REMOVE, 1);
    javax.swing.JButton okButton = new javax.swing.JButton();
    javax.swing.JButton cancelButton = new javax.swing.JButton();
    platformCheckBox = new javax.swing.JCheckBox();
    lineEndCheckBox = new javax.swing.JCheckBox();
    straightCheckBox = new javax.swing.JCheckBox();
    javax.swing.JLabel jLabel4 = new javax.swing.JLabel();
    javax.swing.JLabel jLabel5 = new javax.swing.JLabel();
    javax.swing.JLabel jLabel6 = new javax.swing.JLabel();
    javax.swing.JLabel companyLabel = new javax.swing.JLabel();
    regionsTextField = new javax.swing.JTextField();
    regionsTextField.setEditable(false);
    centerRegionsTextField = new javax.swing.JTextField();
    centerRegionsTextField.setEditable(false);
    companyComboBox = new javax.swing.JComboBox<>();
    setResizable(false);
    // NOI18N
    jLabel1.setText(ResourceLoader.getString("ne.name"));
    // NOI18N
    jLabel2.setText(ResourceLoader.getString("ne.abbr"));
    // NOI18N
    jLabel3.setText(ResourceLoader.getString("ne.type"));
    // NOI18N
    jLabel5.setText(ResourceLoader.getString("ne.regions") + ":");
    // NOI18N
    jLabel6.setText(ResourceLoader.getString("ne.center.regions") + ":");
    // NOI18N
    companyLabel.setText(ResourceLoader.getString("ne.company") + ":");
    typeComboBox.addItemListener(evt -> typeComboBoxItemStateChanged(evt));
    trackList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    trackList.addListSelectionListener(evt -> trackListValueChanged(evt));
    scrollPane.setViewportView(trackList);
    newTrackButton.addActionListener(evt -> newTrackButtonActionPerformed(evt));
    renameTrackButton.addActionListener(evt -> renameTrackButtonActionPerformed(evt));
    deleteTrackButton.addActionListener(evt -> deleteTrackButtonActionPerformed(evt));
    // NOI18N
    okButton.setText(ResourceLoader.getString("button.ok"));
    okButton.addActionListener(evt -> {
        writeValuesBack();
        setVisible(false);
    });
    // NOI18N
    cancelButton.setText(ResourceLoader.getString("button.cancel"));
    cancelButton.addActionListener(evt -> setVisible(false));
    // NOI18N
    platformCheckBox.setText(ResourceLoader.getString("ne.platform"));
    platformCheckBox.setEnabled(false);
    platformCheckBox.addItemListener(evt -> platformCheckBoxItemStateChanged(evt));
    // NOI18N
    lineEndCheckBox.setText(ResourceLoader.getString("ne.line.end"));
    lineEndCheckBox.setEnabled(false);
    lineEndCheckBox.addItemListener(evt -> lineEndCheckBoxItemStateChanged(evt));
    // NOI18N
    jLabel4.setText(ResourceLoader.getString("ne.length"));
    javax.swing.JPanel panel = new javax.swing.JPanel();
    colorsButton = new javax.swing.JButton(ResourceLoader.getString("ne.colors"));
    colorsButton.addActionListener(e -> {
        FreightColorsDialog dialog = new FreightColorsDialog(EditNodeDialog.this);
        dialog.setLocationRelativeTo(EditNodeDialog.this);
        List<FreightColor> result = dialog.showDialog(colors);
        if (result != null) {
            colors = new HashSet<>(result);
        }
        dialog.dispose();
    });
    lengthPanel = new javax.swing.JPanel();
    // NOI18N
    straightCheckBox.setText(ResourceLoader.getString("ne.straight"));
    straightCheckBox.setEnabled(false);
    straightCheckBox.addItemListener(evt -> straightCheckBoxItemStateChanged(evt));
    javax.swing.JLabel label = new javax.swing.JLabel();
    // NOI18N
    label.setText(ResourceLoader.getString("ne.not.straight.speed"));
    javax.swing.JPanel nsSpeedPanel = new javax.swing.JPanel();
    javax.swing.JLabel label_1 = new javax.swing.JLabel();
    // NOI18N
    label_1.setText(ResourceLoader.getString("ne.straight.speed"));
    javax.swing.JPanel sSpeedPanel = new javax.swing.JPanel();
    sSpeedPanel.setLayout(new BorderLayout(0, 0));
    // NOI18N
    javax.swing.JButton editRegionsButton = new javax.swing.JButton("...");
    editRegionsButton.addActionListener(e -> {
        boolean isEmpty = this.regions.isEmpty();
        Region superRegion = isEmpty ? null : this.regions.iterator().next().getSuperRegion();
        Set<Region> available = node.getDiagram().getNet().getRegions().stream().filter(r -> !r.hasSubRegions() && (isEmpty || r.getSuperRegion() == superRegion)).collect(Collectors.toSet());
        this.regions = editRegions(regionsTextField, available, this.regions, this.centerRegions);
    });
    // NOI18N
    javax.swing.JButton editCenterRegionsButton = new javax.swing.JButton("...");
    editCenterRegionsButton.addActionListener(e -> this.centerRegions = editRegions(centerRegionsTextField, regions, centerRegions, null));
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(platformCheckBox).addPreferredGap(ComponentPlacement.RELATED).addComponent(lineEndCheckBox).addPreferredGap(ComponentPlacement.RELATED).addComponent(straightCheckBox)).addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(newTrackButton).addPreferredGap(ComponentPlacement.RELATED).addComponent(renameTrackButton).addPreferredGap(ComponentPlacement.RELATED).addComponent(deleteTrackButton).addGap(18).addComponent(colorsButton).addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(okButton).addPreferredGap(ComponentPlacement.RELATED).addComponent(cancelButton)).addGroup(layout.createSequentialGroup().addComponent(jLabel5, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(regionsTextField, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.RELATED).addComponent(editRegionsButton)).addGroup(layout.createSequentialGroup().addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(centerRegionsTextField, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.RELATED).addComponent(editCenterRegionsButton)).addGroup(layout.createSequentialGroup().addComponent(companyLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(companyComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(nameTextField)).addGroup(layout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(ComponentPlacement.RELATED).addComponent(abbrTextField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(jLabel4, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(lengthPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(typeComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(label, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(nsSpeedPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(label_1).addPreferredGap(ComponentPlacement.RELATED).addComponent(sSpeedPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(nameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(jLabel1)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(jLabel2).addComponent(abbrTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.CENTER).addComponent(label_1).addComponent(sSpeedPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(7).addGroup(layout.createParallelGroup(Alignment.CENTER).addComponent(label).addComponent(nsSpeedPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(6).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(jLabel5).addComponent(regionsTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(editRegionsButton)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(jLabel6).addComponent(centerRegionsTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(editCenterRegionsButton)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(companyLabel).addComponent(companyComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(jLabel3).addComponent(typeComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGap(7).addGroup(layout.createParallelGroup(Alignment.TRAILING, false).addGroup(layout.createSequentialGroup().addComponent(lengthPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED)).addGroup(layout.createSequentialGroup().addComponent(jLabel4).addGap(10))).addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(platformCheckBox).addComponent(lineEndCheckBox).addComponent(straightCheckBox)).addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(newTrackButton).addComponent(renameTrackButton).addComponent(deleteTrackButton)).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(cancelButton).addComponent(okButton).addComponent(colorsButton))).addContainerGap()));
    layout.linkSize(SwingConstants.HORIZONTAL, new Component[] { jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, companyLabel, label, label_1 });
    sSpeedEditBox = new ValueWithUnitEditBox();
    sSpeedPanel.add(sSpeedEditBox, BorderLayout.CENTER);
    sSpeedCheckBox = new javax.swing.JCheckBox();
    sSpeedPanel.add(sSpeedCheckBox, BorderLayout.EAST);
    nsSpeedPanel.setLayout(new BorderLayout(0, 0));
    nsSpeedEditBox = new ValueWithUnitEditBox();
    nsSpeedPanel.add(nsSpeedEditBox, BorderLayout.CENTER);
    nsSpeedCheckBox = new javax.swing.JCheckBox();
    nsSpeedPanel.add(nsSpeedCheckBox, BorderLayout.EAST);
    lengthPanel.setLayout(new BorderLayout(0, 0));
    lengthEditBox = new ValueWithUnitEditBox();
    lengthPanel.add(lengthEditBox, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    signalsCheckBox = new javax.swing.JCheckBox();
    panel.add(signalsCheckBox);
    signalsCheckBox.setText(ResourceLoader.getString("ne.new.signals"));
    trapezoidCheckBox = new javax.swing.JCheckBox();
    panel.add(trapezoidCheckBox);
    trapezoidCheckBox.setText(ResourceLoader.getString("ne.trapezoid.table"));
    controlCheckBox = new javax.swing.JCheckBox();
    panel.add(controlCheckBox);
    controlCheckBox.setText(ResourceLoader.getString("ne.control.station"));
    getContentPane().setLayout(layout);
    pack();
}
Also used : java.util(java.util) net.parostroj.timetable.model.units(net.parostroj.timetable.model.units) OutputFreightUtil(net.parostroj.timetable.output2.util.OutputFreightUtil) LoggerFactory(org.slf4j.LoggerFactory) SwingConstants(javax.swing.SwingConstants) ObjectsUtil(net.parostroj.timetable.utils.ObjectsUtil) BigDecimal(java.math.BigDecimal) NodeTypeWrapperDelegate(net.parostroj.timetable.gui.wrappers.NodeTypeWrapperDelegate) BorderLayout(java.awt.BorderLayout) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) ResourceLoader(net.parostroj.timetable.utils.ResourceLoader) FlowLayout(java.awt.FlowLayout) ItemEvent(java.awt.event.ItemEvent) WrapperListModel(net.parostroj.timetable.gui.wrappers.WrapperListModel) Logger(org.slf4j.Logger) GuiComponentUtils(net.parostroj.timetable.gui.utils.GuiComponentUtils) IdGenerator(net.parostroj.timetable.utils.IdGenerator) ComponentPlacement(javax.swing.LayoutStyle.ComponentPlacement) JOptionPane(javax.swing.JOptionPane) Component(java.awt.Component) Collectors(java.util.stream.Collectors) net.parostroj.timetable.model(net.parostroj.timetable.model) Alignment(javax.swing.GroupLayout.Alignment) GuiIcon(net.parostroj.timetable.gui.utils.GuiIcon) GroupLayout(javax.swing.GroupLayout) ValueWithUnitEditBox(net.parostroj.timetable.gui.components.ValueWithUnitEditBox) FlowLayout(java.awt.FlowLayout) ValueWithUnitEditBox(net.parostroj.timetable.gui.components.ValueWithUnitEditBox) BorderLayout(java.awt.BorderLayout) GroupLayout(javax.swing.GroupLayout) GroupLayout(javax.swing.GroupLayout)

Aggregations

Component (java.awt.Component)2 FlowLayout (java.awt.FlowLayout)2 GroupLayout (javax.swing.GroupLayout)2 ValueWithUnitEditBox (net.parostroj.timetable.gui.components.ValueWithUnitEditBox)2 Wrapper (net.parostroj.timetable.gui.wrappers.Wrapper)2 BorderLayout (java.awt.BorderLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ItemEvent (java.awt.event.ItemEvent)1 BigDecimal (java.math.BigDecimal)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Alignment (javax.swing.GroupLayout.Alignment)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JOptionPane (javax.swing.JOptionPane)1 JPanel (javax.swing.JPanel)1 ComponentPlacement (javax.swing.LayoutStyle.ComponentPlacement)1