Search in sources :

Example 1 with TableRowSWT

use of com.biglybt.ui.swt.views.table.TableRowSWT in project BiglyBT by BiglySoftware.

the class FilesView method initYourTableView.

@Override
public TableViewSWT<DiskManagerFileInfo> initYourTableView() {
    tv = TableViewFactory.createTableViewSWT(com.biglybt.pif.disk.DiskManagerFileInfo.class, TableManager.TABLE_TORRENT_FILES, getPropertiesPrefix(), basicItems, "firstpiece", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    if (allowTabViews) {
        tv.setEnableTabViews(enable_tabs, true, null);
    }
    basicItems = new TableColumnCore[0];
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(pluginUI);
    }
    tv.addTableDataSourceChangedListener(this, true);
    tv.addRefreshListener(this, true);
    tv.addSelectionListener(this, false);
    tv.addMenuFillListener(this);
    tv.addLifeCycleListener(this);
    tv.addKeyListener(this);
    tv.addRefreshListener(new TableRowRefreshListener() {

        @Override
        public void rowRefresh(TableRow row) {
            if (row instanceof TableRowSWT) {
                Object ds = ((TableRowSWT) row).getDataSource(true);
                if (ds instanceof FilesViewNodeInner) {
                    ((TableRowSWT) row).setFontStyle(SWT.ITALIC);
                    ((TableRowSWT) row).setAlpha(220);
                }
            }
        }
    });
    return tv;
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) TableRowSWT(com.biglybt.ui.swt.views.table.TableRowSWT) TableRowRefreshListener(com.biglybt.pif.ui.tables.TableRowRefreshListener) TableRow(com.biglybt.pif.ui.tables.TableRow) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance)

Example 2 with TableRowSWT

use of com.biglybt.ui.swt.views.table.TableRowSWT in project BiglyBT by BiglySoftware.

the class MyTrackerView method tableRefresh.

// @see TableRefreshListener#tableRefresh()
@Override
public void tableRefresh() {
    if (getComposite() == null || getComposite().isDisposed()) {
        return;
    }
    UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
    if (uiFunctions != null) {
        uiFunctions.refreshIconBar();
    }
    // Store values for columns that are calculate from peer information, so
    // that we only have to do one loop.  (As opposed to each cell doing a loop)
    // Calculate code copied from TrackerTableItem
    TableRowCore[] rows = tv.getRows();
    for (int x = 0; x < rows.length; x++) {
        TableRowSWT row = (TableRowSWT) rows[x];
        if (row == null) {
            continue;
        }
        TRHostTorrent host_torrent = (TRHostTorrent) rows[x].getDataSource(true);
        if (host_torrent == null) {
            continue;
        }
        long uploaded = host_torrent.getTotalUploaded();
        long downloaded = host_torrent.getTotalDownloaded();
        long left = host_torrent.getTotalLeft();
        int seed_count = host_torrent.getSeedCount();
        host_torrent.setData("GUI_PeerCount", new Long(host_torrent.getLeecherCount()));
        host_torrent.setData("GUI_SeedCount", new Long(seed_count));
        host_torrent.setData("GUI_BadNATCount", new Long(host_torrent.getBadNATCount()));
        host_torrent.setData("GUI_Uploaded", new Long(uploaded));
        host_torrent.setData("GUI_Downloaded", new Long(downloaded));
        host_torrent.setData("GUI_Left", new Long(left));
        if (seed_count != 0) {
            Color fg = row.getForeground();
            if (fg != null && fg.equals(Colors.blues[Colors.BLUES_MIDDARK])) {
                row.setForeground(Colors.blues[Colors.BLUES_MIDDARK]);
            }
        }
    }
}
Also used : TableRowSWT(com.biglybt.ui.swt.views.table.TableRowSWT) UIFunctions(com.biglybt.ui.UIFunctions) Color(org.eclipse.swt.graphics.Color) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent)

Example 3 with TableRowSWT

use of com.biglybt.ui.swt.views.table.TableRowSWT in project BiglyBT by BiglySoftware.

the class TableColumnSetupWindow method removeSelectedChosen.

/**
 * @since 4.0.0.5
 */
