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",
Constants.FILE_WILDCARD
});
dialog.setFilterNames(new String[] {
"*.vuze",
"*.vuz",
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 ));
Map params = new HashMap();
params.put( "id", new Long( id ));
sendBrowserMessage( "metasearch", "exportTemplateCompleted", params );
}catch( Throwable e ){
Map params = new HashMap();
params.put( "id", new Long( id ));
params.put( "error", "save failed: " + Debug.getNestedExceptionMessage(e));
sendBrowserMessage("metasearch", "exportTemplateFailed",params);
}
}else{
Map params = new HashMap();
params.put( "id", new Long( id ));
params.put( "error", "operation cancelled" );
sendBrowserMessage("metasearch", "exportTemplateFailed",params);
}
}
});
}
}else if ( OP_IMPORT_TEMPLATE.equals(opid)){
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(
new AERunnable()
{
public void
runSupport()
{
FileDialog dialog =
new FileDialog( shell, SWT.SYSTEM_MODAL | SWT.OPEN );
dialog.setFilterPath( TorrentOpener.getFilterPathData() );
dialog.setText(MessageText.getString("metasearch.import.select.template.file"));
dialog.setFilterExtensions(new String[] {
"*.vuze",
"*.vuz",
Constants.FILE_WILDCARD
});
dialog.setFilterNames(new String[] {
"*.vuze",
"*.vuz",
Constants.FILE_WILDCARD
});
String path = TorrentOpener.setFilterPathData( dialog.open());
if ( path != null ){
VuzeFileHandler vfh = VuzeFileHandler.getSingleton();