Search in sources :

Example 11 with ComponentReferenceEditManager

use of org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager in project webtools.sourceediting by eclipse.

the class XSDComplexTypeSection method handleWidgetSelection.

private void handleWidgetSelection(SelectionEvent e) {
    if (e.widget == baseTypeCombo) {
        IEditorPart editor = getActiveEditor();
        if (editor == null)
            return;
        ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class);
        String selection = baseTypeCombo.getText();
        ComponentSpecification newValue;
        IComponentDialog dialog = null;
        if (selection.equals(Messages._UI_COMBO_BROWSE)) {
            dialog = manager.getBrowseDialog();
        } else if (selection.equals(Messages._UI_COMBO_NEW)) {
            dialog = manager.getNewDialog();
        }
        if (dialog != null) {
            if (dialog.createAndOpen() == Window.OK) {
                newValue = dialog.getSelectedComponent();
                manager.modifyComponentReference(input, newValue);
            } else {
                refresh();
            }
        }
    } else if (e.widget == derivedByCombo) {
        XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
        String value = derivedByCombo.getText();
        Command command = new UpdateComplexTypeDerivationBy(complexType, value);
        if (getCommandStack() != null) {
            getCommandStack().execute(command);
        }
    }
    super.doWidgetSelected(e);
}
Also used : IComponentDialog(org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog) XSDComplexTypeBaseTypeEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IEditorPart(org.eclipse.ui.IEditorPart) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) UpdateComplexTypeDerivationBy(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateComplexTypeDerivationBy)

Example 12 with ComponentReferenceEditManager

use of org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager in project webtools.sourceediting by eclipse.

the class XSDElementDeclarationSection method fillElementsCombo.

private void fillElementsCombo() {
    IEditorPart editor = getActiveEditor();
    ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDElementReferenceEditManager.class);
    if (manager != null) {
        componentNameCombo.removeAll();
        componentNameCombo.add(Messages._UI_COMBO_BROWSE);
        componentNameCombo.add(Messages._UI_COMBO_NEW);
        ComponentSpecification[] quickPicks = manager.getQuickPicks();
        if (quickPicks != null) {
            for (int i = 0; i < quickPicks.length; i++) {
                ComponentSpecification componentSpecification = quickPicks[i];
                componentNameCombo.add(componentSpecification.getName());
            }
        }
        ComponentSpecification[] history = manager.getHistory();
        if (history != null) {
            for (int i = 0; i < history.length; i++) {
                ComponentSpecification componentSpecification = history[i];
                componentNameCombo.add(componentSpecification.getName());
            }
        }
    }
    XSDElementDeclaration namedComponent = (XSDElementDeclaration) input;
    Element element = namedComponent.getElement();
    if (element != null) {
        String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE);
        if (attrValue == null) {
            // $NON-NLS-1$
            attrValue = "";
        }
        ComponentSpecification ret = getComponentSpecFromQuickPickForValue(attrValue, manager);
        if (ret == null) {
            componentNameCombo.add(attrValue);
        }
        componentNameCombo.setText(attrValue);
    }
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Element(org.w3c.dom.Element) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IEditorPart(org.eclipse.ui.IEditorPart) XSDElementReferenceEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDElementReferenceEditManager)

Example 13 with ComponentReferenceEditManager

use of org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager in project webtools.sourceediting by eclipse.

the class XSDElementDeclarationSection method handleWidgetSelection.

