Search in sources :

Example 21 with MdiEntry

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

the class ChatMDIEntry method setupMdiEntry.

private void setupMdiEntry() {
    mdi_entry.setViewTitleInfo(this);
    MdiEntryDropListener drop_listener = new MdiEntryDropListener() {

        @Override
        public boolean mdiEntryDrop(MdiEntry entry, Object payload) {
            if (payload instanceof String[]) {
                String[] derp = (String[]) payload;
                if (derp.length > 0) {
                    payload = derp[0];
                }
            }
            if (!(payload instanceof String)) {
                return false;
            }
            MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
            if (mdi != null) {
                String drop = (String) payload;
                if (view == null) {
                    drop_outstanding = drop;
                } else {
                    view.handleDrop(drop);
                }
                mdi.showEntry(mdi_entry);
                return (true);
            } else {
                return (false);
            }
        }
    };
    mdi_entry.addListener(drop_listener);
    mdi_entry.addListener(new MdiCloseListener() {

        @Override
        public void mdiEntryClosed(MdiEntry entry, boolean user) {
            chat.removeListener(adapter);
            chat.destroy();
        }
    });
    /*
		UIManager ui_manager = PluginInitializer.getDefaultInterface().getUIManager();
		
		MenuManager menu_manager = ui_manager.getMenuManager();

		MenuItem menu_item;

		menu_item = menu_manager.addMenuItem( "sidebar." + mdi_entry.getId(), "dasd.ad.ad." );
		menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
		menu_item.addListener(
				new MenuItemListener() 
				{
					@Override
					public void
					selected(
						MenuItem menu, Object target ) 
					{
				      	
					}
				});
		*/
    mdi_entry.setImageLeftID("image.sidebar.chat-overview");
    chat.addListener(adapter);
}
Also used : MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) MdiCloseListener(com.biglybt.ui.mdi.MdiCloseListener) MdiEntryDropListener(com.biglybt.ui.mdi.MdiEntryDropListener)

Example 22 with MdiEntry

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

the class SBC_ChatOverview method createChatMdiEntry.

private static MdiEntry createChatMdiEntry(final ChatInstance chat) {
    MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi == null) {
        return (null);
    }
    try {
        String key = "Chat_" + chat.getNetwork() + ":" + Base32.encode(chat.getKey().getBytes("UTF-8"));
        MdiEntry existing = mdi.getEntry(key);
        if (existing != null) {
            chat.destroy();
            return (existing);
        }
        BuddyPluginBeta bp = BuddyPluginUtils.getBetaPlugin();
        TreeMap<ChatInstance, String> name_map = new TreeMap<>(new Comparator<ChatInstance>() {

            @Override
            public int compare(ChatInstance o1, ChatInstance o2) {
                return (o1.getName().compareTo(o2.getName()));
            }
        });
        name_map.put(chat, key);
        List<ChatInstance> all_chats = bp.getChats();
        for (ChatInstance c : all_chats) {
            try {
                String k = "Chat_" + c.getNetwork() + ":" + Base32.encode(c.getKey().getBytes("UTF-8"));
                if (mdi.getEntry(k) != null) {
                    name_map.put(c, k);
                }
            } catch (Throwable e) {
            }
        }
        String prev_id = null;
        for (String this_id : name_map.values()) {
            if (this_id == key) {
                break;
            }
            prev_id = this_id;
        }
        if (prev_id == null && name_map.size() > 1) {
            Iterator<String> it = name_map.values().iterator();
            it.next();
            prev_id = "~" + it.next();
        }
        MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT, new UISWTViewEventListenerHolder(key, ChatView.class, chat, null), key, true, chat, prev_id);
        ChatMDIEntry entry_info = new ChatMDIEntry(chat, entry);
        chat.setUserData(MDI_KEY, entry_info);
        entry.addListener(new MdiCloseListener() {

            @Override
            public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
                chat.setUserData(MDI_KEY, null);
            }
        });
        return (entry);
    } catch (Throwable e) {
        Debug.out(e);
        return (null);
    }
}
Also used : TreeMap(java.util.TreeMap) UISWTViewEventListenerHolder(com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) BuddyPluginBeta(com.biglybt.plugin.net.buddy.BuddyPluginBeta) MdiCloseListener(com.biglybt.ui.mdi.MdiCloseListener)

Example 23 with MdiEntry

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

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

the class UIFunctionsImpl method openPluginView.

// @see UIFunctionsSWT#openPluginView(java.lang.String, java.lang.String, com.biglybt.ui.swt.pif.UISWTViewEventListener, java.lang.Object, boolean)
@Override
public void openPluginView(String sParentID, String sViewID, UISWTViewEventListener l, Object dataSource, boolean bSetFocus) {
    try {
        MultipleDocumentInterfaceSWT mdi = getMDISWT();
        if (mdi != null) {
            String sidebarParentID = null;
            if (UISWTInstance.VIEW_MYTORRENTS.equals(sParentID)) {
                sidebarParentID = SideBar.SIDEBAR_HEADER_TRANSFERS;
            } else if (UISWTInstance.VIEW_MAIN.equals(sParentID)) {
                sidebarParentID = MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS;
            } else {
                System.err.println("Can't find parent " + sParentID + " for " + sViewID);
            }
            MdiEntry entry = mdi.createEntryFromEventListener(sidebarParentID, l, sViewID, true, dataSource, null);
            if (bSetFocus) {
                mdi.showEntryByID(sViewID);
            } else if (entry instanceof BaseMdiEntry) {
                // Some plugins (CVS Updater) want their view's composite initialized
                // on OpenPluginView, otherwise they won't do logic users expect
                // (like check for new snapshots).  So, enforce loading entry.
                ((BaseMdiEntry) entry).build();
            }
        }
    } catch (Exception e) {
        Logger.log(new LogEvent(LOGID, "openPluginView", e));
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)

Example 25 with MdiEntry

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

the class TableViewSWT_TabsCommon method removeTabView.

private void removeTabView(String id) {
    boolean exists = tabbedMDI.entryExists(id);
    if (!exists) {
        return;
    }
    MdiEntry entry = tabbedMDI.getEntry(id);
    // XXX
    // removedViews.add(((MdiEntrySWT) entry).getEventListener());
    tabbedMDI.removeItem(entry);
}
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