use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateElementReferenceAndManageDirectivesCommand in project webtools.sourceediting by eclipse.
the class XSDElementReferenceEditManager method modifyComponentReference.
// TODO not changed yet
public void modifyComponentReference(Object referencingObject, ComponentSpecification component) {
XSDElementDeclaration concreteComponent = null;
if (referencingObject instanceof Adapter) {
Adapter adapter = (Adapter) referencingObject;
if (adapter.getTarget() instanceof XSDElementDeclaration) {
concreteComponent = (XSDElementDeclaration) adapter.getTarget();
}
} else if (referencingObject instanceof XSDConcreteComponent) {
concreteComponent = (XSDElementDeclaration) referencingObject;
}
if (concreteComponent != null) {
if (component.isNew()) {
XSDElementDeclaration elementDec = null;
if (component.getMetaName() == IXSDSearchConstants.ELEMENT_META_NAME) {
AddXSDElementCommand command = new AddXSDElementCommand(Messages._UI_ACTION_ADD_ELEMENT, concreteComponent.getSchema());
command.setNameToAdd(component.getName());
command.execute();
elementDec = (XSDElementDeclaration) command.getAddedComponent();
}
if (elementDec != null) {
Command command = new UpdateElementReferenceCommand(Messages._UI_ACTION_UPDATE_ELEMENT_REFERENCE, concreteComponent, elementDec);
command.execute();
}
XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
} else {
Command command = new UpdateElementReferenceAndManageDirectivesCommand(concreteComponent, component.getName(), component.getQualifier(), component.getFile());
command.setLabel(Messages._UI_ACTION_UPDATE_ELEMENT_REFERENCE);
command.execute();
}
}
}
Aggregations