Search in sources :

Example 1 with UIInstance

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

the class SBC_TagsOverview method registerPluginViews.

private void registerPluginViews(final UISWTInstance pluginUI) {
    if (registeredCoreSubViews) {
        return;
    }
    pluginUI.addView(TABLE_TAGS, "TagSettingsView", TagSettingsView.class, null);
    pluginUI.addView(TABLE_TAGS, "MyTorrentsSubView", MyTorrentsSubView.class, null);
    registeredCoreSubViews = true;
    final UIManager uiManager = PluginInitializer.getDefaultInterface().getUIManager();
    uiManager.addUIListener(new UIManagerListener() {

        @Override
        public void UIAttached(UIInstance instance) {
        }

        @Override
        public void UIDetached(UIInstance instance) {
            if (!(instance instanceof UISWTInstance)) {
                return;
            }
            registeredCoreSubViews = false;
            pluginUI.removeViews(TABLE_TAGS, "TagSettingsView");
            pluginUI.removeViews(TABLE_TAGS, "MyTorrentsSubView");
            uiManager.removeUIListener(this);
        }
    });
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 2 with UIInstance

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

the class StatsView method registerPluginViews.

private void registerPluginViews(final UISWTInstance pluginUI) {
    if (pluginUI == null || registeredCoreSubViews) {
        return;
    }
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, ActivityView.MSGID_PREFIX, ActivityView.class, null);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, TransferStatsView.MSGID_PREFIX, TransferStatsView.class, null);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, CacheView.MSGID_PREFIX, CacheView.class, null);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX, DHTView.class, DHTView.DHT_TYPE_MAIN);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTOpsView.MSGID_PREFIX, DHTOpsView.class, DHTOpsView.DHT_TYPE_MAIN);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX, VivaldiView.class, VivaldiView.DHT_TYPE_MAIN);
    if (NetworkAdmin.getSingleton().hasDHTIPV6()) {
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".6", DHTView.class, DHTView.DHT_TYPE_MAIN_V6);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".6", VivaldiView.class, VivaldiView.DHT_TYPE_MAIN_V6);
    }
    if (Constants.isCVSVersion()) {
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".cvs", DHTView.class, DHTView.DHT_TYPE_CVS);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".cvs", VivaldiView.class, VivaldiView.DHT_TYPE_CVS);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".biglybt", DHTView.class, DHTView.DHT_TYPE_BIGLYBT);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".biglybt", VivaldiView.class, VivaldiView.DHT_TYPE_BIGLYBT);
    }
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, TagStatsView.MSGID_PREFIX, TagStatsView.class, null);
    registeredCoreSubViews = true;
    final UIManager uiManager = PluginInitializer.getDefaultInterface().getUIManager();
    uiManager.addUIListener(new UIManagerListener() {

        @Override
        public void UIAttached(UIInstance instance) {
        }

        @Override
        public void UIDetached(UIInstance instance) {
            if (!(instance instanceof UISWTInstance)) {
                return;
            }
            registeredCoreSubViews = false;
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, ActivityView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, TransferStatsView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, CacheView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTOpsView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX);
            if (NetworkAdmin.getSingleton().hasDHTIPV6()) {
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".6");
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".6");
            }
            if (Constants.isCVSVersion()) {
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".cvs");
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".cvs");
            }
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, TagStatsView.MSGID_PREFIX);
            uiManager.removeUIListener(this);
        }
    });
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 3 with UIInstance

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

the class PlatformManagerUnixPlugin method initialize.

