Search in sources :

Example 6 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification in project webtools.sourceediting by eclipse.

the class XSDSimpleTypeSection method handleWidgetSelection.

private void handleWidgetSelection(SelectionEvent e) {
    if (e.widget == typesCombo) {
        IEditorPart editor = getActiveEditor();
        if (editor == null)
            return;
        ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class);
        String selection = typesCombo.getText();
        ComponentSpecification newValue;
        IComponentDialog dialog = null;
        if (selection.equals(Messages._UI_COMBO_BROWSE)) {
            dialog = manager.getBrowseDialog();
            ((XSDSearchListDialogDelegate) dialog).showComplexTypes(false);
        } else if (selection.equals(Messages._UI_COMBO_NEW)) {
            dialog = manager.getNewDialog();
            ((NewTypeDialog) dialog).allowComplexType(false);
        }
        if (dialog != null) {
            if (dialog.createAndOpen() == Window.OK) {
                newValue = dialog.getSelectedComponent();
                manager.modifyComponentReference(input, newValue);
            }
        } else // use the value from selected quickPick item
        {
            newValue = getComponentSpecFromQuickPickForValue(selection, manager);
            if (newValue != null)
                manager.modifyComponentReference(input, newValue);
        }
    } else if (e.widget == varietyCombo) {
        if (input != null) {
            if (input instanceof XSDSimpleTypeDefinition) {
                XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input;
                Element parent = st.getElement();
                String variety = varietyCombo.getText();
                if (variety.equals(XSDVariety.ATOMIC_LITERAL.getName())) {
                    // $NON-NLS-1$
                    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON"));
                    st.setVariety(XSDVariety.ATOMIC_LITERAL);
                    // $NON-NLS-1$
                    addCreateElementActionIfNotExist(XSDConstants.RESTRICTION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_RESTRICTION"), parent, null);
                } else if (variety.equals(XSDVariety.UNION_LITERAL.getName())) {
                    // $NON-NLS-1$
                    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES"));
                    st.setVariety(XSDVariety.UNION_LITERAL);
                    // $NON-NLS-1$
                    addCreateElementActionIfNotExist(XSDConstants.UNION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_UNION"), parent, null);
                } else if (variety.equals(XSDVariety.LIST_LITERAL.getName())) {
                    // $NON-NLS-1$
                    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE"));
                    st.setVariety(XSDVariety.LIST_LITERAL);
                    // $NON-NLS-1$
                    addCreateElementActionIfNotExist(XSDConstants.LIST_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LIST"), parent, null);
                }
            }
        }
    }
}
Also used : IComponentDialog(org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog) XSDComplexTypeBaseTypeEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) 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 7 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification in project webtools.sourceediting by eclipse.

the class XSDElementDeclarationAdvancedSection method handleWidgetSelection.

private void handleWidgetSelection(SelectionEvent e) {
    if (e.widget == blockCombo) {
        XSDElementDeclaration eleDec = (XSDElementDeclaration) input;
        String value = blockCombo.getText();
        UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.BLOCK_ATTRIBUTE, value, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_BLOCK);
        command.setDeleteIfEmpty(true);
        getCommandStack().execute(command);
    } else if (e.widget == finalCombo) {
        XSDElementDeclaration eleDec = (XSDElementDeclaration) input;
        String value = finalCombo.getText();
        UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.FINAL_ATTRIBUTE, value, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_FINAL);
        command.setDeleteIfEmpty(true);
        getCommandStack().execute(command);
    } else if (e.widget == abstractCombo) {
        XSDElementDeclaration eleDec = (XSDElementDeclaration) input;
        String value = abstractCombo.getText();
        UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.ABSTRACT_ATTRIBUTE, value, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_ABSTRACT);
        command.setDeleteIfEmpty(true);
        getCommandStack().execute(command);
    } else if (e.widget == substGroupCombo) {
        IEditorPart editor = getActiveEditor();
        if (editor == null)
            return;
        ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDSubstitutionGroupEditManager.class);
        String selection = substGroupCombo.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 {
                substGroupCombo.setText("");
            }
        } else // use the value from selected quickPick item
        {
            newValue = getComponentSpecFromQuickPickForValue(selection, manager);
            if (newValue != null)
                manager.modifyComponentReference(input, newValue);
        }
    } else if (e.widget == nillableCombo) {
        XSDElementDeclaration eleDec = (XSDElementDeclaration) input;
        String value = nillableCombo.getText();
        UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.NILLABLE_ATTRIBUTE, value, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_NILLABLE);
        command.setDeleteIfEmpty(true);
        getCommandStack().execute(command);
    }
}
Also used : IComponentDialog(org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog) UpdateAttributeValueCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeValueCommand) 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)

