use of org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor in project che by eclipse.
the class RenameResourceProcessor method createDescriptor.
protected RenameResourceDescriptor createDescriptor() {
IResource resource = getResource();
RenameResourceDescriptor descriptor = new RenameResourceDescriptor();
descriptor.setProject(resource instanceof IProject ? null : resource.getProject().getName());
descriptor.setDescription(Messages.format(RefactoringCoreMessages.RenameResourceProcessor_description, BasicElementLabels.getResourceName(resource)));
descriptor.setComment(Messages.format(RefactoringCoreMessages.RenameResourceProcessor_comment, new String[] { BasicElementLabels.getPathLabel(resource.getFullPath(), false), BasicElementLabels.getResourceName(getNewResourceName()) }));
descriptor.setFlags(RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE);
descriptor.setResourcePath(resource.getFullPath());
descriptor.setNewName(getNewResourceName());
descriptor.setUpdateReferences(isUpdateReferences());
return descriptor;
}
use of org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor in project che by eclipse.
the class RenameResourceRefactoringContribution method retrieveArgumentMap.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.RefactoringContribution#retrieveArgumentMap(org.eclipse.ltk.core.refactoring.RefactoringDescriptor)
*/
public Map retrieveArgumentMap(final RefactoringDescriptor descriptor) {
HashMap map = new HashMap();
if (descriptor instanceof RenameResourceDescriptor) {
RenameResourceDescriptor resourceDescriptor = (RenameResourceDescriptor) descriptor;
map.put(ATTRIBUTE_INPUT, ResourceProcessors.resourcePathToHandle(descriptor.getProject(), resourceDescriptor.getResourcePath()));
map.put(ATTRIBUTE_NAME, resourceDescriptor.getNewName());
//$NON-NLS-1$//$NON-NLS-2$
map.put(ATTRIBUTE_UPDATE_REFERENCES, resourceDescriptor.isUpdateReferences() ? "true" : "false");
return map;
}
return null;
}
use of org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor 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) });
}
use of org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor in project che by eclipse.
the class RenameResourceRefactoringContribution method createDescriptor.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.RefactoringContribution#createDescriptor(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Map, int)
*/
public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment, Map arguments, int flags) {
String pathString = (String) arguments.get(ATTRIBUTE_INPUT);
String newName = (String) arguments.get(ATTRIBUTE_NAME);
//$NON-NLS-1$
boolean updateReferences = "true".equals(arguments.get(ATTRIBUTE_UPDATE_REFERENCES));
if (pathString != null && newName != null) {
IPath path = ResourceProcessors.handleToResourcePath(project, pathString);
RenameResourceDescriptor descriptor = new RenameResourceDescriptor();
descriptor.setProject(project);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(flags);
descriptor.setNewName(newName);
descriptor.setResourcePath(path);
descriptor.setUpdateReferences(updateReferences);
return descriptor;
}
//$NON-NLS-1$
throw new IllegalArgumentException("Can not restore RenameResourceDescriptor from map");
}
Aggregations