Search in sources :

Example 6 with Annotation

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

the class AnnotationHelper method getAnnotations.

public static Collection<Annotation> getAnnotations(ObeoDSMObject dsmObject, String name) {
    Collection<Annotation> annotations = new ArrayList<Annotation>();
    MetaDataContainer metaDataContainer = dsmObject.getMetadatas();
    if (metaDataContainer != null) {
        for (MetaData metaData : metaDataContainer.getMetadatas()) {
            if (metaData instanceof Annotation) {
                Annotation annotation = (Annotation) metaData;
                if (name.equals(annotation.getTitle())) {
                    annotations.add(annotation);
                }
            }
        }
    }
    return annotations;
}
Also used : MetaData(org.obeonetwork.dsl.environment.MetaData) ArrayList(java.util.ArrayList) MetaDataContainer(org.obeonetwork.dsl.environment.MetaDataContainer) Annotation(org.obeonetwork.dsl.environment.Annotation)

Example 7 with Annotation

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

the class AnnotationHelper method getAllConstraints.

public static Collection<String> getAllConstraints(ObeoDSMObject dsmObject) {
    Collection<String> constraints = new ArrayList<String>();
    Collection<Annotation> constraintsAnnotations = getAllPhysicalCheckAnnotations(dsmObject);
    for (Annotation constraintAnnotation : constraintsAnnotations) {
        if (constraintAnnotation.getBody() != null && constraintAnnotation.getBody().trim().length() > 0) {
            // Use the separator to check if several constraints were defined in this annotation
            String[] definedConstraints = constraintAnnotation.getBody().split(CONSTRAINT_DELIMITER_REGEX);
            for (String definedConstraint : definedConstraints) {
                if (definedConstraint != null && definedConstraint.trim().length() > 0) {
                    constraints.add(definedConstraint);
                }
            }
        }
    }
    return constraints;
}
Also used : ArrayList(java.util.ArrayList) Annotation(org.obeonetwork.dsl.environment.Annotation)

Example 8 with Annotation

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

the class DocumentationLinkType method loadLinks.

/**
 * {@inheritDoc}
 * @see org.obeonetwork.tools.linker.LinkType#loadLinks(org.eclipse.emf.ecore.EObject)
 */
public List<EObjectLink> loadLinks(EObject source) {
    if (source instanceof ObeoDSMObject) {
        ObeoDSMObject element = (ObeoDSMObject) source;
        MetaDataContainer metadatas = element.getMetadatas();
        if (metadatas != null) {
            List<EObjectLink> result = new ArrayList<EObjectLink>();
            for (MetaData metadata : metadatas.getMetadatas()) {
                if (metadata instanceof Annotation) {
                    Annotation annotation = (Annotation) metadata;
                    if (annotation.getTitle() != null && annotation.getTitle().startsWith(DocumentationLink.DOCUMENTATION_ANNOTATION_TITLE)) {
                        DocumentationLink link = new DocumentationLinkImpl(annotation);
                        result.add(link);
                    }
                }
            }
            return result;
        }
    }
    return Collections.emptyList();
}
Also used : MetaData(org.obeonetwork.dsl.environment.MetaData) DocumentationLink(org.obeonetwork.tools.doc.core.DocumentationLink) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) EObjectLink(org.obeonetwork.tools.linker.EObjectLink) ArrayList(java.util.ArrayList) MetaDataContainer(org.obeonetwork.dsl.environment.MetaDataContainer) Annotation(org.obeonetwork.dsl.environment.Annotation)

Example 9 with Annotation

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

the class AnnotationPropertiesEditionComponent 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 Annotation annotation = (Annotation) elt;
        final AnnotationPropertiesEditionPart annotationPart = (AnnotationPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.Annotation.Properties.title_))
            annotationPart.setTitle_(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, annotation.getTitle()));
        if (isAccessible(EnvironmentViewsRepository.Annotation.Properties.body))
            annotationPart.setBody(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, annotation.getBody()));
    // init filters
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : AnnotationPropertiesEditionPart(org.obeonetwork.dsl.environment.parts.AnnotationPropertiesEditionPart) Annotation(org.obeonetwork.dsl.environment.Annotation)

Aggregations

Annotation (org.obeonetwork.dsl.environment.Annotation)9 MetaDataContainer (org.obeonetwork.dsl.environment.MetaDataContainer)5 ArrayList (java.util.ArrayList)3 MetaData (org.obeonetwork.dsl.environment.MetaData)3 EObject (org.eclipse.emf.ecore.EObject)2 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)2 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Image (org.eclipse.swt.graphics.Image)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2