Search in sources :

Example 16 with ComponentSpecification

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

the class NewElementDialog method getSelectedComponent.

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

Example 17 with ComponentSpecification

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

the class ReferenceDirectEditManager method getComponentSpecificationForValue.

protected ComponentSpecification getComponentSpecificationForValue(String value) {
    ComponentReferenceEditManager editManager = getComponentReferenceEditManager();
    if (editManager != null) {
        ComponentSpecification[] quickPicks = editManager.getQuickPicks();
        if (quickPicks != null) {
            for (int i = 0; i < quickPicks.length; i++) {
                ComponentSpecification componentSpecification = quickPicks[i];
                if (value.equals(componentSpecification.getName())) {
                    return componentSpecification;
                }
            }
        }
        ComponentSpecification[] history = editManager.getHistory();
        if (history != null) {
            for (int i = 0; i < history.length; i++) {
                ComponentSpecification componentSpecification = history[i];
                if (value.equals(componentSpecification.getName())) {
                    return componentSpecification;
                }
            }
        }
    }
    return null;
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)

Example 18 with ComponentSpecification

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

the class ReferenceDirectEditManager method computeComboContent.

protected List computeComboContent() {
    List list = new ArrayList();
    ComponentReferenceEditManager editManager = getComponentReferenceEditManager();
    if (editManager != null) {
        list.add(Messages._UI_COMBO_BROWSE);
        list.add(Messages._UI_COMBO_NEW);
        ComponentSpecification[] quickPicks = editManager.getQuickPicks();
        if (quickPicks != null) {
            for (int i = 0; i < quickPicks.length; i++) {
                ComponentSpecification componentSpecification = quickPicks[i];
                list.add(componentSpecification.getName());
            }
        }
        ComponentSpecification[] history = editManager.getHistory();
        if (history != null) {
            for (int i = 0; i < history.length; i++) {
                ComponentSpecification componentSpecification = history[i];
                list.add(componentSpecification.getName());
            }
        }
    }
    return list;
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)

Example 19 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification 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 20 with ComponentSpecification

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification 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)

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