Search in sources :

Example 6 with MultipleDocumentInterface

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

the class UIFunctionsImpl method hasDetailViews.

// @see UIFunctionsSWT#hasDetailViews()
@Override
public boolean hasDetailViews() {
    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
    if (mdi == null) {
        return false;
    }
    MdiEntry[] sideBarEntries = mdi.getEntries();
    for (int i = 0; i < sideBarEntries.length; i++) {
        MdiEntry entry = sideBarEntries[i];
        String id = entry.getId();
        if (id != null && id.startsWith("DMDetails_")) {
            return true;
        }
    }
    return false;
}
Also used : BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Point(org.eclipse.swt.graphics.Point)

Example 7 with MultipleDocumentInterface

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

the class UIFunctionsImpl method closeAllDetails.

// @see UIFunctionsSWT#closeAllDetails()
@Override
public void closeAllDetails() {
    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
    if (mdi == null) {
        return;
    }
    MdiEntry[] sideBarEntries = mdi.getEntries();
    for (int i = 0; i < sideBarEntries.length; i++) {
        MdiEntry entry = sideBarEntries[i];
        String id = entry.getId();
        if (id != null && id.startsWith("DMDetails_")) {
            mdi.closeEntry(id);
        }
    }
}
Also used : BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Point(org.eclipse.swt.graphics.Point)

Example 8 with MultipleDocumentInterface

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

the class UIFunctionsImpl method closePluginView.

/* (non-Javadoc)
	 * @see UIFunctionsSWT#closePluginView(com.biglybt.ui.swt.pifimpl.UISWTViewCore)
	 */
@Override
public void closePluginView(UISWTViewCore view) {
    try {
        MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
        if (mdi == null) {
            return;
        }
        String id;
        if (view instanceof UISWTViewImpl) {
            id = ((UISWTViewImpl) view).getViewID();
        } else {
            id = view.getClass().getName();
            int i = id.lastIndexOf('.');
            if (i > 0) {
                id = id.substring(i + 1);
            }
        }
        mdi.closeEntry(id);
    } catch (Exception e) {
        Logger.log(new LogEvent(LOGID, "closePluginView", e));
    }
}
Also used : UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) LogEvent(com.biglybt.core.logging.LogEvent) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Point(org.eclipse.swt.graphics.Point)

Example 9 with MultipleDocumentInterface

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

the class UIFunctionsImpl method showURL.

/**
 * @param url
 * @param target
 */
private void showURL(final String url, String target) {
    if ("_blank".equalsIgnoreCase(target)) {
        Utils.launch(url);
        return;
    }
    if (target.startsWith("tab-")) {
        target = target.substring(4);
    }
    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
    // by the caller
    if (mdi == null || !mdi.showEntryByID(target)) {
        Utils.launch(url);
        return;
    }
    MdiEntry entry = mdi.getEntry(target);
    entry.addListener(new MdiEntryOpenListener() {

        @Override
        public void mdiEntryOpen(MdiEntry entry) {
            entry.removeListener(this);
            mainWindow.setVisible(true, true);
            if (!(entry instanceof SideBarEntrySWT)) {
                return;
            }
            SideBarEntrySWT entrySWT = (SideBarEntrySWT) entry;
            SWTSkinObjectBrowser soBrowser = SWTSkinUtils.findBrowserSO(entrySWT.getSkinObject());
            if (soBrowser != null) {
                // ((SWTSkinObjectBrowser) skinObject).getBrowser().setVisible(false);
                if (url == null || url.length() == 0) {
                    soBrowser.restart();
                } else {
                    soBrowser.setURL(url);
                }
            }
        }
    });
}
Also used : MdiEntryOpenListener(com.biglybt.ui.mdi.MdiEntryOpenListener) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) SideBarEntrySWT(com.biglybt.ui.swt.views.skin.sidebar.SideBarEntrySWT) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 10 with MultipleDocumentInterface

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

