Search in sources :

Example 1 with TableViewSWT_TabsCommon

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

the class PiecesView method addExistingDatasources.

/**
 * Add datasources already in existance before we called addListener.
 * Faster than allowing addListener to call us one datasource at a time.
 */
private void addExistingDatasources() {
    if (manager == null || tv.isDisposed()) {
        return;
    }
    PEPiece[] dataSources = manager.getCurrentPieces();
    if (dataSources != null && dataSources.length >= 0) {
        tv.addDataSources(dataSources);
        tv.processDataSourceQueue();
    }
    // For this view the tab datasource isn't driven by table row selection so we
    // need to update it with the primary data source
    // TODO: TrackerView and PiecesView now have this similar code -- this
    // would be better handled in TableViewTab (or TableViewSWT?)
    TableViewSWT_TabsCommon tabs = tv.getTabsCommon();
    if (tabs != null) {
        tabs.triggerTabViewsDataSourceChanged(tv);
    }
}
Also used : PEPiece(com.biglybt.core.peer.PEPiece) TableViewSWT_TabsCommon(com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon)

Example 2 with TableViewSWT_TabsCommon

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

the class MyTorrentsSuperView method initializeWithCore.

private void initializeWithCore(Core core, Composite parent) {
    torrentview = createTorrentView(core, TableManager.TABLE_MYTORRENTS_INCOMPLETE, false, getIncompleteColumns(), child1);
    seedingview = createTorrentView(core, TableManager.TABLE_MYTORRENTS_COMPLETE, true, getCompleteColumns(), child2);
    torrentview.getComposite().addListener(SWT.FocusIn, new Listener() {

        @Override
        public void handleEvent(Event event) {
            seedingview.getTableView().getTabsCommon().setTvOverride(torrentview.getTableView());
        }
    });
    seedingview.getComposite().addListener(SWT.FocusIn, new Listener() {

        @Override
        public void handleEvent(Event event) {
            seedingview.getTableView().getTabsCommon().setTvOverride(null);
        }
    });
    // delegate selections from the incomplete view to the sub-tabs owned by the seeding view
    SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewId) {
            if (form.isDisposed() || torrentview == null || seedingview == null) {
                SelectedContentManager.removeCurrentlySelectedContentListener(this);
            } else {
                TableView<?> selected_tv = SelectedContentManager.getCurrentlySelectedTableView();
                TableViewSWT<?> incomp_tv = torrentview.getTableView();
                TableViewSWT<?> comp_tv = seedingview.getTableView();
                if (incomp_tv != null && comp_tv != null && (selected_tv == incomp_tv || selected_tv == comp_tv)) {
                    TableViewSWT_TabsCommon tabs = comp_tv.getTabsCommon();
                    if (tabs != null) {
                        Utils.execSWTThread(new Runnable() {

                            public void run() {
                                tabs.triggerTabViewsDataSourceChanged(selected_tv);
                            }
                        });
                    }
                }
            }
        }
    });
    initializeDone();
}
Also used : TableViewSWT_TabsCommon(com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) UISWTViewCoreEventListener(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) AERunnable(com.biglybt.core.util.AERunnable) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) TableViewSWT(com.biglybt.ui.swt.views.table.TableViewSWT) TableView(com.biglybt.ui.common.table.TableView)

Example 3 with TableViewSWT_TabsCommon

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

the class TrackerView method tableViewInitialized.

public void tableViewInitialized() {
    if (manager != null) {
        manager.addTPSListener(this);
        addExistingDatasources();
        // For this view the tab datasource isn't driven by table row selection so we
        // need to update it with the primary data source
        TableViewSWT_TabsCommon tabs = tv.getTabsCommon();
        if (tabs != null) {
            tabs.triggerTabViewsDataSourceChanged(tv);
        }
    }
}
Also used : TableViewSWT_TabsCommon(com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon)

Example 4 with TableViewSWT_TabsCommon

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

the class TableViewPainted method initialize.

