use of java.awt.MenuItem in project fql by CategoricalData.
the class GUI method makeGUI.
@SuppressWarnings({})
public static Pair<JPanel, MenuBar> makeGUI(JFrame frame) {
topFrame = frame;
MenuBar menuBar = new MenuBar();
Menu fileMenu = makeFileMenu();
Menu editMenu = makeEditMenu();
Menu toolsMenu = makesToolsMenu();
Menu helpMenu = new Menu("Help");
MenuItem aboutItem = new MenuItem("Help/About");
helpMenu.add(aboutItem);
aboutItem.addActionListener(e -> IdeOptions.showAbout());
menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(toolsMenu);
Menu aqlMenu = populateAql();
menuBar.add(aqlMenu);
// Menu legacyMenu = new Menu("Legacy");
Menu fqlMenu = new Menu("FQL");
Menu fqlppMenu = new Menu("FQL++");
Menu oplMenu = new Menu("OPL");
Menu fpqlMenu = new Menu("FPQL");
populateFql(fqlMenu);
populateFqlpp(fqlppMenu);
populateFpql(fpqlMenu);
populateOpl(oplMenu);
menuBar.add(fqlMenu);
menuBar.add(fqlppMenu);
menuBar.add(fpqlMenu);
menuBar.add(oplMenu);
menuBar.add(helpMenu);
JPanel pan = new JPanel();
pan.setLayout(new BorderLayout());
JPanel toolBar = makeToolBar();
pan.add(toolBar, BorderLayout.PAGE_START);
pan.add(editors, BorderLayout.CENTER);
return new Pair<>(pan, menuBar);
}
use of java.awt.MenuItem in project fql by CategoricalData.
the class GUI method makeEditMenu.
private static Menu makeEditMenu() {
Menu editMenu = new Menu("Edit");
MenuItem findItem = new MenuItem("Find/Replace");
editMenu.add(findItem);
MenuItem gotoItem = new MenuItem("Goto Line");
editMenu.add(gotoItem);
MenuItem gotoDef = new MenuItem("Goto Definition");
editMenu.add(gotoDef);
KeyStroke ctrlShiftR = KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut fx = new MenuShortcut(ctrlShiftR.getKeyCode(), true);
gotoDef.setShortcut(fx);
gotoDef.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.showGotoDialog();
}
});
KeyStroke ctrlF = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut f = new MenuShortcut(ctrlF.getKeyCode());
findItem.setShortcut(f);
MenuItem copy = new MenuItem("Copy");
copy.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.topArea.copy();
}
});
KeyStroke ctrlC = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut cc = new MenuShortcut(ctrlC.getKeyCode());
copy.setShortcut(cc);
editMenu.add(copy);
MenuItem rtf = new MenuItem("Copy as RTF");
editMenu.add(rtf);
rtf.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.copyAsRtf();
}
});
MenuItem cut = new MenuItem("Cut");
cut.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.topArea.cut();
}
});
KeyStroke ctrlX = KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut cx = new MenuShortcut(ctrlX.getKeyCode());
cut.setShortcut(cx);
editMenu.add(cut);
MenuItem paste = new MenuItem("Paste");
cut.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.topArea.paste();
}
});
KeyStroke ctrlV = KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut cv = new MenuShortcut(ctrlV.getKeyCode());
paste.setShortcut(cv);
editMenu.add(paste);
MenuItem undo = new MenuItem("Undo");
undo.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.topArea.undoLastAction();
}
});
KeyStroke ctrlZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut z = new MenuShortcut(ctrlZ.getKeyCode());
undo.setShortcut(z);
editMenu.add(undo);
MenuItem redo = new MenuItem("Redo");
redo.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.topArea.redoLastAction();
}
});
KeyStroke ctrlShiftZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
MenuShortcut sz = new MenuShortcut(ctrlShiftZ.getKeyCode(), true);
redo.setShortcut(sz);
editMenu.add(redo);
MenuItem back = new MenuItem("Back");
back.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.backAction();
}
});
editMenu.add(back);
MenuItem fwd = new MenuItem("Forward");
fwd.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.fwdAction();
}
});
editMenu.add(fwd);
MenuItem fall = new MenuItem("Fold All");
editMenu.add(fall);
fall.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.foldAll(true);
}
});
MenuItem uall = new MenuItem("Unfold All");
editMenu.add(uall);
uall.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.foldAll(false);
}
});
findItem.addActionListener(e -> {
delay();
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.replaceAction();
}
});
gotoItem.addActionListener(e -> {
delay();
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.gotoLine();
}
});
MenuItem clear = new MenuItem("Refresh Outline");
editMenu.add(clear);
clear.addActionListener(x -> {
CodeEditor<?, ?, ?> ed = getSelectedEditor();
if (ed != null) {
ed.getOutline().build();
;
}
});
return editMenu;
}
use of java.awt.MenuItem in project fql by CategoricalData.
the class GUI method populateFqlpp.
private static void populateFqlpp(Menu menu) {
MenuItem kbItem = new MenuItem("FQL++ Knuth-Bendix");
menu.add(kbItem);
kbItem.addActionListener(x -> new KBViewer());
}
use of java.awt.MenuItem in project fql by CategoricalData.
the class GUI method populateAql.
private static Menu populateAql() {
Menu menu = new Menu("AQL");
MenuItem st = new MenuItem("Self-Test");
st.addActionListener(x -> AqlTester.doSelfTests());
menu.add(st);
MenuItem im = new MenuItem("Infer Mapping (using last compiled)");
im.addActionListener(x -> infer(Kind.MAPPING));
menu.add(im);
MenuItem iq = new MenuItem("Infer Query (using last compiled)");
iq.addActionListener(x -> infer(Kind.QUERY));
menu.add(iq);
MenuItem it = new MenuItem("Infer Transform (using last compiled)");
it.addActionListener(x -> infer(Kind.TRANSFORM));
menu.add(it);
MenuItem ii = new MenuItem("Infer Instance (using last compiled)");
it.addActionListener(x -> infer(Kind.INSTANCE));
menu.add(ii);
MenuItem ih = new MenuItem("Emit HTML (using last compiled)");
ih.addActionListener(x -> {
CodeEditor<?, ?, ?> c = getSelectedEditor();
if (c == null) {
// TODO aql refact these actions that depend on selected editor
return;
}
if (c instanceof AqlCodeEditor) {
AqlCodeEditor a = (AqlCodeEditor) c;
a.emitDoc();
}
});
menu.add(ih);
MenuItem formatItem = new MenuItem("Code Format");
menu.add(formatItem);
formatItem.addActionListener(x -> formatActionAql());
return menu;
}
use of java.awt.MenuItem in project bisq-desktop by bisq-network.
the class SystemTray method init.
private void init() {
if (!java.awt.SystemTray.isSupported()) {
log.error("System tray is not supported.");
return;
}
// prevent exiting the app when the last window gets closed
// For now we allow to close the app by closing the window.
// Later we only let it close via the system trays exit.
Platform.setImplicitExit(false);
MenuItem aboutItem = new MenuItem(Res.get("systemTray.info"));
MenuItem exitItem = new MenuItem(Res.get("systemTray.exit"));
PopupMenu popupMenu = new PopupMenu();
popupMenu.add(aboutItem);
popupMenu.addSeparator();
popupMenu.add(toggleShowHideItem);
popupMenu.addSeparator();
popupMenu.add(exitItem);
String path;
if (Utilities.isOSX())
path = ImageUtil.isRetina() ? ICON_HI_RES : ICON_LO_RES;
else if (Utilities.isWindows())
path = ICON_WINDOWS;
else
path = ICON_LINUX;
try {
BufferedImage trayIconImage = ImageIO.read(getClass().getResource(path));
TrayIcon trayIcon = new TrayIcon(trayIconImage);
// On OSX we get the correct size from the provided image
if (!Utilities.isOSX()) {
int trayIconWidth = trayIcon.getSize().width;
trayIcon = new TrayIcon(trayIconImage.getScaledInstance(trayIconWidth, -1, Image.SCALE_SMOOTH));
}
trayIcon.setPopupMenu(popupMenu);
trayIcon.setToolTip(Res.get("systemTray.tooltip"));
java.awt.SystemTray.getSystemTray().add(trayIcon);
} catch (AWTException e1) {
log.error("Icon could not be added to system tray.", e1);
} catch (IOException e2) {
throw new BisqException(e2);
}
toggleShowHideItem.addActionListener(e -> {
if (stage.isShowing()) {
toggleShowHideItem.setLabel(SHOW_WINDOW_LABEL);
UserThread.execute(stage::hide);
} else {
toggleShowHideItem.setLabel(HIDE_WINDOW_LABEL);
UserThread.execute(stage::show);
}
});
aboutItem.addActionListener(e -> {
try {
UserThread.execute(() -> GUIUtil.openWebPage("https://bisq.network"));
} catch (Exception e1) {
e1.printStackTrace();
}
});
exitItem.addActionListener(e -> UserThread.execute(onExit::run));
}
Aggregations