svn commit: r13575 - trunk/src_new/org/argouml/uml: diagram/deployment/ui ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2007-09-18 03:13:45-0700
New Revision: 13575

Modified:
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java
   trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java
   trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java

Log:
Fix for issue 3819: The Deployment diagram is always located directly under the model, while it
should be possible to create one for any Package (should have similar behaviour
as a ClassDiagram).
- You can now relocate a deployment diagram by drag and drop in the explorer.
- Deployment diagrams can only exist in a package, i.e. not just any namespace.
- You can create a deployment diagram while a namespace is selected, and the diagram will be created in the "nearest" package.

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java?view=diff&rev=13575&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java&r1=13574&r2=13575
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/UMLDeploymentDiagram.java	2007-09-18 03:13:45-0700
@@ -117,29 +117,29 @@
      * in <em>LayerManager</em>(GEF) to control the adding, changing and
      * deleting layers on the diagram...<p>
      *
-     * @param handle Namespace from the model
+     * @param handle package from the model
      * @author [email protected] Jan. 24, 2002
      */
     public void setNamespace(Object handle) {
-        if (!Model.getFacade().isANamespace(handle)) {
+        if (!Model.getFacade().isAPackage(handle)) {
             LOG.error(
-                "Illegal argument. Object " + handle + " is not a namespace");
+                "Illegal argument. Object " + handle + " is not a package");
             throw new IllegalArgumentException(
-                "Illegal argument. Object " + handle + " is not a namespace");
+                "Illegal argument. Object " + handle + " is not a package");
         }
         Object m = handle;
+        boolean init = (null == getNamespace());
         super.setNamespace(m);
         DeploymentDiagramGraphModel gm = createGraphModel();
         gm.setHomeModel(m);
-        LayerPerspective lay =
-            new LayerPerspectiveMutable(Model.getFacade().getName(m), gm);
-        DeploymentDiagramRenderer rend = new DeploymentDiagramRenderer();
-        lay.setGraphNodeRenderer(rend);
-        lay.setGraphEdgeRenderer(rend);
-        setLayer(lay);
-
-        // singleton
-
+        if (init) {
+            LayerPerspective lay =
+                new LayerPerspectiveMutable(Model.getFacade().getName(m), gm);
+            DeploymentDiagramRenderer rend = new DeploymentDiagramRenderer();
+            lay.setGraphNodeRenderer(rend);
+            lay.setGraphEdgeRenderer(rend);
+            setLayer(lay);
+        }
     }
     
     // TODO: Needs to be tidied up after stable release. Graph model
@@ -456,18 +456,16 @@
      * @see org.argouml.uml.diagram.ui.UMLDiagram#isRelocationAllowed(java.lang.Object)
      */
     public boolean isRelocationAllowed(Object base)  {
-        return false;
-        /* TODO: We may return the following when the
-         * relocate() has been implemented.
-         */
-//      base == ProjectManager.getManager().getCurrentProject().getModel();
+        return Model.getFacade().isAPackage(base);
     }
 
     /*
      * @see org.argouml.uml.diagram.ui.UMLDiagram#relocate(java.lang.Object)
      */
     public boolean relocate(Object base) {
-        return false;
+        setNamespace(base);
+        damage();
+        return true;
     }
     
     /**
@@ -503,11 +501,11 @@
             FigNode newEncloser) {
         if (oldEncloser != null && newEncloser == null
                 && Model.getFacade().isAComponent(oldEncloser.getOwner())) {
-            Collection er1 = Model.getFacade().getElementResidences(
+            Collection<Object> er1 = Model.getFacade().getElementResidences(
                     enclosed.getOwner());
             Collection er2 = Model.getFacade().getResidentElements(
                     oldEncloser.getOwner());
-            Collection common = new ArrayList(er1);
+            Collection<Object> common = new ArrayList<Object>(er1);
             common.retainAll(er2);
             for (Object elementResidence : common) {
                 Model.getUmlFactory().delete(elementResidence);

Modified: trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java?view=diff&rev=13575&p1=trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java&r1=13574&r2=13575
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/ActionAddDiagram.java	2007-09-18 03:13:45-0700
@@ -94,7 +94,7 @@
      *
      * @return the namespace or null
      */
-    private Object findNamespace() {
+    protected Object findNamespace() {
         Project p = ProjectManager.getManager().getCurrentProject();
         Object target = TargetManager.getInstance().getModelTarget();
         Object ns = null;

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=13575&p1=trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java&p2=trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java&r1=13574&r2=13575
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/ActionDeploymentDiagram.java	2007-09-18 03:13:45-0700
@@ -87,6 +87,30 @@
         return false;
     }
 
+    /* 
+     * For a deployment diagram, not just any 
+     * namespace will do - we need a package. 
+     */
+    @Override
+    protected Object findNamespace() {
+        Object ns = super.findNamespace();
+        if (ns == null) {
+            return ns;
+        }
+        if (!Model.getFacade().isANamespace(ns)) {
+            return ns;
+        }
+        while (!Model.getFacade().isAPackage(ns)) {
+            // ns is a namespace, but not a package
+            Object candidate = Model.getFacade().getNamespace(ns);
+            if (!Model.getFacade().isANamespace(candidate)) {
+                return null;
+            }
+            ns = candidate;
+        }
+        return ns;
+    }
+
     /**
      * The UID.
      */
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.