use of javax.swing.JMenuBar in project JMRI by JMRI.
the class LocationsByCarTypeFrame method initComponents.
public void initComponents(String carType) {
// load managers
manager = LocationManager.instance();
// general GUI config
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// Set up the panels
JPanel pCarType = new JPanel();
pCarType.setLayout(new GridBagLayout());
pCarType.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Type")));
addItem(pCarType, typeComboBox, 0, 0);
addItem(pCarType, copyCheckBox, 1, 0);
addItem(pCarType, textCarType, 2, 0);
typeComboBox.setSelectedItem(carType);
copyCheckBox.setToolTipText(Bundle.getMessage("TipCopyCarType"));
pLocations = new JPanel();
pLocations.setLayout(new GridBagLayout());
JScrollPane locationPane = new JScrollPane(pLocations);
locationPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
locationPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Locations")));
updateLocations();
JPanel pButtons = new JPanel();
pButtons.setLayout(new GridBagLayout());
pButtons.setBorder(BorderFactory.createTitledBorder(""));
addItem(pButtons, clearButton, 0, 0);
addItem(pButtons, setButton, 1, 0);
addItem(pButtons, saveButton, 2, 0);
getContentPane().add(pCarType);
getContentPane().add(locationPane);
getContentPane().add(pButtons);
// setup combo box
addComboBoxAction(typeComboBox);
// setup buttons
addButtonAction(setButton);
addButtonAction(clearButton);
addButtonAction(saveButton);
// setup checkbox
addCheckBoxAction(copyCheckBox);
manager.addPropertyChangeListener(this);
CarTypes.instance().addPropertyChangeListener(this);
// build menu
JMenuBar menuBar = new JMenuBar();
JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
toolMenu.add(new PrintLocationsByCarTypesAction(Bundle.getMessage("MenuItemPrintByType"), new Frame(), false, this));
toolMenu.add(new PrintLocationsByCarTypesAction(Bundle.getMessage("MenuItemPreviewByType"), new Frame(), true, this));
menuBar.add(toolMenu);
setJMenuBar(menuBar);
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_ModifyLocationsByCarType", true);
// we need to resize this frame
setPreferredSize(null);
pack();
setMinimumSize(new Dimension(Control.panelWidth300, Control.panelHeight250));
// make a bit wider to eliminate scroll bar
setSize(getWidth() + 25, getHeight());
if (_location != null) {
setTitle(Bundle.getMessage("TitleModifyLocation"));
} else {
setTitle(Bundle.getMessage("TitleModifyLocations"));
}
setVisible(true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class CarSetFrame method initComponents.
@Override
public void initComponents() {
super.initComponents();
// build menu
JMenuBar menuBar = new JMenuBar();
JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
toolMenu.add(new EnableDestinationAction(Bundle.getMessage("MenuEnableDestination"), this));
menuBar.add(toolMenu);
setJMenuBar(menuBar);
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_CarsSet", true);
// optional panel return when empty, load, and kernel
paneOptional.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutOptional")));
pOptional.setLayout(new BoxLayout(pOptional, BoxLayout.Y_AXIS));
// row 5
JPanel pReturnWhenEmpty = new JPanel();
pReturnWhenEmpty.setLayout(new GridBagLayout());
pReturnWhenEmpty.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutReturnWhenEmpty")));
addItem(pReturnWhenEmpty, new JLabel(Bundle.getMessage("Location")), 1, 0);
addItem(pReturnWhenEmpty, new JLabel(Bundle.getMessage("Track")), 2, 0);
addItem(pReturnWhenEmpty, new JLabel(Bundle.getMessage("Load")), 3, 0);
addItemLeft(pReturnWhenEmpty, ignoreRWECheckBox, 0, 1);
addItem(pReturnWhenEmpty, destReturnWhenEmptyBox, 1, 1);
addItem(pReturnWhenEmpty, trackReturnWhenEmptyBox, 2, 1);
addItem(pReturnWhenEmpty, loadReturnWhenEmptyBox, 3, 1);
addItem(pReturnWhenEmpty, autoReturnWhenEmptyTrackCheckBox, 4, 1);
pOptional.add(pReturnWhenEmpty);
// add load fields
JPanel pLoad = new JPanel();
pLoad.setLayout(new GridBagLayout());
pLoad.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Load")));
addItemLeft(pLoad, ignoreLoadCheckBox, 1, 0);
addItem(pLoad, loadComboBox, 2, 0);
addItem(pLoad, editLoadButton, 3, 0);
pOptional.add(pLoad);
// add kernel fields
JPanel pKernel = new JPanel();
pKernel.setLayout(new GridBagLayout());
pKernel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Kernel")));
addItemLeft(pKernel, ignoreKernelCheckBox, 1, 0);
addItem(pKernel, kernelComboBox, 2, 0);
addItem(pKernel, editKernelButton, 3, 0);
pOptional.add(pKernel);
// don't show ignore checkboxes
ignoreRWECheckBox.setVisible(false);
ignoreLoadCheckBox.setVisible(false);
ignoreKernelCheckBox.setVisible(false);
autoReturnWhenEmptyTrackCheckBox.setSelected(autoReturnWhenEmptyTrackCheckBoxSelected);
// setup combobox
addComboBoxAction(destReturnWhenEmptyBox);
addComboBoxAction(loadComboBox);
// setup button
addButtonAction(editLoadButton);
addButtonAction(editKernelButton);
// setup checkboxes
addCheckBoxAction(ignoreRWECheckBox);
addCheckBoxAction(autoReturnWhenEmptyTrackCheckBox);
addCheckBoxAction(ignoreLoadCheckBox);
addCheckBoxAction(ignoreKernelCheckBox);
// tool tips
ignoreRWECheckBox.setToolTipText(Bundle.getMessage("TipIgnore"));
ignoreLoadCheckBox.setToolTipText(Bundle.getMessage("TipIgnore"));
ignoreKernelCheckBox.setToolTipText(Bundle.getMessage("TipIgnore"));
outOfServiceCheckBox.setToolTipText(Bundle.getMessage("TipCarOutOfService"));
autoReturnWhenEmptyTrackCheckBox.setToolTipText(Bundle.getMessage("rsTipAutoTrack"));
// get notified if combo box gets modified
CarLoads.instance().addPropertyChangeListener(this);
carManager.addPropertyChangeListener(this);
packFrame();
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class TrainSwitchListEditFrame method initComponents.
@Override
public void initComponents() {
// listen for any changes in the number of locations
locationManager.addPropertyChangeListener(this);
// the following code sets the frame's initial state
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// tool tips
switchListRealTimeCheckBox.setToolTipText(Bundle.getMessage("RealTimeTip"));
switchListAllTrainsCheckBox.setToolTipText(Bundle.getMessage("AllTrainsTip"));
switchListPageComboBox.setToolTipText(Bundle.getMessage("PageTrainTip"));
csvChangeButton.setToolTipText(Bundle.getMessage("CsvChangesTip"));
printChangesButton.setToolTipText(Bundle.getMessage("PrintChangesTip"));
resetButton.setToolTipText(Bundle.getMessage("ResetSwitchListTip"));
switchPane = new JScrollPane(locationPanelCheckBoxes);
switchPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
switchPane.setBorder(BorderFactory.createTitledBorder(""));
// Layout the panel by rows
locationPanelCheckBoxes.setLayout(new GridBagLayout());
updateLocationCheckboxes();
enableChangeButtons();
// Clear and set buttons
JPanel pButtons = new JPanel();
pButtons.setLayout(new GridBagLayout());
pButtons.setBorder(BorderFactory.createTitledBorder(""));
addItem(pButtons, clearButton, 0, 1);
addItem(pButtons, setButton, 1, 1);
// options
JPanel pSwitchListOptions = new JPanel();
pSwitchListOptions.setLayout(new GridBagLayout());
pSwitchListOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutSwitchListOptions")));
JPanel pSwitchListPageFormat = new JPanel();
pSwitchListPageFormat.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutSwitchListPageFormat")));
pSwitchListPageFormat.add(switchListPageComboBox);
addItem(pSwitchListOptions, switchListAllTrainsCheckBox, 1, 0);
addItem(pSwitchListOptions, pSwitchListPageFormat, 2, 0);
addItem(pSwitchListOptions, switchListRealTimeCheckBox, 3, 0);
addItem(pSwitchListOptions, saveButton, 4, 0);
// buttons
JPanel controlPanel = new JPanel();
controlPanel.setLayout(new GridBagLayout());
controlPanel.setBorder(BorderFactory.createTitledBorder(""));
// row 3
addItem(controlPanel, previewButton, 0, 2);
addItem(controlPanel, printButton, 1, 2);
addItem(controlPanel, printChangesButton, 2, 2);
// row 4
addItem(controlPanel, updateButton, 0, 3);
addItem(controlPanel, resetButton, 1, 3);
// row 5
customPanel = new JPanel();
customPanel.setLayout(new GridBagLayout());
customPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutCustomSwitchLists")));
addItem(customPanel, csvGenerateButton, 1, 4);
addItem(customPanel, csvChangeButton, 2, 4);
addItem(customPanel, runButton, 1, 5);
addItem(customPanel, runChangeButton, 2, 5);
getContentPane().add(switchPane);
getContentPane().add(pButtons);
getContentPane().add(pSwitchListOptions);
getContentPane().add(controlPanel);
getContentPane().add(customPanel);
customPanel.setVisible(Setup.isGenerateCsvSwitchListEnabled());
// Set the state
switchListRealTimeCheckBox.setSelected(Setup.isSwitchListRealTime());
switchListAllTrainsCheckBox.setSelected(Setup.isSwitchListAllTrainsEnabled());
switchListPageComboBox.setSelectedItem(Setup.getSwitchListPageFormat());
updateButton.setVisible(!switchListRealTimeCheckBox.isSelected());
resetButton.setVisible(!switchListRealTimeCheckBox.isSelected());
saveButton.setEnabled(false);
addButtonAction(clearButton);
addButtonAction(setButton);
addButtonAction(printButton);
addButtonAction(previewButton);
addButtonAction(printChangesButton);
addButtonAction(runButton);
addButtonAction(runChangeButton);
addButtonAction(csvGenerateButton);
addButtonAction(csvChangeButton);
addButtonAction(updateButton);
addButtonAction(resetButton);
addButtonAction(saveButton);
addCheckBoxAction(switchListRealTimeCheckBox);
addCheckBoxAction(switchListAllTrainsCheckBox);
addComboBoxAction(switchListPageComboBox);
Setup.addPropertyChangeListener(this);
// build menu
JMenuBar menuBar = new JMenuBar();
JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
toolMenu.add(new SetupExcelProgramSwitchListFrameAction(Bundle.getMessage("MenuItemSetupExcelProgramSwitchList")));
menuBar.add(toolMenu);
setJMenuBar(menuBar);
// add help menu to window
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_SwitchList", true);
// set frame size and train for display
initMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight500));
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class PaneProgDp3Action method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// NOI18N
log.debug("Pane programmer requested");
if (f == null) {
log.debug("found f==null");
// create the initial frame that steers
// NOI18N
f = new JmriJFrame(apps.gui3.dp3.Bundle.getMessage("FrameProgrammerSetup"));
f.getContentPane().setLayout(new BorderLayout());
// ensure status line is cleared on close so it is normal if re-opened
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
// NOI18N
statusLabel.setText(SymbolicProgBundle.getMessage("StateIdle"));
f.windowClosing(we);
}
});
// add the Roster menu
JMenuBar menuBar = new JMenuBar();
// NOI18N
JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
// NOI18N
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
// NOI18N
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
menuBar.add(j);
// NOI18N
menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
f.setJMenuBar(menuBar);
final JPanel bottomPanel = new JPanel(new BorderLayout());
// new Loco on programming track
combinedLocoSelTree = new CombinedLocoSelTreePane(statusLabel, modePane) {
@Override
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String progName) {
// progName is ignored here
log.debug("startProgrammer");
String title = // NOI18N
java.text.MessageFormat.format(// NOI18N
SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), // NOI18N
new Object[] { Bundle.getMessage("NewDecoder") });
if (re != null) {
title = // NOI18N
java.text.MessageFormat.format(// NOI18N
SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { re.getId() });
}
JFrame p;
if (!modePane.isSelected() || modePane.getProgrammer() == null) {
p = new PaneProgFrame(decoderFile, re, // NOI18N
title, // NOI18N
"programmers" + File.separator + "Comprehensive.xml", null, false) {
@Override
protected JPanel getModePane() {
return null;
}
};
} else {
p = new PaneServiceProgFrame(decoderFile, re, // NOI18N
title, // NOI18N
"programmers" + File.separator + "Comprehensive.xml", modePane.getProgrammer());
}
p.pack();
p.setVisible(true);
}
@Override
protected void openNewLoco() {
log.debug("openNewLoco");
// find the decoderFile object
DecoderFile decoderFile = DecoderIndexFile.instance().fileFromTitle(selectedDecoderType());
// NOI18N
log.debug("decoder file: {}", decoderFile.getFilename());
if (rosterIdField.getText().equals(SymbolicProgBundle.getMessage("LabelNewDecoder"))) {
// NOI18N
re = new RosterEntry();
re.setDecoderFamily(decoderFile.getFamily());
re.setDecoderModel(decoderFile.getModel());
// NOI18N
re.setId(SymbolicProgBundle.getMessage("LabelNewDecoder"));
//re.writeFile(cvModel, iCvModel, variableModel );
// note that we're leaving the filename null
// add the new roster entry to the in-memory roster
Roster.getDefault().addEntry(re);
} else {
try {
saveRosterEntry();
} catch (JmriException ex) {
// NOI18N
log.warn("Exception while saving roster entry", ex);
return;
}
}
// create a dummy RosterEntry with the decoder info
// no programmer name in this case
startProgrammer(decoderFile, re, "");
//Set our roster entry back to null so that a fresh roster entry can be created if needed
re = null;
}
@Override
protected JPanel layoutRosterSelection() {
log.debug("layoutRosterSelection");
return null;
}
@Override
protected JPanel layoutDecoderSelection() {
log.debug("layoutDecoderSelection");
JPanel pan = super.layoutDecoderSelection();
dTree.removeTreeSelectionListener(dListener);
dTree.addTreeSelectionListener(dListener = new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
if (!dTree.isSelectionEmpty() && dTree.getSelectionPath() != null && // check that this isn't just a model
((TreeNode) dTree.getSelectionPath().getLastPathComponent()).isLeaf() && // can't be just a mfg, has to be at least a family
dTree.getSelectionPath().getPathCount() > 2 && // can't be a multiple decoder selection
dTree.getSelectionCount() < 2) {
log.debug("Selection event with " + dTree.getSelectionPath().toString());
//if (locoBox != null) locoBox.setSelectedIndex(0);
go2.setEnabled(true);
go2.setRequestFocusEnabled(true);
go2.requestFocus();
// NOI18N
go2.setToolTipText(SymbolicProgBundle.getMessage("TipClickToOpen"));
decoderFile = DecoderIndexFile.instance().fileFromTitle(selectedDecoderType());
setUpRosterPanel();
} else {
decoderFile = null;
// decoder not selected - require one
go2.setEnabled(false);
// NOI18N
go2.setToolTipText(SymbolicProgBundle.getMessage("TipSelectLoco"));
setUpRosterPanel();
}
}
});
return pan;
}
@Override
protected void selectDecoder(int mfgID, int modelID, int productID) {
log.debug("selectDecoder");
//On selecting a new decoder start a fresh with a new roster entry
super.selectDecoder(mfgID, modelID, productID);
findDecoderAddress();
}
@Override
protected JPanel createProgrammerSelection() {
log.debug("createProgrammerSelection");
JPanel pane3a = new JPanel();
pane3a.setLayout(new BoxLayout(pane3a, BoxLayout.Y_AXIS));
// NOI18N
go2 = new JButton(Bundle.getMessage("OpenProgrammer"));
go2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
// NOI18N
log.debug("Open programmer pressed");
openButton();
// close this window to prevent having
// two windows processing at the same time
//
// Alternately, could have just cleared out a
// bunch of stuff to force starting over, but
// that seems to be an even more confusing
// user experience.
log.debug("Closing f {}", f);
WindowEvent wev = new WindowEvent(f, WindowEvent.WINDOW_CLOSING);
java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);
}
});
go2.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
go2.setEnabled(false);
// NOI18N
go2.setToolTipText(SymbolicProgBundle.getMessage("TipSelectLoco"));
bottomPanel.add(go2, BorderLayout.EAST);
return pane3a;
}
};
// load primary frame
JPanel topPanel = new JPanel();
topPanel.add(modePane);
topPanel.add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
f.getContentPane().add(topPanel, BorderLayout.NORTH);
//f.getContentPane().add(modePane);
//f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
combinedLocoSelTree.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(combinedLocoSelTree, BorderLayout.CENTER);
//f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
//basicRoster.setEnabled(false);
statusLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
bottomPanel.add(statusLabel, BorderLayout.SOUTH);
f.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
f.pack();
// NOI18N
log.debug("Tab-Programmer setup created");
} else {
re = null;
combinedLocoSelTree.resetSelections();
}
f.setVisible(true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class AudioTableAction method setMenuBar.
@Override
public void setMenuBar(BeanTableFrame f) {
JMenuBar menuBar = f.getJMenuBar();
ResourceBundle rbapps = ResourceBundle.getBundle("apps.AppsBundle");
MenuElement[] subElements;
JMenu fileMenu = null;
for (int i = 0; i < menuBar.getMenuCount(); i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuFile"))) {
fileMenu = menuBar.getMenu(i);
}
}
}
if (fileMenu == null) {
return;
}
subElements = fileMenu.getSubElements();
for (MenuElement subElement : subElements) {
MenuElement[] popsubElements = subElement.getSubElements();
for (MenuElement popsubElement : popsubElements) {
if (popsubElement instanceof JMenuItem) {
if (((JMenuItem) popsubElement).getText().equals(rbapps.getString("PrintTable"))) {
JMenuItem printMenu = (JMenuItem) popsubElement;
fileMenu.remove(printMenu);
break;
}
}
}
}
fileMenu.add(atp.getPrintItem());
}
Aggregations