use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceAndManagerDirectivesCommand in project webtools.sourceediting by eclipse.
the class XSDAttributeReferenceEditManager method modifyComponentReference.
public void modifyComponentReference(Object referencingObject, ComponentSpecification referencedComponent) {
XSDAttributeDeclaration concreteComponent = null;
if (referencingObject instanceof Adapter) {
Adapter adapter = (Adapter) referencingObject;
if (adapter.getTarget() instanceof XSDAttributeDeclaration) {
concreteComponent = (XSDAttributeDeclaration) adapter.getTarget();
}
} else if (referencingObject instanceof XSDConcreteComponent) {
concreteComponent = (XSDAttributeDeclaration) referencingObject;
}
if (concreteComponent != null) {
if (referencedComponent.isNew()) {
XSDAttributeDeclaration attributeDec = null;
if (referencedComponent.getMetaName() == IXSDSearchConstants.ATTRIBUTE_META_NAME) {
AddXSDAttributeDeclarationCommand command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, concreteComponent.getSchema());
command.setNameToAdd(referencedComponent.getName());
command.execute();
attributeDec = (XSDAttributeDeclaration) command.getAddedComponent();
}
if (attributeDec != null) {
Command command = new UpdateAttributeReferenceCommand(Messages._UI_ACTION_UPDATE_ATTRIBUTE_REFERENCE, concreteComponent, attributeDec);
command.execute();
}
XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
} else {
Command command = new UpdateAttributeReferenceAndManagerDirectivesCommand(concreteComponent, referencedComponent.getName(), referencedComponent.getQualifier(), referencedComponent.getFile());
command.setLabel(Messages._UI_ACTION_UPDATE_ATTRIBUTE_REFERENCE);
command.execute();
}
}
}
Aggregations