use of javax.swing.JSeparator in project JMRI by JMRI.
the class SectionTableAction method addEditPressed.
void addEditPressed() {
pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
if (addFrame == null) {
addFrame = new JmriJFrame(Bundle.getMessage("TitleAddSection"));
addFrame.addHelpMenu("package.jmri.jmrit.beantable.SectionAddEdit", true);
addFrame.getContentPane().setLayout(new BoxLayout(addFrame.getContentPane(), BoxLayout.Y_AXIS));
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.add(sysNameLabel);
p.add(sysNameFixed);
p.add(sysName);
p.add(_autoSystemName);
_autoSystemName.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
autoSystemName();
}
});
if (pref.getSimplePreferenceState(systemNameAuto)) {
_autoSystemName.setSelected(true);
}
sysName.setToolTipText(rbx.getString("SectionSystemNameHint"));
p.add(new JLabel(" "));
p.add(userNameLabel);
p.add(userName);
userName.setToolTipText(rbx.getString("SectionUserNameHint"));
addFrame.getContentPane().add(p);
JPanel pa = new JPanel();
pa.setLayout(new FlowLayout());
pa.add(generationStateLabel);
addFrame.getContentPane().add(pa);
addFrame.getContentPane().add(new JSeparator());
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(new JLabel(rbx.getString("BlockTableMessage")));
p1.add(p11);
JPanel p12 = new JPanel();
// initialize table of blocks
blockTableModel = new BlockTableModel();
JTable blockTable = new JTable(blockTableModel);
blockTable.setRowSelectionAllowed(false);
blockTable.setPreferredScrollableViewportSize(new java.awt.Dimension(350, 100));
TableColumnModel blockColumnModel = blockTable.getColumnModel();
TableColumn sNameColumn = blockColumnModel.getColumn(BlockTableModel.SNAME_COLUMN);
sNameColumn.setResizable(true);
sNameColumn.setMinWidth(90);
sNameColumn.setMaxWidth(130);
TableColumn uNameColumn = blockColumnModel.getColumn(BlockTableModel.UNAME_COLUMN);
uNameColumn.setResizable(true);
uNameColumn.setMinWidth(210);
uNameColumn.setMaxWidth(260);
JScrollPane blockTableScrollPane = new JScrollPane(blockTable);
p12.add(blockTableScrollPane, BorderLayout.CENTER);
p1.add(p12);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(deleteBlocks = new JButton(rbx.getString("DeleteAllBlocksButton")));
deleteBlocks.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteBlocksPressed(e);
}
});
deleteBlocks.setToolTipText(rbx.getString("DeleteAllBlocksButtonHint"));
p13.add(new JLabel(" "));
p13.add(blockBox);
blockBox.setToolTipText(rbx.getString("BlockBoxHint"));
p13.add(addBlock = new JButton(rbx.getString("AddBlockButton")));
addBlock.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addBlockPressed(e);
}
});
addBlock.setToolTipText(rbx.getString("AddBlockButtonHint"));
p1.add(p13);
addFrame.getContentPane().add(p1);
addFrame.getContentPane().add(new JSeparator());
JPanel p31 = new JPanel();
p31.setLayout(new FlowLayout());
p31.add(new JLabel(rbx.getString("EntryPointTable")));
addFrame.getContentPane().add(p31);
JPanel p32 = new JPanel();
p32.setLayout(new FlowLayout());
entryPointOptions = new ButtonGroup();
p32.add(manually);
entryPointOptions.add(manually);
manually.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
manualEntryPoints = true;
}
});
manually.setToolTipText(rbx.getString("SetManuallyHint"));
p32.add(new JLabel(" "));
p32.add(automatic);
entryPointOptions.add(automatic);
automatic.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
manualEntryPoints = false;
}
});
automatic.setToolTipText(rbx.getString("SetAutomaticHint"));
p32.add(layoutEditorBox);
layoutEditorBox.setToolTipText(rbx.getString("LayoutEditorBoxHint"));
layoutEditorBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
layoutEditorSelectionChanged();
}
});
// djd debugging - temporarily hide these items until the automatic setting of entry point direction is ready
// addFrame.getContentPane().add(p32);
// end djd debugging
JPanel p33 = new JPanel();
// initialize table of entry points
entryPointTableModel = new EntryPointTableModel();
JTable entryPointTable = new JTable(entryPointTableModel);
entryPointTable.setRowSelectionAllowed(false);
// GT - 12-Oct-2009
entryPointTable.setPreferredScrollableViewportSize(new java.awt.Dimension(550, 100));
TableColumnModel entryPointColumnModel = entryPointTable.getColumnModel();
TableColumn fromBlockColumn = entryPointColumnModel.getColumn(EntryPointTableModel.BLOCK_COLUMN);
fromBlockColumn.setResizable(true);
fromBlockColumn.setMinWidth(250);
fromBlockColumn.setMaxWidth(310);
// GT - 12-Oct-2009 - start
TableColumn toBlockColumn = entryPointColumnModel.getColumn(EntryPointTableModel.TO_BLOCK_COLUMN);
toBlockColumn.setResizable(true);
toBlockColumn.setMinWidth(150);
toBlockColumn.setMaxWidth(210);
// GT - 12-Oct-2009 - end
JComboBox<String> directionCombo = new JComboBox<String>();
directionCombo.addItem(rbx.getString("SectionForward"));
directionCombo.addItem(rbx.getString("SectionReverse"));
directionCombo.addItem(Bundle.getMessage("BeanStateUnknown"));
TableColumn directionColumn = entryPointColumnModel.getColumn(EntryPointTableModel.DIRECTION_COLUMN);
directionColumn.setCellEditor(new DefaultCellEditor(directionCombo));
entryPointTable.setRowHeight(directionCombo.getPreferredSize().height);
directionColumn.setPreferredWidth(directionCombo.getPreferredSize().width);
directionColumn.setResizable(false);
JScrollPane entryPointTableScrollPane = new JScrollPane(entryPointTable);
p33.add(entryPointTableScrollPane, BorderLayout.CENTER);
addFrame.getContentPane().add(p33);
p33.setVisible(true);
JPanel p34 = new JPanel();
p34.setLayout(new FlowLayout());
p34.add(new JLabel(rbx.getString("DirectionNote")));
addFrame.getContentPane().add(p34);
addFrame.getContentPane().add(new JSeparator());
// set up for direction sensors
JPanel p20 = new JPanel();
p20.setLayout(new FlowLayout());
p20.add(new JLabel(rbx.getString("DirectionSensorLabel")));
addFrame.getContentPane().add(p20);
JPanel p21 = new JPanel();
p21.setLayout(new FlowLayout());
p21.add(new JLabel(rbx.getString("ForwardSensor")));
p21.add(forwardSensorField);
forwardSensorField.setToolTipText(rbx.getString("ForwardSensorHint"));
p21.add(new JLabel(" "));
p21.add(new JLabel(rbx.getString("ReverseSensor")));
p21.add(reverseSensorField);
reverseSensorField.setToolTipText(rbx.getString("ReverseSensorHint"));
addFrame.getContentPane().add(p21);
addFrame.getContentPane().add(new JSeparator());
// set up for stopping sensors
JPanel p40 = new JPanel();
p40.setLayout(new FlowLayout());
p40.add(new JLabel(rbx.getString("StoppingSensorLabel")));
addFrame.getContentPane().add(p40);
JPanel p41 = new JPanel();
p41.setLayout(new FlowLayout());
p41.add(new JLabel(rbx.getString("ForwardStopSensor")));
p41.add(forwardStopSensorField);
forwardStopSensorField.setToolTipText(rbx.getString("ForwardStopSensorHint"));
p41.add(new JLabel(" "));
p41.add(new JLabel(rbx.getString("ReverseStopSensor")));
p41.add(reverseStopSensorField);
reverseStopSensorField.setToolTipText(rbx.getString("ReverseStopSensorHint"));
addFrame.getContentPane().add(p41);
addFrame.getContentPane().add(new JSeparator());
// set up bottom buttons
JButton cancel = null;
JPanel pb = new JPanel();
pb.setLayout(new FlowLayout());
pb.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelPressed(e);
}
});
cancel.setToolTipText(rbx.getString("CancelButtonHint"));
pb.add(create = new JButton(Bundle.getMessage("ButtonCreate")));
create.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
createPressed(e);
}
});
create.setToolTipText(rbx.getString("SectionCreateButtonHint"));
pb.add(update = new JButton(Bundle.getMessage("ButtonUpdate")));
update.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatePressed(e);
}
});
update.setToolTipText(rbx.getString("SectionUpdateButtonHint"));
addFrame.getContentPane().add(pb);
}
if (editMode) {
// setup for edit window
_autoSystemName.setVisible(false);
sysNameLabel.setEnabled(true);
create.setVisible(false);
update.setVisible(true);
sysName.setVisible(false);
sysNameFixed.setVisible(true);
initializeEditInformation();
} else {
// setup for create window
_autoSystemName.setVisible(true);
create.setVisible(true);
update.setVisible(false);
sysName.setVisible(true);
sysNameFixed.setVisible(false);
autoSystemName();
clearForCreate();
}
// initialize layout editor panels
if (initializeLayoutEditorCombo(layoutEditorBox)) {
manually.setVisible(true);
automatic.setVisible(true);
layoutEditorBox.setVisible(true);
} else {
manually.setVisible(false);
automatic.setVisible(false);
layoutEditorBox.setVisible(false);
}
// initialize block combo - first time
initializeBlockCombo();
addFrame.pack();
addFrame.setVisible(true);
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class ImageIndexEditor method init.
private void init(Editor editor) {
JMenuBar menuBar = new JMenuBar();
JMenu findIcon = new JMenu(Bundle.getMessage("MenuFile"));
menuBar.add(findIcon);
JMenuItem storeItem = new JMenuItem(Bundle.getMessage("MIStoreImageIndex"));
findIcon.add(storeItem);
storeItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
storeImageIndex();
}
});
findIcon.addSeparator();
JMenuItem openItem = new JMenuItem(Bundle.getMessage("openDirMenu"));
openItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DirectorySearcher.instance().openDirectory();
}
});
findIcon.add(openItem);
JMenuItem searchItem = new JMenuItem(Bundle.getMessage("searchFSMenu"));
searchItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jmri.jmrit.catalog.DirectorySearcher.instance().searchFS();
}
});
findIcon.add(searchItem);
JMenu editMenu = new JMenu(Bundle.getMessage("EditIndexMenu"));
menuBar.add(editMenu);
JMenuItem addItem = new JMenuItem(Bundle.getMessage("addNode"));
addItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addNode();
}
});
editMenu.add(addItem);
JMenuItem renameItem = new JMenuItem(Bundle.getMessage("renameNode"));
renameItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
renameNode();
}
});
editMenu.add(renameItem);
JMenuItem deleteItem = new JMenuItem(Bundle.getMessage("deleteNode"));
deleteItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteNode();
}
});
editMenu.add(deleteItem);
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.catalog.ImageIndex", true);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel labelPanel = new JPanel();
labelPanel.add(new JLabel(Bundle.getMessage("dragIconsInstr"), SwingConstants.LEFT));
mainPanel.add(labelPanel);
JPanel catalogsPanel = new JPanel();
catalogsPanel.setLayout(new BoxLayout(catalogsPanel, BoxLayout.X_AXIS));
catalogsPanel.add(makeCatalogPanel());
catalogsPanel.add(new JSeparator(SwingConstants.VERTICAL));
catalogsPanel.add(makeIndexPanel());
mainPanel.add(catalogsPanel);
getContentPane().add(mainPanel);
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
DirectorySearcher.instance().close();
}
});
setLocation(10, 200);
pack();
setVisible(true);
}
use of javax.swing.JSeparator 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 javax.swing.JSeparator in project JMRI by JMRI.
the class LayoutTurnout method showPopUp.
/**
* Display popup menu for information and editing
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
if (layoutEditor.isEditable()) {
JMenuItem jmi = null;
switch(getTurnoutType()) {
case RH_TURNOUT:
jmi = popup.add(Bundle.getMessage("RightTurnout"));
break;
case LH_TURNOUT:
jmi = popup.add(Bundle.getMessage("LeftTurnout"));
break;
case WYE_TURNOUT:
jmi = popup.add(rb.getString("WYETurnout"));
break;
case DOUBLE_XOVER:
jmi = popup.add(rb.getString("DoubleCrossOver"));
break;
case RH_XOVER:
jmi = popup.add(Bundle.getMessage("RightCrossOver"));
break;
case LH_XOVER:
jmi = popup.add(Bundle.getMessage("LeftCrossOver"));
break;
default:
break;
}
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
if (getTurnout() == null) {
jmi = popup.add(rb.getString("NoTurnout"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameTurnout") + ": " + turnoutName);
}
jmi.setEnabled(false);
if (blockName.equals("")) {
jmi = popup.add(rb.getString("NoBlock"));
} else {
jmi = popup.add(Bundle.getMessage("BeanNameBlock") + ": " + getLayoutBlock().getID());
}
jmi.setEnabled(false);
if ((type == DOUBLE_XOVER) || (type == RH_XOVER) || (type == LH_XOVER)) {
// check if extra blocks have been entered
if (blockB != null) {
jmi = popup.add(Bundle.getMessage("Block_ID", 2) + ": " + blockBName);
jmi.setEnabled(false);
}
if (blockC != null) {
jmi = popup.add(Bundle.getMessage("Block_ID", 3) + ": " + blockCName);
jmi.setEnabled(false);
}
if (blockD != null) {
jmi = popup.add(Bundle.getMessage("Block_ID", 4) + ": " + blockDName);
jmi.setEnabled(false);
}
}
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
// Rotate if there are no track connections
if ((connectA == null) && (connectB == null) && (connectC == null) && (connectD == null)) {
JMenuItem rotateItem = new JMenuItem(rb.getString("Rotate") + "...");
popup.add(rotateItem);
rotateItem.addActionListener((ActionEvent event) -> {
boolean entering = true;
boolean error = false;
String newAngle = "";
while (entering) {
// prompt for rotation angle
error = false;
newAngle = JOptionPane.showInputDialog(layoutEditor, rb.getString("EnterRotation") + " :");
if (newAngle.length() < 1) {
// cancelled
return;
}
double rot = 0.0;
try {
rot = Double.parseDouble(newAngle);
} catch (Exception e1) {
JOptionPane.showMessageDialog(layoutEditor, rb.getString("Error3") + " " + e1, Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
error = true;
newAngle = "";
}
if (!error) {
entering = false;
if (rot != 0.0) {
rotateCoords(rot);
layoutEditor.redrawPanel();
}
}
}
});
}
if (disableItem == null) {
disableItem = new JCheckBoxMenuItem(Bundle.getMessage("Disabled"));
}
disableItem.setSelected(disabled);
popup.add(disableItem);
disableItem.addActionListener((java.awt.event.ActionEvent e2) -> {
disabled = disableItem.isSelected();
});
if (disableWhenOccupiedItem == null) {
disableWhenOccupiedItem = new JCheckBoxMenuItem(rb.getString("DisabledWhenOccupied"));
}
disableWhenOccupiedItem.setSelected(disableWhenOccupied);
popup.add(disableWhenOccupiedItem);
disableWhenOccupiedItem.addActionListener((java.awt.event.ActionEvent e3) -> {
disableWhenOccupied = disableWhenOccupiedItem.isSelected();
});
popup.add(new AbstractAction(rb.getString("UseSizeAsDefault")) {
@Override
public void actionPerformed(ActionEvent e) {
setUpDefaultSize();
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editLayoutTurnout();
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutEditor.removeLayoutTurnout(instance)) {
// Returned true if user did not cancel
remove();
dispose();
}
}
});
if (getTurnout() != null) {
popup.add(new AbstractAction(rb.getString("SetSignals")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
if ((getTurnoutType() == DOUBLE_XOVER) || (getTurnoutType() == RH_XOVER) || (getTurnoutType() == LH_XOVER)) {
tools.setSignalsAtXoverTurnoutFromMenu(instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == NO_LINK) {
tools.setSignalsAtTurnoutFromMenu(instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == THROAT_TO_THROAT) {
tools.setThroatToThroatFromMenu(instance, linkedTurnoutName, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == FIRST_3_WAY) {
tools.set3WayFromMenu(turnoutName, linkedTurnoutName, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
} else if (linkType == SECOND_3_WAY) {
tools.set3WayFromMenu(linkedTurnoutName, turnoutName, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
}
}
});
}
if (!blockName.equals("")) {
final String[] boundaryBetween = getBlockBoundaries();
boolean blockBoundaries = false;
for (int i = 0; i < 4; i++) {
if (boundaryBetween[i] != null) {
blockBoundaries = true;
}
}
if (InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled()) {
if (blockBName.equals("") && blockCName.equals("") && blockDName.equals("")) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
routeTableAction.actionPerformed(e);
}
});
} else {
JMenu viewRouting = new JMenu(rb.getString("ViewBlockRouting"));
viewRouting.add(new AbstractAction(blockName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockName, getLayoutBlock());
routeTableAction.actionPerformed(e);
}
});
if (!blockBName.equals("") && !blockBName.equals(blockName)) {
viewRouting.add(new AbstractAction(blockBName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockBName, getLayoutBlockB());
routeTableAction.actionPerformed(e);
}
});
}
if (!blockCName.equals("") && !blockCName.equals(blockName) && !blockCName.equals(blockBName)) {
viewRouting.add(new AbstractAction(blockCName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockCName, getLayoutBlockC());
routeTableAction.actionPerformed(e);
}
});
}
if (!blockDName.equals("") && !blockDName.equals(blockName) && !blockDName.equals(blockBName) && !blockDName.equals(blockCName)) {
viewRouting.add(new AbstractAction(blockDName) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockDName, getLayoutBlockD());
routeTableAction.actionPerformed(e);
}
});
}
popup.add(viewRouting);
}
}
if (blockBoundaries) {
popup.add(new AbstractAction(rb.getString("SetSignalMasts")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSignalMastsAtTurnoutFromMenu(instance, boundaryBetween);
}
});
popup.add(new AbstractAction(rb.getString("SetSensors")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSensorsAtTurnoutFromMenu(instance, boundaryBetween, layoutEditor.sensorIconEditor, layoutEditor.sensorFrame);
}
});
}
}
setAdditionalEditPopUpMenu(popup);
layoutEditor.setShowAlignmentMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
} else if (!viewAdditionalMenu.isEmpty()) {
setAdditionalViewPopUpMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class LevelXing method showPopUp.
/**
* Display popup menu for information and editing
*/
protected void showPopUp(MouseEvent e) {
if (popup != null) {
popup.removeAll();
} else {
popup = new JPopupMenu();
}
if (layoutEditor.isEditable()) {
JMenuItem jmi = popup.add(rb.getString("LevelCrossing"));
jmi.setEnabled(false);
jmi = popup.add(ident);
jmi.setEnabled(false);
boolean blockACAssigned = false;
boolean blockBDAssigned = false;
if ((blockNameAC == null) || (blockNameAC.equals(""))) {
jmi = popup.add(Bundle.getMessage("NoBlockX", 1));
} else {
jmi = popup.add(Bundle.getMessage("Block_ID", 1) + ": " + getLayoutBlockAC().getID());
blockACAssigned = true;
}
jmi.setEnabled(false);
if ((blockNameBD == null) || (blockNameBD.equals(""))) {
jmi = popup.add(Bundle.getMessage("NoBlockX", 2));
} else {
jmi = popup.add(Bundle.getMessage("Block_ID", 2) + ": " + getLayoutBlockBD().getID());
blockBDAssigned = true;
}
jmi.setEnabled(false);
if (hidden) {
jmi = popup.add(rb.getString("Hidden"));
} else {
jmi = popup.add(rb.getString("NotHidden"));
}
jmi.setEnabled(false);
popup.add(new JSeparator(JSeparator.HORIZONTAL));
popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {
@Override
public void actionPerformed(ActionEvent e) {
editLevelXing(instance);
}
});
popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutEditor.removeLevelXing(instance)) {
// Returned true if user did not cancel
remove();
dispose();
}
}
});
if (blockACAssigned && blockBDAssigned) {
popup.add(new AbstractAction(rb.getString("SetSignals")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
// bring up signals at level crossing tool dialog
tools.setSignalsAtLevelXingFromMenu(instance, layoutEditor.signalIconEditor, layoutEditor.signalFrame);
}
});
}
final String[] boundaryBetween = getBlockBoundaries();
boolean blockBoundaries = false;
if (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled()) {
if (blockACAssigned && !blockBDAssigned) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlockAC());
routeTableAction.actionPerformed(e);
}
});
} else if (!blockACAssigned && blockBDAssigned) {
popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlockBD());
routeTableAction.actionPerformed(e);
}
});
} else if (blockACAssigned && blockBDAssigned) {
JMenu viewRouting = new JMenu(rb.getString("ViewBlockRouting"));
viewRouting.add(new AbstractAction(blockNameAC) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockNameAC, getLayoutBlockAC());
routeTableAction.actionPerformed(e);
}
});
viewRouting.add(new AbstractAction(blockNameBD) {
@Override
public void actionPerformed(ActionEvent e) {
AbstractAction routeTableAction = new LayoutBlockRouteTableAction(blockNameBD, getLayoutBlockBD());
routeTableAction.actionPerformed(e);
}
});
popup.add(viewRouting);
}
}
for (int i = 0; i < 4; i++) {
if (boundaryBetween[i] != null) {
blockBoundaries = true;
}
}
if (blockBoundaries) {
popup.add(new AbstractAction(rb.getString("SetSignalMasts")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSignalMastsAtLevelXingFromMenu(instance, boundaryBetween, layoutEditor.signalFrame);
}
});
popup.add(new AbstractAction(rb.getString("SetSensors")) {
@Override
public void actionPerformed(ActionEvent e) {
if (tools == null) {
tools = new LayoutEditorTools(layoutEditor);
}
tools.setSensorsAtLevelXingFromMenu(instance, boundaryBetween, layoutEditor.sensorIconEditor, layoutEditor.sensorFrame);
}
});
}
layoutEditor.setShowAlignmentMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
} else if (!viewAdditionalMenu.isEmpty()) {
setAdditionalViewPopUpMenu(popup);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
Aggregations