Search in sources :

Example 1 with ComponentSpecification

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

the class XSDTypeReferenceEditManager method getHistory.

public ComponentSpecification[] getHistory() {
    // TODO (cs) implement this properly - should this history be global or local to each editor?
    // This is something we should play around with ourselves to see what feels right.
    // 
    List list = new ArrayList();
    ComponentSpecification[] result = new ComponentSpecification[list.size()];
    list.toArray(result);
    return result;
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ComponentSpecification

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

the class XSDTypeReferenceEditManager method getQuickPicks.

public ComponentSpecification[] getQuickPicks() {
    if (result != null)
        return result;
    // TODO (cs) implement this properly - we should be providing a list of the
    // most 'common' built in schema types here
    // I believe Trung will be working on a perference page to give us this list
    // for now let's hard code some values
    // 
    List list = new ArrayList();
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "boolean", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "date", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "dateTime", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "double", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "float", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "hexBinary", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "int", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string", null));
    // $NON-NLS-1$
    list.add(new ComponentSpecification(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "time", null));
    result = new ComponentSpecification[list.size()];
    list.toArray(result);
    return result;
}
Also used : ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ComponentSpecification

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

the class AddXSDRedefinableContentAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
    }
    if (selection instanceof XSDRedefine) {
        ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
        configuration.setDescriptionProvider(new RedefineDescriptor());
        configuration.setSearchListProvider(new RedefineSearchListProvider((XSDRedefine) selection, this));
        ComponentSearchListDialog dialog = new ComponentSearchListDialog(Display.getDefault().getActiveShell(), Messages._UI_LABEL_REDEFINE_COMPONENT, configuration) {

            protected Control createDialogArea(Composite parent) {
                // Adjust the dialog's initial size.
                Composite mainComposite = (Composite) super.createDialogArea(parent);
                GridData gridData = (GridData) mainComposite.getLayoutData();
                gridData.heightHint = 500;
                gridData.widthHint = 350;
                return mainComposite;
            }
        };
        dialog.create();
        dialog.setBlockOnOpen(true);
        int result = dialog.open();
        if (result == Window.OK) {
            ComponentSpecification selectedComponent = dialog.getSelectedComponent();
            buildRedefine((XSDRedefine) selection, selectedComponent);
        }
    }
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) ComponentSearchListDialog(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialog) Composite(org.eclipse.swt.widgets.Composite) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) GridData(org.eclipse.swt.layout.GridData) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ComponentSearchListDialogConfiguration(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration)

Example 4 with ComponentSpecification

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

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

the class XSDElementDeclarationSection method fillTypesCombo.

private void fillTypesCombo() {
    IEditorPart editor = getActiveEditor();
    ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
    if (manager != null) {
        ComponentSpecification[] items = manager.getQuickPicks();
        typeCombo.removeAll();
        typeCombo.add(Messages._UI_COMBO_BROWSE);
        typeCombo.add(Messages._UI_COMBO_NEW);
        for (int i = 0; i < items.length; i++) {
            typeCombo.add(items[i].getName());
        }
        // Add the current Type of this element if needed
        XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
        XSDTypeDefinition td = namedComponent.getType();
        if (td != null) {
            String currentTypeName = td.getQName(xsdSchema);
            if (// anonymous type
            currentTypeName == null)
                currentTypeName = "**Anonymous**";
            ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
            if (// not in quickPick
            ret == null && currentTypeName != null) {
                typeCombo.add(currentTypeName);
            }
        }
    }
}
Also used : 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) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

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