Search in sources :

Example 11 with TableColumnCore

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

the class TableManagerImpl method unregisterColumn.

@Override
public void unregisterColumn(final Class forDataSourceType, final String cellID, final TableColumnCreationListener listener) {
    TableColumnManager tcManager = TableColumnManager.getInstance();
    tcManager.unregisterColumn(forDataSourceType, cellID, listener);
    String[] tables = tcManager.getTableIDs();
    for (String tid : tables) {
        TableColumnCore col = tcManager.getTableColumnCore(tid, cellID);
        if (col != null) {
            col.remove();
        }
    }
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Example 12 with TableColumnCore

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

the class TableColumnImpl method setVisible.

// @see com.biglybt.pif.ui.tables.TableColumn#setVisible(boolean)
@Override
public void setVisible(boolean visible) {
    if (bVisible == visible) {
        return;
    }
    // System.out.println("set " + sTableID + "/" + sName + " to " + visible
    // + " via " + Debug.getCompressedStackTrace());
    bVisible = visible;
    if (bVisible && iPosition == POSITION_INVISIBLE) {
        TableColumnCore[] allColumns = TableColumnManager.getInstance().getAllTableColumnCoreAsArray(null, sTableID);
        iPosition = 0;
        for (TableColumnCore tableColumnCore : allColumns) {
            if (tableColumnCore.getPosition() > iPosition) {
                iPosition = tableColumnCore.getPosition() + 1;
            }
        }
    }
    invalidateCells();
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 13 with TableColumnCore

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

the class TableColumnManager method generateDiagnostics.

/**
 * @param writer
 */
public void generateDiagnostics(IndentWriter writer) {
    try {
        items_mon.enter();
        writer.println("TableColumns");
        for (Iterator iter = items.keySet().iterator(); iter.hasNext(); ) {
            String sTableID = (String) iter.next();
            Map mTypes = (Map) items.get(sTableID);
            writer.indent();
            writer.println(sTableID + ": " + mTypes.size() + " columns:");
            writer.indent();
            for (Iterator iter2 = mTypes.values().iterator(); iter2.hasNext(); ) {
                TableColumnCore tc = (TableColumnCore) iter2.next();
                tc.generateDiagnostics(writer);
            }
            writer.exdent();
            writer.exdent();
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        items_mon.exit();
    }
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 14 with TableColumnCore

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

the class TableColumnManager method addColumns.

/**
 * Adds a column definition to the list
 * @param itemsToAdd The column definition object
 */
public void addColumns(TableColumnCore[] itemsToAdd) {
    try {
        items_mon.enter();
        for (int i = 0; i < itemsToAdd.length; i++) {
            TableColumnCore item = itemsToAdd[i];
            if (item == null || item.isRemoved()) {
                continue;
            }
            String name = item.getName();
            String sTableID = item.getTableID();
            Map mTypes = (Map) items.get(sTableID);
            if (mTypes == null) {
                // LinkedHashMap to preserve order
                mTypes = new LinkedHashMap();
                items.put(sTableID, mTypes);
            }
            if (!mTypes.containsKey(name)) {
                mTypes.put(name, item);
                Map mapColumnConfig = getTableConfigMap(sTableID);
                item.loadSettings(mapColumnConfig);
            }
        }
        for (int i = 0; i < itemsToAdd.length; i++) {
            TableColumnCore item = itemsToAdd[i];
            if (item != null && !item.isRemoved() && !item.getColumnAdded()) {
                item.setColumnAdded();
            }
        }
    } catch (Exception e) {
        System.out.println("Error while adding Table Column Extension");
        Debug.printStackTrace(e);
    } finally {
        items_mon.exit();
    }
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 15 with TableColumnCore

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

the class TableColumnManager method resetColumns.

public void resetColumns(Class dataSourceType, String tableID) {
    TableColumnCore[] allTableColumns = getAllTableColumnCoreAsArray(dataSourceType, tableID);
    if (allTableColumns != null) {
        for (TableColumnCore column : allTableColumns) {
            if (column != null) {
                column.setVisible(false);
                column.reset();
            }
        }
    }
    String[] defaultColumnNames = getDefaultColumnNames(tableID);
    if (defaultColumnNames != null) {
        int i = 0;
        for (String name : defaultColumnNames) {
            TableColumnCore column = getTableColumnCore(tableID, name);
            if (column != null) {
                column.setVisible(true);
                column.setPositionNoShift(i++);
            }
        }
    }
    saveTableColumns(dataSourceType, tableID);
    TableStructureEventDispatcher.getInstance(tableID).tableStructureChanged(true, dataSourceType);
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Aggregations

TableColumnCore (com.biglybt.ui.common.table.TableColumnCore)41 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)16 TableColumn (com.biglybt.pif.ui.tables.TableColumn)5 LightHashMap (com.biglybt.core.util.LightHashMap)4 TableRowCore (com.biglybt.ui.common.table.TableRowCore)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 TableCellCore (com.biglybt.ui.common.table.TableCellCore)3 TableColumnCoreCreationListener (com.biglybt.ui.common.table.TableColumnCoreCreationListener)3 Composite (org.eclipse.swt.widgets.Composite)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 Subscription (com.biglybt.core.subs.Subscription)2 TableCellAddedListener (com.biglybt.pif.ui.tables.TableCellAddedListener)2 TableCellRefreshListener (com.biglybt.pif.ui.tables.TableCellRefreshListener)2 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)2 GCStringPrinter (com.biglybt.ui.swt.shells.GCStringPrinter)2 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 TableCellSWTPaintListener (com.biglybt.ui.swt.views.table.TableCellSWTPaintListener)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2