Search in sources :

Example 1 with UISWTViewEventListenerWrapper

use of com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper in project BiglyBT by BiglySoftware.

the class SBC_TorrentDetailsView method initialize.

private void initialize(Composite composite) {
    Composite main_area = new Composite(composite, SWT.NULL);
    main_area.setLayout(new FormLayout());
    // Color bg_color = ColorCache.getColor(composite.getDisplay(), "#c0cbd4");
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    this.parent = composite;
    if (tabbedMDI == null) {
        tabbedMDI = uiFunctions.createTabbedMDI(main_area, "detailsview");
    } else {
        System.out.println("ManagerView::initialize : folder isn't null !!!");
    }
    if (composite.getLayout() instanceof FormLayout) {
        main_area.setLayoutData(Utils.getFilledFormData());
    } else if (composite.getLayout() instanceof GridLayout) {
        main_area.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    composite.layout();
    // Call plugin listeners
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        if (pluginUI != null) {
            MyTorrentsView.registerPluginViews(pluginUI);
            for (String id : new String[] { UISWTInstance.VIEW_MYTORRENTS, UISWTInstance.VIEW_TORRENT_DETAILS }) {
                UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(id);
                for (UISWTViewEventListenerWrapper l : pluginViews) {
                    if (id == UISWTInstance.VIEW_MYTORRENTS && l.getViewID() == PieceInfoView.MSGID_PREFIX) {
                        // Simple hack to exlude PieceInfoView tab as it's already within Pieces View
                        continue;
                    }
                    if (l != null) {
                        try {
                            tabbedMDI.createEntryFromEventListener(null, UISWTInstance.VIEW_TORRENT_DETAILS, l, l.getViewID(), false, manager, null);
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                }
            }
        }
    }
    SelectedContentManager.addCurrentlySelectedContentListener(this);
    tabbedMDI.addListener(new MdiSWTMenuHackListener() {

        @Override
        public void menuWillBeShown(MdiEntry entry, Menu menuTree) {
            menuTree.setData("downloads", new DownloadManager[] { manager });
            menuTree.setData("is_detailed_view", true);
            MenuFactory.buildTorrentMenu(menuTree);
        }
    });
    if (dataSource instanceof Object[] && ((Object[]) dataSource)[0] instanceof PEPeer) {
        tabbedMDI.showEntryByID(PeersView.MSGID_PREFIX);
    } else {
        MdiEntry[] entries = tabbedMDI.getEntries();
        if (entries.length > 0) {
            tabbedMDI.showEntry(entries[0]);
        }
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) PEPeer(com.biglybt.core.peer.PEPeer) Composite(org.eclipse.swt.widgets.Composite) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) DownloadManager(com.biglybt.core.download.DownloadManager) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) UISWTViewEventListenerWrapper(com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) Menu(org.eclipse.swt.widgets.Menu)

Example 2 with UISWTViewEventListenerWrapper

use of com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper in project BiglyBT by BiglySoftware.

the class TableViewSWT_TabsCommon method buildFolder.

private void buildFolder(final Composite form, final String props_prefix) {
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    menuItemShowTabs = menuManager.addMenuItem(props_prefix + "._end_", "ConfigView.section.style.ShowTabsInTorrentView");
    menuItemShowTabs.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItemShowTabs.setStyle(MenuItem.STYLE_CHECK);
    menuItemShowTabs.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setData(COConfigurationManager.getBooleanParameter("Library.ShowTabsInTorrentView"));
        }
    });
    menuItemShowTabs.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            COConfigurationManager.setParameter("Library.ShowTabsInTorrentView", (Boolean) menu.getData());
        }
    });
    cTabsHolder.addListener(SWT.Resize, new Listener() {

        @Override
        public void handleEvent(Event e) {
            if (tabbedMDI.getMinimized()) {
                fdHeightChanger.height = tabbedMDI.getFolderHeight();
                cTabsHolder.getParent().layout();
                return;
            }
            Double l = (Double) sash.getData("PCT");
            if (l != null) {
                int newHeight = (int) (form.getBounds().height * l.doubleValue());
                if (newHeight != fdHeightChanger.height) {
                    fdHeightChanger.height = newHeight;
                    cTabsHolder.getParent().layout();
                }
            }
        }
    });
    String[] restricted_to = tv.getTabViewsRestrictedTo();
    Set<String> rt_set = new HashSet<>();
    if (restricted_to != null) {
        rt_set.addAll(Arrays.asList(restricted_to));
    }
    // Call plugin listeners
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        if (pluginUI != null) {
            UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(tv.getTableID());
            if (pluginViews != null) {
                for (final UISWTViewEventListenerWrapper l : pluginViews) {
                    if (l == null) {
                        continue;
                    }
                    try {
                        String view_id = l.getViewID();
                        if (restricted_to != null && !rt_set.contains(view_id)) {
                            continue;
                        }
                        tabbedMDI.registerEntry(view_id, new MdiEntryCreationListener2() {

                            @Override
                            public MdiEntry createMDiEntry(MultipleDocumentInterface mdi, String id, Object datasource, Map<?, ?> params) {
                                return addTabView(l, null);
                            }
                        });
                        tabbedMDI.loadEntryByID(view_id, false);
                    } catch (Exception e) {
                    // skip, plugin probably specifically asked to not be added
                    }
                }
            }
        }
    }
    if (!tabbedMDI.getMinimized()) {
        MdiEntry[] entries = tabbedMDI.getEntries();
        if (entries.length > 0) {
            tabbedMDI.showEntry(entries[0]);
        }
    }
}
Also used : MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) TabbedMdiMaximizeListener(com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) Listener(org.eclipse.swt.widgets.Listener) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) UIManager(com.biglybt.pif.ui.UIManager) MdiEntryCreationListener2(com.biglybt.ui.mdi.MdiEntryCreationListener2) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) HashSet(java.util.HashSet) PluginInterface(com.biglybt.pif.PluginInterface) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) MenuManager(com.biglybt.pif.ui.menus.MenuManager) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) UISWTViewEventListenerWrapper(com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance)

