File targetFile = new File( targetFolder, fileName );
String targetFileName = fileName; if(fileName.endsWith( ".rptdesign" )) { int index = fileName.lastIndexOf( "." ); targetFileName = fileName.substring( 0, index ) + ".rpttemplate"; } File targetFile = new File( targetFolder, targetFileName );
	public boolean performFinish( )	{		// copy to template folder		String templateFolderPath = ReportPlugin.getDefault( )				.getTemplatePreference( );		String filePath = SessionHandleAdapter.getInstance( )				.getReportDesignHandle( )				.getFileName( );		String fileName = filePath.substring( filePath.lastIndexOf( File.separator ) + 1 );		File targetFolder = new File( templateFolderPath );		if ( !targetFolder.isDirectory( ) )		{			ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishTemplateAction.wizard.errorTitle" ), //$NON-NLS-1$					Messages.getString( "PublishTemplateAction.wizard.notvalidfolder" ) ); //$NON-NLS-1$			return true;		}		if ( !targetFolder.exists( ) )		{			targetFolder.mkdirs( );		}		File targetFile = new File( targetFolder, fileName );		if ( new File( filePath ).compareTo( targetFile ) == 0 )		{			ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishTemplateAction.wizard.errorTitle" ), //$NON-NLS-1$					Messages.getString( "PublishTemplateAction.wizard.message" ) ); //$NON-NLS-1$			return true;		}		int overwrite = Window.OK;		try		{			if ( targetFile.exists( ) )			{				String[] buttons = new String[]{						IDialogConstants.YES_LABEL,						IDialogConstants.NO_LABEL,						IDialogConstants.CANCEL_LABEL				};				String question = Messages.getFormattedString( "SaveAsDialog.overwriteQuestion", //$NON-NLS-1$						new Object[]{							targetFile.getAbsolutePath( )						} );				MessageDialog d = new MessageDialog( getShell( ),						Messages.getString( "SaveAsDialog.Question" ), //$NON-NLS-1$						null,						question,						MessageDialog.QUESTION,						buttons,						0 );				overwrite = d.open( );			}			if ( overwrite == Window.OK					&& ( targetFile.exists( ) || ( !targetFile.exists( ) && targetFile.createNewFile( ) ) ) )			{				copyFile( filePath, targetFile );				try				{					setDesignFile( targetFile.getAbsolutePath( ) );				}				catch ( DesignFileException e )				{					ExceptionHandler.handle( e );					return false;				}				catch ( SemanticException e )				{					ExceptionHandler.handle( e );					return false;				}				catch ( IOException e )				{					ExceptionHandler.handle( e );					return false;				}			}		}		catch ( IOException e )		{			ExceptionHandler.handle( e );		}		return overwrite != 1;	}