use of org.eclipse.wst.xsd.ui.internal.refactor.PerformUnsavedRefactoringOperation in project webtools.sourceediting by eclipse.
the class UpdateNameCommand method renameComponent.
/**
* Performs a rename refactoring to rename the component and all the
* references to it within the current schema.
*
* @param newName the new component name.
*/
private void renameComponent(String newName) {
// this is a 'globally' defined component (e.g. global element)
if (component.eContainer() instanceof XSDSchema) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow != null) {
IWorkbenchPage page = workbenchWindow.getActivePage();
if (page != null) {
IEditorInput editorInput = page.getActiveEditor().getEditorInput();
if (editorInput instanceof FileEditorInput) {
RefactoringComponent refactoringComponent = new XMLRefactoringComponent(component, (IDOMElement) component.getElement(), component.getName(), component.getTargetNamespace());
RenameComponentProcessor processor = new RenameComponentProcessor(refactoringComponent, newName, true);
RenameRefactoring refactoring = new RenameRefactoring(processor);
PerformUnsavedRefactoringOperation operation = new PerformUnsavedRefactoringOperation(refactoring);
operation.run(null);
} else {
// We can't refactor rename external files
component.setName(newName);
}
}
}
} else {
// this is a 'locally' defined component (e.g. local element)
// no need to call refactoring since this component can't be referenced
component.setName(newName);
}
}
Aggregations