Search in sources :

Example 26 with CoreRunningListener

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

the class MyTorrentsSuperView method initialize.

public void initialize(final Composite parent) {
    if (form != null) {
        return;
    }
    form = new Composite(parent, SWT.NONE);
    FormLayout flayout = new FormLayout();
    flayout.marginHeight = 0;
    flayout.marginWidth = 0;
    form.setLayout(flayout);
    GridData gridData;
    gridData = new GridData(GridData.FILL_BOTH);
    form.setLayoutData(gridData);
    GridLayout layout;
    child1 = new Composite(form, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    child1.setLayout(layout);
    final Sash sash = Utils.createSash(form, SASH_WIDTH);
    child2 = new Composite(form, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    child2.setLayout(layout);
    FormData formData;
    // More precision, times by 100
    int weight = (int) (COConfigurationManager.getFloatParameter("MyTorrents.SplitAt"));
    if (weight > 10000) {
        weight = 10000;
    } else if (weight < 100) {
        weight *= 100;
    }
    // Min/max of 5%/95%
    if (weight < 500) {
        weight = 500;
    } else if (weight > 9000) {
        weight = 9000;
    }
    double pct = (float) weight / 10000;
    sash.setData("PCT", new Double(pct));
    // FormData for table child1
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment((int) (pct * 100), 0);
    child1.setLayoutData(formData);
    final FormData child1Data = formData;
    // sash
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(child1);
    formData.height = SASH_WIDTH;
    sash.setLayoutData(formData);
    // child2
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    formData.top = new FormAttachment(sash);
    child2.setLayoutData(formData);
    // Listeners to size the folder
    sash.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final boolean FASTDRAG = true;
            if (FASTDRAG && e.detail == SWT.DRAG)
                return;
            child1Data.height = e.y + e.height - SASH_WIDTH;
            form.layout();
            Double l = new Double((double) child1.getBounds().height / form.getBounds().height);
            sash.setData("PCT", l);
            if (e.detail != SWT.DRAG) {
                int i = (int) (l.doubleValue() * 10000);
                COConfigurationManager.setParameter("MyTorrents.SplitAt", i);
            }
        }
    });
    form.addListener(SWT.Resize, new DelayedListenerMultiCombiner() {

        @Override
        public void handleDelayedEvent(Event e) {
            if (sash.isDisposed()) {
                return;
            }
            Double l = (Double) sash.getData("PCT");
            if (l == null) {
                return;
            }
            int newHeight = (int) (form.getBounds().height * l.doubleValue());
            if (child1Data.height != newHeight || child1Data.bottom != null) {
                child1Data.bottom = null;
                child1Data.height = newHeight;
                form.layout();
            }
        }
    });
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(final Core core) {
            Utils.execSWTThread(new AERunnable() {

                @Override
                public void runSupport() {
                    initializeWithCore(core, parent);
                }
            });
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DelayedListenerMultiCombiner(com.biglybt.ui.swt.DelayedListenerMultiCombiner) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CoreRunningListener(com.biglybt.core.CoreRunningListener) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Core(com.biglybt.core.Core) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 27 with CoreRunningListener

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

the class MyTrackerView method defaultSelected.

// @see TableSelectionListener#defaultSelected(TableRowCore[])
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask) {
    final TRHostTorrent torrent = (TRHostTorrent) tv.getFirstSelectedDataSource();
    if (torrent == null)
        return;
    CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            DownloadManager dm = core.getGlobalManager().getDownloadManager(torrent.getTorrent());
            if (dm != null) {
                UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                if (uiFunctions != null) {
                    uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, dm);
                }
            }
        }
    });
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) CoreRunningListener(com.biglybt.core.CoreRunningListener) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) DownloadManager(com.biglybt.core.download.DownloadManager) Core(com.biglybt.core.Core)

Example 28 with CoreRunningListener

use of com.biglybt.core.CoreRunningListener 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 29 with CoreRunningListener

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

the class PluginManagerImpl method startClient.

/**
 * Starts client.
 * <p>
 * With the exception of null ui, method does not return until client is closed.
 *
 * @param ui "swt", "console", "telnet", etc
 * @param properties
 */
