Search in sources :

Example 1 with TableView

use of com.biglybt.ui.common.table.TableView in project BiglyBT by BiglySoftware.

the class ToolBarView method setupToolBarItems.

private void setupToolBarItems(boolean uiClassic) {
    ToolBarItem item;
    {
        // always add these items, whether they are shown or not is decided later
        // ==OPEN
        item = createItem(this, "open", "image.toolbar.open", "Button.add.torrent");
        item.setDefaultActivationListener(new UIToolBarActivationListener() {

            @Override
            public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
                if (activationType != ACTIVATIONTYPE_NORMAL) {
                    Boolean result = Utils.execSWTThreadWithBool("open", new AERunnableBoolean() {

                        @Override
                        public boolean runSupport() {
                            Clipboard clipboard = new Clipboard(Display.getDefault());
                            try {
                                String text = (String) clipboard.getContents(TextTransfer.getInstance());
                                if (text != null && text.length() <= 2048) {
                                    if (TorrentOpener.openTorrentsFromClipboard(text)) {
                                        return (true);
                                    }
                                }
                            } finally {
                                clipboard.dispose();
                            }
                            return false;
                        }
                    }, 1000);
                    return (result != null && result);
                }
                UIFunctionsManagerSWT.getUIFunctionsSWT().openTorrentWindow();
                return true;
            }
        });
        item.setAlwaysAvailable(true);
        item.setGroupID("classic");
        tbm.addToolBarItem(item, false);
        // ==SEARCH
        item = createItem(this, "search", "search", "Button.search");
        item.setDefaultActivationListener(new UIToolBarActivationListener() {

            @Override
            public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
                if (activationType != ACTIVATIONTYPE_NORMAL) {
                    return false;
                }
                UIFunctionsManagerSWT.getUIFunctionsSWT().promptForSearch();
                return true;
            }
        });
        item.setAlwaysAvailable(true);
        item.setGroupID("classic");
        tbm.addToolBarItem(item, false);
    }
    if (!uiClassic) {
        // ==play
        item = createItem(this, "play", "image.button.play", "iconBar.play");
        item.setDefaultActivationListener(new UIToolBarActivationListener() {

            @Override
            public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
                if (activationType != ACTIVATIONTYPE_NORMAL) {
                    return false;
                }
                ISelectedContent[] sc = SelectedContentManager.getCurrentlySelectedContent();
                if (sc != null && sc.length > 0) {
                    if (PlayUtils.canStreamDS(sc[0], sc[0].getFileIndex(), true)) {
                        TorrentListViewsUtils.playOrStreamDataSource(sc[0], DLReferals.DL_REFERAL_TOOLBAR, true, false);
                    } else {
                        TorrentListViewsUtils.playOrStreamDataSource(sc[0], DLReferals.DL_REFERAL_TOOLBAR, false, true);
                    }
                }
                return false;
            }
        });
        tbm.addToolBarItem(item, false);
    }
    // ==run
    item = createItem(this, "run", "image.toolbar.run", "iconBar.run");
    item.setDefaultActivationListener(new UIToolBarActivationListener() {

        @Override
        public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
            if (activationType != ACTIVATIONTYPE_NORMAL) {
                return false;
            }
            TableView tv = SelectedContentManager.getCurrentlySelectedTableView();
            Object[] ds;
            if (tv != null) {
                ds = tv.getSelectedDataSources().toArray();
            } else {
                ds = SelectedContentManager.getDMSFromSelectedContent();
            }
            if (ds != null) {
                TorrentUtil.runDataSources(ds);
                return true;
            }
            return false;
        }
    });
    tbm.addToolBarItem(item, false);
    if (uiClassic) {
        // ==TOP
        item = createItem(this, "top", "image.toolbar.top", "iconBar.top");
        item.setDefaultActivationListener(new UIToolBarActivationListener() {

            @Override
            public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
                if (activationType == ACTIVATIONTYPE_NORMAL) {
                    return moveTop();
                }
                return false;
            }
        });
        tbm.addToolBarItem(item, false);
    }
    // ==UP
    item = createItem(this, "up", "image.toolbar.up", "iconBar.up");
    item.setDefaultActivationListener(new UIToolBarActivationListener() {

        @Override
        public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
            if (activationType == ACTIVATIONTYPE_NORMAL) {
                if (!CoreFactory.isCoreRunning()) {
                    return false;
                }
                DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
                if (dms != null) {
                    Arrays.sort(dms, new Comparator<DownloadManager>() {

                        @Override
                        public int compare(DownloadManager a, DownloadManager b) {
                            return a.getPosition() - b.getPosition();
                        }
                    });
                    GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
                    for (int i = 0; i < dms.length; i++) {
                        DownloadManager dm = dms[i];
                        if (gm.isMoveableUp(dm)) {
                            gm.moveUp(dm);
                        }
                    }
                }
            } else if (activationType == ACTIVATIONTYPE_HELD) {
                return moveTop();
            }
            return false;
        }
    });
    tbm.addToolBarItem(item, false);
    // ==down
    item = createItem(this, "down", "image.toolbar.down", "iconBar.down");
    item.setDefaultActivationListener(new UIToolBarActivationListener() {

        @Override
        public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
            if (activationType == ACTIVATIONTYPE_NORMAL) {
                if (!CoreFactory.isCoreRunning()) {
                    return false;
                }
                GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
                DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
                if (dms != null) {
                    Arrays.sort(dms, new Comparator<DownloadManager>() {

                        @Override
                        public int compare(DownloadManager a, DownloadManager b) {
                            return b.getPosition() - a.getPosition();
                        }
                    });
                    for (int i = 0; i < dms.length; i++) {
                        DownloadManager dm = dms[i];
                        if (gm.isMoveableDown(dm)) {
                            gm.moveDown(dm);
                        }
                    }
                    return true;
                }
            } else if (activationType == ACTIVATIONTYPE_HELD) {
                return moveBottom();
            }
            return false;
        }
    });
    tbm.addToolBarItem(item, false);
    if (uiClassic) {
        // ==BOTTOM
        item = createItem(this, "bottom", "image.toolbar.bottom", "iconBar.bottom");
        item.setDefaultActivationListener(new UIToolBarActivationListener() {

            @Override
            public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
                if (activationType != ACTIVATIONTYPE_NORMAL) {
                    return false;
                }
                return moveBottom();
            }
        });
        tbm.addToolBarItem(item, false);
    }
    // ==start
    item = createItem(this, "start", "image.toolbar.startstop.start", "iconBar.start");
    item.setDefaultActivationListener(new UIToolBarActivationListener_OffSWT() {

        @Override
        public void toolBarItemActivated_OffSWT(ToolBarItem item, long activationType, Object datasource) {
            ISelectedContent[] selected = SelectedContentManager.getCurrentlySelectedContent();
            TorrentUtil.queueDataSources(selected, true, activationType == ACTIVATIONTYPE_HELD);
        }
    });
    tbm.addToolBarItem(item, false);
    // ==stop
    item = createItem(this, "stop", "image.toolbar.startstop.stop", "iconBar.stop");
    item.setDefaultActivationListener(new UIToolBarActivationListener_OffSWT() {

        @Override
        public void toolBarItemActivated_OffSWT(ToolBarItem item, long activationType, Object datasource) {
            ISelectedContent[] selected = SelectedContentManager.getCurrentlySelectedContent();
            TorrentUtil.stopDataSources(selected, activationType == ACTIVATIONTYPE_HELD);
        }
    });
    tbm.addToolBarItem(item, false);
    // ==startstop
    item = createItem(this, "startstop", "image.toolbar.startstop.start", "iconBar.startstop");
    item.setDefaultActivationListener(new UIToolBarActivationListener_OffSWT() {

        @Override
        public void toolBarItemActivated_OffSWT(ToolBarItem item, long activationType, Object datasource) {
            ISelectedContent[] selected = SelectedContentManager.getCurrentlySelectedContent();
            TorrentUtil.stopOrStartDataSources(selected, activationType == ACTIVATIONTYPE_HELD);
        }
    });
    tbm.addToolBarItem(item, false);
    // ==remove
    item = createItem(this, "remove", "image.toolbar.remove", "iconBar.remove");
    item.setDefaultActivationListener(new UIToolBarActivationListener_OffSWT(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL) {

        @Override
        public void toolBarItemActivated_OffSWT(ToolBarItem item, long activationType, Object datasource) {
            ISelectedContent[] selected = SelectedContentManager.getCurrentlySelectedContent();
            TorrentUtil.removeDataSources(selected);
        }
    });
    tbm.addToolBarItem(item, false);
    if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
        // == mode big
        item = createItem(this, "modeBig", "image.toolbar.table_large", "v3.iconBar.view.big");
        item.setGroupID("views");
        tbm.addToolBarItem(item, false);
        // == mode small
        item = createItem(this, "modeSmall", "image.toolbar.table_normal", "v3.iconBar.view.small");
        item.setGroupID("views");
        tbm.addToolBarItem(item, false);
    }
}
Also used : AERunnableBoolean(com.biglybt.core.util.AERunnableBoolean) DownloadManager(com.biglybt.core.download.DownloadManager) GlobalManager(com.biglybt.core.global.GlobalManager) ToolBarItem(com.biglybt.ui.common.ToolBarItem) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Clipboard(org.eclipse.swt.dnd.Clipboard) AERunnableBoolean(com.biglybt.core.util.AERunnableBoolean) TableView(com.biglybt.ui.common.table.TableView)

