svn commit: r17727 - trunk/src: argouml-app/src/org/argouml/uml/diagram/static_structure argouml-app/src/org/argouml/uml/ui/foundation/core argouml-core-model-mdr/src/org/argouml/model/mdr argouml-core-model/src/org/argouml/model

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2010-01-02 14:23:40-0800
New Revision: 17727

Added:
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelDirectedRelationship.java   (contents, props changed)
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipSourceListModel.java   (contents, props changed)
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipTargetListModel.java   (contents, props changed)
Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java
   trunk/src/argouml-core-model/src/org/argouml/model/Facade.java

Log:
Add support for UML 2.x DirectedRelationship (to fix PackageImport/Permission)

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java?view=diff&pathrev=17727&r1=17726&r2=17727
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java	2010-01-02 14:23:40-0800
@@ -1,4 +1,17 @@
-// $Id$
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jason Robbins - initial implementation
+ *    <see source control change log for other early contributors>
+ *    
+ *******************************************************************************
+ */
 // 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
@@ -316,6 +329,16 @@
         } else if (edge instanceof CommentEdge) {
             sourceModelElement = ((CommentEdge) edge).getSource();
             destModelElement = ((CommentEdge) edge).getDestination();
+        } else if (Model.getFacade().isADirectedRelationship(edge)) {
+            Collection sources = Model.getFacade().getSources(edge);
+            Collection targets = Model.getFacade().getTargets(edge);
+            if (sources.size() == 1 && targets.size() == 1) {
+                sourceModelElement = sources.iterator().next();
+                destModelElement = targets.iterator().next();
+            } else {
+                LOG.error("Edge rejected. More than one source or target for a DirectedRelationship");
+                return false;
+            }
         } else {
             return false;
         }

Added: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelDirectedRelationship.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelDirectedRelationship.java?view=markup&pathrev=17727
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelDirectedRelationship.java	2010-01-02 14:23:40-0800
@@ -0,0 +1,71 @@
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2009,2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Tom Morris - initial implementation
+ *******************************************************************************
+ */
+package org.argouml.uml.ui.foundation.core;
+
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+
+import org.argouml.i18n.Translator;
+import org.argouml.uml.ui.ActionNavigateNamespace;
+import org.argouml.uml.ui.UMLLinkedList;
+
+/**
+ * The properties panel for a DirectedRelationship.
+ * 
+ * @since UML 2.x 
+ */
+public class PropPanelDirectedRelationship extends PropPanelRelationship {
+
+    private JComponent sourceList;
+    private JComponent targetList;
+
+    /**
+     * Construct a property panel for a DirectedRelationship.
+     */
+    public PropPanelDirectedRelationship() {
+        super("label.relationship", lookupIcon("Relationship"));
+        
+        sourceList = new JScrollPane(new UMLLinkedList(
+                new UMLDirectedRelationshipSourceListModel(), true));
+        targetList = new JScrollPane( new UMLLinkedList(
+                new UMLDirectedRelationshipTargetListModel(), true));
+        
+        addField(Translator.localize("label.name"), getNameTextField());
+        addField(Translator.localize("label.namespace"), getNamespaceSelector());
+
+        addSeparator();
+
+        addField(Translator.localize("label.sources"), getSourceList());
+        addField(Translator.localize("label.targets"), getTargetList());
+
+        addAction(new ActionNavigateNamespace());
+        addAction(getDeleteAction());
+    }
+
+
+    /**
+     * @return Return the GUI component containing the list of targets.
+     */
+    protected JComponent getTargetList() {
+        return targetList;
+    }
+
+    /**
+     * @return Returns the GUI component containing the list of sources.
+     */
+    protected JComponent getSourceList() {
+        return sourceList;
+    }
+
+}
+

Added: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipSourceListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipSourceListModel.java?view=markup&pathrev=17727
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipSourceListModel.java	2010-01-02 14:23:40-0800
@@ -0,0 +1,49 @@
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2009,2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Tom Morris - initial implementation
+ *******************************************************************************
+ */
+package org.argouml.uml.ui.foundation.core;
+
+import java.util.Collection;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.UMLModelElementListModel2;
+
+/**
+ * List model for sources of a UML 2.x DirectedRelationship.
+ * 
+ * @author Tom Morris <[email protected]>
+ */
+public class UMLDirectedRelationshipSourceListModel extends UMLModelElementListModel2 {
+
+    /**
+     * Construct a model for sources of a DirectedRelationship
+     */
+    public UMLDirectedRelationshipSourceListModel() {
+        // TODO: What's our property name here
+        super("source");
+    }
+
+    protected void buildModelList() {
+        if (getTarget() != null) {
+            setAllElements(getContents());
+        }
+    }
+
+    protected boolean isValidElement(Object o) {
+        return Model.getFacade().isAElement(o) && getContents().contains(o);
+    }
+    
+    private Collection getContents() {
+        return Model.getFacade().getSources(getTarget());
+    }
+
+}