// @see com.biglybt.pif.Plugin#initialize(com.biglybt.pif.PluginInterface)
@Override
public void initialize(PluginInterface _plugin_interface) throws PluginException {
    plugin_interface = _plugin_interface;
    plugin_interface.getPluginProperties().setProperty("plugin.name", "Platform-Specific Support");
    // default version if plugin not present
    String version = "1.0";
    PlatformManager platform = PlatformManagerFactory.getPlatformManager();
    if (platform.hasCapability(PlatformManagerCapabilities.GetVersion)) {
        try {
            version = platform.getVersion();
        } catch (Throwable e) {
            Debug.printStackTrace(e);
        }
    } else {
        plugin_interface.getPluginProperties().setProperty("plugin.version.info", "Not required for this platform");
    }
    plugin_interface.getPluginProperties().setProperty("plugin.version", version);
    plugin_interface.getUIManager().addUIListener(new UIManagerListener() {

        boolean done = false;

        @Override
        public void UIDetached(UIInstance instance) {
        }

        @Override
        public void UIAttached(UIInstance instance) {
            if (!done) {
                done = true;
                if (Constants.compareVersions(UpdaterUtils.getUpdaterPluginVersion(), "1.8.5") >= 0) {
                    checkStartupScript();
                }
            }
        }
    });
}
Also used : PlatformManager(com.biglybt.platform.PlatformManager) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 4 with UIInstance

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

the class StaticUtilities method getUIManager.

/**
 * gets the default UI manager and also waits for up to a specified time for a UI instance to
 * attach. useful when doing things during initialisation
 * @param millis_to_wait_for_attach
 * @return
 */
public static UIManager getUIManager(long millis_to_wait_for_attach) {
    final UIManager ui_manager = PluginInitializer.getDefaultInterface().getUIManager();
    if (ui_manager.getUIInstances().length == 0) {
        final AESemaphore sem = new AESemaphore("waitforui");
        ui_manager.addUIListener(new UIManagerListener() {

            @Override
            public void UIAttached(UIInstance instance) {
                ui_manager.removeUIListener(this);
                sem.releaseForever();
            }

            @Override
            public void UIDetached(UIInstance instance) {
            }
        });
        // UIAttached is only fired once initialisation is complete. However, the instance
        // can be made available prior to this and there is a case where this event is blocking
        // the firing of the completion event. therefore pick it up if present directly
        long time_to_go = millis_to_wait_for_attach;
        while (ui_manager.getUIInstances().length == 0) {
            if (sem.reserve(1000)) {
                break;
            }
            time_to_go -= 1000;
            if (time_to_go <= 0) {
                Debug.out("Timeout waiting for UI to attach");
                break;
            }
        }
    }
    return (ui_manager);
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) AESemaphore(com.biglybt.core.util.AESemaphore) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 5 with UIInstance

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

the class StartStopRulesDefaultPlugin method initialize.

