cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r810422 [1/3] - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ cayenne-modeler/src/main/java/org/apache/cayenne/m...
Date Wed, 02 Sep 2009 08:52:40 GMT
Author: aadamchik
Date: Wed Sep  2 08:52:39 2009
New Revision: 810422

URL: http://svn.apache.org/viewvc?rev=810422&view=rev
Log:
CAY-1260 Modeler support for embeddables and embedded attributes

first patch by Olga Tkachova - embeddables can be created and saved, still many more things to do

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeEvent.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeListener.java
      - copied, changed from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableEvent.java
      - copied, changed from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableListener.java
      - copied, changed from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EmbeddableAttributeTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EmbeddableAttributeTableModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EmbeddableTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EmbeddableTabbedView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EmbeddableAttributeDisplayEvent.java
      - copied, changed from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EmbeddableAttributeDisplayListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EmbeddableDisplayEvent.java
      - copied, changed from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EmbeddableDisplayListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-embeddable.gif
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-new_embeddable.gif
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/NamedObjectFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectTraversal.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAttributeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAttributeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAttributeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeEvent.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeEvent.java?rev=810422&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeEvent.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeEvent.java Wed Sep  2 08:52:39 2009
@@ -0,0 +1,54 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.map.event;
+
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
+
+public class EmbeddableAttributeEvent extends EmbeddableEvent {
+
+    protected EmbeddableAttribute embeddableAttribute;
+
+    public EmbeddableAttributeEvent(Object source, Embeddable embeddable,
+            EmbeddableAttribute embeddableAttribute) {
+        super(source, embeddable);
+        setEmbeddableAttribute(embeddableAttribute);
+    }
+
+    public EmbeddableAttributeEvent(Object source, EmbeddableAttribute attrib,
+            Embeddable embeddable, int id) {
+       
+        this(source, embeddable, attrib);
+        setId(id);
+    }
+
+    @Override
+    public String getNewName() {
+        return (embeddableAttribute != null) ? embeddableAttribute.getName() : null;
+    }
+
+    public EmbeddableAttribute getEmbeddableAttribute() {
+        return embeddableAttribute;
+    }
+
+    public void setEmbeddableAttribute(EmbeddableAttribute embeddableAttribute) {
+        this.embeddableAttribute = embeddableAttribute;
+    }
+
+}

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeListener.java (from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeListener.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeListener.java&p1=cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java&r1=809002&r2=810422&rev=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableAttributeListener.java Wed Sep  2 08:52:39 2009
@@ -1,4 +1,3 @@
-package org.apache.cayenne.modeler.event;
 /*****************************************************************
  *   Licensed to the Apache Software Foundation (ASF) under one
  *  or more contributor license agreements.  See the NOTICE file
@@ -17,41 +16,18 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.map.event;
 
+import java.util.EventListener;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.map.Attribute;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Entity;
+public interface EmbeddableAttributeListener extends EventListener {
 
-/** 
-  */
-public class AttributeDisplayEvent extends EntityDisplayEvent {
-    protected Attribute[] attributes;
-    
-    public AttributeDisplayEvent(
-            Object src,
-            Attribute attribute,
-            Entity entity,
-            DataMap dataMap,
-            DataDomain domain) {
-        
-            super(src, entity, dataMap, domain);
-            attributes = new Attribute[] { attribute };
-    }
+    /** EmbeddableAttribute property changed. */
+    public void embeddableAttributeChanged(EmbeddableAttributeEvent e);
 
-    public AttributeDisplayEvent(
-        Object src,
-        Attribute[] attributes,
-        Entity entity,
-        DataMap dataMap,
-        DataDomain domain) {
+    /** New EmbeddableAttribute has been created/added. */
+    public void embeddableAttributeAdded(EmbeddableAttributeEvent e);
 
-        super(src, entity, dataMap, domain);
-        this.attributes = attributes;
-    }
-    
-    public Attribute[] getAttributes() {
-        return attributes;
-    }
+    /** EmbeddableAttribute has been removed. */
+    public void embeddableAttributeRemoved(EmbeddableAttributeEvent e);
 }

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableEvent.java (from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableEvent.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableEvent.java&p1=cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java&r1=809002&r2=810422&rev=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableEvent.java Wed Sep  2 08:52:39 2009
@@ -1,4 +1,3 @@
-package org.apache.cayenne.modeler.event;
 /*****************************************************************
  *   Licensed to the Apache Software Foundation (ASF) under one
  *  or more contributor license agreements.  See the NOTICE file
@@ -17,41 +16,42 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.map.event;
 
+import org.apache.cayenne.map.Embeddable;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.map.Attribute;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Entity;
-
-/** 
-  */
-public class AttributeDisplayEvent extends EntityDisplayEvent {
-    protected Attribute[] attributes;
+
+public class EmbeddableEvent extends MapEvent {
+
+    protected Embeddable embeddable;
     
-    public AttributeDisplayEvent(
-            Object src,
-            Attribute attribute,
-            Entity entity,
-            DataMap dataMap,
-            DataDomain domain) {
-        
-            super(src, entity, dataMap, domain);
-            attributes = new Attribute[] { attribute };
-    }
-
-    public AttributeDisplayEvent(
-        Object src,
-        Attribute[] attributes,
-        Entity entity,
-        DataMap dataMap,
-        DataDomain domain) {
+    public EmbeddableEvent(Object source, Embeddable embeddable) {
+        super(source);
+        setEmbeddable(embeddable);
+    }
+
+     public EmbeddableEvent(Object src, Embeddable embeddable2, int id) {
+         this(src, embeddable2);
+         setId(id);
+    }
 
-        super(src, entity, dataMap, domain);
-        this.attributes = attributes;
+     public EmbeddableEvent(Object src, Embeddable embeddable2, String oldClassName) {
+         this(src, embeddable2);
+         setOldName(oldClassName);
     }
+
+     
+    public void setEmbeddable(Embeddable embeddable) {
+        this.embeddable = embeddable;
+    }
+
     
-    public Attribute[] getAttributes() {
-        return attributes;
+    public Embeddable getEmbeddable() {
+        return embeddable;
+    }
+
+    @Override
+    public String getNewName() {
+        return (embeddable != null) ? embeddable.getClassName() : null;
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableListener.java (from r809002, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableListener.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableListener.java&p1=cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java&r1=809002&r2=810422&rev=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/AttributeDisplayEvent.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/EmbeddableListener.java Wed Sep  2 08:52:39 2009
@@ -1,4 +1,3 @@
-package org.apache.cayenne.modeler.event;
 /*****************************************************************
  *   Licensed to the Apache Software Foundation (ASF) under one
  *  or more contributor license agreements.  See the NOTICE file
@@ -17,41 +16,23 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.map.event;
 
+import java.util.EventListener;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Entity;
 
-/** 
-  */
-public class AttributeDisplayEvent extends EntityDisplayEvent {
-    protected Attribute[] attributes;
-    
-    public AttributeDisplayEvent(
-            Object src,
-            Attribute attribute,
-            Entity entity,
-            DataMap dataMap,
-            DataDomain domain) {
-        
-            super(src, entity, dataMap, domain);
-            attributes = new Attribute[] { attribute };
-    }
-
-    public AttributeDisplayEvent(
-        Object src,
-        Attribute[] attributes,
-        Entity entity,
-        DataMap dataMap,
-        DataDomain domain) {
-
-        super(src, entity, dataMap, domain);
-        this.attributes = attributes;
-    }
+
+public interface EmbeddableListener extends EventListener {
     
-    public Attribute[] getAttributes() {
-        return attributes;
-    }
+    /** EmbeddableAttribute property changed. */
+    public void embeddableChanged(EmbeddableEvent e, DataMap map);
+
+    /** New EmbeddableAttribute has been created/added. */
+    public void embeddableAdded(EmbeddableEvent e, DataMap map);
+
+    /** EmbeddableAttribute has been removed. 
+     * @param map */
+    public void embeddableRemoved(EmbeddableEvent e, DataMap map);
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/NamedObjectFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/NamedObjectFactory.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/NamedObjectFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/NamedObjectFactory.java Wed Sep  2 08:52:39 2009
@@ -30,6 +30,8 @@
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
@@ -82,6 +84,8 @@
         factories.put(Procedure.class, new ProcedureFactory());
         factories.put(Query.class, new SelectQueryFactory());
         factories.put(ProcedureParameter.class, new ProcedureParameterFactory());
+        factories.put(Embeddable.class, new EmbeddableFactory());
+        factories.put(EmbeddableAttribute.class, new EmbeddableAttributeFactory());
     }
 
     public static String createName(Class objectClass, Object namingContext) {
@@ -247,6 +251,44 @@
         }
     }
 
+    static class EmbeddableFactory extends NamedObjectFactory {
+        @Override
+        protected String nameBase() {
+            return "Package.UntitledObjEntity";
+        }
+
+        @Override
+        protected Object create(String name, Object namingContext) {
+            return new Embeddable(name);
+        }
+
+        @Override
+        protected boolean isNameInUse(String name, Object namingContext) {
+            DataMap map = (DataMap) namingContext;
+            return map.getEmbeddable(name) != null;
+        }
+    }
+    
+    static class EmbeddableAttributeFactory extends NamedObjectFactory {
+        @Override
+        protected String nameBase() {
+            return "untitledAttr";
+        }
+
+        @Override
+        protected Object create(String name, Object namingContext) {
+            return new EmbeddableAttribute(name);
+        }
+
+        @Override
+        protected boolean isNameInUse(String name, Object namingContext) {
+            Embeddable emb = (Embeddable) namingContext;
+            return emb.getAttribute(name) != null;
+        }
+    }
+
+    
+    
     static class DbEntityFactory extends NamedObjectFactory {
         @Override
         protected String nameBase() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectTraversal.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectTraversal.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectTraversal.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectTraversal.java Wed Sep  2 08:52:39 2009
@@ -27,6 +27,7 @@
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.Relationship;
@@ -42,7 +43,6 @@
  * <i>Current implementation is not very efficient and would actually first read the whole
  * tree, before returning the first element from the iterator.</i>
  * </p>
- * 
  */
 public class ProjectTraversal {
 
@@ -51,6 +51,7 @@
     protected static final Comparator dataDomainComparator = new DataDomainComparator();
     protected static final Comparator dataNodeComparator = new DataNodeComparator();
     protected static final Comparator queryComparator = new QueryComparator();
+    protected static final Comparator embaddableComparator = new EmbeddableComparator();
 
     protected ProjectTraversalHandler handler;
     protected boolean sort;
@@ -61,8 +62,8 @@
 
     /**
      * Creates ProjectTraversal instance with a given handler and sort policy. If
-     * <code>sort</code> is true, children of each node will be sorted using a
-     * predefined Comparator for a given type of child nodes.
+     * <code>sort</code> is true, children of each node will be sorted using a predefined
+     * Comparator for a given type of child nodes.
      */
     public ProjectTraversal(ProjectTraversalHandler handler, boolean sort) {
         this.handler = handler;
@@ -101,6 +102,9 @@
         else if (rootNode instanceof DataNode) {
             this.traverseNodes(Collections.singletonList(rootNode).iterator(), path);
         }
+        else if (rootNode instanceof Embeddable) {
+            this.traverseEmbeddable(Collections.singletonList(rootNode).iterator(), path);
+        }
         else {
             String nodeClass = (rootNode != null)
                     ? rootNode.getClass().getName()
@@ -174,12 +178,31 @@
             if (handler.shouldReadChildren(map, path)) {
                 this.traverseEntities(map.getObjEntities().iterator(), mapPath);
                 this.traverseEntities(map.getDbEntities().iterator(), mapPath);
+                this.traverseEmbeddable(map.getEmbeddables().iterator(), mapPath);
                 this.traverseProcedures(map.getProcedures().iterator(), mapPath);
                 this.traverseQueries(map.getQueries().iterator(), mapPath);
             }
         }
     }
 
+    public void traverseEmbeddable(Iterator embeddadles, ProjectPath path) {
+        if (sort) {
+            embeddadles = Util.sortedIterator(
+                    embeddadles,
+                    ProjectTraversal.embaddableComparator);
+        }
+
+        while (embeddadles.hasNext()) {
+            Embeddable emd = (Embeddable) embeddadles.next();
+            ProjectPath entPath = path.appendToPath(emd);
+            handler.projectNode(entPath);
+
+            if (handler.shouldReadChildren(emd, path)) {
+                this.traverseAttributes(emd.getAttributes().iterator(), entPath);
+            }
+        }
+    }
+
     /**
      * Performs recursive traversal of an Iterator of Cayenne Query objects.
      */
@@ -260,7 +283,9 @@
         }
     }
 
-    public void traverseProcedureParameters(Iterator<? extends ProcedureParameter> parameters, ProjectPath path) {
+    public void traverseProcedureParameters(
+            Iterator<? extends ProcedureParameter> parameters,
+            ProjectPath path) {
         // Note: !! do not try to sort parameters - they are positional by definition
 
         while (parameters.hasNext()) {
@@ -304,6 +329,24 @@
         }
     }
 
+    static class EmbeddableComparator implements Comparator {
+
+        public int compare(Object o1, Object o2) {
+            String name1 = ((Embeddable) o1).getClassName();
+            String name2 = ((Embeddable) o2).getClassName();
+
+            if (name1 == null) {
+                return (name2 != null) ? -1 : 0;
+            }
+            else if (name2 == null) {
+                return 1;
+            }
+            else {
+                return name1.compareTo(name2);
+            }
+        }
+    }
+
     static class DataMapComparator implements Comparator {
 
         public int compare(Object o1, Object o2) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java Wed Sep  2 08:52:39 2009
@@ -45,6 +45,7 @@
 import org.apache.cayenne.modeler.action.CreateDataMapEntityListenerAction;
 import org.apache.cayenne.modeler.action.CreateDbEntityAction;
 import org.apache.cayenne.modeler.action.CreateDomainAction;
+import org.apache.cayenne.modeler.action.CreateEmbeddableAction;
 import org.apache.cayenne.modeler.action.CreateNodeAction;
 import org.apache.cayenne.modeler.action.CreateObjEntityAction;
 import org.apache.cayenne.modeler.action.CreateObjEntityListenerAction;
@@ -123,6 +124,7 @@
     static {
         DATA_MAP_ACTIONS.addAll(Arrays.asList(
                 GenerateCodeAction.getActionName(),
+                CreateEmbeddableAction.getActionName(),
                 CreateObjEntityAction.getActionName(),
                 CreateDbEntityAction.getActionName(),
                 CreateQueryAction.getActionName(),
@@ -152,6 +154,13 @@
                 DbEntitySyncAction.getActionName()));
     }
 
+    static final Collection<String> EMBEDDABLE_ACTIONS = new HashSet<String>(
+            DATA_MAP_ACTIONS);
+    static {
+        EMBEDDABLE_ACTIONS.addAll(Arrays.asList(
+                CreateAttributeAction.getActionName()));
+    }
+    
     static final Collection<String> PROCEDURE_ACTIONS = new HashSet<String>(
             DATA_MAP_ACTIONS);
     static {
@@ -237,6 +246,8 @@
         registerAction(new CopyRelationshipAction(application));
         registerAction(new CopyProcedureParameterAction(application));
         registerAction(new PasteAction(application));
+        
+        registerAction(new CreateEmbeddableAction(application));
     }
 
     private CayenneAction registerAction(CayenneAction action) {
@@ -312,6 +323,11 @@
         updateActions("Query");
     }
     
+    public void embeddableSelected() {
+        processActionsState(EMBEDDABLE_ACTIONS);
+        updateActions("Embeddable");
+    }
+    
     /**
      * Invoked when several objects were selected in ProjectTree at time
      */

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java Wed Sep  2 08:52:39 2009
@@ -51,6 +51,7 @@
 import org.apache.cayenne.modeler.action.CreateDataMapAction;
 import org.apache.cayenne.modeler.action.CreateDbEntityAction;
 import org.apache.cayenne.modeler.action.CreateDomainAction;
+import org.apache.cayenne.modeler.action.CreateEmbeddableAction;
 import org.apache.cayenne.modeler.action.CreateNodeAction;
 import org.apache.cayenne.modeler.action.CreateObjEntityAction;
 import org.apache.cayenne.modeler.action.CreateProcedureAction;
@@ -86,6 +87,8 @@
 import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
 import org.apache.cayenne.modeler.event.DataNodeDisplayListener;
 import org.apache.cayenne.modeler.event.DbEntityDisplayListener;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayListener;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 import org.apache.cayenne.modeler.event.MultipleObjectsDisplayEvent;
 import org.apache.cayenne.modeler.event.MultipleObjectsDisplayListener;
@@ -109,7 +112,8 @@
  */
 public class CayenneModelerFrame extends JFrame implements DataNodeDisplayListener,
         DataMapDisplayListener, ObjEntityDisplayListener, DbEntityDisplayListener,
-        QueryDisplayListener, ProcedureDisplayListener, MultipleObjectsDisplayListener {
+        QueryDisplayListener, ProcedureDisplayListener, MultipleObjectsDisplayListener, 
+        EmbeddableDisplayListener{
 
     protected EditorView view;
     protected RecentFileMenu recentFileMenu;
@@ -215,8 +219,12 @@
 
         projectMenu.add(getAction(CreateObjEntityAction.getActionName()).buildMenu());
         projectMenu.add(getAction(CreateDbEntityAction.getActionName()).buildMenu());
+
+        projectMenu.add(getAction(CreateEmbeddableAction.getActionName()).buildMenu());
+        
         projectMenu.add(getAction(CreateProcedureAction.getActionName()).buildMenu());
         projectMenu.add(getAction(CreateQueryAction.getActionName()).buildMenu());
+        
         projectMenu.addSeparator();
         projectMenu.add(getAction(ObjEntitySyncAction.getActionName()).buildMenu());
         projectMenu.addSeparator();
@@ -371,9 +379,13 @@
 
         toolBar.addSeparator();
 
+        
         toolBar.add(getAction(CreateObjEntityAction.getActionName()).buildButton());
-        toolBar.add(getAction(CreateQueryAction.getActionName()).buildButton());
+      
+        toolBar.add(getAction(CreateEmbeddableAction.getActionName()).buildButton());
 
+        toolBar.add(getAction(CreateQueryAction.getActionName()).buildButton());
+ 
         toolBar.addSeparator();
 
         toolBar.add(getAction(NavigateBackwardAction.getActionName()).buildButton());
@@ -452,6 +464,10 @@
     public void currentObjectsChanged(MultipleObjectsDisplayEvent e) {
         actionManager.multipleObjectsSelected(e.getPaths());
     }
+    
+    public void currentEmbeddableChanged(EmbeddableDisplayEvent e) {
+        actionManager.embeddableSelected();
+    }
 
     /**
      * Returns the right side view panel.

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java Wed Sep  2 08:52:39 2009
@@ -39,6 +39,8 @@
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -54,6 +56,10 @@
 import org.apache.cayenne.map.event.DbRelationshipListener;
 import org.apache.cayenne.map.event.DomainEvent;
 import org.apache.cayenne.map.event.DomainListener;
+import org.apache.cayenne.map.event.EmbeddableAttributeEvent;
+import org.apache.cayenne.map.event.EmbeddableAttributeListener;
+import org.apache.cayenne.map.event.EmbeddableEvent;
+import org.apache.cayenne.map.event.EmbeddableListener;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.map.event.ObjAttributeListener;
@@ -84,6 +90,10 @@
 import org.apache.cayenne.modeler.event.DisplayEvent;
 import org.apache.cayenne.modeler.event.DomainDisplayEvent;
 import org.apache.cayenne.modeler.event.DomainDisplayListener;
+import org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent;
+import org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayListener;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayListener;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 import org.apache.cayenne.modeler.event.EntityListenerEvent;
 import org.apache.cayenne.modeler.event.EntityListenerListener;
@@ -135,6 +145,9 @@
         private DataMap map;
         private ObjEntity objEntity;
         private DbEntity dbEntity;
+        private Embeddable embeddable;
+
+        private EmbeddableAttribute[] embAttrs;
 
         private ObjAttribute[] objAttrs;
         private DbAttribute[] dbAttrs;
@@ -171,9 +184,12 @@
             objEntity = null;
             dbEntity = null;
 
+            embeddable = null;
+
             procedure = null;
 
             // life is much easier if these guys are never null
+            embAttrs = new EmbeddableAttribute[0];
             dbAttrs = new DbAttribute[0];
             dbRels = new DbRelationship[0];
             procedureParameters = new ProcedureParameter[0];
@@ -196,6 +212,7 @@
          * get's a bit messy at the end, because of inheritance heirarchy issues.
          */
         public boolean isEquivalent(ControllerState val) {
+
             if (val == null)
                 return false;
 
@@ -216,6 +233,10 @@
                     && val.event instanceof QueryDisplayEvent) {
                 return query == val.query;
             }
+            else if (event instanceof EmbeddableDisplayEvent
+                    && val.event instanceof EmbeddableDisplayEvent) {
+                return embeddable == val.embeddable;
+            }
             else if (event.getClass() == DataMapDisplayEvent.class
                     && event.getClass() == val.event.getClass()) {
                 return map == val.map;
@@ -228,6 +249,7 @@
                     && event.getClass() == val.event.getClass()) {
                 return domain == val.domain;
             }
+
             return false;
         }
     }
@@ -381,6 +403,7 @@
         addQueryDisplayListener(frame);
         addProcedureDisplayListener(frame);
         addMultipleObjectsDisplayListener(frame);
+        addEmbeddableDisplayListener(frame);
     }
 
     public void reset() {
@@ -488,6 +511,13 @@
                         removeList.add(cs);
                     }
                 }
+                else if (e instanceof EmbeddableEvent
+                        && csEvent instanceof EmbeddableDisplayEvent) {
+                    if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent)
+                            .getEmbeddable()) {
+                        removeList.add(cs);
+                    }
+                }
                 else if (e instanceof ProcedureEvent
                         && csEvent instanceof ProcedureDisplayEvent) {
                     if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent)
@@ -547,6 +577,10 @@
         return currentState.objEntity;
     }
 
+    public Embeddable getCurrentEmbeddable() {
+        return currentState.embeddable;
+    }
+
     public DbEntity getCurrentDbEntity() {
         return currentState.dbEntity;
     }
@@ -566,6 +600,13 @@
     }
 
     /**
+     * @return Array of selected EmbeddableAttribute
+     */
+    public EmbeddableAttribute[] getCurrentEmbAttrs() {
+        return currentState.embAttrs;
+    }
+
+    /**
      * @return Array of selected ObjRelationships
      */
     public ObjRelationship[] getCurrentObjRelationships() {
@@ -635,6 +676,15 @@
         listenerList.add(ObjEntityDisplayListener.class, listener);
     }
 
+    public void addEmbeddableDisplayListener(EmbeddableDisplayListener listener) {
+        listenerList.add(EmbeddableDisplayListener.class, listener);
+    }
+
+    public void addEmbeddableAttributeDisplayListener(
+            EmbeddableAttributeDisplayListener listener) {
+        listenerList.add(EmbeddableAttributeDisplayListener.class, listener);
+    }
+
     public void addDbAttributeListener(DbAttributeListener listener) {
         listenerList.add(DbAttributeListener.class, listener);
     }
@@ -704,7 +754,8 @@
                     || currentState.dbEntity != null
                     || currentState.objEntity != null
                     || currentState.procedure != null
-                    || currentState.query != null;
+                    || currentState.query != null
+                    || currentState.embeddable != null;
         }
 
         if (!e.isRefired()) {
@@ -773,7 +824,8 @@
                     || currentState.dbEntity != null
                     || currentState.objEntity != null
                     || currentState.procedure != null
-                    || currentState.query != null;
+                    || currentState.query != null
+                    || currentState.embeddable != null;
         }
 
         if (!e.isRefired()) {
@@ -833,7 +885,8 @@
             changed = currentState.dbEntity != null
                     || currentState.objEntity != null
                     || currentState.procedure != null
-                    || currentState.query != null;
+                    || currentState.query != null
+                    || currentState.embeddable != null;
         }
 
         if (!e.isRefired()) {
@@ -1147,6 +1200,11 @@
                 fireDbEntityDisplayEvent(ede);
             }
         }
+        else if (de instanceof EmbeddableDisplayEvent) {
+            EmbeddableDisplayEvent ede = (EmbeddableDisplayEvent) de;
+            ede.setEmbeddableChanged(true);
+            fireEmbeddableDisplayEvent(ede);
+        }
         else if (de instanceof ProcedureDisplayEvent) {
             ProcedureDisplayEvent pde = (ProcedureDisplayEvent) de;
             pde.setProcedureChanged(true);
@@ -1203,6 +1261,33 @@
         }
     }
 
+    
+    public void fireEmbeddableDisplayEvent(EmbeddableDisplayEvent e) {
+        boolean changed = e.getEmbeddable() != currentState.embeddable;
+
+        if (!e.isRefired()) {
+            e.setEmbeddableChanged(changed);
+
+            if (changed) {
+                clearState();
+                currentState.domain = e.getDomain();
+                currentState.node = e.getDataNode();
+                currentState.map = e.getDataMap();
+                currentState.embeddable = (Embeddable) e.getEmbeddable();
+            }
+        }
+
+        if (changed) {
+            saveState(e);
+        }
+
+        for (EventListener listener : listenerList
+                .getListeners(EmbeddableDisplayListener.class)) {
+            EmbeddableDisplayListener temp = (EmbeddableDisplayListener) listener;
+            temp.currentEmbeddableChanged(e);
+        }
+    }
+    
     public void fireQueryDisplayEvent(QueryDisplayEvent e) {
         boolean changed = e.getQuery() != currentState.query;
 
@@ -1377,7 +1462,7 @@
 
     public void fireObjAttributeDisplayEvent(AttributeDisplayEvent e) {
         boolean changed = !Arrays.equals(e.getAttributes(), currentState.objAttrs);
-
+        
         if (changed) {
             if (e.getEntity() != currentState.objEntity) {
                 clearState();
@@ -1402,6 +1487,35 @@
         }
     }
 
+    public void fireEmbeddableAttributeDisplayEvent(EmbeddableAttributeDisplayEvent ev) {
+        boolean changed = !Arrays.equals(
+                ev.getEmbeddableAttributes(),
+                currentState.embAttrs);
+
+        if (changed) {
+            if (ev.getEmbeddable() != currentState.embeddable) {
+                clearState();
+                currentState.domain = ev.getDomain();
+                currentState.map = ev.getDataMap();
+                currentState.embeddable = (Embeddable) ev.getEmbeddable();
+            }
+            currentState.embAttrs = new EmbeddableAttribute[ev.getEmbeddableAttributes().length];
+            System.arraycopy(
+                    ev.getEmbeddableAttributes(),
+                    0,
+                    currentState.embAttrs,
+                    0,
+                    currentState.embAttrs.length);
+        }
+
+        EventListener[] list = listenerList
+                .getListeners(EmbeddableAttributeDisplayListener.class);
+        for (EventListener listener : list) {
+            EmbeddableAttributeDisplayListener temp = (EmbeddableAttributeDisplayListener) listener;
+            temp.currentEmbeddableAttributeChanged(ev);
+        }
+    }
+
     /** Notifies all listeners of the change(add, remove) and does the change. */
     public void fireDbRelationshipEvent(RelationshipEvent e) {
         setDirty(true);
@@ -1693,6 +1807,9 @@
         else if (getCurrentDbEntity() != null) {
             return getCurrentDbEntity();
         }
+        else if (getCurrentEmbeddable() != null) {
+            return getCurrentEmbeddable();
+        }
         else if (getCurrentQuery() != null) {
             return getCurrentQuery();
         }
@@ -1734,4 +1851,58 @@
         return null;
     }
 
+    
+
+    public void addEmbeddableAttributeListener(EmbeddableAttributeListener listener) {
+        listenerList.add(EmbeddableAttributeListener.class, listener);
+    }
+
+    public void addEmbeddableListener(EmbeddableListener listener) {
+        listenerList.add(EmbeddableListener.class, listener);
+    }
+
+    public void fireEmbeddableEvent(EmbeddableEvent e, DataMap map) {
+        setDirty(true);
+        for (EventListener listener : listenerList.getListeners(EmbeddableListener.class)) {
+            EmbeddableListener temp = (EmbeddableListener) listener;
+
+            switch (e.getId()) {
+                case MapEvent.ADD:
+                    temp.embeddableAdded(e, map);
+                    break;
+                case MapEvent.CHANGE:
+                    temp.embeddableChanged(e, map);
+                    break;
+                case MapEvent.REMOVE:
+                    temp.embeddableRemoved(e, map);
+                    break;
+                default:
+                    throw new IllegalArgumentException("Invalid RelationshipEvent type: "
+                            + e.getId());
+            }
+        }
+    }
+
+    public void fireEmbeddableAttributeEvent(EmbeddableAttributeEvent e) {
+        setDirty(true);
+        for (EventListener listener : listenerList
+                .getListeners(EmbeddableAttributeListener.class)) {
+            EmbeddableAttributeListener temp = (EmbeddableAttributeListener) listener;
+
+            switch (e.getId()) {
+                case MapEvent.ADD:
+                    temp.embeddableAttributeAdded(e);
+                    break;
+                case MapEvent.CHANGE:
+                    temp.embeddableAttributeChanged(e);
+                    break;
+                case MapEvent.REMOVE:
+                    temp.embeddableAttributeRemoved(e);
+                    break;
+                default:
+                    throw new IllegalArgumentException("Invalid RelationshipEvent type: "
+                            + e.getId());
+            }
+        }
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java Wed Sep  2 08:52:39 2009
@@ -41,6 +41,7 @@
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
@@ -51,6 +52,8 @@
 import org.apache.cayenne.map.event.DbEntityListener;
 import org.apache.cayenne.map.event.DomainEvent;
 import org.apache.cayenne.map.event.DomainListener;
+import org.apache.cayenne.map.event.EmbeddableEvent;
+import org.apache.cayenne.map.event.EmbeddableListener;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.map.event.ObjEntityListener;
 import org.apache.cayenne.map.event.ProcedureEvent;
@@ -61,6 +64,7 @@
 import org.apache.cayenne.modeler.action.CreateDataMapAction;
 import org.apache.cayenne.modeler.action.CreateDbEntityAction;
 import org.apache.cayenne.modeler.action.CreateDomainAction;
+import org.apache.cayenne.modeler.action.CreateEmbeddableAction;
 import org.apache.cayenne.modeler.action.CreateNodeAction;
 import org.apache.cayenne.modeler.action.CreateObjEntityAction;
 import org.apache.cayenne.modeler.action.CreateProcedureAction;
@@ -76,6 +80,8 @@
 import org.apache.cayenne.modeler.event.DbEntityDisplayListener;
 import org.apache.cayenne.modeler.event.DomainDisplayEvent;
 import org.apache.cayenne.modeler.event.DomainDisplayListener;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayListener;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 import org.apache.cayenne.modeler.event.MultipleObjectsDisplayEvent;
 import org.apache.cayenne.modeler.event.MultipleObjectsDisplayListener;
@@ -100,13 +106,14 @@
         DomainListener, DataMapDisplayListener, DataMapListener, DataNodeDisplayListener,
         DataNodeListener, ObjEntityListener, ObjEntityDisplayListener, DbEntityListener,
         DbEntityDisplayListener, QueryListener, QueryDisplayListener, ProcedureListener,
-        ProcedureDisplayListener, MultipleObjectsDisplayListener {
+        ProcedureDisplayListener, MultipleObjectsDisplayListener,
+        EmbeddableDisplayListener, EmbeddableListener {
 
     private static final Log logObj = LogFactory.getLog(ProjectTreeView.class);
 
     protected ProjectController mediator;
     protected TreeSelectionListener treeSelectionListener;
-    
+
     /**
      * Popup menu containing basic functions
      */
@@ -130,40 +137,42 @@
 
             public void valueChanged(TreeSelectionEvent e) {
                 TreePath[] paths = getSelectionPaths();
-                
+
                 if (paths != null) {
                     if (paths.length > 1) {
                         ProjectPath[] projectPaths = new ProjectPath[paths.length];
                         for (int i = 0; i < paths.length; i++) {
                             projectPaths[i] = createProjectPath(paths[i]);
                         }
-                    
-                        mediator.fireMultipleObjectsDisplayEvent(
-                                new MultipleObjectsDisplayEvent(this, projectPaths));
+
+                        mediator
+                                .fireMultipleObjectsDisplayEvent(new MultipleObjectsDisplayEvent(
+                                        this,
+                                        projectPaths));
                     }
                     else if (paths.length == 1) {
                         processSelection(paths[0]);
                     }
                 }
             }
-            
+
             /**
-             * Converts TreePath to ProjectPath 
+             * Converts TreePath to ProjectPath
              */
             private ProjectPath createProjectPath(TreePath treePath) {
                 Object[] path = treePath.getPath();
                 Object[] projectPath = new Object[path.length];
-                
+
                 for (int i = 0; i < projectPath.length; i++) {
                     projectPath[i] = ((DefaultMutableTreeNode) path[i]).getUserObject();
                 }
-                
+
                 return new ProjectPath(projectPath);
             }
         };
 
         addTreeSelectionListener(treeSelectionListener);
-        
+
         addMouseListener(new PopupHandler());
 
         mediator.addDomainListener(this);
@@ -176,15 +185,19 @@
         mediator.addObjEntityDisplayListener(this);
         mediator.addDbEntityListener(this);
         mediator.addDbEntityDisplayListener(this);
+        mediator.addEmbeddableDisplayListener(this);
+        mediator.addEmbeddableListener(this);
         mediator.addProcedureListener(this);
         mediator.addProcedureDisplayListener(this);
         mediator.addQueryListener(this);
         mediator.addQueryDisplayListener(this);
-        
-        mediator.getApplication().getActionManager().setupCCP(this, 
-                CutAction.getActionName(), CopyAction.getActionName());
+
+        mediator.getApplication().getActionManager().setupCCP(
+                this,
+                CutAction.getActionName(),
+                CopyAction.getActionName());
     }
-    
+
     private void initFromModel(Project project) {
         // build model
         ProjectTreeModel model = new ProjectTreeModel(project);
@@ -192,7 +205,8 @@
         setModel(model);
 
         // expand top level
-        getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+        getSelectionModel().setSelectionMode(
+                TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
         Enumeration level = model.getRootNode().children();
         while (level.hasMoreElements()) {
             DefaultMutableTreeNode node = (DefaultMutableTreeNode) level.nextElement();
@@ -207,7 +221,7 @@
     ProjectTreeModel getProjectModel() {
         return (ProjectTreeModel) getModel();
     }
-    
+
     /**
      * Returns a "name" property of the tree node.
      */
@@ -238,6 +252,12 @@
 
         // read name property
         try {
+            if (value instanceof Embeddable) {
+                return (value != null) ? String.valueOf(PropertyUtils.getProperty(
+                        value,
+                        "className")) : "";
+            }
+
             return (value != null) ? String.valueOf(PropertyUtils.getProperty(
                     value,
                     "name")) : "";
@@ -253,7 +273,7 @@
     }
 
     public void currentDomainChanged(DomainDisplayEvent e) {
-        if ((e.getSource() == this || !e.isDomainChanged()) && !e.isRefired()){
+        if ((e.getSource() == this || !e.isDomainChanged()) && !e.isRefired()) {
             return;
         }
 
@@ -263,7 +283,7 @@
     }
 
     public void currentDataNodeChanged(DataNodeDisplayEvent e) {
-        if ((e.getSource() == this || !e.isDataNodeChanged()) && !e.isRefired()){
+        if ((e.getSource() == this || !e.isDataNodeChanged()) && !e.isRefired()) {
             return;
         }
 
@@ -273,7 +293,7 @@
     }
 
     public void currentDataMapChanged(DataMapDisplayEvent e) {
-        if ((e.getSource() == this || !e.isDataMapChanged()) && !e.isRefired()){
+        if ((e.getSource() == this || !e.isDataMapChanged()) && !e.isRefired()) {
             return;
         }
 
@@ -296,14 +316,14 @@
         if ((e.getSource() == this || !e.isEntityChanged()) && !e.isRefired()) {
             return;
         }
-        
+
         showNode(new Object[] {
                 e.getDomain(), e.getDataMap(), e.getEntity()
         });
     }
 
     public void currentProcedureChanged(ProcedureDisplayEvent e) {
-        if ((e.getSource() == this || !e.isProcedureChanged()) && !e.isRefired()){
+        if ((e.getSource() == this || !e.isProcedureChanged()) && !e.isRefired()) {
             return;
         }
 
@@ -313,7 +333,7 @@
     }
 
     public void currentQueryChanged(QueryDisplayEvent e) {
-        if ((e.getSource() == this || !e.isQueryChanged()) && !e.isRefired()){
+        if ((e.getSource() == this || !e.isQueryChanged()) && !e.isRefired()) {
             return;
         }
 
@@ -321,8 +341,9 @@
                 e.getDomain(), e.getDataMap(), e.getQuery()
         });
     }
-    
-    public void currentObjectsChanged(MultipleObjectsDisplayEvent e) {}
+
+    public void currentObjectsChanged(MultipleObjectsDisplayEvent e) {
+    }
 
     public void procedureAdded(ProcedureEvent e) {
 
@@ -346,8 +367,7 @@
         if (e.isNameChange()) {
             Object[] path = new Object[] {
                     mediator.findDomain(e.getProcedure().getDataMap()),
-                    e.getProcedure().getDataMap(),
-                    e.getProcedure()
+                    e.getProcedure().getDataMap(), e.getProcedure()
             };
 
             updateNode(path);
@@ -360,8 +380,7 @@
 
         removeNode(new Object[] {
                 mediator.findDomain(e.getProcedure().getDataMap()),
-                e.getProcedure().getDataMap(),
-                e.getProcedure()
+                e.getProcedure().getDataMap(), e.getProcedure()
         });
     }
 
@@ -369,8 +388,8 @@
 
         DefaultMutableTreeNode node = getProjectModel().getNodeForObjectPath(
                 new Object[] {
-                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataMap()),
-                        e.getDataMap()
+                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                                .getDataMap()), e.getDataMap()
                 });
 
         if (node == null) {
@@ -387,8 +406,8 @@
 
         if (e.isNameChange()) {
             Object[] path = new Object[] {
-                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataMap()),
-                    e.getQuery()
+                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                            .getDataMap()), e.getQuery()
             };
 
             updateNode(path);
@@ -399,9 +418,8 @@
 
     public void queryRemoved(QueryEvent e) {
         removeNode(new Object[] {
-                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataMap()),
-                e.getDataMap(),
-                e.getQuery()
+                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                        .getDataMap()), e.getDataMap(), e.getQuery()
         });
     }
 
@@ -437,8 +455,8 @@
 
         DefaultMutableTreeNode node = getProjectModel().getNodeForObjectPath(
                 new Object[] {
-                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataNode()), 
-                        e.getDataNode()
+                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                                .getDataNode()), e.getDataNode()
                 });
 
         if (node != null) {
@@ -511,7 +529,8 @@
 
         DefaultMutableTreeNode node = getProjectModel().getNodeForObjectPath(
                 new Object[] {
-                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataNode())
+                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                            .getDataNode())
                 });
 
         if (node == null) {
@@ -530,16 +549,16 @@
         }
 
         removeNode(new Object[] {
-                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataNode()),
-                e.getDataNode()
+                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                        .getDataNode()), e.getDataNode()
         });
     }
 
     public void dataMapChanged(DataMapEvent e) {
 
         Object[] path = new Object[] {
-                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataMap()), 
-                e.getDataMap()
+                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                        .getDataMap()), e.getDataMap()
         };
 
         updateNode(path);
