use of com.biglybt.pif.ui.menus.MenuItemFillListener in project BiglyBT by BiglySoftware.
the class SB_Transfers method addHeaderMenu.
protected void addHeaderMenu() {
PluginInterface pi = PluginInitializer.getDefaultInterface();
UIManager uim = pi.getUIManager();
assert uim != null;
final MenuManager menuManager = uim.getMenuManager();
MenuItem menuItem;
menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, "MyTorrentsView.menu.setCategory.add");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
CategoryUIUtils.showCreateCategoryDialog(null);
}
});
// cats in sidebar
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.setVisible(COConfigurationManager.getBooleanParameter("Library.CatInSideBar"));
}
});
menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, "ConfigView.section.style.CatInSidebar");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.setStyle(MenuItem.STYLE_CHECK);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
boolean b = COConfigurationManager.getBooleanParameter("Library.CatInSideBar");
COConfigurationManager.setParameter("Library.CatInSideBar", !b);
}
});
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.setVisible(CategoryManager.getCategories().length > 0);
menu.setData(COConfigurationManager.getBooleanParameter("Library.CatInSideBar"));
}
});
// show tags in sidebar
TagUIUtils.setupSideBarMenus(menuManager);
}
use of com.biglybt.pif.ui.menus.MenuItemFillListener in project BiglyBT by BiglySoftware.
the class SideBar method addGeneralMenus.
/**
* @since 3.1.0.1
*/
private void addGeneralMenus() {
PluginManager pm = CoreFactory.getSingleton().getPluginManager();
PluginInterface pi = pm.getDefaultPluginInterface();
UIManager uim = pi.getUIManager();
MenuManager menuManager = uim.getMenuManager();
{
MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.add.to.dashboard");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
if (sbe != null && sbe.getId().equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
menu.setVisible(false);
} else {
menu.setVisible(sbe != null && sbe.canBuildStandAlone());
}
}
});
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
if (sbe != null) {
MainMDISetup.getSb_dashboard().addItem(sbe);
}
}
});
}
{
MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.pop.out");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
menu.setVisible(sbe != null && sbe.canBuildStandAlone());
}
});
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
if (sbe != null) {
SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
SWTSkin skin = skinnedDialog.getSkin();
SWTSkinObjectContainer cont = sbe.buildStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"));
if (cont != null) {
skinnedDialog.setTitle(sbe.getTitle());
skinnedDialog.open();
} else {
skinnedDialog.close();
}
}
}
});
}
}
use of com.biglybt.pif.ui.menus.MenuItemFillListener 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.pif.ui.menus.MenuItemFillListener in project BiglyBT by BiglySoftware.
the class DeviceManagerUI method createOverallMenu.
private void createOverallMenu(final MenuManager menu_manager, String parentID) {
MenuItem de_menu_item = menu_manager.addMenuItem(parentID, "device.search");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
search();
}
});
// show generic
de_menu_item = menu_manager.addMenuItem(parentID, "device.showGeneric");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.setStyle(MenuItem.STYLE_CHECK);
de_menu_item.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
boolean is_hidden = COConfigurationManager.getBooleanParameter(CONFIG_VIEW_HIDE_REND_GENERIC, true);
menu.setData(!is_hidden);
boolean enabled = false;
if (is_hidden) {
Device[] devices = device_manager.getDevices();
for (Device d : devices) {
if (d.isHidden()) {
continue;
}
if (d instanceof DeviceMediaRenderer) {
DeviceMediaRenderer rend = (DeviceMediaRenderer) d;
if (rend.isNonSimple()) {
enabled = true;
}
}
}
} else {
enabled = true;
}
menu.setEnabled(enabled);
}
});
de_menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
COConfigurationManager.setParameter(CONFIG_VIEW_HIDE_REND_GENERIC, !COConfigurationManager.getBooleanParameter(CONFIG_VIEW_HIDE_REND_GENERIC, true));
}
});
// show tagged
de_menu_item = menu_manager.addMenuItem(parentID, "device.onlyShowTagged");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.setStyle(MenuItem.STYLE_CHECK);
de_menu_item.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.setData(COConfigurationManager.getBooleanParameter(CONFIG_VIEW_SHOW_ONLY_TAGGED, false));
Device[] devices = device_manager.getDevices();
boolean has_tagged = false;
for (Device d : devices) {
if (d.isTagged()) {
has_tagged = true;
break;
}
}
menu.setEnabled(has_tagged);
}
});
de_menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
COConfigurationManager.setParameter(CONFIG_VIEW_SHOW_ONLY_TAGGED, !COConfigurationManager.getBooleanParameter(CONFIG_VIEW_SHOW_ONLY_TAGGED, false));
}
});
// show hidden
de_menu_item = menu_manager.addMenuItem(parentID, "device.show");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.addListener(show_listener);
de_menu_item.addFillListener(show_fill_listener);
// simple
de_menu_item = menu_manager.addMenuItem(parentID, "devices.sidebar.simple");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.setStyle(MenuItem.STYLE_CHECK);
de_menu_item.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.setData(COConfigurationManager.getIntParameter(CONFIG_VIEW_TYPE, SBV_SIMPLE) == SBV_SIMPLE);
}
});
de_menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
COConfigurationManager.setParameter(CONFIG_VIEW_TYPE, ((Boolean) menu.getData()) ? SBV_SIMPLE : SBV_FULL);
}
});
de_menu_item = menu_manager.addMenuItem(parentID, "sep");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.setStyle(MenuItem.STYLE_SEPARATOR);
// on complete do
final MenuItem de_oxc_menu = menu_manager.addMenuItem(parentID, "devices.sidebar.onxcodecomplete");
de_oxc_menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_oxc_menu.setStyle(MenuItem.STYLE_MENU);
de_oxc_menu.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.removeAllChildItems();
final List<MenuItem> oxc_items = new ArrayList<>();
final MenuItem oxc_nothing = menu_manager.addMenuItem(de_oxc_menu, "devices.sidebar.oxc.nothing");
oxc_items.add(oxc_nothing);
oxc_nothing.setStyle(MenuItem.STYLE_CHECK);
oxc_nothing.setData(oxc_action == OXC_NOTHING);
final MenuItem oxc_close_vuze = menu_manager.addMenuItem(de_oxc_menu, "devices.sidebar.oxc.closevuze");
oxc_items.add(oxc_close_vuze);
oxc_close_vuze.setStyle(MenuItem.STYLE_CHECK);
oxc_close_vuze.setData(oxc_action == OXC_QUIT_VUZE);
PlatformManager pm = PlatformManagerFactory.getPlatformManager();
int sdt = pm.getShutdownTypes();
final Map<MenuItem, String> oxc_pm_map = new HashMap<>();
for (int type : PlatformManager.SD_ALL) {
if ((sdt | type) != 0) {
String action = OXC_NOTHING;
if (type == PlatformManager.SD_SLEEP) {
action = OXC_SLEEP;
} else if (type == PlatformManager.SD_HIBERNATE) {
action = OXC_HIBERNATE;
} else if (type == PlatformManager.SD_SHUTDOWN) {
action = OXC_SHUTDOWN;
} else {
Debug.out("Unknown type: " + type);
}
MenuItem oxc_pm = menu_manager.addMenuItem(de_oxc_menu, "devices.sidebar.oxc.pm." + type);
oxc_items.add(oxc_pm);
oxc_pm.setStyle(MenuItem.STYLE_CHECK);
oxc_pm.setData(oxc_action == action);
oxc_pm_map.put(oxc_pm, action);
}
}
MenuItemListener oxc_mil = new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
if ((Boolean) menu.getData()) {
if (menu == oxc_nothing) {
setOXCState(OXC_NOTHING);
} else if (menu == oxc_close_vuze) {
setOXCState(OXC_QUIT_VUZE);
} else {
setOXCState(oxc_pm_map.get(menu));
}
}
}
};
for (MenuItem mi : oxc_items) {
mi.addListener(oxc_mil);
}
}
});
de_menu_item = menu_manager.addMenuItem(parentID, "sep2");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.setStyle(MenuItem.STYLE_SEPARATOR);
// options
de_menu_item = menu_manager.addMenuItem(parentID, "MainWindow.menu.view.configuration");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null) {
uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, CONFIG_SECTION_ID);
}
}
});
if (Constants.isCVSVersion()) {
de_menu_item = menu_manager.addMenuItem(parentID, "!(CVS Only)Show FTUX!");
de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
de_menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
DevicesFTUX.showForDebug();
}
});
}
}
use of com.biglybt.pif.ui.menus.MenuItemFillListener in project BiglyBT by BiglySoftware.
the class DeviceManagerUI method setupTranscodeMenus.
private void setupTranscodeMenus() {
if (DISABLED_TRANSCODING) {
return;
}
// top level menus
final String[] tables = { TableManager.TABLE_MYTORRENTS_INCOMPLETE, TableManager.TABLE_MYTORRENTS_INCOMPLETE_BIG, TableManager.TABLE_MYTORRENTS_COMPLETE, TableManager.TABLE_MYTORRENTS_COMPLETE_BIG, TableManager.TABLE_TORRENT_FILES, TableManager.TABLE_MYTORRENTS_UNOPENED, TableManager.TABLE_MYTORRENTS_UNOPENED_BIG, TableManager.TABLE_MYTORRENTS_ALL_BIG };
TableManager table_manager = plugin_interface.getUIManager().getTableManager();
MenuItemFillListener menu_fill_listener = new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object _target) {
final TableRow[] target;
if (_target instanceof TableRow) {
target = new TableRow[] { (TableRow) _target };
} else {
target = (TableRow[]) _target;
}
boolean enabled = target.length > 0;
for (TableRow row : target) {
Object obj = row.getDataSource();
if (obj instanceof Download) {
Download download = (Download) obj;
if (download.getState() == Download.ST_ERROR) {
enabled = false;
}
} else {
DiskManagerFileInfo file = (DiskManagerFileInfo) obj;
try {
if (file.getIndex() < 0 || file.getDownload().getState() == Download.ST_ERROR) {
enabled = false;
}
} catch (Throwable e) {
enabled = false;
}
}
}
menu.setEnabled(enabled);
menu.removeAllChildItems();
if (enabled) {
Device[] devices = device_manager.getDevices();
int devices_added = 0;
for (Device device : devices) {
if (device.isHidden()) {
continue;
}
if (device instanceof TranscodeTarget) {
devices_added++;
final TranscodeTarget renderer = (TranscodeTarget) device;
TranscodeProfile[] profiles = renderer.getTranscodeProfiles();
TableContextMenuItem device_item = plugin_interface.getUIManager().getTableManager().addContextMenuItem((TableContextMenuItem) menu, "!" + device.getName() + (profiles.length == 0 ? " (No Profiles)" : "") + "!");
device_item.setStyle(MenuItem.STYLE_MENU);
if (profiles.length == 0) {
device_item.setEnabled(false);
} else {
Arrays.sort(profiles, new Comparator<TranscodeProfile>() {
@Override
public int compare(TranscodeProfile o1, TranscodeProfile o2) {
int i1 = o1.getIconIndex();
int i2 = o2.getIconIndex();
if (i1 == i2) {
return o1.getName().compareToIgnoreCase(o2.getName());
} else {
return (i1 - i2);
}
}
});
for (final TranscodeProfile profile : profiles) {
TableContextMenuItem profile_item = plugin_interface.getUIManager().getTableManager().addContextMenuItem(device_item, "!" + profile.getName() + "!");
profile_item.addMultiListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object x) {
for (TableRow row : target) {
Object obj = row.getDataSource();
try {
if (obj instanceof Download) {
Download download = (Download) obj;
addDownload(renderer, profile, -1, download);
} else {
DiskManagerFileInfo file = (DiskManagerFileInfo) obj;
addFile(renderer, profile, -1, file);
}
} catch (Throwable e) {
Debug.out(e);
}
}
}
});
}
}
}
}
if (devices_added == 0) {
TableContextMenuItem device_item = plugin_interface.getUIManager().getTableManager().addContextMenuItem((TableContextMenuItem) menu, "!(No Devices)!");
device_item.setEnabled(false);
}
}
}
};
// instead of forcing a loop like this
for (String table : tables) {
TableContextMenuItem menu = table_manager.addContextMenuItem(table, "devices.contextmenu.xcode");
menu.setStyle(TableContextMenuItem.STYLE_MENU);
menu.setHeaderCategory(MenuItem.HEADER_CONTENT);
menu.addFillListener(menu_fill_listener);
menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
}
}
Aggregations