Search in sources :

Example 26 with TableColumnCore

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

the class SBC_ChatOverview method initTable.

private void initTable(Composite control) {
    if (tv == null) {
        tv = TableViewFactory.createTableViewSWT(ChatInstance.class, TABLE_CHAT, TABLE_CHAT, new TableColumnCore[0], ColumnChatName.COLUMN_ID, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
        if (txtFilter != null) {
            tv.enableFilterCheck(txtFilter, this);
        }
        tv.setRowDefaultHeightEM(1);
        table_parent = new Composite(control, SWT.BORDER);
        table_parent.setLayoutData(Utils.getFilledFormData());
        GridLayout layout = new GridLayout();
        layout.marginHeight = layout.marginWidth = layout.verticalSpacing = layout.horizontalSpacing = 0;
        table_parent.setLayout(layout);
        tv.addMenuFillListener(this);
        tv.addSelectionListener(this, false);
        tv.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                if (e.stateMask == 0 && e.keyCode == SWT.DEL) {
                    Object[] datasources = tv.getSelectedDataSources().toArray();
                    if (datasources.length > 0) {
                        List<ChatInstance> chats = new ArrayList<>();
                        String str = "";
                        for (Object object : datasources) {
                            if (object instanceof ChatInstance) {
                                ChatInstance chat = (ChatInstance) object;
                                chats.add(chat);
                                if (chats.size() == 1) {
                                    str = chat.getDisplayName();
                                    if (str == null) {
                                        str = chat.getName();
                                    }
                                } else if (chats.size() == 2) {
                                    str += ", ...";
                                }
                            }
                        }
                        MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { str }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
                        mb.open(new UserPrompterResultListener() {

                            @Override
                            public void prompterClosed(int result) {
                                if (result == 0) {
                                    for (ChatInstance chat : chats) {
                                        chat.remove();
                                    }
                                }
                            }
                        });
                    }
                    e.doit = false;
                }
            }
        });
        tv.initialize(table_parent);
    }
    control.layout(true);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) List(java.util.List) ArrayList(java.util.ArrayList) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 27 with TableColumnCore

use of com.biglybt.ui.common.table.TableColumnCore 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 28 with TableColumnCore

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

the class ColumnTC_ChosenColumn method refresh.

// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    int colPos = column.getPosition();
    // colPos can have gaps in numbers
    if (!cell.setSortValue(colPos) && cell.isValid()) {
        return;
    }
    String key = column.getTitleLanguageKey();
    String s = MessageText.getString(key, column.getName());
    // s = column.getPosition() + "] " + s;
    cell.setText(s);
    String info = MessageText.getString(key + ".info", "");
    cell.setToolTip(info);
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 29 with TableColumnCore

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

the class ColumnTC_Info method refresh.

// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    String key = column.getTitleLanguageKey();
    if (!cell.setSortValue(key) && cell.isValid()) {
        return;
    }
    cell.setText(MessageText.getString(key + ".info", ""));
}
Also used : TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 30 with TableColumnCore

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

the class ColumnTC_NameInfo method refresh.

// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
    TableColumnCore column = (TableColumnCore) cell.getDataSource();
    String key = column.getTitleLanguageKey();
    cell.setSortValue(MessageText.getString(key, column.getName()));
}
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