use of java.awt.Menu 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.Menu 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.Menu 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.Menu in project ffx by mjschnie.
the class ModelingShell method initMenus.
/**
* Update the shell menu items.
*/
private void initMenus() {
JFrame frame = (JFrame) this.getFrame();
MenuBar menuBar = frame.getMenuBar();
/**
* Remove "Capture Std. Out", "Capture Std. Error" & "Detached Output"
* from the View menu.
*/
Menu menu = menuBar.getMenu(2);
menu.remove(5);
menu.remove(5);
menu.remove(9);
/**
* Edit the Script menu.
*/
menu = menuBar.getMenu(4);
menu.remove(4);
menu.remove(4);
menu.remove(4);
menu.remove(5);
menu.remove(7);
}
use of java.awt.Menu in project proxyee-down by monkeyWie.
the class HttpDownApplication method addTray.
private void addTray() {
try {
if (SystemTray.isSupported()) {
// 获得系统托盘对象
SystemTray systemTray = SystemTray.getSystemTray();
// 获取图片所在的URL
URL url = Thread.currentThread().getContextClassLoader().getResource("favicon.png");
TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(url), "proxyee-down");
// 为系统托盘加托盘图标
systemTray.add(trayIcon);
trayIcon.setImageAutoSize(true);
// 托盘双击事件
trayIcon.addActionListener(event -> Platform.runLater(() -> open(true)));
// 创建弹出菜单
PopupMenu popupMenu = new PopupMenu();
MenuItem tasksItem = new MenuItem("显示");
tasksItem.addActionListener(event -> Platform.runLater(() -> open(true)));
MenuItem crtItem = new MenuItem("证书目录");
crtItem.addActionListener(event -> {
try {
Desktop.getDesktop().open(new File(HttpDownConstant.SSL_PATH));
} catch (Exception e) {
LOGGER.error("open cert dir error", e);
}
});
Menu proxyMenu = new Menu("嗅探模式");
if (!OsUtil.isWindows() && !OsUtil.isMac()) {
proxyMenu.setEnabled(false);
} else {
CheckboxMenuItemGroup mig = new CheckboxMenuItemGroup();
CheckboxMenuItem globalProxyItem = new CheckboxMenuItem("全网");
globalProxyItem.setName("1");
CheckboxMenuItem bdyProxyItem = new CheckboxMenuItem("百度云");
bdyProxyItem.setName("2");
CheckboxMenuItem disableProxyItem = new CheckboxMenuItem("关闭");
disableProxyItem.setName("3");
proxyMenu.add(globalProxyItem);
proxyMenu.add(bdyProxyItem);
proxyMenu.add(disableProxyItem);
mig.add(globalProxyItem);
mig.add(bdyProxyItem);
mig.add(disableProxyItem);
try {
// 默认选中
if (ContentManager.CONFIG.get().getSniffModel() == 1) {
mig.selectItem(globalProxyItem);
OsUtil.enabledHTTPProxy("127.0.0.1", ContentManager.CONFIG.get().getProxyPort());
} else if (ContentManager.CONFIG.get().getSniffModel() == 2) {
mig.selectItem(bdyProxyItem);
OsUtil.enabledPACProxy("http://127.0.0.1:" + ConfigUtil.getValue("tomcat.server.port") + "/res/pd.pac?t=" + System.currentTimeMillis());
} else {
mig.selectItem(disableProxyItem);
}
} catch (Exception e) {
LOGGER.error("set proxy error", e);
}
mig.addActionListener(event -> {
try {
String selectedItemName = ((CheckboxMenuItem) event.getSource()).getName();
if ("1".equals(selectedItemName)) {
ContentManager.CONFIG.get().setSniffModel(1);
OsUtil.enabledHTTPProxy("127.0.0.1", ContentManager.CONFIG.get().getProxyPort());
} else if ("2".equals(selectedItemName)) {
ContentManager.CONFIG.get().setSniffModel(2);
OsUtil.enabledPACProxy("http://127.0.0.1:" + ConfigUtil.getValue("tomcat.server.port") + "/res/pd.pac?t=" + System.currentTimeMillis());
} else {
ContentManager.CONFIG.get().setSniffModel(3);
OsUtil.disabledProxy();
}
ContentManager.CONFIG.save();
} catch (Exception e) {
LOGGER.error("proxy switch error", e);
trayIcon.displayMessage("提示", "嗅探模式切换失败", TrayIcon.MessageType.INFO);
}
});
}
Menu uiMenu = new Menu("UI模式");
CheckboxMenuItemGroup mig = new CheckboxMenuItemGroup();
CheckboxMenuItem guiItem = new CheckboxMenuItem("GUI");
guiItem.setName("1");
CheckboxMenuItem browserItem = new CheckboxMenuItem("浏览器");
browserItem.setName("2");
if (isSupportBrowser) {
uiMenu.add(guiItem);
} else {
ContentManager.CONFIG.get().setUiModel(2);
ContentManager.CONFIG.save();
}
uiMenu.add(browserItem);
mig.add(guiItem);
mig.add(browserItem);
// 默认选中
if (ContentManager.CONFIG.get().getUiModel() == 1) {
mig.selectItem(guiItem);
} else {
mig.selectItem(browserItem);
}
mig.addActionListener(event -> {
String selectedItemName = ((CheckboxMenuItem) event.getSource()).getName();
Platform.runLater(() -> {
if ("1".equals(selectedItemName)) {
ContentManager.CONFIG.get().setUiModel(1);
initBrowser();
} else {
ContentManager.CONFIG.get().setUiModel(2);
destroyBrowser();
stage.close();
}
open(true);
ContentManager.CONFIG.save();
});
});
MenuItem aboutItem = new MenuItem("关于");
aboutItem.addActionListener(event -> Platform.runLater(() -> {
if (ContentManager.CONFIG.get().getUiModel() == 1) {
browser.webEngine.executeScript("vue.$children[0].openTabHandle('/about');");
}
open(true);
}));
MenuItem closeItem = new MenuItem("退出");
closeItem.addActionListener(event -> {
// 记录窗口信息
ContentManager.CONFIG.get().setGuiX(stage.getX());
ContentManager.CONFIG.get().setGuiY(stage.getY());
ContentManager.CONFIG.get().setGuiHeight(stage.getHeight());
ContentManager.CONFIG.get().setGuiWidth(stage.getWidth());
ContentManager.CONFIG.save();
System.exit(0);
});
popupMenu.add(tasksItem);
popupMenu.addSeparator();
popupMenu.add(crtItem);
popupMenu.add(proxyMenu);
popupMenu.add(uiMenu);
popupMenu.addSeparator();
popupMenu.add(aboutItem);
popupMenu.add(closeItem);
// 为托盘图标加弹出菜弹
trayIcon.setPopupMenu(popupMenu);
trayIcon.displayMessage("提示", "proxyee-down启动成功", TrayIcon.MessageType.INFO);
}
} catch (Exception e) {
LOGGER.error("addTray error:", e);
showMsg("托盘初始化失败");
}
afterTrayInit();
}
Aggregations