the class MainMenuV3 method buildSimpleViewMenu.

/**
 * @param viewMenu
 *
 * @since 4.5.0.3
 */
private void buildSimpleViewMenu(final Menu viewMenu, int accelerator) {
    try {
        MenuFactory.addMenuItem(viewMenu, SWT.CHECK, PREFIX_V3 + ".view.sidebar", new Listener() {

            @Override
            public void handleEvent(Event event) {
                SideBar sidebar = (SideBar) SkinViewManager.getByClass(SideBar.class);
                if (sidebar != null) {
                    sidebar.flipSideBarVisibility();
                }
            }
        });
        if (COConfigurationManager.getIntParameter("User Mode") > 1) {
            SWTSkin skin = SWTSkinFactory.getInstance();
            SWTSkinObject plugin_bar = skin.getSkinObject(SkinConstants.VIEWID_PLUGINBAR);
            if (plugin_bar != null) {
                MenuItem mi = MainMenuV3.createViewMenuItem(skin, viewMenu, "v3.MainWindow.menu.view." + SkinConstants.VIEWID_PLUGINBAR, SkinConstants.VIEWID_PLUGINBAR + ".visible", SkinConstants.VIEWID_PLUGINBAR, true, -1);
                if (accelerator != -1 && mi.getAccelerator() == accelerator) {
                    Listener[] listeners = mi.getListeners(SWT.Selection);
                    for (Listener l : listeners) {
                        try {
                            l.handleEvent(null);
                        } catch (Throwable e) {
                        }
                    }
                }
            }
        }
        MenuFactory.addViewToolbarMenuItem(viewMenu);
        // ///////
        MenuItem itemStatusBar = MenuFactory.createTopLevelMenuItem(viewMenu, "v3.MainWindow.menu.view.statusbar");
        itemStatusBar.setText(itemStatusBar.getText());
        Menu menuStatusBar = itemStatusBar.getMenu();
        final String[] statusAreaLangs = { "ConfigView.section.style.status.show_sr", "ConfigView.section.style.status.show_nat", "ConfigView.section.style.status.show_ddb", "ConfigView.section.style.status.show_ipf" };
        final String[] statusAreaConfig = { "Status Area Show SR", "Status Area Show NAT", "Status Area Show DDB", "Status Area Show IPF" };
        for (int i = 0; i < statusAreaConfig.length; i++) {
            final String configID = statusAreaConfig[i];
            String langID = statusAreaLangs[i];
            final MenuItem item = new MenuItem(menuStatusBar, SWT.CHECK);
            Messages.setLanguageText(item, langID);
            item.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    COConfigurationManager.setParameter(configID, !COConfigurationManager.getBooleanParameter(configID));
                }
            });
            menuStatusBar.addListener(SWT.Show, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    item.setSelection(COConfigurationManager.getBooleanParameter(configID));
                }
            });
        }
        if (Constants.isWindows) {
            MenuFactory.addSeparatorMenuItem(viewMenu);
        }
        boolean needsSep = false;
        boolean enabled = COConfigurationManager.getBooleanParameter("Beta Programme Enabled");
        if (enabled) {
            MenuFactory.addMenuItem(viewMenu, SWT.CHECK, PREFIX_V2 + ".view.beta", new Listener() {

                @Override
                public void handleEvent(Event event) {
                    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                    if (mdi != null) {
                        mdi.showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_BETAPROGRAM);
                    }
                }
            });
            needsSep = true;
        }
        if (needsSep) {
            MenuFactory.addSeparatorMenuItem(viewMenu);
        }
        needsSep = PluginsMenuHelper.getInstance().buildViewMenu(viewMenu, viewMenu.getShell());
        if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
            if (needsSep) {
                MenuFactory.addSeparatorMenuItem(viewMenu);
            }
            // Ubuntu Unity (14.04) with SWT 4508 crashes when global View menu triggered as it appears
            // that radio menu items aren't supported
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=419729#c9
            int simple_advanced_menu_type = Constants.isLinux ? SWT.CHECK : SWT.RADIO;
            MenuFactory.addMenuItem(viewMenu, simple_advanced_menu_type, PREFIX_V3 + ".view.asSimpleList", new Listener() {

                @Override
                public void handleEvent(Event event) {
                    UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                    if (tb != null) {
                        UIToolBarItem item = tb.getToolBarItem("modeBig");
                        if (item != null) {
                            item.triggerToolBarItem(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, SelectedContentManager.convertSelectedContentToObject(null));
                        }
                    }
                }
            });
            MenuFactory.addMenuItem(viewMenu, simple_advanced_menu_type, PREFIX_V3 + ".view.asAdvancedList", new Listener() {

                @Override
                public void handleEvent(Event event) {
                    UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                    if (tb != null) {
                        UIToolBarItem item = tb.getToolBarItem("modeSmall");
                        if (item != null) {
                            item.triggerToolBarItem(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, SelectedContentManager.convertSelectedContentToObject(null));
                        }
                    }
                }
            });
        }
        viewMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuShown(MenuEvent e) {
                MenuItem sidebarMenuItem = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.sidebar");
                if (sidebarMenuItem != null) {
                    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                    if (mdi != null) {
                        sidebarMenuItem.setSelection(mdi.isVisible());
                    }
                }
                if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
                    MenuItem itemShowAsSimple = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.asSimpleList");
                    if (itemShowAsSimple != null) {
                        UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                        if (tb != null) {
                            UIToolBarItem item = tb.getToolBarItem("modeBig");
                            long state = item == null ? 0 : item.getState();
                            itemShowAsSimple.setEnabled((state & UIToolBarItem.STATE_ENABLED) > 0);
                            itemShowAsSimple.setSelection((state & UIToolBarItem.STATE_DOWN) > 0);
                        }
                    }
                    MenuItem itemShowAsAdv = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.asAdvancedList");
                    if (itemShowAsAdv != null) {
                        UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                        if (tb != null) {
                            UIToolBarItem item = tb.getToolBarItem("modeSmall");
                            long state = item == null ? 0 : item.getState();
                            itemShowAsAdv.setEnabled((state & UIToolBarItem.STATE_ENABLED) > 0);
                            itemShowAsAdv.setSelection((state & UIToolBarItem.STATE_DOWN) > 0);
                        }
                    }
                }
            }

            @Override
            public void menuHidden(MenuEvent e) {
            }
        });
    } catch (Exception e) {
        Debug.out("Error creating View Menu", e);
    }
}
Also used : ParameterListener(com.biglybt.core.config.ParameterListener) UIToolBarActivationListener(com.biglybt.pif.ui.toolbar.UIToolBarActivationListener) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) UIException(com.biglybt.pif.ui.UIException) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIToolBarManager(com.biglybt.pif.ui.toolbar.UIToolBarManager) IMainMenu(com.biglybt.ui.swt.mainwindow.IMainMenu) UIToolBarItem(com.biglybt.pif.ui.toolbar.UIToolBarItem) SideBar(com.biglybt.ui.swt.views.skin.sidebar.SideBar)

Aggregations

MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)27 MdiEntry (com.biglybt.ui.mdi.MdiEntry)15 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)6 PluginInterface (com.biglybt.pif.PluginInterface)5 Point (org.eclipse.swt.graphics.Point)5 ParameterListener (com.biglybt.core.config.ParameterListener)4 UIManager (com.biglybt.pif.ui.UIManager)4 MdiListener (com.biglybt.ui.mdi.MdiListener)4 ArrayList (java.util.ArrayList)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)3 Subscription (com.biglybt.core.subs.Subscription)3 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)3 GlobalManager (com.biglybt.core.global.GlobalManager)2 LogEvent (com.biglybt.core.logging.LogEvent)2 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)2 UIFunctions (com.biglybt.ui.UIFunctions)2