Search in sources :

Example 16 with CoreRunningListener

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

the class TopBarView method skinObjectInitialShow.

@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    this.skin = skinObject.getSkin();
    skin.addListener("topbar-plugins", new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
                skin.removeListener("topbar-plugins", this);
                // building needs UISWTInstance, which needs core.
                CoreFactory.addCoreRunningListener(new CoreRunningListener() {

                    @Override
                    public void coreRunning(Core core) {
                        Utils.execSWTThreadLater(0, new AERunnable() {

                            @Override
                            public void runSupport() {
                                buildTopBarViews();
                            }
                        });
                    }
                });
            }
            return null;
        }
    });
    // trigger autobuild and hook in events
    skin.getSkinObject("topbar-area-plugin").addListener(new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
                if (activeTopBar != null) {
                    activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
                }
            } else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
                if (activeTopBar != null) {
                    activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
                }
            }
            return (null);
        }
    });
    return null;
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) CoreRunningListener(com.biglybt.core.CoreRunningListener) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Core(com.biglybt.core.Core)

Example 17 with CoreRunningListener

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

the class TagPropertyConstraintHandler method checkTimer.

private void checkTimer() {
    if (constrained_tags.size() > 0) {
        if (timer == null) {
            timer = SimpleTimer.addPeriodicEvent("tag:constraint:timer", 30 * 1000, new TimerEventPerformer() {

                @Override
                public void perform(TimerEvent event) {
                    apply_history.clear();
                    apply();
                }
            });
            CoreFactory.addCoreRunningListener(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    synchronized (constrained_tags) {
                        if (timer != null) {
                            core.getPluginManager().getDefaultPluginInterface().getDownloadManager().getGlobalDownloadEventNotifier().addListener(TagPropertyConstraintHandler.this);
                            dm_listener_added = true;
                        }
                    }
                }
            });
        }
    } else if (timer != null) {
        timer.cancel();
        timer = null;
        if (dm_listener_added) {
            core.getPluginManager().getDefaultPluginInterface().getDownloadManager().getGlobalDownloadEventNotifier().removeListener(this);
        }
        apply_history.clear();
    }
}
Also used : CoreRunningListener(com.biglybt.core.CoreRunningListener) Core(com.biglybt.core.Core)

Example 18 with CoreRunningListener

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

the class TorrentListener method handleMessage.

@Override
public void handleMessage(final BrowserMessage message) {
    String opid = message.getOperationId();
    if (OP_LOAD_TORRENT.equals(opid) || OP_LOAD_TORRENT_OLD.equals(opid)) {
        final Map decodedMap = message.getDecodedMap();
        String url = MapUtils.getMapString(decodedMap, "url", null);
        final boolean playNow = MapUtils.getMapBoolean(decodedMap, "play-now", false);
        final boolean playPrepare = MapUtils.getMapBoolean(decodedMap, "play-prepare", false);
        final boolean bringToFront = MapUtils.getMapBoolean(decodedMap, "bring-to-front", true);
        if (url != null) {
            if (torrentURLHandler != null) {
                try {
                    torrentURLHandler.handleTorrentURL(url);
                } catch (Throwable e) {
                    Debug.printStackTrace(e);
                }
            }
            final DownloadUrlInfo dlInfo = new DownloadUrlInfo(url);
            dlInfo.setReferer(message.getReferer());
            CoreFactory.addCoreRunningListener(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    TorrentUIUtilsV3.loadTorrent(dlInfo, playNow, playPrepare, bringToFront);
                }
            });
        } else {
            CoreFactory.addCoreRunningListener(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    loadTorrentByB64(core, message, MapUtils.getMapString(decodedMap, "b64", null));
                }
            });
        }
    } else {
        throw new IllegalArgumentException("Unknown operation: " + opid);
    }
}
Also used : DownloadUrlInfo(com.biglybt.ui.selectedcontent.DownloadUrlInfo) CoreRunningListener(com.biglybt.core.CoreRunningListener) Map(java.util.Map) Core(com.biglybt.core.Core)

Example 19 with CoreRunningListener

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

the class ConfigListener method checkForUpdates.

/**
 * @since 3.0.5.3
 */
