Search in sources :

Example 1 with SelectedContentListener

use of com.biglybt.ui.selectedcontent.SelectedContentListener in project BiglyBT by BiglySoftware.

the class MyTorrentsSuperView method initializeWithCore.

private void initializeWithCore(Core core, Composite parent) {
    torrentview = createTorrentView(core, TableManager.TABLE_MYTORRENTS_INCOMPLETE, false, getIncompleteColumns(), child1);
    seedingview = createTorrentView(core, TableManager.TABLE_MYTORRENTS_COMPLETE, true, getCompleteColumns(), child2);
    torrentview.getComposite().addListener(SWT.FocusIn, new Listener() {

        @Override
        public void handleEvent(Event event) {
            seedingview.getTableView().getTabsCommon().setTvOverride(torrentview.getTableView());
        }
    });
    seedingview.getComposite().addListener(SWT.FocusIn, new Listener() {

        @Override
        public void handleEvent(Event event) {
            seedingview.getTableView().getTabsCommon().setTvOverride(null);
        }
    });
    // delegate selections from the incomplete view to the sub-tabs owned by the seeding view
    SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewId) {
            if (form.isDisposed() || torrentview == null || seedingview == null) {
                SelectedContentManager.removeCurrentlySelectedContentListener(this);
            } else {
                TableView<?> selected_tv = SelectedContentManager.getCurrentlySelectedTableView();
                TableViewSWT<?> incomp_tv = torrentview.getTableView();
                TableViewSWT<?> comp_tv = seedingview.getTableView();
                if (incomp_tv != null && comp_tv != null && (selected_tv == incomp_tv || selected_tv == comp_tv)) {
                    TableViewSWT_TabsCommon tabs = comp_tv.getTabsCommon();
                    if (tabs != null) {
                        Utils.execSWTThread(new Runnable() {

                            public void run() {
                                tabs.triggerTabViewsDataSourceChanged(selected_tv);
                            }
                        });
                    }
                }
            }
        }
    });
    initializeDone();
}
Also used : TableViewSWT_TabsCommon(com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) UISWTViewCoreEventListener(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) AERunnable(com.biglybt.core.util.AERunnable) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) TableViewSWT(com.biglybt.ui.swt.views.table.TableViewSWT) TableView(com.biglybt.ui.common.table.TableView)

Example 2 with SelectedContentListener

use of com.biglybt.ui.selectedcontent.SelectedContentListener in project BiglyBT by BiglySoftware.

the class UIManagerImpl method initialisationComplete.

public static void initialisationComplete() {
    SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewID) {
            triggerDataSourceListeners(SelectedContentManager.convertSelectedContentToObject(null));
        }
    });
    List<Object[]> to_fire = new ArrayList<>();
    try {
        class_mon.enter();
        initialisation_complete = true;
        for (int j = 0; j < ui_factories.size(); j++) {
            UIInstanceFactory factory = (UIInstanceFactory) ui_factories.get(j);
            Iterator<Object[]> it = ui_listeners.iterator();
            while (it.hasNext()) {
                Object[] entry = it.next();
                List<UIInstanceFactory> fired = (List<UIInstanceFactory>) entry[2];
                if (!fired.contains(factory)) {
                    fired.add(factory);
                    to_fire.add(new Object[] { entry[0], factory.getInstance((PluginInterface) entry[1]) });
                }
            }
        }
    } finally {
        class_mon.exit();
    }
    for (Object[] entry : to_fire) {
        try {
            ((UIManagerListener) entry[0]).UIAttached((UIInstance) entry[1]);
        } catch (Throwable e) {
            Debug.printStackTrace(e);
        }
    }
    for (Object[] entry : to_fire) {
        try {
            if (entry[0] instanceof UIManagerListener2) {
                ((UIManagerListener2) entry[0]).UIAttachedComplete((UIInstance) entry[1]);
            }
        } catch (Throwable e) {
            Debug.printStackTrace(e);
        }
    }
}
Also used : ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) PluginInterface(com.biglybt.pif.PluginInterface) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) CopyOnWriteList(com.biglybt.core.util.CopyOnWriteList)

Example 3 with SelectedContentListener

use of com.biglybt.ui.selectedcontent.SelectedContentListener in project BiglyBT by BiglySoftware.