Example 3 with UISWTViewEventListenerWrapper

use of com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper in project BiglyBT by BiglySoftware.

the class StatsView method initialize.

private void initialize(Composite composite) {
    parent = composite;
    // Call plugin listeners
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        tabbedMDI = uiFunctions.createTabbedMDI(composite, VIEW_ID);
        CTabFolder folder = tabbedMDI.getTabFolder();
        Label lblClose = new Label(folder, SWT.WRAP);
        lblClose.setText("x");
        lblClose.addListener(SWT.MouseUp, new Listener() {

            @Override
            public void handleEvent(Event event) {
                delete();
            }
        });
        folder.setTopRight(lblClose);
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(pluginUI);
        if (pluginUI != null) {
            UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(UISWTInstance.VIEW_STATISTICS);
            for (int i = 0; i < pluginViews.length; i++) {
                UISWTViewEventListenerWrapper l = pluginViews[i];
                String name = l.getViewID();
                try {
                    MdiEntrySWT entry = (MdiEntrySWT) tabbedMDI.createEntryFromEventListener(UISWTInstance.VIEW_STATISTICS, l, name, false, null, null);
                    entry.setDestroyOnDeactivate(false);
                    if ((dataSource == null && i == 0) || name.equals(dataSource)) {
                        tabbedMDI.showEntry(entry);
                    }
                } catch (Exception e) {
                // skip
                }
            }
        }
    }
    updateThread = new UpdateThread();
    updateThread.setDaemon(true);
    updateThread.start();
    dataSourceChanged(dataSource);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) Listener(org.eclipse.swt.widgets.Listener) Label(org.eclipse.swt.widgets.Label) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) UISWTViewEventListenerWrapper(com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance)

Aggregations

UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)3 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)3 UISWTViewEventListenerWrapper (com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper)3 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 DownloadManager (com.biglybt.core.download.DownloadManager)1 PEPeer (com.biglybt.core.peer.PEPeer)1 PluginInterface (com.biglybt.pif.PluginInterface)1 UIManager (com.biglybt.pif.ui.UIManager)1 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)1 MenuItem (com.biglybt.pif.ui.menus.MenuItem)1 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)1 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)1 MenuManager (com.biglybt.pif.ui.menus.MenuManager)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 MdiEntryCreationListener2 (com.biglybt.ui.mdi.MdiEntryCreationListener2)1 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)1 SelectedContentListener (com.biglybt.ui.selectedcontent.SelectedContentListener)1 MdiEntrySWT (com.biglybt.ui.swt.mdi.MdiEntrySWT)1