if ( !menu_added ){
menu_added = true;
final MenuItem template_menu = menuManager.addMenuItem("sidebar.Search","Search.menu.engines");
template_menu.setStyle( MenuItem.STYLE_MENU );
template_menu.addFillListener(
new MenuItemFillListener()
{
public void menuWillBeShown(MenuItem menu, Object data) {
template_menu.removeAllChildItems();
Engine[] engines = MetaSearchManagerFactory.getSingleton().getMetaSearch().getEngines( true, false );
Arrays.sort(
engines,
new Comparator()
{
public int
compare(
Object o1,
Object o2)
{
return(((Engine)o1).getName().compareToIgnoreCase(((Engine)o2).getName()));
}
});
for (int i=0;i<engines.length;i++){
final Engine engine = engines[i];
MenuItem engine_menu = menuManager.addMenuItem( template_menu, "!" + engine.getName() + "!" );
engine_menu.setStyle( MenuItem.STYLE_MENU );
if ( true || engine.getSource() != Engine.ENGINE_SOURCE_VUZE ){
MenuItem mi = menuManager.addMenuItem( engine_menu, "MyTorrentsView.menu.exportmenu" );
mi.addListener(
new MenuItemListener()
{
public void
selected(
MenuItem menu,
Object target)
{
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(
new AERunnable()
{
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(new String[] {
"*.vuze",
"*.vuz",
org.gudy.azureus2.core3.util.Constants.FILE_WILDCARD
});
dialog.setFilterNames(new String[] {
"*.vuze",
"*.vuz",
org.gudy.azureus2.core3.util.Constants.FILE_WILDCARD
});
String path = TorrentOpener.setFilterPathData( dialog.open());
if ( path != null ){
String lc = path.toLowerCase();
if ( !lc.endsWith( ".vuze" ) && !lc.endsWith( ".vuz" )){
path += ".vuze";
}
try{
engine.exportToVuzeFile( new File( path ));
}catch( Throwable e ){
Debug.out( e );
}
}
}
});
}
});
}
if ( Constants.IS_CVS_VERSION ){
MenuItem copy_mi = menuManager.addMenuItem( engine_menu, "ConfigView.copy.to.clipboard.tooltip" );
copy_mi.addListener(
new MenuItemListener()
{
public void
selected(
MenuItem menu,
Object target)
{
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(
new AERunnable()
{
public void
runSupport()
{
try{
ClipboardCopy.copyToClipBoard( engine.exportToJSONString());
}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 ){
MenuItem mi = menuManager.addMenuItem( engine_menu, "Subscription.menu.resetauth" );
mi.addListener(
new MenuItemListener()
{
public void
selected(
MenuItem menu,
Object target)
{
we.setCookies( null );
}
});
}
}
}
if ( engine_menu.getItems().length > 0 ){
MenuItem mi = menuManager.addMenuItem( engine_menu, "Subscription.menu.sep" );
mi.setStyle( MenuItem.STYLE_SEPARATOR );
}
MenuItem mi = menuManager.addMenuItem( engine_menu, "Subscription.menu.properties" );
mi.addListener(
new MenuItemListener()
{
public void
selected(
MenuItem menu,
Object target)
{
String engine_str;
String auth_str = String.valueOf(false);
engine_str = engine.getNameEx();
if ( engine instanceof WebEngine ){
WebEngine web_engine = (WebEngine)engine;
if ( web_engine.isNeedsAuth()){
auth_str = String.valueOf(true) + ": cookies=" + toString( web_engine.getRequiredCookies());
}
}
String[] keys = {
"subs.prop.template",
"subs.prop.auth",
};
String[] values = {
engine_str,
auth_str,
};
new PropertiesWindow( engine.getName(), keys, values );
}
private String
toString(
String[] strs )
{
String res = "";
for(int i=0;i<strs.length;i++){
res += (i==0?"":",") + strs[i];
}
return( res );
}
});
if ( engine_menu.getItems().length == 0 ){
engine_menu.setEnabled( false );
}
}
}
});
final MenuItem export_menu = menuManager.addMenuItem("sidebar.Search","search.export.all");
export_menu.setStyle( MenuItem.STYLE_PUSH );
export_menu.addListener(
new MenuItemListener()
{
public void
selected(
MenuItem menu,