Author: b00__1
Date: 2007-08-15 12:49:14-0700
New Revision: 13371
Modified:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java
Log:
Use the editing domain's command stack
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java?view=diff&rev=13371&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java&r1=13370&r2=13371
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java 2007-08-15 12:49:14-0700
@@ -60,45 +60,106 @@
}
public Actor buildActor(Object actor, Object model) {
+ if (!(actor instanceof Actor)) {
+ throw new IllegalArgumentException();
+ }
+ if (((Actor) actor).getNamespace() == null
+ && !(model instanceof Namespace)) {
+ throw new IllegalArgumentException();
+ }
Namespace ns = ((Actor) actor).getNamespace();
if (ns == null) {
ns = (Namespace) model;
}
- Actor actor2 = (Actor) createActor();
- modelImpl.getCoreHelper().addOwnedElement(ns, actor2);
- actor2.setIsLeaf(false);
-// actor2.setIsRoot(false);
- return actor2;
+ Actor ret = createActor();
+ modelImpl.getCoreHelper().addOwnedElement(
+ ns, ret, "Create the actor # in the namespace #", ret, ns);
+// ret.setIsLeaf(false);
+// ret.setIsRoot(false);
+ return ret;
}
public Extend buildExtend(Object abase, Object anextension) {
return buildExtend(abase, anextension, null);
}
- public Extend buildExtend(Object abase, Object anextension, Object apoint) {
- ExtensionPoint ep;
- if (apoint == null) {
- ep = buildExtensionPoint((UseCase) abase);
- } else {
- ep = (ExtensionPoint) apoint;
- if (!ep.getUseCase().equals(abase)) {
- throw new IllegalArgumentException(
- "extension point must belong to " + //$NON-NLS-1$
- "extended use case"); //$NON-NLS-1$
- }
+ public Extend buildExtend(final Object extendedCase,
+ final Object extension, final Object extensionLocation) {
+ if (!(extendedCase instanceof UseCase)
+ || !(extension instanceof UseCase)) {
+ throw new IllegalArgumentException();
}
- Extend extend =
- ((UseCase) anextension).createExtend(null, (UseCase) abase);
- extend.getExtensionLocations().add(ep);
- return extend;
+ if (extensionLocation != null
+ && !(extensionLocation instanceof ExtensionPoint)) {
+ throw new IllegalArgumentException();
+ }
+ if (extensionLocation != null
+ && !((ExtensionPoint) extensionLocation).getUseCase().equals(
+ extendedCase)) {
+ throw new IllegalArgumentException(
+ "extensionLocation must belong to " + extendedCase); //$NON-NLS-1$
+ }
+ RunnableClass run = new RunnableClass() {
+ public void run() {
+ ExtensionPoint ep;
+ if (extensionLocation == null) {
+ ep = createExtensionPoint();
+ ((UseCase) extendedCase).getExtensionPoints().add(ep);
+ } else {
+ ep = (ExtensionPoint) extensionLocation;
+ }
+ Extend extend = createExtend();
+ extend.setExtendedCase((UseCase) extendedCase);
+ extend.setExtension((UseCase) extension);
+ extend.getExtensionLocations().add(ep);
+ getParams().add(extend);
+ getParams().add(ep);
+ }
+ };
+ ChangeCommand cmd = new ChangeCommand(
+ modelImpl, run,
+ "Create the extend # for the case # that extends the case # through #");
+ modelImpl.getEditingDomain().getCommandStack().execute(cmd);
+ cmd.setObjects(
+ run.getParams().get(0), extension, extendedCase,
+ run.getParams().get(1));
+
+ return (Extend) run.getParams().get(0);
}
public ExtensionPoint buildExtensionPoint(Object modelElement) {
- return ((UseCase) modelElement).createExtensionPoint(null);
+ if (!(modelElement instanceof UseCase)) {
+ throw new IllegalArgumentException();
+ }
+ ExtensionPoint ep = createExtensionPoint();
+ modelImpl.getCoreHelper().addOwnedElement(
+ modelElement, ep,
+ "Create the extension point # for the case #", ep,
+ modelElement);
+ return ep;
}
- public Include buildInclude(Object abase, Object anaddition) {
- return ((UseCase) anaddition).createInclude(null, (UseCase) abase);
+ public Include buildInclude(final Object addition,
+ final Object includingCase) {
+ if (!(addition instanceof UseCase)
+ || !(includingCase instanceof UseCase)) {
+ throw new IllegalArgumentException();
+ }
+ RunnableClass run = new RunnableClass() {
+ public void run() {
+ Include include = createInclude();
+ include.setAddition((UseCase) addition);
+ include.setIncludingCase((UseCase) includingCase);
+ getParams().add(include);
+ }
+ };
+ ChangeCommand cmd = new ChangeCommand(
+ modelImpl, run,
+ "Create the include # of the including case # that include the case #");
+ modelImpl.getEditingDomain().getCommandStack().execute(cmd);
+ cmd.setObjects(run.getParams().get(0), includingCase, addition);
+
+ return (Include) run.getParams().get(0);
}
public Actor createActor() {
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.