| // ***************************************************************************** |
| // Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v1.0 |
| // which accompanies this distribution, and is available at |
| // http://www.eclipse.org/legal/epl-v10.html |
| // |
| // Contributors: |
| // Pierre Allard - initial API and implementation |
| // Regent L'Archeveque |
| // Olivier L. Larouche |
| // |
| // SPDX-License-Identifier: EPL-1.0 |
| // ***************************************************************************** |
| @GenModel(prefix="ApogyCommonEMF", |
| copyrightText="******************************************************************************* |
| Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| All rights reserved. This program and the accompanying materials |
| are made available under the terms of the Eclipse Public License v1.0 |
| which accompanies this distribution, and is available at |
| http://www.eclipse.org/legal/epl-v10.html |
| |
| Contributors: |
| Pierre Allard - initial API and implementation |
| Regent L'Archeveque, |
| Olivier L. Larouche |
| |
| SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************", |
| childCreationExtenders="true", |
| suppressGenModelAnnotations="false", |
| extensibleProviderFactory="true", |
| modelName="ApogyCommonEMF") |
| @GenModel(dynamicTemplates="true", templateDirectory="platform:/plugin/org.eclipse.apogy.common.emf.codegen/templates") |
| @GenModel(modelDirectory="/org.eclipse.apogy.common.emf/src-gen") |
| @GenModel(editDirectory="/org.eclipse.apogy.common.emf.edit/src-gen") |
| |
| package org.eclipse.apogy.common.emf |
| |
| import java.util.HashMap |
| import java.util.List |
| import org.eclipse.core.resources.IFile |
| import org.eclipse.emf.common.notify.Adapter |
| import org.eclipse.emf.common.notify.Notification |
| import org.eclipse.emf.common.util.EList |
| import org.eclipse.emf.common.util.URI |
| import org.eclipse.emf.ecore.EAnnotation |
| import org.eclipse.emf.ecore.EClass |
| import org.eclipse.emf.ecore.EDate |
| import org.eclipse.emf.ecore.EObject |
| import org.eclipse.emf.ecore.EOperation |
| import org.eclipse.emf.ecore.EParameter |
| import org.eclipse.emf.ecore.EReference |
| import org.eclipse.emf.ecore.EStructuralFeature |
| import org.eclipse.emf.ecore.ETypedElement |
| import org.eclipse.emf.ecore.resource.Resource |
| import org.eclipse.emf.ecore.resource.ResourceSet |
| import org.eclipse.apogy.common.Apogy |
| import org.eclipse.emf.ecore.EModelElement |
| |
| // Types. |
| |
| type Exception wraps java.lang.Exception |
| type List < T > wraps java.util.List |
| type SortedSet < T > wraps java.util.SortedSet |
| type EClassFilter wraps EClassFilter |
| type Number wraps java.lang.Number |
| type IFile wraps IFile |
| type Resource wraps Resource |
| type Unit wraps javax.measure.unit.Unit<?> |
| type Collection<T> wraps java.util.Collection |
| type EList<EObject> wraps EList |
| type URI wraps URI |
| type Job wraps org.eclipse.core.runtime.jobs.Job |
| type ResourceSet wraps ResourceSet |
| type ListNamed wraps List<? extends Named> |
| type ListFeature wraps List<? extends EStructuralFeature> |
| type Adapter wraps Adapter |
| type Notification wraps Notification |
| type HashMap<key, value> wraps HashMap |
| |
| /** |
| * Facade for Common EMF. |
| */ |
| @Apogy(isSingleton="true", hasCustomClass="true") |
| class ApogyCommonEMFFacade |
| { |
| /** |
| * The date format string used for representing date as string. |
| */ |
| String dateFormatString = "yyyy.MM.dd HH:mm:ss.SSS z" |
| |
| /** |
| * Returns all available EClass currently installed. |
| */ |
| op List<EClass> getAllAvailableEClasses() |
| |
| /** |
| * Returns all the sub classes of the specified super class. The result list contains |
| * only implementation classes (not abstract). |
| * @param superClass Super type of the classes to be found. |
| * @return List of sub classes. |
| */ |
| op List<EClass> getAllSubEClasses(EClass superClass) |
| |
| /** |
| * Applies a filter to a list of EClasses and returns the list of EClass that passes the filter. |
| * @param eClasses The list of EClasses to filter. |
| * @param filter The filter to apply. |
| * @return The list of EClass that passes the filter. Never null, can be empty. |
| */ |
| op List<EClass> filterEClasses(List<EClass> eClasses, EClassFilter filter) |
| |
| /** |
| * Applies a list of filters to a list of EClasses and returns the list of EClass that passes all the filtesr. |
| * @param eClasses The list of EClasses to filter. |
| * @param filters The list filters to apply. |
| * @return The list of EClass that passes all the filters. Never null, can be empty. |
| */ |
| op List<EClass> filterEClasses(List<EClass> eClasses, List<EClassFilter> filters) |
| |
| /** |
| * Finds the closest match in a {@link List} of {@link EClass}. |
| * @param eClass reference to the EClass to find the closest match. |
| * @param eClasses list of EClasses to search. |
| * @return {@link EClass} of the closest super class of the specified EClass. |
| */ |
| op EClass findClosestMatch(EClass eClass, List<EClass> eClasses) |
| |
| /** |
| * Returns the {@link EClass} that fits the specified fully qualified name. |
| * @param str Fully qualified name. |
| * @return Reference to the class or null there is no match. |
| */ |
| op EClass getEClass(String str) |
| |
| /** |
| * Sorts a list of EClass alphabetically based on their Instance Class Name. |
| * @param eClasses The list of EClasses to filter. |
| * @return The eClasses sorted alphabetically. |
| */ |
| op SortedSet<EClass> sortAlphabetically(List<EClass> eClasses) |
| |
| /** |
| * Returns the list of EOperation of a given EClass. |
| * @param eClass The EClass. |
| * @return The list of EOperation. |
| */ |
| op List<EOperation> getAllAvailableEOperations(EClass eClass) |
| |
| /** |
| * Sorts a list of EOperation alphabetically based on their name. |
| * @param eOperations The list of EOperation to filter. |
| * @return The eOperations sorted alphabetically. |
| */ |
| op SortedSet<EOperation> sortEOperationsAlphabetically(List<EOperation> eOperations) |
| |
| /** |
| * Gets the documentation associated with a EAnnotation. |
| * @param eAnnotation The EAnnotation. |
| * @return The documentation string. |
| */ |
| op String getDocumentation(EAnnotation eAnnotation) |
| |
| /** |
| * Gets the documentation associated with a EModelElement. |
| * @param eModelElement The EModelElement. |
| * @return The documentation string. |
| */ |
| op String getDocumentation(EModelElement eModelElement) |
| |
| /** |
| * Gets the documentation associated with a EParameter, it includes units and ranges (if available). |
| * @param eParameter The EParameter. |
| * @return The documentation string. |
| */ |
| op String getDocumentation(EParameter eParameter) |
| |
| /** |
| * Returns the EMF GenModel annotation (@GenModel) associated linked to the model element. |
| * |
| * @param Refers the EModelElement. |
| * |
| * @return Returns the EMF annotation of the specified model element. |
| */ |
| op EAnnotation getGenModelEAnnotation(EModelElement eModelElement) |
| |
| /** |
| * Returns the EMF Apogy annotation (@Apogy) associated linked to the model element. |
| * |
| * @param Refers the EModelElement. |
| * |
| * @return Returns the EMF annotation of the specified model element. |
| */ |
| op EAnnotation getApogyEAnnotation(EModelElement eModelElement) |
| |
| /* |
| * Returns the value associated to the key. |
| * @param eAnnotation Annotation that contains key value details. |
| * @param key Detail key to extract the number value from. |
| * @return The value if the eAnnotation is not null and there is a value for |
| * the specified key. |
| */ |
| op String getEAnnotationDetailValue(EAnnotation eAnnotation, String key) |
| |
| /* |
| * Returns 'true' if the value of the specified annotation key is 'true' |
| * otherwise false. If the annotation or the key are not defined, it return |
| * false. |
| * |
| * @param eAnnotation Refers the annotation. |
| * |
| * @param key Refers the Annotation key. |
| * |
| * @return Returns 'true' if the value of the specified annotation key is 'true' |
| * otherwise false. |
| */ |
| op boolean isTrue(EAnnotation eAnnotation, String key) |
| |
| /** |
| * Returns the number value associated to the key. |
| * @param eAnnotation Annotation that contains key, value details. |
| * @param key Detail key to extract the number value from. |
| * @return The value if the eAnnotation is not null and there is a value for |
| * the specified key. |
| */ |
| op Number getEAnnotationDetailNumberValue(EAnnotation eAnnotation, String key) |
| |
| /** |
| * Gets the engineering units string associated with a ETypedElement. |
| * @param eTypedElement The ETypedElement. |
| * @return The engineering units string, null if none is found. |
| */ |
| op String getEngineeringUnitsAsString(ETypedElement eTypedElement) |
| |
| /** |
| * Returns the Unit defined for a specified eTypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return the Unit, or null if none found. |
| */ |
| op Unit getEngineeringUnits(ETypedElement eTypedElement) |
| |
| /** |
| * Returns the expected update rate for a given eTypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The update rate, in seconds, -1 if none is found. |
| */ |
| @Apogy(units="s") |
| op Double getValueUpdateRate(ETypedElement eTypedElement) |
| |
| /** |
| * Returns the OCL expression used to determine if an ETypedElement is within Warning range. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The OCL string. |
| */ |
| op String getWarningOCLExpression(ETypedElement eTypedElement) |
| |
| /** |
| * Returns the OCL expression used to determine if an ETypedElement is within Alarm range. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The OCL string. |
| */ |
| op String getAlarmOCLExpression(ETypedElement eTypedElement) |
| |
| /** |
| * Returns the OCL expression used to determine if an ETypedElement is within OUt-Of-Range range. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The OCL string. |
| */ |
| op String getOutOfRangeOCLExpression(ETypedElement eTypedElement) |
| |
| /** |
| * Return the Warning minimum value for a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The Warning minimum, null if none is found. |
| */ |
| op Number getWarningMinValue(ETypedElement eTypedElement) |
| |
| /** |
| * Return the Warning maximum value for a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The Warning maximum, null if none is found. |
| */ |
| op Number getWarningMaxValue(ETypedElement eTypedElement) |
| |
| /** |
| * Return the Alarm minimum value for a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The Alarm minimum, null if none is found. |
| */ |
| op Number getAlarmMinValue(ETypedElement eTypedElement) |
| |
| /** |
| * Return the Alarm maximum value for a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The Alarm maximum, null if none is found. |
| */ |
| op Number getAlarmMaxValue(ETypedElement eTypedElement) |
| |
| /** |
| * Return the Out-Of-Range minimum value for a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The Out-Of-Range minimum, null if none is found. |
| */ |
| op Number getOutOfRangeMinValue(ETypedElement eTypedElement) |
| |
| /** |
| * Return the Out-Of-Range maximum value for a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return The Out-Of-Range maximum, null if none is found. |
| */ |
| op Number getOutOfRangeMaxValue(ETypedElement eTypedElement) |
| |
| /** |
| * Gets the Ranges associated with a given value for a specified ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @param value The value of the specified ETypedElement. |
| * @return The Ranges in which the value falls, UNKNOWN if none is found. |
| */ |
| op Ranges getRange(ETypedElement eTypedElement, Object value) |
| |
| /** |
| * Gets a string that describes a a given ETypedElement. |
| * @param eTypedElement The specified ETypedElement. |
| * @return A description string. Includes ranges values. |
| */ |
| op String getFullDescription(ETypedElement eTypedElement) |
| |
| /** |
| * Method that return a string representing the |
| * ancestors of the specified AbstractFeatureNode. |
| */ |
| op String getAncestriesString(AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Method that return the root of the tree for a |
| * specified AbstractFeatureNode. |
| */ |
| op AbstractRootNode getFeatureRoot(AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Method that return the list of ancestor of a |
| * specified AbstractFeatureNode, from FeatureRoot to |
| * (and including) the specified AbstractFeatureNode. |
| */ |
| op List<AbstractFeatureNode> getAncestries(AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Method that return the list of descendants of a |
| * specified AbstractFeatureNode, excluding the specified |
| * AbstractFeatureNode. |
| */ |
| op List<AbstractFeatureNode> getDescendants(AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Method that return the list of available child |
| * EStructuralFeature type for a given Node. |
| */ |
| op List<EStructuralFeature> getChildEStructuralFeatures(AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Method that resolve the value of a FeatureNode |
| * for a specified source EObjet. |
| */ |
| op Object resolve(EObject sourceObject, AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Sets the current of a feature of a given EObject to a specified one. |
| * @param sourceObject The object containing the feature to set. |
| * @param abstractFeatureNode The AbstractFeatureNode specifying the feature to set. |
| * @param value The specified value. |
| */ |
| op void setValue(EObject sourceObject, AbstractFeatureNode abstractFeatureNode, Object value) |
| |
| /** |
| * Method that tells whether or not the |
| * FeatureNode is currently accessible for |
| * the specified source EObject. |
| */ |
| op boolean isResolved(EObject sourceObject, AbstractFeatureNode abstractFeatureNode) |
| |
| /** |
| * Gets the leaf (node with nod child) for a given ListRootNode. |
| * @param listRootNode The ListRootNode for which to find the leaf. |
| * @return The leaf node. |
| */ |
| op AbstractFeatureListNode getLeaf(ListRootNode listRootNode) |
| |
| /** |
| * Returns the IFile associated with a specified Resource. |
| * @param resource The specified Ressource. |
| * @return The IFile, null if none is found. |
| */ |
| op IFile getFile(Resource resource) |
| |
| /** |
| * Returns the content contained in the resource. |
| * @param uri Resource uri. |
| * @return Reference to the content. |
| */ |
| op EList<EObject> getContent(URI uri) |
| |
| /** |
| * Returns a sorted set of Timed elements. |
| * @param timedCollection A Collection of Timed elements. |
| * @return The timed elements sorted by date. |
| */ |
| op SortedSet<Timed> sortTimed(Collection<Timed> timedCollection) |
| |
| /** |
| * Returns the time span, in seconds, of a collection of Timed elements. |
| * @param timedCollection A Collection of Timed elements. |
| * @return The time difference between the latest and earliest Timed element in the collection, in seconds. |
| */ |
| @Apogy(units="s") |
| op double getTimeSpan(Collection<Timed> timedCollection) |
| |
| /** |
| * Return an EObject unique ID. |
| * @param eObject The EObject. |
| * @return the unique ID, null if none is found. |
| */ |
| op String getID(EObject eObject) |
| |
| /** |
| * Searches the ResourceSet for an EObject with the specified id. |
| * @param resourceSet Reference to the resourceSet |
| * @param id Object identifier. |
| */ |
| op EObject getEObjectById(ResourceSet resourceSet, String ^id) |
| |
| /** |
| * Searches the content of a specified EObject for children that are of type or sub type of a EClass. |
| * @param rootContainer The root EObject to search from. |
| * @param eClass The EClass. |
| * @return The list of EObject. |
| */ |
| op List<EObject> getEObjectsByType(EObject rootContainer, EClass eClass) |
| |
| /** |
| * Generates and returns a default name for a specific feature container. |
| * @param eContainer The instance of the container. |
| * @param eObject The instance of the object to name. |
| * @param typedElement The typed element containing or referencing the EObject. |
| * @return A unique name. |
| */ |
| op String getDefaultName(EObject eContainer, EObject eObject, ETypedElement typedElement) |
| |
| /** |
| * Returns all the child classes of the specified parent class. The result list contains |
| * only implementation classes (not abstract). |
| * @param parentEClass Type of the class to find child classes. |
| * @return List of child classes. |
| */ |
| op List<EClass> getChildEClasses(EClass parentEClass) |
| |
| /** |
| * Returns a list of all the object's child EReferences that are either empty or a list |
| * @param eObject The parent object |
| * @return List of EReferences that are either empty or a list |
| */ |
| op EList<EReference> getSettableEReferences(EObject eObject) |
| |
| /** |
| * Returns the string representation of the list of {@link Named}. |
| * @param nameds List of named. |
| * @param separator String used to separate the nameds. |
| * @return Reference to the string representation. |
| */ |
| op String toString(ListNamed nameds, String separator) |
| |
| /** |
| * Formats a specified Date as string. Uses the format defined in attribute dateFormatString. |
| * @param date The specified date. |
| * @return A string representation of the specified date. |
| */ |
| op String format(EDate date) |
| |
| /** |
| * Searches for {@link Startable} in the containment hierarchy of an {@link EObject} and stops them if they are running. |
| * @param root |
| */ |
| op void stopAllStartables(EObject root) |
| |
| /** |
| * Serializes an {@link EObject} to obtain a {@link String}. |
| * This methods uses a copy of the {@link EObject}, so it will not be removed for it's ResourceSet. |
| * |
| * @param eObject reference to the EObject to serialize. |
| * @param id id to use as id for the serialized resource. Cannot be null. |
| * @return The EObject serialized. |
| */ |
| op String serializeEObject(EObject eObject, String uriID) |
| |
| /** |
| * Deserializes a {@link String} to obtain an {@link EObject}. |
| * |
| * @param eObject reference to the EObject to serialize. |
| * @param id id to use as id for the serialized resource. Cannot be null. |
| * @return The EObject |
| */ |
| op EObject deserializeString(String str, String uriID) |
| } |
| |
| /** |
| * Reference to an {@link EObject}. |
| */ |
| class EObjectReference |
| { |
| /** |
| * The referred EObject. |
| */ |
| @GenModel(children="true") |
| refers EObject eObject |
| } |
| |
| /* |
| * Named element. |
| */ |
| interface Named |
| { |
| /** |
| * Name of the element. |
| */ |
| String name |
| } |
| |
| /* |
| * Described element. |
| */ |
| interface Described |
| { |
| /** |
| * Description of the element. |
| */ |
| String description |
| } |
| |
| /* |
| * An element that includes a time stamp. |
| */ |
| interface Timed |
| { |
| /** |
| * The time stamp. |
| */ |
| EDate time |
| } |
| |
| /** |
| * Base class of a Server. |
| */ |
| class Server extends Startable |
| { |
| /** |
| * The Job associated with the server. |
| */ |
| readonly transient Job serverJob |
| } |
| |
| /** |
| * Defines an element that has a started status. |
| */ |
| class Startable |
| { |
| /** |
| * Whether or not the element has been started. |
| */ |
| transient boolean started = "false" |
| } |
| |
| /** |
| * This class handles the concept of time duration. It provides methods to process duration |
| * between two {@link Timed} event. It provides methods to express the duration in years, months, |
| * days, minutes, seconds and milliseconds. |
| */ |
| @Apogy(hasCustomClass="true") |
| class Duration |
| { |
| /** |
| * Duration value in ms. |
| */ |
| @Apogy(units="ms") |
| long value |
| |
| /* |
| * Number of days. |
| */ |
| @Apogy(units="day") |
| derived readonly volatile transient byte days |
| |
| /** |
| * Number of hours. |
| */ |
| @Apogy(units="hour") |
| derived readonly volatile transient byte hours |
| |
| /* |
| * Number of minutes. |
| */ |
| @Apogy(units="min") |
| derived readonly volatile transient byte minutes |
| |
| /** |
| * Number of seconds. |
| */ |
| @Apogy(units="s") |
| derived readonly volatile transient byte seconds |
| |
| /* |
| * Number of milliseconds. |
| */ |
| @Apogy(units="ms") |
| derived readonly volatile transient int milliseconds |
| |
| /** |
| * Creates and returns the duration between the {@link firstEvent} and the {@link secondEvent}. |
| * @param firstEvent First {@link Timed} event. |
| * @param secondEvent Second {@link Timed} event. |
| * @return Duration instance. |
| */ |
| op Duration getDuration(Timed firstEvent, Timed secondEvent) |
| } |
| |
| /** |
| * Defines a Timed element that provides time. |
| */ |
| @Apogy(hasCustomClass="true") |
| abstract class TimeSource extends Named, Described, Timed, Disposable |
| { |
| /** |
| * Offset in milliseconds |
| */ |
| @GenModel(notify="true", property="Editable") |
| @Apogy(units="ms") |
| int offset = "0" |
| } |
| |
| /** |
| * Time source that provides a fixed time. |
| */ |
| @Apogy(hasCustomClass="true") |
| class FixedTimeSource extends TimeSource |
| { |
| } |
| |
| /** |
| * Time source that provides the current time. |
| */ |
| @Apogy(hasCustomClass="true") |
| class CurrentTimeSource extends TimeSource |
| { |
| /** |
| * The update period of the time, in milliseconds |
| */ |
| @GenModel(notify="true", property="Editable") |
| @Apogy(units="ms") |
| int updatePeriod = "1000" |
| |
| /** |
| * Whether or not the time source has been paused. |
| */ |
| @GenModel(notify="true", property="Readonly") |
| boolean paused = "false" |
| |
| /** |
| * Pauses the time. |
| */ |
| op void pause() |
| |
| /** |
| * Resumes time update. |
| */ |
| op void resume() |
| } |
| |
| /** |
| * Time source that provides an accelerated time. |
| */ |
| @Apogy(hasCustomClass="true") |
| class BrowseableTimeSource extends TimeSource |
| { |
| /** |
| * The start time. Default to current |
| * time upon creation. |
| */ |
| @GenModel(notify="true", property="Editable") |
| Date startTime |
| |
| /** |
| * The update period of the time. |
| */ |
| @GenModel(notify="true", property="Editable") |
| @Apogy(units="ms") |
| int updatePeriod = "1000" |
| |
| /** |
| * The time acceleration. |
| */ |
| @GenModel(notify="true", property="Editable") |
| float timeAcceration = "10.0" |
| |
| /** |
| * The time direction. |
| */ |
| @GenModel(notify="true", property="Editable") |
| TimeDirection timeDirection |
| |
| /** |
| * Plays time forward. |
| */ |
| op void playForward() |
| |
| /** |
| * Plays time in reverse. |
| */ |
| op void playReverse() |
| |
| /** |
| * Pauses time. |
| */ |
| op void pause() |
| |
| /** |
| * Reset the time to the start time |
| */ |
| op void reset() |
| } |
| |
| /** |
| * Time source that is based on a list of Timed elements. |
| */ |
| @Apogy(hasCustomClass="true", hasCustomItemProvider="true") |
| class CollectionTimedTimeSource extends BrowseableTimeSource |
| { |
| /** |
| * Whether or not to enable time looping when end of list of time is reached. |
| */ |
| boolean loopEnable = "false" |
| |
| /** |
| * The collection of Timed elements. |
| */ |
| @GenModel(property="None") |
| refers transient Timed[0..*] timedsList |
| |
| /** |
| * The current Timed element. |
| */ |
| @GenModel(property="Readonly") |
| refers transient Timed currentTimedElement |
| |
| /** |
| * The earliest date found in the collection of Timed. |
| */ |
| @GenModel(property="Readonly") |
| Date earliestDate |
| |
| /** |
| * The latest date found in the collection of Timed. |
| */ |
| @GenModel(property="Readonly") |
| Date latestDate |
| |
| /** |
| * Jumps to the next Timed element. |
| */ |
| op void jumpToNext() |
| |
| /** |
| * Jumps to the previous Timed element. |
| */ |
| op void jumpToPrevious() |
| } |
| |
| /** |
| * Time direction. |
| */ |
| enum TimeDirection |
| { |
| FORWARD as "Forward" = 0, |
| REVERSE as "Reverse" = 1 |
| } |
| |
| |
| /* ------------------------------------------------------------------------- |
| * Disposable. |
| * ------------------------------------------------------------------------- */ |
| |
| |
| /** |
| * Defines an element that can be disposed of. |
| */ |
| interface Disposable |
| { |
| /** |
| * Method used to dispose of the element. |
| */ |
| op void dispose() |
| } |
| |
| /** |
| * Ranges Definition |
| */ |
| enum Ranges |
| { |
| UNKNOWN as "UNKNOWN" = 0, |
| NOMINAL as "NOMINAL" = 1, |
| WARNING as "WARNING" = 2, |
| ALARM as "ALARM" = 3, |
| OUT_OF_RANGE as "OUT_OF_RANGE" = 4 |
| } |
| |
| /* ------------------------------------------------------------------------- |
| * Feature Tree |
| * ------------------------------------------------------------------------- */ |
| |
| /** |
| * Adapter used to listens to changes to a feature of a source EObject. |
| */ |
| @Apogy(hasCustomClass="true") |
| class FeatureNodeAdapter |
| { |
| /** |
| * The object onto which to apply the FeatureNode. |
| */ |
| refers EObject sourceObject |
| |
| /** |
| * The FeatureNode defining which feature to monitor. |
| */ |
| refers AbstractFeatureNode featureNode |
| |
| /** |
| * The current value of the feature of the sourceObject associated with the FeatureNode. |
| */ |
| Object currentValue |
| |
| /** |
| * Tells whether or not the featureNode is currently resolved. |
| */ |
| boolean resolved = "false" |
| } |
| |
| /** |
| * Base class of all Feature Nodes. This used to refer to a particular feature in an EClass. |
| */ |
| abstract class AbstractFeatureNode |
| { |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is part of a List. |
| */ |
| @Apogy(hasCustomItemProvider="true") |
| abstract class AbstractFeatureListNode extends AbstractFeatureNode |
| { |
| /** |
| * The parent node of this ListNode. |
| */ |
| @GenModel(property="Readonly") |
| container AbstractFeatureListNode[0..1] parent opposite child |
| |
| /** |
| * The child node of this ListNode. |
| */ |
| @GenModel(property="None") |
| contains AbstractFeatureListNode[0..1] child opposite parent |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is part of a Tree. |
| */ |
| @Apogy(hasCustomItemProvider="true") |
| abstract class AbstractFeatureTreeNode extends AbstractFeatureNode |
| { |
| /** |
| * The parent node of this TreeNode. |
| */ |
| @GenModel(property="Readonly") |
| container AbstractFeatureTreeNode[0..1] parent opposite children |
| |
| /** |
| * The children node(s) of this TreeNode. |
| */ |
| @GenModel(property="None") |
| contains AbstractFeatureTreeNode[0..*] children opposite parent |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is a root. |
| */ |
| abstract class AbstractRootNode |
| { |
| /** |
| * The source class. |
| */ |
| @GenModel(notify="true") |
| refers EClass[1] sourceClass |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is the root of a Tree. |
| */ |
| @Apogy(hasCustomItemProvider="true") |
| class TreeRootNode extends AbstractFeatureTreeNode, AbstractRootNode |
| { |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is a node in a Tree. |
| */ |
| @Apogy(hasCustomClass="true", hasCustomItemProvider="true") |
| class TreeFeatureNode extends AbstractFeatureTreeNode, AbstractFeatureSpecifier |
| { |
| |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is the root of a List. |
| */ |
| @Apogy(hasCustomItemProvider="true") |
| class ListRootNode extends AbstractFeatureListNode, AbstractRootNode |
| { |
| } |
| |
| /** |
| * Defines an AbstractFeatureNode that is a node in a List. |
| */ |
| @Apogy(hasCustomClass="true", hasCustomItemProvider="true") |
| class ListFeatureNode extends AbstractFeatureListNode, AbstractFeatureSpecifier |
| { |
| } |
| |
| /** |
| * Class that describes a StructuralFeature of interest. |
| */ |
| abstract class AbstractFeatureSpecifier |
| { |
| /** |
| * The EStructuralFeature that is referred by this FeatureSpecifier. |
| */ |
| @GenModel(notify="true") |
| refers EStructuralFeature[1] structuralFeature |
| |
| /** |
| * Whether or not this FeatureSpecifier refers to a multi-valued feature. |
| */ |
| @GenModel(notify="true") |
| derived transient volatile readonly boolean multiValued = "false" |
| |
| /** |
| * Index of the value if the EStructuralFeature referred |
| * to by this FeatureSpecifier if multi-valued. |
| */ |
| @GenModel(notify="true") |
| int index = "0" |
| } |
| |
| |
| /*------------------------------------------------------------------------- |
| * FeaturePathAdapter |
| * ------------------------------------------------------------------------- */ |
| |
| /** |
| * Class used to put adapters on all the features of a path. |
| * This will work on lists, putting adapters on every element of the list. |
| * |
| * |
| * To use it, create a new instance of FeaturePathAdapterImpl and override |
| * getFeaturePath() and NotifyChanged(Notification msg). |
| * |
| * Then initialize the adapters using init(EObject root) this will try to |
| * put adapters following the features path in the order specified in getFeaturePath(). |
| * |
| * After this, the FeaturePathAdapter, will dynamically add and remove adapters. |
| * |
| * To remove all the adapters, use dispose(). |
| * |
| */ |
| @Apogy(hasCustomClass="true") |
| abstract class FeaturePathAdapter |
| { |
| /** |
| * Needs to be called to initialize the adapters. |
| * @param root first {@link EObject} to add {@link Adapter} to. |
| */ |
| op void init(EObject root) |
| |
| /** |
| * Removes all the adapters. |
| */ |
| op void dispose() |
| |
| /** |
| * Is called to initialize the features to listen with the adapters that will be created. |
| * This list needs to be in the order of containment starting with the root. |
| */ |
| op ListFeature getFeaturePath() |
| |
| // FIXME Document this. |
| op ListFeature getFeatureList() |
| |
| /** |
| * Is called when an object in the featurePath has a notifyChanged called on a feature in the featurePath. |
| */ |
| op void notifyChanged(Notification msg) |
| } |
| |
| /** |
| * Class used to keep track of EObject and feature. Used by FeaturePathAdapter. |
| */ |
| class FeaturePathAdapterEntry |
| { |
| /** |
| * The notifier. |
| */ |
| refers EObject notifier |
| |
| /** |
| * The feature of the notifier. |
| */ |
| refers EStructuralFeature feature |
| |
| /** |
| * The Adapter used. |
| */ |
| Adapter adapter |
| } |
| |
| |
| /* ------------------------------------------------------------------------- |
| * Comparators |
| * ------------------------------------------------------------------------- */ |
| |
| /** |
| * Defines a generic Comparator Interface that implements the java.util.Comparator. |
| */ |
| interface IComparator<T> wraps java.util.Comparator |
| { |
| /* |
| * Compares two objects. |
| * @see java.util.Comparator |
| */ |
| op int compare(T o1, T o2) |
| } |
| |
| /** |
| * Base class of all Comparators. |
| */ |
| @Apogy(hasCustomClass="true") |
| abstract class EComparator<T> extends IComparator<T>, Named |
| { |
| } |
| |
| /** |
| * Defines a composite comparator that uses a list of Comparator to compare two objects. |
| * This comparator compare(T o1, T o2) method iterates over it list of comparator until |
| * one that does not return equality is found. |
| */ |
| @Apogy(hasCustomClass="true") |
| class CompositeComparator<T> extends EComparator<T> |
| { |
| /** |
| * The list of comparator used. |
| */ |
| contains IComparator<T>[1..*] comparators |
| } |
| |
| /** |
| * Comparator that compares EObject based on their generated Id. |
| */ |
| @Apogy(hasCustomClass="true") |
| class EIdComparator<T extends EObject> extends EComparator<T> |
| { |
| } |
| |
| /* ------------------------------------------------------------------------- |
| * Comparators |
| * ------------------------------------------------------------------------- */ |
| |
| /** |
| * Comparator for Timed. |
| */ |
| @Apogy(hasCustomClass="true") |
| class TimedComparator<T extends Timed> extends EComparator<T> |
| { |
| } |
| |
| /** |
| * Comparator for Named. |
| */ |
| @Apogy(hasCustomClass="true") |
| class NamedComparator<T extends Named> extends EComparator<T> |
| { |
| |
| } |
| |
| /* ------------------------------------------------------------------------- |
| * Filters |
| * ------------------------------------------------------------------------- */ |
| |
| /** |
| * A class that defines a filtering function. |
| */ |
| @Apogy(hasCustomClass="true") |
| abstract class IFilter<T> extends Named |
| { |
| /** |
| * Determines whether or not a specified object should pass through the filter. |
| * @param object The specified object. |
| * @return True if the object satisfies the filter conditions, false otherwise. |
| */ |
| op boolean matches(T object) |
| |
| /** |
| * Filters a list of objects |
| * @param objects The list of object to filter. |
| * @return The list of objects that passed the filter. Never null, but can be empty. |
| */ |
| op Collection<T> filter(Collection<T> objects) |
| } |
| |
| /** |
| * A specialization of Filter that makes use of a list of Filter. |
| * If the list of filter is empty, matches(T object) always returns true. |
| */ |
| @Apogy(hasCustomClass="true") |
| class CompositeFilter<T> extends IFilter<T> |
| { |
| /** |
| * The type of chain. |
| */ |
| CompositeFilterType filterChainType = "AND" |
| |
| /** |
| * The list of filter used. |
| */ |
| contains IFilter<T>[0..*] filters |
| } |
| |
| /** |
| * The types of FilterChain. |
| */ |
| enum CompositeFilterType |
| { |
| /** |
| * All filter must matches for the object to pass through. |
| */ |
| AND as "AND" = 0, |
| /** |
| * At least one filter must matches for the object to pass through. |
| */ |
| OR as "OR" = 1 |
| } |
| |
| /* ------------------------------------------------------------------------- |
| * Timed Filters |
| * ------------------------------------------------------------------------- */ |
| |
| /** |
| * A Filter that matches a dates before a specified date. |
| */ |
| @Apogy(hasCustomClass="true", hasCustomItemProvider="true") |
| class TimedBeforeFilter<T extends Timed> extends IFilter<T> |
| { |
| /** |
| * Whether or not a Timed with perfect match to beforeDate should be allowed thru. |
| */ |
| boolean inclusive = "true" |
| |
| /** |
| * The date defining the latest date limit. |
| */ |
| @GenModel(notify="true") |
| Date beforeDate |
| } |
| |
| /* |
| * A Filter that matches dates after a specified date. |
| */ |
| @Apogy(hasCustomClass="true", hasCustomItemProvider="true") |
| class TimedAfterFilter<T extends Timed> extends IFilter<T> |
| { |
| /* |
| * Whether or not a Timed with perfect match to afterDate should be allowed thru. |
| */ |
| boolean inclusive = "true" |
| |
| /** |
| * The date defining the earliest date limit. |
| */ |
| @GenModel(notify="true") |
| Date afterDate |
| } |
| |
| /** |
| * A composite Filter for Timed. |
| */ |
| class TimedCompositeFilter<T extends Timed> extends CompositeFilter<T> |
| { |
| } |