use of com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper in project BiglyBT by BiglySoftware.
the class SBC_TorrentDetailsView method initialize.
private void initialize(Composite composite) {
Composite main_area = new Composite(composite, SWT.NULL);
main_area.setLayout(new FormLayout());
// Color bg_color = ColorCache.getColor(composite.getDisplay(), "#c0cbd4");
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
this.parent = composite;
if (tabbedMDI == null) {
tabbedMDI = uiFunctions.createTabbedMDI(main_area, "detailsview");
} else {
System.out.println("ManagerView::initialize : folder isn't null !!!");
}
if (composite.getLayout() instanceof FormLayout) {
main_area.setLayoutData(Utils.getFilledFormData());
} else if (composite.getLayout() instanceof GridLayout) {
main_area.setLayoutData(new GridData(GridData.FILL_BOTH));
}
composite.layout();
// Call plugin listeners
if (uiFunctions != null) {
UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
if (pluginUI != null) {
MyTorrentsView.registerPluginViews(pluginUI);
for (String id : new String[] { UISWTInstance.VIEW_MYTORRENTS, UISWTInstance.VIEW_TORRENT_DETAILS }) {
UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(id);
for (UISWTViewEventListenerWrapper l : pluginViews) {
if (id == UISWTInstance.VIEW_MYTORRENTS && l.getViewID() == PieceInfoView.MSGID_PREFIX) {
// Simple hack to exlude PieceInfoView tab as it's already within Pieces View
continue;
}
if (l != null) {
try {
tabbedMDI.createEntryFromEventListener(null, UISWTInstance.VIEW_TORRENT_DETAILS, l, l.getViewID(), false, manager, null);
} catch (Throwable e) {
Debug.out(e);
}
}
}
}
}
}
SelectedContentManager.addCurrentlySelectedContentListener(this);
tabbedMDI.addListener(new MdiSWTMenuHackListener() {
@Override
public void menuWillBeShown(MdiEntry entry, Menu menuTree) {
menuTree.setData("downloads", new DownloadManager[] { manager });
menuTree.setData("is_detailed_view", true);
MenuFactory.buildTorrentMenu(menuTree);
}
});
if (dataSource instanceof Object[] && ((Object[]) dataSource)[0] instanceof PEPeer) {
tabbedMDI.showEntryByID(PeersView.MSGID_PREFIX);
} else {
MdiEntry[] entries = tabbedMDI.getEntries();
if (entries.length > 0) {
tabbedMDI.showEntry(entries[0]);
}
}
}
use of com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper 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.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper in project BiglyBT by BiglySoftware.
the class StatsView method initialize.
private void initialize(Composite composite) {
parent = composite;
// Call plugin listeners
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
tabbedMDI = uiFunctions.createTabbedMDI(composite, VIEW_ID);
CTabFolder folder = tabbedMDI.getTabFolder();
Label lblClose = new Label(folder, SWT.WRAP);
lblClose.setText("x");
lblClose.addListener(SWT.MouseUp, new Listener() {
@Override
public void handleEvent(Event event) {
delete();
}
});
folder.setTopRight(lblClose);
UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
registerPluginViews(pluginUI);
if (pluginUI != null) {
UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(UISWTInstance.VIEW_STATISTICS);
for (int i = 0; i < pluginViews.length; i++) {
UISWTViewEventListenerWrapper l = pluginViews[i];
String name = l.getViewID();
try {
MdiEntrySWT entry = (MdiEntrySWT) tabbedMDI.createEntryFromEventListener(UISWTInstance.VIEW_STATISTICS, l, name, false, null, null);
entry.setDestroyOnDeactivate(false);
if ((dataSource == null && i == 0) || name.equals(dataSource)) {
tabbedMDI.showEntry(entry);
}
} catch (Exception e) {
// skip
}
}
}
}
updateThread = new UpdateThread();
updateThread.setDaemon(true);
updateThread.start();
dataSourceChanged(dataSource);
}
Aggregations