use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class BeanEditAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (bean == null) {
// add error dialog TODO
//NOI18N
log.error("No bean set so unable to edit a null bean");
return;
}
if (f == null) {
f = new JmriJFrame(Bundle.getMessage("EditBean", 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() {
@Override
public void actionPerformed(ActionEvent e) {
applyButtonAction(e);
}
});
JButton okBut = new JButton(Bundle.getMessage("ButtonOK"));
okBut.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
applyButtonAction(e);
f.dispose();
}
});
JButton cancelBut = new JButton(Bundle.getMessage("ButtonCancel"));
cancelBut.addActionListener(new ActionListener() {
@Override
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);
}
use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class OptionsMenu method optionWindowRequested.
private void optionWindowRequested(ActionEvent e) {
if (optionsFrame == null) {
optionsFrame = new JmriJFrame(Bundle.getMessage("MenuOptions"), false, true);
optionsFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Options", true);
optionsPane = optionsFrame.getContentPane();
optionsPane.setLayout(new BoxLayout(optionsFrame.getContentPane(), BoxLayout.Y_AXIS));
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(useConnectivityCheckBox);
useConnectivityCheckBox.setToolTipText(Bundle.getMessage("UseConnectivityHint"));
p1.add(layoutEditorBox);
layoutEditorBox.setToolTipText(Bundle.getMessage("LayoutEditorHint"));
signalTypeBox = new JComboBox<String>(signalTypes);
p1.add(signalTypeBox);
signalTypeBox.setToolTipText(Bundle.getMessage("SignalTypeHint"));
optionsPane.add(p1);
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
ButtonGroup trainsGroup = new ButtonGroup();
p2.add(trainsFromRoster);
trainsFromRoster.setToolTipText(Bundle.getMessage("TrainsFromRosterHint"));
trainsGroup.add(trainsFromRoster);
ActionListener useRosterEntryListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (trainsFromRoster.isSelected()) {
rosterInBlockCheckBox.setEnabled(true);
if (nameInBlockCheckBox.isSelected() && e.getSource() == nameInBlockCheckBox) {
rosterInBlockCheckBox.setSelected(false);
} else if (rosterInBlockCheckBox.isSelected() && e.getSource() == rosterInBlockCheckBox) {
nameInBlockCheckBox.setSelected(false);
}
} else {
rosterInBlockCheckBox.setEnabled(false);
}
}
};
trainsFromRoster.addActionListener(useRosterEntryListener);
p2.add(new JLabel(" "));
p2.add(trainsFromTrains);
trainsFromTrains.setToolTipText(Bundle.getMessage("TrainsFromTrainsHint"));
trainsFromTrains.addActionListener(useRosterEntryListener);
trainsGroup.add(trainsFromTrains);
p2.add(new JLabel(" "));
p2.add(trainsFromUser);
trainsFromUser.setToolTipText(Bundle.getMessage("TrainsFromUserHint"));
trainsFromUser.addActionListener(useRosterEntryListener);
trainsGroup.add(trainsFromUser);
optionsPane.add(p2);
JPanel p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(detectionCheckBox);
detectionCheckBox.setToolTipText(Bundle.getMessage("DetectionBoxHint"));
optionsPane.add(p3);
JPanel p4 = new JPanel();
p4.setLayout(new FlowLayout());
p4.add(autoAllocateCheckBox);
autoAllocateCheckBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
optionsPane.add(p4);
JPanel p5 = new JPanel();
p5.setLayout(new FlowLayout());
p5.add(autoTurnoutsCheckBox);
autoTurnoutsCheckBox.setToolTipText(Bundle.getMessage("AutoTurnoutsBoxHint"));
optionsPane.add(p5);
JPanel p16 = new JPanel();
p16.setLayout(new FlowLayout());
p16.add(trustKnownTurnoutsCheckBox);
trustKnownTurnoutsCheckBox.setToolTipText(Bundle.getMessage("trustKnownTurnoutsHint"));
optionsPane.add(p16);
JPanel p6 = new JPanel();
p6.setLayout(new FlowLayout());
p6.add(shortNameCheckBox);
shortNameCheckBox.setToolTipText(Bundle.getMessage("ShortNameBoxHint"));
optionsPane.add(p6);
JPanel p7 = new JPanel();
p7.setLayout(new FlowLayout());
p7.add(nameInBlockCheckBox);
nameInBlockCheckBox.setToolTipText(Bundle.getMessage("NameInBlockBoxHint"));
nameInBlockCheckBox.addActionListener(useRosterEntryListener);
optionsPane.add(p7);
JPanel p7b = new JPanel();
p7b.setLayout(new FlowLayout());
p7b.add(rosterInBlockCheckBox);
rosterInBlockCheckBox.setToolTipText(Bundle.getMessage("RosterInBlockBoxHint"));
rosterInBlockCheckBox.addActionListener(useRosterEntryListener);
optionsPane.add(p7b);
JPanel p10 = new JPanel();
p10.setLayout(new FlowLayout());
p10.add(extraColorForAllocatedCheckBox);
extraColorForAllocatedCheckBox.setToolTipText(Bundle.getMessage("ExtraColorForAllocatedBoxHint"));
optionsPane.add(p10);
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(nameInAllocatedBlockCheckBox);
nameInAllocatedBlockCheckBox.setToolTipText(Bundle.getMessage("NameInAllocatedBlockBoxHint"));
optionsPane.add(p11);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(supportVSDecoderCheckBox);
supportVSDecoderCheckBox.setToolTipText(Bundle.getMessage("SupportVSDecoderBoxHint"));
optionsPane.add(p13);
JPanel p8 = new JPanel();
initializeScaleCombo();
p8.add(new JLabel(Bundle.getMessage("LayoutScale") + ":"));
p8.add(layoutScaleBox);
layoutScaleBox.setToolTipText(Bundle.getMessage("ScaleBoxHint"));
optionsPane.add(p8);
JPanel p12 = new JPanel();
p12.setLayout(new FlowLayout());
p12.add(new JLabel(Bundle.getMessage("Units") + " "));
ButtonGroup scaleGroup = new ButtonGroup();
p12.add(scaleFeet);
scaleFeet.setToolTipText(Bundle.getMessage("ScaleFeetHint"));
scaleGroup.add(scaleFeet);
p12.add(new JLabel(" "));
p12.add(scaleMeters);
scaleMeters.setToolTipText(Bundle.getMessage("ScaleMetersHint"));
scaleGroup.add(scaleMeters);
optionsPane.add(p12);
JPanel p15 = new JPanel();
p15.setLayout(new FlowLayout());
p15.add(new JLabel(Bundle.getMessage("minThrottleInterval") + " :"));
NumberFormatter numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
numberFormatter.setValueClass(Integer.class);
numberFormatter.setMinimum(20);
numberFormatter.setMaximum(1000);
minThrottleIntervalTextField = new JFormattedTextField(numberFormatter);
minThrottleIntervalTextField.setColumns(4);
minThrottleIntervalTextField.setValue(250);
minThrottleIntervalTextField.setToolTipText(Bundle.getMessage("minThrottleIntervalHint"));
p15.add(minThrottleIntervalTextField);
p15.add(new JLabel(Bundle.getMessage("ms")));
optionsPane.add(p15);
JPanel p17 = new JPanel();
p17.setLayout(new FlowLayout());
p17.add(new JLabel(Bundle.getMessage("fullRampTime") + " :"));
numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
numberFormatter.setValueClass(Integer.class);
numberFormatter.setMinimum(1000);
numberFormatter.setMaximum(20000);
fullRampTimeTextField = new JFormattedTextField(numberFormatter);
fullRampTimeTextField.setColumns(4);
fullRampTimeTextField.setValue(5000);
fullRampTimeTextField.setToolTipText(Bundle.getMessage("fullRampTimeHint"));
p17.add(fullRampTimeTextField);
p17.add(new JLabel(Bundle.getMessage("ms")));
optionsPane.add(p17);
JPanel p14 = new JPanel();
p14.setLayout(new FlowLayout());
p14.add(openDispatcherWithPanel);
openDispatcherWithPanel.setToolTipText(Bundle.getMessage("OpenDispatcherWithPanelBoxHint"));
optionsPane.add(p14);
optionsPane.add(new JSeparator());
JPanel p9 = new JPanel();
p9.setLayout(new FlowLayout());
JButton cancelButton = null;
p9.add(cancelButton = new JButton(Bundle.getMessage("ButtonCancel")));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelOptions(e);
}
});
cancelButton.setToolTipText(Bundle.getMessage("CancelButtonHint2"));
p9.add(new JLabel(" "));
JButton applyButton = null;
p9.add(applyButton = new JButton(Bundle.getMessage("ButtonApply")));
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
applyOptions(e);
}
});
applyButton.setToolTipText(Bundle.getMessage("ApplyButtonHint"));
optionsPane.add(p9);
}
if (initializeLayoutEditorCombo()) {
useConnectivityCheckBox.setVisible(true);
layoutEditorBox.setVisible(true);
} else {
useConnectivityCheckBox.setVisible(false);
layoutEditorBox.setVisible(false);
}
useConnectivityCheckBox.setSelected(dispatcher.getUseConnectivity());
signalTypeBox.setSelectedIndex(dispatcher.getSignalType());
trainsFromRoster.setSelected(dispatcher.getTrainsFromRoster());
trainsFromTrains.setSelected(dispatcher.getTrainsFromTrains());
trainsFromUser.setSelected(dispatcher.getTrainsFromUser());
detectionCheckBox.setSelected(dispatcher.getHasOccupancyDetection());
autoAllocateCheckBox.setSelected(dispatcher.getAutoAllocate());
autoTurnoutsCheckBox.setSelected(dispatcher.getAutoTurnouts());
trustKnownTurnoutsCheckBox.setSelected(dispatcher.getTrustKnownTurnouts());
shortNameCheckBox.setSelected(dispatcher.getShortActiveTrainNames());
nameInBlockCheckBox.setSelected(dispatcher.getShortNameInBlock());
rosterInBlockCheckBox.setSelected(dispatcher.getRosterEntryInBlock());
extraColorForAllocatedCheckBox.setSelected(dispatcher.getExtraColorForAllocated());
nameInAllocatedBlockCheckBox.setSelected(dispatcher.getNameInAllocatedBlock());
supportVSDecoderCheckBox.setSelected(dispatcher.getSupportVSDecoder());
scaleMeters.setSelected(dispatcher.getUseScaleMeters());
scaleFeet.setSelected(!dispatcher.getUseScaleMeters());
minThrottleIntervalTextField.setValue(dispatcher.getMinThrottleInterval());
fullRampTimeTextField.setValue(dispatcher.getFullRampTime());
if (dispatcher.getLayoutEditor() != null) {
openDispatcherWithPanel.setSelected(dispatcher.getLayoutEditor().getOpenDispatcherOnLoad());
}
optionsFrame.pack();
optionsFrame.setVisible(true);
}
use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class LayoutTurnout method editLayoutTurnout.
/**
* Edit a Layout Turnout
*/
protected void editLayoutTurnout() {
if (editOpen) {
editLayoutTurnoutFrame.setVisible(true);
return;
}
// Initialize if needed
if (editLayoutTurnoutFrame == null) {
editLayoutTurnoutFrame = new JmriJFrame(rb.getString("EditTurnout"), false, true);
editLayoutTurnoutFrame.addHelpMenu("package.jmri.jmrit.display.EditLayoutTurnout", true);
editLayoutTurnoutFrame.setLocation(50, 30);
Container contentPane = editLayoutTurnoutFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// setup turnout name
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel turnoutNameLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanNameTurnout")));
panel1.add(turnoutNameLabel);
// add combobox to select turnout
firstTurnoutComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getTurnout(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
layoutEditor.setupComboBox(firstTurnoutComboBox, true, true);
panel1.add(firstTurnoutComboBox);
contentPane.add(panel1);
JPanel panel1a = new JPanel();
panel1a.setLayout(new BoxLayout(panel1a, BoxLayout.Y_AXIS));
secondTurnoutComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getSecondTurnout(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
layoutEditor.setupComboBox(secondTurnoutComboBox, true, false);
additionalTurnout.addActionListener((ActionEvent e) -> {
if (additionalTurnout.isSelected()) {
secondTurnoutLabel.setEnabled(true);
secondTurnoutComboBox.setEnabled(true);
} else {
secondTurnoutLabel.setEnabled(false);
secondTurnoutComboBox.setEnabled(false);
}
});
if ((type != DOUBLE_XOVER) && (type != RH_XOVER) && (type != LH_XOVER)) {
additionalTurnout.setText(rb.getString("ThrowTwoTurnouts"));
}
panel1a.add(additionalTurnout);
contentPane.add(panel1a);
secondTurnoutLabel = new JLabel(Bundle.getMessage("Supporting", Bundle.getMessage("BeanNameTurnout")));
secondTurnoutLabel.setEnabled(false);
secondTurnoutComboBox.setEnabled(false);
JPanel panel1b = new JPanel();
panel1b.add(secondTurnoutLabel);
panel1b.add(secondTurnoutComboBox);
contentPane.add(panel1b);
// add continuing state choice, if not crossover
if ((type != DOUBLE_XOVER) && (type != RH_XOVER) && (type != LH_XOVER)) {
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
stateBox.removeAllItems();
stateBox.addItem(InstanceManager.turnoutManagerInstance().getClosedText());
turnoutClosedIndex = 0;
stateBox.addItem(InstanceManager.turnoutManagerInstance().getThrownText());
turnoutThrownIndex = 1;
stateBox.setToolTipText(rb.getString("StateToolTip"));
panel3.add(new JLabel(rb.getString("ContinuingState")));
panel3.add(stateBox);
contentPane.add(panel3);
}
JPanel panel33 = new JPanel();
panel33.setLayout(new FlowLayout());
hiddenBox.setToolTipText(rb.getString("HiddenToolTip"));
panel33.add(hiddenBox);
contentPane.add(panel33);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
border.setTitle(Bundle.getMessage("BeanNameBlock"));
// setup block name
JPanel panel2 = new JPanel();
panel2.setBorder(border);
panel2.setLayout(new FlowLayout());
panel2.add(blockNameComboBox);
layoutEditor.setupComboBox(blockNameComboBox, false, true);
blockNameComboBox.setToolTipText(rb.getString("EditBlockNameHint"));
panel2.add(turnoutEditBlock = new JButton(rb.getString("CreateEdit")));
turnoutEditBlock.addActionListener((ActionEvent e) -> {
turnoutEditBlockPressed(e);
});
contentPane.add(panel2);
if ((type == DOUBLE_XOVER) || (type == RH_XOVER) || (type == LH_XOVER)) {
JPanel panel21 = new JPanel();
panel21.setLayout(new FlowLayout());
TitledBorder borderblk2 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
borderblk2.setTitle(Bundle.getMessage("BeanNameBlock") + " 2");
panel21.setBorder(borderblk2);
layoutEditor.setupComboBox(blockBNameComboBox, false, true);
blockBNameComboBox.setToolTipText(rb.getString("EditBlockBNameHint"));
panel21.add(blockBNameComboBox);
panel21.add(turnoutEditBlockB = new JButton(rb.getString("CreateEdit")));
turnoutEditBlockB.addActionListener((ActionEvent e) -> {
turnoutEditBlockBPressed(e);
});
turnoutEditBlockB.setToolTipText(Bundle.getMessage("EditBlockHint", "2"));
contentPane.add(panel21);
JPanel panel22 = new JPanel();
panel22.setLayout(new FlowLayout());
TitledBorder borderblk3 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
borderblk3.setTitle(Bundle.getMessage("BeanNameBlock") + " 3");
panel22.setBorder(borderblk3);
layoutEditor.setupComboBox(blockCNameComboBox, false, true);
blockCNameComboBox.setToolTipText(rb.getString("EditBlockCNameHint"));
panel22.add(blockCNameComboBox);
panel22.add(turnoutEditBlockC = new JButton(rb.getString("CreateEdit")));
turnoutEditBlockC.addActionListener((ActionEvent e) -> {
turnoutEditBlockCPressed(e);
});
turnoutEditBlockC.setToolTipText(Bundle.getMessage("EditBlockHint", "3"));
contentPane.add(panel22);
JPanel panel23 = new JPanel();
panel23.setLayout(new FlowLayout());
TitledBorder borderblk4 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
borderblk4.setTitle(Bundle.getMessage("BeanNameBlock") + " 4");
panel23.setBorder(borderblk4);
layoutEditor.setupComboBox(blockDNameComboBox, false, true);
blockDNameComboBox.setToolTipText(rb.getString("EditBlockDNameHint"));
panel23.add(blockDNameComboBox);
panel23.add(turnoutEditBlockD = new JButton(rb.getString("CreateEdit")));
turnoutEditBlockD.addActionListener((ActionEvent e) -> {
turnoutEditBlockDPressed(e);
});
turnoutEditBlockD.setToolTipText(Bundle.getMessage("EditBlockHint", "4"));
contentPane.add(panel23);
}
// set up Edit Block, Done and Cancel buttons
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
// Edit Block
// empty value for block 1
turnoutEditBlock.setToolTipText(Bundle.getMessage("EditBlockHint", ""));
// Done
panel5.add(turnoutEditDone = new JButton(Bundle.getMessage("ButtonDone")));
// make this button the default button (return or enter activates)
// Note: We have to invoke this later because we don't currently have a root pane
SwingUtilities.invokeLater(() -> {
JRootPane rootPane = SwingUtilities.getRootPane(turnoutEditDone);
rootPane.setDefaultButton(turnoutEditDone);
});
turnoutEditDone.addActionListener((ActionEvent e) -> {
turnoutEditDonePressed(e);
});
turnoutEditDone.setToolTipText(Bundle.getMessage("DoneHint", Bundle.getMessage("ButtonDone")));
// Cancel
panel5.add(turnoutEditCancel = new JButton(Bundle.getMessage("ButtonCancel")));
turnoutEditCancel.addActionListener((ActionEvent e) -> {
turnoutEditCancelPressed(e);
});
turnoutEditCancel.setToolTipText(Bundle.getMessage("CancelHint", Bundle.getMessage("ButtonCancel")));
contentPane.add(panel5);
}
hiddenBox.setSelected(hidden);
// Set up for Edit
blockNameComboBox.getEditor().setItem(blockName);
if ((type == DOUBLE_XOVER) || (type == RH_XOVER) || (type == LH_XOVER)) {
blockBNameComboBox.getEditor().setItem(blockBName);
blockCNameComboBox.getEditor().setItem(blockCName);
blockDNameComboBox.getEditor().setItem(blockDName);
}
firstTurnoutComboBox.setSelectedItem(turnoutName);
if (secondNamedTurnout != null) {
additionalTurnout.setSelected(true);
secondTurnoutLabel.setEnabled(true);
secondTurnoutComboBox.setEnabled(true);
}
if ((type != DOUBLE_XOVER) && (type != RH_XOVER) && (type != LH_XOVER)) {
if (continuingSense == Turnout.CLOSED) {
stateBox.setSelectedIndex(turnoutClosedIndex);
} else {
stateBox.setSelectedIndex(turnoutThrownIndex);
}
}
editLayoutTurnoutFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
turnoutEditCancelPressed(null);
}
});
editLayoutTurnoutFrame.pack();
editLayoutTurnoutFrame.setVisible(true);
editOpen = true;
needsBlockUpdate = false;
}
use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class LayoutTurntable method editTurntable.
/**
* Edit a Turntable
*/
protected void editTurntable(LayoutTurntable x) {
if (editOpen) {
editTurntableFrame.setVisible(true);
return;
}
needsRedraw = false;
// Initialize if needed
if (editTurntableFrame == null) {
editTurntableFrame = new JmriJFrame(rb.getString("EditTurntable"), false, true);
editTurntableFrame.addHelpMenu("package.jmri.jmrit.display.EditTurntable", true);
editTurntableFrame.setLocation(50, 30);
Container contentPane = editTurntableFrame.getContentPane();
JPanel headerPane = new JPanel();
JPanel footerPane = new JPanel();
headerPane.setLayout(new BoxLayout(headerPane, BoxLayout.Y_AXIS));
footerPane.setLayout(new BoxLayout(footerPane, BoxLayout.Y_AXIS));
contentPane.setLayout(new BorderLayout());
contentPane.add(headerPane, BorderLayout.NORTH);
contentPane.add(footerPane, BorderLayout.SOUTH);
// setup radius
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel radiusLabel = new JLabel(rb.getString("TurntableRadius"));
panel1.add(radiusLabel);
panel1.add(radiusField);
radiusField.setToolTipText(rb.getString("TurntableRadiusHint"));
headerPane.add(panel1);
// setup add ray track
JPanel panel2 = new JPanel();
panel2.setLayout(new FlowLayout());
JLabel rayAngleLabel = new JLabel(rb.getString("RayAngle"));
panel2.add(rayAngleLabel);
panel2.add(angleField);
angleField.setToolTipText(rb.getString("RayAngleHint"));
headerPane.add(panel2);
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
panel3.add(addRayTrack = new JButton(rb.getString("AddRayTrack")));
addRayTrack.setToolTipText(rb.getString("AddRayTrackHint"));
addRayTrack.addActionListener((ActionEvent e) -> {
addRayTrackPressed(e);
updateRayPanel();
});
panel3.add(dccControlled = new JCheckBox(rb.getString("TurntableDCCControlled")));
dccControlled.setSelected(isTurnoutControlled());
dccControlled.addActionListener((ActionEvent e) -> {
setTurnoutControlled(dccControlled.isSelected());
for (RayTrack rt : rayList) {
rt.showTurnoutDetails();
}
editTurntableFrame.pack();
});
headerPane.add(panel3);
// set up Done and Cancel buttons
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
panel5.add(turntableEditDone = new JButton(Bundle.getMessage("ButtonDone")));
turntableEditDone.addActionListener((ActionEvent e) -> {
turntableEditDonePressed(e);
});
// make this button the default button (return or enter activates)
// Note: We have to invoke this later because we don't currently have a root pane
SwingUtilities.invokeLater(() -> {
JRootPane rootPane = SwingUtilities.getRootPane(turntableEditDone);
rootPane.setDefaultButton(turntableEditDone);
});
turntableEditDone.setToolTipText(Bundle.getMessage("DoneHint", Bundle.getMessage("ButtonDone")));
// Cancel
panel5.add(turntableEditCancel = new JButton(Bundle.getMessage("ButtonCancel")));
turntableEditCancel.addActionListener((ActionEvent e) -> {
turntableEditCancelPressed(e);
});
turntableEditCancel.setToolTipText(Bundle.getMessage("CancelHint", Bundle.getMessage("ButtonCancel")));
footerPane.add(panel5);
rayPanel = new JPanel();
rayPanel.setLayout(new BoxLayout(rayPanel, BoxLayout.Y_AXIS));
for (RayTrack rt : rayList) {
rayPanel.add(rt.getPanel());
}
JScrollPane rayScrollPane = new JScrollPane(rayPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
contentPane.add(rayScrollPane, BorderLayout.CENTER);
} else {
updateRayPanel();
}
// Set up for Edit
radiusField.setText(" " + radius);
oldRadius = radiusField.getText();
angleField.setText("0");
editTurntableFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
turntableEditCancelPressed(null);
}
});
editTurntableFrame.pack();
editTurntableFrame.setVisible(true);
editOpen = true;
}
use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class LogixTableAction method makeEditLogixWindow.
/**
* Create and/or initialize the Edit Logix pane.
*/
void makeEditLogixWindow() {
// Setup the name box components.
setNameBoxListeners();
//if (log.isDebugEnabled()) log.debug("makeEditLogixWindow ");
editUserName.setText(_curLogix.getUserName());
// clear conditional table if needed
if (conditionalTableModel != null) {
conditionalTableModel.fireTableStructureChanged();
}
inEditMode = true;
if (editLogixFrame == null) {
editLogixFrame = new JmriJFrame(rbx.getString("TitleEditLogix"), false, false);
editLogixFrame.addHelpMenu("package.jmri.jmrit.beantable.LogixAddEdit", true);
editLogixFrame.setLocation(100, 30);
Container contentPane = editLogixFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel systemNameLabel = new JLabel(Bundle.getMessage("ColumnSystemName") + ":");
panel1.add(systemNameLabel);
JLabel fixedSystemName = new JLabel(_curLogix.getSystemName());
panel1.add(fixedSystemName);
contentPane.add(panel1);
JPanel panel2 = new JPanel();
panel2.setLayout(new FlowLayout());
JLabel userNameLabel = new JLabel(Bundle.getMessage("ColumnUserName") + ":");
panel2.add(userNameLabel);
panel2.add(editUserName);
editUserName.setToolTipText(rbx.getString("LogixUserNameHint2"));
contentPane.add(panel2);
// add table of Conditionals
JPanel pctSpace = new JPanel();
pctSpace.setLayout(new FlowLayout());
pctSpace.add(new JLabel(" "));
contentPane.add(pctSpace);
JPanel pTitle = new JPanel();
pTitle.setLayout(new FlowLayout());
pTitle.add(new JLabel(rbx.getString("ConditionalTableTitle")));
contentPane.add(pTitle);
// initialize table of conditionals
conditionalTableModel = new ConditionalTableModel();
JTable conditionalTable = new JTable(conditionalTableModel);
conditionalTable.setRowSelectionAllowed(false);
TableColumnModel conditionalColumnModel = conditionalTable.getColumnModel();
TableColumn sNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.SNAME_COLUMN);
sNameColumn.setResizable(true);
sNameColumn.setMinWidth(100);
sNameColumn.setPreferredWidth(130);
TableColumn uNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.UNAME_COLUMN);
uNameColumn.setResizable(true);
uNameColumn.setMinWidth(210);
uNameColumn.setPreferredWidth(260);
TableColumn stateColumn = conditionalColumnModel.getColumn(ConditionalTableModel.STATE_COLUMN);
stateColumn.setResizable(true);
stateColumn.setMinWidth(50);
stateColumn.setMaxWidth(100);
TableColumn buttonColumn = conditionalColumnModel.getColumn(ConditionalTableModel.BUTTON_COLUMN);
// install button renderer and editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
conditionalTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
conditionalTable.setDefaultEditor(JButton.class, buttonEditor);
JButton testButton = new JButton("XXXXXX");
conditionalTable.setRowHeight(testButton.getPreferredSize().height);
buttonColumn.setMinWidth(testButton.getPreferredSize().width);
buttonColumn.setMaxWidth(testButton.getPreferredSize().width);
buttonColumn.setResizable(false);
JScrollPane conditionalTableScrollPane = new JScrollPane(conditionalTable);
Dimension dim = conditionalTable.getPreferredSize();
dim.height = 450;
conditionalTableScrollPane.getViewport().setPreferredSize(dim);
contentPane.add(conditionalTableScrollPane);
// add message area between table and buttons
JPanel panel4 = new JPanel();
panel4.setLayout(new BoxLayout(panel4, BoxLayout.Y_AXIS));
JPanel panel41 = new JPanel();
panel41.setLayout(new FlowLayout());
panel41.add(status);
panel4.add(panel41);
JPanel panel42 = new JPanel();
panel42.setLayout(new FlowLayout());
// Conditional panel buttons - New Conditional
JButton newConditionalButton = new JButton(rbx.getString("NewConditionalButton"));
panel42.add(newConditionalButton);
newConditionalButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newConditionalPressed(e);
}
});
newConditionalButton.setToolTipText(rbx.getString("NewConditionalButtonHint"));
// Conditional panel buttons - Reorder
JButton reorderButton = new JButton(rbx.getString("ReorderButton"));
panel42.add(reorderButton);
reorderButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
reorderPressed(e);
}
});
reorderButton.setToolTipText(rbx.getString("ReorderButtonHint"));
// Conditional panel buttons - Calculate
JButton calculateButton = new JButton(rbx.getString("CalculateButton"));
panel42.add(calculateButton);
calculateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculatePressed(e);
}
});
calculateButton.setToolTipText(rbx.getString("CalculateButtonHint"));
panel4.add(panel42);
Border panel4Border = BorderFactory.createEtchedBorder();
panel4.setBorder(panel4Border);
contentPane.add(panel4);
// add buttons at bottom of window
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
// Bottom Buttons - Done Logix
JButton done = new JButton(Bundle.getMessage("ButtonDone"));
panel5.add(done);
done.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
donePressed(e);
}
});
done.setToolTipText(rbx.getString("DoneButtonHint"));
// Delete Logix
JButton delete = new JButton(Bundle.getMessage("ButtonDelete"));
panel5.add(delete);
delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deletePressed(e);
}
});
delete.setToolTipText(rbx.getString("DeleteLogixButtonHint"));
contentPane.add(panel5);
}
editLogixFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
if (inEditMode) {
donePressed(null);
} else {
finishDone();
}
}
});
editLogixFrame.pack();
editLogixFrame.setVisible(true);
}
Aggregations