Author: mvw Date: 2014-09-07 11:41:24-0700 New Revision: 19948 Modified: trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/ClAttributeCompartment.java trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java
Log: Fix for issue 6252: Adding associationclass does not add node. I am still unsure about the architecture, but this is a severe bug and the fix can not wait longer. Tested again - it works. Modified: trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/ClAttributeCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/ClAttributeCompartment.java?view=diff&pathrev=19948&r1=19947&r2=19948 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/ClAttributeCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/ClAttributeCompartment.java 2014-09-07 11:41:24-0700 @@ -1,6 +1,6 @@ /* $Id$ ***************************************************************************** - * Copyright (c) 2009 Contributors - see below + * Copyright (c) 2009-2014 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 @@ -8,6 +8,7 @@ * * Contributors: * bobtarling + * Michiel van der Wulp ***************************************************************************** * * Some portions of this file was previously release using the BSD License: @@ -148,12 +149,14 @@ final Object modelElement = fig.getOwner(); if (Model.getUmlFactory().isContainmentValid( Model.getMetaTypes().getAttribute(), modelElement)) { - FigCompartmentBox fcb = (FigCompartmentBox) fig; - FigCompartment fc = - fcb.getCompartment(Model.getMetaTypes().getAttribute()); - Rectangle fr = fc.getBounds(); - fig = null; - return fr.contains(x, y); + if (fig instanceof FigCompartmentBox) { + FigCompartmentBox fcb = (FigCompartmentBox) fig; + FigCompartment fc = + fcb.getCompartment(Model.getMetaTypes().getAttribute()); + Rectangle fr = fc.getBounds(); + fig = null; + return fr.contains(x, y); + } // else it is a FigAssociationClass, then what? } return false; } 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=19948&r1=19947&r2=19948 ============================================================================== --- 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 2014-09-07 11:41:24-0700 @@ -1,6 +1,6 @@ /* $Id$ ******************************************************************************* - * Copyright (c) 2010-2012 Contributors - see below + * Copyright (c) 2010-2014 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 @@ -9,6 +9,7 @@ * Contributors: * Jason Robbins - initial implementation * <see source control change log for other early contributors> + * Michiel van der Wulp * ******************************************************************************* */ @@ -49,6 +50,8 @@ import org.argouml.model.Model; import org.argouml.uml.CommentEdge; import org.argouml.uml.diagram.UMLMutableGraphSupport; +import org.argouml.uml.diagram.ui.ModeCreateAssociationClass; +import org.tigris.gef.base.Globals; /** * This class defines a bridge between the UML meta-model @@ -463,6 +466,10 @@ addEdge(associationEnd); } else if (canAddEdge(association)) { addEdge(association); + if (Model.getFacade().isAAssociationClass(association)) { + ModeCreateAssociationClass.buildInActiveLayer(Globals + .curEditor(), association); + } } } } Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java?view=diff&pathrev=19948&r1=19947&r2=19948 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java 2014-09-07 11:41:24-0700 @@ -1,6 +1,6 @@ /* $Id$ ***************************************************************************** - * Copyright (c) 2009-2012 Contributors - see below + * Copyright (c) 2009-2014 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 @@ -55,6 +55,7 @@ import java.util.logging.Logger; import org.argouml.kernel.Owned; +import org.argouml.model.Model; import org.argouml.ui.TransferableModelElements; import org.argouml.uml.diagram.ArgoDiagram; import org.argouml.uml.diagram.DiagramElement; @@ -234,23 +235,27 @@ Iterator i = modelElements.iterator(); while (i.hasNext()) { - /* TODO: Why not call UMLDiagram.doesAccept() first, - * like in ClassDiagramRenderer? */ - final DiagramElement figNode = diagram.drop(i.next(), point); - - if (figNode != null && figNode instanceof Owned) { - Object owner = ((Owned) figNode).getOwner(); - if (!gm.getNodes().contains(owner)) { - gm.getNodes().add(owner); - } - - layer.add((Fig) figNode); - if (figNode instanceof FigNode && figNode instanceof Owned) { - gm.addNodeRelatedEdges(((Owned) figNode).getOwner()); + Object node = i.next(); + if (diagram.doesAccept(node)) { + final DiagramElement figNode = diagram.drop(node, point); + + if (figNode != null && figNode instanceof Owned) { + Object owner = ((Owned) figNode).getOwner(); + if (!gm.getNodes().contains(owner)) { + gm.getNodes().add(owner); + } + + layer.add((Fig) figNode); + if (figNode instanceof FigNode && figNode instanceof Owned) { + gm.addNodeRelatedEdges(((Owned) figNode).getOwner()); + } + if (Model.getFacade().isAAssociationClass(node)) { + ModeCreateAssociationClass.buildInActiveLayer(Globals + .curEditor(), node); + } } } } - dropTargetDropEvent.getDropTargetContext().dropComplete(true); } catch (UnsupportedFlavorException e) { LOG.log(Level.SEVERE, "Exception caught", e); ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=3088074 To unsubscribe from this discussion, e-mail: [[email protected]].
