Search in sources :

Example 31 with MdiEntry

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

the class SBC_ActivityTableView method setupSidebarEntry.

public static void setupSidebarEntry(final MultipleDocumentInterface mdi) {
    // Put TitleInfo in another class
    final ViewTitleInfo titleInfoActivityView = new ViewTitleInfo() {

        boolean had_unviewed = false;

        @Override
        public Object getTitleInfoProperty(int propertyID) {
            if (propertyID == TITLE_INDICATOR_TEXT) {
                int num_unread = 0;
                int num_unviewed = 0;
                List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
                for (ActivitiesEntry entry : allEntries) {
                    if (!entry.isRead()) {
                        num_unread++;
                    }
                    if (!entry.getViewed()) {
                        num_unviewed++;
                    }
                }
                if (num_unread == 0) {
                    num_unviewed = 0;
                }
                boolean has_unviewed = num_unviewed > 0;
                if (has_unviewed != had_unviewed) {
                    if (has_unviewed) {
                        MdiEntry parent = mdi.getEntry(MultipleDocumentInterface.SIDEBAR_HEADER_VUZE);
                        if (parent != null && !parent.isExpanded()) {
                            parent.setExpanded(true);
                        }
                    }
                    had_unviewed = has_unviewed;
                }
                if (num_unviewed > 0) {
                    return (String.valueOf(num_unviewed) + (num_unread == 0 ? "" : (":" + num_unread)));
                } else if (num_unread > 0) {
                    return (String.valueOf(num_unread));
                }
                return null;
            } else if (propertyID == TITLE_IMAGEID) {
                return "image.sidebar.activity";
            } else if (propertyID == TITLE_INDICATOR_COLOR) {
                boolean has_unread = false;
                boolean has_unviewed = false;
                List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
                for (ActivitiesEntry entry : allEntries) {
                    if (!entry.isRead()) {
                        has_unread = true;
                    }
                    if (!entry.getViewed()) {
                        has_unviewed = true;
                    }
                }
                if (has_unread && has_unviewed) {
                    return (COLOR_UNVIEWED_ENTRIES);
                }
            }
            return null;
        }
    };
    activitiesListener = new ActivitiesListener() {

        @Override
        public void vuzeNewsEntryChanged(ActivitiesEntry entry) {
            refresh();
        }

        @Override
        public void vuzeNewsEntriesRemoved(ActivitiesEntry[] entries) {
            refresh();
        }

        @Override
        public void vuzeNewsEntriesAdded(ActivitiesEntry[] entries) {
            refresh();
        }

        private void refresh() {
            ViewTitleInfoManager.refreshTitleInfo(titleInfoActivityView);
            if (mdi_entry != null) {
                mdi_entry.redraw();
            }
        }
    };
    ActivitiesManager.addListener(activitiesListener);
    MdiEntryCreationListener creationListener = new MdiEntryCreationListener() {

        @Override
        public MdiEntry createMDiEntry(String id) {
            mdi_entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_VUZE, MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, "activity", "{sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES + "}", titleInfoActivityView, null, false, null);
            return (mdi_entry);
        }
    };
    mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, creationListener);
    mdi.registerEntry("activities", creationListener);
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    final MenuItem menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, "v3.activity.button.readall");
    menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItem.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
            for (ActivitiesEntry entry : allEntries) {
                entry.setRead(true);
            }
        }
    });
    mdi.addListener(new MdiListener() {

        @Override
        public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
        }

        @Override
        public void mdiDisposed(MultipleDocumentInterface mdi) {
            if (activitiesListener != null) {
                ActivitiesManager.removeListener(activitiesListener);
                activitiesListener = null;
            }
            menuItem.remove();
        }
    });
}
Also used : ActivitiesListener(com.biglybt.activities.ActivitiesListener) MdiListener(com.biglybt.ui.mdi.MdiListener) MdiEntryCreationListener(com.biglybt.ui.mdi.MdiEntryCreationListener) PluginInterface(com.biglybt.pif.PluginInterface) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MenuManager(com.biglybt.pif.ui.menus.MenuManager) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) ArrayList(java.util.ArrayList) List(java.util.List) ViewTitleInfo(com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)

Example 32 with MdiEntry

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

