svn commit: r13008 - trunk/src_new/org/argouml: ui/cmd ui/explorer uml/diagram uml/diagram/ui uml/reveng/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-07-09 13:19:33-0700
New Revision: 13008

Added:
   trunk/src_new/org/argouml/uml/diagram/ArgoDiagramImpl.java
      - copied, changed from r13005, /trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java
Modified:
   trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java
   trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java
   trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java
   trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java
   trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java
   trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java

Log:
Issue 4789 - Introduce interface for ArgoDiagram to decouple users from the implementation

Modified: trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java?view=diff&rev=13008&p1=trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java&p2=trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java&r1=13007&r2=13008
==============================================================================
--- trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java	(original)
+++ trunk/src_new/org/argouml/ui/cmd/ActionGotoDiagram.java	2007-07-09 13:19:33-0700
@@ -34,7 +34,7 @@
 import org.argouml.kernel.ProjectManager;
 import org.argouml.ui.GotoDialog;
 import org.argouml.ui.targetmanager.TargetManager;
-import org.tigris.gef.base.Diagram;
+import org.argouml.uml.diagram.ArgoDiagram;
 import org.tigris.gef.undo.UndoableAction;
 
 ////////////////////////////////////////////////////////////////
@@ -73,7 +73,7 @@
      */
     public boolean doCommand(String argument) {
 	Project p = ProjectManager.getManager().getCurrentProject();
-        Diagram d = p.getDiagram(argument);
+        ArgoDiagram d = p.getDiagram(argument);
         if (d != null) {
             TargetManager.getInstance().setTarget(d);
             return true;

Modified: trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java?view=diff&rev=13008&p1=trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java&p2=trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java&r1=13007&r2=13008
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java	(original)
+++ trunk/src_new/org/argouml/ui/explorer/ExplorerPopup.java	2007-07-09 13:19:33-0700
@@ -106,13 +106,13 @@
 
         final Project currentProject =
             ProjectManager.getManager().getCurrentProject();
-        final Diagram activeDiagram = currentProject.getActiveDiagram();
+        final ArgoDiagram activeDiagram = currentProject.getActiveDiagram();
 
         // TODO: I've made some attempt to rationalize the conditions here
         // and make them more readable. However I'd suggest that the
         // conditions should move to each diagram.
         // Break up one complex method into a few simple ones and
-        // give the diagrams more knowledge of themselelves
+        // give the diagrams more knowledge of themselves
         // (although the diagrams may in fact delegate this in
         // turn to the Model component).
         // Bob Tarling 31 Jan 2004

Copied: trunk/src_new/org/argouml/uml/diagram/ArgoDiagramImpl.java (from r13005, /trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java)
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ArgoDiagramImpl.java?view=diff&rev=13008&p1=/trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java&p2=trunk/src_new/org/argouml/uml/diagram/ArgoDiagramImpl.java&r1=13005&r2=13008
==============================================================================
--- /trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ArgoDiagramImpl.java	2007-07-09 13:19:33-0700
@@ -42,6 +42,7 @@
 import org.argouml.uml.diagram.static_structure.ui.FigComment;
 import org.argouml.uml.diagram.ui.FigEdgeModelElement;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.util.EnumerationIterator;
 import org.tigris.gef.base.Diagram;
 import org.tigris.gef.base.Editor;
 import org.tigris.gef.graph.MutableGraphSupport;
@@ -73,20 +74,20 @@
  * And the namespace of the statechart diagram should be 
  * the namespace of its statemachine.
  */
-public abstract class ArgoDiagram extends Diagram 
-    implements PropertyChangeListener {
+public abstract class ArgoDiagramImpl extends Diagram 
+    implements PropertyChangeListener, ArgoDiagram {
 
     private ItemUID id;
 
     /**
      * Logger.
      */
-    private static final Logger LOG = Logger.getLogger(ArgoDiagram.class);
+    private static final Logger LOG = Logger.getLogger(ArgoDiagramImpl.class);
 
     /**
      * The constructor.
      */
-    public ArgoDiagram() {
+    public ArgoDiagramImpl() {
         super();
         // really dirty hack to remove unwanted listeners
         getLayer().getGraphModel().removeGraphEventListener(getLayer());
@@ -104,7 +105,7 @@
      *
      * @param diagramName the name of the diagram
      */
-    public ArgoDiagram(String diagramName) {
+    public ArgoDiagramImpl(String diagramName) {
         // next line patch to issue 596 (hopefully)
         super(diagramName);
         try {
@@ -112,52 +113,30 @@
         } catch (PropertyVetoException pve) { }
     }
 
-    ////////////////////////////////////////////////////////////////
-    // accessors
 
-    /*
-     * @see org.tigris.gef.base.Diagram#setName(java.lang.String)
-     */
+
     public void setName(String n) throws PropertyVetoException {
         super.setName(n);
         MutableGraphSupport.enableSaveAction();
     }
 
-    /**
-     * @param i the new id
-     */
+
     public void setItemUID(ItemUID i) {
         id = i;
     }
 
-    /**
-     * USED BY pgml.tee!!
-     * @return the item UID
-     */
+
     public ItemUID getItemUID() {
         return id;
     }
 
-    /** The bean property name denoting the diagram's namespace. 
-     * Value is a String. */
-    public static final String NAMESPACE_KEY = "namespace";
 
-    ////////////////////////////////////////////////////////////////
-    // event management
     /**
      * The UID.
      */
     static final long serialVersionUID = -401219134410459387L;
 
-    /**
-     * TODO: The reference to the method
-     * org.argouml.uml.ui.VetoablePropertyChange#getVetoMessage(String)
-     * was here but the class does exist anymore. Where is it?
-     * This method is never used!
-     *
-     * @param propertyName is the name of the property
-     * @return a message or null if not applicable.
-     */
+
     public String getVetoMessage(String propertyName) {
     	if (propertyName.equals("name")) {
 	    return "Name of diagram may not exist already";
@@ -165,17 +144,7 @@
         return null;
     }
 
-    /**
-     * Finds the presentation (the Fig) for some object. If the object
-     * is a modelelement that is contained in some other modelelement
-     * that has its own fig, that fig is returned. It extends
-     * presentationFor that only gets the fig belonging to the node
-     * obj.<p>
-     *
-     * @author [email protected]
-     * @return the Fig for the object
-     * @param obj is th object
-     */
+
     public Fig getContainingFig(Object obj) {
         Fig fig = super.presentationFor(obj);
         if (fig == null && Model.getFacade().isAUMLElement(obj)) {
@@ -192,10 +161,7 @@
         return fig;
     }
 
-    /**
-     * This will mark the entire visible area of all Editors to be repaired
-     *  from any damage - i.e. repainted.
-     */
+
     public void damage() {
         if (getLayer() != null && getLayer().getEditors() != null) {
             Iterator it = getLayer().getEditors().iterator();
@@ -205,11 +171,7 @@
         }
     }
 
-    /*
-     * Get all the model elements in this diagram that are represented
-     * by a FigEdge.
-     * @see org.tigris.gef.base.Diagram#getEdges()
-     */
+
     public List getEdges() {
         if (getGraphModel() != null) {
             return getGraphModel().getEdges();
@@ -218,11 +180,6 @@
     }
 
 
-    /*
-     * Get all the model elements in this diagram that are represented
-     * by a FigNode.
-     * @see org.tigris.gef.base.Diagram#getNodes()
-     */
     public List getNodes() {
         if (getGraphModel() != null) {
             return getGraphModel().getNodes();
@@ -231,22 +188,11 @@
     }
 
 
-    /*
-     * @see java.lang.Object#toString()
-     */
     public String toString() {
         return "Diagram: " + getName();
     }
 
-    /**
-     * We hang our heads in shame. There are still bugs in ArgoUML
-     * and/or GEF that cause corruptions in the model.
-     * Before a save takes place we repair the model in order to
-     * be as certain as possible that the saved file will reload.
-     * TODO: Split into small inner classes for each fix.
-     *
-     * @return A text that explains what is repaired.
-     */
+
     public String repair() {
         StringBuffer report = new StringBuffer(500);
 
@@ -456,14 +402,7 @@
         return description + "\n";
     }
 
-    /*
-     * Find the all Figs that visualise the given model element in
-     * this layer, or null if there is none.
-     * 
-     * TODO: once GEF includes this same method in Diagram then the can go
-     * 
-     * @see org.tigris.gef.base.Diagram#presentationsFor(java.lang.Object)
-     */
+
     public List presentationsFor(Object obj) {
         List presentations = new ArrayList();
         int figCount = getLayer().getContents().size();
@@ -489,6 +428,7 @@
         super.remove();
     }
     
+
     public void setProject(Project p) {
 	this.project = p;
     }
@@ -497,45 +437,21 @@
 	return project;
     }
     
-    /**
-     * Called when the user releases a dragged a FigNode.
-     * 
-     * @param enclosed the enclosed FigNode that was dragged into the encloser
-     * @param oldEncloser the previous encloser
-     * @param newEncloser the FigNode that encloses the dragged FigNode
-     */
     public abstract void encloserChanged(
             FigNode enclosed, FigNode oldEncloser, FigNode newEncloser); 
 	// Do nothing, override in subclass.
 
-    /**
-     * This method shall return any UML modelelements
-     * that should be deleted when the diagram gets deleted,
-     * or null if there are none. The default implementation returns null;
-     * e.g. a statechart diagram should return its statemachine.
-     *
-     * @author [email protected]
-     *
-     * @return the dependent element - in the general case there aren't, so null
-     */
+
     public Object getDependentElement() {
         return null;
     }
 
-    /**
-     * @return the namespace for the diagram
-     */
+
     public Object getNamespace() {
         return namespace;
     }
 
-    /**
-     * Sets the namespace of the Diagram, and
-     * adds the diagram as a listener of its namespace in the UML model
-     * (so that it can delete itself when the model element is deleted).
-     *
-     * @param ns the namespace for the diagram
-     */
+
     public void setNamespace(Object ns) {
         if (!Model.getFacade().isANamespace(ns)) {
             LOG.error("Not a namespace");
@@ -557,15 +473,7 @@
         Model.getPump().addModelEventListener(this, namespace, "remove");
     }
 
-    /**
-     * Set the namespace of a model element to the owner of
-     * the given namespace. If the namespace is null
-     * the namespace of the diagram is used instead.
-     * If the modelElement is not valid in the given namespace
-     * this method takes no action.
-     * @param modelElement the model element
-     * @param ns the namespace
-     */
+
     public void setModelElementNamespace(Object modelElement, Object ns) {
         if (modelElement == null) {
             return;
@@ -605,19 +513,7 @@
         }
     }
 
-    /**
-     * This diagram listens to events from its namespace ModelElement;
-     * when the modelelement is removed, we also want to delete this
-     * diagram.  <p>
-     *
-     * There is also a risk that if this diagram was the one shown in
-     * the diagram panel, then it will remain after it has been
-     * deleted. So we need to deselect this diagram. 
-     * There are other things to take care of, so all this is delegated to 
-     * {@link org.argouml.kernel.Project#moveToTrash(Object)}.
-     *
-     * {@inheritDoc}
-     */
+
     public void propertyChange(PropertyChangeEvent evt) {
         if ((evt.getSource() == namespace)
                 && (evt instanceof DeleteInstanceEvent)
@@ -629,14 +525,13 @@
         }
     }
 
-    /**
-     * The default implementation for diagrams that
-     * have the namespace as their owner.
-     *
-     * @return the namespace
-     */
+
     public Object getOwner() {
         return getNamespace();
     }
 
-} /* end class ArgoDiagram */
+    public Iterator<Fig> getFigIterator() {
+        return new EnumerationIterator(elements());
+    }
+    
+}

Modified: trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java?view=diff&rev=13008&p1=trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java&r1=13007&r2=13008
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ActionAddNote.java	2007-07-09 13:19:33-0700
@@ -40,7 +40,6 @@
 import org.argouml.ui.targetmanager.TargetManager;
 import org.argouml.uml.CommentEdge;
 import org.argouml.uml.diagram.ArgoDiagram;
-import org.tigris.gef.base.Diagram;
 import org.tigris.gef.graph.MutableGraphModel;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.FigEdge;
@@ -157,7 +156,7 @@
      * @return The position where it should be placed.
      */
     private Point calculateLocation(
-            Diagram diagram, Object firstTarget, Fig noteFig) {
+            ArgoDiagram diagram, Object firstTarget, Fig noteFig) {
         Point point = new Point(DEFAULT_POS, DEFAULT_POS);
 
         if (firstTarget == null) {

Modified: trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java?view=diff&rev=13008&p1=trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java&r1=13007&r2=13008
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java	2007-07-09 13:19:33-0700
@@ -405,8 +405,8 @@
 
     public void propertyChange(PropertyChangeEvent arg0) {
         if ("remove".equals(arg0.getPropertyName())) {
-            Diagram diagram = ProjectManager.getManager()
-                .getCurrentProject().getActiveDiagram();
+            ArgoDiagram diagram = ProjectManager.getManager()
+                    .getCurrentProject().getActiveDiagram();
             TargetManager.getInstance().setTarget(diagram);
         }
     }

Modified: trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java?view=diff&rev=13008&p1=trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java&r1=13007&r2=13008
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/UMLDiagram.java	2007-07-09 13:19:33-0700
@@ -45,7 +45,7 @@
 import org.argouml.model.Model;
 import org.argouml.ui.CmdCreateNode;
 import org.argouml.uml.UUIDHelper;
-import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.ArgoDiagramImpl;
 import org.argouml.uml.diagram.Relocatable;
 import org.argouml.uml.diagram.UMLMutableGraphSupport;
 import org.argouml.util.ToolBarUtility;
@@ -86,7 +86,7 @@
  * panel as the "home model". <p>
  */
 public abstract class UMLDiagram
-    extends ArgoDiagram
+    extends ArgoDiagramImpl
     implements Relocatable {
 
     /**

Modified: trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java?view=diff&rev=13008&p1=trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java&p2=trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java&r1=13007&r2=13008
==============================================================================
--- trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java	(original)
+++ trunk/src_new/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java	2007-07-09 13:19:33-0700
@@ -36,7 +36,6 @@
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
@@ -180,15 +179,15 @@
             portCnt =
                 SequenceDiagramLayer.getNodeIndex(
                     figMessage.getDestMessageNode().getFigMessagePort().getY());
-            Enumeration enu = diagram.elements();
-            while (enu.hasMoreElements()) {
-                Object f = enu.nextElement();
+            Iterator<Fig> it = diagram.getFigIterator();
+            while (it.hasNext()) {
+                Fig f = it.next();
                 if (f instanceof FigClassifierRole) {
-                    int x = ((Fig) f).getX();
+                    int x = f.getX();
                     if (maxXPos < x) {
                         maxXPos = x;
                     }
-                    if (Model.getFacade().getName(((Fig) f).getOwner())
+                    if (Model.getFacade().getName(f.getOwner())
                             .startsWith("anon")) {
                         anonCnt++;
                     }
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.