FileDocCategorySizeDatePackage
ExportTorrentWizard.javaAPI DocAzureus 3.0.3.44469Tue May 08 19:02:34 BST 2007org.gudy.azureus2.ui.swt.exporttorrent.wizard

ExportTorrentWizard

public class ExportTorrentWizard extends org.gudy.azureus2.ui.swt.wizard.Wizard
author
parg

Fields Summary
String
torrent_file
String
export_file
Constructors Summary
public ExportTorrentWizard(AzureusCore azureus_core, org.eclipse.swt.widgets.Display display)

  
	 
	
				
 		 	 
	
		super(azureus_core,"exportTorrentWizard.title");
	
		ExportTorrentWizardInputPanel input_panel = new ExportTorrentWizardInputPanel(this,null);
	
		setFirstPanel(input_panel);
	
public ExportTorrentWizard(AzureusCore azureus_core, org.eclipse.swt.widgets.Display display, DownloadManager dm)

		super(azureus_core, "exportTorrentWizard.title");
	
		setTorrentFile( dm.getTorrentFileName());
		
		ExportTorrentWizardOutputPanel output_panel = new ExportTorrentWizardOutputPanel(this,null);
	
		setFirstPanel(output_panel);
	
Methods Summary
protected java.lang.StringgetExportFile()

		return( export_file );
	
protected java.lang.StringgetTorrentFile()

		return( torrent_file );
	
public voidonClose()

 		// Call the parent class to clean up resources
 		super.onClose();	
 	
protected booleanperformExport()

		File input_file;
		
		try{
			input_file = new File( getTorrentFile()).getCanonicalFile();
			
		}catch( IOException e ){
			
			MessageBox mb = new MessageBox(getWizardWindow(),SWT.ICON_ERROR | SWT.OK );
		
			mb.setText(MessageText.getString("exportTorrentWizard.process.inputfilebad.title"));
		
			mb.setMessage(	MessageText.getString("exportTorrentWizard.process.inputfilebad.message")+"\n" +
							e.toString());
			
			mb.open();
			
			return( false );
		}
		
		File output_file = new File( export_file );
		
		if ( output_file.exists()){
			
			MessageBox mb = new MessageBox(this.getWizardWindow(),SWT.ICON_QUESTION | SWT.YES | SWT.NO);
			
			mb.setText(MessageText.getString("exportTorrentWizard.process.outputfileexists.title"));
			
			mb.setMessage(MessageText.getString("exportTorrentWizard.process.outputfileexists.message"));
			
			int result = mb.open();
		
			if( result == SWT.NO ){
				
				return( false );
			}
		}

		String	error_title;
		String	error_detail;
		
		try{
		
			TOTorrent	torrent;
			
			try{
				
				torrent = TOTorrentFactory.deserialiseFromBEncodedFile( input_file );
	
				try{
					
					torrent.serialiseToXMLFile( output_file );
					
					return( true );
								
				}catch( TOTorrentException e ){
				
					error_title 	= MessageText.getString("exportTorrentWizard.process.exportfail.title");
				
					error_detail	= TorrentUtils.exceptionToText( e ); 
				}
			}catch( TOTorrentException e ){
				
				error_title 	= MessageText.getString("exportTorrentWizard.process.torrentfail.title");
				
				error_detail	= TorrentUtils.exceptionToText( e ); 
			}
			
		}catch( Throwable e ){

			error_title 	= MessageText.getString("exportTorrentWizard.process.unknownfail.title");
		
			error_detail 	= e.toString();
		}

		MessageBox mb = new MessageBox(this.getWizardWindow(),SWT.ICON_ERROR | SWT.OK );
			
		mb.setText(error_title);
			
		mb.setMessage(error_detail);
			
		mb.open();
		
		return( false );
	
protected voidsetExportFile(java.lang.String str)

		export_file = str;
	
protected voidsetTorrentFile(java.lang.String str)

		torrent_file = str;
		
		export_file = str + ".xml";