Search in sources :

Example 16 with MultipleDocumentInterface

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

the class SBC_ChatOverview method fillMenu.

@Override
public void fillMenu(String sColumnName, Menu menu) {
    List<Object> ds = tv.getSelectedDataSources();
    final List<ChatInstance> chats = new ArrayList<>();
    for (Object obj : ds) {
        if (obj instanceof ChatInstance) {
            chats.add((ChatInstance) obj);
        }
    }
    // show in sidebar
    MenuItem itemSiS = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(itemSiS, Utils.isAZ2UI() ? "label.show.in.tab" : "label.show.in.sidebar");
    itemSiS.setEnabled(chats.size() > 0);
    itemSiS.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            MdiEntry first_entry = null;
            for (ChatInstance chat : chats) {
                try {
                    MdiEntry entry = createChatMdiEntry(chat.getClone());
                    if (first_entry == null) {
                        first_entry = entry;
                    }
                } catch (Throwable e) {
                    Debug.out(e);
                }
            }
            if (first_entry != null) {
                MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                if (mdi != null) {
                    mdi.showEntry(first_entry);
                }
            }
        }
    });
    MenuItem itemRemove = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(itemRemove, "MySharesView.menu.remove");
    Utils.setMenuItemImage(itemRemove, "delete");
    itemRemove.setEnabled(chats.size() > 0);
    itemRemove.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            for (ChatInstance chat : chats) {
                chat.remove();
            }
        }
    });
    new MenuItem(menu, SWT.SEPARATOR);
}
Also used : TableSelectionListener(com.biglybt.ui.common.table.TableSelectionListener) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) MdiCloseListener(com.biglybt.ui.mdi.MdiCloseListener) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) Listener(org.eclipse.swt.widgets.Listener) MdiEntry(com.biglybt.ui.mdi.MdiEntry) ArrayList(java.util.ArrayList) KeyEvent(org.eclipse.swt.events.KeyEvent) Event(org.eclipse.swt.widgets.Event) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MenuItem(org.eclipse.swt.widgets.MenuItem) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 17 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface 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)

Example 18 with MultipleDocumentInterface

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

the class MainWindowImpl method getUsageActiveTabID.

private String getUsageActiveTabID() {
    try {
        MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
        if (mdi != null) {
            MdiEntry curEntry = mdi.getCurrentEntry();
            if (curEntry == null) {
                return "none";
            }
            String id = curEntry.getLogID();
            return id == null ? "null" : id;
        }
    } catch (Exception e) {
        String name = e.getClass().getName();
        int i = name.indexOf('.');
        if (i > 0) {
            return name.substring(i);
        }
        return name;
    }
    return "unknown";
}
Also used : MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 19 with MultipleDocumentInterface

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

the class MainWindowImpl method mdiEntrySelected.

// @see MdiListener#mdiEntrySelected(MdiEntry, MdiEntry)
@Override
public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
    if (newEntry == null) {
        return;
    }
    if (mapTrackUsage != null && oldEntry != null) {
        oldEntry.removeListener(this);
        String id2 = null;
        MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
        if (mdi != null) {
            id2 = oldEntry.getLogID();
        }
        if (id2 == null) {
            id2 = oldEntry.getId();
        }
        updateMapTrackUsage(id2);
    }
    if (mapTrackUsage != null) {
        newEntry.addListener(this);
    }
}
Also used : MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 20 with MultipleDocumentInterface

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

the class MainMenuV3 method addV3HelpMenu.

/**
 * Creates the Help menu and all its children
 */
private void addV3HelpMenu() {
    MenuItem helpItem = MenuFactory.createHelpMenuItem(menuBar);
    Menu helpMenu = helpItem.getMenu();
    if (!Constants.isOSX) {
        /*
			 * The 'About' menu is on the application menu on OSX
			 */
        MenuFactory.addAboutMenuItem(helpMenu);
        MenuFactory.addSeparatorMenuItem(helpMenu);
    }
    MenuFactory.addMenuItem(helpMenu, PREFIX_V3 + ".getting_started", new Listener() {

        @Override
        public void handleEvent(Event event) {
            MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
            if (mdi != null) {
                mdi.showEntryByID(SideBar.SIDEBAR_SECTION_WELCOME);
            }
        }
    });
    MenuFactory.addReleaseNotesMenuItem(helpMenu);
    if (!SystemProperties.isJavaWebStartInstance()) {
        MenuFactory.addSeparatorMenuItem(helpMenu);
        MenuFactory.addCheckUpdateMenuItem(helpMenu);
        MenuFactory.addBetaMenuItem(helpMenu);
    }
    MenuFactory.addDonationMenuItem(helpMenu);
    MenuFactory.addSeparatorMenuItem(helpMenu);
    MenuFactory.addConfigWizardMenuItem(helpMenu);
    MenuFactory.addNatTestMenuItem(helpMenu);
    MenuFactory.addNetStatusMenuItem(helpMenu);
    MenuFactory.addSpeedTestMenuItem(helpMenu);
    MenuFactory.addAdvancedHelpMenuItem(helpMenu);
    MenuFactory.addSeparatorMenuItem(helpMenu);
    MenuFactory.addDebugHelpMenuItem(helpMenu);
}
Also used : ParameterListener(com.biglybt.core.config.ParameterListener) UIToolBarActivationListener(com.biglybt.pif.ui.toolbar.UIToolBarActivationListener) IMainMenu(com.biglybt.ui.swt.mainwindow.IMainMenu) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

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