Search in sources :

Example 1 with ViewManagerSWT

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

the class UISWTInstanceImpl method openView.

@Override
public boolean openView(final String forViewID, final String sViewID, final Object dataSource, final boolean setfocus) {
    ViewManagerSWT vm = ViewManagerSWT.getInstance();
    UISWTViewBuilderCore builder = vm.getBuilder(forViewID, sViewID);
    if (builder == null) {
        return false;
    }
    // Just in case, clone the builder with new ds
    if (dataSource != builder.getInitialDataSource()) {
        builder = builder.cloneBuilder();
        builder.setInitialDatasource(dataSource);
    }
    uiFunctions.openPluginView(builder, setfocus && !bUIAttaching);
    return true;
}
Also used : ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT)

Example 2 with ViewManagerSWT

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

the class TableViewSWT_TabsCommon method createSashForm.

// TabViews Functions
public Composite createSashForm(final Composite composite) {
    if (!tv.isTabViewsEnabled()) {
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    if (parentView instanceof TabbedEntry) {
        if (!((TabbedEntry) parentView).getMDI().getAllowSubViews()) {
            tableComposite = tv.createMainPanel(composite);
            return tableComposite;
        }
    }
    SelectedContentManager.addCurrentlySelectedContentListener(this);
    ConfigurationManager configMan = ConfigurationManager.getInstance();
    ViewManagerSWT vm = ViewManagerSWT.getInstance();
    int iNumViews = vm.getBuilders(tv.getTableID()).size() + vm.getBuilders(tv.getDataSourceType()).size();
    if (iNumViews == 0) {
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    final String props_prefix = tv.getTableID() + "." + tv.getPropertiesPrefix();
    FormData formData;
    final Composite form = new Composite(composite, SWT.NONE);
    FormLayout flayout = new FormLayout();
    flayout.marginHeight = 0;
    flayout.marginWidth = 0;
    form.setLayout(flayout);
    GridData gridData;
    gridData = new GridData(GridData.FILL_BOTH);
    form.setLayoutData(gridData);
    // Create them in reverse order, so we can have the table auto-grow, and
    // set the tabFolder's height manually
    cTabsHolder = new Composite(form, SWT.NONE);
    tabbedMDI = new TabbedMDI(tv.getDataSourceType(), tv.getTableID(), props_prefix, parentView, null);
    tabbedMDI.setAllowSubViews(false);
    tabbedMDI.setMinimizeVisible(true);
    tabbedMDI.buildMDI(cTabsHolder);
    if (tabbedMDI.isEmpty()) {
        // All views said no, undo our tab creation
        // TODO: If a new view is registered for this table id, we should
        // create the tabbedMDI.  But we don't even do that yet when there
        // are 0 subviews and one is added.. so, don't worry about it
        form.dispose();
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    tabbedMDI.setTabbedMdiMaximizeListener(new TabbedMdiMaximizeListener() {

        @Override
        public void maximizePressed() {
            TableView tvToUse = tvOverride == null ? tv : tvOverride;
            Object[] ds = tvToUse.getSelectedDataSources(true);
            if (ds.length == 1 && ds[0] instanceof DownloadManager) {
                UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                if (uiFunctions != null) {
                    uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, ds);
                }
            }
        }
    });
    final int SASH_WIDTH = 5;
    sash = Utils.createSash(form, SASH_WIDTH);
    tableComposite = tv.createMainPanel(form);
    Composite cFixLayout = tableComposite;
    while (cFixLayout != null && cFixLayout.getParent() != form) {
        cFixLayout = cFixLayout.getParent();
    }
    if (cFixLayout == null) {
        cFixLayout = tableComposite;
    }
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cFixLayout.setLayout(layout);
    // FormData for Folder
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    int iSplitAt = configMan.getIntParameter(props_prefix + ".SplitAt2", 300000);
    if (iSplitAt == 300000) {
        // was stored with less precision
        String legacy_key = props_prefix + ".SplitAt";
        if (configMan.hasParameter(legacy_key, false)) {
            iSplitAt = configMan.getIntParameter(legacy_key, 3000);
            configMan.removeParameter(legacy_key);
            if (iSplitAt < 100) {
                iSplitAt *= 100;
            }
            iSplitAt *= 100;
        }
    }
    // pct is % bottom
    double pct = iSplitAt / 1000000.0;
    if (pct < 0.03) {
        pct = 0.03;
    } else if (pct > 0.97) {
        pct = 0.97;
    }
    // height will be set on first resize call
    sash.setData("PCT", new Double(pct));
    cTabsHolder.setLayout(new FormLayout());
    fdHeightChanger = formData;
    cTabsHolder.setLayoutData(formData);
    // FormData for Sash
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(cTabsHolder);
    formData.height = SASH_WIDTH;
    sash.setLayoutData(formData);
    // FormData for table Composite
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(sash);
    cFixLayout.setLayoutData(formData);
    // Listeners to size the folder
    sash.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final boolean FASTDRAG = true;
            if (FASTDRAG && e.detail == SWT.DRAG) {
                return;
            }
            Rectangle area = form.getClientArea();
            int height = area.height - e.y - e.height;
            if (!Constants.isWindows) {
                height -= SASH_WIDTH;
            }
            if (area.height - height < 100) {
                height = area.height - 100;
            }
            if (height < 0) {
                height = 0;
            }
            fdHeightChanger.height = height;
            Double l = new Double((double) height / area.height);
            sash.setData("PCT", l);
            if (e.detail != SWT.DRAG) {
                ConfigurationManager configMan = ConfigurationManager.getInstance();
                double d_split_at = l.doubleValue() * 1000000;
                int split_at = (int) d_split_at;
                if (d_split_at - split_at > 0) {
                    split_at++;
                }
                configMan.setParameter(props_prefix + ".SplitAt2", split_at);
            }
            form.layout();
            // sometimes sash cheese is left
            cTabsHolder.redraw();
        }
    });
    buildFolder(form, props_prefix);
    return form;
}
Also used : ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) DownloadManager(com.biglybt.core.download.DownloadManager) UIFunctions(com.biglybt.ui.UIFunctions) SelectionEvent(org.eclipse.swt.events.SelectionEvent) COConfigurationManager(com.biglybt.core.config.COConfigurationManager) ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager) TableView(com.biglybt.ui.common.table.TableView)