public static void startClient(String ui, Properties properties, final StartClientListener startClientListener) throws PluginException {
    try {
        class_mon.enter();
        if (running) {
            throw (new RuntimeException(Constants.APP_NAME + " is already running"));
        }
        running = true;
    } finally {
        class_mon.exit();
    }
    String config_dir = (String) properties.get(PR_USER_DIRECTORY);
    if (config_dir != null) {
        System.setProperty(SystemProperties.SYSPROP_CONFIG_PATH, config_dir);
    }
    String user_dir = (String) properties.get(PR_APP_DIRECTORY);
    if (user_dir != null) {
        System.setProperty(SystemProperties.SYSPROP_INSTALL_PATH, user_dir);
        System.setProperty("user.dir", user_dir);
    }
    String doc_dir = (String) properties.get(PR_DOC_DIRECTORY);
    if (doc_dir != null) {
        System.setProperty(SystemProperties.SYSPROP_DOC_PATH, doc_dir);
    }
    String disable_native = (String) properties.get(PR_DISABLE_NATIVE_SUPPORT);
    if (disable_native != null && disable_native.equalsIgnoreCase("true")) {
        System.setProperty(SystemProperties.SYSPROP_PLATFORM_MANAGER_DISABLE, "true");
    }
    if (startClientListener != null) {
        CoreFactory.addCoreRunningListener(new CoreRunningListener() {

            @Override
            public void coreRunning(Core core) {
                startClientListener.clientStarted(core.getPluginManager());
            }
        });
    }
    if (ui == null) {
        try {
            core = CoreFactory.create();
            core.start();
        } catch (Throwable e) {
            Debug.printStackTrace(e);
            throw (new PluginException(Constants.APP_NAME + " failed to start", e));
        }
    } else {
        // Most likely, a plugin is calling this from their main(), which
        // will not be using our primary class loader.  Which means we already
        // have some core classes initialized on it, making it too late to
        // switch. (For example, aereg.dll will already be loaded, and the class
        // loading switch will cause an exception when trying to laod it again)
        System.setProperty("USE_OUR_PRIMARYCLASSLOADER", "0");
        String mi = (String) properties.get(PluginManager.PR_MULTI_INSTANCE);
        if (mi != null && mi.equalsIgnoreCase("true")) {
            System.setProperty(PluginManager.PR_MULTI_INSTANCE, "true");
        }
        try {
            Class.forName("com.biglybt.ui.Main").getMethod("main", new Class[] { String[].class }).invoke(null, (Object) new String[] { "--ui=" + ui });
        } catch (Throwable e) {
            throw (new PluginException("Main method invocation failed", e));
        }
    }
}
Also used : PluginException(com.biglybt.pif.PluginException) CoreRunningListener(com.biglybt.core.CoreRunningListener) Core(com.biglybt.core.Core)

Example 30 with CoreRunningListener

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

the class SBC_SubscriptionResultsView method skinObjectInitialShow.

