Search in sources :

Example 21 with StructuredType

use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.

the class ReferenceSpec method setContainingType.

public void setContainingType(StructuredType newType) {
    if (newType != eInternalContainer() || (eContainerFeatureID() != EnvironmentPackage.REFERENCE__CONTAINING_TYPE && newType != null)) {
        if (EcoreUtil.isAncestor(this, newType))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null) {
            msgs = eBasicRemoveFromContainer(msgs);
        }
        if (newType != null) {
            msgs = ((InternalEObject) newType).eInverseAdd(this, EnvironmentPackage.STRUCTURED_TYPE__OWNED_REFERENCES, StructuredType.class, msgs);
        }
        msgs = eBasicSetContainer((InternalEObject) newType, EnvironmentPackage.REFERENCE__CONTAINING_TYPE, msgs);
        if (msgs != null) {
            msgs.dispatch();
        } else {
            // We check if the oppositeOf is still consistent
            if (getOppositeOf() != null && !newType.isSubtypeOf(getOppositeOf().getReferencedType())) {
                setOppositeOf(null);
            }
        }
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, EnvironmentPackage.REFERENCE__CONTAINING_TYPE, newType, newType));
}
Also used : NotificationChain(org.eclipse.emf.common.notify.NotificationChain) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) InternalEObject(org.eclipse.emf.ecore.InternalEObject) StructuredType(org.obeonetwork.dsl.environment.StructuredType)

Example 22 with StructuredType

use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.

the class ReferenceReferencePropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        editingPart.setContext(elt, allResource);
        final Reference reference = (Reference) elt;
        final ReferencePropertiesEditionPart referencePart = (ReferencePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.name))
            referencePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, reference.getName()));
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.referencedType)) {
            // init part
            referencedTypeSettings = new EObjectFlatComboSettings(reference, EnvironmentPackage.eINSTANCE.getReference_ReferencedType());
            referencePart.initReferencedType(referencedTypeSettings);
            // set the button mode
            referencePart.setReferencedTypeButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.multiplicity)) {
            referencePart.initMultiplicity(EEFUtils.choiceOfValues(reference, EnvironmentPackage.eINSTANCE.getProperty_Multiplicity()), reference.getMultiplicity());
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.isComposite)) {
            referencePart.setIsComposite(reference.isIsComposite());
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.navigable)) {
            referencePart.setNavigable(reference.isNavigable());
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.oppositeOf)) {
            // init part
            oppositeOfSettings = new EObjectFlatComboSettings(reference, EnvironmentPackage.eINSTANCE.getReference_OppositeOf());
            referencePart.initOppositeOf(oppositeOfSettings);
            // set the button mode
            referencePart.setOppositeOfButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.identifier)) {
            referencePart.setIdentifier(reference.isIsIdentifier());
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.description))
            referencePart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, reference.getDescription()));
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.referencedType)) {
            referencePart.addFilterToReferencedType(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    return (element instanceof StructuredType);
                }
            });
        // Start of user code for additional businessfilters for referencedType
        // End of user code
        }
        if (isAccessible(EnvironmentViewsRepository.Reference.Properties.oppositeOf)) {
            referencePart.addFilterToOppositeOf(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof Reference);
                }
            });
        // Start of user code for additional businessfilters for oppositeOf
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : ReferencePropertiesEditionPart(org.obeonetwork.dsl.environment.parts.ReferencePropertiesEditionPart) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Reference(org.obeonetwork.dsl.environment.Reference) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) StructuredType(org.obeonetwork.dsl.environment.StructuredType)

Aggregations

StructuredType (org.obeonetwork.dsl.environment.StructuredType)22 ArrayList (java.util.ArrayList)11 Reference (org.obeonetwork.dsl.environment.Reference)9 EObject (org.eclipse.emf.ecore.EObject)8 HashSet (java.util.HashSet)5 Attribute (org.obeonetwork.dsl.environment.Attribute)3 Type (org.obeonetwork.dsl.environment.Type)3 HashMap (java.util.HashMap)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 BindingInfo (org.obeonetwork.dsl.environment.BindingInfo)2 DataType (org.obeonetwork.dsl.environment.DataType)2 Enumeration (org.obeonetwork.dsl.environment.Enumeration)2 Namespace (org.obeonetwork.dsl.environment.Namespace)2 Collator (java.text.Collator)1 LinkedHashSet (java.util.LinkedHashSet)1 NotificationChain (org.eclipse.emf.common.notify.NotificationChain)1 EClass (org.eclipse.emf.ecore.EClass)1