Search in sources :

Example 21 with TableColumnManager

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

the class ClientStatsView method initColumns.

private void initColumns(Core core) {
    synchronized (ClientStatsView.class) {
        if (columnsAdded) {
            return;
        }
        columnsAdded = true;
    }
    UIManager uiManager = PluginInitializer.getDefaultInterface().getUIManager();
    TableManager tableManager = uiManager.getTableManager();
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_Name.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Name(column);
        }
    });
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_Count.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Count(column);
        }
    });
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_Discarded.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Discarded(column);
        }
    });
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_Received.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Received(column);
        }
    });
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_ReceivedPer.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_ReceivedPer(column);
        }
    });
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_Sent.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Sent(column);
        }
    });
    tableManager.registerColumn(ClientStatsDataSource.class, ColumnCS_Pct.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Pct(column);
        }
    });
    for (final String network : AENetworkClassifier.AT_NETWORKS) {
        tableManager.registerColumn(ClientStatsDataSource.class, network + "." + ColumnCS_Sent.COLUMN_ID, new TableColumnCreationListener() {

            @Override
            public void tableColumnCreated(TableColumn column) {
                column.setUserData("network", network);
                new ColumnCS_Sent(column);
            }
        });
        tableManager.registerColumn(ClientStatsDataSource.class, network + "." + ColumnCS_Discarded.COLUMN_ID, new TableColumnCreationListener() {

            @Override
            public void tableColumnCreated(TableColumn column) {
                column.setUserData("network", network);
                new ColumnCS_Discarded(column);
            }
        });
        tableManager.registerColumn(ClientStatsDataSource.class, network + "." + ColumnCS_Received.COLUMN_ID, new TableColumnCreationListener() {

            @Override
            public void tableColumnCreated(TableColumn column) {
                column.setUserData("network", network);
                new ColumnCS_Received(column);
            }
        });
        tableManager.registerColumn(ClientStatsDataSource.class, network + "." + ColumnCS_Count.COLUMN_ID, new TableColumnCreationListener() {

            @Override
            public void tableColumnCreated(TableColumn column) {
                column.setUserData("network", network);
                new ColumnCS_Count(column);
            }
        });
    }
    TableColumnManager tcManager = TableColumnManager.getInstance();
    tcManager.setDefaultColumnNames(TABLEID, new String[] { ColumnCS_Name.COLUMN_ID, ColumnCS_Pct.COLUMN_ID, ColumnCS_Count.COLUMN_ID, ColumnCS_Received.COLUMN_ID, ColumnCS_Sent.COLUMN_ID, ColumnCS_Discarded.COLUMN_ID });
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) TableColumn(com.biglybt.pif.ui.tables.TableColumn) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) TableManager(com.biglybt.pif.ui.tables.TableManager)

Example 22 with TableColumnManager

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

the class PeersViewBase method initYourTableView.

