Search in sources :

Example 1 with MenuManager

use of com.biglybt.pif.ui.menus.MenuManager in project BiglyBT by BiglySoftware.

the class SB_Transfers method addHeaderMenu.

protected void addHeaderMenu() {
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    UIManager uim = pi.getUIManager();
    assert uim != null;
    final MenuManager menuManager = uim.getMenuManager();
    MenuItem menuItem;
    menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, "MyTorrentsView.menu.setCategory.add");
    menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItem.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            CategoryUIUtils.showCreateCategoryDialog(null);
        }
    });
    // cats in sidebar
    menuItem.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setVisible(COConfigurationManager.getBooleanParameter("Library.CatInSideBar"));
        }
    });
    menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, "ConfigView.section.style.CatInSidebar");
    menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItem.setStyle(MenuItem.STYLE_CHECK);
    menuItem.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            boolean b = COConfigurationManager.getBooleanParameter("Library.CatInSideBar");
            COConfigurationManager.setParameter("Library.CatInSideBar", !b);
        }
    });
    menuItem.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setVisible(CategoryManager.getCategories().length > 0);
            menu.setData(COConfigurationManager.getBooleanParameter("Library.CatInSideBar"));
        }
    });
    // show tags in sidebar
    TagUIUtils.setupSideBarMenus(menuManager);
}
Also used : MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) PluginInterface(com.biglybt.pif.PluginInterface) MenuManager(com.biglybt.pif.ui.menus.MenuManager) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener)

Example 2 with MenuManager

use of com.biglybt.pif.ui.menus.MenuManager in project BiglyBT by BiglySoftware.

the class SideBar method addGeneralMenus.

/**
 * @since 3.1.0.1
 */
private void addGeneralMenus() {
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getDefaultPluginInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    {
        MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.add.to.dashboard");
        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        menuItem.addFillListener(new MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null && sbe.getId().equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
                    menu.setVisible(false);
                } else {
                    menu.setVisible(sbe != null && sbe.canBuildStandAlone());
                }
            }
        });
        menuItem.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null) {
                    MainMDISetup.getSb_dashboard().addItem(sbe);
                }
            }
        });
    }
    {
        MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.pop.out");
        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        menuItem.addFillListener(new MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                menu.setVisible(sbe != null && sbe.canBuildStandAlone());
            }
        });
        menuItem.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null) {
                    SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
                    null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
                    SWTSkin skin = skinnedDialog.getSkin();
                    SWTSkinObjectContainer cont = sbe.buildStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"));
                    if (cont != null) {
                        skinnedDialog.setTitle(sbe.getTitle());
                        skinnedDialog.open();
                    } else {
                        skinnedDialog.close();
                    }
                }
            }
        });
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) PluginInterface(com.biglybt.pif.PluginInterface) MenuManager(com.biglybt.pif.ui.menus.MenuManager) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog)

Example 3 with MenuManager

use of com.biglybt.pif.ui.menus.MenuManager 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 4 with MenuManager

use of com.biglybt.pif.ui.menus.MenuManager in project BiglyBT by BiglySoftware.

the class MainMDISetup method setupSidebarVuzeUI.

private static void setupSidebarVuzeUI(final MultipleDocumentInterfaceSWT mdi) {
    String[] preferredOrder = new String[] { MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD, MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, MultipleDocumentInterface.SIDEBAR_HEADER_VUZE, MultipleDocumentInterface.SIDEBAR_HEADER_DISCOVERY, MultipleDocumentInterface.SIDEBAR_HEADER_DEVICES, MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS };
    mdi.setPreferredOrder(preferredOrder);
    sb_dashboard = new SB_Dashboard(mdi);
    for (int i = 0; i < preferredOrder.length; i++) {
        String id = preferredOrder[i];
        mdi.registerEntry(id, new MdiEntryCreationListener() {

            @Override
            public MdiEntry createMDiEntry(String id) {
                MdiEntry entry;
                if (id.equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
                    entry = sb_dashboard.setupMDIEntry();
                } else {
                    entry = mdi.createHeader(id, "sidebar." + id, null);
                    if (entry == null) {
                        return (null);
                    }
                    entry.setDefaultExpanded(true);
                    if (id.equals(MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS)) {
                        entry.addListener(new MdiChildCloseListener() {

                            @Override
                            public void mdiChildEntryClosed(MdiEntry parent, MdiEntry child, boolean user) {
                                if (mdi.getChildrenOf(parent.getId()).size() == 0) {
                                    parent.close(true);
                                }
                            }
                        });
                        PluginInterface pi = PluginInitializer.getDefaultInterface();
                        UIManager uim = pi.getUIManager();
                        MenuManager menuManager = uim.getMenuManager();
                        MenuItem menuItem;
                        menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS, "label.plugin.options");
                        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
                        menuItem.addListener(new MenuItemListener() {

                            @Override
                            public void selected(MenuItem menu, Object target) {
                                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                                if (uif != null) {
                                    uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, "plugins");
                                }
                            }
                        });
                    }
                }
                return entry;
            }
        });
    }
    sb_transfers = new SB_Transfers(mdi, true);
    sb_vuze = new SB_Vuze(mdi);
    new SB_Discovery(mdi);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD, false);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY, false);
    if (COConfigurationManager.getBooleanParameter("Show New In Side Bar")) {
        mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY_UNOPENED, false);
    }
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_SUBSCRIPTIONS, false);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_DEVICES, false);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, false);
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UIFunctions(com.biglybt.ui.UIFunctions) MenuManager(com.biglybt.pif.ui.menus.MenuManager) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener)

