use of org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor in project che by eclipse.
the class RenameResourceDescriptor method createRefactoring.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.RefactoringDescriptor#createRefactoring(org.eclipse.ltk.core.refactoring.RefactoringStatus)
*/
public Refactoring createRefactoring(RefactoringStatus status) throws CoreException {
IPath resourcePath = getResourcePath();
if (resourcePath == null) {
status.addFatalError(RefactoringCoreMessages.RenameResourceDescriptor_error_path_not_set);
return null;
}
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath);
if (resource == null || !resource.exists()) {
status.addFatalError(Messages.format(RefactoringCoreMessages.RenameResourceDescriptor_error_resource_not_existing, BasicElementLabels.getPathLabel(resourcePath, false)));
return null;
}
String newName = getNewName();
if (newName == null || newName.length() == 0) {
status.addFatalError(RefactoringCoreMessages.RenameResourceDescriptor_error_name_not_defined);
return null;
}
RenameResourceProcessor processor = new RenameResourceProcessor(resource);
processor.setNewResourceName(newName);
processor.setUpdateReferences(isUpdateReferences());
return new RenameRefactoring(processor);
}
use of org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor in project tdi-studio-se by Talend.
the class ChangeProjectTechinicalNameMigrationTask method renameProject.
/**
*
* DOC ggu Comment method "renameProject".
*
* @param localProject
* @param newProjectName
* @return
*/
@SuppressWarnings("restriction")
protected boolean renameProject(IProject localProject, String newProjectName) {
RenameResourceProcessor renameProcessor = new RenameResourceProcessor(localProject);
renameProcessor.setNewResourceName(newProjectName);
CheckConditionsOperation condictionOperation = new CheckConditionsOperation(new RenameRefactoring(renameProcessor), CheckConditionsOperation.FINAL_CONDITIONS);
CreateChangeOperation operation = new CreateChangeOperation(condictionOperation, RefactoringCore.getConditionCheckingFailedSeverity());
PerformChangeOperation performChangeOp = new PerformChangeOperation(operation);
try {
performChangeOp.run(null);
} catch (CoreException e) {
ExceptionHandler.process(e);
return false;
}
return true;
}
use of org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor in project xtext-xtend by eclipse.
the class AbstractXtendRenameRefactoringTest method renameTo.
protected IFile renameTo(IFile file, String newFileName, IProgressMonitor monitor) throws OperationCanceledException, CoreException {
RenameResourceProcessor renameResourceProcessor = new RenameResourceProcessor(file);
renameResourceProcessor.setNewResourceName(newFileName);
RenameRefactoring renameRefactoring = new RenameRefactoring(renameResourceProcessor);
renameRefactoring.checkAllConditions(monitor);
Change change = renameRefactoring.createChange(monitor);
workspace.run(new ICoreRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
change.perform(monitor);
}
}, monitor);
IResource newFile = testHelper.getProject().findMember(new Path("src/" + newFileName));
assertTrue(newFile.exists());
assertTrue(newFile instanceof IFile);
return (IFile) newFile;
}
use of org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor in project mdw-designer by CenturyLinkCloud.
the class WorkflowProjectManager method renameRemoteProject.
public static void renameRemoteProject(WorkflowProject workflowProject, String newName) {
if (!workflowProject.isRemote())
throw new RuntimeException("Can only rename remote projects");
try {
deRegisterProject(workflowProject);
IProject workflowSourceProject = workflowProject.getSourceProject();
if (workflowSourceProject != null && workflowSourceProject.exists()) {
RenameResourceProcessor renameProc = new RenameResourceProcessor(workflowSourceProject);
renameProc.setNewResourceName(newName);
RenameRefactoring refactoring = new RenameRefactoring(renameProc);
refactoring.checkAllConditions(new NullProgressMonitor());
Change change = refactoring.createChange(new NullProgressMonitor());
change.perform(new NullProgressMonitor());
}
workflowProject.setSourceProjectName(newName);
registerProject(workflowProject);
} catch (CoreException ex) {
// fail silently since older remote projects don't have physical
// counterparts
PluginMessages.log(ex);
}
}
Aggregations