Author: tfmorris
Date: 2008-05-28 13:53:46-0700
New Revision: 14822
Added:
branches/work_ocl2_tfmorris/src/argouml-app/
- copied from r14819, /trunk/src/argouml-app/
Removed:
branches/work_ocl2_tfmorris/src/argouml-app/lib/ocl-argo-1.1.jar
Modified:
branches/work_ocl2_tfmorris/src/argouml-app/.classpath
branches/work_ocl2_tfmorris/src/argouml-app/ArgoUML DEBUG.launch
branches/work_ocl2_tfmorris/src/argouml-app/META-INF/MANIFEST.MF
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLExpander.java
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLUtil.java
branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java
Log:
Dresden OCL2 toolkit upgrade from OCL1 - based on rev 14819 plus changes from Raphael Schmid and additional integration work by tfmorris
Modified: branches/work_ocl2_tfmorris/src/argouml-app/.classpath
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/.classpath?view=diff&rev=14822&p1=/trunk/src/argouml-app/.classpath&p2=branches/work_ocl2_tfmorris/src/argouml-app/.classpath&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/.classpath (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/.classpath 2008-05-28 13:53:46-0700
@@ -1,17 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry excluding="tudresden/ocl20/integration/|org/argouml/ocl/ArgoFacade.java" kind="src" path="src"/>
<classpathentry kind="src" output="build-eclipse-tests" path="tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/antlr-2.7.7.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/gef-0.12.4BETA3.jar" sourcepath="/gef/src"/>
- <classpathentry exported="true" kind="lib" path="lib/ocl-argo-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/swidgets-0.1.4.jar" sourcepath="/swidgets/src"/>
<classpathentry exported="true" kind="lib" path="lib/toolbar-1.4.1-20071227.jar" sourcepath="/toolbar/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="lib" path="/argouml-core-tools/lib/easymock12.jar"/>
<classpathentry kind="lib" path="/argouml-core-tools/jdepend-2.9/lib/jdepend-2.9.jar"/>
+ <classpathentry kind="lib" path="lib/ocl20codegen-java.jar"/>
+ <classpathentry kind="lib" path="lib/ocl20jmiapi.jar"/>
+ <classpathentry kind="lib" path="lib/ocl20jmiimpl.jar" sourcepath="/ocl20/src"/>
+ <classpathentry kind="lib" path="lib/ocl20parserbase.jar"/>
+ <classpathentry kind="lib" path="lib/ocl20parsertools.jar"/>
+ <classpathentry kind="lib" path="lib/ocl20repository.jar" sourcepath="/ocl20/src"/>
+ <classpathentry kind="lib" path="lib/ocl20stdlib.jar"/>
+ <classpathentry kind="lib" path="lib/ocl2-argo.jar"/>
+ <classpathentry kind="lib" path="/argouml-core-model-mdr/lib/jmi.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/argouml-core-model-mdr"/>
<classpathentry kind="output" path="build-eclipse"/>
</classpath>
Modified: branches/work_ocl2_tfmorris/src/argouml-app/ArgoUML DEBUG.launch
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/ArgoUML%20DEBUG.launch?view=diff&rev=14822&p1=/trunk/src/argouml-app/ArgoUML%20DEBUG.launch&p2=branches/work_ocl2_tfmorris/src/argouml-app/ArgoUML%20DEBUG.launch&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/ArgoUML DEBUG.launch (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/ArgoUML DEBUG.launch 2008-05-28 13:53:46-0700
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/argouml-app/src/org/argouml/application/Main.java"/>
@@ -28,5 +28,5 @@
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.argouml.application.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-app"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512M -ea -Dlog4j.configuration=org/argouml/resource/full_console.lcf"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512M -ea -Dlog4j.configuration=org/argouml/resource/full_console.lcf -DrepositoryLocation=org/argouml/resource"/>
</launchConfiguration>
Modified: branches/work_ocl2_tfmorris/src/argouml-app/META-INF/MANIFEST.MF
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/META-INF/MANIFEST.MF?view=diff&rev=14822&p1=/trunk/src/argouml-app/META-INF/MANIFEST.MF&p2=branches/work_ocl2_tfmorris/src/argouml-app/META-INF/MANIFEST.MF&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/META-INF/MANIFEST.MF (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/META-INF/MANIFEST.MF 2008-05-28 13:53:46-0700
@@ -151,22 +151,67 @@
templates,
testmodels.uml13,
testmodels.uml14,
- tudresden.ocl,
- tudresden.ocl.check,
- tudresden.ocl.check.bootstrap,
- tudresden.ocl.check.types,
- tudresden.ocl.codegen,
- tudresden.ocl.gui,
- tudresden.ocl.gui.events,
- tudresden.ocl.images,
- tudresden.ocl.injection.lib,
- tudresden.ocl.lib,
- tudresden.ocl.normalize,
- tudresden.ocl.parser,
- tudresden.ocl.parser.analysis,
- tudresden.ocl.parser.lexer,
- tudresden.ocl.parser.node,
- tudresden.ocl.parser.parser
+ tudresden.ocl20,
+ tudresden.ocl20.codegen.java,
+ tudresden.ocl20.core,
+ tudresden.ocl20.core.jmi.cwm.behavioral,
+ tudresden.ocl20.core.jmi.cwm.core,
+ tudresden.ocl20.core.jmi.cwm.datatypes,
+ tudresden.ocl20.core.jmi.cwm.instance,
+ tudresden.ocl20.core.jmi.cwm.keysindexes,
+ tudresden.ocl20.core.jmi.cwm.relational,
+ tudresden.ocl20.core.jmi.cwm.relational.enumerations,
+ tudresden.ocl20.core.jmi.cwm.xml,
+ tudresden.ocl20.core.jmi.mof14.corbaidltypes,
+ tudresden.ocl20.core.jmi.mof14.impl.model,
+ tudresden.ocl20.core.jmi.mof14.impl.mof14ocl.adapters,
+ tudresden.ocl20.core.jmi.mof14.impl.mof14ocl.expressions,
+ tudresden.ocl20.core.jmi.mof14.impl.mof14ocl.types,
+ tudresden.ocl20.core.jmi.mof14.model,
+ tudresden.ocl20.core.jmi.mof14.mof14ocl,
+ tudresden.ocl20.core.jmi.mof14.mof14ocl.adapters,
+ tudresden.ocl20.core.jmi.mof14.mof14ocl.expressions,
+ tudresden.ocl20.core.jmi.mof14.mof14ocl.types,
+ tudresden.ocl20.core.jmi.mof14.primitivetypes,
+ tudresden.ocl20.core.jmi.ocl,
+ tudresden.ocl20.core.jmi.ocl.commonmodel,
+ tudresden.ocl20.core.jmi.ocl.expressions,
+ tudresden.ocl20.core.jmi.ocl.primitivetypes,
+ tudresden.ocl20.core.jmi.ocl.types,
+ tudresden.ocl20.core.jmi.uml15.actionfoundation,
+ tudresden.ocl20.core.jmi.uml15.actions,
+ tudresden.ocl20.core.jmi.uml15.activitygraphs,
+ tudresden.ocl20.core.jmi.uml15.collaborations,
+ tudresden.ocl20.core.jmi.uml15.commonbehavior,
+ tudresden.ocl20.core.jmi.uml15.core,
+ tudresden.ocl20.core.jmi.uml15.datatypes,
+ tudresden.ocl20.core.jmi.uml15.impl.commonbehavior,
+ tudresden.ocl20.core.jmi.uml15.impl.core,
+ tudresden.ocl20.core.jmi.uml15.impl.datatypes,
+ tudresden.ocl20.core.jmi.uml15.impl.modelmanagement,
+ tudresden.ocl20.core.jmi.uml15.impl.uml15ocl.expressions,
+ tudresden.ocl20.core.jmi.uml15.impl.uml15ocl.types,
+ tudresden.ocl20.core.jmi.uml15.modelmanagement,
+ tudresden.ocl20.core.jmi.uml15.statemachines,
+ tudresden.ocl20.core.jmi.uml15.uml15,
+ tudresden.ocl20.core.jmi.uml15.uml15ocl,
+ tudresden.ocl20.core.jmi.uml15.uml15ocl.expressions,
+ tudresden.ocl20.core.jmi.uml15.uml15ocl.types,
+ tudresden.ocl20.core.jmi.uml15.usecases,
+ tudresden.ocl20.core.lib,
+ tudresden.ocl20.core.parser,
+ tudresden.ocl20.core.parser.astgen,
+ tudresden.ocl20.core.parser.astlib,
+ tudresden.ocl20.core.parser.sablecc.analysis,
+ tudresden.ocl20.core.parser.sablecc.lexer,
+ tudresden.ocl20.core.parser.sablecc.node,
+ tudresden.ocl20.core.parser.sablecc.parser,
+ tudresden.ocl20.core.parser.util,
+ tudresden.ocl20.core.util,
+ tudresden.ocl20.gui,
+ tudresden.ocl20.gui.events,
+ tudresden.ocl20.images,
+ tudresden.ocl20.integration
Require-Bundle: org.argouml.core.infra,
org.argouml.core.model
Eclipse-RegisterBuddy: org.argouml.core.infra
Removed: /trunk/src/argouml-app/lib/ocl-argo-1.1.jar
Url: http://argouml.tigris.org/source/browse/argouml//trunk/src/argouml-app/lib/ocl-argo-1.1.jar?view=auto&rev=14819
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java 2008-05-28 13:53:46-0700
@@ -49,7 +49,7 @@
import org.argouml.configuration.Configuration;
import org.argouml.model.Model;
import org.argouml.moduleloader.ModuleInterface;
-import org.argouml.ocl.ArgoFacade;
+//import org.argouml.ocl.ArgoFacade;
import org.argouml.uml.DocumentationManager;
import org.argouml.uml.generator.CodeGenerator;
import org.argouml.uml.generator.GeneratorHelper;
@@ -58,9 +58,9 @@
import org.argouml.uml.generator.TempFileUtils;
import org.argouml.uml.reveng.ImportInterface;
-import tudresden.ocl.OclTree;
-import tudresden.ocl.parser.analysis.DepthFirstAdapter;
-import tudresden.ocl.parser.node.AConstraintBody;
+//import tudresden.ocl20.OclTree;
+import tudresden.ocl20.core.parser.sablecc.analysis.DepthFirstAdapter;
+//import tudresden.ocl20.core.parser.sablecc.node.AConstraintBody;
import antlr.ANTLRException;
/**
@@ -1266,88 +1266,89 @@
// Add each constraint
- class TagExtractor extends DepthFirstAdapter {
- private LinkedList<String> llsTags = new LinkedList<String>();
- private String constraintName;
- private int constraintID;
-
- /**
- * Constructor.
- *
- * @param sConstraintName The constraint name.
- */
- public TagExtractor(String sConstraintName) {
- super();
-
- constraintName = sConstraintName;
- }
-
- public Iterator getTags() {
- return llsTags.iterator();
- }
-
- /*
- * @see tudresden.ocl.parser.analysis.Analysis#caseAConstraintBody(tudresden.ocl.parser.node.AConstraintBody)
- */
- @Override
- public void caseAConstraintBody(AConstraintBody node) {
- // We don't care for anything below this node, so we
- // do not use apply anymore.
- String sKind =
- (node.getStereotype() != null)
- ? (node.getStereotype().toString())
- : (null);
- String sExpression =
- (node.getExpression() != null)
- ? (node.getExpression().toString())
- : (null);
- String sName =
- (node.getName() != null)
- ? (node.getName().getText())
- : (constraintName + "_" + (constraintID++));
-
- if ((sKind == null) || (sExpression == null)) {
- return;
- }
-
- String sTag;
- if (sKind.equals("inv ")) {
- sTag = "@invariant ";
- } else if (sKind.equals("post ")) {
- sTag = "@postcondition ";
- } else if (sKind.equals("pre ")) {
- sTag = "@precondition ";
- } else {
- return;
- }
-
- sTag += sName + ": " + sExpression;
- llsTags.addLast(sTag);
- }
- }
-
- tudresden.ocl.check.types.ModelFacade mf = new ArgoFacade(me);
- for (Object constraint : cConstraints) {
- try {
- String body =
- (String) Model.getFacade().getBody(
- Model.getFacade().getBody(constraint));
- OclTree otParsed = OclTree.createTree(body, mf);
-
- TagExtractor te =
- new TagExtractor(Model.getFacade().getName(constraint));
- otParsed.apply(te);
-
- for (Iterator j = te.getTags(); j.hasNext();) {
- sDocComment.append(' ').append(j.next());
- sDocComment.append(LINE_SEPARATOR);
- sDocComment.append(INDENT).append(" *");
- }
- } catch (IOException ioe) {
- // Nothing to be done, should not happen anyway ;-)
- }
- }
-
+// class TagExtractor extends tudresden.ocl20.core.parser.sablecc.analysis.DepthFirstAdapter {
+// private LinkedList<String> llsTags = new LinkedList<String>();
+// private String constraintName;
+// private int constraintID;
+//
+// /**
+// * Constructor.
+// *
+// * @param sConstraintName The constraint name.
+// */
+// public TagExtractor(String sConstraintName) {
+// super();
+//
+// constraintName = sConstraintName;
+// }
+//
+// public Iterator getTags() {
+// return llsTags.iterator();
+// }
+//
+// /*
+// * @see tudresden.ocl.parser.analysis.Analysis#caseAConstraintBody(tudresden.ocl.parser.node.AConstraintBody)
+// */
+// @Override
+// public void caseAConstraintBody(AConstraintBody node) {
+// // We don't care for anything below this node, so we
+// // do not use apply anymore.
+// String sKind =
+// (node.getStereotype() != null)
+// ? (node.getStereotype().toString())
+// : (null);
+// String sExpression =
+// (node.getExpression() != null)
+// ? (node.getExpression().toString())
+// : (null);
+// String sName =
+// (node.getName() != null)
+// ? (node.getName().getText())
+// : (constraintName + "_" + (constraintID++));
+//
+// if ((sKind == null) || (sExpression == null)) {
+// return;
+// }
+//
+// String sTag;
+// if (sKind.equals("inv ")) {
+// sTag = "@invariant ";
+// } else if (sKind.equals("post ")) {
+// sTag = "@postcondition ";
+// } else if (sKind.equals("pre ")) {
+// sTag = "@precondition ";
+// } else {
+// return;
+// }
+//
+// sTag += sName + ": " + sExpression;
+// llsTags.addLast(sTag);
+// }
+// }
+//
+//// tudresden.ocl.check.types.ModelFacade mf = new ArgoFacade(me);
+// ArgoFacade mf = new ArgoFacade(me);
+// for (Object constraint : cConstraints) {
+// try {
+// String body =
+// (String) Model.getFacade().getBody(
+// Model.getFacade().getBody(constraint));
+// OclTree otParsed = OclTree.createTree(body, mf);
+//
+// TagExtractor te =
+// new TagExtractor(Model.getFacade().getName(constraint));
+// otParsed.apply(te);
+//
+// for (Iterator j = te.getTags(); j.hasNext();) {
+// sDocComment.append(' ').append(j.next());
+// sDocComment.append(LINE_SEPARATOR);
+// sDocComment.append(INDENT).append(" *");
+// }
+// } catch (IOException ioe) {
+// // Nothing to be done, should not happen anyway ;-)
+// }
+// }
+//
sDocComment.append("/").append(LINE_SEPARATOR);
return sDocComment.toString();
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/ArgoFacade.java 2008-05-28 13:53:46-0700
@@ -32,11 +32,15 @@
import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
-import tudresden.ocl.check.OclTypeException;
-import tudresden.ocl.check.types.Any;
-import tudresden.ocl.check.types.Basic;
-import tudresden.ocl.check.types.Type;
-import tudresden.ocl.check.types.Type2;
+import tudresden.ocl20.core.lib.OclAny;
+
+//import tudresden.ocl.check.OclTypeException;
+//import tudresden.ocl.check.types.Any;
+//import tudresden.ocl.check.types.Basic;
+//import tudresden.ocl.check.types.Type;
+//import tudresden.ocl.check.types.Type2;
+
+
/**
* Provides a facade of the ArgoUml uml model for the OCL compiler.<p>
@@ -48,7 +52,8 @@
* import java.util.Collection;
* import tudresden.ocl.check.types.Collection;
*/
-public class ArgoFacade implements tudresden.ocl.check.types.ModelFacade {
+//public class ArgoFacade implements tudresden.ocl20.check.types.ModelFacade {
+public class ArgoFacade {
/**
* The target that this instance is connected to.
@@ -56,7 +61,7 @@
private Object target;
/**
- * Construtor.
+ * Constructor.
*
* @param t The target to create this facade for.
*/
@@ -92,7 +97,9 @@
/**
* A class that is the wrapper for any type.
*/
-class ArgoAny implements Any, Type2 {
+//ocl2 below
+class ArgoAny {
+//class ArgoAny implements Any, Type2 {
/**
* Logger for the ArgoAny class.
*/
@@ -178,10 +185,10 @@
== -1)) {
if (Model.getExtensionMechanismsHelper().hasStereotype(ae,
"ordered")) {
- isSequence = true;
- } else {
- isSet = true;
- }
+ isSequence = true;
+ } else {
+ isSet = true;
+ }
}
}
}
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java 2008-05-28 13:53:46-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -24,36 +24,27 @@
package org.argouml.ocl;
+import java.util.Iterator;
+
+
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.tigris.gef.base.Diagram;
import org.tigris.gef.ocl.ExpansionException;
/**
- * CriticOclEvaluator is singleton version of OCLEvaluator which is used for
- * evaluating simple OCL expressions used in the critiques.<p>
- *
- * Implementation History: As best I was able to reconstruct the history in
- * early 2007, OclEvaluator was originally implemented as a singleton, but that
- * was changed in September, 2004 because of some perceived problems, but then
- * it was discovered that the Critic subsystem depended on the singleton
- * pattern, so an earlier version of OclEvaluator was reintroduced with a new
- * name. Because of the large amount of duplicate code between the two classes,
- * this was refactored in March, 2007 to use an instance of the main
- * OclEvaluator class.
- *
+ * CriticOclEvaluator is responsible for evaluating simple OCL expressions
+ * used in the critiques.<p>
+ *
* @stereotype singleton
- * @deprecated for 0.25.2 by tfmorris - use {@link OCLEvaluator}
*/
-@Deprecated
-public class CriticOclEvaluator {
+public class CriticOclEvaluator extends org.tigris.gef.ocl.OCLEvaluator {
private static final CriticOclEvaluator INSTANCE =
new CriticOclEvaluator();
- private static final OCLEvaluator EVALUATOR =
- new OCLEvaluator();
-
private CriticOclEvaluator() {
- // no instantiations
}
/**
@@ -68,8 +59,52 @@
*/
public synchronized String evalToString(Object self, String expr)
throws ExpansionException {
-
- return EVALUATOR.evalToString(self, expr);
+ String res = null;
+ if (GET_NAME_EXPR_1.equals(expr)
+ && Model.getFacade().isAModelElement(self)) {
+ res = Model.getFacade().getName(self);
+ if (res == null || "".equals(res)) {
+ res = Translator.localize("misc.name.anon");
+ }
+ }
+ if (GET_NAME_EXPR_2.equals(expr)
+ && Model.getFacade().isAModelElement(self)) {
+ res = Model.getFacade().getName(self);
+ if (res == null || "".equals(res)) {
+ res = Translator.localize("misc.name.anon");
+ }
+ }
+ if (GET_OWNER_EXPR.equals(expr) && Model.getFacade().isAFeature(self)) {
+ Object owner = Model.getFacade().getOwner(self);
+ if (owner != null) {
+ res = Model.getFacade().getName(owner);
+ if (res == null || "".equals(res)) {
+ res = Translator.localize("misc.name.anon");
+ }
+ }
+ }
+ if (GET_NAME_EXPR_1.equals(expr) && self instanceof Diagram) {
+ res = ((Diagram) self).getName();
+ if (res == null || "".equals(res)) {
+ res = Translator.localize("misc.name.anon");
+ }
+ }
+ if (GET_NAME_EXPR_2.equals(expr) && self instanceof Diagram) {
+ res = ((Diagram) self).getName();
+ if (res == null || "".equals(res)) {
+ res = Translator.localize("misc.name.anon");
+ }
+ }
+ /*
+ if (GET_OWNER_EXPR.equals(expr) && self instanceof Diagram) {
+ res = ((Diagram)self).getOwner().getName();
+ if (res == null || "".equals(res)) res = Translator.localize("misc.name.anon");
+ }
+ */
+ if (res == null) {
+ res = evalToString(self, expr, ", ");
+ }
+ return res;
}
/*
@@ -78,10 +113,33 @@
public synchronized String evalToString(
Object self,
String expr,
- String sep)
- throws ExpansionException {
-
- return EVALUATOR.evalToString(self, expr, sep);
+ String sep) throws ExpansionException {
+ _scratchBindings.put("self", self);
+ java.util.List values = eval(_scratchBindings, expr);
+ _strBuf.setLength(0);
+ Iterator iter = values.iterator();
+ while (iter.hasNext()) {
+ Object v = iter.next();
+ if (Model.getFacade().isAModelElement(v)) {
+ v = Model.getFacade().getName(v);
+ if ("".equals(v)) {
+ v = Translator.localize("misc.name.anon");
+ }
+ }
+ if (Model.getFacade().isAExpression(v)) {
+ v = Model.getFacade().getBody(v);
+ if ("".equals(v)) {
+ v = "(unspecified)";
+ }
+ }
+ if (!"".equals(v)) {
+ _strBuf.append(v);
+ if (iter.hasNext()) {
+ _strBuf.append(sep);
+ }
+ }
+ }
+ return _strBuf.toString();
}
-}
\ No newline at end of file
+} // end of OCLEvaluator
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLEvaluator.java 2008-05-28 13:53:46-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -51,94 +51,91 @@
* @see org.tigris.gef.ocl.OCLEvaluator#evalToString(java.lang.Object,
* java.lang.String)
*/
- protected synchronized String evalToString(Object self, String expr)
- throws ExpansionException {
- String res = null;
- if (GET_NAME_EXPR_1.equals(expr)
- && Model.getFacade().isAModelElement(self)) {
- res = Model.getFacade().getName(self);
- if (res == null || "".equals(res)) {
- res = Translator.localize("misc.name.anon");
- }
- }
- if (GET_NAME_EXPR_2.equals(expr)
- && Model.getFacade().isAModelElement(self)) {
- res = Model.getFacade().getName(self);
- if (res == null || "".equals(res)) {
- res = Translator.localize("misc.name.anon");
- }
- }
- if (GET_OWNER_EXPR.equals(expr) && Model.getFacade().isAFeature(self)) {
- Object owner = Model.getFacade().getOwner(self);
- if (owner != null) {
- res = Model.getFacade().getName(owner);
- if (res == null || "".equals(res)) {
- res = Translator.localize("misc.name.anon");
- }
- }
- }
- if (GET_NAME_EXPR_1.equals(expr) && self instanceof Diagram) {
- res = ((Diagram) self).getName();
- if (res == null || "".equals(res)) {
- res = Translator.localize("misc.name.anon");
- }
- }
- if (GET_NAME_EXPR_2.equals(expr) && self instanceof Diagram) {
- res = ((Diagram) self).getName();
- if (res == null || "".equals(res)) {
- res = Translator.localize("misc.name.anon");
- }
- }
- /*
- if (GET_OWNER_EXPR.equals(expr) && self instanceof Diagram) {
- res = ((Diagram)self).getOwner().getName();
- if (res == null || "".equals(res)) {
- res = Translator.localize("misc.name.anon");
- }
- }
- */
- if (res == null) {
- res = evalToString(self, expr, ", ");
- }
- return res;
- }
+// protected synchronized String evalToString(Object self, String expr)
+// throws ExpansionException {
+// String res = null;
+// if (GET_NAME_EXPR_1.equals(expr)
+// && Model.getFacade().isAModelElement(self)) {
+// res = Model.getFacade().getName(self);
+// if (res == null || "".equals(res)) {
+// res = Translator.localize("misc.name.anon");
+// }
+// }
+// if (GET_NAME_EXPR_2.equals(expr)
+// && Model.getFacade().isAModelElement(self)) {
+// res = Model.getFacade().getName(self);
+// if (res == null || "".equals(res)) {
+// res = Translator.localize("misc.name.anon");
+// }
+// }
+// if (GET_OWNER_EXPR.equals(expr) && Model.getFacade().isAFeature(self)) {
+// res = Model.getFacade().getName(self);
+// if (res == null || "".equals(res)) {
+// res = Translator.localize("misc.name.anon");
+// }
+// }
+// if (GET_NAME_EXPR_1.equals(expr) && self instanceof Diagram) {
+// res = Model.getFacade().getName(self);
+// if (res == null || "".equals(res)) {
+// res = Translator.localize("misc.name.anon");
+// }
+// }
+// if (GET_NAME_EXPR_2.equals(expr) && self instanceof Diagram) {
+// res = Model.getFacade().getName(self);
+// if (res == null || "".equals(res)) {
+// res = Translator.localize("misc.name.anon");
+// }
+// }
+// /*
+// if (GET_OWNER_EXPR.equals(expr) && self instanceof Diagram) {
+// res = ((Diagram)self).getOwner().getName();
+// if (res == null || "".equals(res)) {
+// res = Translator.localize("misc.name.anon");
+// }
+// }
+// */
+// if (res == null) {
+// res = evalToString(self, expr, ", ");
+// }
+// return res;
+// }
/*
* @see org.tigris.gef.ocl.OCLEvaluator#evalToString(java.lang.Object,
* java.lang.String, java.lang.String)
*/
- protected synchronized String evalToString(
- Object self,
- String expr,
- String sep)
- throws ExpansionException {
-
- _scratchBindings.put("self", self);
- java.util.List values = eval(_scratchBindings, expr);
- _strBuf.setLength(0);
- Iterator iter = values.iterator();
- while (iter.hasNext()) {
- Object v = iter.next();
- if (Model.getFacade().isAModelElement(v)) {
- v = Model.getFacade().getName(v);
- if ("".equals(v)) {
- v = Translator.localize("misc.name.anon");
- }
- }
- if (Model.getFacade().isAExpression(v)) {
- v = Model.getFacade().getBody(v);
- if ("".equals(v)) {
- v = "(unspecified)";
- }
- }
- if (!"".equals(v)) {
- _strBuf.append(v);
- if (iter.hasNext()) {
- _strBuf.append(sep);
- }
- }
- }
- return _strBuf.toString();
- }
+// protected synchronized String evalToString(
+// Object self,
+// String expr,
+// String sep)
+// throws ExpansionException {
+//
+// _scratchBindings.put("self", self);
+// java.util.List values = eval(_scratchBindings, expr);
+// _strBuf.setLength(0);
+// Iterator iter = values.iterator();
+// while (iter.hasNext()) {
+// Object v = iter.next();
+// if (Model.getFacade().isAModelElement(v)) {
+// v = Model.getFacade().getName(v);
+// if ("".equals(v)) {
+// v = Translator.localize("misc.name.anon");
+// }
+// }
+// if (Model.getFacade().isAExpression(v)) {
+// v = Model.getFacade().getBody(v);
+// if ("".equals(v)) {
+// v = "(unspecified)";
+// }
+// }
+// if (!"".equals(v)) {
+// _strBuf.append(v);
+// if (iter.hasNext()) {
+// _strBuf.append(sep);
+// }
+// }
+// }
+// return _strBuf.toString();
+// }
} // end of OCLEvaluator
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLExpander.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLExpander.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/ocl/OCLExpander.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLExpander.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ocl/OCLExpander.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLExpander.java 2008-05-28 13:53:46-0700
@@ -41,10 +41,10 @@
super(templates);
}
- /**
+ /*
* Create the specialist OCLEvaluator for ArgoUML
*/
- protected void createEvaluator() {
- evaluator = new OCLEvaluator();
- }
+// protected void createEvaluator() {
+// evaluator = new OCLEvaluator();
+// }
} /* end class OCLExpander */
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLUtil.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLUtil.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/ocl/OCLUtil.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLUtil.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ocl/OCLUtil.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/ocl/OCLUtil.java 2008-05-28 13:53:46-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -24,8 +24,7 @@
package org.argouml.ocl;
-import java.util.Collection;
-import java.util.Iterator;
+import java.util.List;
import org.argouml.model.Model;
@@ -58,6 +57,7 @@
return me;
}
+
/**
* Return a context string for the given model element.
*
@@ -66,52 +66,70 @@
* @return the context string for the model element.
*/
public static String getContextString (final Object me) {
- if (me == null || !(Model.getFacade().isAModelElement(me)))
- return "";
- Object mnsContext =
- getInnerMostEnclosingNamespace (me);
-
- if (Model.getFacade().isABehavioralFeature(me)) {
- StringBuffer sbContext = new StringBuffer ("context ");
- sbContext.append (Model.getFacade().getName(mnsContext));
- sbContext.append ("::");
- sbContext.append (Model.getFacade().getName(me));
- sbContext.append (" (");
-
- Collection lParams = Model.getFacade().getParameters(me);
- String sReturnType = null;
- boolean fFirstParam = true;
-
- for (Iterator i = lParams.iterator(); i.hasNext();) {
- Object mp = i.next(); //MParameter
-
- if (Model.getFacade().isReturn(mp)) {
- sReturnType = Model.getFacade().getName(
- Model.getFacade().getType(mp));
- } else {
- if (fFirstParam) {
- fFirstParam = false;
- } else {
- sbContext.append ("; ");
- }
-
- sbContext.append(
- Model.getFacade().getType(mp)).append(": ");
- sbContext.append(Model.getFacade().getName(
- Model.getFacade().getType(mp)));
- }
- }
-
- sbContext.append (")");
-
- // The ocl toolkit does not like void return types
- if (sReturnType != null && !sReturnType.equalsIgnoreCase("void")) {
- sbContext.append (": ").append (sReturnType);
- }
-
- return sbContext.toString();
- } else {
- return "context " + Model.getFacade().getName(mnsContext);
- }
+
+ // Extension by Raphael Schmid
+
+ String packageName = null;
+ String className = null;
+ String featureName = null;
+ String returnTypeName = null;
+
+ // Object selectedObject = TargetManager.getInstance().getTarget();
+ Object selectedObject = me;
+ if (selectedObject instanceof org.omg.uml.foundation.core.UmlClass) {
+ packageName = ((org.omg.uml.foundation.core.UmlClass) selectedObject)
+ .getNamespace().getName();
+ className = ((org.omg.uml.foundation.core.UmlClass) selectedObject)
+ .getName();
+ }
+ if (selectedObject instanceof org.omg.uml.foundation.core.Feature) {
+ packageName = ((org.omg.uml.foundation.core.Feature) selectedObject)
+ .getOwner().getNamespace().getName();
+ className = ((org.omg.uml.foundation.core.Feature) selectedObject)
+ .getOwner().getName();
+ featureName = ((org.omg.uml.foundation.core.Feature) selectedObject)
+ .getName();
+
+ if (selectedObject instanceof org.omg.uml.foundation.core.BehavioralFeature) {
+ List<org.omg.uml.foundation.core.Parameter> parameters = ((org.omg.uml.foundation.core.BehavioralFeature) selectedObject)
+ .getParameter();
+ for (org.omg.uml.foundation.core.Parameter p : parameters) {
+ if (p.getKind() == org.omg.uml.foundation.datatypes.ParameterDirectionKindEnum.PDK_RETURN) {
+ returnTypeName = p.getType().getName();
+ break;
+ }
+ }
+ }
+ }
+
+ String text = new String("package ");
+ if (packageName != null) {
+ text = text.concat(packageName);
+ }
+ text = text.concat("\n");
+
+ text = text.concat("context ");
+ if (className != null) {
+ text = text.concat(className);
+ }
+
+ if (featureName != null) {
+ text = text.concat("::");
+ text = text.concat(featureName);
+
+ if (returnTypeName != null) {
+ text = text.concat("(): ");
+ text = text.concat(returnTypeName);
+ }
+ }
+
+ text = text.concat("\n");
+ text = text.concat("\n");
+ text = text.concat("\n");
+ text = text.concat("endpackage");
+ // LOG.debug(text);
+ return text;
+
}
+
}
Modified: branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java?view=diff&rev=14822&p1=/trunk/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java&p2=branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java&r1=14819&r2=14822
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/org/argouml/uml/ui/TabConstraints.java 2008-05-28 13:53:46-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -29,44 +29,40 @@
import java.awt.event.ComponentListener;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.JToolBar;
import javax.swing.event.EventListenerList;
import org.apache.log4j.Logger;
-import org.argouml.application.api.AbstractArgoJPanel;
import org.argouml.model.Model;
-import org.argouml.ocl.ArgoFacade;
import org.argouml.ocl.OCLUtil;
import org.argouml.swingext.UpArrowIcon;
+import org.argouml.ui.AbstractArgoJPanel;
import org.argouml.ui.TabModelTarget;
import org.argouml.ui.targetmanager.TargetEvent;
import org.tigris.gef.presentation.Fig;
import org.tigris.toolbar.ToolBarManager;
-import tudresden.ocl.OclException;
-import tudresden.ocl.OclTree;
-import tudresden.ocl.check.OclTypeException;
-import tudresden.ocl.gui.ConstraintRepresentation;
-import tudresden.ocl.gui.EditingUtilities;
-import tudresden.ocl.gui.OCLEditor;
-import tudresden.ocl.gui.OCLEditorModel;
-import tudresden.ocl.gui.events.ConstraintChangeEvent;
-import tudresden.ocl.gui.events.ConstraintChangeListener;
-import tudresden.ocl.parser.OclParserException;
-import tudresden.ocl.parser.analysis.DepthFirstAdapter;
-import tudresden.ocl.parser.node.AConstraintBody;
-import tudresden.ocl.parser.node.TName;
+import tudresden.ocl20.core.OclModel;
+import tudresden.ocl20.core.OclModelException;
+import tudresden.ocl20.core.parser.sablecc.analysis.AttrEvalException;
+import tudresden.ocl20.core.parser.sablecc.lexer.LexerException;
+import tudresden.ocl20.core.parser.sablecc.parser.ParserException;
+import tudresden.ocl20.gui.ConstraintRepresentation;
+import tudresden.ocl20.gui.EditingUtilities;
+import tudresden.ocl20.gui.OCLEditor;
+import tudresden.ocl20.gui.OCLEditorModel;
+import tudresden.ocl20.gui.events.ConstraintChangeEvent;
+import tudresden.ocl20.gui.events.ConstraintChangeListener;
/**
- * Tab for OCL constraint editing.
- *
- * @author v1.0: Falk Finger
- * @author v2.0: Steffen Zschaler
- */
+ * Tab for OCL constraint editing.
+ *
+ * @author v1.0: Falk Finger
+ * @author v2.0: Steffen Zschaler
+ * @author v3.0: Raphael Schmid
+ */
public class TabConstraints extends AbstractArgoJPanel
implements TabModelTarget, ComponentListener {
@@ -93,7 +89,7 @@
mOcleEditor = new OCLEditor();
mOcleEditor.setOptionMask(OCLEditor.OPTIONMASK_TYPECHECK
- /*| //removed to workaround problems with autosplit
+ /*| //removed to workaround problems with autosplit
OCLEditor.OPTIONMASK_AUTOSPLIT*/);
mOcleEditor.setDoAutoSplit(false);
setToolbarRollover(true);
@@ -101,7 +97,7 @@
getOclToolbar().setName("misc.toolbar.constraints");
add(mOcleEditor);
-
+
addComponentListener(this);
}
@@ -177,7 +173,7 @@
*/
public void setTarget(Object oTarget) {
oTarget =
- (oTarget instanceof Fig) ? ((Fig) oTarget).getOwner() : oTarget;
+ (oTarget instanceof Fig) ? ((Fig) oTarget).getOwner() : oTarget;
if (!(Model.getFacade().isAModelElement(oTarget))) {
mMmeiTarget = null;
return;
@@ -226,7 +222,7 @@
theMMmeiTarget = mmeiTarget;
theMAlConstraints =
- new ArrayList(Model.getFacade().getConstraints(theMMmeiTarget));
+ new ArrayList(Model.getFacade().getConstraints(theMMmeiTarget));
}
/**
@@ -280,29 +276,29 @@
// check ocl parsing constraints
Object mmeContext = OCLUtil
- .getInnerMostEnclosingNamespace(theMMmeiTarget);
+ .getInnerMostEnclosingNamespace(theMMmeiTarget);
String contextName = Model.getFacade().getName(mmeContext);
String targetName = Model.getFacade().getName(theMMmeiTarget);
if ((contextName == null
- || contextName.equals (""))
- || // this is to fix issue #2056
- (targetName == null
- || targetName.equals (""))
- || // this is to fix issue #2056
- !Character.isUpperCase(contextName.charAt(0))
- || (Model.getFacade().isAClass (theMMmeiTarget)
- && !Character.isUpperCase(targetName.charAt(0)))
- || (Model.getFacade().isAFeature(theMMmeiTarget)
- && !Character.isLowerCase(targetName.charAt(0)))) {
+ || contextName.equals (""))
+ || // this is to fix issue #2056
+ (targetName == null
+ || targetName.equals (""))
+ || // this is to fix issue #2056
+ !Character.isUpperCase(contextName.charAt(0))
+ || (Model.getFacade().isAClass (theMMmeiTarget)
+ && !Character.isUpperCase(targetName.charAt(0)))
+ || (Model.getFacade().isAFeature(theMMmeiTarget)
+ && !Character.isLowerCase(targetName.charAt(0)))) {
// TODO: I18n
JOptionPane.showMessageDialog(
- null,
- "The OCL Toolkit requires that:\n\n"
- + "Class names have a capital first letter and\n"
- + "Attribute or Operation names have "
- + "a lower case first letter.",
- "Require Correct name convention:",
- JOptionPane.ERROR_MESSAGE);
+ null,
+ "The OCL Toolkit requires that:\n\n"
+ + "Class names have a capital first letter and\n"
+ + "Attribute or Operation names have "
+ + "a lower case first letter.",
+ "Require Correct name convention:",
+ JOptionPane.ERROR_MESSAGE);
// do not create a constraint:
return;
}
@@ -370,159 +366,92 @@
*
* @exception IllegalStateException if the constraint is
* not in a state to accept body changes.
- * @exception OclParserException if the specified constraint is not
- * syntactically correct.
- * @exception OclTypeException if the specified constraint
- * does not adhere by OCL type rules.
+ * @exception OclModelException thrown by the methods of
+ * {@link OclModel OclModel} in case of an error.
+ * @exception ParserException if a syntax error occurred.
+ * @exception LexerException if the SableCC lexer throws
+ * @exception AttrEvalException if a type checking error occurred.
+ * @exception IOException if an I/O operation failed.
*/
public void setData(String sData, EditingUtilities euHelper)
- throws OclParserException, OclTypeException {
+ throws IllegalStateException, OclModelException,
+ ParserException, LexerException, AttrEvalException, IOException {
+
+ // Updated by Raphael Schmid
+
// Parse and check specified constraint.
- OclTree tree = null;
- try {
- Object mmeContext = OCLUtil
- .getInnerMostEnclosingNamespace(theMMmeiTarget);
+ Object mmeContext = OCLUtil
+ .getInnerMostEnclosingNamespace(theMMmeiTarget);
- try {
- tree =
- euHelper.parseAndCheckConstraint(
- sData,
- new ArgoFacade(mmeContext));
- } catch (IOException ioe) {
- // Ignored: Highly unlikely, and what would we
- // do anyway? log it
- LOG.error("problem parsing And Checking Constraints",
- ioe);
- return;
- }
+ euHelper.parseAndCheckConstraint(sData);
- // Split constraint body, if user wants us to
- if (euHelper.getDoAutoSplit()) {
- List lConstraints = euHelper.splitConstraint(tree);
-
- if (lConstraints.size() > 0) {
- removeConstraintAt(theMNIdx);
-
- for (Iterator i = lConstraints.iterator();
- i.hasNext();) {
- OclTree ocltCurrent = (OclTree) i.next();
-
- Object mc =
- Model.getCoreFactory()
- .createConstraint();
- Model.getCoreHelper().setName(mc, ocltCurrent
- .getConstraintName());
- Model.getCoreHelper().setBody(mc,
- Model.getDataTypesFactory()
- .createBooleanExpression(
- "OCL",
- ocltCurrent
- .getExpression()));
- Model.getCoreHelper().addConstraint(
- theMMmeiTarget,
- mc);
-
- // the constraint _must_ be owned by a namespace
- if (Model.getFacade().getNamespace(
- theMMmeiTarget)
- != null) {
- Model.getCoreHelper().addOwnedElement(
- Model.getFacade().getNamespace(
- theMMmeiTarget),
- mc);
- } else if (Model.getFacade().getNamespace(
- mmeContext) != null) {
- Model.getCoreHelper().addOwnedElement(
- Model.getFacade().getNamespace(
- mmeContext),
- theMMcConstraint);
- }
-
- theMAlConstraints.add(mc);
- fireConstraintAdded();
- }
+ // Store constraint body
+ Object mcOld = null;
- return;
- }
- }
+ if (theMMcConstraint == null) {
+ // New constraint, first time setData is called
+ theMMcConstraint =
+ Model.getCoreFactory().createConstraint();
- // Store constraint body
- Object mcOld = null;
+ Model.getCoreHelper().setName(
+ theMMcConstraint,
+ "newConstraint");
+ Model.getCoreHelper().setBody(
+ theMMcConstraint,
+ Model.getDataTypesFactory()
+ .createBooleanExpression("OCL", sData));
- if (theMMcConstraint == null) {
- // New constraint, first time setData is called
- theMMcConstraint =
- Model.getCoreFactory().createConstraint();
-
- Model.getCoreHelper().setName(
- theMMcConstraint,
- "newConstraint");
- Model.getCoreHelper().setBody(
- theMMcConstraint,
- Model.getDataTypesFactory()
- .createBooleanExpression("OCL", sData));
+ Model.getCoreHelper().addConstraint(theMMmeiTarget,
+ theMMcConstraint);
- Model.getCoreHelper().addConstraint(theMMmeiTarget,
+ // the constraint _must_ be owned by a namespace
+ Object targetNamespace =
+ Model.getFacade().getNamespace(theMMmeiTarget);
+ Object contextNamespace =
+ Model.getFacade().getNamespace(mmeContext);
+ if (targetNamespace != null) {
+ Model.getCoreHelper().addOwnedElement(
+ targetNamespace,
+ theMMcConstraint);
+ } else if (contextNamespace != null) {
+ Model.getCoreHelper().addOwnedElement(
+ contextNamespace,
theMMcConstraint);
-
- // the constraint _must_ be owned by a namespace
- Object targetNamespace =
- Model.getFacade().getNamespace(theMMmeiTarget);
- Object contextNamespace =
- Model.getFacade().getNamespace(mmeContext);
- if (targetNamespace != null) {
- Model.getCoreHelper().addOwnedElement(
- targetNamespace,
- theMMcConstraint);
- } else if (contextNamespace != null) {
- Model.getCoreHelper().addOwnedElement(
- contextNamespace,
- theMMcConstraint);
- }
-
- theMAlConstraints.set(theMNIdx, theMMcConstraint);
- } else {
- mcOld = Model.getCoreFactory().createConstraint();
- Model.getCoreHelper().setName(
- mcOld,
- Model.getFacade().getName(theMMcConstraint));
- Model.getCoreHelper().setBody(
- mcOld,
- Model.getDataTypesFactory()
- .createBooleanExpression("OCL",
- (String) Model.getFacade()
- .getBody(
- Model.getFacade().getBody(
- theMMcConstraint))));
- Model.getCoreHelper().setBody(theMMcConstraint,
- Model.getDataTypesFactory()
- .createBooleanExpression("OCL", sData));
}
- fireConstraintDataChanged(theMNIdx, mcOld,
- theMMcConstraint);
-
- } catch (OclTypeException pe) {
- LOG.warn("There was some sort of OCL Type problem", pe);
- throw pe;
- } catch (OclParserException pe1) {
- LOG.warn("Could not parse the constraint", pe1);
- throw pe1;
- } catch (OclException oclExc) {
- // a runtime exception that occurs when some
- // internal test fails
- LOG.warn("There was some unidentified problem");
- throw oclExc;
+ theMAlConstraints.set(theMNIdx, theMMcConstraint);
+ } else {
+ mcOld = Model.getCoreFactory().createConstraint();
+ Model.getCoreHelper().setName(
+ mcOld,
+ Model.getFacade().getName(theMMcConstraint));
+ Model.getCoreHelper().setBody(
+ mcOld,
+ Model.getDataTypesFactory()
+ .createBooleanExpression("OCL",
+ (String) Model.getFacade()
+ .getBody(
+ Model.getFacade().getBody(
+ theMMcConstraint))));
+ Model.getCoreHelper().setBody(theMMcConstraint,
+ Model.getDataTypesFactory()
+ .createBooleanExpression("OCL", sData));
}
+
+ fireConstraintDataChanged(theMNIdx, mcOld,
+ theMMcConstraint);
+
}
/**
* Set the constraint's name.
*/
public void setName(
- final String sName,
- final EditingUtilities euHelper) {
+ final String sName,
+ final EditingUtilities euHelper) {
+ // Updated by Raphael Schmid
+
if (theMMcConstraint != null) {
// Check name for consistency with spec
if (!euHelper.isValidConstraintName(sName)) {
@@ -535,34 +464,34 @@
Model.getCoreFactory().createConstraint();
Model.getCoreHelper().setName(mcOld,
Model.getFacade().getName(theMMcConstraint));
- Object constraintBody =
+ Object constraintBody =
Model.getFacade().getBody(theMMcConstraint);
Model.getCoreHelper().setBody(mcOld,
Model.getDataTypesFactory()
.createBooleanExpression(
- "OCL",
- (String) Model.getFacade().getBody(
- constraintBody)));
+ "OCL",
+ (String) Model.getFacade().getBody(
+ constraintBody)));
Model.getCoreHelper().setName(theMMcConstraint, sName);
fireConstraintNameChanged(theMNIdx, mcOld,
- theMMcConstraint);
+ theMMcConstraint);
// Also set name in constraint body -- Added 03/14/2001
+ /* removed during OCL1 -> OCL2 migration
try {
OclTree tree = null;
Object mmeContext = OCLUtil
.getInnerMostEnclosingNamespace(theMMmeiTarget);
-
- constraintBody =
- Model.getFacade().getBody(theMMcConstraint);
+ constraintBody =
+ Model.getFacade().getBody(theMMcConstraint);
tree =
euHelper.parseAndCheckConstraint(
(String) Model.getFacade().getBody(
constraintBody),
new ArgoFacade(mmeContext));
-
+
if (tree != null) {
tree.apply(new DepthFirstAdapter() {
private int nameID = 0;
@@ -587,12 +516,15 @@
// constraint body better had log it.
LOG.error("some unidentified problem", t);
}
+ */
} else {
throw new IllegalStateException(
- "Please define and submit a constraint body first.");
+ "Please define and submit a constraint "
+ + "body first.");
}
}
}
+
/**
* Create a representation adapter for the given constraint.
@@ -643,13 +575,13 @@
// Lazily create the event:
if (cce == null) {
cce = new ConstraintChangeEvent(
- this,
- nIdx,
- new CR(mc, nIdx),
- null);
+ this,
+ nIdx,
+ new CR(mc, nIdx),
+ null);
}
((ConstraintChangeListener) listeners[i + 1])
- .constraintRemoved(cce);
+ .constraintRemoved(cce);
}
}
}
@@ -675,15 +607,15 @@
representationFor(nIdx));
}
((ConstraintChangeListener) listeners[i + 1])
- .constraintAdded(cce);
+ .constraintAdded(cce);
}
}
}
protected void fireConstraintDataChanged(
- int nIdx,
- Object mcOld,
- Object mcNew) {
+ int nIdx,
+ Object mcOld,
+ Object mcNew) {
// Guaranteed to return a non-null array
Object[] listeners = theMEllListeners.getListenerList();
@@ -696,22 +628,22 @@
// Lazily create the event:
if (cce == null) {
cce = new ConstraintChangeEvent(
- this,
- nIdx,
- new CR(mcOld, nIdx),
- new CR(mcNew, nIdx));
+ this,
+ nIdx,
+ new CR(mcOld, nIdx),
+ new CR(mcNew, nIdx));
}
((ConstraintChangeListener) listeners[i + 1])
- .constraintDataChanged(cce);
+ .constraintDataChanged(cce);
}
}
}
protected void fireConstraintNameChanged(
- int nIdx,
- Object mcOld,
- Object mcNew) {
+ int nIdx,
+ Object mcOld,
+ Object mcNew) {
// Guaranteed to return a non-null array
Object[] listeners = theMEllListeners.getListenerList();
@@ -724,14 +656,14 @@
// Lazily create the event:
if (cce == null) {
cce = new ConstraintChangeEvent(
- this,
- nIdx,
- new CR(mcOld, nIdx),
- new CR(mcNew, nIdx));
+ this,
+ nIdx,
+ new CR(mcOld, nIdx),
+ new CR(mcNew, nIdx));
}
((ConstraintChangeListener) listeners[i + 1])
- .constraintNameChanged(cce);
+ .constraintNameChanged(cce);
}
}
}
@@ -760,7 +692,7 @@
public void targetSet(TargetEvent e) {
setTarget(e.getNewTarget());
}
-
+
/*
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
*/
@@ -768,7 +700,7 @@
// Update our model with our saved target
setTargetInternal(mMmeiTarget);
}
-
+
/*
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
*/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.