the class TableViewPainted method initialize.

@Override
public void initialize(UISWTView parentView, Composite parent) {
    tvTabsCommon = new TableViewSWT_TabsCommon(parentView, this);
    shell = parent.getShell();
    mainComposite = tvTabsCommon.createSashForm(parent);
    mainComposite.setData("Name", tableID);
    mainComposite.setData("ObfuscateImage", this);
    Composite cTableComposite = tvTabsCommon.tableComposite;
    cTableComposite.setLayout(new FormLayout());
    Layout layout = parent.getLayout();
    if (layout instanceof FormLayout) {
        FormData fd = Utils.getFilledFormData();
        cTableComposite.setLayoutData(fd);
    }
    cHeaderArea = new Canvas(cTableComposite, SWT.DOUBLE_BUFFERED);
    fontHeader = FontUtils.getFontWithHeight(cHeaderArea.getFont(), null, Utils.adjustPXForDPI(12));
    fontHeaderSmall = FontUtils.getFontPercentOf(fontHeader, 0.8f);
    cHeaderArea.setFont(fontHeader);
    cTable = new Canvas(cTableComposite, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.V_SCROLL);
    int minRowHeight = FontUtils.getFontHeightInPX(cTable.getFont());
    if (iHeightEM > 0) {
        defaultRowHeight = (int) ((minRowHeight * iHeightEM) + iHeightEM);
        iHeightEM = -1;
    }
    // good test
    // cTable.setFont(FontUtils.getFontPercentOf(cTable.getFont(), 1.50f));
    minRowHeight += Math.ceil(minRowHeight * 2.0 / 16.0);
    if (defaultRowHeight < minRowHeight) {
        defaultRowHeight = minRowHeight;
    }
    cTable.setBackground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_LIST_BACKGROUND));
    headerHeight = configMan.getIntParameter("Table.headerHeight");
    if (headerHeight <= 0) {
        headerHeight = Utils.adjustPXForDPI(DEFAULT_HEADER_HEIGHT);
    }
    FormData fd = Utils.getFilledFormData();
    fd.height = headerHeight;
    fd.bottom = null;
    cHeaderArea.setLayoutData(fd);
    fd = Utils.getFilledFormData();
    fd.top = new FormAttachment(cHeaderArea);
    cTable.setLayoutData(fd);
    clientArea = cTable.getClientArea();
    TableColumnCore[] tableColumns = getAllColumns();
    TableColumnCore[] tmpColumnsOrdered = new TableColumnCore[tableColumns.length];
    // Create all columns
    int columnOrderPos = 0;
    Arrays.sort(tableColumns, TableColumnManager.getTableColumnOrderComparator());
    for (int i = 0; i < tableColumns.length; i++) {
        int position = tableColumns[i].getPosition();
        if (position != -1 && tableColumns[i].isVisible()) {
            // table.createNewColumn(SWT.NULL);
            // System.out.println(i + "] " + tableColumns[i].getName() + ";" + position);
            tmpColumnsOrdered[columnOrderPos++] = tableColumns[i];
        }
    }
    // int numSWTColumns = table.getColumnCount();
    // int iNewLength = numSWTColumns - (bSkipFirstColumn ? 1 : 0);
    TableColumnCore[] columnsOrdered = new TableColumnCore[columnOrderPos];
    System.arraycopy(tmpColumnsOrdered, 0, columnsOrdered, 0, columnOrderPos);
    setColumnsOrdered(columnsOrdered);
    cTable.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            swt_paintComposite(e);
        }
    });
    menu = createMenu();
    cTable.setMenu(menu);
    cHeaderArea.setMenu(menu);
    setupHeaderArea(cHeaderArea);
    cTable.addControlListener(new ControlListener() {

        boolean inControlResize = false;

        @Override
        public void controlResized(ControlEvent e) {
            if (inControlResize) {
                return;
            }
            try {
                inControlResize = true;
                swt_calculateClientArea();
                swt_fixupSize();
            } finally {
                inControlResize = false;
            }
        }

        @Override
        public void controlMoved(ControlEvent e) {
        }
    });
    hBar = cTable.getHorizontalBar();
    if (hBar != null) {
        hBar.setValues(0, 0, 0, 10, 10, 100);
        hBar.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // swt_calculateClientArea();
                if (DIRECT_DRAW) {
                    swt_calculateClientArea();
                    redrawTable();
                } else {
                    cTable.redraw();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    vBar = cTable.getVerticalBar();
    if (vBar != null) {
        vBar.setValues(0, 0, 0, 50, getRowDefaultHeight(), 50);
        vBar.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                swt_vBarChanged();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    if (DEBUG_WITH_SHELL) {
        Shell shell = new Shell();
        sCanvasImage = new Canvas(shell, SWT.DOUBLE_BUFFERED);
        shell.setLayout(new FillLayout());
        sCanvasImage.addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                if (canvasImage == null) {
                    return;
                }
                e.gc.drawImage(canvasImage, 0, 0);
            // System.out.println(System.currentTimeMillis() + "] Paint " + e.x + "x" + e.y + " " + e.width + "x" + e.height);
            }
        });
        shell.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                sCanvasImage = null;
            }
        });
        shell.setVisible(true);
    }
    cTable.addMouseListener(tvSWTCommon);
    cTable.addMouseMoveListener(tvSWTCommon);
    cTable.addKeyListener(tvSWTCommon);
    // composite.addSelectionListener(tvSWTCommon);
    cTable.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent e) {
            e.doit = true;
        }
    });
    cTable.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (canvasImage != null) {
                canvasImage.dispose();
                canvasImage = null;
            }
        }
    });
    SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewID) {
            if (cTable == null || cTable.isDisposed()) {
                SelectedContentManager.removeCurrentlySelectedContentListener(this);
            } else {
                redrawTable();
            }
        }
    });
    cTable.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            isFocused = false;
            redrawTable();
        }

        @Override
        public void focusGained(FocusEvent e) {
            isFocused = true;
            redrawTable();
        }
    });
    isFocused = cTable.isFocusControl();
    new TableTooltips(this, cTable);
    TableColumnManager tcManager = TableColumnManager.getInstance();
    String sSortColumn = tcManager.getDefaultSortColumnName(tableID);
    if (sSortColumn == null || sSortColumn.length() == 0) {
        sSortColumn = sDefaultSortOn;
    }
    TableColumnCore tc = tcManager.getTableColumnCore(tableID, sSortColumn);
    if (tc == null && tableColumns.length > 0) {
        tc = tableColumns[0];
    }
    setSortColumn(tc, false);
    triggerLifeCycleListener(TableLifeCycleListener.EVENT_TABLELIFECYCLE_INITIALIZED);
    configMan.addParameterListener("Graphics Update", this);
    configMan.addParameterListener("ReOrder Delay", this);
    configMan.addParameterListener("Table.extendedErase", this);
    configMan.addParameterListener("Table.headerHeight", this);
    Colors.getInstance().addColorsChangedListener(this);
    // So all TableView objects of the same TableID have the same columns,
    // and column widths, etc
    TableStructureEventDispatcher.getInstance(tableID).addListener(this);
    MessageText.addListener(this);
}
Also used : TableTooltips(com.biglybt.ui.swt.views.table.impl.TableTooltips) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) TableViewSWT_TabsCommon(com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener)

