Search in sources :

Example 11 with TableColumnManager

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

the class SBC_ChatOverview method initColumns.

protected void initColumns() {
    synchronized (SBC_ChatOverview.class) {
        if (columnsAdded) {
            return;
        }
        columnsAdded = true;
    }
    TableColumnManager tableManager = TableColumnManager.getInstance();
    tableManager.registerColumn(ChatInstance.class, ColumnChatName.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnChatName(column);
        }
    });
    tableManager.registerColumn(ChatInstance.class, ColumnChatMessageCount.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnChatMessageCount(column);
        }
    });
    tableManager.registerColumn(ChatInstance.class, ColumnChatUserCount.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnChatUserCount(column);
        }
    });
    tableManager.registerColumn(ChatInstance.class, ColumnChatFavorite.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnChatFavorite(column);
        }
    });
    tableManager.registerColumn(ChatInstance.class, ColumnChatMsgOutstanding.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnChatMsgOutstanding(column);
        }
    });
    // last
    tableManager.registerColumn(ChatInstance.class, ColumnChatStatus.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnChatStatus(column);
        }
    });
    tableManager.setDefaultColumnNames(TABLE_CHAT, new String[] { ColumnChatName.COLUMN_ID, ColumnChatMessageCount.COLUMN_ID, ColumnChatUserCount.COLUMN_ID, ColumnChatFavorite.COLUMN_ID, ColumnChatMsgOutstanding.COLUMN_ID, ColumnChatStatus.COLUMN_ID });
    tableManager.setDefaultSortColumnName(TABLE_CHAT, ColumnChatName.COLUMN_ID);
}
Also used : TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) TableColumn(com.biglybt.pif.ui.tables.TableColumn) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Example 12 with TableColumnManager

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

the class TableColumnCreatorV3 method initCoreColumns.

/**
 * @since 3.1.1.1
 */
public static void initCoreColumns() {
    TableColumnCreator.initCoreColumns();
    // short variable names to reduce wrapping
    final Map<String, cInfo> c = new LightHashMap<>(7);
    c.put(ColumnUnopened.COLUMN_ID, new cInfo(ColumnUnopened.class, ColumnUnopened.DATASOURCE_TYPES));
    c.put(ColumnThumbAndName.COLUMN_ID, new cInfo(ColumnThumbAndName.class, ColumnThumbAndName.DATASOURCE_TYPES));
    c.put(ColumnStream.COLUMN_ID, new cInfo(ColumnStream.class, ColumnStream.DATASOURCE_TYPES));
    c.put(DateAddedItem.COLUMN_ID, new cInfo(DateAddedItem.class, DateAddedItem.DATASOURCE_TYPE));
    c.put(DateCompletedItem.COLUMN_ID, new cInfo(DateCompletedItem.class, DateCompletedItem.DATASOURCE_TYPE));
    c.put(ColumnProgressETA.COLUMN_ID, new cInfo(ColumnProgressETA.class, ColumnProgressETA.DATASOURCE_TYPE));
    c.put(ColumnChatMessageCount.COLUMN_ID, new cInfo(ColumnChatMessageCount.class, Download.class));
    // ///////
    final Class ac = ActivitiesEntry.class;
    c.put(ColumnActivityNew.COLUMN_ID, new cInfo(ColumnActivityNew.class, ac));
    c.put(ColumnActivityType.COLUMN_ID, new cInfo(ColumnActivityType.class, ac));
    c.put(ColumnActivityText.COLUMN_ID, new cInfo(ColumnActivityText.class, ac));
    c.put(ColumnActivityActions.COLUMN_ID, new cInfo(ColumnActivityActions.class, ac));
    c.put(ColumnActivityDate.COLUMN_ID, new cInfo(ColumnActivityDate.class, ac));
    c.put(ColumnThumbnail.COLUMN_ID, new cInfo(ColumnThumbnail.class, new Class[] { ac }));
    // Core columns are implementors of TableColumn to save one class creation
    // Otherwise, we'd have to create a generic TableColumnImpl class, pass it
    // to another class so that it could manipulate it and act upon changes.
    TableColumnManager tcManager = TableColumnManager.getInstance();
    TableColumnCoreCreationListener tcCreator = new TableColumnCoreCreationListener() {

        // @see com.biglybt.ui.swt.views.table.TableColumnCoreCreationListener#createTableColumnCore(java.lang.Class, java.lang.String, java.lang.String)
        @Override
        public TableColumnCore createTableColumnCore(Class forDataSourceType, String tableID, String columnID) {
            cInfo info = c.get(columnID);
            if (info.cla.isAssignableFrom(TableColumnCore.class)) {
                return null;
            }
            try {
                Constructor<TableColumnCore> constructor = info.cla.getDeclaredConstructor(String.class);
                TableColumnCore column = constructor.newInstance(tableID);
                return column;
            } catch (NoSuchMethodException ignored) {
            } catch (Exception e) {
                Debug.out(e);
            }
            return null;
        }

        @Override
        public void tableColumnCreated(TableColumn column) {
            cInfo info = c.get(column.getName());
            if (column.getClass().equals(info.cla)) {
                return;
            }
            try {
                Constructor constructor = info.cla.getDeclaredConstructor(TableColumn.class);
                if (constructor != null) {
                    constructor.newInstance(column);
                }
            } catch (NoSuchMethodException e) {
            } catch (Exception e) {
                Debug.out(e);
            }
        }
    };
    tcManager.unregisterColumn(NameItem.DATASOURCE_TYPE, NameItem.COLUMN_ID, null);
    for (String id : c.keySet()) {
        cInfo info = c.get(id);
        for (int i = 0; i < info.forDataSourceTypes.length; i++) {
            Class cla = info.forDataSourceTypes[i];
            tcManager.registerColumn(cla, id, tcCreator);
        }
    }
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) Download(com.biglybt.pif.download.Download) LightHashMap(com.biglybt.core.util.LightHashMap) Constructor(java.lang.reflect.Constructor) TableColumn(com.biglybt.pif.ui.tables.TableColumn) TableColumnCoreCreationListener(com.biglybt.ui.common.table.TableColumnCoreCreationListener) ColumnChatMessageCount(com.biglybt.plugin.net.buddy.swt.columns.ColumnChatMessageCount)

