Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java')
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java120
1 files changed, 120 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java
new file mode 100644
index 00000000000..9d3e75c3a76
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
+import org.eclipse.uml2.uml.DurationObservation;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+/**
+ * Specific Parser for the DurationObservation.
+ */
+public class DurationObservationParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The String for displaying a line break */
+ private static final String LINE_BREAK = System.getProperty("line.separator");
+
+ public DurationObservationParser() {
+ super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ public DurationObservationParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public DurationObservationParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ /**
+ * Gets the e structural feature.
+ *
+ * @param notification
+ * @return the structural feature
+ */
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if(notification instanceof Notification) {
+ Object feature = ((Notification)notification).getFeature();
+ if(feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature)feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPrintString(IAdaptable element, int flags) {
+ Object adapter = element.getAdapter(EObject.class);
+ if(adapter instanceof DurationObservation) {
+ return DurationObservationHelper.getLabelString((DurationObservation)adapter);
+ }
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public List getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if(element instanceof DurationObservation) {
+ DurationObservation observation = (DurationObservation)element;
+ semanticElementsBeingParsed.add(observation);
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getMessage_SendEvent().equals(feature) || UMLPackage.eINSTANCE.getMessage_ReceiveEvent().equals(feature) || UMLPackage.eINSTANCE.getDurationObservation_Event().equals(feature);
+ }
+
+}

Back to the top