use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.
the class JSPTypeMoveParticipant method createChange.
/*
* (non-Javadoc)
*
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
*/
public Change createChange(IProgressMonitor pm) throws CoreException {
if (pm != null && pm.isCanceled()) {
return null;
}
CompositeChange multiChange = null;
Object dest = getArguments().getDestination();
if (dest instanceof IPackageFragment) {
Change[] changes = JSPTypeMoveChange.createChangesFor(fType, ((IPackageFragment) dest).getElementName());
if (changes.length > 0) {
multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
}
}
return multiChange;
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.
the class JSPMoveParticipant method createChange.
/**
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(
* org.eclipse.core.runtime.IProgressMonitor)
*/
public Change createChange(IProgressMonitor pm) throws CoreException {
// $NON-NLS-1$
this.getTextChange("");
// create one multi change to contain all new created changes
CompositeChange multiChange = new CompositeChange(JSPUIMessages.JSP_changes);
// for each element get the changes for it and add it to the multi change
Iterator iter = fElementAndArgumentPairs.values().iterator();
while (iter.hasNext()) {
ElementAndArgumentsPair elemArgsPair = (ElementAndArgumentsPair) iter.next();
Object dest = elemArgsPair.fArgs.getDestination();
if (dest instanceof IPackageFragment) {
Change[] changes = createChangesFor(elemArgsPair.fElement, ((IPackageFragment) dest).getElementName(), pm);
/* add all new text changes to the local list of text changes so that
* future iterations through the while loop will be aware of already
* existing changes
*/
for (int i = 0; i < changes.length; ++i) {
if (changes[i] instanceof TextChange) {
fLocalTextChanges.put(((TextChange) changes[i]).getModifiedElement(), changes[i]);
}
}
if (changes.length > 0) {
multiChange.addAll(changes);
}
}
}
// unless there are actually new changes return null
Change result = null;
if (multiChange.getChildren().length > 0) {
result = multiChange;
}
return result;
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.
the class PerformUnsavedRefactoringOperation method run.
public void run(IProgressMonitor pm) {
if (pm == null) {
pm = new NullProgressMonitor();
}
try {
refactoring.checkAllConditions(pm);
Change change = refactoring.createChange(pm);
if (change instanceof CompositeChange) {
CompositeChange compositeChange = (CompositeChange) change;
setSaveMode(compositeChange);
}
change.perform(pm);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project che by eclipse.
the class DeleteResourcesProcessor method createChange.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
*/
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
pm.beginTask(RefactoringCoreMessages.DeleteResourcesProcessor_create_task, fResources.length);
try {
RefactoringChangeDescriptor descriptor = new RefactoringChangeDescriptor(createDescriptor());
CompositeChange change = new CompositeChange(RefactoringCoreMessages.DeleteResourcesProcessor_change_name);
change.markAsSynthetic();
for (int i = 0; i < fResources.length; i++) {
pm.worked(1);
DeleteResourceChange dc = new DeleteResourceChange(fResources[i].getFullPath(), true, fDeleteContents);
dc.setDescriptor(descriptor);
change.add(dc);
}
return change;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project che by eclipse.
the class RenamePackageProcessor method postCreateChange.
@Override
public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException {
if (fQualifiedNameSearchResult != null) {
CompositeChange parent = (CompositeChange) fRenamePackageChange.getParent();
try {
/*
* Sneak text changes in before the package rename to ensure
* modified files are still at original location (see
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=154238)
*/
parent.remove(fRenamePackageChange);
parent.add(fQualifiedNameSearchResult.getSingleChange(Changes.getModifiedFiles(participantChanges)));
} finally {
fQualifiedNameSearchResult = null;
parent.add(fRenamePackageChange);
fRenamePackageChange = null;
}
}
return null;
}
Aggregations