final String cuName= fCuParser.getTypeName() + ".java";
final String cuName= fCuParser.getTypeName() + JavaModelUtil.DEFAULT_CU_SUFFIX;
		public void paste(IJavaElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaModelException, InterruptedException, InvocationTargetException{			final IEditorPart[] editorPart= new IEditorPart[1];						IWorkspaceRunnable op= new IWorkspaceRunnable() {				public void run(IProgressMonitor pm) throws CoreException {					pm.beginTask("", 4); //$NON-NLS-1$										if (! fDestinationPack.exists())						JavaModelUtil.getPackageFragmentRoot(fDestinationPack).createPackageFragment(fCuParser.getPackageName(), true, new SubProgressMonitor(pm, 1));					else						pm.worked(1);										final String cuName= fCuParser.getTypeName() + ".java"; //$NON-NLS-1$					final ICompilationUnit cu= fDestinationPack.getCompilationUnit(cuName);					boolean alreadyExists= cu.exists();					if (alreadyExists) {						String msg= MessageFormat.format(ReorgMessages.PasteAction_TextPaster_exists, new Object[] {cuName});						boolean overwrite= MessageDialog.openQuestion(getShell(), ReorgMessages.PasteAction_TextPaster_confirmOverwriting, msg);						if (! overwrite)							return;												editorPart[0]= openCu(cu); //Open editor before overwriting to allow undo.					}										fDestinationPack.createCompilationUnit(cuName, fCuParser.getText(), true, new SubProgressMonitor(pm, 1));										if (!alreadyExists) {						editorPart[0]= openCu(cu);					}					if (!fDestinationPack.getElementName().equals(fCuParser.getPackageName())) {						if (fDestinationPack.getElementName().length() == 0) {							removePackageDeclaration(cu);						} else {							cu.createPackageDeclaration(fDestinationPack.getElementName(), new SubProgressMonitor(pm, 1));						}						if (!alreadyExists && editorPart[0] != null)							editorPart[0].doSave(new SubProgressMonitor(pm, 1)); //avoid showing error marker due to missing/wrong package declaration						else							pm.worked(1);					} else {						pm.worked(1);					}					BasicNewResourceWizard.selectAndReveal(cu.getResource(), PlatformUI.getWorkbench().getActiveWorkbenchWindow());				}				private void removePackageDeclaration(final ICompilationUnit cu) throws JavaModelException, CoreException {					IPackageDeclaration[] packageDeclarations= cu.getPackageDeclarations();					if (packageDeclarations.length != 0) {						ITextFileBuffer buffer= null;						try {							buffer= RefactoringFileBuffers.acquire(cu);							ISourceRange sourceRange= packageDeclarations[0].getSourceRange();							buffer.getDocument().replace(sourceRange.getOffset(), sourceRange.getLength(), ""); //$NON-NLS-1$						} catch (BadLocationException e) {							JavaPlugin.log(e);						} finally {							if (buffer != null)								RefactoringFileBuffers.release(cu);						}					}				}			};						IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow();			if (context == null) {				context= new BusyIndicatorRunnableContext();			}			PlatformUI.getWorkbench().getProgressService().runInUI(context, new WorkbenchRunnableAdapter(op), null);						if (editorPart[0] != null)				editorPart[0].getEditorSite().getPage().activate(editorPart[0]); //activate editor again, since runInUI restores previous active part		}