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);
}
Aggregations