Search in sources :

Example 6 with UISWTViewEventListenerHolder

use of com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder in project BiglyBT by BiglySoftware.

the class SideBar method createSideBarPluginViews.

private void createSideBarPluginViews() {
    if (cPluginsArea == null) {
        return;
    }
    UISWTInstanceImpl uiSWTinstance = (UISWTInstanceImpl) UIFunctionsManagerSWT.getUIFunctionsSWT().getUISWTInstance();
    if (uiSWTinstance == null) {
        return;
    }
    UISWTViewEventListenerHolder[] pluginViews = uiSWTinstance.getViewListeners(UISWTInstance.VIEW_SIDEBAR_AREA);
    for (UISWTViewEventListenerHolder l : pluginViews) {
        if (l != null) {
            try {
                UISWTViewImpl view = new UISWTViewImpl(l.getViewID(), UISWTInstance.VIEW_SIDEBAR_AREA, false);
                view.setEventListener(l, true);
                addSideBarView(view, cPluginsArea);
                cPluginsArea.getParent().getParent().layout(true, true);
            } catch (Exception e) {
                e.printStackTrace();
            // skip, plugin probably specifically asked to not be added
            }
        }
    }
    swtViewListener = new SWTViewListener() {

        @Override
        public void setViewAdded(final String parent, final String id, final UISWTViewEventListener l) {
            if (!parent.equals(UISWTInstance.VIEW_SIDEBAR_AREA)) {
                return;
            }
            Utils.execSWTThread(new AERunnable() {

                @Override
                public void runSupport() {
                    try {
                        UISWTViewImpl view = new UISWTViewImpl(id, parent, false);
                        view.setEventListener(l, true);
                        addSideBarView(view, cPluginsArea);
                    } catch (Exception e) {
                        e.printStackTrace();
                    // skip, plugin probably specifically asked to not be added
                    }
                }
            });
        }

        @Override
        public void setViewRemoved(final String parent, final String id, final UISWTViewEventListener l) {
            if (!parent.equals(UISWTInstance.VIEW_SIDEBAR_AREA)) {
                return;
            }
            Utils.execSWTThread(new AERunnable() {

                @Override
                public void runSupport() {
                    try {
                        for (UISWTViewCore view : SideBar.this.pluginViews) {
                            if (l.equals(view.getEventListener())) {
                                view.closeView();
                            } else {
                                if (l instanceof UISWTViewEventListenerHolder) {
                                    UISWTViewEventListener l2 = ((UISWTViewEventListenerHolder) l).getDelegatedEventListener(view);
                                    if (l2 != null && l2.equals(view.getEventListener())) {
                                        view.closeView();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    // skip, plugin probably specifically asked to not be added
                    }
                }
            });
        }
    };
    uiSWTinstance.addSWTViewListener(swtViewListener);
    cPluginsArea.getParent().getParent().layout(true, true);
}
Also used : UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore) UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) SWTViewListener(com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.SWTViewListener) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) UISWTViewEventListenerHolder(com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder) UISWTInstanceImpl(com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl)

Aggregations

UISWTViewEventListenerHolder (com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)6 MdiEntry (com.biglybt.ui.mdi.MdiEntry)3 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)3 UIFunctions (com.biglybt.ui.UIFunctions)2 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)2 UISWTViewCore (com.biglybt.ui.swt.pifimpl.UISWTViewCore)2 DownloadManager (com.biglybt.core.download.DownloadManager)1 DownloadManagerPeerListener (com.biglybt.core.download.DownloadManagerPeerListener)1 PEPeer (com.biglybt.core.peer.PEPeer)1 PEPeerStats (com.biglybt.core.peer.PEPeerStats)1 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 MenuItem (com.biglybt.pif.ui.menus.MenuItem)1 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)1 MenuManager (com.biglybt.pif.ui.menus.MenuManager)1 FormattersImpl (com.biglybt.pifimpl.local.utils.FormattersImpl)1 BuddyPluginBeta (com.biglybt.plugin.net.buddy.BuddyPluginBeta)1 MdiCloseListener (com.biglybt.ui.mdi.MdiCloseListener)1 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)1 UISWTInstanceImpl (com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl)1 SWTViewListener (com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.SWTViewListener)1