Search in sources :

Example 1 with IComponentDialog

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

the class SetBaseTypeAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
        boolean complexType = selection instanceof XSDComplexTypeDefinition;
        boolean simpleType = selection instanceof XSDSimpleTypeDefinition;
        if (complexType || simpleType) {
            if (getWorkbenchPart() instanceof IEditorPart) {
                IEditorPart editor = (IEditorPart) getWorkbenchPart();
                ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class);
                ComponentSpecification newValue;
                IComponentDialog dialog = null;
                dialog = manager.getBrowseDialog();
                if (dialog != null) {
                    if (simpleType) {
                        ((XSDSearchListDialogDelegate) dialog).showComplexTypes(false);
                    }
                    if (dialog.createAndOpen() == Window.OK) {
                        newValue = dialog.getSelectedComponent();
                        manager.modifyComponentReference(selection, newValue);
                    }
                }
            }
        }
    }
}
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) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSearchListDialogDelegate(org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate)

Example 2 with IComponentDialog

use of org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog 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 3 with IComponentDialog

use of org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog 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 4 with IComponentDialog

use of org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog 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 5 with IComponentDialog

use of org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog 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)

Aggregations

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