Example 8 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification in project webtools.sourceediting by eclipse.

the class ReferenceDirectEditManager method performModify.

public void performModify(Object value) {
    ComponentReferenceEditManager editManager = getComponentReferenceEditManager();
    if (editManager == null) {
        return;
    }
    // 
    if (value instanceof String) {
        value = getComponentSpecificationForValue((String) value);
    }
    // 
    if (value instanceof ComponentSpecification) {
        // we need to perform an asyncExec here since the 'host' editpart may be
        // removed as a side effect of performing the action
        DelayedSetReferenceRunnable runnable = new DelayedSetReferenceRunnable(editManager, setObject, (ComponentSpecification) value);
        // runnable.run();
        Display.getCurrent().asyncExec(runnable);
    }
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)

Example 9 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification in project webtools.sourceediting by eclipse.

the class BuiltInTypesTreeViewerProvider method getAllBuiltInTypes.

public static List getAllBuiltInTypes() {
    List items = new ArrayList();
    // for (int i = 0; i < XSDDOMHelper.dataType.length; i++) {
    // items.add(XSDDOMHelper.dataType[i][0]);
    // }
    Iterator it = items.iterator();
    List mainContainer = new ArrayList(BUILT_IN_TYPES_SUB_GROUP);
    ComponentSpecification header = new ComponentSpecification("", "Root", null);
    mainContainer.add(header);
    List numbersGroup = new ArrayList();
    header = new ComponentSpecification("", "Numbers", null);
    numbersGroup.add(header);
    mainContainer.add(numbersGroup);
    List dateAndTimeGroup = new ArrayList();
    header = new ComponentSpecification("", "Date and Time", null);
    dateAndTimeGroup.add(header);
    mainContainer.add(dateAndTimeGroup);
    List otherGroup = new ArrayList();
    header = new ComponentSpecification("", "Other", null);
    otherGroup.add(header);
    mainContainer.add(otherGroup);
    while (it.hasNext()) {
        Object item = it.next();
        String name = item.toString();
        ComponentSpecification builtInTypeItem = new ComponentSpecification(name, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, null);
        // if this built-In Type is in Number group
        if (partOf(name, numberTypes)) {
            // Set parent
            // builtInTypeItem.addAttributeInfo(CONST_PARENT, numbersGroup);
            numbersGroup.add(builtInTypeItem);
        } else // if this built-In Type is in Date-and-Time group
        if (partOf(name, dateAndTimeTypes)) {
            // builtInTypeItem.addAttributeInfo(CONST_PARENT, dateAndTimeGroup);
            dateAndTimeGroup.add(builtInTypeItem);
        } else // otherwise, put in Other group
        {
            // builtInTypeItem.addAttributeInfo(CONST_PARENT, otherGroup);
            otherGroup.add(builtInTypeItem);
        }
    }
    return mainContainer;
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification in project webtools.sourceediting by eclipse.

the class NewAttributeDialog method getSelectedComponent.

public ComponentSpecification getSelectedComponent() {
    ComponentSpecification componentSpecification = new ComponentSpecification(null, getName(), null);
    componentSpecification.setMetaName(IXSDSearchConstants.ATTRIBUTE_META_NAME);
    componentSpecification.setNew(true);
    return componentSpecification;
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification)

Aggregations

ComponentSpecification (org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification)28 ComponentReferenceEditManager (org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)15 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)7 List (java.util.List)7 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)5 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 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)3 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)2 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)2 Iterator (java.util.Iterator)1 IFile (org.eclipse.core.resources.IFile)1 Path (org.eclipse.core.runtime.Path)1