MainMenupublic class MainMenu extends Object
Fields Summary |
---|
final String | PREFIX_V2 | final String | PREFIX_V3 | private Menu | menuBar | private final com.aelitis.azureus.ui.swt.skin.SWTSkin | skin |
Methods Summary |
---|
private void | addFileMenu(Shell parent)
//The File Menu
MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
Messages.setLanguageText(fileItem, PREFIX_V2 + ".file");
Menu fileMenu = new Menu(parent, SWT.DROP_DOWN);
fileItem.setMenu(fileMenu);
createMenuItem(fileMenu, PREFIX_V2 + ".file.open", new Listener() {
public void handleEvent(Event event) {
TorrentOpener.openTorrentSimple();
}
});
//No need for restart and exit on OS X
if (!Constants.isOSX) {
new MenuItem(fileMenu, SWT.SEPARATOR);
MenuItem file_restart = new MenuItem(fileMenu, SWT.NULL);
Messages.setLanguageText(file_restart, PREFIX_V2 + ".file.restart");
file_restart.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
UIFunctionsManagerSWT.getUIFunctionsSWT().dispose(true, false);
}
});
final MenuItem file_exit = new MenuItem(fileMenu, SWT.NULL);
if (!COConfigurationManager.getBooleanParameter("Enable System Tray")
|| !COConfigurationManager.getBooleanParameter("Close To Tray")) {
KeyBindings.setAccelerator(file_exit, PREFIX_V2 + ".file.exit");
}
Messages.setLanguageText(file_exit, PREFIX_V2 + ".file.exit");
file_exit.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
UIFunctionsManagerSWT.getUIFunctionsSWT().dispose(false, false);
}
});
// let platform decide
ParameterListener paramListener = new ParameterListener() {
public void parameterChanged(String parameterName) {
if (COConfigurationManager.getBooleanParameter("Enable System Tray")
&& COConfigurationManager.getBooleanParameter("Close To Tray")) {
KeyBindings.removeAccelerator(file_exit, PREFIX_V2 + ".file.exit");
} else {
KeyBindings.setAccelerator(file_exit, PREFIX_V2 + ".file.exit");
}
}
};
COConfigurationManager.addParameterListener("Enable System Tray",
paramListener);
COConfigurationManager.addParameterListener("Close To Tray",
paramListener);
}
| private void | addHelpMenu(Shell parent)
final Display display = parent.getDisplay();
//The Help Menu
MenuItem helpItem = new MenuItem(menuBar, SWT.CASCADE);
Messages.setLanguageText(helpItem, "MainWindow.menu.help");
final Menu helpMenu = new Menu(parent, SWT.DROP_DOWN);
helpItem.setMenu(helpMenu);
if (!Constants.isOSX) {
MenuItem help_about = new MenuItem(helpMenu, SWT.NULL);
Messages.setLanguageText(help_about, "MainWindow.menu.help.about");
help_about.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
AboutWindow.show(display);
}
});
new MenuItem(helpMenu, SWT.SEPARATOR);
}
MenuItem help_whatsnew = new MenuItem(helpMenu, SWT.NULL);
Messages.setLanguageText(help_whatsnew, "MainWindow.menu.help.releasenotes");
help_whatsnew.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
new WelcomeWindow(parent);
}
});
MenuItem help_faq = new MenuItem(helpMenu, SWT.NULL);
Messages.setLanguageText(help_faq, "MainWindow.menu.help.faq");
help_faq.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String faqString = com.aelitis.azureus.util.Constants.URL_FAQ;
Utils.launch(faqString);
}
});
new MenuItem(helpMenu, SWT.SEPARATOR);
if (!SystemProperties.isJavaWebStartInstance()) {
MenuItem help_checkupdate = new MenuItem(helpMenu, SWT.NULL);
KeyBindings.setAccelerator(help_checkupdate,
"MainWindow.menu.help.checkupdate");
Messages.setLanguageText(help_checkupdate,
"MainWindow.menu.help.checkupdate");
help_checkupdate.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.bringToFront();
}
AzureusCore core = AzureusCoreFactory.getSingleton();
UpdateMonitor.getSingleton(core).performCheck(true, false, false,
new UpdateCheckInstanceListener() {
public void cancelled(UpdateCheckInstance instance) {
}
public void complete(UpdateCheckInstance instance) {
if (instance.getUpdates().length == 0) {
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
Utils.openMessageBox(parent, SWT.ICON_INFORMATION
| SWT.OK, "window.update.noupdates",
(String[]) null);
}
});
}
}
});
}
});
}
new MenuItem(helpMenu, SWT.SEPARATOR);
MenuItem help_debug = new MenuItem(helpMenu, SWT.NULL);
Messages.setLanguageText(help_debug, "MainWindow.menu.help.debug");
help_debug.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
UIDebugGenerator.generate();
}
});
| public void | addToOldMenuView(Menu viewMenu)
new MenuItem(viewMenu, SWT.SEPARATOR);
addViewMenuItems(viewMenu);
new MenuItem(viewMenu, SWT.SEPARATOR);
createViewMenuItem(skin, viewMenu, PREFIX_V3 + ".view.searchbar",
"SearchBar.visible", "searchbar");
createViewMenuItem(skin, viewMenu, PREFIX_V3 + ".view.tabbar",
"TabBar.visible", "tabbar");
| private void | addViewMenu(Shell parent)
MenuItem viewItem = new MenuItem(menuBar, SWT.CASCADE);
Messages.setLanguageText(viewItem, PREFIX_V2 + ".view");
Menu viewMenu = new Menu(parent, SWT.DROP_DOWN);
viewItem.setMenu(viewMenu);
addViewMenuItems(viewMenu);
| private void | addViewMenuItems(Menu viewMenu)
createMenuItem(viewMenu, PREFIX_V3 + ".home", new Listener() {
public void handleEvent(Event event) {
skin.setActiveTab(SkinConstants.TABSET_MAIN, "maintabs.home");
}
});
createMenuItem(viewMenu, PREFIX_V3 + ".browse", new Listener() {
public void handleEvent(Event event) {
skin.setActiveTab(SkinConstants.TABSET_MAIN, "maintabs.browse");
}
});
createMenuItem(viewMenu, PREFIX_V3 + ".library", new Listener() {
public void handleEvent(Event event) {
skin.setActiveTab(SkinConstants.TABSET_MAIN, "maintabs.library");
}
});
createMenuItem(viewMenu, PREFIX_V3 + ".publish", new Listener() {
public void handleEvent(Event event) {
skin.setActiveTab(SkinConstants.TABSET_MAIN, "maintabs.publish");
}
});
new MenuItem(viewMenu, SWT.SEPARATOR);
createMenuItem(viewMenu, PREFIX_V3 + ".advanced", new Listener() {
public void handleEvent(Event event) {
skin.setActiveTab(SkinConstants.TABSET_MAIN, "maintabs.advanced");
}
});
| private void | buildMenu(Shell parent)
//The Main Menu
menuBar = new Menu(parent, SWT.BAR);
addFileMenu(parent);
addViewMenu(parent);
addHelpMenu(parent);
parent.setMenuBar(menuBar);
| private MenuItem | createMenuItem(Menu parent, java.lang.String key, Listener selectionListener)
return createMenuItem(parent, SWT.PUSH, key, selectionListener);
| private static MenuItem | createMenuItem(Menu parent, int style, java.lang.String key, Listener selectionListener)
MenuItem item = new MenuItem(parent, style);
Messages.setLanguageText(item, key);
KeyBindings.setAccelerator(item, key);
item.addListener(SWT.Selection, selectionListener);
return item;
| public static MenuItem | createViewMenuItem(com.aelitis.azureus.ui.swt.skin.SWTSkin skin, Menu viewMenu, java.lang.String textID, java.lang.String configID, java.lang.String viewID)
MenuItem item;
if (!ConfigurationDefaults.getInstance().doesParameterDefaultExist(configID)) {
COConfigurationManager.setBooleanDefault(configID, true);
}
item = createMenuItem(viewMenu, SWT.CHECK, textID, new Listener() {
public void handleEvent(Event event) {
SWTSkinObject skinObject = skin.getSkinObject(viewID);
if (skinObject != null) {
SWTSkinUtils.setVisibility(skin, configID, viewID,
!skinObject.isVisible());
}
}
});
SWTSkinUtils.setVisibility(skin, configID, viewID,
COConfigurationManager.getBooleanParameter(configID));
final MenuItem itemViewSearchBar = item;
final ParameterListener listener = new ParameterListener() {
public void parameterChanged(String parameterName) {
itemViewSearchBar.setSelection(COConfigurationManager.getBooleanParameter(parameterName));
}
};
COConfigurationManager.addAndFireParameterListener(configID, listener);
item.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
COConfigurationManager.removeParameterListener(configID, listener);
}
});
return item;
| public Menu | getMenuBar()
return menuBar;
| public void | linkMenuBar(Shell parent)
parent.setMenuBar(menuBar);
| public static void | setVisibility(com.aelitis.azureus.ui.swt.skin.SWTSkin skin, java.lang.String configID, java.lang.String viewID, boolean visible)
SWTSkinUtils.setVisibility(skin, configID, viewID, visible, true, false);
| public static void | setVisibility(com.aelitis.azureus.ui.swt.skin.SWTSkin skin, java.lang.String configID, java.lang.String viewID, boolean visible, boolean save)
SWTSkinUtils.setVisibility(skin, configID, viewID, visible, save, false);
|
|