Search in sources :

Example 1 with SWTNetworkSelection

use of com.biglybt.ui.swt.networks.SWTNetworkSelection in project BiglyBT by BiglySoftware.

the class Initializer method run.

@Override
public void run() {
    DelayedTask delayed_task = UtilitiesImpl.addDelayedTask("SWT Initialisation", new Runnable() {

        @Override
        public void run() {
            init_task.reserve();
        }
    });
    delayed_task.queueFirst();
    // initialise the SWT locale util
    long startTime = SystemTime.getCurrentTime();
    new LocaleUtilSWT(core);
    final Display display = Utils.getDisplay();
    new UIMagnetHandler(core);
    if (!STARTUP_UIFIRST) {
        // Ensure colors initialized
        Colors.getInstance();
        UIConfigDefaultsSWT.initialize();
        UIConfigDefaultsSWTv3.initialize(core);
    } else {
        COConfigurationManager.setBooleanDefault("Show Splash", false);
    }
    if (COConfigurationManager.getBooleanParameter("Show Splash")) {
        display.asyncExec(new AERunnable() {

            @Override
            public void runSupport() {
                new SplashWindow(display, Initializer.this);
            }
        });
    }
    System.out.println("Locale Initializing took " + (SystemTime.getCurrentTime() - startTime) + "ms");
    startTime = SystemTime.getCurrentTime();
    core.addLifecycleListener(new CoreLifecycleAdapter() {

        @Override
        public void componentCreated(Core core, CoreComponent component) {
            Initializer.this.reportPercent(curPercent + 1);
            if (component instanceof GlobalManager) {
                reportCurrentTaskByKey("splash.initializePlugins");
                InitialisationFunctions.earlyInitialisation(core);
            } else if (component instanceof PluginInterface) {
                PluginInterface pi = (PluginInterface) component;
                String name = pi.getPluginName();
                String version = pi.getPluginVersion();
                // text says initializing, but it's actually initialized.  close enough
                String s = MessageText.getString("splash.plugin.init") + " " + name + (version == null ? "" : (" v" + version));
                reportCurrentTask(s);
            }
        }

        // @see com.biglybt.core.CoreLifecycleAdapter#started(com.biglybt.core.Core)
        @Override
        public void started(Core core) {
            handleCoreStarted(core);
        }

        @Override
        public void stopping(Core core) {
            Alerts.stopInitiated();
        }

        @Override
        public void stopped(Core core) {
        }

        @Override
        public boolean syncInvokeRequired() {
            return (true);
        }

        @Override
        public boolean requiresPluginInitCompleteBeforeStartedEvent() {
            return (false);
        }

        @Override
        public boolean stopRequested(Core _core) throws CoreException {
            return handleStopRestart(false);
        }

        @Override
        public boolean restartRequested(final Core core) {
            return handleStopRestart(true);
        }
    });
    reportCurrentTaskByKey("splash.initializeCore");
    boolean uiClassic = COConfigurationManager.getStringParameter("ui").equals("az2");
    try {
        new SearchUI();
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
    try {
        subscriptionManagerUI = new SubscriptionManagerUI();
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
    if (!uiClassic) {
        try {
            deviceManagerUI = new DeviceManagerUI(core);
        } catch (Throwable e) {
            Debug.printStackTrace(e);
        }
    }
    if (core.canStart()) {
        // Other UIs could start the core before us
        if (!core.isStarted()) {
            core.start();
        } else {
            handleCoreStarted(core);
        }
        reportPercent(50);
        System.out.println("Core Initializing took " + (SystemTime.getCurrentTime() - startTime) + "ms");
        startTime = SystemTime.getCurrentTime();
        reportCurrentTaskByKey("splash.initializeUIElements");
        // Ensure colors initialized
        Colors.getInstance();
        reportPercent(curPercent + 1);
        Alerts.init();
        reportPercent(curPercent + 1);
        ProgressWindow.register(core);
        reportPercent(curPercent + 1);
        new SWTNetworkSelection();
        reportPercent(curPercent + 1);
        new AuthenticatorWindow();
        new CryptoWindow();
        reportPercent(curPercent + 1);
        new CertificateTrustWindow();
        core.getPluginManager().getPluginInstaller().addListener(new PluginInstallerListener() {

            @Override
            public boolean installRequest(final String reason, final InstallablePlugin plugin) throws PluginException {
                if (plugin instanceof StandardPlugin) {
                    Map<Integer, Object> properties = new HashMap<>();
                    properties.put(UpdateCheckInstance.PT_UI_EXTRA_MESSAGE, reason);
                    plugin.install(false, false, false, properties);
                    return (true);
                } else {
                    return (false);
                }
            }
        });
    } else {
        CoreWaiterSWT.startupAbandoned();
        final AESemaphore sem = new AESemaphore("waiter");
        Utils.execSWTThread(new Runnable() {

            @Override
            public void run() {
                MessageBoxShell mb = new MessageBoxShell(MessageText.getString("msgbox.force.close.title"), MessageText.getString("msgbox.force.close.text", new String[] { core.getLockFile().getAbsolutePath() }), new String[] { MessageText.getString("Button.ok") }, 0);
                mb.setIconResource("error");
                mb.setModal(true);
                mb.open(new UserPrompterResultListener() {

                    @Override
                    public void prompterClosed(int result) {
                        sem.releaseForever();
                    }
                });
            }
        });
        sem.reserve();
        SESecurityManager.exitVM(1);
    }
}
Also used : DeviceManagerUI(com.biglybt.ui.swt.devices.DeviceManagerUI) PluginInstallerListener(com.biglybt.pif.installer.PluginInstallerListener) AuthenticatorWindow(com.biglybt.ui.swt.auth.AuthenticatorWindow) SearchUI(com.biglybt.ui.swt.search.SearchUI) CertificateTrustWindow(com.biglybt.ui.swt.auth.CertificateTrustWindow) GlobalManager(com.biglybt.core.global.GlobalManager) DelayedTask(com.biglybt.pif.utils.DelayedTask) SubscriptionManagerUI(com.biglybt.ui.swt.subscriptions.SubscriptionManagerUI) PluginInterface(com.biglybt.pif.PluginInterface) PluginException(com.biglybt.pif.PluginException) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) StandardPlugin(com.biglybt.pif.installer.StandardPlugin) InstallablePlugin(com.biglybt.pif.installer.InstallablePlugin) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) CryptoWindow(com.biglybt.ui.swt.auth.CryptoWindow) SWTNetworkSelection(com.biglybt.ui.swt.networks.SWTNetworkSelection) Map(java.util.Map) HashMap(java.util.HashMap) Display(org.eclipse.swt.widgets.Display)

Aggregations

GlobalManager (com.biglybt.core.global.GlobalManager)1 PluginException (com.biglybt.pif.PluginException)1 PluginInterface (com.biglybt.pif.PluginInterface)1 InstallablePlugin (com.biglybt.pif.installer.InstallablePlugin)1 PluginInstallerListener (com.biglybt.pif.installer.PluginInstallerListener)1 StandardPlugin (com.biglybt.pif.installer.StandardPlugin)1 DelayedTask (com.biglybt.pif.utils.DelayedTask)1 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)1 AuthenticatorWindow (com.biglybt.ui.swt.auth.AuthenticatorWindow)1 CertificateTrustWindow (com.biglybt.ui.swt.auth.CertificateTrustWindow)1 CryptoWindow (com.biglybt.ui.swt.auth.CryptoWindow)1 DeviceManagerUI (com.biglybt.ui.swt.devices.DeviceManagerUI)1 SWTNetworkSelection (com.biglybt.ui.swt.networks.SWTNetworkSelection)1 SearchUI (com.biglybt.ui.swt.search.SearchUI)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 SubscriptionManagerUI (com.biglybt.ui.swt.subscriptions.SubscriptionManagerUI)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Display (org.eclipse.swt.widgets.Display)1