org.eclipse.ui.actions.ReadOnlyStateChecker#org.eclipse.ltk.core.refactoring.RefactoringCore源码实例Demo

下面列出了org.eclipse.ui.actions.ReadOnlyStateChecker#org.eclipse.ltk.core.refactoring.RefactoringCore 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xds-ide   文件: RenameRefactoringProcessor.java
private Change createRenameModuleFileChange(IFile ifile, String newName, RefactoringChangeContext refactoringChangeContext) {
	IFile renamedIFile = getRenamedAbsoluteFile(ifile, newName);
	if (ResourceUtils.equals(renamedIFile, ifile)) {
		return null;
	}
	
	final RenameResourceDescriptor descriptor= (RenameResourceDescriptor) RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID).createDescriptor();
	descriptor.setProject(ifile.getProject().getName());
	descriptor.setDescription(Messages.RenameRefactoringProcessor_RenameModule);
	descriptor.setComment(""); //$NON-NLS-1$
	descriptor.setFlags(RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE);
	descriptor.setResourcePath(ifile.getFullPath());
	descriptor.setNewName(newName);
	descriptor.setUpdateReferences(true);
	
	IPath conflictingResourcePath = null;
	if (renamedIFile.exists()) {
		conflictingResourcePath = renamedIFile.getFullPath();
		refactoringChangeContext.registerFileDelete(ResourceUtils.getAbsoluteFile(renamedIFile));
	}
	XdsRenameResourceChange resourceChange = new XdsRenameResourceChange(ifile.getFullPath(), conflictingResourcePath, newName);
	resourceChange.setDescriptor(new RefactoringChangeDescriptor(descriptor));
	
	return resourceChange;
}
 
源代码2 项目: gwt-eclipse-plugin   文件: RefactoringUtilities.java
/**
 * Creates a {@link RefactoringDescriptor} from a
 * {@link RefactoringContribution} of the given ID.
 * 
 * @return a non-null {@link RefactoringDescriptor}
 * @throws RefactoringException if there was a problem creating the descriptor
 */
public static RefactoringDescriptor createDescriptor(String contributionId)
    throws RefactoringException {
  RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(contributionId);
  if (contribution == null) {
    throw new RefactoringException(
        String.format("The refactoring contribution (%s) is not available.",
            contributionId));
  }

  RefactoringDescriptor refactoringDescriptor = contribution.createDescriptor();
  if (refactoringDescriptor == null) {
    throw new RefactoringException(
        String.format(
            "A descriptor could not be created from the refactoring contribution (%s).",
            contribution.getClass().getSimpleName()));
  }

  return refactoringDescriptor;
}
 
private IntroduceParameterDescriptor getRefactoringDescriptor() {
	ChangeMethodSignatureDescriptor extended= (ChangeMethodSignatureDescriptor) fChangeSignatureProcessor.createDescriptor();
	RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(IJavaRefactorings.CHANGE_METHOD_SIGNATURE);

	Map<String, String> argumentsMap= contribution.retrieveArgumentMap(extended);

	final Map<String, String> arguments= new HashMap<String, String>();
	arguments.put(ATTRIBUTE_ARGUMENT, fParameter.getNewName());
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
	arguments.putAll(argumentsMap);
	String signature= fChangeSignatureProcessor.getMethodName();
	try {
		signature= fChangeSignatureProcessor.getOldMethodSignature();
	} catch (JavaModelException exception) {
		JavaPlugin.log(exception);
	}
	final String description= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fChangeSignatureProcessor.getMethod().getElementName()));
	final String header= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fParameter.getNewName()), signature, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(extended.getProject(), this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_original_pattern, JavaElementLabels.getTextLabel(fChangeSignatureProcessor.getMethod(),
			JavaElementLabels.ALL_FULLY_QUALIFIED)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))));
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_parameter_pattern, BasicElementLabels.getJavaElementName(getAddedParameterInfo().getNewName())));
	return RefactoringSignatureDescriptorFactory.createIntroduceParameterDescriptor(extended.getProject(), description, comment.asString(), arguments, extended.getFlags());
}
 