Example 3 with ViewManagerSWT

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

the class TabbedMDI method buildTabs.

private void buildTabs() {
    CTabItem[] items = tabFolder.getItems();
    for (CTabItem item : items) {
        item.setData(KEY_AUTO_CLOSE, true);
    }
    for (CTabItem item : items) {
        item.dispose();
    }
    ViewManagerSWT vm = ViewManagerSWT.getInstance();
    List<UISWTViewBuilderCore> builders = vm.getBuilders(getViewID(), getDataSourceType());
    for (UISWTViewBuilderCore builder : builders) {
        try {
            createEntry(builder, true);
        } catch (Exception ignore) {
        }
    }
    if (!isMainMDI) {
        Utils.execSWTThreadLater(0, () -> {
            String key = props_prefix + ".selectedTab";
            String id = COConfigurationManager.getStringParameter(key, null);
            if (id != null) {
                int index = indexOf(id);
                if (index != -1) {
                    tabFolder.setSelection(index);
                    return;
                }
            }
            if (tabFolder.getItemCount() > 0) {
                tabFolder.setSelection(0);
            }
        });
    }
}
Also used : ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT) UISWTViewBuilderCore(com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore) UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException)

Example 4 with ViewManagerSWT

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

the class SBC_AllTrackersView method registerPluginViews.

private static void registerPluginViews() {
    ViewManagerSWT vm = ViewManagerSWT.getInstance();
    if (vm.areCoreViewsRegistered(PLUGIN_DS_TYPE)) {
        return;
    }
    vm.registerView(PLUGIN_DS_TYPE, new UISWTViewBuilderCore(MyTorrentsSubView.MSGID_PREFIX, null, MyTorrentsSubView.class));
    vm.setCoreViewsRegistered(PLUGIN_DS_TYPE);
}
Also used : MyTorrentsSubView(com.biglybt.ui.swt.views.MyTorrentsSubView) ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT) UISWTViewBuilderCore(com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore)

Example 5 with ViewManagerSWT

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

the class SBC_ArchivedDownloadsView method registerPluginViews.

private static void registerPluginViews() {
    ViewManagerSWT vm = ViewManagerSWT.getInstance();
    if (vm.areCoreViewsRegistered(PLUGIN_DS_TYPE)) {
        return;
    }
    vm.registerView(PLUGIN_DS_TYPE, new UISWTViewBuilderCore(ArchivedFilesView.MSGID_PREFIX, null, ArchivedFilesView.class));
    vm.setCoreViewsRegistered(PLUGIN_DS_TYPE);
}
Also used : ArchivedFilesView(com.biglybt.ui.swt.views.ArchivedFilesView) ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT) UISWTViewBuilderCore(com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore)

Aggregations

ViewManagerSWT (com.biglybt.ui.swt.views.ViewManagerSWT)10 UISWTViewBuilderCore (com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore)8 MenuItem (org.eclipse.swt.widgets.MenuItem)2 COConfigurationManager (com.biglybt.core.config.COConfigurationManager)1 ConfigurationManager (com.biglybt.core.config.impl.ConfigurationManager)1 DownloadManager (com.biglybt.core.download.DownloadManager)1 UIFunctions (com.biglybt.ui.UIFunctions)1 TableView (com.biglybt.ui.common.table.TableView)1 MenuItemManager (com.biglybt.ui.common.util.MenuItemManager)1 UISWTViewEventCancelledException (com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException)1 ArchivedFilesView (com.biglybt.ui.swt.views.ArchivedFilesView)1 MyTorrentsSubView (com.biglybt.ui.swt.views.MyTorrentsSubView)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1