use of org.eclipse.wst.xsd.ui.internal.refactor.XMLRefactoringComponent in project webtools.sourceediting by eclipse.
the class RenameHandler method run.
public void run(ISelection selection, XSDSchema schema, XSDNamedComponent selectedComponent) {
if (selectedComponent.getName() == null) {
selectedComponent.setName(new String());
}
if (selectedComponent.getSchema() == null) {
if (schema != null) {
schema.updateElement(true);
}
}
boolean rc = SaveDirtyFilesDialog.saveDirtyFiles();
if (!rc) {
return;
}
RefactoringComponent component = new XMLRefactoringComponent(selectedComponent, (IDOMElement) selectedComponent.getElement(), selectedComponent.getName(), selectedComponent.getTargetNamespace());
RenameComponentProcessor processor = new RenameComponentProcessor(component, selectedComponent.getName());
RenameRefactoring refactoring = new RenameRefactoring(processor);
try {
RefactoringWizard wizard = new RenameRefactoringWizard(refactoring, RefactoringWizardMessages.RenameComponentWizard_defaultPageTitle, RefactoringWizardMessages.RenameComponentWizard_inputPage_description, null);
RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
op.run(XSDEditorPlugin.getShell(), wizard.getDefaultPageTitle());
} catch (InterruptedException e) {
// do nothing. User action got canceled
}
}
use of org.eclipse.wst.xsd.ui.internal.refactor.XMLRefactoringComponent 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);
}
}
use of org.eclipse.wst.xsd.ui.internal.refactor.XMLRefactoringComponent in project webtools.sourceediting by eclipse.
the class RenameComponentAction method run.
public void run(ISelection selection) {
if (selectedComponent.getName() == null) {
selectedComponent.setName(new String());
}
if (selectedComponent.getSchema() == null) {
if (getSchema() != null) {
getSchema().updateElement(true);
}
}
boolean rc = SaveDirtyFilesDialog.saveDirtyFiles();
if (!rc) {
return;
}
RefactoringComponent component = new XMLRefactoringComponent(selectedComponent, (IDOMElement) selectedComponent.getElement(), selectedComponent.getName(), selectedComponent.getTargetNamespace());
RenameComponentProcessor processor = new RenameComponentProcessor(component, selectedComponent.getName());
RenameRefactoring refactoring = new RenameRefactoring(processor);
try {
RefactoringWizard wizard = new RenameRefactoringWizard(refactoring, RefactoringWizardMessages.RenameComponentWizard_defaultPageTitle, RefactoringWizardMessages.RenameComponentWizard_inputPage_description, null);
RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
op.run(XSDEditorPlugin.getShell(), wizard.getDefaultPageTitle());
// TODO (cs) I'm not sure why we need to do this. See bug 145700
// triggerBuild();
} catch (InterruptedException e) {
// do nothing. User action got cancelled
}
}
Aggregations