public boolean run(Shell parent) throws InterruptedException, InvocationTargetException {
	Refactoring ref= new MoveRefactoring(fMoveProcessor);
	if (fMoveProcessor.hasAllInputSet()) {
		IRunnableContext context= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(parent));
		fMoveProcessor.setReorgQueries(new ReorgQueries(parent));
		new RefactoringExecutionHelper(ref, RefactoringCore.getConditionCheckingFailedSeverity(), fMoveProcessor.getSaveMode(), parent, context).perform(false, false);
		return true;
	} else {
		RefactoringWizard wizard= new ReorgMoveWizard(fMoveProcessor, ref);
		/*
		 * We want to get the shell from the refactoring dialog but it's not known at this point,
		 * so we pass the wizard and then, once the dialog is open, we will have access to its shell.
		 */
		fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(wizard));
		fMoveProcessor.setReorgQueries(new ReorgQueries(wizard));
		return new RefactoringStarter().activate(wizard, parent, RefactoringMessages.OpenRefactoringWizardAction_refactoring, fMoveProcessor.getSaveMode());
	}
}
 
/**
 * Executes the rename refactoring without showing a dialog to gather
 * additional user input (for example the new name of the <tt>IJavaElement</tt>).
 * Only an error dialog is shown (if necessary) to present the result
 * of the refactoring's full precondition checking.
 * <p>
 * The method has to be called from within the UI thread.
 * </p>
 *
 * @param parent a shell used as a parent for the error dialog.
 * @param context a {@link IRunnableContext} to execute the operation.
 *
 * @throws InterruptedException if the operation has been canceled by the
 * user.
 * @throws InvocationTargetException if an error occurred while executing the
 * operation.
 *
 * @see #openDialog(Shell)
 * @see IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
 */
public void perform(Shell parent, IRunnableContext context) throws InterruptedException, InvocationTargetException {
	try {
		ensureChecked();
		if (fPreCheckStatus.hasFatalError()) {
			showInformation(parent, fPreCheckStatus);
			return;
		}

		RenameSelectionState state= createSelectionState();

		RefactoringExecutionHelper helper= new RefactoringExecutionHelper(fRefactoring,
				RefactoringCore.getConditionCheckingFailedSeverity(),
				getJavaRenameProcessor().getSaveMode(),
				parent,
				context);
		helper.perform(true, true);

		restoreSelectionState(state);
	} catch (CoreException e) {
		throw new InvocationTargetException(e);
	}
}
 
/**
 * Registers a refactoring execution manager with the refactoring history service.
 * @param rm the refactoring execution manager
 */
public static void register(RefactoringExecutionManager rm) {
    IRefactoringHistoryService rs = RefactoringCore.getHistoryService();
    if (rs != null) {
        rs.addExecutionListener(rm);
        // rs.addHistoryListener(rm);
    }
}
 
/**
 * Unregisters a refactoring execution manager with the refactoring history service.
 * @param rm the refactoring execution manager
 */
public static void unregister(RefactoringExecutionManager rm) {
    IRefactoringHistoryService rs = RefactoringCore.getHistoryService();
    if (rs != null) {
        rs.removeExecutionListener(rm);
        // rs.removeHistoryListener(rm);
    }
}
 