protected void removeSelectedChosen() {
    Object[] datasources = tvChosen.getSelectedDataSources().toArray();
    for (int i = 0; i < datasources.length; i++) {
        TableColumnCore column = (TableColumnCore) datasources[i];
        mapNewVisibility.put(column, Boolean.FALSE);
    }
    tvChosen.removeDataSources(datasources);
    tvChosen.processDataSourceQueue();
    for (int i = 0; i < datasources.length; i++) {
        TableRowSWT row = (TableRowSWT) tvAvail.getRow((TableColumn) datasources[i]);
        if (row != null) {
            row.redraw();
        }
    }
}
Also used : TableRowSWT(com.biglybt.ui.swt.views.table.TableRowSWT) TableColumn(com.biglybt.pif.ui.tables.TableColumn)

Example 4 with TableRowSWT

use of com.biglybt.ui.swt.views.table.TableRowSWT in project BiglyBT by BiglySoftware.

the class SBC_LibraryTableView method initShow.

public void initShow(Core core) {
    Object data = soParent.getControl().getData("TorrentFilterMode");
    if (data instanceof Long) {
        torrentFilterMode = (int) ((Long) data).longValue();
    }
    data = soParent.getControl().getData("DataSource");
    boolean useBigTable = useBigTable();
    SWTSkinObjectTextbox soFilter = (SWTSkinObjectTextbox) skin.getSkinObject("library-filter", soParent.getParent());
    Text txtFilter = soFilter == null ? null : soFilter.getTextControl();
    SWTSkinObjectContainer soCats = (SWTSkinObjectContainer) skin.getSkinObject("library-categories", soParent.getParent());
    Composite cCats = soCats == null ? null : soCats.getComposite();
    // columns not needed for small mode, all torrents
    TableColumnCore[] columns = useBigTable || torrentFilterMode != SBC_LibraryView.TORRENTS_ALL ? getColumns() : null;
    if (null != columns) {
        TableColumnManager tcManager = TableColumnManager.getInstance();
        tcManager.addColumns(columns);
    }
    if (useBigTable) {
        if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE || torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE || torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
            swtViewListener = torrentView = new MyTorrentsView_Big(core, torrentFilterMode, columns, txtFilter, cCats);
        } else {
            swtViewListener = torrentView = new MyTorrentsView_Big(core, torrentFilterMode, columns, txtFilter, cCats);
        }
    } else {
        String tableID = SB_Transfers.getTableIdFromFilterMode(torrentFilterMode, false);
        if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE) {
            swtViewListener = torrentView = new MyTorrentsView(core, tableID, true, columns, txtFilter, cCats, true);
        } else if (torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE) {
            swtViewListener = torrentView = new MyTorrentsView(core, tableID, false, columns, txtFilter, cCats, true);
        } else if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
            swtViewListener = torrentView = new MyTorrentsView(core, tableID, true, columns, txtFilter, cCats, true) {

                @Override
                public boolean isOurDownloadManager(DownloadManager dm) {
                    if (PlatformTorrentUtils.getHasBeenOpened(dm)) {
                        return false;
                    }
                    return super.isOurDownloadManager(dm);
                }
            };
        } else {
            swtViewListener = new MyTorrentsSuperView(txtFilter, cCats) {

                @Override
                public void initializeDone() {
                    MyTorrentsView seedingview = getSeedingview();
                    if (seedingview != null) {
                        seedingview.overrideDefaultSelected(new TableSelectionAdapter() {

                            @Override
                            public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
                                doDefaultClick(rows, stateMask, false, origin);
                            }
                        });
                        MyTorrentsView torrentview = getTorrentview();
                        if (torrentview != null) {
                            torrentview.overrideDefaultSelected(new TableSelectionAdapter() {

                                @Override
                                public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
                                    doDefaultClick(rows, stateMask, false, origin);
                                }
                            });
                        }
                    }
                }
            };
        }
        if (torrentView != null) {
            torrentView.overrideDefaultSelected(new TableSelectionAdapter() {

                @Override
                public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
                    doDefaultClick(rows, stateMask, false, origin);
                }
            });
        }
    }
    if (torrentView != null) {
        tv = torrentView.getTableView();
        if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
            torrentView.setRebuildListOnFocusGain(true);
        }
    }
    try {
        view = new UISWTViewImpl(ID + torrentFilterMode, UISWTInstance.VIEW_MAIN, false);
        view.setDatasource(data);
        view.setEventListener(swtViewListener, true);
    } catch (Exception e) {
        Debug.out(e);
    }
    SWTSkinObjectContainer soContents = new SWTSkinObjectContainer(skin, skin.getSkinProperties(), getUpdateUIName(), "", soMain);
    skin.layout();
    viewComposite = soContents.getComposite();
    viewComposite.setLayoutData(Utils.getFilledFormData());
    GridLayout gridLayout = new GridLayout();
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
    viewComposite.setLayout(gridLayout);
    view.initialize(viewComposite);
    SWTSkinObject soSizeSlider = skin.getSkinObject("table-size-slider", soParent.getParent());
    if (soSizeSlider instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer so = (SWTSkinObjectContainer) soSizeSlider;
        if (tv != null && !tv.enableSizeSlider(so.getComposite(), 16, 100)) {
            so.setVisible(false);
        }
    }
    if (torrentFilterMode == SBC_LibraryView.TORRENTS_ALL && tv != null) {
        tv.addRefreshListener(new TableRowRefreshListener() {

            @Override
            public void rowRefresh(TableRow row) {
                TableRowSWT rowCore = (TableRowSWT) row;
                Object ds = rowCore.getDataSource(true);
                if (!(ds instanceof DownloadManager)) {
                    return;
                }
                DownloadManager dm = (DownloadManager) ds;
                boolean changed = false;
                boolean assumedComplete = dm.getAssumedComplete();
                if (!assumedComplete) {
                    changed |= rowCore.setAlpha(160);
                } else if (!PlatformTorrentUtils.getHasBeenOpened(dm)) {
                    changed |= rowCore.setAlpha(255);
                } else {
                    changed |= rowCore.setAlpha(255);
                }
            }
        });
    }
    viewComposite.getParent().layout(true);
}
Also used : TableSelectionAdapter(com.biglybt.ui.common.table.TableSelectionAdapter) TableRowSWT(com.biglybt.ui.swt.views.table.TableRowSWT) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) DownloadManager(com.biglybt.core.download.DownloadManager) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) TableRowCore(com.biglybt.ui.common.table.TableRowCore) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SWTSkinObjectTextbox(com.biglybt.ui.swt.skin.SWTSkinObjectTextbox) MyTorrentsSuperView(com.biglybt.ui.swt.views.MyTorrentsSuperView) Composite(org.eclipse.swt.widgets.Composite) TableRowRefreshListener(com.biglybt.pif.ui.tables.TableRowRefreshListener) Text(org.eclipse.swt.widgets.Text) MyTorrentsView(com.biglybt.ui.swt.views.MyTorrentsView) UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) TableRow(com.biglybt.pif.ui.tables.TableRow) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Aggregations

TableRowSWT (com.biglybt.ui.swt.views.table.TableRowSWT)4 TableRow (com.biglybt.pif.ui.tables.TableRow)2 TableRowRefreshListener (com.biglybt.pif.ui.tables.TableRowRefreshListener)2 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)1 DownloadManager (com.biglybt.core.download.DownloadManager)1 TRHostTorrent (com.biglybt.core.tracker.host.TRHostTorrent)1 TableColumn (com.biglybt.pif.ui.tables.TableColumn)1 UIFunctions (com.biglybt.ui.UIFunctions)1 TableColumnCore (com.biglybt.ui.common.table.TableColumnCore)1 TableRowCore (com.biglybt.ui.common.table.TableRowCore)1 TableSelectionAdapter (com.biglybt.ui.common.table.TableSelectionAdapter)1 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)1 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)1 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)1 UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 SWTSkinObjectTextbox (com.biglybt.ui.swt.skin.SWTSkinObjectTextbox)1 MyTorrentsSuperView (com.biglybt.ui.swt.views.MyTorrentsSuperView)1 MyTorrentsView (com.biglybt.ui.swt.views.MyTorrentsView)1