Search in sources :

Example 1 with FilesView

use of com.biglybt.ui.swt.views.FilesView in project BiglyBT by BiglySoftware.

the class ColumnFileCount method openFilesMiniView.

private void openFilesMiniView(DownloadManager dm, TableCell cell) {
    Shell shell = ShellFactory.createShell(Utils.findAnyShell(), SWT.SHELL_TRIM);
    FillLayout fillLayout = new FillLayout();
    fillLayout.marginHeight = 2;
    fillLayout.marginWidth = 2;
    shell.setLayout(fillLayout);
    Rectangle bounds = ((TableCellSWT) cell).getBoundsOnDisplay();
    bounds.y += bounds.height;
    bounds.width = 630;
    bounds.height = (16 * dm.getNumFileInfos()) + 60;
    Rectangle realBounds = shell.computeTrim(0, 0, bounds.width, bounds.height);
    realBounds.width -= realBounds.x;
    realBounds.height -= realBounds.y;
    realBounds.x = bounds.x;
    realBounds.y = bounds.y;
    if (bounds.height > 500) {
        bounds.height = 500;
    }
    shell.setBounds(realBounds);
    shell.setAlpha(230);
    Utils.verifyShellRect(shell, true);
    final FilesView view = new FilesView(false);
    view.dataSourceChanged(dm);
    view.initialize(shell);
    Composite composite = view.getComposite();
    // composite.setLayoutData(null);
    // shell.setLayout(new FillLayout());
    view.viewActivated();
    view.refresh();
    final UIUpdatable viewUpdater = new UIUpdatable() {

        @Override
        public void updateUI() {
            view.refresh();
        }

        @Override
        public String getUpdateUIName() {
            return view.getFullTitle();
        }
    };
    UIUpdaterSWT.getInstance().addUpdater(viewUpdater);
    shell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            UIUpdaterSWT.getInstance().removeUpdater(viewUpdater);
            view.delete();
        }
    });
    shell.layout(true, true);
    shell.setText(dm.getDisplayName());
    shell.open();
}
Also used : UIUpdatable(com.biglybt.ui.common.updater.UIUpdatable) DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) TableCellSWT(com.biglybt.ui.swt.views.table.TableCellSWT) Composite(org.eclipse.swt.widgets.Composite) FilesView(com.biglybt.ui.swt.views.FilesView) Rectangle(org.eclipse.swt.graphics.Rectangle) FillLayout(org.eclipse.swt.layout.FillLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 2 with FilesView

use of com.biglybt.ui.swt.views.FilesView in project BiglyBT by BiglySoftware.

the class TagUIUtils method showFilesView.

private static void showFilesView(final TagDownload tag) {
    Shell shell = ShellFactory.createShell(Utils.findAnyShell(), SWT.SHELL_TRIM);
    FillLayout fillLayout = new FillLayout();
    fillLayout.marginHeight = 2;
    fillLayout.marginWidth = 2;
    shell.setLayout(fillLayout);
    final FilesView view = new FilesView(false);
    view.setDisableWhenEmpty(false);
    Set<DownloadManager> dms = tag.getTaggedDownloads();
    view.dataSourceChanged(dms.toArray());
    view.initialize(shell);
    view.viewActivated();
    view.refresh();
    final UIUpdatable viewUpdater = new UIUpdatable() {

        @Override
        public void updateUI() {
            view.refresh();
        }

        @Override
        public String getUpdateUIName() {
            return view.getFullTitle();
        }
    };
    UIUpdaterSWT.getInstance().addUpdater(viewUpdater);
    final TagListener tag_listener = new TagListener() {

        @Override
        public void taggableSync(Tag tag) {
        }

        @Override
        public void taggableRemoved(Tag t, Taggable tagged) {
            Set<DownloadManager> dms = tag.getTaggedDownloads();
            view.dataSourceChanged(dms.toArray());
        }

        @Override
        public void taggableAdded(Tag t, Taggable tagged) {
            Set<DownloadManager> dms = tag.getTaggedDownloads();
            view.dataSourceChanged(dms.toArray());
        }
    };
    tag.addTagListener(tag_listener, false);
    shell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            tag.removeTagListener(tag_listener);
            UIUpdaterSWT.getInstance().removeUpdater(viewUpdater);
            view.delete();
        }
    });
    shell.layout(true, true);
    shell.setText(tag.getTagName(true));
    shell.open();
}
Also used : UIUpdatable(com.biglybt.ui.common.updater.UIUpdatable) DisposeListener(org.eclipse.swt.events.DisposeListener) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) FilesView(com.biglybt.ui.swt.views.FilesView) FillLayout(org.eclipse.swt.layout.FillLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)2 FilesView (com.biglybt.ui.swt.views.FilesView)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 DownloadManager (com.biglybt.core.download.DownloadManager)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 TableCellSWT (com.biglybt.ui.swt.views.table.TableCellSWT)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1