源代码8 项目: xtext-eclipse   文件: RenameRefactoringExecuter.java
@Override
public void run(IProgressMonitor pm) throws CoreException {
	try {
		pm.beginTask("", 11);
		pm.subTask("");
		final RefactoringStatus status = refactoring.checkAllConditions(SubMonitor.convert(pm, 4));
		if (status.getSeverity() >= RefactoringStatus.WARNING) {
			final boolean[] canceled = { false };
			shell.getDisplay().syncExec(new Runnable() {
				@Override
				public void run() {
					canceled[0] = showStatusDialog(status);
				}
			});
			if (canceled[0]) {
				throw new OperationCanceledException();
			}
		}
		Change change = refactoring.createChange(SubMonitor.convert(pm, 2));
		change.initializeValidationData(SubMonitor.convert(pm, 1));
		performChangeOperation = new PerformChangeOperation(change);
		performChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), refactoring.getName());
		performChangeOperation.setSchedulingRule(ResourcesPlugin.getWorkspace().getRoot());
	} finally {
		pm.done();
	}
}
 
源代码9 项目: eclipse.jdt.ls   文件: ChangeCorrectionProposal.java
/**
 * Performs the change associated with this proposal.
 * <p>
 * Subclasses may extend, but must call the super implementation.
 *
 * @throws CoreException
 *             when the invocation of the change failed
 */
@Override
protected void performChange() throws CoreException {

	Change change= null;
	try {
		change= getChange();
		if (change != null) {

			change.initializeValidationData(new NullProgressMonitor());
			RefactoringStatus valid= change.isValid(new NullProgressMonitor());
			if (valid.hasFatalError()) {
				IStatus status = new Status(IStatus.ERROR,  IConstants.PLUGIN_ID, IStatus.ERROR,
						valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null);
				throw new CoreException(status);
			} else {
				IUndoManager manager= RefactoringCore.getUndoManager();
				Change undoChange;
				boolean successful= false;
				try {
					manager.aboutToPerformChange(change);
					undoChange= change.perform(new NullProgressMonitor());
					successful= true;
				} finally {
					manager.changePerformed(change, successful);
				}
				if (undoChange != null) {
					undoChange.initializeValidationData(new NullProgressMonitor());
					manager.addUndo(getName(), undoChange);
				}
			}
		}
	} finally {

		if (change != null) {
			change.dispose();
		}
	}
}
 
源代码10 项目: xtext-xtend   文件: XtendQuickfixProvider.java
@Fix(IssueCodes.WRONG_FILE)
public void fixWrongFileRenameClass(final Issue issue, final IssueResolutionAcceptor acceptor) {
	URI uri = issue.getUriToProblem();
	String className = uri.trimFileExtension().lastSegment();
	String label = String.format("Rename class to '%s'", className);
	acceptor.accept(issue, label, label, null, (element, context) -> {
		context.getXtextDocument().modify(resource -> {
			IRenameElementContext renameContext = renameContextFactory.createRenameElementContext(element, null,
					new TextSelection(context.getXtextDocument(), issue.getOffset(), issue.getLength()), resource);
			final ProcessorBasedRefactoring refactoring = renameRefactoringProvider.getRenameRefactoring(renameContext);
			((RenameElementProcessor) refactoring.getProcessor()).setNewName(className);
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, monitor -> {
				try {
					if (!refactoring.checkFinalConditions(monitor).isOK())
						return;
					Change change = refactoring.createChange(monitor);
					change.initializeValidationData(monitor);
					PerformChangeOperation performChangeOperation = new PerformChangeOperation(change);
					performChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), refactoring.getName());
					performChangeOperation.setSchedulingRule(ResourcesPlugin.getWorkspace().getRoot());
					performChangeOperation.run(monitor);
				} catch (CoreException e) {
					logger.error(e);
				}
			});
			return null;
		});
	});
}
 
