use of javax.swing.JMenuItem in project felix by apache.
the class ControlPoint method doMenuBar.
public void doMenuBar(JFrame frame) {
JMenuBar menuBar = new JMenuBar();
// ////////////// FILE
JMenu file_menu = new JMenu("File");
file_menu.setMnemonic(KeyEvent.VK_F);
searchMenu = new JMenu("Search");
final String ALL_DEVICE = "ssdp:all";
final String ROOT_DEVICE = "upnp:rootdevice";
searchMenu.setMnemonic(KeyEvent.VK_L);
searchMenu.setEnabled(false);
AbstractAction searchAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(ALL_DEVICE))
controller.doSearch(ALL_DEVICE);
else if (e.getActionCommand().equals(ROOT_DEVICE))
controller.doSearch(ROOT_DEVICE);
}
};
JMenuItem rootDeviceItem = new JMenuItem("Root Devices");
rootDeviceItem.setMnemonic(KeyEvent.VK_R);
rootDeviceItem.addActionListener(searchAction);
rootDeviceItem.setActionCommand(ROOT_DEVICE);
searchMenu.add(rootDeviceItem);
JMenuItem allDeviceItem = new JMenuItem("All Devices");
allDeviceItem.setMnemonic(KeyEvent.VK_A);
allDeviceItem.addActionListener(searchAction);
allDeviceItem.setActionCommand(ALL_DEVICE);
searchMenu.add(allDeviceItem);
JMenuItem checkIncompleteItem = new JMenuItem("Print Pending Devices");
checkIncompleteItem.setMnemonic(KeyEvent.VK_I);
checkIncompleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mediator.getRootDeviceListener().checkIncompleteDevice();
}
});
JMenuItem checkErrataItem = new JMenuItem("Check Errata UPnPDevices");
checkErrataItem.setMnemonic(KeyEvent.VK_E);
checkErrataItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
RootDeviceListener.checkErrataDevice();
}
});
loggerMenu = new JMenu("Felix Logger");
final String NO_LOGGING = "No Logging";
final String ERROR = "Error";
final String WARNING = "Warning";
final String INFO = "Info";
final String DEBUG = "Debug";
loggerMenu.getPopupMenu().addPopupMenuListener(this);
loggerMenu.setMnemonic(KeyEvent.VK_L);
loggerMenu.setEnabled(false);
AbstractAction loggerAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(NO_LOGGING))
controller.setLogLevel(0);
else if (e.getActionCommand().equals(ERROR))
controller.setLogLevel(1);
else if (e.getActionCommand().equals(WARNING))
controller.setLogLevel(2);
else if (e.getActionCommand().equals(INFO))
controller.setLogLevel(3);
else if (e.getActionCommand().equals(DEBUG))
controller.setLogLevel(4);
}
};
ButtonGroup group = new ButtonGroup();
JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem(NO_LOGGING);
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_N);
rbMenuItem.setActionCommand(NO_LOGGING);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
loggerMenu.addSeparator();
rbMenuItem = new JRadioButtonMenuItem(ERROR);
rbMenuItem.setMnemonic(KeyEvent.VK_E);
rbMenuItem.setActionCommand(ERROR);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(WARNING);
rbMenuItem.setMnemonic(KeyEvent.VK_W);
rbMenuItem.setActionCommand(WARNING);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(INFO);
rbMenuItem.setMnemonic(KeyEvent.VK_I);
rbMenuItem.setActionCommand(INFO);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(DEBUG);
rbMenuItem.setMnemonic(KeyEvent.VK_D);
rbMenuItem.setActionCommand(DEBUG);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
final String ON = "On";
final String OFF = "Off";
cyberMenu = new JMenu("Cyber Debugger");
cyberMenu.getPopupMenu().addPopupMenuListener(this);
cyberMenu.setMnemonic(KeyEvent.VK_C);
cyberMenu.setEnabled(false);
AbstractAction cyberAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(ON))
controller.setCyberDebug(true);
else if (e.getActionCommand().equals(OFF))
controller.setCyberDebug(false);
}
};
ButtonGroup cyberGroup = new ButtonGroup();
rbMenuItem = new JRadioButtonMenuItem(ON);
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_O);
rbMenuItem.setActionCommand(ON);
rbMenuItem.addActionListener(cyberAction);
cyberGroup.add(rbMenuItem);
cyberMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(OFF);
rbMenuItem.setMnemonic(KeyEvent.VK_F);
rbMenuItem.setActionCommand(OFF);
rbMenuItem.addActionListener(cyberAction);
cyberGroup.add(rbMenuItem);
cyberMenu.add(rbMenuItem);
/*
JMenuItem clearSubscriptionItem = new JMenuItem("Clear Subscriptions");
clearSubscriptionItem.setMnemonic(KeyEvent.VK_S);
clearSubscriptionItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// to do
}
});
*/
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic(KeyEvent.VK_X);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Activator.context.getBundle().stop();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
file_menu.add(searchMenu);
file_menu.addSeparator();
file_menu.add(loggerMenu);
file_menu.add(cyberMenu);
file_menu.addSeparator();
file_menu.add(checkIncompleteItem);
file_menu.add(checkErrataItem);
// file_menu.addSeparator();
// file_menu.add(clearSubscriptionItem);
file_menu.addSeparator();
file_menu.add(exitItem);
menuBar.add(file_menu);
frame.setJMenuBar(menuBar);
}
use of javax.swing.JMenuItem in project omegat by omegat-org.
the class MatchesTextArea method populateContextMenu.
private void populateContextMenu(JPopupMenu popup, final int index) {
boolean hasMatches = Core.getProject().isProjectLoaded() && index >= 0 && index < matches.size();
if (hasMatches) {
NearString m = matches.get(index);
if (m.projs.length > 1) {
JMenuItem item = popup.add(OStrings.getString("MATCHES_PROJECTS"));
item.setEnabled(false);
for (int i = 0; i < m.projs.length; i++) {
String proj = m.projs[i];
StringBuilder b = new StringBuilder();
if (proj.equals("")) {
b.append(OStrings.getString("MATCHES_THIS_PROJECT"));
} else {
b.append(proj);
}
b.append(" ");
b.append(m.scores[i].toString());
JMenuItem pItem = popup.add(b.toString());
pItem.setEnabled(false);
}
popup.addSeparator();
}
}
JMenuItem item = popup.add(OStrings.getString("MATCHES_INSERT"));
item.addActionListener(new ActionListener() {
// the action: insert this match
@Override
public void actionPerformed(ActionEvent e) {
if (StringUtil.isEmpty(getSelectedText())) {
setActiveMatch(index);
}
Core.getMainWindow().getMainMenu().invokeAction("editInsertTranslationMenuItem", 0);
}
});
item.setEnabled(hasMatches);
item = popup.add(OStrings.getString("MATCHES_REPLACE"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (StringUtil.isEmpty(getSelectedText())) {
setActiveMatch(index);
}
Core.getMainWindow().getMainMenu().invokeAction("editOverwriteTranslationMenuItem", 0);
}
});
item.setEnabled(hasMatches);
popup.addSeparator();
item = popup.add(OStrings.getString("MATCHES_GO_TO_SEGMENT_SOURCE"));
item.setEnabled(hasMatches);
if (hasMatches) {
final NearString ns = matches.get(index);
String proj = ns.projs[0];
if (StringUtil.isEmpty(proj)) {
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Core.getEditor().gotoEntry(ns.source, ns.key);
}
});
} else {
item.setEnabled(false);
}
}
}
use of javax.swing.JMenuItem in project omegat by omegat-org.
the class MatchesTextArea method populatePaneMenu.
@Override
public void populatePaneMenu(JPopupMenu menu) {
populateContextMenu(menu, activeMatch);
menu.addSeparator();
final JMenuItem notify = new JCheckBoxMenuItem(OStrings.getString("GUI_MATCHWINDOW_SETTINGS_NOTIFICATIONS"));
notify.setSelected(Preferences.isPreference(Preferences.NOTIFY_FUZZY_MATCHES));
notify.addActionListener(e -> Preferences.setPreference(Preferences.NOTIFY_FUZZY_MATCHES, notify.isSelected()));
menu.add(notify);
menu.addSeparator();
final JMenuItem prefs = new JMenuItem(OStrings.getString("MATCHES_OPEN_PREFERENCES"));
prefs.addActionListener(e -> new PreferencesWindowController().show(Core.getMainWindow().getApplicationFrame(), TMMatchesPreferencesController.class));
menu.add(prefs);
}
use of javax.swing.JMenuItem in project omegat by omegat-org.
the class MultipleTransPane method populateContextMenu.
private void populateContextMenu(JPopupMenu popup, int pos) {
final DisplayedEntry de = getEntryAtPosition(pos);
JMenuItem item;
// default translation
item = popup.add(OStrings.getString("MULT_POPUP_DEFAULT"));
item.setEnabled(de != null && de.entry.key != null);
if (de != null && de.entry.key != null) {
item.addActionListener(e -> {
Core.getEditor().replaceEditText(de.entry.entry.translation);
Core.getEditor().setAlternateTranslationForCurrentEntry(false);
Core.getEditor().commitAndLeave();
});
}
// non-default translation
item = popup.add(OStrings.getString("MULT_POPUP_REPLACE"));
item.setEnabled(de != null);
if (de != null) {
item.addActionListener(e -> Core.getEditor().replaceEditText(de.entry.entry.translation));
}
item = popup.add(OStrings.getString("MULT_POPUP_GOTO"));
item.setEnabled(de != null);
if (de != null) {
item.addActionListener(e -> Core.getEditor().gotoEntry(de.entry.sourceText, de.entry.key));
}
}
use of javax.swing.JMenuItem in project omegat by omegat-org.
the class NotesTextArea method populatePaneMenu.
@Override
public void populatePaneMenu(JPopupMenu menu) {
final JMenuItem notify = new JCheckBoxMenuItem(OStrings.getString("GUI_NOTESWINDOW_NOTIFICATIONS"));
notify.setSelected(Preferences.isPreference(Preferences.NOTIFY_NOTES));
notify.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Preferences.setPreference(Preferences.NOTIFY_NOTES, notify.isSelected());
}
});
menu.add(notify);
}
Aggregations