Search in sources :

Example 1 with SWTViewListener

use of com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.SWTViewListener 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

UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)1 UISWTInstanceImpl (com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl)1 SWTViewListener (com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.SWTViewListener)1 UISWTViewCore (com.biglybt.ui.swt.pifimpl.UISWTViewCore)1 UISWTViewEventListenerHolder (com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)1 UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)1