the class SBC_GenericBrowsePage method skinObjectInitialShow.

@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    Object creationParams = skinObject.getData("CreationParams");
    browserSkinObject = SWTSkinUtils.findBrowserSO(soMain);
    final MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi != null) {
        entry = mdi.getEntryBySkinView(this);
        if (entry != null) {
            vitalityImage = entry.addVitalityImage("image.sidebar.vitality.dots");
            vitalityImage.setVisible(false);
            mdi.addListener(new MdiListener() {

                long lastSelect = 0;

                @Override
                public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
                    if (entry == newEntry) {
                        if (entry == oldEntry) {
                            if (lastSelect < SystemTime.getOffsetTime(-1000)) {
                                if (browserSkinObject != null) {
                                    browserSkinObject.restart();
                                }
                            }
                        } else {
                            lastSelect = SystemTime.getCurrentTime();
                        }
                    }
                }

                @Override
                public void mdiDisposed(MultipleDocumentInterface mdi) {
                }
            });
        }
    }
    browserSkinObject.addListener(new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == EVENT_SHOW) {
                browserSkinObject.removeListener(this);
                browserSkinObject.addListener(new BrowserContext.loadingListener() {

                    @Override
                    public void browserLoadingChanged(boolean loading, String url) {
                        if (vitalityImage != null) {
                            vitalityImage.setVisible(loading);
                        }
                    }
                });
            } else if (eventType == EVENT_DATASOURCE_CHANGED) {
                if (params instanceof String) {
                    browserSkinObject.setURL((String) params);
                }
            }
            return null;
        }
    });
    openURL();
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MdiListener(com.biglybt.ui.mdi.MdiListener) MdiEntry(com.biglybt.ui.mdi.MdiEntry) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 33 with MdiEntry

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

the class DevicesFTUX method _doInstall.

