Search in sources :

Example 21 with XSDComponent

use of org.eclipse.xsd.XSDComponent in project tmdm-studio-se by Talend.

the class XSDEditFacetAction method doAction.

@Override
public IStatus doAction() {
    try {
        IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof XSDSimpleTypeDefinition) {
            std = (XSDSimpleTypeDefinition) selection.getFirstElement();
        } else {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDSimpleTypeDefinition) {
                    std = (XSDSimpleTypeDefinition) (tPath.getSegment(i));
                }
            }
        }
        /**
         * totalDigits, fractionDigits, maxInclusive, maxExclusive, minInclusive, minExclusive
         */
        if (facetName.equals("pattern")) {
            // $NON-NLS-1$
            editPattern();
        } else if (facetName.equals("enumeration")) {
            // $NON-NLS-1$
            editEnumeration();
        } else if (facetName.equals("length")) {
            // $NON-NLS-1$
            editLength();
        } else if (facetName.equals("minLength")) {
            // $NON-NLS-1$
            editMinLength();
        } else if (facetName.equals("maxLength")) {
            // $NON-NLS-1$
            editMaxLength();
        } else if (facetName.equals("totalDigits")) {
            // $NON-NLS-1$
            editTotalDigits();
        } else if (facetName.equals("fractionDigits")) {
            // $NON-NLS-1$
            editFractionDigits();
        } else if (facetName.equals("maxInclusive")) {
            // $NON-NLS-1$
            editMaxInclusive();
        } else if (facetName.equals("maxExclusive")) {
            // $NON-NLS-1$
            editMaxExclusive();
        } else if (facetName.equals("minInclusive")) {
            // $NON-NLS-1$
            editMinInclusive();
        } else if (facetName.equals("minExclusive")) {
            // $NON-NLS-1$
            editMinExclusive();
        } else if (facetName.equals("whiteSpace")) {
            // $NON-NLS-1$
            editWhiteSpace();
        } else {
            MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditFacetAction_ErrorMsg1, facetName));
            return Status.CANCEL_STATUS;
        }
        std.updateElement();
        page.getTreeViewer().refresh(true);
        page.markDirty();
        page.refresh();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditFacetAction_ErrorMsg2, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDComponent(org.eclipse.xsd.XSDComponent)

Aggregations

XSDComponent (org.eclipse.xsd.XSDComponent)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 TreePath (org.eclipse.jface.viewers.TreePath)14 XSDAnnotationsStructure (com.amalto.workbench.utils.XSDAnnotationsStructure)13 TreeSelection (org.eclipse.jface.viewers.TreeSelection)13 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)13 Element (org.w3c.dom.Element)13 ArrayList (java.util.ArrayList)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 SelectionListener (org.eclipse.swt.events.SelectionListener)5 AnnotationLanguageLabelsDialog (com.amalto.workbench.dialogs.AnnotationLanguageLabelsDialog)4 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)4 AnnotationOrderedListsDialog (com.amalto.workbench.dialogs.AnnotationOrderedListsDialog)3 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)3 Iterator (java.util.Iterator)2 XSDParticle (org.eclipse.xsd.XSDParticle)2 XSDSchema (org.eclipse.xsd.XSDSchema)2 DataModelMainPage (com.amalto.workbench.editors.DataModelMainPage)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IInputValidator (org.eclipse.jface.dialogs.IInputValidator)1