Author: tfmorris
Date: 2007-07-10 10:44:47-0700
New Revision: 13023
Modified:
trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java
trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java
trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java
trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java
trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java
trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java
trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java
Log:
Issue 4789 - hide implementation classes from DiagramFactory API
Modified: trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java&p2=trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/DiagramFactory.java 2007-07-10 10:44:47-0700
@@ -24,10 +24,11 @@
package org.argouml.uml.diagram;
+import java.util.ArrayList;
+import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
import org.argouml.model.ActivityDiagram;
import org.argouml.model.ClassDiagram;
@@ -47,18 +48,50 @@
import org.argouml.uml.diagram.use_case.ui.UMLUseCaseDiagram;
import org.tigris.gef.base.Diagram;
import org.tigris.gef.graph.GraphNodeRenderer;
-import org.tigris.gef.presentation.Fig;
/**
* Provide a factory method to create different UML diagrams.
* @author Bob Tarling
*/
public final class DiagramFactory {
+
+ /**
+ * Map from our public enum to our internal implementation classes.
+ * This allows use to hide the implementation classes from users of
+ * the factory.
+ * NOTE: This needs to be initialized before the constructor is called
+ * to initialize the singleton.
+ */
+ private static Map<DiagramType, Class> diagramClasses =
+ new EnumMap<DiagramType, Class>(DiagramType.class);
+
+ /**
+ * The singleton instance.
+ */
private static DiagramFactory diagramFactory = new DiagramFactory();
- private List diagrams = new Vector();
+ /**
+ * Enumeration containing all the different types of UML diagrams.
+ */
+ public enum DiagramType {
+ Class, UseCase, State, Deployment, Collaboration, Activity, Sequence
+ }
+
+
+
+
+ private List<ArgoDiagram> diagrams = new ArrayList<ArgoDiagram>();
private DiagramFactory() {
+ super();
+ diagramClasses.put(DiagramType.Class, UMLClassDiagram.class);
+ diagramClasses.put(DiagramType.UseCase, UMLUseCaseDiagram.class);
+ diagramClasses.put(DiagramType.State, UMLStateDiagram.class);
+ diagramClasses.put(DiagramType.Deployment, UMLDeploymentDiagram.class);
+ diagramClasses.put(DiagramType.Collaboration,
+ UMLCollaborationDiagram.class);
+ diagramClasses.put(DiagramType.Activity, UMLActivityDiagram.class);
+ diagramClasses.put(DiagramType.Sequence, UMLSequenceDiagram.class);
}
/**
@@ -71,16 +104,35 @@
/**
* @return the list of diagrams
*/
- public List getDiagram() {
+ public List<ArgoDiagram> getDiagram() {
return diagrams;
}
-
-// public ArgoDiagram createDiagram(Class type, Object namespace,
-// Object machine) {
-//
-// }
+ /**
+ * Factory method to create a new default instance of an ArgoDiagram.
+ * @param namespace The namespace that (in)directly
+ * owns the elements on the diagram
+ * @return the newly instantiated class diagram
+ */
+ public ArgoDiagram createDefaultDiagram(Object namespace) {
+ return createDiagram(DiagramType.Class, namespace, null);
+ }
+
+ /**
+ * Factory method to create a new instance of an ArgoDiagram.
+ *
+ * @param type The class of rendering diagram to create
+ * @param namespace The namespace that (in)directly
+ * owns the elements on the diagram
+ * @param machine The StateMachine for the diagram
+ * (only: statemachine - activitygraph)
+ * @return the newly instantiated class diagram
+ */
+ public ArgoDiagram createDiagram(DiagramType type, Object namespace,
+ Object machine) {
+ return createDiagram(diagramClasses.get(type), namespace, machine);
+ }
/**
* Factory method to create a new instance of an ArgoDiagram.
@@ -91,7 +143,10 @@
* @param machine The StateMachine for the diagram
* (only: statemachine - activitygraph)
* @return the newly instantiated class diagram
+ * @deprecated for 0.25.4 by tfmorris. Use
+ * {@link #createDiagram(DiagramType, Object, Object)}.
*/
+ @Deprecated
public ArgoDiagram createDiagram(Class type, Object namespace,
Object machine) {
@@ -159,22 +214,24 @@
return diagram;
}
- public DiDiagram getDiDiagram(Object graphModel) {
- if (graphModel instanceof UMLMutableGraphSupport) {
- return ((UMLMutableGraphSupport) graphModel).getDiDiagram();
- }
- throw new IllegalArgumentException("graphModel: " + graphModel);
- }
+ // Unused - tfm - 20070706
+// public DiDiagram getDiDiagram(Object graphModel) {
+// if (graphModel instanceof UMLMutableGraphSupport) {
+// return ((UMLMutableGraphSupport) graphModel).getDiDiagram();
+// }
+// throw new IllegalArgumentException("graphModel: " + graphModel);
+// }
- public void addElement(Object diagram, Object element) {
- if (!(diagram instanceof ArgoDiagram)) {
- throw new IllegalArgumentException("diagram: " + diagram);
- }
- if (!(element instanceof Fig)) {
- throw new IllegalArgumentException("fig: " + element);
- }
- ((ArgoDiagram) diagram).add((Fig) element);
- }
+ // Unused - tfm 20070706
+// public void addElement(Object diagram, Object element) {
+// if (!(diagram instanceof ArgoDiagram)) {
+// throw new IllegalArgumentException("diagram: " + diagram);
+// }
+// if (!(element instanceof Fig)) {
+// throw new IllegalArgumentException("fig: " + element);
+// }
+// ((ArgoDiagram) diagram).add((Fig) element);
+// }
private final Map noStyleProperties = new HashMap();
Modified: trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/ui/ActionActivityDiagram.java 2007-07-10 10:44:47-0700
@@ -28,9 +28,8 @@
import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
import org.argouml.ui.targetmanager.TargetManager;
-import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactory;
-import org.argouml.uml.diagram.activity.ui.UMLActivityDiagram;
+import org.argouml.uml.diagram.ArgoDiagram;
/**
* Action to trigger creation of a new activity diagram.<p>
@@ -57,10 +56,11 @@
* @return the newly created and initialized diagram
*/
protected ArgoDiagram createDiagram() {
- Project p = ProjectManager.getManager().getCurrentProject();
Object target = TargetManager.getInstance().getModelTarget();
Object graph = null;
- Object namespace = p.getRoot(); // the root model
+// Project p = ProjectManager.getManager().getCurrentProject();
+// Object namespace = p.getRoot(); // the root model
+ Object namespace = Model.getModelManagementFactory().getRootModel();
if (Model.getActivityGraphsHelper().isAddingActivityGraphAllowed(
target)) {
/* The target is a valid context */
@@ -76,7 +76,7 @@
}
return DiagramFactory.getInstance().createDiagram(
- UMLActivityDiagram.class,
+ DiagramFactory.DiagramType.Activity,
Model.getFacade().getNamespace(graph),
graph);
}
@@ -86,4 +86,4 @@
*/
private static final long serialVersionUID = -28844322376391273L;
-} /* end class ActionActivityDiagram */
+}
Modified: trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/ui/ActionClassDiagram.java 2007-07-10 10:44:47-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -26,27 +26,20 @@
import org.apache.log4j.Logger;
import org.argouml.model.Model;
-import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactory;
-import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.argouml.uml.diagram.ArgoDiagram;
/**
* Action to trigger creation of new class diagram.
*/
public class ActionClassDiagram extends ActionAddDiagram {
- ////////////////////////////////////////////////////////////////
- // static variables
-
/**
* Logger.
*/
private static final Logger LOG =
Logger.getLogger(ActionClassDiagram.class);
- ////////////////////////////////////////////////////////////////
- // constructors
-
/**
* Constructor.
*/
@@ -60,7 +53,7 @@
public ArgoDiagram createDiagram(Object ns) {
if (Model.getFacade().isANamespace(ns)) {
return DiagramFactory.getInstance().createDiagram(
- UMLClassDiagram.class,
+ DiagramFactory.DiagramType.Class,
ns,
null);
}
@@ -87,4 +80,4 @@
* The UID.
*/
private static final long serialVersionUID = 2415943949021223859L;
-} /* end class ActionClassDiagram */
+}
Modified: trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/ui/ActionCollaborationDiagram.java 2007-07-10 10:44:47-0700
@@ -24,9 +24,8 @@
package org.argouml.uml.ui;
-import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactory;
-import org.argouml.uml.diagram.collaboration.ui.UMLCollaborationDiagram;
+import org.argouml.uml.diagram.ArgoDiagram;
/**
* Action to trigger creation of new collaboration diagram.
@@ -45,7 +44,7 @@
*/
public ArgoDiagram createDiagram() {
return DiagramFactory.getInstance().createDiagram(
- UMLCollaborationDiagram.class,
+ DiagramFactory.DiagramType.Collaboration,
createCollaboration(),
null);
}
@@ -55,4 +54,4 @@
*/
private static final long serialVersionUID = -1089352213298998155L;
-} /* end class ActionCollaborationDiagram */
+}
Modified: trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java 2007-07-10 10:44:47-0700
@@ -25,29 +25,22 @@
package org.argouml.uml.ui;
import org.apache.log4j.Logger;
-import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
-import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactory;
-import org.argouml.uml.diagram.deployment.ui.UMLDeploymentDiagram;
+import org.argouml.uml.diagram.ArgoDiagram;
/**
* Action to trigger creation of a deployment diagram.
*/
public class ActionDeploymentDiagram extends ActionAddDiagram {
- ////////////////////////////////////////////////////////////////
- // static variables
/**
* Logger.
*/
private static final Logger LOG =
Logger.getLogger(ActionDeploymentDiagram.class);
- ////////////////////////////////////////////////////////////////
- // constructors
-
/**
* Constructor.
*/
@@ -55,17 +48,15 @@
super("action.deployment-diagram");
}
- ////////////////////////////////////////////////////////////////
- // main methods
-
/*
* @see org.argouml.uml.ui.ActionAddDiagram#createDiagram(Object)
*/
public ArgoDiagram createDiagram(Object notUsedHandle) {
// a deployment diagram shows something about the whole model
// according to the uml spec
- Project p = ProjectManager.getManager().getCurrentProject();
- Object handle = p.getRoot();
+ Object handle = Model.getModelManagementFactory().getRootModel();
+// Project p = ProjectManager.getManager().getCurrentProject();
+// Object handle = p.getRoot();
if (!Model.getFacade().isANamespace(handle)) {
LOG.error("No namespace as argument");
LOG.error(handle);
@@ -74,7 +65,7 @@
+ "is not a namespace.");
}
return DiagramFactory.getInstance().createDiagram(
- UMLDeploymentDiagram.class,
+ DiagramFactory.DiagramType.Deployment,
handle,
null);
}
@@ -109,4 +100,4 @@
* The UID.
*/
private static final long serialVersionUID = 9027235104963895167L;
-} /* end class ActionDeploymentDiagram */
+}
Modified: trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/ui/ActionSequenceDiagram.java 2007-07-10 10:44:47-0700
@@ -24,9 +24,8 @@
package org.argouml.uml.ui;
-import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactory;
-import org.argouml.uml.diagram.sequence.ui.UMLSequenceDiagram;
+import org.argouml.uml.diagram.ArgoDiagram;
/**
* Action to add a new sequence diagram.
@@ -45,7 +44,7 @@
*/
public ArgoDiagram createDiagram() {
return DiagramFactory.getInstance().createDiagram(
- UMLSequenceDiagram.class,
+ DiagramFactory.DiagramType.Sequence,
createCollaboration(),
null);
}
Modified: trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java?view=diff&rev=13023&p1=trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java&r1=13022&r2=13023
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/ui/ActionUseCaseDiagram.java 2007-07-10 10:44:47-0700
@@ -26,9 +26,8 @@
import org.apache.log4j.Logger;
import org.argouml.model.Model;
-import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactory;
-import org.argouml.uml.diagram.use_case.ui.UMLUseCaseDiagram;
+import org.argouml.uml.diagram.ArgoDiagram;
/**
* Action to create a new use case diagram.
@@ -56,7 +55,7 @@
"The argument " + namespace + "is not a namespace.");
}
return DiagramFactory.getInstance().createDiagram(
- UMLUseCaseDiagram.class,
+ DiagramFactory.DiagramType.UseCase,
namespace,
null);
}
@@ -67,7 +66,7 @@
public boolean isValidNamespace(Object handle) {
boolean validNamespace = false;
if (Model.getFacade().isAPackage(handle)
- || Model.getFacade().isAClassifier(handle))
+ || Model.getFacade().isAClassifier(handle))
validNamespace = true;
return validNamespace;
}
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.