protected TableViewSWT<PEPeer> initYourTableView(String table_id, boolean enable_tabs) {
    if (table_id == TableManager.TABLE_TORRENT_PEERS) {
        tv = TableViewFactory.createTableViewSWT(Peer.class, TableManager.TABLE_TORRENT_PEERS, getPropertiesPrefix(), basicItems, "pieces", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    } else {
        TableColumnCore[] items = PeersView.getBasicColumnItems(TableManager.TABLE_ALL_PEERS);
        TableColumnCore[] basicItems = new TableColumnCore[items.length + 1];
        System.arraycopy(items, 0, basicItems, 0, items.length);
        basicItems[items.length] = new DownloadNameItem(TableManager.TABLE_ALL_PEERS);
        TableColumnManager tcManager = TableColumnManager.getInstance();
        tcManager.setDefaultColumnNames(TableManager.TABLE_ALL_PEERS, basicItems);
        tv = TableViewFactory.createTableViewSWT(Peer.class, TableManager.TABLE_ALL_PEERS, getPropertiesPrefix(), basicItems, "connected_time", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    }
    tv.setRowDefaultHeightEM(1);
    tv.setEnableTabViews(enable_tabs, true, null);
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(table_id, pluginUI);
    }
    tv.addLifeCycleListener(this);
    tv.addMenuFillListener(this);
    tv.addSelectionListener(this, false);
    return tv;
}
Also used : Peer(com.biglybt.pif.peers.Peer) PEPeer(com.biglybt.core.peer.PEPeer) DownloadNameItem(com.biglybt.ui.swt.views.tableitems.peers.DownloadNameItem) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Example 23 with TableColumnManager

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

the class TableColumnSetupWindow method fillAvail.

/**
 * @since 4.0.0.5
 */
protected void fillAvail() {
    String selectedCat = null;
    if (CAT_BUTTONS) {
        Control[] children = cCategories.getChildren();
        for (int i = 0; i < children.length; i++) {
            Control child = children[i];
            if (child instanceof Button) {
                Button btn = (Button) child;
                if (btn.getSelection()) {
                    selectedCat = (String) btn.getData("cat");
                    break;
                }
            }
        }
    } else {
        selectedCat = comboFilter.getItem(comboFilter.getSelectionIndex());
    }
    if (selectedCat != null && selectedCat.equals("all")) {
        selectedCat = null;
    }
    byte selectedProf = 0;
    for (byte i = 0; i < radProficiency.length; i++) {
        Button btn = radProficiency[i];
        if (btn.getSelection()) {
            selectedProf = i;
            break;
        }
    }
    String s;
    // = "Available " + radProficiency[selectedProf].getText() + " Columns";
    if (selectedCat != null) {
        s = MessageText.getString("ColumnSetup.availcolumns.filteredby", new String[] { radProficiency[selectedProf].getText(), selectedCat });
    } else {
        s = MessageText.getString("ColumnSetup.availcolumns", new String[] { radProficiency[selectedProf].getText() });
    }
    cPickArea.setText(s);
    tvAvail.removeAllTableRows();
    final TableColumnManager tcm = TableColumnManager.getInstance();
    TableColumnCore[] datasources = tcm.getAllTableColumnCoreAsArray(forDataSourceType, forTableID);
    if (selectedCat == "uncat") {
        datasources = listColumnsNoCat.toArray(new TableColumnCore[listColumnsNoCat.size()]);
    }
    for (int i = 0; i < datasources.length; i++) {
        TableColumnCore column = datasources[i];
        TableColumnInfo info = tcm.getColumnInfo(forDataSourceType, forTableID, column.getName());
        String[] cats = info == null ? null : info.getCategories();
        if (cats == null) {
            if (selectedCat == null || selectedCat.equals("uncat")) {
                tvAvail.addDataSource(column);
            }
        } else {
            for (int j = 0; j < cats.length; j++) {
                String cat = cats[j];
                if ((selectedCat == null || selectedCat.equalsIgnoreCase(cat)) && info.getProficiency() <= selectedProf) {
                    tvAvail.addDataSource(column);
                    break;
                }
            }
        }
    }
    tvAvail.processDataSourceQueue();
}
Also used : TableColumnInfo(com.biglybt.pif.ui.tables.TableColumnInfo) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Example 24 with TableColumnManager

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

the class TableColumnSetupWindow method createTVAvail.

/**
 * @return
 *
 * @since 4.0.0.5
 */
private TableViewSWT<TableColumn> createTVAvail() {
    final TableColumnManager tcm = TableColumnManager.getInstance();
    Map<String, TableColumnCore> mapColumns = tcm.getTableColumnsAsMap(TableColumn.class, TABLEID_AVAIL);
    TableColumnCore[] columns;
    int[] widths = { 405, 105 };
    if (sampleRow == null) {
        columns = new TableColumnCore[] { mapColumns.get(ColumnTC_NameInfo.COLUMN_ID) };
        widths = new int[] { 510 };
    } else {
        columns = new TableColumnCore[] { mapColumns.get(ColumnTC_NameInfo.COLUMN_ID), mapColumns.get(ColumnTC_Sample.COLUMN_ID) };
    }
    for (int i = 0; i < columns.length; i++) {
        TableColumnCore column = columns[i];
        if (column != null) {
            column.setVisible(true);
            column.setPositionNoShift(i);
            column.setWidth(widths[i]);
        }
    }
    final TableViewSWT<TableColumn> tvAvail = TableViewFactory.createTableViewSWT(TableColumn.class, TABLEID_AVAIL, TABLEID_AVAIL, columns, ColumnTC_NameInfo.COLUMN_ID, SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.SINGLE);
    tvAvail.setParentDataSource(this);
    tvAvail.setMenuEnabled(false);
    tvAvail.setRowDefaultHeightEM(5);
    tvAvail.addLifeCycleListener(new TableLifeCycleListener() {

        private DragSource dragSource;

        private DropTarget dropTarget;

        @Override
        public void tableLifeCycleEventOccurred(TableView tv, int eventType, Map<String, Object> data) {
            switch(eventType) {
                case EVENT_TABLELIFECYCLE_INITIALIZED:
                    tableViewInitialized();
                    break;
                case EVENT_TABLELIFECYCLE_DESTROYED:
                    tableViewDestroyed();
                    break;
            }
        }

        private void tableViewInitialized() {
            dragSource = tvAvail.createDragSource(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
            dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
            dragSource.setData("tv", tvAvail);
            dragSource.addDragListener(dragSourceListener);
            dropTarget = tvAvail.createDropTarget(DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_TARGET_MOVE);
            dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
            dropTarget.addDropListener(new DropTargetAdapter() {

                @Override
                public void drop(DropTargetEvent event) {
                    String id = (String) event.data;
                    if (!id.equals("c")) {
                        return;
                    }
                    removeSelectedChosen();
                }
            });
        }

        private void tableViewDestroyed() {
            if (dragSource != null && !dragSource.isDisposed()) {
                dragSource.dispose();
            }
            if (dropTarget != null && !dropTarget.isDisposed()) {
                dropTarget.dispose();
            }
        }
    });
    tvAvail.addSelectionListener(new TableSelectionAdapter() {

        @Override
        public void defaultSelected(TableRowCore[] rows, int stateMask) {
            for (int i = 0; i < rows.length; i++) {
                TableRowCore row = rows[i];
                TableColumnCore column = (TableColumnCore) row.getDataSource();
                chooseColumn(column, null, false);
            }
        }
    }, false);
    tvAvail.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.stateMask == 0) {
                if (e.keyCode == SWT.ARROW_RIGHT) {
                    TableRowCore[] selectedRows = tvAvail.getSelectedRows();
                    for (int i = 0; i < selectedRows.length; i++) {
                        TableRowCore row = selectedRows[i];
                        TableColumnCore column = (TableColumnCore) row.getDataSource();
                        chooseColumn(column, null, false);
                        tvChosen.processDataSourceQueue();
                        row.redraw();
                    }
                    e.doit = false;
                } else if (e.keyCode == SWT.ARROW_LEFT) {
                    TableRowCore[] selectedRows = tvAvail.getSelectedRows();
                    for (int i = 0; i < selectedRows.length; i++) {
                        TableRowCore row = selectedRows[i];
                        TableColumnCore column = (TableColumnCore) row.getDataSource();
                        mapNewVisibility.put(column, Boolean.FALSE);
                        tvChosen.removeDataSource(column);
                        tvChosen.processDataSourceQueue();
                        row.redraw();
                    }
                    e.doit = false;
                }
            }
        }
    });
    return tvAvail;
}
Also used : TableColumn(com.biglybt.pif.ui.tables.TableColumn) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Example 25 with TableColumnManager

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