public static void checkForUpdates() {
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        uiFunctions.bringToFront();
    }
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            UpdateMonitor.getSingleton(core).performCheck(true, false, false, null);
        }
    });
}
Also used : CoreRunningListener(com.biglybt.core.CoreRunningListener) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) Core(com.biglybt.core.Core)

Example 20 with CoreRunningListener

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

the class DeviceManagerUI method createTranscodingSection.

public void createTranscodingSection() {
    // default dir
    String def = device_manager.getDefaultWorkingDirectory().getAbsolutePath();
    final DirectoryParameter def_work_dir = configModel.addDirectoryParameter2("device.config.xcode.workdir", "device.config.xcode.workdir", def);
    def_work_dir.setValue(def);
    def_work_dir.addListener(new ParameterListener() {

        @Override
        public void parameterChanged(Parameter param) {
            device_manager.setDefaultWorkingDirectory(new File(def_work_dir.getValue()));
        }
    });
    // max xcode
    final IntParameter max_xcode = configModel.addIntParameter2("device.config.xcode.maxbps", "device.config.xcode.maxbps", (int) (device_manager.getTranscodeManager().getQueue().getMaxBytesPerSecond() / 1024), 0, Integer.MAX_VALUE);
    max_xcode.addListener(new ParameterListener() {

        @Override
        public void parameterChanged(Parameter param) {
            device_manager.getTranscodeManager().getQueue().setMaxBytesPerSecond(max_xcode.getValue() * 1024);
        }
    });
    // disable sleep
    final BooleanParameter disable_sleep = configModel.addBooleanParameter2("device.config.xcode.disable_sleep", "device.config.xcode.disable_sleep", device_manager.getDisableSleep());
    disable_sleep.addListener(new ParameterListener() {

        @Override
        public void parameterChanged(Parameter param) {
            device_manager.setDisableSleep(disable_sleep.getValue());
        }
    });
    // itunes
    final ActionParameter btnITunes = configModel.addActionParameter2("devices.button.installitunes", "UpdateWindow.columns.install");
    btnITunes.setEnabled(false);
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            boolean hasItunes = core.getPluginManager().getPluginInterfaceByID("azitunes") != null;
            btnITunes.setEnabled(!hasItunes);
        }
    });
    btnITunes.addListener(new ParameterListener() {

        @Override
        public void parameterChanged(Parameter param) {
            CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    try {
                        PluginInstaller installer = core.getPluginManager().getPluginInstaller();
                        StandardPlugin itunes_plugin = installer.getStandardPlugin("azitunes");
                        if (itunes_plugin == null) {
                            Debug.out("iTunes standard plugin not found");
                        } else {
                            itunes_plugin.install(false);
                        }
                    } catch (Throwable e) {
                        Debug.printStackTrace(e);
                    }
                }
            });
        }
    });
    configModel.createGroup("device.xcode.group", new Parameter[] { def_work_dir, max_xcode, disable_sleep, btnITunes });
}
Also used : StandardPlugin(com.biglybt.pif.installer.StandardPlugin) PluginInstaller(com.biglybt.pif.installer.PluginInstaller) CoreRunningListener(com.biglybt.core.CoreRunningListener) File(java.io.File) DiskManagerFileInfoFile(com.biglybt.core.download.DiskManagerFileInfoFile) VuzeFile(com.biglybt.core.vuzefile.VuzeFile) Core(com.biglybt.core.Core)

Aggregations

Core (com.biglybt.core.Core)35 CoreRunningListener (com.biglybt.core.CoreRunningListener)35 DownloadManager (com.biglybt.core.download.DownloadManager)8 GridLayout (org.eclipse.swt.layout.GridLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 GlobalManager (com.biglybt.core.global.GlobalManager)5 AERunnable (com.biglybt.core.util.AERunnable)5 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)4 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)4 MessageText (com.biglybt.core.internat.MessageText)3 LogAlert (com.biglybt.core.logging.LogAlert)3 Tag (com.biglybt.core.tag.Tag)3 TOTorrent (com.biglybt.core.torrent.TOTorrent)3 VuzeFile (com.biglybt.core.vuzefile.VuzeFile)3 UIFunctions (com.biglybt.ui.UIFunctions)3 File (java.io.File)3 List (java.util.List)3 GridData (org.eclipse.swt.layout.GridData)3 ParameterListener (com.biglybt.core.config.ParameterListener)2 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)2