@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            initColumns(core);
        }
    });
    MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi != null && ds != null) {
        String mdi_key = "Subscription_" + ByteFormatter.encodeString(ds.getPublicKey());
        mdi_entry = mdi.getEntry(mdi_key);
        if (mdi_entry != null) {
            mdi_entry.addToolbarEnabler(this);
        }
    }
    if (ds != null) {
        if ((ds.getViewOptions() & Subscription.VO_HIDE_HEADER) != 0) {
            SWTSkinObject top_area = getSkinObject("toparea");
            top_area.setVisible(false);
        }
        SWTSkinObjectText title = (SWTSkinObjectText) getSkinObject("title");
        if (title != null) {
            title.setText(MessageText.getString("subs.results.view.title", new String[] { ds.getName() }));
            Control control = title.getControl();
            final Menu menu = new Menu(control);
            control.setMenu(menu);
            final String menu_key = SubscriptionMDIEntry.setupMenus(ds, null);
            menu.addMenuListener(new MenuListener() {

                @Override
                public void menuShown(MenuEvent e) {
                    for (MenuItem mi : menu.getItems()) {
                        mi.dispose();
                    }
                    com.biglybt.pif.ui.menus.MenuItem[] menu_items = MenuItemManager.getInstance().getAllAsArray(menu_key);
                    MenuBuildUtils.addPluginMenuItems(menu_items, menu, true, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl(new Object[] { ds }));
                }

                @Override
                public void menuHidden(MenuEvent e) {
                // TODO Auto-generated method stub
                }
            });
        }
    }
    SWTSkinObjectTextbox soFilterBox = (SWTSkinObjectTextbox) getSkinObject("filterbox");
    if (soFilterBox != null) {
        txtFilter = soFilterBox.getTextControl();
    }
    final SWTSkinObject soFilterArea = getSkinObject("filterarea");
    if (soFilterArea != null) {
        SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
        if (soFilterButton != null) {
            boolean toggled = COConfigurationManager.getBooleanParameter("Subscription View Filter Options Expanded", false);
            if (toggled) {
                soFilterButton.setToggled(true);
                soFilterArea.setVisible(true);
            }
            soFilterButton.addSelectionListener(new SWTSkinToggleListener() {

                @Override
                public void toggleChanged(SWTSkinObjectToggle so, boolean toggled) {
                    COConfigurationManager.setParameter("Subscription View Filter Options Expanded", toggled);
                    soFilterArea.setVisible(toggled);
                    Utils.relayout(soFilterArea.getControl().getParent());
                }
            });
        }
        Composite parent = (Composite) soFilterArea.getControl();
        Label label;
        FormData fd;
        GridLayout layout;
        int sepHeight = 20;
        Composite cFilters = new Composite(parent, SWT.NONE);
        fd = Utils.getFilledFormData();
        cFilters.setLayoutData(fd);
        layout = new GridLayout(1, true);
        layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
        layout.marginWidth = layout.marginHeight = 0;
        cFilters.setLayout(layout);
        SubscriptionResultFilter filters = null;
        Runnable pFilterUpdater = null;
        if (ds != null && ds.isUpdateable()) {
            try {
                filters = ds.getFilters();
                Composite pFilters = new Composite(cFilters, SWT.NONE);
                pFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                layout = new GridLayout(1, false);
                layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
                layout.marginWidth = layout.marginHeight = 0;
                pFilters.setLayout(layout);
                final Label pflabel = new Label(pFilters, SWT.NONE);
                pflabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                final SubscriptionResultFilter f_filters = filters;
                pFilterUpdater = new Runnable() {

                    @Override
                    public void run() {
                        long kInB = DisplayFormatters.getKinB();
                        long mInB = kInB * kInB;
                        long min_size = f_filters.getMinSze() / mInB;
                        long max_size = f_filters.getMaxSize() / mInB;
                        pflabel.setText(MessageText.getString("subs.persistent.filters", new String[] { getString(f_filters.getWithWords()), getString(f_filters.getWithoutWords()), String.valueOf(min_size < 0 ? 0 : min_size), String.valueOf(max_size < 0 ? 0 : max_size) }));
                    }
                };
                pFilterUpdater.run();
            } catch (Throwable e) {
                Debug.out(e);
            }
        }
        Composite vFilters = new Composite(cFilters, SWT.NONE);
        vFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
        rowLayout.spacing = 5;
        rowLayout.marginBottom = rowLayout.marginTop = rowLayout.marginLeft = rowLayout.marginRight = 0;
        rowLayout.center = true;
        vFilters.setLayout(rowLayout);
        // with/without keywords
        ImageLoader imageLoader = ImageLoader.getInstance();
        for (int i = 0; i < 2; i++) {
            final boolean with = i == 0;
            if (!with) {
                label = new Label(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
                label.setLayoutData(new RowData(-1, sepHeight));
            }
            Composite cWithKW = new Composite(vFilters, SWT.NONE);
            layout = new GridLayout(2, false);
            layout.marginWidth = 0;
            layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
            cWithKW.setLayout(layout);
            // Label lblWithKW = new Label(cWithKW, SWT.NONE);
            // lblWithKW.setText(MessageText.getString(with?"SubscriptionResults.filter.with.words":"SubscriptionResults.filter.without.words"));
            Label lblWithKWImg = new Label(cWithKW, SWT.NONE);
            lblWithKWImg.setImage(imageLoader.getImage(with ? "icon_filter_plus" : "icon_filter_minus"));
            final Text textWithKW = new Text(cWithKW, SWT.BORDER);
            textWithKW.setMessage(MessageText.getString(with ? "SubscriptionResults.filter.with.words" : "SubscriptionResults.filter.without.words"));
            GridData gd = new GridData();
            gd.widthHint = Utils.adjustPXForDPI(100);
            textWithKW.setLayoutData(gd);
            textWithKW.addModifyListener(new ModifyListener() {

                @Override
                public void modifyText(ModifyEvent e) {
                    String text = textWithKW.getText().toLowerCase(Locale.US);
                    String[] bits = text.split("\\s+");
                    Set<String> temp = new HashSet<>();
                    for (String bit : bits) {
                        bit = bit.trim();
                        if (bit.length() > 0) {
                            temp.add(bit);
                        }
                    }
                    String[] words = temp.toArray(new String[temp.size()]);
                    synchronized (filter_lock) {
                        if (with) {
                            with_keywords = words;
                        } else {
                            without_keywords = words;
                        }
                    }
                    refilter_dispatcher.dispatch();
                }
            });
        }
        // min size
        label = new Label(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
        label.setLayoutData(new RowData(-1, sepHeight));
        Composite cMinSize = new Composite(vFilters, SWT.NONE);
        layout = new GridLayout(2, false);
        layout.marginWidth = 0;
        layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
        cMinSize.setLayout(layout);
        Label lblMinSize = new Label(cMinSize, SWT.NONE);
        lblMinSize.setText(MessageText.getString("SubscriptionResults.filter.min_size"));
        Spinner spinMinSize = new Spinner(cMinSize, SWT.BORDER);
        spinMinSize.setMinimum(0);
        // 100 TB should do...
        spinMinSize.setMaximum(100 * 1024 * 1024);
        spinMinSize.setSelection(minSize);
        spinMinSize.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                minSize = ((Spinner) event.widget).getSelection();
                refilter_dispatcher.dispatch();
            }
        });
        // max size
        label = new Label(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
        label.setLayoutData(new RowData(-1, sepHeight));
        Composite cMaxSize = new Composite(vFilters, SWT.NONE);
        layout = new GridLayout(2, false);
        layout.marginWidth = 0;
        layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
        cMaxSize.setLayout(layout);
        Label lblMaxSize = new Label(cMaxSize, SWT.NONE);
        lblMaxSize.setText(MessageText.getString("SubscriptionResults.filter.max_size"));
        Spinner spinMaxSize = new Spinner(cMaxSize, SWT.BORDER);
        spinMaxSize.setMinimum(0);
        // 100 TB should do...
        spinMaxSize.setMaximum(100 * 1024 * 1024);
        spinMaxSize.setSelection(maxSize);
        spinMaxSize.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                maxSize = ((Spinner) event.widget).getSelection();
                refilter_dispatcher.dispatch();
            }
        });
        if (filters != null) {
            label = new Label(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
            label.setLayoutData(new RowData(-1, sepHeight));
            final SubscriptionResultFilter f_filters = filters;
            final Runnable f_pFilterUpdater = pFilterUpdater;
            Button save = new Button(vFilters, SWT.PUSH);
            save.setText(MessageText.getString("ConfigView.button.save"));
            save.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    try {
                        long kInB = DisplayFormatters.getKinB();
                        long mInB = kInB * kInB;
                        f_filters.update(with_keywords, without_keywords, minSize * mInB, maxSize * mInB);
                        f_pFilterUpdater.run();
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
        }
        parent.layout(true);
    }
    return null;
}
Also used : TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) SubscriptionListener(com.biglybt.core.subs.SubscriptionListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) Core(com.biglybt.core.Core) MessageText(com.biglybt.core.internat.MessageText) SubscriptionResultFilter(com.biglybt.core.subs.SubscriptionResultFilter) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

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