use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class LocaleUtilSWT method selectDecoder.
@Override
public LocaleUtilDecoderCandidate selectDecoder(LocaleUtil locale_util, Object decision_owner, List<LocaleUtilDecoderCandidate> candidates, boolean forceAsk) throws LocaleUtilEncodingException {
if (!forceAsk) {
if (decision_owner != remembered_on_behalf_of) {
remembered_on_behalf_of = decision_owner;
rememberedDecoder = null;
}
if (rememberEncodingDecision && rememberedDecoder != null) {
for (LocaleUtilDecoderCandidate candidate : candidates) {
if (candidate.getValue() != null && rememberedDecoder == candidate.getDecoder()) {
return (candidate);
}
}
}
}
LocaleUtilDecoderCandidate default_candidate = candidates.get(0);
String defaultString = default_candidate.getValue();
ArrayList choosableCandidates = new ArrayList();
if (defaultString != null) {
choosableCandidates.add(default_candidate);
}
LocaleUtilDecoder[] general_decoders = locale_util.getGeneralDecoders();
for (int j = 0; j < general_decoders.length; j++) {
for (LocaleUtilDecoderCandidate candidate : candidates) {
if (candidate.getValue() == null || candidate.getDecoder() == null)
continue;
if (general_decoders[j] != null && general_decoders[j].getName().equals(candidate.getDecoder().getName())) {
if (!choosableCandidates.contains(candidate)) {
choosableCandidates.add(candidate);
break;
}
}
}
}
for (LocaleUtilDecoderCandidate candidate : candidates) {
if (candidate.getValue() == null || candidate.getDecoder() == null)
continue;
if (!choosableCandidates.contains(candidate)) {
choosableCandidates.add(candidate);
}
}
final LocaleUtilDecoderCandidate[] candidatesToChoose = (LocaleUtilDecoderCandidate[]) choosableCandidates.toArray(new LocaleUtilDecoderCandidate[0]);
final LocaleUtilDecoderCandidate[] selected_candidate = { null };
// Run Synchronously, since we want the results
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
try {
showChoosableEncodingWindow(Utils.findAnyShell(false), candidatesToChoose, selected_candidate);
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
}, false);
if (selected_candidate[0] == null) {
throw (new LocaleUtilEncodingException(true));
} else {
return (selected_candidate[0]);
}
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class TorrentInfoView method dataSourceChanged.
private void dataSourceChanged(Object newDataSource) {
DownloadManager[] dms = DataSourceUtils.getDMs(newDataSource);
if (dms.length != 1) {
download_manager = null;
} else {
download_manager = dms[0];
}
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (parent != null && !parent.isDisposed()) {
initialize(parent);
}
}
});
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class TranscodeProviderVuze method update.
protected void update(PluginInterface pi) {
plugin_interface = pi;
try {
plugin_interface.getIPC().invoke("addProfileListChangedListener", new Object[] { new AERunnable() {
@Override
public void runSupport() {
resetProfiles();
}
} });
} catch (IPCException e) {
}
resetProfiles();
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class SearchUtils method addMenus.
public static void addMenus(final MenuManager menuManager) {
final com.biglybt.pif.ui.menus.MenuItem template_menu = menuManager.addMenuItem("sidebar.Search", "Search.menu.engines");
template_menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
template_menu.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_MENU);
template_menu.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(com.biglybt.pif.ui.menus.MenuItem menu, Object data) {
template_menu.removeAllChildItems();
Engine[] engines = MetaSearchManagerFactory.getSingleton().getMetaSearch().getEngines(true, false);
Arrays.sort(engines, new Comparator<Engine>() {
@Override
public int compare(Engine o1, Engine o2) {
return (o1.getName().compareToIgnoreCase(o2.getName()));
}
});
com.biglybt.pif.ui.menus.MenuItem import_menu = menuManager.addMenuItem(template_menu, "menu.import.json.from.clipboard");
import_menu.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
importFromClipboard();
}
});
com.biglybt.pif.ui.menus.MenuItem sep = menuManager.addMenuItem(template_menu, "!sep!");
sep.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_SEPARATOR);
for (int i = 0; i < engines.length; i++) {
final Engine engine = engines[i];
com.biglybt.pif.ui.menus.MenuItem engine_menu = menuManager.addMenuItem(template_menu, "!" + engine.getName() + "!");
engine_menu.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_MENU);
if (!(engine instanceof PluginEngine)) {
com.biglybt.pif.ui.menus.MenuItem mi = menuManager.addMenuItem(engine_menu, "MyTorrentsView.menu.exportmenu");
mi.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(new AERunnable() {
@Override
public void runSupport() {
FileDialog dialog = new FileDialog(shell, SWT.SYSTEM_MODAL | SWT.SAVE);
dialog.setFilterPath(TorrentOpener.getFilterPathData());
dialog.setText(MessageText.getString("metasearch.export.select.template.file"));
dialog.setFilterExtensions(VuzeFileHandler.getVuzeFileFilterExtensions());
dialog.setFilterNames(VuzeFileHandler.getVuzeFileFilterExtensions());
String path = TorrentOpener.setFilterPathData(dialog.open());
if (path != null) {
if (!VuzeFileHandler.isAcceptedVuzeFileName(path)) {
path = VuzeFileHandler.getVuzeFileName(path);
}
try {
engine.exportToVuzeFile(new File(path));
} catch (Throwable e) {
Debug.out(e);
}
}
}
});
}
});
com.biglybt.pif.ui.menus.MenuItem copy_mi = menuManager.addMenuItem(engine_menu, "menu.export.json.to.clipboard");
copy_mi.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(new AERunnable() {
@Override
public void runSupport() {
try {
ClipboardCopy.copyToClipBoard(engine.exportToVuzeFile().exportToJSON());
} catch (Throwable e) {
Debug.out(e);
}
}
});
}
});
final Subscription subs = engine.getSubscription();
if (subs != null) {
com.biglybt.pif.ui.menus.MenuItem copy_uri = menuManager.addMenuItem(engine_menu, "label.copy.uri.to.clip");
copy_uri.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(new AERunnable() {
@Override
public void runSupport() {
try {
ClipboardCopy.copyToClipBoard(subs.getURI());
} catch (Throwable e) {
Debug.out(e);
}
}
});
}
});
}
if (engine instanceof WebEngine) {
final WebEngine we = (WebEngine) engine;
if (we.isNeedsAuth()) {
String cookies = we.getCookies();
if (cookies != null && cookies.length() > 0) {
mi = menuManager.addMenuItem(engine_menu, "Subscription.menu.resetauth");
mi.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
we.setCookies(null);
}
});
}
}
}
}
if (!(engine instanceof PluginEngine)) {
if (engine_menu.getItems().length > 0) {
com.biglybt.pif.ui.menus.MenuItem mi = menuManager.addMenuItem(engine_menu, "Subscription.menu.sep");
mi.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_SEPARATOR);
}
com.biglybt.pif.ui.menus.MenuItem mi = menuManager.addMenuItem(engine_menu, "Button.remove");
mi.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
engine.setSelectionState(Engine.SEL_STATE_FORCE_DESELECTED);
}
});
mi = menuManager.addMenuItem(engine_menu, "Subscription.menu.sep2");
mi.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_SEPARATOR);
}
if (engine_menu.getItems().length > 0) {
com.biglybt.pif.ui.menus.MenuItem mi = menuManager.addMenuItem(engine_menu, "Subscription.menu.sep2");
mi.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_SEPARATOR);
}
com.biglybt.pif.ui.menus.MenuItem mi = menuManager.addMenuItem(engine_menu, "Subscription.menu.properties");
mi.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
showProperties(engine);
}
});
}
}
});
com.biglybt.pif.ui.menus.MenuItem chat_menu = menuManager.addMenuItem("sidebar.Search", "label.chat");
chat_menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
MenuBuildUtils.addChatMenu(menuManager, chat_menu, new MenuBuildUtils.ChatKeyResolver() {
@Override
public String getResourceKey() {
return ("menu.discuss.searchtemplates");
}
@Override
public String getChatKey(Object object) {
return ("Search Templates");
}
});
com.biglybt.pif.ui.menus.MenuItem export_menu = menuManager.addMenuItem("sidebar.Search", "search.export.all");
export_menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
export_menu.setStyle(com.biglybt.pif.ui.menus.MenuItem.STYLE_PUSH);
export_menu.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object target) {
exportAll();
}
});
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class SearchUtils method addMenus.
public static void addMenus(Menu engine_menu, final Engine engine, boolean separator_required) {
if (separator_required) {
new MenuItem(engine_menu, SWT.SEPARATOR);
separator_required = false;
}
if (!(engine instanceof PluginEngine)) {
MenuItem export_json = new MenuItem(engine_menu, SWT.PUSH);
Messages.setLanguageText(export_json, "menu.export.json.to.clipboard");
export_json.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(new AERunnable() {
@Override
public void runSupport() {
try {
ClipboardCopy.copyToClipBoard(engine.exportToVuzeFile().exportToJSON());
} catch (Throwable e) {
Debug.out(e);
}
}
});
}
});
final Subscription subs = engine.getSubscription();
if (subs != null) {
MenuItem export_uri = new MenuItem(engine_menu, SWT.PUSH);
Messages.setLanguageText(export_uri, "label.copy.uri.to.clip");
export_uri.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(new AERunnable() {
@Override
public void runSupport() {
try {
ClipboardCopy.copyToClipBoard(subs.getURI());
} catch (Throwable e) {
Debug.out(e);
}
}
});
}
});
}
new MenuItem(engine_menu, SWT.SEPARATOR);
MenuItem remove_item = new MenuItem(engine_menu, SWT.PUSH);
Messages.setLanguageText(remove_item, "Button.remove");
Utils.setMenuItemImage(remove_item, "delete");
remove_item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
engine.setSelectionState(Engine.SEL_STATE_FORCE_DESELECTED);
}
});
separator_required = true;
}
if (separator_required) {
new MenuItem(engine_menu, SWT.SEPARATOR);
separator_required = false;
}
MenuItem show_props = new MenuItem(engine_menu, SWT.PUSH);
Messages.setLanguageText(show_props, "Subscription.menu.properties");
show_props.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showProperties(engine);
}
});
}
Aggregations