Example 13 with TableColumnManager

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

the class TableColumnCreatorV3 method createActivityBig.

public static TableColumnCore[] createActivityBig(String tableID) {
    final String[] defaultVisibleOrder = { ColumnActivityNew.COLUMN_ID, ColumnActivityType.COLUMN_ID, ColumnActivityText.COLUMN_ID, ColumnThumbnail.COLUMN_ID, ColumnActivityActions.COLUMN_ID, ColumnActivityDate.COLUMN_ID };
    TableColumnManager tcManager = TableColumnManager.getInstance();
    Map<String, TableColumnCore> mapTCs = tcManager.getTableColumnsAsMap(ActivitiesEntry.class, tableID);
    tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
    if (!tcManager.loadTableColumnSettings(ActivitiesEntry.class, tableID) || areNoneVisible(mapTCs)) {
        setVisibility(mapTCs, defaultVisibleOrder, true);
        ColumnActivityText tcText = (ColumnActivityText) mapTCs.get(ColumnActivityText.COLUMN_ID);
        if (tcText != null) {
            tcText.setWidth(350);
        }
        ColumnActivityDate tc = (ColumnActivityDate) mapTCs.get(ColumnActivityDate.COLUMN_ID);
        if (tc != null) {
            tcManager.setDefaultSortColumnName(tableID, ColumnActivityDate.COLUMN_ID);
            tc.setSortAscending(false);
        }
    }
    return mapTCs.values().toArray(new TableColumnCore[0]);
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Example 14 with TableColumnManager

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

the class TableColumnCreatorV3 method createIncompleteDM.

public static TableColumnCore[] createIncompleteDM(String tableID, boolean big) {
    final String[] oldVisibleOrder = { ColumnThumbAndName.COLUMN_ID, ColumnStream.COLUMN_ID, SizeItem.COLUMN_ID, ColumnFileCount.COLUMN_ID, ColumnProgressETA.COLUMN_ID, SeedsItem.COLUMN_ID, PeersItem.COLUMN_ID, "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending" };
    final String[] defaultVisibleOrder = { RankItem.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, ColumnStream.COLUMN_ID, ColumnProgressETA.COLUMN_ID, SizeItem.COLUMN_ID, ColumnTorrentSpeed.COLUMN_ID, ETAItem.COLUMN_ID, "RatingColumn", "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", DateAddedItem.COLUMN_ID };
    TableColumnManager tcManager = TableColumnManager.getInstance();
    Map<String, TableColumnCore> mapTCs = tcManager.getTableColumnsAsMap(DownloadTypeIncomplete.class, tableID);
    tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
    if (!tcManager.loadTableColumnSettings(DownloadTypeIncomplete.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);
        }
    }
    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)

Example 15 with TableColumnManager

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

the class TableColumnCreatorV3 method createActivitySmall.

public static TableColumnCore[] createActivitySmall(String tableID) {
    final String[] defaultVisibleOrder = { ColumnActivityNew.COLUMN_ID, ColumnActivityType.COLUMN_ID, ColumnActivityText.COLUMN_ID, ColumnActivityActions.COLUMN_ID, ColumnActivityDate.COLUMN_ID };
    TableColumnManager tcManager = TableColumnManager.getInstance();
    Map<String, TableColumnCore> mapTCs = tcManager.getTableColumnsAsMap(ActivitiesEntry.class, tableID);
    tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
    if (!tcManager.loadTableColumnSettings(ActivitiesEntry.class, tableID) || areNoneVisible(mapTCs)) {
        setVisibility(mapTCs, defaultVisibleOrder, true);
        ColumnActivityDate tc = (ColumnActivityDate) mapTCs.get(ColumnActivityDate.COLUMN_ID);
        if (tc != null) {
            tcManager.setDefaultSortColumnName(tableID, ColumnActivityDate.COLUMN_ID);
            tc.setSortAscending(false);
        }
        ColumnActivityText tcText = (ColumnActivityText) mapTCs.get(ColumnActivityText.COLUMN_ID);
        if (tcText != null) {
            tcText.setWidth(445);
        }
    }
    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