the class TableColumnCreatorV3 method createAllDM.

/**
 * @since 4.0.0.1
 */
public static TableColumnCore[] createAllDM(String tableID, boolean big) {
    final String[] oldVisibleOrder = { ColumnUnopened.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, ColumnStream.COLUMN_ID, SizeItem.COLUMN_ID, ColumnProgressETA.COLUMN_ID, "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", StatusItem.COLUMN_ID, ColumnTorrentSpeed.COLUMN_ID, SeedsItem.COLUMN_ID, PeersItem.COLUMN_ID, ShareRatioItem.COLUMN_ID };
    final String[] defaultVisibleOrder = { RankItem.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, ColumnStream.COLUMN_ID, ColumnProgressETA.COLUMN_ID, SizeItem.COLUMN_ID, ColumnTorrentSpeed.COLUMN_ID, ETAItem.COLUMN_ID, // DateCompletedItem.COLUMN_ID,
    "RatingColumn", "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", DateAddedItem.COLUMN_ID };
    TableColumnManager tcManager = TableColumnManager.getInstance();
    Map<String, TableColumnCore> mapTCs = tcManager.getTableColumnsAsMap(Download.class, tableID);
    tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
    if (!tcManager.loadTableColumnSettings(Download.class, tableID) || areNoneVisible(mapTCs)) {
        setVisibility(mapTCs, defaultVisibleOrder, true);
        RankItem tc = (RankItem) mapTCs.get(RankItem.COLUMN_ID);
        if (tc != null) {
            tcManager.setDefaultSortColumnName(tableID, RankItem.COLUMN_ID);
            tc.setSortAscending(true);
        }
    } else {
        upgradeColumns(oldVisibleOrder, defaultVisibleOrder, mapTCs);
    }
    // special changes
    StatusItem tcStatusItem = (StatusItem) mapTCs.get(StatusItem.COLUMN_ID);
    if (tcStatusItem != null) {
        tcStatusItem.setChangeRowFG(false);
        if (big) {
            tcStatusItem.setChangeCellFG(false);
            tcStatusItem.setShowTrackerErrors(true);
        }
    }
    if (big) {
        ShareRatioItem tcShareRatioItem = (ShareRatioItem) mapTCs.get(ShareRatioItem.COLUMN_ID);
        if (tcShareRatioItem != null) {
            tcShareRatioItem.setChangeFG(false);
            tcShareRatioItem.setWidth(80);
        }
    }
    return mapTCs.values().toArray(new TableColumnCore[0]);
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Aggregations

TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)38 TableColumnCore (com.biglybt.ui.common.table.TableColumnCore)16 TableColumn (com.biglybt.pif.ui.tables.TableColumn)13 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)11 LightHashMap (com.biglybt.core.util.LightHashMap)4 UIManager (com.biglybt.pif.ui.UIManager)4 TableManager (com.biglybt.pif.ui.tables.TableManager)4 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)3 Subscription (com.biglybt.core.subs.Subscription)2 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 UIFunctions (com.biglybt.ui.UIFunctions)2 TableColumnCoreCreationListener (com.biglybt.ui.common.table.TableColumnCoreCreationListener)2 TableRowCore (com.biglybt.ui.common.table.TableRowCore)2 DownloadUrlInfo (com.biglybt.ui.selectedcontent.DownloadUrlInfo)2 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)2 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)2 ColumnDateSizer (com.biglybt.ui.swt.views.tableitems.ColumnDateSizer)2 Map (java.util.Map)2