Search in sources :

Example 1 with MdiEntryCreationListener2

use of com.biglybt.ui.mdi.MdiEntryCreationListener2 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 2 with MdiEntryCreationListener2

use of com.biglybt.ui.mdi.MdiEntryCreationListener2 in project BiglyBT by BiglySoftware.

the class SBC_ChatOverview method preInitialize.

public static void preInitialize() {
    UIManager ui_manager = PluginInitializer.getDefaultInterface().getUIManager();
    ui_manager.addUIListener(new UIManagerListener() {

        @Override
        public void UIAttached(UIInstance instance) {
            final MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
            if (mdi == null) {
                return;
            }
            mdi.registerEntry("Chat_.*", new MdiEntryCreationListener2() {

                @Override
                public MdiEntry createMDiEntry(MultipleDocumentInterface mdi, String id, Object datasource, Map<?, ?> params) {
                    ChatInstance chat = null;
                    if (datasource instanceof ChatInstance) {
                        chat = (ChatInstance) datasource;
                        try {
                            chat = chat.getClone();
                        } catch (Throwable e) {
                            chat = null;
                            Debug.out(e);
                        }
                    } else if (id.length() > 7) {
                        BuddyPluginBeta beta = BuddyPluginUtils.getBetaPlugin();
                        if (beta != null) {
                            try {
                                String[] bits = id.substring(5).split(":");
                                String network = AENetworkClassifier.internalise(bits[0]);
                                String key = new String(Base32.decode(bits[1]), "UTF-8");
                                chat = beta.getChat(network, key);
                            } catch (Throwable e) {
                                Debug.out(e);
                            }
                        }
                    }
                    if (chat != null) {
                        chat.setAutoNotify(true);
                        return (createChatMdiEntry(chat));
                    }
                    return (null);
                }
            });
        }

        @Override
        public void UIDetached(UIInstance instance) {
        }
    });
}
Also used : MdiEntryCreationListener2(com.biglybt.ui.mdi.MdiEntryCreationListener2) UIManager(com.biglybt.pif.ui.UIManager) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) BuddyPluginBeta(com.biglybt.plugin.net.buddy.BuddyPluginBeta) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) Map(java.util.Map) TreeMap(java.util.TreeMap) UIInstance(com.biglybt.pif.ui.UIInstance)

Aggregations

UIManager (com.biglybt.pif.ui.UIManager)2 MdiEntryCreationListener2 (com.biglybt.ui.mdi.MdiEntryCreationListener2)2 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)2 PluginInterface (com.biglybt.pif.PluginInterface)1 UIInstance (com.biglybt.pif.ui.UIInstance)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 BuddyPluginBeta (com.biglybt.plugin.net.buddy.BuddyPluginBeta)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 SelectedContentListener (com.biglybt.ui.selectedcontent.SelectedContentListener)1 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)1 TabbedMdiMaximizeListener (com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener)1 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)1 UISWTViewEventListenerWrapper (com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper)1 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 HashSet (java.util.HashSet)1