private void handleWidgetSelection(SelectionEvent e) {
    if (e.widget == typeCombo) {
        IEditorPart editor = getActiveEditor();
        if (editor == null)
            return;
        ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
        String selection = typeCombo.getText();
        ComponentSpecification newValue;
        IComponentDialog dialog = null;
        if (selection.equals(Messages._UI_COMBO_BROWSE)) {
            dialog = manager.getBrowseDialog();
            ((XSDSearchListDialogDelegate) dialog).showComplexTypes(true);
        } else if (selection.equals(Messages._UI_COMBO_NEW)) {
            dialog = manager.getNewDialog();
            ((NewTypeDialog) dialog).allowComplexType(true);
        }
        if (dialog != null) {
            if (dialog.createAndOpen() == Window.OK) {
                newValue = dialog.getSelectedComponent();
                XSDElementDeclaration elementDeclaration = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
                manager.modifyComponentReference(elementDeclaration, newValue);
            } else {
                typeCombo.setText(typeName);
            }
        } else // use the value from selected quickPick item
        {
            newValue = getComponentSpecFromQuickPickForValue(selection, manager);
            if (newValue != null)
                manager.modifyComponentReference(input, newValue);
        }
    } else if (e.widget == componentNameCombo) {
        IEditorPart editor = getActiveEditor();
        if (editor == null)
            return;
        ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDElementReferenceEditManager.class);
        String selection = componentNameCombo.getText();
        ComponentSpecification newValue;
        IComponentDialog dialog = null;
        if (selection.equals(Messages._UI_COMBO_BROWSE)) {
            dialog = manager.getBrowseDialog();
        } else if (selection.equals(Messages._UI_COMBO_NEW)) {
            dialog = manager.getNewDialog();
        }
        if (dialog != null) {
            if (dialog.createAndOpen() == Window.OK) {
                newValue = dialog.getSelectedComponent();
                manager.modifyComponentReference(input, newValue);
            } else {
                componentNameCombo.setText("");
            }
        } else // use the value from selected quickPick item
        {
            newValue = getComponentSpecFromQuickPickForValue(selection, manager);
            if (newValue != null)
                manager.modifyComponentReference(input, newValue);
        }
    } else if (e.widget == maxCombo) {
        updateMaxAttribute();
    } else if (e.widget == minCombo) {
        updateMinAttribute();
    }
}
Also used : IComponentDialog(org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog) XSDTypeReferenceEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IEditorPart(org.eclipse.ui.IEditorPart) XSDSearchListDialogDelegate(org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate)

Example 14 with ComponentReferenceEditManager

use of org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager in project webtools.sourceediting by eclipse.

the class XSDSimpleTypeSection method fillTypesCombo.

private void fillTypesCombo() {
    typesCombo.removeAll();
    IEditorPart editor = getActiveEditor();
    ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
    if (manager != null) {
        ComponentSpecification[] items = manager.getQuickPicks();
        typesCombo.add(Messages._UI_COMBO_BROWSE);
        typesCombo.add(Messages._UI_COMBO_NEW);
        for (int i = 0; i < items.length; i++) {
            typesCombo.add(items[i].getName());
        }
        // Add the current Type of this attribute if needed
        XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) input;
        XSDTypeDefinition baseType = simpleType.getBaseType();
        if (baseType != null && baseType.getQName() != null) {
            // no prefix
            String currentTypeName = baseType.getQName(xsdSchema);
            ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
            if (// not in quickPick
            ret == null && currentTypeName != null) {
                typesCombo.add(currentTypeName);
            }
        }
    }
}
Also used : XSDTypeReferenceEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IEditorPart(org.eclipse.ui.IEditorPart) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 15 with ComponentReferenceEditManager

use of org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager in project webtools.sourceediting by eclipse.

the class SetTypeCommand method execute.

public void execute() {
    try {
        beginRecording(parent.getElement());
        ComponentReferenceEditManager componentReferenceEditManager = getComponentReferenceEditManager();
        continueApply = true;
        if (parent instanceof XSDElementDeclaration) {
            if (action.equals(SetTypeAction.SET_NEW_TYPE_ID)) {
                ComponentSpecification newValue = (ComponentSpecification) invokeDialog(componentReferenceEditManager.getNewDialog());
                if (continueApply)
                    componentReferenceEditManager.modifyComponentReference(adapter, newValue);
            } else {
                ComponentSpecification newValue = (ComponentSpecification) invokeDialog(componentReferenceEditManager.getBrowseDialog());
                if (continueApply)
                    componentReferenceEditManager.modifyComponentReference(adapter, newValue);
            }
            formatChild(parent.getElement());
        }
    } finally {
        endRecording();
    }
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)

Aggregations

ComponentReferenceEditManager (org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)19 IEditorPart (org.eclipse.ui.IEditorPart)15 ComponentSpecification (org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification)15 IComponentDialog (org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog)6 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)6 XSDTypeReferenceEditManager (org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager)4 XSDSearchListDialogDelegate (org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate)4 Element (org.w3c.dom.Element)4 XSDComplexTypeBaseTypeEditManager (org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)3 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)2 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)2 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Command (org.eclipse.gef.commands.Command)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 ComponentReferenceEditManager2 (org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager2)1 UpdateAttributeValueCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeValueCommand)1