@Override
public void run(IProgressMonitor pm) throws CoreException {
	try {
		pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$
		pm.subTask(""); //$NON-NLS-1$

		final RefactoringStatus status= fRefactoring.checkAllConditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
		if (status.getSeverity() >= fStopSeverity) {
			final boolean[] canceled= { false };
			if (fForked) {
				fParent.getDisplay().syncExec(new Runnable() {
					@Override
					public void run() {
						canceled[0]= showStatusDialog(status);
					}
				});
			} else {
				canceled[0]= showStatusDialog(status);
			}
			if (canceled[0]) {
				throw new OperationCanceledException();
			}
		}

		fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
		fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));

		fPerformChangeOperation= new PerformChangeOperation(fChange);//RefactoringUI.createUIAwareChangeOperation(fChange);
		fPerformChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName());
		if (fRefactoring instanceof IScheduledRefactoring)
			fPerformChangeOperation.setSchedulingRule(((IScheduledRefactoring)fRefactoring).getSchedulingRule());

		if (!fForked || fForkChangeExecution)
			fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
	} finally {
		pm.done();
	}
}
 
public static void startCutRefactoring(final Object[] elements, final Shell shell) throws InterruptedException, InvocationTargetException {
	JavaDeleteProcessor processor= new JavaDeleteProcessor(elements);
	processor.setSuggestGetterSetterDeletion(false);
	processor.setQueries(new ReorgQueries(shell));
	Refactoring refactoring= new DeleteRefactoring(processor);
	int stopSeverity= RefactoringCore.getConditionCheckingFailedSeverity();
	new RefactoringExecutionHelper(refactoring, stopSeverity, RefactoringSaveHelper.SAVE_NOTHING, shell, new ProgressMonitorDialog(shell)).perform(false, false);
}
 
public void run(IProgressMonitor pm) throws CoreException {
	try {
		pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$
		pm.subTask(""); //$NON-NLS-1$

		final RefactoringStatus status= fRefactoring.checkAllConditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
		if (status.getSeverity() >= fStopSeverity) {
			final boolean[] canceled= { false };
			if (fForked) {
				fParent.getDisplay().syncExec(new Runnable() {
					public void run() {
						canceled[0]= showStatusDialog(status);
					}
				});
			} else {
				canceled[0]= showStatusDialog(status);
			}
			if (canceled[0]) {
				throw new OperationCanceledException();
			}
		}

		fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
		fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));

		fPerformChangeOperation= new PerformChangeOperation(fChange);//RefactoringUI.createUIAwareChangeOperation(fChange);
		fPerformChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName());
		if (fRefactoring instanceof IScheduledRefactoring)
			fPerformChangeOperation.setSchedulingRule(((IScheduledRefactoring)fRefactoring).getSchedulingRule());

		if (!fForked || fForkChangeExecution)
			fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
	} finally {
		pm.done();
	}
}
 
/**
 * Deconfigures the classpath of the project after refactoring.
 *
 * @param monitor
 *            the progress monitor to use
 * @throws CoreException
 *             if an error occurs while deconfiguring the classpath
 */
