Shell shell= getSite().getShell(); IEditorInput input = getEditorInput();  SaveAsDialog dialog= new SaveAsDialog(shell);  IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) dialog.setOriginalFile(original);  dialog.create();   IDocumentProvider provider= getDocumentProvider(); if (provider == null) {  return; }  if (provider.isDeleted(input) && original != null) { String message= Messages.format(JavaEditorMessages.CompilationUnitEditor_warning_save_delete, new Object[] { original.getName() }); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); }  if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; }  IPath filePath= dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; }  IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot(); IFile file= workspaceRoot.getFile(filePath); final IEditorInput newInput= new FileEditorInput(file);  boolean success= false; try {  provider.aboutToChange(newInput); getDocumentProvider().saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success= true;  } catch (CoreException x) { IStatus status= x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) ErrorDialog.openError(shell, JavaEditorMessages.CompilationUnitEditor_error_saving_title2, JavaEditorMessages.CompilationUnitEditor_error_saving_message2, x.getStatus()); } finally { provider.changed(newInput); if (success) setInput(newInput); }  if (progressMonitor != null) progressMonitor.setCanceled(!success);
IPreferenceStore store= EditorsUI.getPreferenceStore(); String key= getEditorSite().getId() + ".internal.delegateSaveAs"; store.setValue(key, true); super.performSaveAs(progressMonitor);
	protected void performSaveAs(IProgressMonitor progressMonitor) {		Shell shell= getSite().getShell();		IEditorInput input = getEditorInput();		SaveAsDialog dialog= new SaveAsDialog(shell);		IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;		if (original != null)			dialog.setOriginalFile(original);		dialog.create();		IDocumentProvider provider= getDocumentProvider();		if (provider == null) {			// editor has been programmatically closed while the dialog was open			return;		}		if (provider.isDeleted(input) && original != null) {			String message= Messages.format(JavaEditorMessages.CompilationUnitEditor_warning_save_delete, new Object[] { original.getName() });			dialog.setErrorMessage(null);			dialog.setMessage(message, IMessageProvider.WARNING);		}		if (dialog.open() == Window.CANCEL) {			if (progressMonitor != null)				progressMonitor.setCanceled(true);			return;		}		IPath filePath= dialog.getResult();		if (filePath == null) {			if (progressMonitor != null)				progressMonitor.setCanceled(true);			return;		}		IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();		IFile file= workspaceRoot.getFile(filePath);		final IEditorInput newInput= new FileEditorInput(file);		boolean success= false;		try {			provider.aboutToChange(newInput);			getDocumentProvider().saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);			success= true;		} catch (CoreException x) {			IStatus status= x.getStatus();			if (status == null || status.getSeverity() != IStatus.CANCEL)				ErrorDialog.openError(shell, JavaEditorMessages.CompilationUnitEditor_error_saving_title2, JavaEditorMessages.CompilationUnitEditor_error_saving_message2, x.getStatus());		} finally {			provider.changed(newInput);			if (success)				setInput(newInput);		}		if (progressMonitor != null)			progressMonitor.setCanceled(!success);	}