use of org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange in project che by eclipse.
the class JavaMoveProcessor method createChange.
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
Assert.isTrue(fMovePolicy.getJavaElementDestination() == null || fMovePolicy.getResourceDestination() == null);
Assert.isTrue(fMovePolicy.getJavaElementDestination() != null || fMovePolicy.getResourceDestination() != null);
try {
final DynamicValidationStateChange result = new DynamicValidationStateChange(RefactoringCoreMessages.JavaMoveProcessor_change_name) {
@Override
public ChangeDescriptor getDescriptor() {
return fMovePolicy.getDescriptor();
}
@Override
public Change perform(IProgressMonitor pm2) throws CoreException {
Change change = super.perform(pm2);
Change[] changes = getChildren();
for (int index = 0; index < changes.length; index++) {
if (!(changes[index] instanceof TextEditBasedChange))
return null;
}
return change;
}
};
CreateTargetExecutionLog log = null;
if (fCreateTargetQueries instanceof MonitoringCreateTargetQueries) {
final MonitoringCreateTargetQueries queries = (MonitoringCreateTargetQueries) fCreateTargetQueries;
final ICreateTargetQueries delegate = queries.getDelegate();
if (delegate instanceof LoggedCreateTargetQueries)
log = queries.getCreateTargetExecutionLog();
}
if (log != null) {
final Object[] selected = log.getSelectedElements();
for (int index = 0; index < selected.length; index++) {
result.add(new LoggedCreateTargetChange(selected[index], fCreateTargetQueries));
}
}
Change change = fMovePolicy.createChange(pm);
if (change instanceof CompositeChange) {
CompositeChange subComposite = (CompositeChange) change;
result.merge(subComposite);
} else {
result.add(change);
}
return result;
} finally {
pm.done();
}
}
use of org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange in project che by eclipse.
the class RenameCompilationUnitProcessor method createChange.
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
// renaming the file is taken care of in renameTypeRefactoring
if (fWillRenameType)
return fRenameTypeProcessor.createChange(pm);
fRenameTypeProcessor = null;
final String newName = getNewElementName();
final IResource resource = fCu.getResource();
if (resource != null && resource.isLinked()) {
final IProject project = resource.getProject();
final String name = project.getName();
final String description = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description_short, BasicElementLabels.getResourceName(resource.getName()));
final String header = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description, new String[] { BasicElementLabels.getPathLabel(resource.getFullPath(), false), BasicElementLabels.getResourceName(resource.getName()) });
final String comment = new JDTRefactoringDescriptorComment(name, this, header).asString();
final int flags = RefactoringDescriptor.STRUCTURAL_CHANGE;
final RenameResourceDescriptor descriptor = (RenameResourceDescriptor) RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID).createDescriptor();
descriptor.setProject(name);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(flags);
descriptor.setResourcePath(resource.getFullPath());
descriptor.setNewName(newName);
RenameResourceChange resourceChange = new RenameResourceChange(resource.getFullPath(), newName);
resourceChange.setDescriptor(new RefactoringChangeDescriptor(descriptor));
return new DynamicValidationStateChange(resourceChange);
}
String label = JavaElementLabels.getTextLabel(fCu, JavaElementLabels.ALL_FULLY_QUALIFIED);
final String name = fCu.getJavaProject().getElementName();
final String description = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description_short, BasicElementLabels.getFileName(fCu));
final String header = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description, new String[] { label, BasicElementLabels.getResourceName(newName) });
final String comment = new JDTRefactoringDescriptorComment(name, this, header).asString();
final int flags = RefactoringDescriptor.STRUCTURAL_CHANGE;
final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_COMPILATION_UNIT);
descriptor.setProject(name);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(flags);
descriptor.setJavaElement(fCu);
descriptor.setNewName(newName);
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenameCompilationUnitRefactoring_name, new Change[] { new RenameCompilationUnitChange(fCu, newName) });
}
Aggregations