Example 4 with SelectedContentListener

use of com.biglybt.ui.selectedcontent.SelectedContentListener in project BiglyBT by BiglySoftware.

the class SBC_LibraryView method skinObjectInitialShow.

// @see SkinView#showSupport(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(final SWTSkinObject skinObject, Object params) {
    selectedContentListener = new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewId) {
            selection_count = currentContent.length;
            long total_size = 0;
            long total_done = 0;
            ArrayList<DownloadManager> dms = new ArrayList<>(currentContent.length);
            for (ISelectedContent sc : currentContent) {
                DownloadManager dm = sc.getDownloadManager();
                if (dm != null) {
                    dms.add(dm);
                    int file_index = sc.getFileIndex();
                    if (file_index == -1) {
                        DiskManagerFileInfo[] file_infos = dm.getDiskManagerFileInfoSet().getFiles();
                        for (DiskManagerFileInfo file_info : file_infos) {
                            if (!file_info.isSkipped()) {
                                total_size += file_info.getLength();
                                total_done += file_info.getDownloaded();
                            }
                        }
                    } else {
                        DiskManagerFileInfo file_info = dm.getDiskManagerFileInfoSet().getFiles()[file_index];
                        if (!file_info.isSkipped()) {
                            total_size += file_info.getLength();
                            total_done += file_info.getDownloaded();
                        }
                    }
                }
            }
            selection_size = total_size;
            selection_done = total_done;
            selection_dms = dms.toArray(new DownloadManager[dms.size()]);
            SB_Transfers transfers = MainMDISetup.getSb_transfers();
            if (transfers != null) {
                transfers.triggerCountRefreshListeners();
            }
        }
    };
    SelectedContentManager.addCurrentlySelectedContentListener(selectedContentListener);
    soWait = null;
    try {
        soWait = getSkinObject("library-wait");
        soWaitProgress = getSkinObject("library-wait-progress");
        soWaitTask = (SWTSkinObjectText) getSkinObject("library-wait-task");
        if (soWaitProgress != null) {
            soWaitProgress.getControl().addPaintListener(new PaintListener() {

                @Override
                public void paintControl(PaintEvent e) {
                    assert e != null;
                    Control c = (Control) e.widget;
                    Point size = c.getSize();
                    e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
                    int breakX = size.x * waitProgress / 100;
                    e.gc.fillRectangle(0, 0, breakX, size.y);
                    e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
                    e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
                }
            });
        }
        soLibraryInfo = (SWTSkinObjectText) getSkinObject("library-info");
        if (soLibraryInfo != null) {
            MainMDISetup.getSb_transfers().addCountRefreshListener(new SB_Transfers.countRefreshListener() {

                final Map<Composite, ExtraInfoProvider> extra_info_map = new HashMap<>();

                {
                    soLibraryInfo.getControl().getParent().setData("ViewUtils:ViewTitleExtraInfo", new ViewUtils.ViewTitleExtraInfo() {

                        @Override
                        public void update(Composite reporter, int count, int active) {
                            ExtraInfoProvider provider = getProvider(reporter);
                            if (provider == null) {
                                return;
                            }
                            if (provider.value != count || provider.active != active) {
                                provider.value = count;
                                provider.active = active;
                                if (viewMode == provider.view_mode && provider.enabled) {
                                    MainMDISetup.getSb_transfers().triggerCountRefreshListeners();
                                }
                            }
                        }

                        @Override
                        public void setEnabled(Composite reporter, boolean enabled) {
                            ExtraInfoProvider provider = getProvider(reporter);
                            if (provider == null) {
                                return;
                            }
                            if (provider.enabled != enabled) {
                                provider.enabled = enabled;
                                if (viewMode == provider.view_mode) {
                                    MainMDISetup.getSb_transfers().triggerCountRefreshListeners();
                                }
                            }
                        }

                        private ExtraInfoProvider getProvider(Composite reporter) {
                            synchronized (extra_info_map) {
                                ExtraInfoProvider provider = extra_info_map.get(reporter);
                                if (provider != null) {
                                    return (provider);
                                }
                                Composite temp = reporter;
                                while (temp != null) {
                                    Integer vm = (Integer) temp.getData("SBC_LibraryView:ViewMode");
                                    if (vm != null) {
                                        provider = new ExtraInfoProvider(vm);
                                        extra_info_map.put(reporter, provider);
                                        return (provider);
                                    }
                                    temp = temp.getParent();
                                }
                                Debug.out("No view mode found for " + reporter);
                                return (null);
                            }
                        }
                    });
                }

                // @see SBC_LibraryView.countRefreshListener#countRefreshed(SBC_LibraryView.stats, SBC_LibraryView.stats)
                @Override
                public void countRefreshed(SB_Transfers.stats statsWithLowNoise, SB_Transfers.stats statsNoLowNoise) {
                    SB_Transfers.stats stats = viewMode == MODE_SMALLTABLE ? statsWithLowNoise : statsNoLowNoise;
                    String s;
                    if (torrentFilterMode == TORRENTS_ALL || (datasource instanceof Tag)) {
                        if (datasource instanceof Category) {
                            Category cat = (Category) datasource;
                            String id = "library.category.header";
                            s = MessageText.getString(id, new String[] { (cat.getType() != Category.TYPE_USER) ? MessageText.getString(cat.getName()) : cat.getName() });
                        } else if (datasource instanceof Tag) {
                            Tag tag = (Tag) datasource;
                            String id = "library.tag.header";
                            s = MessageText.getString(id, new String[] { tag.getTagName(true) });
                            String desc = tag.getDescription();
                            if (desc != null) {
                                s += " - " + desc;
                            }
                        } else {
                            String id = "library.all.header";
                            if (stats.numComplete + stats.numIncomplete != 1) {
                                id += ".p";
                            }
                            s = MessageText.getString(id, new String[] { String.valueOf(stats.numComplete + stats.numIncomplete), String.valueOf(stats.numSeeding + stats.numDownloading) });
                            if (stats.numQueued > 0) {
                                s += ", " + MessageText.getString("label.num_queued", new String[] { String.valueOf(stats.numQueued) });
                            }
                        }
                    } else if (torrentFilterMode == TORRENTS_INCOMPLETE) {
                        String id = "library.incomplete.header";
                        if (stats.numDownloading != 1) {
                            id += ".p";
                        }
                        int numWaiting = Math.max(stats.numIncomplete - stats.numDownloading, 0);
                        s = MessageText.getString(id, new String[] { String.valueOf(stats.numDownloading), String.valueOf(numWaiting) });
                    } else if (torrentFilterMode == TORRENTS_UNOPENED || torrentFilterMode == TORRENTS_COMPLETE) {
                        // complete filtering currently uses same display text as unopened
                        String id = "library.unopened.header";
                        if (stats.numUnOpened != 1) {
                            id += ".p";
                        }
                        s = MessageText.getString(id, new String[] { String.valueOf(stats.numUnOpened) });
                    } else {
                        s = "";
                    }
                    synchronized (extra_info_map) {
                        int filter_total = 0;
                        int filter_active = 0;
                        boolean filter_enabled = false;
                        for (ExtraInfoProvider provider : extra_info_map.values()) {
                            if (viewMode == provider.view_mode) {
                                if (provider.enabled) {
                                    filter_enabled = true;
                                    filter_total += provider.value;
                                    filter_active += provider.active;
                                }
                            }
                        }
                        if (filter_enabled) {
                            String extra = MessageText.getString("filter.header.matches2", new String[] { String.valueOf(filter_total), String.valueOf(filter_active) });
                            s += " " + extra;
                        }
                    }
                    SB_Transfers transfers = MainMDISetup.getSb_transfers();
                    if (selection_count > 1) {
                        s += ", " + MessageText.getString("label.num_selected", new String[] { String.valueOf(selection_count) });
                        String size_str = null;
                        String rate_str = null;
                        if (selection_size > 0) {
                            if (selection_size == selection_done) {
                                size_str = DisplayFormatters.formatByteCountToKiBEtc(selection_size);
                            } else {
                                size_str = DisplayFormatters.formatByteCountToKiBEtc(selection_done) + "/" + DisplayFormatters.formatByteCountToKiBEtc(selection_size);
                            }
                        }
                        DownloadManager[] dms = selection_dms;
                        if (transfers.header_show_rates && dms.length > 1) {
                            long total_data_up = 0;
                            long total_prot_up = 0;
                            long total_data_down = 0;
                            long total_prot_down = 0;
                            for (DownloadManager dm : dms) {
                                DownloadManagerStats dm_stats = dm.getStats();
                                total_prot_up += dm_stats.getProtocolSendRate();
                                total_data_up += dm_stats.getDataSendRate();
                                total_prot_down += dm_stats.getProtocolReceiveRate();
                                total_data_down += dm_stats.getDataReceiveRate();
                            }
                            rate_str = MessageText.getString("ConfigView.download.abbreviated") + DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(total_data_down, total_prot_down) + " " + MessageText.getString("ConfigView.upload.abbreviated") + DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(total_data_up, total_prot_up);
                        }
                        if (size_str != null || rate_str != null) {
                            String temp;
                            if (size_str == null) {
                                temp = rate_str;
                            } else if (rate_str == null) {
                                temp = size_str;
                            } else {
                                temp = size_str + "; " + rate_str;
                            }
                            s += " (" + temp + ")";
                        }
                    }
                    if (transfers.header_show_uptime && transfers.totalStats != null) {
                        long up_secs = (transfers.totalStats.getSessionUpTime() / 60) * 60;
                        String op;
                        if (up_secs < 60) {
                            up_secs = 60;
                            op = "<";
                        } else {
                            op = " ";
                        }
                        String up_str = TimeFormatter.format2(up_secs, false);
                        if (s.equals("")) {
                            Debug.out("eh");
                        }
                        s += "; " + MessageText.getString("label.uptime_coarse", new String[] { op, up_str });
                    }
                    soLibraryInfo.setText(s);
                }

                class ExtraInfoProvider {

                    int view_mode;

                    boolean enabled;

                    int value;

                    int active;

                    private ExtraInfoProvider(int vm) {
                        view_mode = vm;
                    }
                }
            });
        }
    } catch (Exception ignored) {
    }
    // Core core = CoreFactory.getSingleton();
    if (!CoreFactory.isCoreRunning()) {
        if (soWait != null) {
            soWait.setVisible(true);
        // soWait.getControl().getParent().getParent().getParent().layout(true, true);
        }
        final Initializer initializer = Initializer.getLastInitializer();
        if (initializer != null) {
            initializer.addListener(new InitializerListener() {

                @Override
                public void reportPercent(final int percent) {
                    Utils.execSWTThread(new AERunnable() {

                        @Override
                        public void runSupport() {
                            if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
                                waitProgress = percent;
                                soWaitProgress.getControl().redraw();
                                soWaitProgress.getControl().update();
                            }
                        }
                    });
                    if (percent > 100) {
                        initializer.removeListener(this);
                    }
                }

                @Override
                public void reportCurrentTask(String currentTask) {
                    if (soWaitTask != null && !soWaitTask.isDisposed()) {
                        soWaitTask.setText(currentTask);
                    }
                }
            });
        }
    }
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(final Core core) {
            PluginInterface pi = PluginInitializer.getDefaultInterface();
            final UIManager uim = pi.getUIManager();
            uim.addUIListener(new UIManagerListener() {

                @Override
                public void UIDetached(UIInstance instance) {
                }

                @Override
                public void UIAttached(UIInstance instance) {
                    if (instance instanceof UISWTInstance) {
                        uim.removeUIListener(this);
                        Utils.execSWTThread(new AERunnable() {

                            @Override
                            public void runSupport() {
                                if (soWait != null) {
                                    soWait.setVisible(false);
                                }
                                if (!skinObject.isDisposed()) {
                                    setupView(core, skinObject);
                                }
                            }
                        });
                    }
                }
            });
        }
    });
    return null;
}
Also used : Category(com.biglybt.core.category.Category) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UIManager(com.biglybt.pif.ui.UIManager) DownloadManager(com.biglybt.core.download.DownloadManager) Control(org.eclipse.swt.widgets.Control) CoreRunningListener(com.biglybt.core.CoreRunningListener) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) UIInstance(com.biglybt.pif.ui.UIInstance) Core(com.biglybt.core.Core) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) PluginInterface(com.biglybt.pif.PluginInterface) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) InitializerListener(com.biglybt.ui.InitializerListener) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) PluginInitializer(com.biglybt.pifimpl.local.PluginInitializer) Initializer(com.biglybt.ui.swt.Initializer) Tag(com.biglybt.core.tag.Tag) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIManagerListener(com.biglybt.pif.ui.UIManagerListener)

Aggregations

ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)4 SelectedContentListener (com.biglybt.ui.selectedcontent.SelectedContentListener)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)2 PluginInterface (com.biglybt.pif.PluginInterface)2 TableViewSWT_TabsCommon (com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon)2 Core (com.biglybt.core.Core)1 Category (com.biglybt.core.category.Category)1 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)1 DownloadManager (com.biglybt.core.download.DownloadManager)1 DownloadManagerStats (com.biglybt.core.download.DownloadManagerStats)1 Tag (com.biglybt.core.tag.Tag)1 AERunnable (com.biglybt.core.util.AERunnable)1 CopyOnWriteList (com.biglybt.core.util.CopyOnWriteList)1 UIInstance (com.biglybt.pif.ui.UIInstance)1 UIManager (com.biglybt.pif.ui.UIManager)1 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)1 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 PluginInitializer (com.biglybt.pifimpl.local.PluginInitializer)1 InitializerListener (com.biglybt.ui.InitializerListener)1 TableView (com.biglybt.ui.common.table.TableView)1