Example 5 with MenuManager

use of com.biglybt.pif.ui.menus.MenuManager in project BiglyBT by BiglySoftware.

the class BuddyPluginView method checkBetaInit.

private void checkBetaInit() {
    if (plugin.isBetaEnabled() && plugin.getBeta().isAvailable()) {
        synchronized (this) {
            if (beta_init_done) {
                return;
            }
            beta_init_done = true;
        }
        MenuManager menu_manager = plugin.getPluginInterface().getUIManager().getMenuManager();
        MenuItem chat_item = menu_manager.addMenuItem(MenuManager.MENU_DOWNLOAD_CONTEXT, "label.chat");
        chat_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        chat_item.setHeaderCategory(MenuItem.HEADER_SOCIAL);
        final MenuItem mi_chat = MenuBuildUtils.addChatMenu(menu_manager, chat_item, new MenuBuildUtils.ChatKeyResolver() {

            @Override
            public String getChatKey(Object object) {
                return (BuddyPluginUtils.getChatKey((Download) object));
            }
        });
        addBetaSubviews(true);
        beta_status = ui_instance.createStatusEntry();
        beta_status.setImageEnabled(true);
        beta_status.setVisible(true);
        updateIdleTT(false);
        Utils.execSWTThread(new AERunnable() {

            @Override
            public void runSupport() {
                ImageLoader imageLoader = ImageLoader.getInstance();
                bs_chat_gray = imageLoader.getImage("dchat_gray");
                bs_chat_gray_text = imageLoader.getImage("dchat_gray_text");
                bs_chat_green = imageLoader.getImage("dchat_green");
                bs_chat_red = imageLoader.getImage("dchat_red");
                setBetaStatus(bs_chat_gray);
                mi_chat.setGraphic(ui_instance.createGraphic(bs_chat_gray));
            }
        });
        beta_status.setListener(new UISWTStatusEntryListener() {

            @Override
            public void entryClicked(UISWTStatusEntry entry) {
                Set<ChatInstance> current_instances = menu_latest_instances;
                for (ChatInstance chat : current_instances) {
                    if (chat.getMessageOutstanding()) {
                        try {
                            openChat(chat.getClone());
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                }
            }
        });
        periodicEventMsgCheck = SimpleTimer.addPeriodicEvent("msgcheck", 30 * 1000, new TimerEventPerformer() {

            @Override
            public void perform(TimerEvent event) {
                List<ChatInstance> chats = plugin.getBeta().getChats();
                synchronized (pending_msg_map) {
                    for (ChatInstance chat : chats) {
                        if (chat.isInvisible()) {
                            continue;
                        }
                        if (!chat_uis.containsKey(chat)) {
                            if (chat.isFavourite() || chat.isAutoNotify() || chat.isInteresting()) {
                                if (!chat.isStatistics()) {
                                    ChatMessage last_msg = chat.getLastMessageRequiringAttention();
                                    if (last_msg != null) {
                                        ChatMessage last_handled = (ChatMessage) chat.getUserData(CHAT_LM_KEY);
                                        long last_msg_time = last_msg.getTimeStamp();
                                        if (last_handled == null || last_msg_time > last_handled.getTimeStamp()) {
                                            chat.setUserData(CHAT_LM_KEY, last_msg);
                                            betaMessagePending(chat, null, last_msg);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    updateIdleTT(false);
                }
            }
        });
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ChatInstance(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance) UISWTStatusEntryListener(com.biglybt.ui.swt.pif.UISWTStatusEntryListener) ChatMessage(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatMessage) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UISWTStatusEntry(com.biglybt.ui.swt.pif.UISWTStatusEntry) MenuManager(com.biglybt.pif.ui.menus.MenuManager) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) MenuBuildUtils(com.biglybt.ui.swt.MenuBuildUtils)

Aggregations

MenuManager (com.biglybt.pif.ui.menus.MenuManager)15 MenuItem (com.biglybt.pif.ui.menus.MenuItem)13 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)13 PluginInterface (com.biglybt.pif.PluginInterface)8 UIManager (com.biglybt.pif.ui.UIManager)7 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)6 UnassociatedDevice (com.biglybt.core.devices.DeviceManager.UnassociatedDevice)4 UIFunctions (com.biglybt.ui.UIFunctions)4 UPnPDevice (com.biglybt.net.upnp.UPnPDevice)3 UPnPRootDevice (com.biglybt.net.upnp.UPnPRootDevice)3 PluginManager (com.biglybt.pif.PluginManager)3 TableContextMenuItem (com.biglybt.pif.ui.tables.TableContextMenuItem)3 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 ChatInstance (com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance)2 MdiEntry (com.biglybt.ui.mdi.MdiEntry)2 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)2 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)2 SkinnedDialog (com.biglybt.ui.swt.views.skin.SkinnedDialog)2 HashSet (java.util.HashSet)2