use of javax.swing.JMenuItem in project jabref by JabRef.
the class BasicAction method initPopupMenuAndToolbar.
private void initPopupMenuAndToolbar() {
// copy/paste Menu
PasteAction pasteAction = new PasteAction();
ClearAction clearAction = new ClearAction();
JMenuItem pasteMI = new JMenuItem(pasteAction);
inputMenu.add(clearAction);
inputMenu.addSeparator();
inputMenu.add(pasteMI);
inputMenu.addSeparator();
// Right-click append/override
JMenu appendMenu = new JMenu(Localization.lang("Append"));
appendMenu.setToolTipText(Localization.lang("Append the selected text to BibTeX field"));
JMenu overrideMenu = new JMenu(Localization.lang("Override"));
overrideMenu.setToolTipText(Localization.lang("Override the BibTeX field by the selected text"));
for (String field : allFields) {
appendMenu.add(new JMenuItem(new MenuTextForTagAction(field, false)));
overrideMenu.add(new JMenuItem(new MenuTextForTagAction(field, true)));
}
inputMenu.add(appendMenu);
inputMenu.add(overrideMenu);
// Toolbar
toolBar.add(clearAction);
toolBar.setBorderPainted(false);
toolBar.addSeparator();
toolBar.add(pasteAction);
toolBar.add(new LoadAction());
}
use of javax.swing.JMenuItem in project JMRI by JMRI.
the class PowerManagerMenu method getManager.
public PowerManager getManager() {
// start with default
PowerManager manager = InstanceManager.getNullableDefault(jmri.PowerManager.class);
if (manager == null) {
return null;
}
String name = manager.getUserName();
// find active name
for (JMenuItem item : items) {
if (item.isSelected()) {
name = item.getActionCommand();
break;
}
}
// find PowerManager and return
List<PowerManager> managers = InstanceManager.getList(PowerManager.class);
for (PowerManager mgr : managers) {
if (name.equals(mgr.getUserName())) {
return mgr;
}
}
// should not happen
return null;
}
use of javax.swing.JMenuItem in project JMRI by JMRI.
the class JMenuUtil method jMenuFromElement.
@Nonnull
static JMenu jMenuFromElement(@CheckForNull Element main, WindowInterface wi, Object context) {
boolean addSep = false;
String name = "<none>";
if (main == null) {
log.warn("Menu from element called without an element");
return new JMenu(name);
}
name = LocaleSelector.getAttribute(main, "name");
//Next statement left in if the xml file hasn't been converted
if ((name == null) || (name.equals(""))) {
if (main.getChild("name") != null) {
name = main.getChild("name").getText();
}
}
JMenu menu = new JMenu(name);
ArrayList<Integer> mnemonicList = new ArrayList<Integer>();
for (Object item : main.getChildren("node")) {
JMenuItem menuItem = null;
Element child = (Element) item;
if (child.getChildren("node").size() == 0) {
// leaf
if ((child.getText().trim()).equals("separator")) {
addSep = true;
} else {
if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel() && ((child.getChild("adapter") != null && child.getChild("adapter").getText().equals("apps.gui3.TabbedPreferencesAction")) || (child.getChild("current") != null && child.getChild("current").getText().equals("quit"))))) {
if (addSep) {
menu.addSeparator();
addSep = false;
}
Action act = actionFromNode(child, wi, context);
menu.add(menuItem = new JMenuItem(act));
}
}
} else {
if (addSep) {
menu.addSeparator();
addSep = false;
}
if (child.getChild("group") != null && child.getChild("group").getText().equals("yes")) {
//A seperate method is required for creating radio button groups
menu.add(createMenuGroupFromElement(child, wi, context));
} else {
// not leaf
menu.add(menuItem = jMenuFromElement(child, wi, context));
}
}
if (menuItem != null && child.getChild("current") != null) {
setMenuItemInterAction(context, child.getChild("current").getText(), menuItem);
}
if (menuItem != null && child.getChild("mnemonic") != null) {
int mnemonic = convertStringToKeyEvent(child.getChild("mnemonic").getText());
if (mnemonicList.contains(mnemonic)) {
log.error("Menu Item '" + menuItem.getText() + "' Mnemonic '" + child.getChild("mnemonic").getText() + "' has already been assigned");
} else {
menuItem.setMnemonic(mnemonic);
mnemonicList.add(mnemonic);
}
}
}
return menu;
}
use of javax.swing.JMenuItem in project jabref by JabRef.
the class ChangeEntryTypeMenu method createEntryTypeSection.
private void createEntryTypeSection(BasePanel panel, JMenu menu, String title, List<? extends EntryType> types) {
// bibtex
JMenuItem header = new JMenuItem(title);
Font font = new Font(menu.getFont().getName(), Font.ITALIC, menu.getFont().getSize());
header.setFont(font);
header.setEnabled(false);
if (!types.isEmpty()) {
menu.add(header);
}
for (EntryType type : types) {
menu.add(new ChangeTypeAction(type, panel));
}
}
use of javax.swing.JMenuItem in project jabref by JabRef.
the class FileHistoryMenu method addItem.
private void addItem(String filename, int num) {
String number = Integer.toString(num);
JMenuItem item = new JMenuItem(number + ". " + filename);
char mnemonic = Character.toUpperCase(number.charAt(0));
item.setMnemonic((int) mnemonic);
item.addActionListener(this);
add(item);
//history.addFirst(item);
}
Aggregations