Search in sources :

Example 1 with ConfigureWizard

use of com.biglybt.ui.swt.config.wizard.ConfigureWizard in project BiglyBT by BiglySoftware.

the class MainWindowImpl method showMainWindow.

private void showMainWindow() {
    configShowDLBasketListener = new ParameterListener() {

        @Override
        public void parameterChanged(String parameterName) {
            configureDownloadBasket();
        }
    };
    COConfigurationManager.addAndFireParameterListener("Show Download Basket", configShowDLBasketListener);
    boolean isOSX = com.biglybt.core.util.Constants.isOSX;
    boolean bEnableTray = COConfigurationManager.getBooleanParameter("Enable System Tray");
    boolean bPassworded = COConfigurationManager.getBooleanParameter("Password enabled");
    boolean bStartMinimize = bEnableTray && (bPassworded || COConfigurationManager.getBooleanParameter("Start Minimized"));
    SWTSkinObject soMain = skin.getSkinObject("main");
    if (soMain != null) {
        soMain.getControl().setVisible(true);
    }
    shell.addListener(SWT.Show, new Listener() {

        @Override
        public void handleEvent(Event event) {
            System.out.println("---------SHOWN AT " + SystemTime.getCurrentTime() + ";" + (SystemTime.getCurrentTime() - Initializer.startTime) + "ms");
            if (statusBar != null) {
                Utils.execSWTThreadLater(10, new Runnable() {

                    @Override
                    public void run() {
                        statusBar.relayout();
                    }
                });
            }
            // bring back and stand-alone shells
            ShellManager.sharedManager().performForShells(new Listener() {

                @Override
                public void handleEvent(Event event) {
                    Shell this_shell = (Shell) event.widget;
                    if (this_shell.getParent() == null && !this_shell.isVisible()) {
                        boolean minimize;
                        synchronized (minimized_on_hide) {
                            minimize = minimized_on_hide.remove(this_shell);
                        }
                        this_shell.setVisible(true);
                        if (minimize) {
                            this_shell.setMinimized(true);
                        } else {
                            this_shell.moveAbove(shell);
                        }
                    }
                }
            });
        }
    });
    if (!bStartMinimize) {
        shell.open();
        if (!isOSX) {
            shell.forceActive();
        }
    }
    if (delayedCore) {
        // max 5 seconds of dispatching.  We don't display.sleep here because
        // we only want to clear the backlog of SWT events, and sleep would
        // add new ones
        Display display = Utils.getDisplay();
        if (display == null) {
            return;
        }
        try {
            long endSWTDispatchOn = SystemTime.getOffsetTime(5000);
            while (SystemTime.getCurrentTime() < endSWTDispatchOn && !display.isDisposed() && display.readAndDispatch()) ;
        } catch (Exception e) {
            Debug.out(e);
        }
        System.out.println("---------DONE DISPATCH AT " + SystemTime.getCurrentTime() + ";" + (SystemTime.getCurrentTime() - Initializer.startTime) + "ms");
        if (display.isDisposed()) {
            return;
        }
    }
    if (bEnableTray) {
        try {
            systemTraySWT = SystemTraySWT.getTray();
        } catch (Throwable e) {
            e.printStackTrace();
            Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "Upgrade to SWT3.0M8 or later for system tray support."));
        }
        if (bStartMinimize) {
            minimizeToTray(null);
        } else // Only show the password if not started minimized
        // Correct bug #878227
        {
            if (bPassworded) {
                minimizeToTray(null);
                // invokes password
                setVisible(true);
            }
        }
    }
    if (uiInitializer != null) {
        uiInitializer.initializationComplete();
    }
    boolean run_speed_test = false;
    if (!Utils.isAZ2UI() && !COConfigurationManager.getBooleanParameter("SpeedTest Completed")) {
        if (ConfigurationChecker.isNewInstall()) {
            run_speed_test = true;
        } else if (FeatureAvailability.triggerSpeedTestV1()) {
            long upload_limit = COConfigurationManager.getLongParameter("Max Upload Speed KBs");
            boolean auto_up = COConfigurationManager.getBooleanParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY);
            if (auto_up) {
                if (upload_limit <= 18) {
                    run_speed_test = true;
                }
            } else {
                boolean up_seed_limit = COConfigurationManager.getBooleanParameter("enable.seedingonly.upload.rate");
                if (upload_limit == 0 && !up_seed_limit) {
                    run_speed_test = true;
                }
            }
        }
    }
    if (run_speed_test) {
        SpeedTestSelector.runMLABTest(new AERunnable() {

            @Override
            public void runSupport() {
                WelcomeView.setWaitLoadingURL(false);
            }
        });
    } else {
        WelcomeView.setWaitLoadingURL(false);
    }
    if (Utils.isAZ2UI()) {
        if (!COConfigurationManager.getBooleanParameter("Wizard Completed")) {
            CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    new ConfigureWizard(false, ConfigureWizard.WIZARD_MODE_FULL);
                }
            });
        }
        checkForWhatsNewWindow();
    }
    AssociationChecker.checkAssociations();
    // Donation stuff
    Map<?, ?> map = VersionCheckClient.getSingleton().getMostRecentVersionCheckData();
    DonationWindow.setInitialAskHours(MapUtils.getMapInt(map, "donations.askhrs", DonationWindow.getInitialAskHours()));
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            core.triggerLifeCycleComponentCreated(uiFunctions);
        }
    });
    System.out.println("---------READY AT " + SystemTime.getCurrentTime() + ";" + (SystemTime.getCurrentTime() - Initializer.startTime) + "ms");
    isReady = true;
// SESecurityManagerImpl.getSingleton().exitVM(0);
}
Also used : MdiEntryLogIdListener(com.biglybt.ui.mdi.MdiEntryLogIdListener) ParameterListener(com.biglybt.core.config.ParameterListener) MdiListener(com.biglybt.ui.mdi.MdiListener) NavigationHelper.navigationListener(com.biglybt.util.NavigationHelper.navigationListener) GlobalManagerListener(com.biglybt.core.global.GlobalManagerListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) ConfigureWizard(com.biglybt.ui.swt.config.wizard.ConfigureWizard) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) ObfuscateShell(com.biglybt.ui.swt.debug.ObfuscateShell) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) CoreRunningListener(com.biglybt.core.CoreRunningListener) ParameterListener(com.biglybt.core.config.ParameterListener) Core(com.biglybt.core.Core)

Example 2 with ConfigureWizard

use of com.biglybt.ui.swt.config.wizard.ConfigureWizard 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

ConfigureWizard (com.biglybt.ui.swt.config.wizard.ConfigureWizard)2 Core (com.biglybt.core.Core)1 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 GlobalManagerListener (com.biglybt.core.global.GlobalManagerListener)1 UIFunctions (com.biglybt.ui.UIFunctions)1 MdiEntryLogIdListener (com.biglybt.ui.mdi.MdiEntryLogIdListener)1 MdiListener (com.biglybt.ui.mdi.MdiListener)1 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)1 ObfuscateShell (com.biglybt.ui.swt.debug.ObfuscateShell)1 PluginsMenuHelper (com.biglybt.ui.swt.mainwindow.PluginsMenuHelper)1 NatTestWindow (com.biglybt.ui.swt.nat.NatTestWindow)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 SpeedTestWizard (com.biglybt.ui.swt.speedtest.SpeedTestWizard)1 SWTRunnable (com.biglybt.ui.swt.utils.SWTRunnable)1 NavigationHelper.navigationListener (com.biglybt.util.NavigationHelper.navigationListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1