svn commit: r16541 - trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui

Michiel van der Wulp <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2009-01-07 23:46:08-0800
New Revision: 16541

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/FigClassifierRole.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/UMLCollaborationDiagram.java

Log:
Fix for issue 5500 for ClassifierRole (new constructors).
Fix for issue 5598: ClassifierRole grows when reloading. Fixed by the setLocation() call.

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/FigClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/FigClassifierRole.java?view=diff&pathrev=16541&r1=16540&r2=16541
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/FigClassifierRole.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/FigClassifierRole.java	2009-01-07 23:46:08-0800
@@ -27,16 +27,13 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Rectangle;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
 import java.util.Iterator;
 
 import org.argouml.model.AddAssociationEvent;
 import org.argouml.model.AttributeChangeEvent;
-import org.argouml.model.Model;
 import org.argouml.model.UmlChangeEvent;
-import org.argouml.notation.NotationProvider;
 import org.argouml.notation.NotationProviderFactory2;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
 import org.tigris.gef.base.Layer;
 import org.tigris.gef.base.Selection;
@@ -63,8 +60,6 @@
      */
     private static final int PADDING = 5;
 
-    private NotationProvider notationProvider;
-
     /**
      * The fig that is used for the complete classifier role.
      * Identical in size to {@link FigNodeModelElement#bigPort}.<p>
@@ -78,9 +73,60 @@
      * connections ({@link FigNodeModelElement#bigPort}), with
      * matching rectangle providing the graphic rendering ({@link
      * #cover}). Stereotype and name are rendered centrally in the
-     * rectangle.<p>
+     * rectangle.
+     * 
+     * @deprecated for 0.27.4 by mvw. Use 
+     * {@link #FigClassifierRole(Object, Rectangle, DiagramSettings)}.
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public FigClassifierRole() {
+        initClassifierRoleFigs();
+        
+        // Set our bounds to those we are given.
+
+        Rectangle r = getBounds();
+        setBounds(r.x, r.y, r.width, r.height);
+    }
+
+    /**
+     * Variant constructor that associates the classifier role with a
+     * particular model element.<p>
+     *
+     * Classifier role is constructed with {@link #FigClassifierRole()}.<p>
+     *
+     * @param gm    The graph model to use. Ignored in this implementation.
+     * @param lay   The layer
+     * @param node  The model element object to associate with this Fig.
+     * @deprecated for 0.27.4 by mvw.  Use 
+     * {@link #FigClassifierRole(Object, Rectangle, DiagramSettings)}.
+     */
+    @SuppressWarnings("deprecation")
+    @Deprecated
+    public FigClassifierRole(@SuppressWarnings("unused")
+            GraphModel gm, Layer lay, Object node) {
+        this();
+        setLayer(lay);
+        setOwner(node);
+    }
+
+    /**
+     * Construct a FigClassifierRole.
+     * 
+     * @param owner owning UML element
+     * @param bounds position and size (size is ignored)
+     * @param settings render settings
+     */
+    public FigClassifierRole(Object owner, Rectangle bounds, 
+            DiagramSettings settings) {
+        super(owner, bounds, settings);
+        initClassifierRoleFigs();
+        if (bounds != null) {
+            setLocation(bounds.x, bounds.y);
+        }
+    }
+
+    private void initClassifierRoleFigs() {
         // The big port and cover. Color of the big port is irrelevant
 
         setBigPort(new FigRect(X0, Y0, 90, 50, DEBUG_COLOR, DEBUG_COLOR));
@@ -118,43 +164,27 @@
         addFig(cover);
         addFig(getStereotypeFig());
         addFig(getNameFig());
-
-        // Set our bounds to those we are given.
-
-        Rectangle r = getBounds();
-        setBounds(r.x, r.y, r.width, r.height);
-    }
-
-    /**
-     * Variant constructor that associates the classifier role with a
-     * particular model element.<p>
-     *
-     * Classifier role is constructed with {@link #FigClassifierRole()}.<p>
-     *
-     * @param gm    The graph model to use. Ignored in this implementation.
-     * @param lay   The layer
-     * @param node  The model element object to associate with this Fig.
-     */
-    public FigClassifierRole(GraphModel gm, Layer lay, Object node) {
-        this();
-        setLayer(lay);
-        setOwner(node);
     }
 
     /*
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#initNotationProviders(java.lang.Object)
+     * The NotationProvider for the ClassifierRole. <p>
+     * 
+     * The syntax is for UML is:
+     * <pre>
+     * baselist := [base] [, base]*
+     * classifierRole := [name] [/ role] [: baselist]
+     * </pre></p>
+     * 
+     * The <code>name</code> is the Instance name, not used currently.
+     * See ClassifierRoleNotationUml for details.<p>
+     *
+     * This syntax is compatible with the UML 1.4 specification.
      */
     @Override