@Override
public void initialize(UISWTView parentView, Composite parent) {
    tvTabsCommon = new TableViewSWT_TabsCommon(parentView, this);
    shell = parent.getShell();
    mainComposite = tvTabsCommon.createSashForm(parent);
    mainComposite.setData("Name", tableID);
    mainComposite.setData("ObfuscateImage", this);
    Composite cTableComposite = tvTabsCommon.tableComposite;
    cTableComposite.setLayout(new FormLayout());
    Layout layout = parent.getLayout();
    if (layout instanceof FormLayout) {
        FormData fd = Utils.getFilledFormData();
        cTableComposite.setLayoutData(fd);
    }
    cHeaderArea = new Canvas(cTableComposite, SWT.DOUBLE_BUFFERED);
    fontHeader = FontUtils.getFontWithHeight(cHeaderArea.getFont(), null, Utils.adjustPXForDPI(12));
    fontHeaderSmall = FontUtils.getFontPercentOf(fontHeader, 0.8f);
    cHeaderArea.setFont(fontHeader);
    cTable = new Canvas(cTableComposite, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.V_SCROLL);
    int minRowHeight = FontUtils.getFontHeightInPX(cTable.getFont());
    if (iHeightEM > 0) {
        defaultRowHeight = (int) ((minRowHeight * iHeightEM) + iHeightEM);
        iHeightEM = -1;
    }
    // good test
    // cTable.setFont(FontUtils.getFontPercentOf(cTable.getFont(), 1.50f));
    minRowHeight += Math.ceil(minRowHeight * 2.0 / 16.0);
    if (defaultRowHeight < minRowHeight) {
        defaultRowHeight = minRowHeight;
    }
    cTable.setBackground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_LIST_BACKGROUND));
    headerHeight = configMan.getIntParameter("Table.headerHeight");
    if (headerHeight <= 0) {
        headerHeight = Utils.adjustPXForDPI(DEFAULT_HEADER_HEIGHT);
    }
    FormData fd = Utils.getFilledFormData();
    fd.height = headerHeight;
    fd.bottom = null;
    cHeaderArea.setLayoutData(fd);
    fd = Utils.getFilledFormData();
    fd.top = new FormAttachment(cHeaderArea);
    cTable.setLayoutData(fd);
    clientArea = cTable.getClientArea();
    TableColumnCore[] tableColumns = getAllColumns();
    TableColumnCore[] tmpColumnsOrdered = new TableColumnCore[tableColumns.length];
    // Create all columns
    int columnOrderPos = 0;
    Arrays.sort(tableColumns, TableColumnManager.getTableColumnOrderComparator());
    for (int i = 0; i < tableColumns.length; i++) {
        int position = tableColumns[i].getPosition();
        if (position != -1 && tableColumns[i].isVisible()) {
            // table.createNewColumn(SWT.NULL);
            // System.out.println(i + "] " + tableColumns[i].getName() + ";" + position);
            tmpColumnsOrdered[columnOrderPos++] = tableColumns[i];
        }
    }
    // int numSWTColumns = table.getColumnCount();
    // int iNewLength = numSWTColumns - (bSkipFirstColumn ? 1 : 0);
    TableColumnCore[] columnsOrdered = new TableColumnCore[columnOrderPos];
    System.arraycopy(tmpColumnsOrdered, 0, columnsOrdered, 0, columnOrderPos);
    setColumnsOrdered(columnsOrdered);
    cTable.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            swt_paintComposite(e);
        }
    });
    menu = createMenu();
    cTable.setMenu(menu);
    cHeaderArea.setMenu(menu);
    setupHeaderArea(cHeaderArea);
    cTable.addControlListener(new ControlListener() {

        boolean inControlResize = false;

        @Override
        public void controlResized(ControlEvent e) {
            if (inControlResize) {
                return;
            }
            try {
                inControlResize = true;
                swt_calculateClientArea();
                swt_fixupSize();
            } finally {
                inControlResize = false;
            }
        }

        @Override
        public void controlMoved(ControlEvent e) {
        }
    });
    hBar = cTable.getHorizontalBar();
    if (hBar != null) {
        hBar.setValues(0, 0, 0, 10, 10, 100);
        hBar.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // swt_calculateClientArea();
                if (DIRECT_DRAW) {
                    swt_calculateClientArea();
                    redrawTable();
                } else {
                    cTable.redraw();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    vBar = cTable.getVerticalBar();
    if (vBar != null) {
        vBar.setValues(0, 0, 0, 50, getRowDefaultHeight(), 50);
        vBar.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                swt_vBarChanged();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    if (DEBUG_WITH_SHELL) {
        Shell shell = new Shell();
        sCanvasImage = new Canvas(shell, SWT.DOUBLE_BUFFERED);
        shell.setLayout(new FillLayout());
        sCanvasImage.addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                if (canvasImage == null) {
                    return;
                }
                e.gc.drawImage(canvasImage, 0, 0);
            // System.out.println(System.currentTimeMillis() + "] Paint " + e.x + "x" + e.y + " " + e.width + "x" + e.height);
            }
        });
        shell.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                sCanvasImage = null;
            }
        });
        shell.setVisible(true);
    }
    cTable.addMouseListener(tvSWTCommon);
    cTable.addMouseMoveListener(tvSWTCommon);
    cTable.addKeyListener(tvSWTCommon);
    // composite.addSelectionListener(tvSWTCommon);
    cTable.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent e) {
            e.doit = true;
        }
    });
    cTable.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (canvasImage != null) {
                canvasImage.dispose();
                canvasImage = null;
            }
        }
    });
    SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewID) {
            if (cTable == null || cTable.isDisposed()) {
                SelectedContentManager.removeCurrentlySelectedContentListener(this);
            } else {
                redrawTable();
            }
        }
    });
    cTable.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            isFocused = false;
            redrawTable();
        }

        @Override
        public void focusGained(FocusEvent e) {
            isFocused = true;
            redrawTable();
        }
    });
    isFocused = cTable.isFocusControl();
    new TableTooltips(this, cTable);
    TableColumnManager tcManager = TableColumnManager.getInstance();
    String sSortColumn = tcManager.getDefaultSortColumnName(tableID);
    if (sSortColumn == null || sSortColumn.length() == 0) {
        sSortColumn = sDefaultSortOn;
    }
    TableColumnCore tc = tcManager.getTableColumnCore(tableID, sSortColumn);
    if (tc == null && tableColumns.length > 0) {
        tc = tableColumns[0];
    }
    setSortColumn(tc, false);
    triggerLifeCycleListener(TableLifeCycleListener.EVENT_TABLELIFECYCLE_INITIALIZED);
    configMan.addParameterListener("Graphics Update", this);
    configMan.addParameterListener("ReOrder Delay", this);
    configMan.addParameterListener("Table.extendedErase", this);
    configMan.addParameterListener("Table.headerHeight", this);
    Colors.getInstance().addColorsChangedListener(this);
    // So all TableView objects of the same TableID have the same columns,
    // and column widths, etc
    TableStructureEventDispatcher.getInstance(tableID).addListener(this);
    MessageText.addListener(this);
}
Also used : TableTooltips(com.biglybt.ui.swt.views.table.impl.TableTooltips) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) TableViewSWT_TabsCommon(com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener)

Aggregations

TableViewSWT_TabsCommon (com.biglybt.ui.swt.views.table.impl.TableViewSWT_TabsCommon)4 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 SelectedContentListener (com.biglybt.ui.selectedcontent.SelectedContentListener)2 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 PEPiece (com.biglybt.core.peer.PEPiece)1 AERunnable (com.biglybt.core.util.AERunnable)1 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 TableView (com.biglybt.ui.common.table.TableView)1 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)1 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)1 UISWTViewCoreEventListener (com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener)1 TableViewSWT (com.biglybt.ui.swt.views.table.TableViewSWT)1 TableTooltips (com.biglybt.ui.swt.views.table.impl.TableTooltips)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1