@Override
public void initialize(PluginInterface _plugin_interface) {
    if (bAlreadyInitialized) {
        System.err.println("StartStopRulesDefaultPlugin Already initialized!!");
    } else {
        bAlreadyInitialized = true;
    }
    AEDiagnostics.addWeakEvidenceGenerator(this);
    monoStartedOn = SystemTime.getMonotonousTime();
    pi = _plugin_interface;
    plugin_config = pi.getPluginconfig();
    plugin_config.setPluginConfigKeyPrefix("");
    download_manager = pi.getDownloadManager();
    // Create a configModel for StartStopRules
    // We always need to do this in order to set up configuration defaults
    UIManager manager = pi.getUIManager();
    // TODO: don't name it Q
    final BasicPluginConfigModel configModel = manager.createBasicPluginConfigModel(ConfigSection.SECTION_ROOT, "Q");
    setupConfigModel(configModel);
    pi.addListener(new PluginListener() {

        @Override
        public void initializationComplete() {
        }

        @Override
        public void closedownInitiated() {
            closingDown = true;
            // we don't want to go off recalculating stuff when config is saved
            // on closedown
            COConfigurationManager.removeListener(StartStopRulesDefaultPlugin.this);
        }

        @Override
        public void closedownComplete() {
        /* not implemented */
        }
    });
    Runnable r = new Runnable() {

        @Override
        public void run() {
            download_manager.addListener(new StartStopDMListener());
            SimpleTimer.addPeriodicEvent("StartStop:gross", CHECK_FOR_GROSS_CHANGE_PERIOD, new ChangeCheckerTimerTask());
            SimpleTimer.addPeriodicEvent("StartStop:check", PROCESS_CHECK_PERIOD, new ChangeFlagCheckerTask());
        }
    };
    pi.getUtilities().createDelayedTask(r).queue();
    log = pi.getLogger().getTimeStampedChannel("StartStopRules");
    log.log(LoggerChannel.LT_INFORMATION, "Default StartStopRules Plugin Initialisation");
    COConfigurationManager.addListener(this);
    try {
        pi.getUIManager().createLoggingViewModel(log, true);
        pi.getUIManager().addUIListener(new UIManagerListener() {

            @Override
            public void UIAttached(UIInstance instance) {
                TableManager tm = pi.getUIManager().getTableManager();
                seedingRankColumn = tm.createColumn(TableManager.TABLE_MYTORRENTS_COMPLETE, "SeedingRank");
                seedingRankColumn.initialize(TableColumn.ALIGN_TRAIL, TableColumn.POSITION_LAST, 80, TableColumn.INTERVAL_LIVE);
                TableCellRefreshListener columnListener = new SeedingRankColumnListener(downloadDataMap, plugin_config);
                seedingRankColumn.addCellRefreshListener(columnListener);
                tm.addColumn(seedingRankColumn);
                TableColumn downloadingRankColumn = tm.createColumn(TableManager.TABLE_MYTORRENTS_INCOMPLETE, "DownloadingRank");
                downloadingRankColumn.setMinimumRequiredUserMode(1);
                downloadingRankColumn.initialize(TableColumn.ALIGN_TRAIL, TableColumn.POSITION_INVISIBLE, 80, TableColumn.INTERVAL_LIVE);
                columnListener = new DownloadingRankColumnListener(StartStopRulesDefaultPlugin.this);
                downloadingRankColumn.addCellRefreshListener(columnListener);
                tm.addColumn(downloadingRankColumn);
                if (instance.getUIType().equals(UIInstance.UIT_SWT)) {
                    // We have our own config model :)
                    configModel.destroy();
                    try {
                        swt_ui = (UIAdapter) Class.forName("com.biglybt.plugin.startstoprules.defaultplugin.ui.swt.StartStopRulesDefaultPluginSWTUI").getConstructor(new Class[] { PluginInterface.class }).newInstance(new Object[] { pi });
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            }

            @Override
            public void UIDetached(UIInstance instance) {
            }
        });
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
    reloadConfigParams();
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) PluginListener(com.biglybt.pif.PluginListener) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance) BasicPluginConfigModel(com.biglybt.pif.ui.model.BasicPluginConfigModel)

Aggregations

UIInstance (com.biglybt.pif.ui.UIInstance)19 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)18 UIManager (com.biglybt.pif.ui.UIManager)14 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)10 DownloadManager (com.biglybt.core.download.DownloadManager)4 PluginListener (com.biglybt.pif.PluginListener)4 Download (com.biglybt.pif.download.Download)4 MenuItem (com.biglybt.pif.ui.menus.MenuItem)4 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)4 BasicPluginConfigModel (com.biglybt.pif.ui.model.BasicPluginConfigModel)4 Tag (com.biglybt.core.tag.Tag)2 PluginInterface (com.biglybt.pif.PluginInterface)2 DownloadException (com.biglybt.pif.download.DownloadException)2 ParameterListener (com.biglybt.pif.ui.config.ParameterListener)2 BuddyPluginBeta (com.biglybt.plugin.net.buddy.BuddyPluginBeta)2 ArrayList (java.util.ArrayList)2 Core (com.biglybt.core.Core)1 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 Category (com.biglybt.core.category.Category)1 ParameterListener (com.biglybt.core.config.ParameterListener)1