protected void _doInstall(Core core, boolean itunes) {
    List<InstallablePlugin> plugins = new ArrayList<>(2);
    final PluginInstaller installer = core.getPluginManager().getPluginInstaller();
    StandardPlugin vuze_plugin = null;
    try {
        vuze_plugin = installer.getStandardPlugin("vuzexcode");
    } catch (Throwable ignored) {
    }
    if (vuze_plugin != null && !vuze_plugin.isAlreadyInstalled()) {
        plugins.add(vuze_plugin);
    }
    if (itunes) {
        StandardPlugin itunes_plugin = null;
        try {
            itunes_plugin = installer.getStandardPlugin("azitunes");
        } catch (Throwable ignored) {
        }
        if (itunes_plugin != null && !itunes_plugin.isAlreadyInstalled()) {
            plugins.add(itunes_plugin);
        }
    }
    if (plugins.size() == 0) {
        close();
        return;
    }
    InstallablePlugin[] installablePlugins = plugins.toArray(new InstallablePlugin[0]);
    try {
        install_area_parent.setVisible(true);
        install_area_parent.moveAbove(null);
        Map<Integer, Object> properties = new HashMap<>();
        properties.put(UpdateCheckInstance.PT_UI_STYLE, UpdateCheckInstance.PT_UI_STYLE_SIMPLE);
        properties.put(UpdateCheckInstance.PT_UI_PARENT_SWT_COMPOSITE, install_area);
        properties.put(UpdateCheckInstance.PT_UI_DISABLE_ON_SUCCESS_SLIDEY, true);
        installer.install(installablePlugins, false, properties, new PluginInstallationListener() {

            @Override
            public void completed() {
                close();
                MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                MdiEntry entry = mdi.getEntry(SideBar.SIDEBAR_HEADER_DEVICES);
                List<? extends MdiEntryVitalityImage> vitalityImages = entry.getVitalityImages();
                for (MdiEntryVitalityImage vi : vitalityImages) {
                    if (vi.getImageID().contains("turnon")) {
                        vi.setVisible(false);
                    }
                }
                List<Runnable> to_fire;
                synchronized (to_fire_on_complete) {
                    to_fire = new ArrayList<>(to_fire_on_complete);
                    to_fire_on_complete.clear();
                }
                for (Runnable r : to_fire) {
                    if (r != null) {
                        try {
                            Utils.execSWTThread(r);
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                }
            }

            @Override
            public void cancelled() {
                close();
            }

            @Override
            public void failed(PluginException e) {
                Debug.out(e);
                // Utils.openMessageBox(Utils.findAnyShell(), SWT.OK, "Error",
                // e.toString());
                close();
            }
        });
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
}
Also used : HashMap(java.util.HashMap) PluginException(com.biglybt.pif.PluginException) ArrayList(java.util.ArrayList) StandardPlugin(com.biglybt.pif.installer.StandardPlugin) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) InstallablePlugin(com.biglybt.pif.installer.InstallablePlugin) PluginInstaller(com.biglybt.pif.installer.PluginInstaller) PluginInstallationListener(com.biglybt.pif.installer.PluginInstallationListener) MdiEntry(com.biglybt.ui.mdi.MdiEntry) AERunnable(com.biglybt.core.util.AERunnable) ArrayList(java.util.ArrayList) List(java.util.List) MdiEntryVitalityImage(com.biglybt.ui.mdi.MdiEntryVitalityImage)

Example 34 with MdiEntry

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

the class MenuFactory method addCloseTabMenuItem.

public static MenuItem addCloseTabMenuItem(Menu menu) {
    final MenuItem menuItem = addMenuItem(menu, MENU_ID_CLOSE_TAB, new Listener() {

        @Override
        public void handleEvent(Event event) {
            MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
            if (mdi != null) {
                MdiEntry currentEntry = mdi.getCurrentEntry();
                if (currentEntry != null && currentEntry.isCloseable()) {
                    mdi.closeEntry(currentEntry, true);
                }
            }
        }
    });
    menu.addMenuListener(new MenuListener() {

        @Override
        public void menuShown(MenuEvent e) {
            MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
            if (mdi != null) {
                MdiEntry currentEntry = mdi.getCurrentEntry();
                if (currentEntry != null && currentEntry.isCloseable()) {
                    menuItem.setEnabled(true);
                    return;
                }
            }
            menuItem.setEnabled(false);
        }

        @Override
        public void menuHidden(MenuEvent e) {
        }
    });
    return menuItem;
}
Also used : UpdateCheckInstanceListener(com.biglybt.pif.update.UpdateCheckInstanceListener) ParameterListener(com.biglybt.core.config.ParameterListener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 35 with MdiEntry

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

the class TabbedMDI method showEntry.

@Override
public void showEntry(final MdiEntry _newEntry) {
    if (_newEntry == null) {
        return;
    }
    TabbedEntry newEntry = (TabbedEntry) _newEntry;
    select_history.remove(newEntry);
    select_history.add(newEntry);
    if (select_history.size() > 64) {
        select_history.removeFirst();
    }
    MdiEntry oldEntry = getCurrentEntry();
    if (newEntry == oldEntry && oldEntry != null) {
        ((BaseMdiEntry) newEntry).show();
        triggerSelectionListener(newEntry, newEntry);
        return;
    }
    if (oldEntry != null) {
        oldEntry.hide();
    }
    setCurrentEntry((MdiEntrySWT) newEntry);
    if (newEntry instanceof BaseMdiEntry) {
        ((BaseMdiEntry) newEntry).show();
    }
    triggerSelectionListener(newEntry, oldEntry);
}
Also used : MdiEntry(com.biglybt.ui.mdi.MdiEntry)

Aggregations

MdiEntry (com.biglybt.ui.mdi.MdiEntry)41 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)13 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)11 MenuItem (com.biglybt.pif.ui.menus.MenuItem)4 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)4 MdiCloseListener (com.biglybt.ui.mdi.MdiCloseListener)4 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)4 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)4 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)4 ParameterListener (com.biglybt.core.config.ParameterListener)3 DownloadManager (com.biglybt.core.download.DownloadManager)3 PluginInterface (com.biglybt.pif.PluginInterface)3 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)3 UIFunctions (com.biglybt.ui.UIFunctions)3 DownloadManagerPeerListener (com.biglybt.core.download.DownloadManagerPeerListener)2 PEPeer (com.biglybt.core.peer.PEPeer)2 PEPeerStats (com.biglybt.core.peer.PEPeerStats)2 UIManager (com.biglybt.pif.ui.UIManager)2 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)2 MenuManager (com.biglybt.pif.ui.menus.MenuManager)2