Added: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipTargetListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipTargetListModel.java?view=markup&pathrev=17727
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLDirectedRelationshipTargetListModel.java	2010-01-02 14:23:40-0800
@@ -0,0 +1,49 @@
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2009,2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Tom Morris - initial implementation
+ *******************************************************************************
+ */
+package org.argouml.uml.ui.foundation.core;
+
+import java.util.Collection;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.UMLModelElementListModel2;
+
+/**
+ * List model for targets of a UML 2.x DirectedRelationship.
+ * 
+ * @author Tom Morris <[email protected]>
+ */
+public class UMLDirectedRelationshipTargetListModel extends UMLModelElementListModel2 {
+
+    /**
+     * Construct a model for sources of a DirectedRelationship
+     */
+    public UMLDirectedRelationshipTargetListModel() {
+        // TODO: What's our property name here
+        super("target");
+    }
+    
+    protected void buildModelList() {
+        if (getTarget() != null) {
+            setAllElements(getContents());
+        }
+    }
+
+    protected boolean isValidElement(Object o) {
+        return Model.getFacade().isAElement(o) && getContents().contains(o);
+    }
+    
+    private Collection getContents() {
+        return Model.getFacade().getTargets(getTarget());
+    }
+
+}

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java?view=diff&pathrev=17727&r1=17726&r2=17727
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java	2010-01-02 14:23:40-0800
@@ -1,5 +1,19 @@
-// $Id$
-// Copyright (c) 2005-2009 The Regents of the University of California. All
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Linus Tolke - initial framework implementation
+ *    <see source control change log for other early contributors>
+ *    Ludovic Maitre - UML 1.4
+ *    Tom Morris - UML 1.4 
+ *    
+ *******************************************************************************
+ */// Copyright (c) 2005-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
@@ -4546,4 +4560,13 @@
         // Return the metatype proxy 
         return pkg.refClass(names.get(1));
     }
+
+
+    public Collection getTargets(Object handle) {
+        return Collections.emptySet();
+    }
+
+    public boolean isADirectedRelationship(Object handle) {
+        return false;
+    }
 }

Modified: trunk/src/argouml-core-model/src/org/argouml/model/Facade.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/Facade.java?view=diff&pathrev=17727&r1=17726&r2=17727
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/Facade.java	(original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/Facade.java	2010-01-02 14:23:40-0800
@@ -1,4 +1,18 @@
-// $Id$
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Linus Tolke - initial implementation
+ *    <see source control change log for other early contributors>
+ *    Tom Morris - UML 1.4 and UML 2.x additions
+ *    
+ *******************************************************************************
+ */
 // Copyright (c) 2005-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
@@ -409,6 +423,13 @@
      */
     boolean isADependency(Object handle);
 
+    
+    /**
+     * @param handle element to test
+     * @return true if Element is a DirectedRelationship
+     */
+    public boolean isADirectedRelationship(Object handle);
+    
     /**
      * Recognizer for DestroyAction.
      *
@@ -1417,13 +1438,21 @@
      * return value is a Collection of elements, not a single element.  If you
      * know you are dealing with a ClassifierRole, it is prefeable to use
      * {@link #getBases(Object)}.
+     * <p>
+     * For UML 2.x with a target of an Include element, use getIncludingCase().
      * 
      * @param handle
      *            the model element
      * @return the base
      */
     Object getBase(Object handle);
-
+    
+    /**
+     * @param handle Include element
+     * @return the UseCase into which the included UseCase will be added
+     */
+//    Object getIncludingCase(Object handle);
+    
     /**
      * Get the bases of a ClassifierRole.
      *
@@ -2567,9 +2596,9 @@
     Object getSource(Object handle);
 
     /**
-     * Return the source for some given flow.
+     * Return the source for some given flow or a UML2 DirectedRelationship.
      *
-     * @param handle the flow
+     * @param handle the flow or DirectedRelationship
      * @return Collection
      */
     Collection getSources(Object handle);
@@ -2739,6 +2768,14 @@
     Object getTarget(Object handle);
 
     /**
+     * Return the targets of a UML 2.x DirectedRelationship.
+     *
+     * @param handle the relationship
+     * @return Object
+     */
+    Collection getTargets(Object handle);
+    
+    /**
      * Return the target scope of a StructuralFeature or AssociationEnd.
      * 
      * @param handle the model element
@@ -3245,4 +3282,17 @@
      * @return true if the element is an instance of the given metatype
      */
     boolean isA(String metatypeName, Object element);
+    
+    /**
+     * @param element a PackageImport or ElementImport
+     * @return the Namepace into which the PackageImport is pulling things
+     */
+//    Object getImportingNamespace(Object element);
+    
+    /**
+     * @param element a PackageImport
+     * @return the Package being imported
+     */
+//    Object getImportedPackage(Object element);
+    
 }

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

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.