use of javax.swing.JMenuItem in project JMRI by JMRI.
the class HelpUtil method makeHelpMenu.
public static JMenu makeHelpMenu(String ref, boolean direct) {
if (!initOK()) {
log.warn("help initialization not completed");
// initialization failed
return null;
}
JMenu helpMenu = new JMenu(Bundle.getMessage("HELP"));
JMenuItem item = makeHelpMenuItem(ref);
if (item == null) {
log.error("Can't make help menu item for " + ref);
return null;
}
helpMenu.add(item);
if (direct) {
item = new JMenuItem(Bundle.getMessage("MenuItemHelp"));
globalHelpBroker.enableHelpOnButton(item, "index", null);
helpMenu.add(item);
// add standard items
JMenuItem license = new JMenuItem(Bundle.getMessage("MenuItemLicense"));
helpMenu.add(license);
license.addActionListener(new apps.LicenseAction());
JMenuItem directories = new JMenuItem(Bundle.getMessage("MenuItemLocations"));
helpMenu.add(directories);
directories.addActionListener(new jmri.jmrit.XmlFileLocationAction());
JMenuItem updates = new JMenuItem(Bundle.getMessage("MenuItemCheckUpdates"));
helpMenu.add(updates);
updates.addActionListener(new apps.CheckForUpdateAction());
JMenuItem context = new JMenuItem(Bundle.getMessage("MenuItemContext"));
helpMenu.add(context);
context.addActionListener(new apps.ReportContextAction());
JMenuItem console = new JMenuItem(Bundle.getMessage("MenuItemConsole"));
helpMenu.add(console);
console.addActionListener(new apps.SystemConsoleAction());
helpMenu.add(new jmri.jmrit.mailreport.ReportAction());
// Put about dialog in Apple's prefered area on Mac OS X
if (SystemType.isMacOSX()) {
try {
Application.getApplication().setAboutHandler((EventObject eo) -> {
new AboutDialog(null, true).setVisible(true);
});
} catch (java.lang.RuntimeException re) {
log.error("Unable to put About handler in default location", re);
}
}
// Include About in Help menu if not on Mac OS X or not using Aqua Look and Feel
if (!SystemType.isMacOSX() || !UIManager.getLookAndFeel().isNativeLookAndFeel()) {
helpMenu.addSeparator();
JMenuItem about = new JMenuItem(Bundle.getMessage("MenuItemAbout") + " " + jmri.Application.getApplicationName());
helpMenu.add(about);
about.addActionListener(new AboutAction());
}
}
return helpMenu;
}
use of javax.swing.JMenuItem in project JMRI by JMRI.
the class HelpUtil method makeHelpMenuItem.
public static JMenuItem makeHelpMenuItem(String ref) {
if (!initOK()) {
// initialization failed
return null;
}
JMenuItem menuItem = new JMenuItem(Bundle.getMessage("MenuItemWindowHelp"));
globalHelpBroker.enableHelpOnButton(menuItem, ref, null);
// start help to see what happend
log.debug("help: {}:{}:{}", globalHelpSet.getHomeID(), globalHelpSet.getTitle(), globalHelpSet.getHelpSetURL());
return menuItem;
}
use of javax.swing.JMenuItem in project JMRI by JMRI.
the class PowerManagerMenu method setDefault.
void setDefault() {
// name of default
PowerManager manager = InstanceManager.getNullableDefault(jmri.PowerManager.class);
if (manager == null) {
return;
}
String defaultMgr = manager.getUserName();
for (JMenuItem item : items) {
if (defaultMgr.equals(item.getActionCommand())) {
item.setSelected(true);
}
}
}
use of javax.swing.JMenuItem in project JMRI by JMRI.
the class Source method createPopUpMenu.
//ArrayList<LayoutBlock> protectingBlocks;
void createPopUpMenu() {
if (entryExitPopUp != null) {
return;
}
entryExitPopUp = new JMenu(Bundle.getMessage("MenuEntryExit"));
editClear = new JMenuItem(Bundle.getMessage("MenuItemClearRoute"));
editClear.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelClearInterlockFromSource(EntryExitPairs.CLEARROUTE);
}
});
entryExitPopUp.add(editClear);
editCancel = new JMenuItem(Bundle.getMessage("MenuItemCancelRoute"));
editCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelClearInterlockFromSource(EntryExitPairs.CANCELROUTE);
}
});
entryExitPopUp.add(editCancel);
editOneClick = new JMenuItem(Bundle.getMessage("MenuItemLockManualRoute"));
editOneClick.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ManuallySetRoute(pd);
}
});
entryExitPopUp.add(editOneClick);
clear = new JMenuItem(Bundle.getMessage("MenuItemClearRoute"));
clear.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelClearInterlockFromSource(EntryExitPairs.CLEARROUTE);
}
});
cancel = new JMenuItem(Bundle.getMessage("MenuItemCancelRoute"));
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelClearInterlockFromSource(EntryExitPairs.CANCELROUTE);
}
});
oneClick = new JMenuItem(Bundle.getMessage("MenuItemLockManualRoute"));
oneClick.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ManuallySetRoute(pd);
}
});
pd.getPanel().addToPopUpMenu(pd.getSensor(), entryExitPopUp, jmri.jmrit.display.Editor.EDITPOPUPONLY);
pd.getPanel().addToPopUpMenu(pd.getSensor(), clear, jmri.jmrit.display.Editor.VIEWPOPUPONLY);
pd.getPanel().addToPopUpMenu(pd.getSensor(), cancel, jmri.jmrit.display.Editor.VIEWPOPUPONLY);
pd.getPanel().addToPopUpMenu(pd.getSensor(), oneClick, jmri.jmrit.display.Editor.VIEWPOPUPONLY);
setMenuEnabled(false);
}
use of javax.swing.JMenuItem in project JMRI by JMRI.
the class CsvExportAction method startLogging.
void startLogging(ActionEvent e) {
System.out.println("" + e);
((JMenuItem) (e.getSource())).setText("Stop CSV Export Reading...");
// initialize chooser
if (fileChooser == null) {
fileChooser = new JFileChooser();
} else {
fileChooser.rescanCurrentDirectory();
}
// get file
int retVal = fileChooser.showSaveDialog(mParent);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
if (log.isDebugEnabled()) {
log.debug("start to log to file " + file);
}
try {
str = new PrintStream(new FileOutputStream(file));
Distributor.instance().addReadingListener(this);
logging = true;
} catch (IOException ex) {
log.error("Error opening file: " + ex);
}
}
}
Aggregations