FileDocCategorySizeDatePackage
ImportTorrentWizard.javaAPI DocAzureus 3.0.3.44195Tue May 08 19:02:34 BST 2007org.gudy.azureus2.ui.swt.importtorrent.wizard

ImportTorrentWizard

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

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

  
	 
	
			
		 	 
	
		super(azureus_core,"importTorrentWizard.title");
	
		ImportTorrentWizardInputPanel input_panel = new ImportTorrentWizardInputPanel(this,null);
	
		this.setFirstPanel(input_panel);
	
Methods Summary
protected java.lang.StringgetImportFile()

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

		return( torrent_file );
	
public voidonClose()

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

		File input_file;
		
		try{
			input_file = new File( getImportFile()).getCanonicalFile();
			
		}catch( IOException e ){
			
			MessageBox mb = new MessageBox(getWizardWindow(),SWT.ICON_ERROR | SWT.OK );
		
			mb.setText(MessageText.getString("importTorrentWizard.process.inputfilebad.title"));
		
			mb.setMessage(	MessageText.getString("importTorrentWizard.process.inputfilebad.message")+"\n" +
							e.toString());
			
			mb.open();
			
			return( false );
		}
		
		File output_file = new File( getTorrentFile() );
		
		if ( output_file.exists()){
			
			MessageBox mb = new MessageBox(this.getWizardWindow(),SWT.ICON_QUESTION | SWT.YES | SWT.NO);
			
			mb.setText(MessageText.getString("importTorrentWizard.process.outputfileexists.title"));
			
			mb.setMessage(MessageText.getString("importTorrentWizard.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.deserialiseFromXMLFile( input_file );
	
				try{
					
					torrent.serialiseToBEncodedFile( output_file );
					
					return( true );
								
				}catch( TOTorrentException e ){
				
					//e.printStackTrace();
					
					error_title 	= MessageText.getString("importTorrentWizard.process.torrentfail.title");
				
					error_detail	= TorrentUtils.exceptionToText( e ); 
				}
			}catch( TOTorrentException e ){
				
				// e.printStackTrace();
				
				error_title 	= MessageText.getString("importTorrentWizard.process.importfail.title");
				
				error_detail	= TorrentUtils.exceptionToText( e ); 
			}
			
		}catch( Throwable e ){

			error_title 	= MessageText.getString("importTorrentWizard.process.unknownfail.title");
		
			Debug.printStackTrace( e );
			
			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 voidsetImportFile(java.lang.String str)

		import_file = str;
		
		torrent_file = str + ".torrent";
	
protected voidsetTorrentFile(java.lang.String str)

		torrent_file = str;