-    protected void initNotationProviders(Object own) {
-        super.initNotationProviders(own);
-        if (Model.getFacade().isAClassifierRole(own)) {
-            notationProvider =
-                NotationProviderFactory2.getInstance().getNotationProvider(
-                    NotationProviderFactory2.TYPE_CLASSIFIERROLE, own);
-        }
+    protected int getNotationProviderType() {
+        return NotationProviderFactory2.TYPE_CLASSIFIERROLE;
     }
 
-
     /**
      * Version of the clone to ensure all sub-figs are copied.<p>
      *
@@ -179,7 +209,7 @@
     /**
      * Update the stereotype text.<p>
      *
-     * If the stereotype text is non-existant, we must make sure it is
+     * If the stereotype text is non-existent, we must make sure it is
      * marked not displayed, and update the display accordingly.<p>
      *
      * Similarly if there is text, we must make sure it is marked
@@ -375,57 +405,6 @@
         updateEdges();
     }
 
-    /**
-     * Called after text has been edited directly on the screen.<p>
-     *
-     * @param ft  The text that was edited.
-     * @throws PropertyVetoException by the parser
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#textEdited(org.tigris.gef.presentation.FigText)
-     */
-    @Override
-    protected void textEdited(FigText ft) throws PropertyVetoException {
-        if (ft == getNameFig()) {
-            notationProvider.parse(getOwner(), ft.getText());
-            ft.setText(notationProvider.toString(getOwner(),
-                    getNotationSettings()));
-        }
-    }
-
-    /*
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#textEditStarted(org.tigris.gef.presentation.FigText)
-     */
-    @Override
-    protected void textEditStarted(FigText ft) {
-        if (ft == getNameFig()) {
-            showHelp(notationProvider.getParsingHelp());
-        }
-    }
-
-    /**
-     * Adjust the fig in the light of some change to the model.<p>
-     *
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateNameText()
-     */
-    @Override
-    protected void updateNameText() {
-        if (notationProvider != null) {
-            getNameFig().setText(notationProvider.toString(getOwner(), 
-                    getNotationSettings()));
-        }
-    }
-
-    /*
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent)
-     */
-    @Override
-    protected void modelChanged(PropertyChangeEvent mee) {
-        super.modelChanged(mee);
-        if (mee instanceof AddAssociationEvent
-                || mee instanceof AttributeChangeEvent) {
-            notationProvider.updateListener(this, getOwner(), mee);
-        }
-    }
-
     @Override
     protected void updateLayout(UmlChangeEvent event) {
         super.updateLayout(event);

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/UMLCollaborationDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/UMLCollaborationDiagram.java?view=diff&pathrev=16541&r1=16540&r2=16541
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/UMLCollaborationDiagram.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/UMLCollaborationDiagram.java	2009-01-07 23:46:08-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Copyright (c) 1996-2009 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
@@ -485,16 +485,13 @@
     private FigClassifierRole makeNewFigCR(Object classifierRole, 
             Point location) {
         if (classifierRole != null) {
-            FigClassifierRole newCR = new FigClassifierRole(getGraphModel(),
-                    getLayer(), classifierRole);
+            FigClassifierRole newCR = new FigClassifierRole(classifierRole,
+                    new Rectangle(location), getDiagramSettings());
             
             getGraphModel().getNodes().add(newCR.getOwner());
-            
-            newCR.setY(location.y);
-            newCR.setX(location.x);
+
             return newCR;
         }
-        
         return null;
     }
     
@@ -512,7 +509,7 @@
         DiagramSettings settings = getDiagramSettings();
         
         if (Model.getFacade().isAClassifierRole(droppedObject)) {
-            figNode = new FigClassifierRole(gm, lay, droppedObject);
+            figNode = new FigClassifierRole(droppedObject, bounds, settings);
         } else if (Model.getFacade().isAMessage(droppedObject)) {
             figNode = new FigMessage(droppedObject, bounds, settings);
         } else if (Model.getFacade().isAComment(droppedObject)) {

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1011196

To unsubscribe from this discussion, e-mail: [[email protected]].
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.