use of java.awt.MenuItem in project i2p.i2p by i2p.
the class InternalTrayManager method getMainMenu.
public synchronized PopupMenu getMainMenu() {
PopupMenu popup = new PopupMenu();
final MenuItem statusItem = new MenuItem("");
final MenuItem browserLauncher;
if (CONSOLE_ENABLED) {
browserLauncher = new MenuItem(_t("Launch I2P Browser"));
browserLauncher.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
return null;
}
@Override
protected void done() {
launchBrowser();
}
}.execute();
}
});
} else {
browserLauncher = null;
}
PopupMenu desktopguiConfigurationLauncher = new PopupMenu(_t("Configure I2P System Tray"));
MenuItem configSubmenu = new MenuItem(_t("Disable"));
configSubmenu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
configureDesktopgui(false);
return null;
}
}.execute();
}
});
final MenuItem restartItem;
if (_context.hasWrapper()) {
restartItem = new MenuItem(_t("Restart I2P"));
restartItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
RouterManager.restartGracefully(_context);
return null;
}
}.execute();
}
});
} else {
restartItem = null;
}
final MenuItem stopItem = new MenuItem(_t("Stop I2P"));
stopItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
RouterManager.shutDownGracefully(_context);
return null;
}
}.execute();
}
});
final MenuItem restartItem2;
if (_context.hasWrapper()) {
restartItem2 = new MenuItem(_t("Restart I2P Immediately"));
restartItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
RouterManager.restart(_context);
return null;
}
}.execute();
}
});
} else {
restartItem2 = null;
}
final MenuItem stopItem2 = new MenuItem(_t("Stop I2P Immediately"));
stopItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
RouterManager.shutDown(_context);
return null;
}
}.execute();
}
});
final MenuItem cancelItem = new MenuItem(_t("Cancel I2P Shutdown"));
cancelItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
RouterManager.cancelShutdown(_context);
return null;
}
}.execute();
}
});
popup.add(statusItem);
popup.addSeparator();
if (CONSOLE_ENABLED) {
popup.add(browserLauncher);
popup.addSeparator();
}
desktopguiConfigurationLauncher.add(configSubmenu);
popup.add(desktopguiConfigurationLauncher);
popup.addSeparator();
if (_context.hasWrapper())
popup.add(restartItem);
popup.add(stopItem);
if (_context.hasWrapper())
popup.add(restartItem2);
popup.add(stopItem2);
popup.add(cancelItem);
_statusItem = statusItem;
_browserItem = browserLauncher;
_configItem = desktopguiConfigurationLauncher;
_restartItem = restartItem;
_stopItem = stopItem;
_restartHardItem = restartItem2;
_stopHardItem = stopItem2;
_cancelItem = cancelItem;
return popup;
}
use of java.awt.MenuItem in project cryptomator by cryptomator.
the class TrayMenuController method buildSubmenu.
private Menu buildSubmenu(Vault vault) {
Menu submenu = new Menu(vault.getDisplayName());
if (vault.isLocked()) {
MenuItem unlockItem = new MenuItem(resourceBundle.getString("traymenu.vault.unlock"));
unlockItem.addActionListener(createActionListenerForVault(vault, this::unlockVault));
submenu.add(unlockItem);
} else if (vault.isUnlocked()) {
MenuItem lockItem = new MenuItem(resourceBundle.getString("traymenu.vault.lock"));
lockItem.addActionListener(createActionListenerForVault(vault, this::lockVault));
submenu.add(lockItem);
MenuItem revealItem = new MenuItem(resourceBundle.getString("traymenu.vault.reveal"));
revealItem.addActionListener(createActionListenerForVault(vault, this::revealVault));
submenu.add(revealItem);
}
return submenu;
}
use of java.awt.MenuItem in project openblocks by mikaelhg.
the class ContextMenu method initRemoveCommentMenu.
/**
* Initializes the context menu for deleting Comments.
*/
private static void initRemoveCommentMenu() {
removeCommentItem = new MenuItem("Delete Comment");
removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
removeCommentItem.addActionListener(rndBlockMenu);
removeCommentMenu.add(removeCommentItem);
// rndBlockMenu.add(runBlockItem);
removeCommentMenuInit = true;
}
Aggregations