Search in sources :

Example 1 with SpeedTestWizard

use of com.biglybt.ui.swt.speedtest.SpeedTestWizard in project BiglyBT by BiglySoftware.

the class CocoaUIEnhancer method initialize.

private void initialize() throws Exception {
    // Get the Mac OS X Application menu.
    Object sharedApplication = invoke(nsapplicationCls, "sharedApplication");
    Object mainMenu = invoke(sharedApplication, "mainMenu");
    Object mainMenuItem = invoke(nsmenuCls, mainMenu, "itemAtIndex", new Object[] { wrapPointer(0) });
    Object appMenu = invoke(mainMenuItem, "submenu");
    // disable services menu
    Object servicesMenuItem = invoke(nsmenuCls, appMenu, "itemAtIndex", new Object[] { wrapPointer(kServicesMenuItem) });
    invoke(nsmenuitemCls, servicesMenuItem, "setEnabled", new Object[] { false });
    Menu systemMenu = Display.getCurrent().getSystemMenu();
    if (systemMenu != null) {
        MenuItem sysItem = getItem(systemMenu, SWT.ID_ABOUT);
        if (sysItem != null) {
            sysItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    AboutWindow.show();
                }
            });
        }
        sysItem = getItem(systemMenu, SWT.ID_PREFERENCES);
        if (sysItem != null) {
            sysItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                    if (uiFunctions != null) {
                        uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG);
                    }
                }
            });
        }
        int quitIndex = systemMenu.indexOf(getItem(systemMenu, SWT.ID_QUIT));
        MenuItem restartItem = new MenuItem(systemMenu, SWT.CASCADE, quitIndex);
        Messages.setLanguageText(restartItem, "MainWindow.menu.file.restart");
        restartItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                if (uiFunctions != null) {
                    uiFunctions.dispose(true, false);
                }
            }
        });
        // Add other menus
        boolean isAZ3 = "az3".equalsIgnoreCase(COConfigurationManager.getStringParameter("ui"));
        if (!isAZ3) {
            // add Wizard, NAT Test, Speed Test
            int prefIndex = systemMenu.indexOf(getItem(systemMenu, SWT.ID_PREFERENCES)) + 1;
            MenuItem wizItem = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
            Messages.setLanguageText(wizItem, "MainWindow.menu.file.configure");
            wizItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    new ConfigureWizard(false, ConfigureWizard.WIZARD_MODE_FULL);
                }
            });
            MenuItem natMenu = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
            Messages.setLanguageText(natMenu, "MainWindow.menu.tools.nattest");
            natMenu.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    new NatTestWindow();
                }
            });
            MenuItem netstatMenu = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
            Messages.setLanguageText(netstatMenu, "MainWindow.menu.tools.netstat");
            netstatMenu.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
                    if (uiFunctions != null) {
                        PluginsMenuHelper.IViewInfo[] views = PluginsMenuHelper.getInstance().getPluginViewsInfo();
                        for (PluginsMenuHelper.IViewInfo view : views) {
                            String viewID = view.viewID;
                            if (viewID != null && viewID.equals("aznetstatus")) {
                                view.openView(uiFunctions);
                            }
                        }
                    }
                }
            });
            MenuItem speedMenu = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
            Messages.setLanguageText(speedMenu, "MainWindow.menu.tools.speedtest");
            speedMenu.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    new SpeedTestWizard();
                }
            });
        }
    }
    // Register names in objective-c.
    if (sel_applicationShouldHandleReopen_ == 0) {
        sel_applicationShouldHandleReopen_ = registerName(osCls, "applicationShouldHandleReopen:hasVisibleWindows:");
    }
    // Add the action callbacks for menu items.
    invoke(osCls, "class_addMethod", new Object[] { wrapPointer(delegateIdSWTApplication), wrapPointer(sel_applicationShouldHandleReopen_), wrapPointer(callBack4Addr), "@:@c" });
    initialized = true;
}
Also used : NatTestWindow(com.biglybt.ui.swt.nat.NatTestWindow) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) PluginsMenuHelper(com.biglybt.ui.swt.mainwindow.PluginsMenuHelper) ConfigureWizard(com.biglybt.ui.swt.config.wizard.ConfigureWizard) UIFunctions(com.biglybt.ui.UIFunctions) SpeedTestWizard(com.biglybt.ui.swt.speedtest.SpeedTestWizard) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

UIFunctions (com.biglybt.ui.UIFunctions)1 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)1 ConfigureWizard (com.biglybt.ui.swt.config.wizard.ConfigureWizard)1 PluginsMenuHelper (com.biglybt.ui.swt.mainwindow.PluginsMenuHelper)1 NatTestWindow (com.biglybt.ui.swt.nat.NatTestWindow)1 SpeedTestWizard (com.biglybt.ui.swt.speedtest.SpeedTestWizard)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1