Search in sources :

Example 1 with UpdateAttributeReferenceAndManagerDirectivesCommand

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();
        }
    }
}
Also used : AddXSDAttributeDeclarationCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeDeclarationCommand) UpdateAttributeReferenceCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceCommand) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) UpdateAttributeReferenceAndManagerDirectivesCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceAndManagerDirectivesCommand) UpdateAttributeReferenceCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceCommand) Command(org.eclipse.gef.commands.Command) AddXSDAttributeDeclarationCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeDeclarationCommand) Adapter(org.eclipse.emf.common.notify.Adapter) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) UpdateAttributeReferenceAndManagerDirectivesCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceAndManagerDirectivesCommand)

Aggregations

Adapter (org.eclipse.emf.common.notify.Adapter)1 Command (org.eclipse.gef.commands.Command)1 AddXSDAttributeDeclarationCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeDeclarationCommand)1 UpdateAttributeReferenceAndManagerDirectivesCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceAndManagerDirectivesCommand)1 UpdateAttributeReferenceCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceCommand)1 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1