Search in sources :

Example 11 with CoreLifecycleAdapter

use of com.biglybt.core.CoreLifecycleAdapter in project BiglyBT by BiglySoftware.

the class UIConfigDefaultsSWTv3 method initialize.

public static void initialize(Core core) {
    ConfigurationManager config = ConfigurationManager.getInstance();
    if ("az2".equalsIgnoreCase(config.getStringParameter("ui", "az3"))) {
        return;
    }
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    boolean startAdvanced = userMode > 1;
    boolean configNeedsSave = false;
    if (System.getProperty("FORCE_PROGRESSIVE", "").length() > 0) {
        // TODO HACK FOR DEMO PURPOSES ONLY!
        config.setParameter("Prioritize First Piece", true);
        configNeedsSave = true;
    }
    final ConfigurationDefaults defaults = ConfigurationDefaults.getInstance();
    defaults.addParameter("ui", "az3");
    defaults.addParameter("Auto Upload Speed Enabled", true);
    defaults.addParameter(ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS, startAdvanced ? ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_ALWAYS : ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_MANY);
    // defaults.addParameter("Add URL Silently", true);			not used 11/30/2015 - see "Activate Window On External Download"
    // defaults.addParameter("add_torrents_silently", true);	not used 11/30/2015
    defaults.addParameter("Popup Download Finished", false);
    defaults.addParameter("Popup Download Added", false);
    defaults.addParameter("Status Area Show SR", false);
    defaults.addParameter("Status Area Show NAT", false);
    defaults.addParameter("Status Area Show IPF", false);
    defaults.addParameter("Status Area Show RIP", true);
    defaults.addParameter("Message Popup Autoclose in Seconds", 10);
    defaults.addParameter("window.maximized", true);
    defaults.addParameter("update.autodownload", true);
    // defaults.addParameter("suppress_file_download_dialog", true);
    defaults.addParameter("auto_remove_inactive_items", false);
    defaults.addParameter("show_torrents_menu", false);
    config.removeParameter("v3.home-tab.starttab");
    defaults.addParameter("MyTorrentsView.table.style", 0);
    defaults.addParameter("v3.Show Welcome", true);
    defaults.addParameter("Library.viewmode", startAdvanced ? 1 : 0);
    defaults.addParameter("LibraryDL.viewmode", startAdvanced ? 1 : 0);
    defaults.addParameter("LibraryDL.UseDefaultIndicatorColor", false);
    defaults.addParameter("LibraryUnopened.viewmode", startAdvanced ? 1 : 0);
    defaults.addParameter("LibraryCD.viewmode", startAdvanced ? 1 : 0);
    defaults.addParameter("Library.EnableSimpleView", 1);
    defaults.addParameter("Library.CatInSideBar", startAdvanced ? 1 : 0);
    defaults.addParameter("Library.TagInSideBar", 1);
    defaults.addParameter("Library.ShowTabsInTorrentView", 1);
    defaults.addParameter("list.dm.dblclick", "0");
    // === defaults used by MainWindow
    defaults.addParameter("vista.adminquit", false);
    defaults.addParameter("Start Minimized", false);
    defaults.addParameter("Password enabled", false);
    defaults.addParameter("ToolBar.showText", true);
    defaults.addParameter("Table.extendedErase", !Constants.isWindowsXP);
    defaults.addParameter("Table.useTree", true);
    // by default, turn off some slidey warning
    // Since they are plugin configs, we need to set the default after the
    // plugin sets the default
    core.addLifecycleListener(new CoreLifecycleAdapter() {

        @Override
        public void started(Core core) {
            defaults.addParameter("Plugin.DHT.dht.warn.user", false);
            defaults.addParameter("Plugin.UPnP.upnp.alertothermappings", false);
            defaults.addParameter("Plugin.UPnP.upnp.alertdeviceproblems", false);
        }
    });
    // run
    if (!COConfigurationManager.hasParameter("v3.StartTab", true)) {
        // Reset 'big' columns, remove some tables that no longer exist
        Map<?, ?> map = FileUtil.readResilientConfigFile("tables.config");
        if (map != null && map.size() > 0) {
            Object[] keys = map.keySet().toArray();
            boolean removedSome = false;
            for (int i = 0; i < keys.length; i++) {
                if (keys[i] instanceof String) {
                    String sKey = (String) keys[i];
                    if (sKey.endsWith(".big") || sKey.startsWith("Table.library-") || sKey.startsWith("Table.Media") || sKey.startsWith("Table.activity.table") || sKey.equals("Table.Activity.big") || sKey.equals("Table.Activity_SB")) {
                        map.remove(sKey);
                        removedSome = true;
                    }
                }
            }
            if (removedSome) {
                FileUtil.writeResilientConfigFile("tables.config", map);
            }
        }
    }
    if (configNeedsSave) {
        config.save();
    }
}
Also used : CoreLifecycleAdapter(com.biglybt.core.CoreLifecycleAdapter) COConfigurationManager(com.biglybt.core.config.COConfigurationManager) Core(com.biglybt.core.Core)

Example 12 with CoreLifecycleAdapter

use of com.biglybt.core.CoreLifecycleAdapter in project BiglyBT by BiglySoftware.

the class SBC_DashboardView method build.

private void build() {
    synchronized (SBC_DashboardView.class) {
        if (!core_running) {
            Core core = CoreFactory.getSingleton();
            if (core.isStarted()) {
                core_running = true;
            } else {
                if (!core_running_listener_added) {
                    core_running_listener_added = true;
                    core.addLifecycleListener(new CoreLifecycleAdapter() {

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

                        @Override
                        public void started(Core core) {
                            synchronized (SBC_DashboardView.class) {
                                core_running = true;
                            }
                            Utils.execSWTThread(new Runnable() {

                                public void run() {
                                    buildSupport();
                                }
                            });
                        }
                    });
                }
                return;
            }
        }
    }
    buildSupport();
}
Also used : CoreLifecycleAdapter(com.biglybt.core.CoreLifecycleAdapter) Core(com.biglybt.core.Core)

Aggregations

Core (com.biglybt.core.Core)12 CoreLifecycleAdapter (com.biglybt.core.CoreLifecycleAdapter)12 CoreComponent (com.biglybt.core.CoreComponent)2 DownloadManager (com.biglybt.core.download.DownloadManager)2 TimerEvent (com.biglybt.core.util.TimerEvent)2 TimerEventPerformer (com.biglybt.core.util.TimerEventPerformer)2 TimerEventPeriodic (com.biglybt.core.util.TimerEventPeriodic)2 BufferedLabel (com.biglybt.ui.swt.components.BufferedLabel)2 IntParameter (com.biglybt.ui.swt.config.IntParameter)2 Parameter (com.biglybt.ui.swt.config.Parameter)2 ParameterChangeAdapter (com.biglybt.ui.swt.config.ParameterChangeAdapter)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Point (org.eclipse.swt.graphics.Point)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 CoreException (com.biglybt.core.CoreException)1 COConfigurationManager (com.biglybt.core.config.COConfigurationManager)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 DownloadManagerInitialisationAdapter (com.biglybt.core.download.DownloadManagerInitialisationAdapter)1