private void deconfigureClasspath(final IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask(JarImportMessages.JarImportWizard_cleanup_import, 300);
		if (fJavaProject != null) {
			final IClasspathEntry[] entries= fJavaProject.readRawClasspath();
			final boolean changed= deconfigureClasspath(entries, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
			final RefactoringHistory history= getRefactoringHistory();
			final boolean valid= history != null && !history.isEmpty();
			if (valid)
				RefactoringCore.getUndoManager().flush();
			if (valid || changed)
				fJavaProject.setRawClasspath(entries, changed, new SubProgressMonitor(monitor, 60, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
		}
		if (fSourceFolder != null) {
			final IFileStore store= EFS.getStore(fSourceFolder.getRawLocationURI());
			if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
				store.delete(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
			fSourceFolder.delete(true, false, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
			fSourceFolder.clearHistory(new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
			fSourceFolder= null;
		}
		if (fJavaProject != null) {
			try {
				fJavaProject.getResource().refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
			} catch (CoreException exception) {
				JavaPlugin.log(exception);
			}
		}
	} finally {
		fJavaProject= null;
		monitor.done();
	}
}
 
public void run(Shell parent) throws InterruptedException, InvocationTargetException {
	IRunnableContext context= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	fCopyProcessor.setNewNameQueries(new NewNameQueries(parent));
	fCopyProcessor.setReorgQueries(new ReorgQueries(parent));
	CopyRefactoring refactoring= new CopyRefactoring(fCopyProcessor);
	new RefactoringExecutionHelper(refactoring, RefactoringCore.getConditionCheckingFailedSeverity(), fCopyProcessor.getSaveMode(), parent, context).perform(false, false);
}
 
private void performSaveActions(IFile file, IDocument document, IProgressMonitor monitor,
		IPreferenceStore preferenceStore) {
	boolean runFormat = preferenceStore.getBoolean(TypeScriptUIPreferenceConstants.EDITOR_SAVE_ACTIONS_FORMAT);
	SubMonitor progress = SubMonitor.convert(monitor, (runFormat ? 10 : 0));
	if (!runFormat) {
		return;
	}

	IUndoManager manager = RefactoringCore.getUndoManager();

	CompositeChange saveActionsChange = new CompositeChange("Save Actions");
	List<Change> undoChanges = new ArrayList<>();
	boolean success = false;
	try {
		manager.aboutToPerformChange(saveActionsChange);

		// Format the file contents
		if (runFormat) {
			TextFileChange change = new TextFileChange("Format", file);
			try {
				IIDETypeScriptProject tsProject = TypeScriptResourceUtil.getTypeScriptProject(file.getProject());
				final IIDETypeScriptFile tsFile = tsProject.openFile(file, document);
				List<CodeEdit> codeEdits = tsFile.format(0, document.getLength()).get();
				change.setEdit(DocumentUtils.toTextEdit(codeEdits, document));
				change.initializeValidationData(new NullProgressMonitor());
				PerformChangeOperation performChangeOperation = new PerformChangeOperation(change);
				ResourcesPlugin.getWorkspace().run(performChangeOperation, progress.newChild(10));
				Change undoChange = performChangeOperation.getUndoChange();
				if (undoChange != null) {
					undoChanges.add(undoChange);
				}
			} catch (Exception e) {
				JSDTTypeScriptUIPlugin.log(e);
			}
		}

		success = true;
	} finally {
		manager.changePerformed(saveActionsChange, success);
	}

	// Add an undo change if possible
	if (!undoChanges.isEmpty()) {
		manager.addUndo(saveActionsChange.getName(), new CompositeChange(saveActionsChange.getName(),
				undoChanges.toArray(new Change[undoChanges.size()])));
	}
}
 
源代码17 项目: typescript.java   文件: RenameSupport.java
/**
 * Executes the rename refactoring without showing a dialog to gather
 * additional user input (for example the new name of the
 * <tt>IJavaElement</tt>). Only an error dialog is shown (if necessary) to
 * present the result of the refactoring's full precondition checking.
 * <p>
 * The method has to be called from within the UI thread.
 * </p>
 *
 * @param parent
 *            a shell used as a parent for the error dialog.
 * @param context
 *            a {@link IRunnableContext} to execute the operation.
 *
 * @throws InterruptedException
 *             if the operation has been canceled by the user.
 * @throws InvocationTargetException
 *             if an error occurred while executing the operation.
 *
 * @see #openDialog(Shell)
 * @see IRunnableContext#run(boolean, boolean,
 *      org.eclipse.jface.operation.IRunnableWithProgress)
 */
public void perform(Shell parent, IRunnableContext context) throws InterruptedException, InvocationTargetException {
	try {
		ensureChecked();
		if (fPreCheckStatus.hasFatalError()) {
			showInformation(parent, fPreCheckStatus);
			return;
		}

		RenameSelectionState state = createSelectionState();

		RefactoringExecutionHelper helper = new RefactoringExecutionHelper(fRefactoring,
				RefactoringCore.getConditionCheckingFailedSeverity(), getTypeScriptRenameProcessor().getSaveMode(),
				parent, context);
		helper.perform(true, true);

		restoreSelectionState(state);
	} catch (CoreException e) {
		throw new InvocationTargetException(e);
	}
}
 
/**
 * {@inheritDoc}
 */
@Override
protected RefactoringContext createRefactoringContext(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor) throws CoreException {
	Assert.isNotNull(descriptor);

	createNecessarySourceCode(monitor);

	if (descriptor instanceof JavaRefactoringDescriptor) {
		JavaRefactoringDescriptor javaDescriptor= (JavaRefactoringDescriptor) descriptor;
		RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());

		Map<String, String> map= contribution.retrieveArgumentMap(descriptor);
		if (fJavaProject == null) {
			status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
			return null;
		}

		String name= fJavaProject.getElementName();

		String handle= map.get(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
		if (handle != null && handle.length() > 0)
			map.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, getTransformedHandle(name, handle));

		int count= 1;
		String attribute= JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
		while ((handle= map.get(attribute)) != null) {
			if (handle.length() > 0)
				map.put(attribute, getTransformedHandle(name, handle));
			count++;
			attribute= JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
		}

		// create adapted descriptor
		try {
			descriptor= contribution.createDescriptor(descriptor.getID(), name, descriptor.getDescription(), descriptor.getComment(), map, descriptor.getFlags());
		} catch (IllegalArgumentException e) {
			status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
			return null;
		}
	}
	return descriptor.createRefactoringContext(status);
}
 
public void run(Shell parent) throws InterruptedException, InvocationTargetException {
	IRunnableContext context= new ProgressMonitorDialog(parent);
	new RefactoringExecutionHelper(fPasteRefactoring, RefactoringCore.getConditionCheckingFailedSeverity(), RefactoringSaveHelper.SAVE_NOTHING, parent, context).perform(false, false);
}
 
private void xmlReadRefactoring(JarPackageData jarPackage, Element element) throws java.io.IOException {
	if (element.getNodeName().equals("storedRefactorings")) { //$NON-NLS-1$
		jarPackage.setExportStructuralOnly(getBooleanAttribute(element, "structuralOnly", jarPackage.isExportStructuralOnly())); //$NON-NLS-1$
		jarPackage.setDeprecationAware(getBooleanAttribute(element, "deprecationInfo", jarPackage.isDeprecationAware())); //$NON-NLS-1$
		List<IAdaptable> elements= new ArrayList<IAdaptable>();
		int count= 1;
		String value= element.getAttribute("project" + count); //$NON-NLS-1$
		while (value != null && !"".equals(value)) { //$NON-NLS-1$
			final IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(value);
			if (project.exists())
				elements.add(project);
			count++;
			value= element.getAttribute("project" + count); //$NON-NLS-1$
		}
		jarPackage.setRefactoringProjects(elements.toArray(new IProject[elements.size()]));
		elements.clear();
		count= 1;
		IRefactoringHistoryService service= RefactoringCore.getHistoryService();
		try {
			service.connect();
			value= element.getAttribute("refactoring" + count); //$NON-NLS-1$
			while (value != null && !"".equals(value)) { //$NON-NLS-1$
				final ByteArrayInputStream stream= new ByteArrayInputStream(value.getBytes("UTF-8")); //$NON-NLS-1$
				try {
					final RefactoringHistory history= service.readRefactoringHistory(stream, RefactoringDescriptor.NONE);
					if (history != null) {
						final RefactoringDescriptorProxy[] descriptors= history.getDescriptors();
						if (descriptors.length > 0) {
							for (int index= 0; index < descriptors.length; index++) {
								elements.add(descriptors[index]);
							}
						}
					}
				} catch (CoreException exception) {
					JavaPlugin.log(exception);
				}
				count++;
				value= element.getAttribute("refactoring" + count); //$NON-NLS-1$
			}
		} finally {
			service.disconnect();
		}
		jarPackage.setRefactoringDescriptors(elements.toArray(new RefactoringDescriptorProxy[elements.size()]));
	}
}