Author: b00__1
Date: 2007-08-03 02:05:20-0700
New Revision: 13213
Modified:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java
Log:
Implemented addAllStereotypes() and addAnnotatedElement()
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java?view=diff&rev=13213&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java&r1=13212&r2=13213
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java 2007-08-03 02:05:20-0700
@@ -35,10 +35,10 @@
import org.argouml.model.NotImplementedException;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.uml2.common.edit.command.ChangeCommand;
-import org.eclipse.uml2.uml.AggregationKind;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.BehavioralFeature;
import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Dependency;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Extend;
@@ -51,6 +51,7 @@
import org.eclipse.uml2.uml.PackageableElement;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.RedefinableElement;
+import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.StructuralFeature;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.TypedElement;
@@ -66,6 +67,8 @@
* The model implementation.
*/
private EUMLModelImplementation modelImpl;
+
+ private EditingDomain editingDomain;
/**
* Constructor.
@@ -74,16 +77,49 @@
*/
public CoreHelperEUMLImpl(EUMLModelImplementation implementation) {
modelImpl = implementation;
+ editingDomain = implementation.getEditingDomain();
}
- public void addAllStereotypes(Object modelElement, Collection stereos) {
- throw new NotYetImplementedException();
-
+ public void addAllStereotypes(final Object modelElement, final Collection stereos) {
+ if (!(modelElement instanceof Element)) {
+ throw new IllegalArgumentException("modelElement must be instance of Element"); //$NON-NLS-1$
+ }
+ if (stereos == null) {
+ throw new NullPointerException("stereos must be non-null"); //$NON-NLS-1$
+ }
+ for (Object o : stereos) {
+ if (!(o instanceof Stereotype)) {
+ throw new IllegalArgumentException("The stereotypes from stereo collection must be instances of Stereotype"); //$NON-NLS-1$
+ }
+ if (!((Element) modelElement).isStereotypeApplicable((Stereotype) o)) {
+ throw new UnsupportedOperationException("The stereotype " + o + " cannot be applied to " + modelElement); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ RunnableClass run = new RunnableClass() {
+ public void run() {
+ for (Object o : stereos) {
+ ((Element) modelElement).applyStereotype((Stereotype) o);
+ }
+ }
+ };
+ editingDomain.getCommandStack().execute(
+ new ChangeCommand(editingDomain, run, "Apply stereotypes to an Element"));
}
- public void addAnnotatedElement(Object comment, Object annotatedElement) {
- throw new NotYetImplementedException();
-
+ public void addAnnotatedElement(final Object comment, final Object annotatedElement) {
+ if (!(annotatedElement instanceof Element)) {
+ throw new IllegalArgumentException("annotatedElement must be instance of Element"); //$NON-NLS-1$
+ }
+ if (!(comment instanceof Comment)) {
+ throw new IllegalArgumentException("comment must be instance of Comment"); //$NON-NLS-1$
+ }
+ RunnableClass run = new RunnableClass() {
+ public void run() {
+ ((Comment) comment).getAnnotatedElements().add((Element) annotatedElement);
+ }
+ };
+ editingDomain.getCommandStack().execute(
+ new ChangeCommand(editingDomain, run, "Add an annotated element to a comment"));
}
public void addClient(Object dependency, Object element) {
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.