Skip to content

Instantly share code, notes, and snippets.

@suxiaogang
Last active December 15, 2015 15:39
Show Gist options
  • Save suxiaogang/5283711 to your computer and use it in GitHub Desktop.
Save suxiaogang/5283711 to your computer and use it in GitHub Desktop.
IResource rename in plugin development
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 performChangeOperation = new PerformChangeOperation(operation);
try {
performChangeOperation.run(null);
} catch (CoreException e) {
return false;
}
return true;
} //org.eclipse.ltk.core.refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment