Search in sources :

Example 1 with UIInstanceFactory

use of com.biglybt.pif.ui.UIInstanceFactory in project BiglyBT by BiglySoftware.

the class MainMenuV3 method builFileMenu.

/**
 * Builds the File menu dynamically
 * @param fileMenu
 */
private void builFileMenu(Menu fileMenu) {
    MenuItem openMenuItem = MenuFactory.createOpenMenuItem(fileMenu);
    Menu openSubMenu = openMenuItem.getMenu();
    MenuFactory.addOpenTorrentMenuItem(openSubMenu);
    MenuFactory.addOpenURIMenuItem(openSubMenu);
    MenuFactory.addOpenTorrentForTrackingMenuItem(openSubMenu);
    MenuFactory.addOpenVuzeFileMenuItem(openSubMenu);
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    if (userMode > 0) {
        Menu shareSubMenu = MenuFactory.createShareMenuItem(fileMenu).getMenu();
        MenuFactory.addShareFileMenuItem(shareSubMenu);
        MenuFactory.addShareFolderMenuItem(shareSubMenu);
        MenuFactory.addShareFolderContentMenuItem(shareSubMenu);
        MenuFactory.addShareFolderContentRecursiveMenuItem(shareSubMenu);
    }
    MenuFactory.addCreateMenuItem(fileMenu);
    if (!Constants.isOSX) {
        MenuFactory.addSeparatorMenuItem(fileMenu);
        MenuFactory.addCloseWindowMenuItem(fileMenu);
        MenuFactory.addCloseDetailsMenuItem(fileMenu);
        MenuFactory.addCloseDownloadBarsToMenu(fileMenu);
    }
    MenuFactory.addSeparatorMenuItem(fileMenu);
    MenuFactory.createTransfersMenuItem(fileMenu);
    /*
		 * No need for restart and exit on OS X since it's already handled on the application menu
		 */
    if (!Constants.isOSX) {
        MenuFactory.addSeparatorMenuItem(fileMenu);
        MenuFactory.addRestartMenuItem(fileMenu);
    }
    if (Constants.isCVSVersion() && !UI.isFirstUI()) {
        MenuItem itemLogout = new MenuItem(fileMenu, SWT.PUSH);
        itemLogout.setText("Shutdown UI (Keep " + Constants.APP_NAME + " running)");
        itemLogout.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
                if (uiFunctions != null) {
                    UISWTInstance uiSWTInstance = uiFunctions.getUISWTInstance();
                    if (uiSWTInstance instanceof UIInstanceFactory) {
                        try {
                            PluginInterface pi = PluginInitializer.getDefaultInterface();
                            pi.getUIManager().detachUI((UIInstanceFactory) uiSWTInstance);
                        } catch (UIException e1) {
                            e1.printStackTrace();
                        }
                    }
                }
            }
        });
    }
    if (!Constants.isOSX) {
        MenuFactory.addExitMenuItem(fileMenu);
    }
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) UIException(com.biglybt.pif.ui.UIException) IMainMenu(com.biglybt.ui.swt.mainwindow.IMainMenu) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIInstanceFactory(com.biglybt.pif.ui.UIInstanceFactory)

Aggregations

PluginInterface (com.biglybt.pif.PluginInterface)1 UIException (com.biglybt.pif.ui.UIException)1 UIInstanceFactory (com.biglybt.pif.ui.UIInstanceFactory)1 IMainMenu (com.biglybt.ui.swt.mainwindow.IMainMenu)1 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)1