Example 2 with TableView

use of com.biglybt.ui.common.table.TableView in project BiglyBT by BiglySoftware.

the class TableViewSWT_TabsCommon method createSashForm.

public Composite createSashForm(final Composite composite) {
    if (!tv.isTabViewsEnabled()) {
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    SelectedContentManager.addCurrentlySelectedContentListener(this);
    ConfigurationManager configMan = ConfigurationManager.getInstance();
    int iNumViews = 0;
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        if (pluginUI != null) {
            iNumViews += pluginUI.getViewListeners(tv.getTableID()).length;
        }
    }
    if (iNumViews == 0) {
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    final String props_prefix = tv.getTableID() + "." + tv.getPropertiesPrefix();
    FormData formData;
    final Composite form = new Composite(composite, 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);
    // Create them in reverse order, so we can have the table auto-grow, and
    // set the tabFolder's height manually
    cTabsHolder = new Composite(form, SWT.NONE);
    tabbedMDI = uiFunctions.createTabbedMDI(cTabsHolder, props_prefix);
    tabbedMDI.setMaximizeVisible(true);
    tabbedMDI.setMinimizeVisible(true);
    tabbedMDI.setTabbedMdiMaximizeListener(new TabbedMdiMaximizeListener() {

        @Override
        public void maximizePressed() {
            TableView tvToUse = tvOverride == null ? tv : tvOverride;
            Object[] ds = tvToUse.getSelectedDataSources(true);
            if (ds.length == 1 && ds[0] instanceof DownloadManager) {
                UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                if (uiFunctions != null) {
                    uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, ds);
                }
            }
        }
    });
    final int SASH_WIDTH = 5;
    sash = Utils.createSash(form, SASH_WIDTH);
    tableComposite = tv.createMainPanel(form);
    Composite cFixLayout = tableComposite;
    while (cFixLayout != null && cFixLayout.getParent() != form) {
        cFixLayout = cFixLayout.getParent();
    }
    if (cFixLayout == null) {
        cFixLayout = tableComposite;
    }
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cFixLayout.setLayout(layout);
    // FormData for Folder
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    int iSplitAt = configMan.getIntParameter(props_prefix + ".SplitAt", 3000);
    // Was stored at whole
    if (iSplitAt < 100) {
        iSplitAt *= 100;
    }
    // pct is % bottom
    double pct = iSplitAt / 10000.0;
    if (pct < 0.03) {
        pct = 0.03;
    } else if (pct > 0.97) {
        pct = 0.97;
    }
    // height will be set on first resize call
    sash.setData("PCT", new Double(pct));
    cTabsHolder.setLayout(new FormLayout());
    fdHeightChanger = formData;
    cTabsHolder.setLayoutData(formData);
    // FormData for Sash
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(cTabsHolder);
    formData.height = SASH_WIDTH;
    sash.setLayoutData(formData);
    // FormData for table Composite
    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(sash);
    cFixLayout.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;
            }
            Rectangle area = form.getClientArea();
            int height = area.height - e.y - e.height;
            if (!Constants.isWindows) {
                height -= SASH_WIDTH;
            }
            if (area.height - height < 100) {
                height = area.height - 100;
            }
            if (height < 0) {
                height = 0;
            }
            fdHeightChanger.height = height;
            Double l = new Double((double) height / area.height);
            sash.setData("PCT", l);
            if (e.detail != SWT.DRAG) {
                ConfigurationManager configMan = ConfigurationManager.getInstance();
                configMan.setParameter(props_prefix + ".SplitAt", (int) (l.doubleValue() * 10000));
            }
            form.layout();
            // sometimes sash cheese is left
            cTabsHolder.redraw();
        }
    });
    buildFolder(form, props_prefix);
    return form;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) DownloadManager(com.biglybt.core.download.DownloadManager) TabbedMdiMaximizeListener(com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener) UIFunctions(com.biglybt.ui.UIFunctions) SelectionEvent(org.eclipse.swt.events.SelectionEvent) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) COConfigurationManager(com.biglybt.core.config.COConfigurationManager) ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager) TableView(com.biglybt.ui.common.table.TableView)