@@ -553,18 +572,21 @@
     public void dataMapAdded(DataMapEvent e) {
         DefaultMutableTreeNode domainNode = getProjectModel().getNodeForObjectPath(
                 new Object[] {
-                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataMap())
+                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                            .getDataMap())
                 });
 
         DefaultMutableTreeNode newMapNode = ProjectTreeModel.wrapProjectNode(e
                 .getDataMap());
-        positionNode(domainNode, newMapNode, Comparators.getDataDomainChildrenComparator());
+        positionNode(domainNode, newMapNode, Comparators
+                .getDataDomainChildrenComparator());
         showNode(newMapNode);
     }
 
     public void dataMapRemoved(DataMapEvent e) {
         DataMap map = e.getDataMap();
-        DataDomain domain = e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getDataMap());
+        DataDomain domain = e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                .getDataMap());
 
         removeNode(new Object[] {
                 domain, map
@@ -572,7 +594,7 @@
 
         // Clean up map from the nodes
         for (DataNode dataNode : new ArrayList<DataNode>(domain.getDataNodes())) {
-            removeNode(new Object[]{
+            removeNode(new Object[] {
                     domain, dataNode, map
             });
         }
@@ -613,9 +635,9 @@
     protected void entityChanged(EntityEvent e) {
         if (e.isNameChange()) {
             Object[] path = new Object[] {
-                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getEntity().getDataMap()), 
-                    e.getEntity().getDataMap(),
-                    e.getEntity()
+                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                            .getEntity()
+                            .getDataMap()), e.getEntity().getDataMap(), e.getEntity()
             };
 
             updateNode(path);
@@ -634,8 +656,9 @@
 
         DefaultMutableTreeNode mapNode = getProjectModel().getNodeForObjectPath(
                 new Object[] {
-                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getEntity().getDataMap()), 
-                        e.getEntity().getDataMap()
+                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                                .getEntity()
+                                .getDataMap()), e.getEntity().getDataMap()
                 });
 
         if (mapNode == null) {
@@ -644,7 +667,7 @@
 
         DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(entity, false);
         positionNode(mapNode, currentNode, Comparators.getDataMapChildrenComparator());
-        //showNode(currentNode);
+        showNode(currentNode);
     }
 
     /**
@@ -658,9 +681,9 @@
 
         // remove from DataMap tree
         removeNode(new Object[] {
-                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e.getEntity().getDataMap()), 
-                e.getEntity().getDataMap(),
-                e.getEntity()
+                e.getDomain() != null ? e.getDomain() : mediator.findDomain(e
+                        .getEntity()
+                        .getDataMap()), e.getEntity().getDataMap(), e.getEntity()
         });
     }
 
@@ -819,6 +842,14 @@
                 mediator.fireDbEntityDisplayEvent(e);
             }
         }
+        else if (obj instanceof Embeddable) {
+            EmbeddableDisplayEvent e = new EmbeddableDisplayEvent(
+                    this,
+                    (Embeddable) obj,
+                    (DataMap) data[data.length - 2],
+                    (DataDomain) data[data.length - 3]);
+            mediator.fireEmbeddableDisplayEvent(e);
+        }
         else if (obj instanceof Procedure) {
             ProcedureDisplayEvent e = new ProcedureDisplayEvent(
                     this,
@@ -882,20 +913,20 @@
     public TreeSelectionListener getTreeSelectionListener() {
         return treeSelectionListener;
     }
-    
+
     /**
      * Creates JPopupMenu containing main functions
      */
-    private JPopupMenu createJPopupMenu()
-    {
+    private JPopupMenu createJPopupMenu() {
         JPopupMenu popup = new JPopupMenu();
-        
+
         popup.add(buildMenu(CreateDomainAction.getActionName()));
         popup.add(buildMenu(CreateNodeAction.getActionName()));
         popup.add(buildMenu(CreateDataMapAction.getActionName()));
 
         popup.add(buildMenu(CreateObjEntityAction.getActionName()));
         popup.add(buildMenu(CreateDbEntityAction.getActionName()));
+        popup.add(buildMenu(CreateEmbeddableAction.getActionName()));
         popup.add(buildMenu(CreateProcedureAction.getActionName()));
         popup.add(buildMenu(CreateQueryAction.getActionName()));
         popup.addSeparator();
@@ -906,12 +937,13 @@
         popup.add(buildMenu(CutAction.getActionName()));
         popup.add(buildMenu(CopyAction.getActionName()));
         popup.add(buildMenu(PasteAction.getActionName()));
-        
+
         return popup;
     }
-    
+
     /**
      * Creates and returns an menu item associated with the key.
+     * 
      * @param key action key
      */
     private JMenuItem buildMenu(String key) {
@@ -919,33 +951,86 @@
     }
 
     /**
-     * Class to handle right-click and show popup for selected tree row 
+     * Class to handle right-click and show popup for selected tree row
      */
-    class PopupHandler extends MouseAdapter
-    {
+    class PopupHandler extends MouseAdapter {
+
         @Override
-        public void mousePressed(MouseEvent e) 
-        {
+        public void mousePressed(MouseEvent e) {
             mouseReleased(e);
         }
 
         @Override
-        public void mouseReleased(MouseEvent e) 
-        {
-            if(e.isPopupTrigger())
-            {
-                if(popup == null)
+        public void mouseReleased(MouseEvent e) {
+            if (e.isPopupTrigger()) {
+                if (popup == null)
                     popup = createJPopupMenu();
-                
+
                 /**
                  * Selecting specified row
                  */
                 int row = getRowForLocation(e.getX(), e.getY());
-                if(row != -1 && !isRowSelected(row))
+                if (row != -1 && !isRowSelected(row))
                     setSelectionRow(row);
-                
+
                 popup.show(ProjectTreeView.this, e.getX(), e.getY());
             }
         }
     }
+
+    public void embeddableAdded(EmbeddableEvent e, DataMap map) {
+        Embeddable embeddable = e.getEmbeddable();
+
+        DefaultMutableTreeNode mapNode = getProjectModel().getNodeForObjectPath(
+                new Object[] {
+                        e.getDomain() != null ? e.getDomain() : mediator.findDomain(map),
+                        map
+                });
+
+        if (mapNode == null) {
+            return;
+        }
+
+        DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(embeddable, false);
+        positionNode(mapNode, currentNode, Comparators.getDataMapChildrenComparator());
+        showNode(currentNode);
+    }
+
+    public void embeddableChanged(EmbeddableEvent e, DataMap map) {
+        if (e.isNameChange()) {
+            Object[] path = new Object[] {
+                    e.getDomain() != null ? e.getDomain() : mediator.findDomain(map),
+                    map, e.getEmbeddable()
+            };
+
+            updateNode(path);
+            positionNode(path, Comparators.getDataMapChildrenComparator());
+            showNode(path);
+        }
+    }
+
+    public void embeddableRemoved(EmbeddableEvent e, DataMap map) {
+        if (e.getSource() == this) {
+            return;
+        }
+
+        // remove from DataMap tree
+        removeNode(new Object[] {
+                e.getDomain() != null ? e.getDomain() : mediator.findDomain(map), map,
+                e.getEmbeddable()
+        });
+    }
+
+    public void currentEmbeddableChanged(EmbeddableDisplayEvent e) {
+        e.setEmbeddableChanged(true);
+        
+        if ((e.getSource() == this || !e.isEmbeddableChanged()) && !e.isRefired()) {
+            return;
+        }
+
+        showNode(new Object[] {
+                e.getDomain(), e.getDataMap(), e.getEmbeddable()
+        });
+        
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java Wed Sep  2 08:52:39 2009
@@ -29,6 +29,8 @@
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -119,6 +121,7 @@
         Object last = path.getObject();
         if (last instanceof DataMap || last instanceof Query
                 || last instanceof DbEntity || last instanceof ObjEntity
+                || last instanceof Embeddable || last instanceof EmbeddableAttribute
                 || last instanceof DbAttribute || last instanceof DbRelationship
                 || last instanceof ObjAttribute || last instanceof ObjRelationship
                 || last instanceof Procedure || last instanceof ProcedureParameter) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAttributeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAttributeAction.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAttributeAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAttributeAction.java Wed Sep  2 08:52:39 2009
@@ -21,6 +21,7 @@
 import java.util.Arrays;
 
 import org.apache.cayenne.map.Attribute;
+import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.project.ProjectPath;
@@ -29,8 +30,9 @@
  * Action for copying attribute(s)
  */
 public class CopyAttributeAction extends CopyAction implements MultipleObjectsAction {
+
     private final static String ACTION_NAME = "Copy Attribute";
-    
+
     /**
      * Name of action if multiple attrs are selected
      */
@@ -39,7 +41,7 @@
     public static String getActionName() {
         return ACTION_NAME;
     }
-    
+
     public String getActionName(boolean multiple) {
         return multiple ? ACTION_NAME_MULTIPLE : ACTION_NAME;
     }
@@ -57,21 +59,28 @@
         if (path == null) {
             return false;
         }
+        boolean isEnable = path.getObject() instanceof Attribute;
+        if (!isEnable) {
+            isEnable = path.getObject() instanceof EmbeddableAttribute;
+        }
 
-        return path.getObject() instanceof Attribute;
+        return isEnable;
     }
-    
+
     @Override
     public Object copy(ProjectController mediator) {
         Object[] attrs = getProjectController().getCurrentObjAttributes();
         if (attrs == null || attrs.length == 0) {
             attrs = getProjectController().getCurrentDbAttributes();
         }
-        
+        if (attrs == null || attrs.length == 0) {
+            attrs = getProjectController().getCurrentEmbAttrs();
+        }
+
         if (attrs != null && attrs.length > 0) {
             return Arrays.asList(attrs);
         }
-        
+
         return null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java Wed Sep  2 08:52:39 2009
@@ -23,14 +23,18 @@
 
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.event.AttributeEvent;
+import org.apache.cayenne.map.event.EmbeddableAttributeEvent;
 import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
+import org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -40,7 +44,7 @@
 public class CreateAttributeAction extends CayenneAction {
 
     public static String getActionName() {
-    	return "Create Attribute";
+        return "Create Attribute";
     }
 
     /**
@@ -60,6 +64,9 @@
      */
     @Override
     public void performAction(ActionEvent e) {
+        if (getProjectController().getCurrentEmbeddable() != null) {
+            createEmbAttribute();
+        }
         if (getProjectController().getCurrentObjEntity() != null) {
             createObjAttribute();
         }
@@ -68,6 +75,39 @@
         }
     }
 
+    private void createEmbAttribute() {
+        ProjectController mediator = getProjectController();
+        Embeddable embeddable = mediator.getCurrentEmbeddable();
+
+        EmbeddableAttribute attr = (EmbeddableAttribute) NamedObjectFactory.createObject(
+                EmbeddableAttribute.class,
+                embeddable);
+        embeddable.addAttribute(attr);
+
+        fireEmbeddableAttributeEvent(this, mediator, embeddable, attr);
+    }
+
+    static void fireEmbeddableAttributeEvent(
+            Object src,
+            ProjectController mediator,
+            Embeddable embeddable,
+            EmbeddableAttribute attr) {
+        mediator.fireEmbeddableAttributeEvent(new EmbeddableAttributeEvent(
+                src,
+                attr,
+                embeddable,
+                MapEvent.ADD));
+
+        EmbeddableAttributeDisplayEvent e = new EmbeddableAttributeDisplayEvent(
+                src,
+                embeddable,
+                attr,
+                mediator.getCurrentDataMap(),
+                mediator.getCurrentDataDomain());
+
+        mediator.fireEmbeddableAttributeDisplayEvent(e);
+    }
+
     public void createObjAttribute() {
         ProjectController mediator = getProjectController();
         ObjEntity objEntity = mediator.getCurrentObjEntity();
@@ -79,11 +119,14 @@
 
         fireObjAttributeEvent(this, mediator, objEntity, attr);
     }
-    
+
     /**
      * Fires events when an obj attribute was added
      */
-    static void fireObjAttributeEvent(Object src, ProjectController mediator, ObjEntity objEntity, 
+    static void fireObjAttributeEvent(
+            Object src,
+            ProjectController mediator,
+            ObjEntity objEntity,
             ObjAttribute attr) {
         mediator.fireObjAttributeEvent(new AttributeEvent(
                 src,
@@ -111,11 +154,14 @@
         ProjectController mediator = getProjectController();
         fireDbAttributeEvent(this, mediator, dbEntity, attr);
     }
-    
+
     /**
      * Fires events when a db attribute was added
      */
-    static void fireDbAttributeEvent(Object src, ProjectController mediator, DbEntity dbEntity, 
+    static void fireDbAttributeEvent(
+            Object src,
+            ProjectController mediator,
+            DbEntity dbEntity,
             DbAttribute attr) {
         mediator.fireDbAttributeEvent(new AttributeEvent(
                 src,

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java?rev=810422&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java Wed Sep  2 08:52:39 2009
@@ -0,0 +1,96 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.action;
+
+import java.awt.event.ActionEvent;
+
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.event.EmbeddableEvent;
+import org.apache.cayenne.map.event.MapEvent;
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.project.NamedObjectFactory;
+import org.apache.cayenne.project.ProjectPath;
+
+public class CreateEmbeddableAction extends CayenneAction {
+
+    public static String getActionName() {
+        return "Create Embeddable";
+    }
+
+    public CreateEmbeddableAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    @Override
+    public String getIconName() {
+        return "icon-new_embeddable.gif";
+    }
+
+    @Override
+    public void performAction(ActionEvent e) {
+        createEmbeddable();
+    }
+
+    private void createEmbeddable() {
+        ProjectController mediator = getProjectController();
+
+        DataMap dataMap = mediator.getCurrentDataMap();
+        Embeddable embeddable = (Embeddable) NamedObjectFactory.createObject(
+                Embeddable.class,
+                mediator.getCurrentDataMap());
+
+
+        dataMap.addEmbeddable(embeddable);
+
+        fireEmbeddableEvent(this, mediator, dataMap, embeddable);
+    }
+
+    static void fireEmbeddableEvent(
+            Object src,
+            ProjectController mediator,
+            DataMap dataMap,
+            Embeddable embeddable) {
+
+        mediator.fireEmbeddableEvent(new EmbeddableEvent(src, embeddable, MapEvent.ADD), dataMap);
+        EmbeddableDisplayEvent displayEvent = new EmbeddableDisplayEvent(
+                src,
+                embeddable,
+                dataMap,
+                mediator.getCurrentDataDomain());
+        displayEvent.setMainTabFocus(true);
+        mediator.fireEmbeddableDisplayEvent(displayEvent);
+
+    }
+
+    /**
+     * Returns <code>true</code> if path contains a DataMap object.
+     */
+    @Override
+    public boolean enableForPath(ProjectPath path) {
+        if (path == null) {
+            return false;
+        }
+
+        return path.firstInstanceOf(DataMap.class) != null;
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAttributeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAttributeAction.java?rev=810422&r1=810421&r2=810422&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAttributeAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAttributeAction.java Wed Sep  2 08:52:39 2009
@@ -21,6 +21,7 @@
 import java.awt.event.ActionEvent;
 
 import org.apache.cayenne.map.Attribute;
+import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.project.ProjectPath;
 
@@ -28,8 +29,9 @@
  * Action for cutting attribute(s)
  */
 public class CutAttributeAction extends CutAction implements MultipleObjectsAction {
+
     private final static String ACTION_NAME = "Cut Attribute";
-    
+
     /**
      * Name of action if multiple attrs are selected
      */
@@ -38,7 +40,7 @@
     public static String getActionName() {
         return ACTION_NAME;
     }
-    
+
     public String getActionName(boolean multiple) {
         return multiple ? ACTION_NAME_MULTIPLE : ACTION_NAME;
     }
@@ -56,16 +58,21 @@
         if (path == null) {
             return false;
         }
+        boolean isEnable = path.getObject() instanceof Attribute;
+        if (!isEnable) {
+            isEnable = path.getObject() instanceof EmbeddableAttribute;
+        }
 
-        return path.getObject() instanceof Attribute;
+        return isEnable;
     }
-    
+
     /**
      * Performs cutting of items
      */
     @Override
     public void performAction(ActionEvent e) {
         application.getAction(CopyAttributeAction.getActionName()).performAction(e);
-        ((RemoveAction) application.getAction(RemoveAttributeAction.getActionName())).performAction(e, false);
+        ((RemoveAction) application.getAction(RemoveAttributeAction.getActionName()))
+                .performAction(e, false);
     }
 }



Mime
View raw message