use of javax.swing.JMenuBar in project JMRI by JMRI.
the class PaneProgFrame method installComponents.
protected void installComponents() {
// create ShutDownTasks
if (jmri.InstanceManager.getNullableDefault(jmri.ShutDownManager.class) != null) {
if (decoderDirtyTask == null) {
decoderDirtyTask = new SwingShutDownTask("DecoderPro Decoder Window Check", Bundle.getMessage("PromptQuitWindowNotWrittenDecoder"), (String) null, this) {
@Override
public boolean checkPromptNeeded() {
return !checkDirtyDecoder();
}
};
}
jmri.InstanceManager.getDefault(jmri.ShutDownManager.class).register(decoderDirtyTask);
if (fileDirtyTask == null) {
fileDirtyTask = new SwingShutDownTask("DecoderPro Decoder Window Check", Bundle.getMessage("PromptQuitWindowNotWrittenConfig"), Bundle.getMessage("PromptSaveQuit"), this) {
@Override
public boolean checkPromptNeeded() {
return !checkDirtyFile();
}
@Override
public boolean doPrompt() {
// storeFile false if failed, abort shutdown
boolean result = storeFile();
return result;
}
};
}
jmri.InstanceManager.getDefault(jmri.ShutDownManager.class).register(fileDirtyTask);
}
// Create a menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
// add a "File" menu
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
menuBar.add(fileMenu);
// add a "Factory Reset" menu
resetMenu = new JMenu(Bundle.getMessage("MenuReset"));
menuBar.add(resetMenu);
resetMenu.add(new FactoryResetAction(Bundle.getMessage("MenuFactoryReset"), resetModel, this));
resetMenu.setEnabled(false);
// Add a save item
fileMenu.add(new AbstractAction(Bundle.getMessage("MenuSave")) {
@Override
public void actionPerformed(ActionEvent e) {
storeFile();
}
});
JMenu printSubMenu = new JMenu(Bundle.getMessage("MenuPrint"));
printSubMenu.add(new PrintAction(Bundle.getMessage("MenuPrintAll"), this, false));
printSubMenu.add(new PrintCvAction(Bundle.getMessage("MenuPrintCVs"), cvModel, this, false, _rosterEntry));
fileMenu.add(printSubMenu);
JMenu printPreviewSubMenu = new JMenu(Bundle.getMessage("MenuPrintPreview"));
printPreviewSubMenu.add(new PrintAction(Bundle.getMessage("MenuPrintPreviewAll"), this, true));
printPreviewSubMenu.add(new PrintCvAction(Bundle.getMessage("MenuPrintPreviewCVs"), cvModel, this, true, _rosterEntry));
fileMenu.add(printPreviewSubMenu);
// add "Import" submenu; this is heirarchical because
// some of the names are so long, and we expect more formats
JMenu importSubMenu = new JMenu(Bundle.getMessage("MenuImport"));
fileMenu.add(importSubMenu);
importSubMenu.add(new CsvImportAction(Bundle.getMessage("MenuImportCSV"), cvModel, this, progStatus));
importSubMenu.add(new Pr1ImportAction(Bundle.getMessage("MenuImportPr1"), cvModel, this, progStatus));
importSubMenu.add(new LokProgImportAction(Bundle.getMessage("MenuImportLokProg"), cvModel, this, progStatus));
importSubMenu.add(new QuantumCvMgrImportAction(Bundle.getMessage("MenuImportQuantumCvMgr"), cvModel, this, progStatus));
// add "Export" submenu; this is heirarchical because
// some of the names are so long, and we expect more formats
JMenu exportSubMenu = new JMenu(Bundle.getMessage("MenuExport"));
fileMenu.add(exportSubMenu);
exportSubMenu.add(new CsvExportAction(Bundle.getMessage("MenuExportCSV"), cvModel, this));
exportSubMenu.add(new Pr1ExportAction(Bundle.getMessage("MenuExportPr1DOS"), cvModel, this));
exportSubMenu.add(new Pr1WinExportAction(Bundle.getMessage("MenuExportPr1WIN"), cvModel, this));
// to control size, we need to insert a single
// JPanel, then have it laid out with BoxLayout
JPanel pane = new JPanel();
tempPane = pane;
// general GUI config
pane.setLayout(new BorderLayout());
// configure GUI elements
// set read buttons enabled state, tooltips
enableReadButtons();
readChangesButton.addItemListener(l1 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(readChangesButton);
readChangesButton.setText(Bundle.getMessage("ButtonStopReadChangesAll"));
readChanges();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
readChangesButton.setText(Bundle.getMessage("ButtonReadChangesAllSheets"));
}
}
});
readAllButton.addItemListener(l3 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(readAllButton);
readAllButton.setText(Bundle.getMessage("ButtonStopReadAll"));
readAll();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
readAllButton.setText(Bundle.getMessage("ButtonReadAllSheets"));
}
}
});
writeChangesButton.setToolTipText(Bundle.getMessage("TipWriteHighlightedValues"));
writeChangesButton.addItemListener(l2 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(writeChangesButton);
writeChangesButton.setText(Bundle.getMessage("ButtonStopWriteChangesAll"));
writeChanges();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
writeChangesButton.setText(Bundle.getMessage("ButtonWriteChangesAllSheets"));
}
}
});
writeAllButton.setToolTipText(Bundle.getMessage("TipWriteAllValues"));
writeAllButton.addItemListener(l4 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(writeAllButton);
writeAllButton.setText(Bundle.getMessage("ButtonStopWriteAll"));
writeAll();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
writeAllButton.setText(Bundle.getMessage("ButtonWriteAllSheets"));
}
}
});
// most of the GUI is done from XML in readConfig() function
// which configures the tabPane
pane.add(tabPane, BorderLayout.CENTER);
// and put that pane into the JFrame
getContentPane().add(pane);
// add help
addHelp();
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class PaneNewProgAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (log.isDebugEnabled()) {
log.debug("New roster entry programmer requested");
}
// create the initial frame that steers
final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameNewEntrySetup"));
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
// add the Roster menu
JMenuBar menuBar = new JMenuBar();
// menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
menuBar.add(j);
menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
f.setJMenuBar(menuBar);
// new Loco on programming track
JPanel pane1 = new LocoSelTreePane(null, null) {
@Override
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
String title = SymbolicProgBundle.getMessage("FrameNewEntryTitle");
JFrame p = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {
@Override
protected JPanel getModePane() {
return null;
}
};
p.pack();
p.setVisible(true);
}
};
// load primary frame
pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(pane1);
f.pack();
if (log.isDebugEnabled()) {
log.debug("Tab-Programmer setup created");
}
f.setVisible(true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class AutoSpeedAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (log.isInfoEnabled()) {
log.debug("auto speed tool requested");
}
// create the initial frame that steers
final JFrame f = new JFrame("Auto-speed Tool Setup");
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
// add the Roster menu
JMenuBar menuBar = new JMenuBar();
// menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
menuBar.add(new jmri.jmrit.roster.swing.RosterMenu("Roster", jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
f.setJMenuBar(menuBar);
// known loco on main track
JPanel pane1 = new // no ident in ops mode yet
KnownLocoSelPane(// no ident in ops mode yet
false) {
@Override
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
String title = "Set speed info for " + re.getId() + " on main track";
// find the ops-mode programmer
int address = Integer.parseInt(re.getDccAddress());
boolean longAddr = true;
if (address < 100) {
longAddr = false;
}
Programmer programmer = InstanceManager.getDefault(jmri.ProgrammerManager.class).getAddressedProgrammer(longAddr, address);
// and created the frame
JFrame p = new PaneOpsProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", programmer);
p.pack();
p.setVisible(true);
f.setVisible(false);
f.dispose();
}
};
// load primary frame
pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(pane1);
f.pack();
if (log.isInfoEnabled()) {
log.debug("setup created");
}
f.setVisible(true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class VSDManagerFrame method addHelpMenu.
/**
* Add a standard help menu, including window specific help item.
*
* @param ref JHelp reference for the desired window-specific help page
* @param direct true if the help menu goes directly to the help system,
* e.g. there are no items in the help menu
*
* WARNING: BORROWED FROM JmriJFrame.
*/
@Override
public void addHelpMenu(String ref, boolean direct) {
// only works if no menu present?
JMenuBar bar = getJMenuBar();
if (bar == null) {
bar = new JMenuBar();
}
// add Window menu
// * GT 28-AUG-2008 Added window menu
bar.add(new WindowMenu(this));
// add Help menu
jmri.util.HelpUtil.helpMenu(bar, ref, direct);
setJMenuBar(bar);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class VSDManagerFrame method buildMenu.
private void buildMenu() {
// uses NamedBeanBundle
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
// OK to use this different key name for Mnemonics
fileMenu.setMnemonic(Mnemonics.get("FileMenu"));
fileMenu.add(new LoadVSDFileAction(Bundle.getMessage("VSDecoderFileMenuLoadVSDFile")));
fileMenu.add(new StoreXmlVSDecoderAction(Bundle.getMessage("VSDecoderFileMenuSaveProfile")));
fileMenu.add(new LoadXmlVSDecoderAction(Bundle.getMessage("VSDecoderFileMenuLoadProfile")));
JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
// OK to use this different key name for Mnemonics
editMenu.setMnemonic(Mnemonics.get("EditMenu"));
editMenu.add(new VSDPreferencesAction(Bundle.getMessage("VSDecoderFileMenuPreferences")));
// disable XML store
fileMenu.getItem(1).setEnabled(false);
// disable XML load
fileMenu.getItem(2).setEnabled(false);
menuList = new ArrayList<JMenu>(3);
menuList.add(fileMenu);
menuList.add(editMenu);
this.setJMenuBar(new JMenuBar());
this.getJMenuBar().add(fileMenu);
this.getJMenuBar().add(editMenu);
// Fix this... needs to be help for the new frame
this.addHelpMenu("package.jmri.jmrit.vsdecoder.swing.VSDManagerFrame", true);
}
Aggregations