Example 3 with TableView

use of com.biglybt.ui.common.table.TableView in project BiglyBT by BiglySoftware.

the class SelectedContentManager method convertSelectedContentToObject.

public static Object convertSelectedContentToObject(ISelectedContent[] contents) {
    if (contents == null) {
        contents = getCurrentlySelectedContent();
    }
    if (contents.length == 0) {
        TableView tv = SelectedContentManager.getCurrentlySelectedTableView();
        if (tv != null) {
            return tv.getSelectedDataSources(false);
        }
        return null;
    }
    if (contents.length == 1) {
        return selectedContentToObject(contents[0]);
    }
    Object[] objects = new Object[contents.length];
    for (int i = 0; i < contents.length; i++) {
        ISelectedContent content = contents[i];
        objects[i] = selectedContentToObject(content);
    }
    return objects;
}
Also used : TableView(com.biglybt.ui.common.table.TableView)

Example 4 with TableView

use of com.biglybt.ui.common.table.TableView in project BiglyBT by BiglySoftware.

the class TorrentUtil method calculateToolbarStates.

// XXX Don't think *View's need this call anymore.  ToolBarView does it fo them
public static Map<String, Long> calculateToolbarStates(ISelectedContent[] currentContent, String viewID_unused) {
    // System.out.println("calculateToolbarStates(" + currentContent.length + ", " + viewID_unused + " via " + Debug.getCompressedStackTrace());
    /*
		String[] TBKEYS = new String[] {
			"download",
			"play",
			"stream",
			"run",
			"top",
			"up",
			"down",
			"bottom",
			"start",
			"stop",
			"remove"
		};
		*/
    Map<String, Long> mapNewToolbarStates = new HashMap<>();
    String[] itemsNeedingSelection = {};
    String[] itemsNeedingRealDMSelection = { "remove", "top", "bottom", "transcode", "startstop" };
    String[] itemsRequiring1DMwithHash = { "details", "comment", "up", "down" };
    String[] itemsRequiring1DMSelection = {};
    int numSelection = currentContent.length;
    boolean hasSelection = numSelection > 0;
    boolean has1Selection = numSelection == 1;
    for (int i = 0; i < itemsNeedingSelection.length; i++) {
        String itemID = itemsNeedingSelection[i];
        mapNewToolbarStates.put(itemID, hasSelection ? UIToolBarItem.STATE_ENABLED : 0);
    }
    TableView tv = SelectedContentManager.getCurrentlySelectedTableView();
    // not sure why we assume that the existance of any table view
    boolean hasRealDM = tv != null;
    if (!hasRealDM && numSelection > 0) {
        hasRealDM = true;
        for (int i = 0; i < currentContent.length; i++) {
            ISelectedContent content = currentContent[i];
            DownloadManager dm = content.getDownloadManager();
            if (dm == null) {
                hasRealDM = false;
                break;
            }
        }
    }
    if (!hasRealDM) {
        MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
        if (mdi != null) {
            MdiEntrySWT entry = mdi.getCurrentEntrySWT();
            if (entry != null) {
                if (entry.getDatasource() instanceof DownloadManager) {
                    hasRealDM = true;
                } else if ((entry instanceof UIPluginView) && (((UIPluginView) entry).getDataSource() instanceof DownloadManager)) {
                    hasRealDM = true;
                }
            }
        }
    }
    boolean canStart = false;
    boolean canStop = false;
    boolean canRemoveFileInfo = false;
    boolean canRunFileInfo = false;
    boolean canCheckExist = false;
    boolean hasDM = false;
    boolean canRecheck = false;
    if (currentContent.length > 0 && hasRealDM) {
        // well, in fact, we can have hasRealDM set to true here (because tv isn't null) and actually not have a real dm.
        // fancy that - protect against null DownloadManagers...
        boolean canMoveUp = false;
        boolean canMoveDown = false;
        boolean canDownload = false;
        canCheckExist = true;
        GlobalManager gm = null;
        for (int i = 0; i < currentContent.length; i++) {
            ISelectedContent content = currentContent[i];
            DownloadManager dm = content.getDownloadManager();
            if (dm == null) {
                if (!canDownload && content.getDownloadInfo() != null) {
                    canDownload = true;
                }
                continue;
            }
            if (gm == null) {
                gm = dm.getGlobalManager();
            }
            int state = dm.getState();
            canCheckExist &= (state == DownloadManager.STATE_ERROR || state == DownloadManager.STATE_STOPPED || state == DownloadManager.STATE_QUEUED);
            int fileIndex = content.getFileIndex();
            if (fileIndex == -1) {
                if (!canMoveUp && gm.isMoveableUp(dm)) {
                    canMoveUp = true;
                }
                if (!canMoveDown && gm.isMoveableDown(dm)) {
                    canMoveDown = true;
                }
                hasDM = true;
                if (!canStart && ManagerUtils.isStartable(dm)) {
                    canStart = true;
                }
                if (!canStop && ManagerUtils.isStopable(dm)) {
                    canStop = true;
                }
            } else {
                DiskManagerFileInfoSet fileInfos = dm.getDiskManagerFileInfoSet();
                if (fileIndex < fileInfos.nbFiles()) {
                    DiskManagerFileInfo fileInfo = fileInfos.getFiles()[fileIndex];
                    if (!canStart && (fileInfo.isSkipped())) {
                        canStart = true;
                    }
                    if (!canStop && !fileInfo.isSkipped()) {
                        canStop = true;
                    }
                    if (!canRemoveFileInfo && !fileInfo.isSkipped()) {
                        int storageType = fileInfo.getStorageType();
                        if (storageType == DiskManagerFileInfo.ST_LINEAR || storageType == DiskManagerFileInfo.ST_COMPACT) {
                            canRemoveFileInfo = true;
                        }
                    }
                    if (!canRunFileInfo && fileInfo.getAccessMode() == DiskManagerFileInfo.READ && fileInfo.getDownloaded() == fileInfo.getLength() && fileInfo.getFile(true).exists()) {
                        canRunFileInfo = true;
                    }
                }
            }
            canRecheck = canRecheck || dm.canForceRecheck();
        }
        boolean canRemove = hasDM || canRemoveFileInfo;
        mapNewToolbarStates.put("remove", canRemove ? UIToolBarItem.STATE_ENABLED : 0);
        mapNewToolbarStates.put("download", canDownload ? UIToolBarItem.STATE_ENABLED : 0);
        if (currentContent.length == 1) {
            mapNewToolbarStates.put("up", canMoveUp ? UIToolBarItem.STATE_ENABLED : 0);
            mapNewToolbarStates.put("down", canMoveDown ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    boolean canRun = has1Selection && ((hasDM && !canRunFileInfo) || (!hasDM && canRunFileInfo));
    if (canRun) {
        ISelectedContent content = currentContent[0];
        DownloadManager dm = content.getDownloadManager();
        if (dm == null) {
            canRun = false;
        } else {
            TOTorrent torrent = dm.getTorrent();
            if (torrent == null) {
                canRun = false;
            } else if (!dm.getAssumedComplete() && torrent.isSimpleTorrent()) {
                canRun = false;
            /*
									} else if (PlatformTorrentUtils.useEMP(torrent)
											&& PlatformTorrentUtils.embeddedPlayerAvail()
											&& PlayUtils.canProgressiveOrIsComplete(torrent)) {
										// play button enabled and not UMP.. don't need launch

										canRun = false;

									}
									*/
            }
        }
    }
    mapNewToolbarStates.put("run", canRun ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put("start", canStart ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put("stop", canStop ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put("startstop", canStart || canStop ? UIToolBarItem.STATE_ENABLED : 0);
    for (int i = 0; i < itemsNeedingRealDMSelection.length; i++) {
        String itemID = itemsNeedingRealDMSelection[i];
        if (!mapNewToolbarStates.containsKey(itemID)) {
            mapNewToolbarStates.put(itemID, hasSelection && hasDM && hasRealDM ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    for (int i = 0; i < itemsRequiring1DMSelection.length; i++) {
        String itemID = itemsRequiring1DMSelection[i];
        if (!mapNewToolbarStates.containsKey(itemID)) {
            mapNewToolbarStates.put(itemID, has1Selection && hasDM ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    for (int i = 0; i < itemsRequiring1DMwithHash.length; i++) {
        String itemID = itemsRequiring1DMwithHash[i];
        if (!mapNewToolbarStates.containsKey(itemID)) {
            mapNewToolbarStates.put(itemID, hasDM ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    mapNewToolbarStates.put("download", has1Selection && (!(currentContent[0] instanceof ISelectedVuzeFileContent)) && currentContent[0].getDownloadManager() == null && (currentContent[0].getHash() != null || currentContent[0].getDownloadInfo() != null) ? UIToolBarItem.STATE_ENABLED : 0);
    if (tv != null) {
        TableColumn tc = tv.getTableColumn(RankItem.COLUMN_ID);
        if (tc != null && !tc.isVisible()) {
            mapNewToolbarStates.put("up", 0L);
            mapNewToolbarStates.put("down", 0L);
        }
    }
    mapNewToolbarStates.put(TU_ITEM_RECHECK, canRecheck ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put(TU_ITEM_CHECK_FILES, canCheckExist ? UIToolBarItem.STATE_ENABLED : 0);
    return mapNewToolbarStates;
}
Also used : ISelectedVuzeFileContent(com.biglybt.ui.selectedcontent.ISelectedVuzeFileContent) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DiskManagerFileInfoSet(com.biglybt.core.disk.DiskManagerFileInfoSet) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT) DownloadManager(com.biglybt.core.download.DownloadManager) TableColumn(com.biglybt.pif.ui.tables.TableColumn) GlobalManager(com.biglybt.core.global.GlobalManager) TOTorrent(com.biglybt.core.torrent.TOTorrent) UIPluginView(com.biglybt.pif.ui.UIPluginView) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) TableView(com.biglybt.ui.common.table.TableView)

Example 5 with TableView

use of com.biglybt.ui.common.table.TableView 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)

Aggregations

TableView (com.biglybt.ui.common.table.TableView)5 DownloadManager (com.biglybt.core.download.DownloadManager)3 GlobalManager (com.biglybt.core.global.GlobalManager)2 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 COConfigurationManager (com.biglybt.core.config.COConfigurationManager)1 ConfigurationManager (com.biglybt.core.config.impl.ConfigurationManager)1 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)1 DiskManagerFileInfoSet (com.biglybt.core.disk.DiskManagerFileInfoSet)1 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 AERunnable (com.biglybt.core.util.AERunnable)1 AERunnableBoolean (com.biglybt.core.util.AERunnableBoolean)1 UIPluginView (com.biglybt.pif.ui.UIPluginView)1 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 TableColumn (com.biglybt.pif.ui.tables.TableColumn)1 UIFunctions (com.biglybt.ui.UIFunctions)1 ToolBarItem (com.biglybt.ui.common.ToolBarItem)1 ISelectedVuzeFileContent (com.biglybt.ui.selectedcontent.ISelectedVuzeFileContent)1 SelectedContentListener (com.biglybt.ui.selectedcontent.SelectedContentListener)1