svn commit: r13010 - trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java

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

Added:
   trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java   (contents, props changed)

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

Added: trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java?view=auto&rev=13010
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/uml/diagram/ArgoDiagram.java	2007-07-09 13:22:55-0700
@@ -0,0 +1,306 @@
+// $Id$
+// Copyright (c) 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.diagram;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+import org.argouml.cognitive.ItemUID;
+import org.argouml.kernel.Project;
+import org.tigris.gef.base.Diagram;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.graph.GraphModel;
+import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigNode;
+
+/**
+ * An interface to decouple ArgoUML from GEF and to untangle the Project <->
+ * ArgoDiagram ball of string.
+ * <p>
+ * Although this interface is implemented by {@link ArgoDiagramImpl}, it does
+ * <em>NOT</em> extend any GEF interfaces (since GEF is made up entirely of
+ * concrete classes), so any new methods which are added to
+ * {@link org.tigris.gef.base.Diagram} and which are needed by ArgoUML will need
+ * to be added to this interface manually.
+ * 
+ * @author Tom Morris <[email protected]>
+ * @since 0.25.4 when it replaced the implementation class of the same name
+ */
+public interface ArgoDiagram {
+
+    /*
+     * @see org.tigris.gef.base.Diagram#setName(java.lang.String)
+     */
+    public void setName(String n) throws PropertyVetoException;
+
+    /**
+     * @param i the new id
+     */
+    public void setItemUID(ItemUID i);
+
+    /**
+     * USED BY pgml.tee!!
+     * @return the item UID
+     */
+    public ItemUID getItemUID();
+
+    /** The bean property name denoting the diagram's namespace. 
+     * Value is a String. */
+    public static final String NAMESPACE_KEY = "namespace";
+
+    /**
+     * 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);
+
+    /**
+     * 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);
+
+    /**
+     * This will mark the entire visible area of all Editors to be repaired
+     *  from any damage - i.e. repainted.
+     */
+    public void damage();
+
+    /**
+     * Get all the model elements in this diagram that are represented
+     * by a FigEdge.
+     * @see org.tigris.gef.base.Diagram#getEdges()
+     */
+    public List getEdges();
+
+    /**
+     * Get all the model elements in this diagram that are represented
+     * by a FigNode.
+     * @see org.tigris.gef.base.Diagram#getNodes()
+     */
+    public List getNodes();
+
+
+    /**
+     * 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();
+
+    /**
+     * 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);
+
+    // TODO: Move to GEF
+    public void remove();
+
+    public void setProject(Project p);
+
+    /**
+     * 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 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 the namespace for the diagram
+     */
+    public Object getNamespace();
+
+    /**
+     * 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);
+
+    /**
+     * 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);
+
+    /**
+     * 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);
+
+    /**
+     * The default implementation for diagrams that
+     * have the namespace as their owner.
+     *
+     * @return the namespace
+     */
+    public Object getOwner();
+    
+    /**
+     * @return an iterator which iterates over all Figs in Diagram
+     */
+    public Iterator<Fig> getFigIterator();
+    
+    ///////////////// GEF Methods ////////////////////////////
+    // TODO: These should really be picked up automatically from
+    // some GEF interface that we extend, but there is no such
+    // thing.  NOTE: We've only added methods used by ArgoUML,
+    // so it's possible that external consumers need other methods.
+    
+    /**
+     * @return an enumeration of the contents of the fig.
+     * @deprecated for 0.25.4 by tfmorris. Use {@link #getFigIterator()}.
+     * @see Diagram#elements()
+     */
+    public Enumeration elements();
+    /**
+     * @param listener
+     * @see Diagram#addVetoableChangeListener(VetoableChangeListener)
+     */
+    public void addVetoableChangeListener(VetoableChangeListener listener);
+
+    /**
+     * @param listener
+     * @see Diagram#removeVetoableChangeListener(VetoableChangeListener)
+     */
+    public void removeVetoableChangeListener(VetoableChangeListener listener);
+
+    /**
+     * @param property
+     * @param listener
+     * @see Diagram#addPropertyChangeListener(String, PropertyChangeListener)
+     */
+    public void addPropertyChangeListener(String property,
+            PropertyChangeListener listener);
+
+    /**
+     * @param property
+     * @param listener
+     * @see Diagram#removePropertyChangeListener(String, PropertyChangeListener)
+     */
+    public void removePropertyChangeListener(String property,
+            PropertyChangeListener listener);
+    
+    /**
+     * @return
+     * @see Diagram#getGraphModel()
+     */
+    public GraphModel getGraphModel();
+    
+    /**
+     * @return
+     * @see Diagram#getLayer()
+     */
+    public LayerPerspective getLayer();
+    
+    /**
+     * @param figures list of Figures to check for in diagram
+     * @return count of figures contained in this diagram
+     * @see Diagram#countContained(List)
+     */
+    public int countContained(List figures);
+    
+    /**
+     * @param o The object which owns the fig
+     * @return the corresponding fig
+     * @see Diagram#presentationFor(Object)
+     */
+    public Fig presentationFor(Object o);
+    
+    /**
+     * @param f Fig to be added
+     * @see Diagram#add(Fig)
+     */
+    public void add(Fig f);
+    
+    /**
+     * @return the name of the diagram
+     * @see Diagram#getName()
+     */
+    public String getName();
+    
+    /////////////////// End GEF methods ////////////////////////
+
+}
\ No newline at end of file
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.