use of com.biglybt.ui.mdi.MdiEntryCreationListener2 in project BiglyBT by BiglySoftware.
the class TableViewSWT_TabsCommon method buildFolder.
private void buildFolder(final Composite form, final String props_prefix) {
PluginInterface pi = PluginInitializer.getDefaultInterface();
UIManager uim = pi.getUIManager();
MenuManager menuManager = uim.getMenuManager();
menuItemShowTabs = menuManager.addMenuItem(props_prefix + "._end_", "ConfigView.section.style.ShowTabsInTorrentView");
menuItemShowTabs.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItemShowTabs.setStyle(MenuItem.STYLE_CHECK);
menuItemShowTabs.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.setData(COConfigurationManager.getBooleanParameter("Library.ShowTabsInTorrentView"));
}
});
menuItemShowTabs.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
COConfigurationManager.setParameter("Library.ShowTabsInTorrentView", (Boolean) menu.getData());
}
});
cTabsHolder.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event e) {
if (tabbedMDI.getMinimized()) {
fdHeightChanger.height = tabbedMDI.getFolderHeight();
cTabsHolder.getParent().layout();
return;
}
Double l = (Double) sash.getData("PCT");
if (l != null) {
int newHeight = (int) (form.getBounds().height * l.doubleValue());
if (newHeight != fdHeightChanger.height) {
fdHeightChanger.height = newHeight;
cTabsHolder.getParent().layout();
}
}
}
});
String[] restricted_to = tv.getTabViewsRestrictedTo();
Set<String> rt_set = new HashSet<>();
if (restricted_to != null) {
rt_set.addAll(Arrays.asList(restricted_to));
}
// Call plugin listeners
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
if (pluginUI != null) {
UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(tv.getTableID());
if (pluginViews != null) {
for (final UISWTViewEventListenerWrapper l : pluginViews) {
if (l == null) {
continue;
}
try {
String view_id = l.getViewID();
if (restricted_to != null && !rt_set.contains(view_id)) {
continue;
}
tabbedMDI.registerEntry(view_id, new MdiEntryCreationListener2() {
@Override
public MdiEntry createMDiEntry(MultipleDocumentInterface mdi, String id, Object datasource, Map<?, ?> params) {
return addTabView(l, null);
}
});
tabbedMDI.loadEntryByID(view_id, false);
} catch (Exception e) {
// skip, plugin probably specifically asked to not be added
}
}
}
}
}
if (!tabbedMDI.getMinimized()) {
MdiEntry[] entries = tabbedMDI.getEntries();
if (entries.length > 0) {
tabbedMDI.showEntry(entries[0]);
}
}
}
use of com.biglybt.ui.mdi.MdiEntryCreationListener2 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) {
}
});
}
Aggregations