use of net.parostroj.timetable.gui.wrappers.Wrapper in project grafikon by jub77.
the class SettingsDialog method initComponents.
private void initComponents() {
JTabbedPane tabbedPane = new JTabbedPane();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(tabbedPane, BorderLayout.CENTER);
javax.swing.JPanel dataPanel = new javax.swing.JPanel();
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("modelinfo.tab.config"), dataPanel);
javax.swing.JPanel scriptPanel = new javax.swing.JPanel();
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("modelinfo.tab.script"), scriptPanel);
javax.swing.JPanel freightPanel = new javax.swing.JPanel();
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("modelinfo.tab.freight"), freightPanel);
java.awt.GridBagConstraints gridBagConstraints;
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
scaleComboBox = new javax.swing.JComboBox<>();
javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
ratioComboBox = new javax.swing.JComboBox<>();
roundingComboBox = new javax.swing.JComboBox<>();
javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
nameTemplateEditBox = new net.parostroj.timetable.gui.components.TextTemplateEditBox();
javax.swing.JLabel jLabel4 = new javax.swing.JLabel();
cNameTemplateEditBox = new net.parostroj.timetable.gui.components.TextTemplateEditBox();
javax.swing.JLabel jLabel5 = new javax.swing.JLabel();
sortComboBox = new javax.swing.JComboBox<>();
javax.swing.JLabel jLabel6 = new javax.swing.JLabel();
changesTrackingCheckBox = new javax.swing.JCheckBox();
javax.swing.JLabel jLabel11 = new javax.swing.JLabel();
javax.swing.JPanel routeLengthPanel = new javax.swing.JPanel();
javax.swing.JLabel jLabel12 = new javax.swing.JLabel();
javax.swing.JLabel jLabel14 = new javax.swing.JLabel();
rlRatioTextField = new NumberTextField();
javax.swing.JLabel jLabel13 = new javax.swing.JLabel();
rlUnitComboBox = new javax.swing.JComboBox<>();
javax.swing.JPanel weightPerAxlePanel = new javax.swing.JPanel();
javax.swing.JLabel jLabel7 = new javax.swing.JLabel();
javax.swing.JLabel jLabel8 = new javax.swing.JLabel();
loadedWeightEditBox = new net.parostroj.timetable.gui.components.ValueWithUnitEditBox();
javax.swing.JLabel jLabel9 = new javax.swing.JLabel();
emptyWeightEditBox = new net.parostroj.timetable.gui.components.ValueWithUnitEditBox();
javax.swing.JPanel lengthPanel = new javax.swing.JPanel();
javax.swing.JLabel jLabel10 = new javax.swing.JLabel();
lengthPerAxleEditBox = new net.parostroj.timetable.gui.components.ValueWithUnitEditBox();
javax.swing.JLabel jLabel15 = new javax.swing.JLabel();
lengthUnitComboBox = new javax.swing.JComboBox<>();
javax.swing.JPanel timeRangePanel = new javax.swing.JPanel();
javax.swing.JLabel jLabel16 = new javax.swing.JLabel();
fromTimeTextField = new javax.swing.JTextField();
javax.swing.JLabel jLabel17 = new javax.swing.JLabel();
toTimeTextField = new javax.swing.JTextField();
scriptEditBox = new net.parostroj.timetable.gui.components.ScriptEditBox();
javax.swing.JPanel buttonPanel = new javax.swing.JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.RIGHT);
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
// NOI18N
setTitle(ResourceLoader.getString("modelinfo"));
dataPanel.setLayout(new GridBagLayout());
// NOI18N
jLabel1.setText(ResourceLoader.getString("modelinfo.scales"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(5, 5, 5, 5);
dataPanel.add(jLabel1, gridBagConstraints);
GridBagConstraints gridBagConstraints_2 = new java.awt.GridBagConstraints();
gridBagConstraints_2.gridx = 1;
gridBagConstraints_2.gridy = 0;
gridBagConstraints_2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_2.insets = new Insets(5, 2, 5, 10);
dataPanel.add(scaleComboBox, gridBagConstraints_2);
// NOI18N
jLabel2.setText(ResourceLoader.getString("modelinfo.ratio"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(0, 5, 5, 5);
dataPanel.add(jLabel2, gridBagConstraints);
ratioComboBox.setEditable(true);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(0, 2, 5, 10);
dataPanel.add(ratioComboBox, gridBagConstraints);
JLabel label = new JLabel(ResourceLoader.getString("modelinfo.rounding"));
GridBagConstraints gbc_label = new GridBagConstraints();
gbc_label.anchor = GridBagConstraints.WEST;
gbc_label.insets = new Insets(0, 5, 5, 5);
gbc_label.gridx = 0;
gbc_label.gridy = 2;
dataPanel.add(label, gbc_label);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(0, 2, 5, 10);
dataPanel.add(roundingComboBox, gridBagConstraints);
// NOI18N
jLabel3.setText(ResourceLoader.getString("edit.traintypes.nametemplate"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(0, 5, 5, 5);
dataPanel.add(jLabel3, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new Insets(0, 5, 5, 5);
dataPanel.add(nameTemplateEditBox, gridBagConstraints);
// NOI18N
jLabel4.setText(ResourceLoader.getString("edit.traintypes.completenametemplate"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 5;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(0, 5, 5, 5);
dataPanel.add(jLabel4, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 6;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new Insets(0, 5, 5, 5);
dataPanel.add(cNameTemplateEditBox, gridBagConstraints);
// NOI18N
jLabel5.setText(ResourceLoader.getString("modelinfo.sort"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 7;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(0, 5, 5, 5);
dataPanel.add(jLabel5, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 7;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(0, 2, 5, 10);
dataPanel.add(sortComboBox, gridBagConstraints);
// NOI18N
jLabel6.setText(ResourceLoader.getString("modelinfo.crossing"));
java.awt.GridBagConstraints gridBagConstraints_7 = new java.awt.GridBagConstraints();
gridBagConstraints_7.gridwidth = 3;
gridBagConstraints_7.gridx = 0;
gridBagConstraints_7.gridy = 8;
gridBagConstraints_7.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_7.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints_7.insets = new Insets(0, 0, 5, 0);
javax.swing.JPanel crossingPanel = new javax.swing.JPanel(new FlowLayout(java.awt.FlowLayout.LEFT));
crossingPanel.add(jLabel6);
dataPanel.add(crossingPanel, gridBagConstraints_7);
stationTransferTextField = new javax.swing.JTextField();
stationTransferTextField.setColumns(5);
crossingPanel.add(stationTransferTextField);
JLabel lblMin = new JLabel("min");
crossingPanel.add(lblMin);
// NOI18N
changesTrackingCheckBox.setText(ResourceLoader.getString("modelinfo.tracking.changes"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 9;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(0, 2, 5, 10);
dataPanel.add(changesTrackingCheckBox, gridBagConstraints);
routeLengthPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
// NOI18N
jLabel12.setText(ResourceLoader.getString("modelinfo.route.length") + " -");
routeLengthPanel.add(jLabel12);
// NOI18N
jLabel14.setText(ResourceLoader.getString("modelinfo.route.length.ratio") + ":");
routeLengthPanel.add(jLabel14);
rlRatioTextField.setColumns(7);
routeLengthPanel.add(rlRatioTextField);
// NOI18N
jLabel13.setText(ResourceLoader.getString("modelinfo.route.length.unit") + ":");
routeLengthPanel.add(jLabel13);
routeLengthPanel.add(rlUnitComboBox);
GridBagConstraints gridBagConstraints_3 = new java.awt.GridBagConstraints();
gridBagConstraints_3.insets = new Insets(0, 0, 5, 0);
gridBagConstraints_3.gridx = 0;
gridBagConstraints_3.gridy = 12;
gridBagConstraints_3.gridwidth = 3;
gridBagConstraints_3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_3.anchor = java.awt.GridBagConstraints.WEST;
dataPanel.add(routeLengthPanel, gridBagConstraints_3);
weightPerAxlePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
// NOI18N
jLabel7.setText(ResourceLoader.getString("modelinfo.weight.per.axle") + " - ");
weightPerAxlePanel.add(jLabel7);
// NOI18N
jLabel8.setText(ResourceLoader.getString("modelinfo.weight.per.axle.loaded") + ":");
weightPerAxlePanel.add(jLabel8);
loadedWeightEditBox.setValueColumns(5);
weightPerAxlePanel.add(loadedWeightEditBox);
// NOI18N
jLabel9.setText(ResourceLoader.getString("modelinfo.weight.per.axle.empty") + ":");
weightPerAxlePanel.add(jLabel9);
emptyWeightEditBox.setValueColumns(5);
weightPerAxlePanel.add(emptyWeightEditBox);
GridBagConstraints gridBagConstraints_1 = new java.awt.GridBagConstraints();
gridBagConstraints_1.insets = new Insets(0, 0, 5, 0);
gridBagConstraints_1.gridx = 0;
gridBagConstraints_1.gridy = 10;
gridBagConstraints_1.gridwidth = 3;
gridBagConstraints_1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_1.anchor = java.awt.GridBagConstraints.WEST;
dataPanel.add(weightPerAxlePanel, gridBagConstraints_1);
lengthPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
// NOI18N
jLabel10.setText(ResourceLoader.getString("modelinfo.axle.length") + ":");
lengthPanel.add(jLabel10);
lengthPerAxleEditBox.setValueColumns(5);
lengthPanel.add(lengthPerAxleEditBox);
// NOI18N
jLabel15.setText(ResourceLoader.getString("modelinfo.length.unit") + ":");
lengthPanel.add(jLabel15);
lengthPanel.add(lengthUnitComboBox);
GridBagConstraints gridBagConstraints_4 = new java.awt.GridBagConstraints();
gridBagConstraints_4.insets = new Insets(0, 0, 5, 0);
gridBagConstraints_4.gridx = 0;
gridBagConstraints_4.gridy = 11;
gridBagConstraints_4.gridwidth = 3;
gridBagConstraints_4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_4.anchor = java.awt.GridBagConstraints.WEST;
dataPanel.add(lengthPanel, gridBagConstraints_4);
timeRangePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
// NOI18N
jLabel16.setText(ResourceLoader.getString("modelinfo.from.time"));
timeRangePanel.add(jLabel16);
fromTimeTextField.setColumns(7);
fromTimeTextField.addFocusListener(new java.awt.event.FocusAdapter() {
@Override
public void focusLost(java.awt.event.FocusEvent evt) {
timeTextFieldFocusLost(evt);
}
});
timeRangePanel.add(fromTimeTextField);
// NOI18N
jLabel17.setText(ResourceLoader.getString("modelinfo.to.time"));
timeRangePanel.add(jLabel17);
toTimeTextField.setColumns(7);
toTimeTextField.addFocusListener(new java.awt.event.FocusAdapter() {
@Override
public void focusLost(java.awt.event.FocusEvent evt) {
timeTextFieldFocusLost(evt);
}
});
timeRangePanel.add(toTimeTextField);
GridBagConstraints gridBagConstraints_5 = new java.awt.GridBagConstraints();
gridBagConstraints_5.insets = new Insets(0, 0, 5, 0);
gridBagConstraints_5.gridx = 0;
gridBagConstraints_5.gridy = 13;
gridBagConstraints_5.gridwidth = 3;
gridBagConstraints_5.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_5.anchor = java.awt.GridBagConstraints.WEST;
dataPanel.add(timeRangePanel, gridBagConstraints_5);
javax.swing.JPanel unitsPanel = new javax.swing.JPanel();
unitsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
gridBagConstraints_5 = new java.awt.GridBagConstraints();
gridBagConstraints_5.insets = new Insets(0, 0, 0, 0);
gridBagConstraints_5.gridx = 0;
gridBagConstraints_5.gridy = 14;
gridBagConstraints_5.gridwidth = 3;
gridBagConstraints_5.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints_5.anchor = java.awt.GridBagConstraints.WEST;
dataPanel.add(unitsPanel, gridBagConstraints_5);
unitsPanel.add(new javax.swing.JLabel(ResourceLoader.getString("modelinfo.unit")));
unitComboBox = new javax.swing.JComboBox<>();
unitsPanel.add(unitComboBox);
unitsPanel.add(new javax.swing.JLabel(ResourceLoader.getString("modelinfo.speed.unit")));
speedUnitComboBox = new javax.swing.JComboBox<>();
unitsPanel.add(speedUnitComboBox);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 15;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
dataPanel.add(Box.createVerticalGlue(), gridBagConstraints);
freightPanel.setLayout(new BorderLayout());
javax.swing.JPanel freightStrategyPanel = new javax.swing.JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
freightStrategyPanel.setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 0));
freightPanel.add(freightStrategyPanel, BorderLayout.NORTH);
freightStrategyPanel.add(new JLabel(ResourceLoader.getString("modelinfo.freight.connection.strategy") + ": "));
strategyTypeModel = new WrapperListModel<>(true);
javax.swing.JComboBox<Wrapper<ConnectionStrategyType>> strategyType = new javax.swing.JComboBox<>();
strategyType.setModel(strategyTypeModel);
freightStrategyPanel.add(strategyType);
strategyType.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
ConnectionStrategyType sType = strategyTypeModel.getSelectedObject();
if (sType == ConnectionStrategyType.CUSTOM_CONNECTION_FILTER) {
filterScriptEditBox.setEnabled(true);
filterScriptEditBox.setScriptText("builder.netFilter = { context, dest, level -> ok }\nbuilder.trainFilter = { context, dest, level -> ok }");
} else {
filterScriptEditBox.setScript(null);
filterScriptEditBox.setEnabled(false);
}
}
});
filterScriptEditBox = new net.parostroj.timetable.gui.components.ScriptEditBox();
// NOI18N
filterScriptEditBox.setScriptFont(new java.awt.Font("Monospaced", 0, 12));
// allow only groovy script language for the filter
filterScriptEditBox.setScriptLanguage(Script.Language.GROOVY);
filterScriptEditBox.setLanguageChange(false);
freightPanel.add(filterScriptEditBox, BorderLayout.CENTER);
scriptPanel.setLayout(new GridBagLayout());
// NOI18N
jLabel11.setText(ResourceLoader.getString("modelinfo.running.time.script"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(5, 5, 0, 0);
scriptPanel.add(jLabel11, gridBagConstraints);
scriptEditBox.setRows(8);
// NOI18N
scriptEditBox.setScriptFont(new java.awt.Font("Monospaced", 0, 12));
GridBagConstraints gridBagConstraints_6 = new java.awt.GridBagConstraints();
gridBagConstraints_6.insets = new Insets(0, 0, 5, 0);
gridBagConstraints_6.gridx = 0;
gridBagConstraints_6.gridy = 1;
gridBagConstraints_6.gridwidth = 3;
gridBagConstraints_6.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints_6.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints_6.weightx = 1.0;
gridBagConstraints_6.weighty = 1.0;
scriptPanel.add(scriptEditBox, gridBagConstraints_6);
// NOI18N
okButton.setText(ResourceLoader.getString("button.ok"));
okButton.addActionListener(evt -> okButtonActionPerformed(evt));
buttonPanel.add(okButton);
// NOI18N
cancelButton.setText(ResourceLoader.getString("button.cancel"));
cancelButton.addActionListener(evt -> cancelButtonActionPerformed(evt));
buttonPanel.add(cancelButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
pack();
}
use of net.parostroj.timetable.gui.wrappers.Wrapper 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();
}
use of net.parostroj.timetable.gui.wrappers.Wrapper in project grafikon by jub77.
the class GroupsComboBox method updateGroups.
/**
* updates combobox.
*
* @param diagram diagram
* @param groupSelect selected group (depends on type)
*/
public void updateGroups(TrainDiagram diagram, GroupSelect groupSelect) {
if (groupSelect.getType() == Type.ALL && !allOption)
throw new IllegalArgumentException("Cannot set ALL.");
// clear
removeAllItems();
// add no and all
if (allOption) {
addItem(all);
}
addItem(none);
List<Group> groups = new ArrayList<Group>(diagram.getGroups());
this.sortGroups(groups);
for (Group group : groups) {
this.addItem(new Wrapper<Group>(group));
}
switch(groupSelect.getType()) {
case ALL:
setSelectedItem(all);
break;
case NONE:
setSelectedItem(none);
break;
default:
Wrapper<Group> w = new Wrapper<Group>(groupSelect.getGroup());
setSelectedItem(w);
break;
}
}
use of net.parostroj.timetable.gui.wrappers.Wrapper in project grafikon by jub77.
the class ChangedTrainsPanel method initComponents.
private void initComponents() {
scrollPane = new javax.swing.JScrollPane();
trainsList = new javax.swing.JList<Wrapper<Train>>();
setLayout(new java.awt.BorderLayout());
trainsList.setModel(listModel);
trainsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
scrollPane.setViewportView(trainsList);
add(scrollPane, java.awt.BorderLayout.CENTER);
JPanel buttonPanel = new JPanel();
add(buttonPanel, BorderLayout.SOUTH);
JButton clearButton = new JButton(ResourceLoader.getString("eventsviewer.button.clear"));
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
listModel.clear();
}
});
buttonPanel.add(clearButton);
limitTextField = new javax.swing.JFormattedTextField();
limitTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
limitTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
limitTextField.setColumns(4);
limitTextField.setValue(0l);
buttonPanel.add(limitTextField);
JButton limitButton = new JButton(ResourceLoader.getString("eventsviewer.button.limit"));
limitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Long value = (Long) limitTextField.getValue();
if (value >= 0) {
limit = value;
limitTrains(limit);
} else {
limit = 0;
limitTextField.setValue(0l);
}
}
});
buttonPanel.add(limitButton);
}
use of net.parostroj.timetable.gui.wrappers.Wrapper in project grafikon by jub77.
the class TCItemChangeDialog method updateFromTo.
private void updateFromTo(List<TimeInterval> intervals, TimeInterval from, TimeInterval to) {
fromComboBox.removeAllItems();
toComboBox.removeAllItems();
for (TimeInterval interval : intervals) {
if (interval.isNodeOwner()) {
Wrapper<TimeInterval> w = new Wrapper<>(interval);
fromComboBox.addItem(w);
toComboBox.addItem(w);
}
}
fromComboBox.setSelectedItem(new Wrapper<>(from));
toComboBox.setSelectedItem(new Wrapper<>(to));
}
Aggregations