cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r988538 [4/4] - in /cayenne/main/trunk: framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ framework/cayenne-modeler/src/main/java/org/apache/cayenn...
Date Tue, 24 Aug 2010 13:34:39 GMT
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -29,34 +29,31 @@ import org.apache.cayenne.modeler.event.
 
 public class CreateDataMapUndoableEdit extends CayenneUndoableEdit {
 
-	@Override
-	public String getPresentationName() {
-		return "Create DataMap";
-	}
-
-	
-
-	private DataChannelDescriptor domain;
-	private DataMap map;
-
-	public CreateDataMapUndoableEdit(DataChannelDescriptor domain, DataMap map) {
-		this.domain = domain;
-		this.map = map;
-	}
-
-	@Override
-	public void redo() throws CannotRedoException {
-		CreateDataMapAction action = (CreateDataMapAction) actionManager
-				.getAction(CreateDataMapAction.getActionName());
-		action.createDataMap(map);
-	}
-
-	@Override
-	public void undo() throws CannotUndoException {
-		RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction.getActionName());
-		
-		controller.fireDomainDisplayEvent(new DomainDisplayEvent(this, domain));
-		
-		action.removeDataMap(map);
-	}
+    @Override
+    public String getPresentationName() {
+        return "Create DataMap";
+    }
+
+    private DataChannelDescriptor domain;
+    private DataMap map;
+
+    public CreateDataMapUndoableEdit(DataChannelDescriptor domain, DataMap map) {
+        this.domain = domain;
+        this.map = map;
+    }
+
+    @Override
+    public void redo() throws CannotRedoException {
+        CreateDataMapAction action = actionManager.getAction(CreateDataMapAction.class);
+        action.createDataMap(map);
+    }
+
+    @Override
+    public void undo() throws CannotUndoException {
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
+
+        controller.fireDomainDisplayEvent(new DomainDisplayEvent(this, domain));
+
+        action.removeDataMap(map);
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDbEntityUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDbEntityUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDbEntityUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDbEntityUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -38,8 +38,6 @@ public class CreateDbEntityUndoableEdit 
         return "Create DbEntity";
     }
 
-    
-
     private DataMap map;
     private DbEntity entity;
 
@@ -50,15 +48,13 @@ public class CreateDbEntityUndoableEdit 
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateDbEntityAction action = (CreateDbEntityAction) actionManager
-                .getAction(CreateDbEntityAction.getActionName());
+        CreateDbEntityAction action = actionManager.getAction(CreateDbEntityAction.class);
         action.createEntity(map, entity);
     }
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
         action.removeDbEntity(map, entity);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbAttributeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbAttributeUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbAttributeUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbAttributeUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -45,8 +45,8 @@ public class CreateEmbAttributeUndoableE
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateAttributeAction action = (CreateAttributeAction) actionManager
-                .getAction(CreateAttributeAction.getActionName());
+        CreateAttributeAction action = actionManager
+                .getAction(CreateAttributeAction.class);
         for (EmbeddableAttribute attr : attrs) {
             action.createEmbAttribute(embeddable, attr);
         }
@@ -54,8 +54,8 @@ public class CreateEmbAttributeUndoableE
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveAttributeAction action = (RemoveAttributeAction) actionManager
-                .getAction(RemoveAttributeAction.getActionName());
+        RemoveAttributeAction action = actionManager
+                .getAction(RemoveAttributeAction.class);
         action.removeEmbeddableAttributes(embeddable, attrs);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbeddableUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbeddableUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbeddableUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbeddableUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -43,16 +43,15 @@ public class CreateEmbeddableUndoableEdi
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateEmbeddableAction action = (CreateEmbeddableAction) actionManager
-                .getAction(CreateEmbeddableAction.getActionName());
+        CreateEmbeddableAction action = actionManager
+                .getAction(CreateEmbeddableAction.class);
 
         action.createEmbeddable(dataMap, embeddable);
     }
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
         action.removeEmbeddable(dataMap, embeddable);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEntityListenerUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEntityListenerUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEntityListenerUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEntityListenerUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -28,7 +28,6 @@ import org.apache.cayenne.modeler.action
 
 public class CreateEntityListenerUndoableEdit extends CayenneUndoableEdit {
 
-    
     private ObjEntity objEntity;
     private EntityListener listener;
 
@@ -44,15 +43,15 @@ public class CreateEntityListenerUndoabl
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateDataMapEntityListenerAction action = (CreateDataMapEntityListenerAction) actionManager
-                .getAction(CreateDataMapEntityListenerAction.getActionName());
+        CreateDataMapEntityListenerAction action = actionManager
+                .getAction(CreateDataMapEntityListenerAction.class);
         action.createEntityListener(objEntity, listener);
     }
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveEntityListenerAction action = (RemoveEntityListenerAction) actionManager
-                .getAction(RemoveEntityListenerAction.getActionName());
+        RemoveEntityListenerAction action = actionManager
+                .getAction(RemoveEntityListenerAction.class);
 
         action.removeEntityListener(objEntity, listener.getClassName());
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -47,15 +47,13 @@ public class CreateNodeUndoableEdit exte
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
         action.removeDataNode(node);
     }
 
     public void redo() throws CannotRedoException {
         domain.getNodeDescriptors().add(node);
-        CreateNodeAction action = (CreateNodeAction) actionManager
-                .getAction(CreateNodeAction.getActionName());
+        CreateNodeAction action = actionManager.getAction(CreateNodeAction.class);
         action.createDataNode(node);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateObjEntityUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateObjEntityUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateObjEntityUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateObjEntityUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -28,8 +28,6 @@ import org.apache.cayenne.modeler.action
 
 public class CreateObjEntityUndoableEdit extends CayenneUndoableEdit {
 
-    
-
     private DataMap map;
     private ObjEntity objEntity;
 
@@ -50,18 +48,15 @@ public class CreateObjEntityUndoableEdit
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateObjEntityAction action = (CreateObjEntityAction) actionManager
-                .getAction(CreateObjEntityAction.getActionName());
+        CreateObjEntityAction action = actionManager
+                .getAction(CreateObjEntityAction.class);
 
         action.createObjEntity(map, objEntity);
     }
 
     @Override
     public void undo() throws CannotUndoException {
-
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
-
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
         action.removeObjEntity(map, objEntity);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -28,8 +28,6 @@ import org.apache.cayenne.modeler.action
 
 public class CreateProcedureUndoableEdit extends CayenneUndoableEdit {
 
-    
-
     private DataMap map;
     private Procedure procedure;
 
@@ -45,15 +43,14 @@ public class CreateProcedureUndoableEdit
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateProcedureAction action = (CreateProcedureAction) actionManager
-                .getAction(CreateProcedureAction.getActionName());
+        CreateProcedureAction action = actionManager
+                .getAction(CreateProcedureAction.class);
         action.createProcedure(map, procedure);
     }
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
         action.removeProcedure(map, procedure);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -41,8 +41,7 @@ public class CreateQueryUndoableEdit ext
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateQueryAction action = (CreateQueryAction) actionManager
-                .getAction(CreateQueryAction.getActionName());
+        CreateQueryAction action = actionManager.getAction(CreateQueryAction.class);
         action.createQuery(domain, map, query);
     }
 
@@ -53,10 +52,7 @@ public class CreateQueryUndoableEdit ext
 
     @Override
     public void undo() throws CannotUndoException {
-
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
-
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
         action.removeQuery(map, query);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -47,7 +47,7 @@ public class CreateRelationshipUndoableE
         this.dbEnt = dbEnt;
         this.dbRel = dbRel;
     }
-    
+
     @Override
     public String getPresentationName() {
         return "Create Relationship";
@@ -55,8 +55,8 @@ public class CreateRelationshipUndoableE
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateRelationshipAction action = (CreateRelationshipAction) actionManager
-                .getAction(CreateRelationshipAction.getActionName());
+        CreateRelationshipAction action = actionManager
+                .getAction(CreateRelationshipAction.class);
 
         if (objEnt != null) {
             for (ObjRelationship rel : objectRel) {
@@ -73,8 +73,8 @@ public class CreateRelationshipUndoableE
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveRelationshipAction action = (RemoveRelationshipAction) actionManager
-                .getAction(RemoveRelationshipAction.getActionName());
+        RemoveRelationshipAction action = actionManager
+                .getAction(RemoveRelationshipAction.class);
 
         if (objEnt != null) {
             action.removeObjRelationships(objEnt, objectRel);
@@ -82,13 +82,15 @@ public class CreateRelationshipUndoableE
                     this,
                     objEnt,
                     objEnt.getDataMap(),
-                    (DataChannelDescriptor)controller.getProject().getRootNode()));
+                    (DataChannelDescriptor) controller.getProject().getRootNode()));
         }
 
         if (dbEnt != null) {
             action.removeDbRelationships(dbEnt, dbRel);
             controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEnt, dbEnt
-                    .getDataMap(), (DataChannelDescriptor)controller.getProject().getRootNode()));
+                    .getDataMap(), (DataChannelDescriptor) controller
+                    .getProject()
+                    .getRootNode()));
         }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -41,14 +41,13 @@ import org.apache.cayenne.query.Query;
 
 public class PasteUndoableEdit extends CayenneUndoableEdit {
 
-    
-
     private DataChannelDescriptor domain;
     private DataMap map;
     private Object where;
     private Object content;
 
-    public PasteUndoableEdit(DataChannelDescriptor domain, DataMap map, Object where, Object content) {
+    public PasteUndoableEdit(DataChannelDescriptor domain, DataMap map, Object where,
+            Object content) {
         this.domain = domain;
         this.map = map;
         this.where = where;
@@ -67,32 +66,32 @@ public class PasteUndoableEdit extends C
 
     @Override
     public void redo() throws CannotRedoException {
-        PasteAction action = (PasteAction) actionManager.getAction(PasteAction
-                .getActionName());
+        PasteAction action = actionManager.getAction(PasteAction.class);
 
         action.paste(where, content, domain, map);
     }
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveAttributeAction rAttributeAction = (RemoveAttributeAction) actionManager
-                .getAction(RemoveAttributeAction.getActionName());
+        RemoveAttributeAction rAttributeAction = actionManager
+                .getAction(RemoveAttributeAction.class);
 
-        RemoveAction rAction = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
+        RemoveAction rAction = actionManager.getAction(RemoveAction.class);
 
-        RemoveRelationshipAction rRelationShipAction = (RemoveRelationshipAction) actionManager
-                .getAction(RemoveRelationshipAction.getActionName());
+        RemoveRelationshipAction rRelationShipAction = actionManager
+                .getAction(RemoveRelationshipAction.class);
 
-        RemoveProcedureParameterAction rProcedureParamAction = (RemoveProcedureParameterAction) actionManager
-                .getAction(RemoveProcedureParameterAction.getActionName());
+        RemoveProcedureParameterAction rProcedureParamAction = actionManager
+                .getAction(RemoveProcedureParameterAction.class);
 
         if (content instanceof DataMap) {
             if (where instanceof DataChannelDescriptor) {
                 rAction.removeDataMap((DataMap) content);
             }
             else if (where instanceof DataNodeDescriptor) {
-                rAction.removeDataMapFromDataNode((DataNodeDescriptor) where, (DataMap) content);
+                rAction.removeDataMapFromDataNode(
+                        (DataNodeDescriptor) where,
+                        (DataMap) content);
             }
         }
         else if (where instanceof DataMap) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -73,8 +73,8 @@ public class RemoveAttributeUndoableEdit
 
     @Override
     public void redo() throws CannotRedoException {
-        RemoveAttributeAction action = (RemoveAttributeAction) actionManager
-                .getAction(RemoveAttributeAction.getActionName());
+        RemoveAttributeAction action = actionManager
+                .getAction(RemoveAttributeAction.class);
 
         if (objEntity != null) {
             action.removeObjAttributes(objEntity, objAttributes);
@@ -107,8 +107,8 @@ public class RemoveAttributeUndoableEdit
     @Override
     public void undo() throws CannotUndoException {
 
-        CreateAttributeAction action = (CreateAttributeAction) actionManager
-                .getAction(CreateAttributeAction.getActionName());
+        CreateAttributeAction action = actionManager
+                .getAction(CreateAttributeAction.class);
 
         if (objEntity != null) {
             for (ObjAttribute attr : objAttributes) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -30,58 +30,59 @@ import org.apache.cayenne.modeler.action
 
 public class RemoveRelationshipUndoableEdit extends CayenneUndoableEdit {
 
-	private ObjEntity objEntity;
-	private ObjRelationship[] rels;
+    private ObjEntity objEntity;
+    private ObjRelationship[] rels;
 
-	private DbEntity dbEntity;
-	private DbRelationship[] dbRels;
+    private DbEntity dbEntity;
+    private DbRelationship[] dbRels;
 
-	public RemoveRelationshipUndoableEdit(ObjEntity objEntity,
-			ObjRelationship[] rels) {
-		super();
-		this.objEntity = objEntity;
-		this.rels = rels;
-	}
-
-	public RemoveRelationshipUndoableEdit(DbEntity dbEntity,
-			DbRelationship[] dbRels) {
-		super();
-		this.dbEntity = dbEntity;
-		this.dbRels = dbRels;
-	}
-
-	@Override
-	public String getPresentationName() {
-		if (objEntity != null) {
-			return "Remove Obj Relationship";
-		} else {
-			return "Remove Db Relationship";
-		}
-	}
-
-	@Override
-	public void redo() throws CannotRedoException {
-		RemoveRelationshipAction action = (RemoveRelationshipAction) actionManager
-				.getAction(RemoveRelationshipAction.getActionName());
-		if (objEntity != null) {
-			action.removeObjRelationships(objEntity, rels);
-		} else {
-			action.removeDbRelationships(dbEntity, dbRels);
-		}
-	}
-
-	@Override
-	public void undo() throws CannotUndoException {
-		CreateRelationshipAction action = (CreateRelationshipAction) actionManager
-				.getAction(CreateRelationshipAction.getActionName());
-		if (objEntity != null) {
-			for (ObjRelationship r : rels) {
-				action.createObjRelationship(objEntity, r);
-			}
-		} else {
-			for (DbRelationship dr : dbRels) {
-				action.createDbRelationship(dbEntity, dr);
-			}
-		}
-	}
+    public RemoveRelationshipUndoableEdit(ObjEntity objEntity, ObjRelationship[] rels) {
+        super();
+        this.objEntity = objEntity;
+        this.rels = rels;
+    }
+
+    public RemoveRelationshipUndoableEdit(DbEntity dbEntity, DbRelationship[] dbRels) {
+        super();
+        this.dbEntity = dbEntity;
+        this.dbRels = dbRels;
+    }
+
+    @Override
+    public String getPresentationName() {
+        if (objEntity != null) {
+            return "Remove Obj Relationship";
+        }
+        else {
+            return "Remove Db Relationship";
+        }
+    }
+
+    @Override
+    public void redo() throws CannotRedoException {
+        RemoveRelationshipAction action = actionManager
+                .getAction(RemoveRelationshipAction.class);
+        if (objEntity != null) {
+            action.removeObjRelationships(objEntity, rels);
+        }
+        else {
+            action.removeDbRelationships(dbEntity, dbRels);
+        }
+    }
+
+    @Override
+    public void undo() throws CannotUndoException {
+        CreateRelationshipAction action = actionManager
+                .getAction(CreateRelationshipAction.class);
+        if (objEntity != null) {
+            for (ObjRelationship r : rels) {
+                action.createObjRelationship(objEntity, r);
+            }
+        }
+        else {
+            for (DbRelationship dr : dbRels) {
+                action.createDbRelationship(dbEntity, dr);
+            }
+        }
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java Tue Aug 24 13:34:35 2010
@@ -28,9 +28,9 @@ import java.util.Map.Entry;
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.configuration.event.DataNodeEvent;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.event.DataNodeEvent;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
@@ -54,8 +54,6 @@ import org.apache.cayenne.query.Query;
 
 public class RemoveUndoableEdit extends CayenneUndoableEdit {
 
-    
-
     private DataMap map;
     private DbEntity dbEntity;
     private ObjEntity objEntity;
@@ -77,24 +75,28 @@ public class RemoveUndoableEdit extends 
     private REMOVE_MODE mode;
 
     public RemoveUndoableEdit(Application application) {
-        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
+        this.domain = (DataChannelDescriptor) application.getProject().getRootNode();
+        ;
         this.mode = REMOVE_MODE.DOMAIN;
     }
 
-    public RemoveUndoableEdit(Application application, DataNodeDescriptor node, DataMap map) {
+    public RemoveUndoableEdit(Application application, DataNodeDescriptor node,
+            DataMap map) {
         this.map = map;
         this.dataNode = node;
         this.mode = REMOVE_MODE.MAP_FROM_NODE;
     }
 
     public RemoveUndoableEdit(Application application, DataMap map) {
-        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
+        this.domain = (DataChannelDescriptor) application.getProject().getRootNode();
+        ;
         this.map = map;
         this.mode = REMOVE_MODE.MAP_FROM_DOMAIN;
     }
 
     public RemoveUndoableEdit(Application application, DataNodeDescriptor node) {
-        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
+        this.domain = (DataChannelDescriptor) application.getProject().getRootNode();
+        ;
         this.dataNode = node;
         this.mode = REMOVE_MODE.NODE;
     }
@@ -196,8 +198,7 @@ public class RemoveUndoableEdit extends 
 
     @Override
     public void redo() throws CannotRedoException {
-        RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
-                .getActionName());
+        RemoveAction action = actionManager.getAction(RemoveAction.class);
 
         switch (this.mode) {
             case OBJECT_ENTITY:
@@ -228,8 +229,8 @@ public class RemoveUndoableEdit extends 
     @Override
     public void undo() throws CannotUndoException {
 
-        CreateRelationshipAction relationshipAction = (CreateRelationshipAction) actionManager
-                .getAction(CreateRelationshipAction.getActionName());
+        CreateRelationshipAction relationshipAction = actionManager
+                .getAction(CreateRelationshipAction.class);
 
         switch (this.mode) {
             case OBJECT_ENTITY: {
@@ -242,8 +243,8 @@ public class RemoveUndoableEdit extends 
                     }
                 }
 
-                CreateObjEntityAction action = (CreateObjEntityAction) actionManager
-                        .getAction(CreateObjEntityAction.getActionName());
+                CreateObjEntityAction action = actionManager
+                        .getAction(CreateObjEntityAction.class);
                 action.createObjEntity(map, objEntity);
 
                 break;
@@ -258,31 +259,32 @@ public class RemoveUndoableEdit extends 
                     }
                 }
 
-                CreateDbEntityAction action = (CreateDbEntityAction) actionManager
-                        .getAction(CreateDbEntityAction.getActionName());
+                CreateDbEntityAction action = actionManager
+                        .getAction(CreateDbEntityAction.class);
 
                 action.createEntity(map, dbEntity);
 
                 break;
             }
             case QUERY: {
-               
-                this.domain = (DataChannelDescriptor)Application
+
+                this.domain = (DataChannelDescriptor) Application
                         .getInstance()
                         .getFrameController()
                         .getProjectController()
-                        .getProject().getRootNode();
+                        .getProject()
+                        .getRootNode();
 
-                CreateQueryAction action = (CreateQueryAction) actionManager
-                        .getAction(CreateQueryAction.getActionName());
+                CreateQueryAction action = actionManager
+                        .getAction(CreateQueryAction.class);
 
                 action.createQuery(domain, map, query);
 
                 break;
             }
             case PROCEDURE: {
-                CreateProcedureAction action = (CreateProcedureAction) actionManager
-                        .getAction(CreateProcedureAction.getActionName());
+                CreateProcedureAction action = actionManager
+                        .getAction(CreateProcedureAction.class);
                 action.createProcedure(map, procedure);
                 break;
             }
@@ -296,32 +298,34 @@ public class RemoveUndoableEdit extends 
                         .getFrameController()
                         .getProjectController();
 
-                e.setDomain( (DataChannelDescriptor)controller.getProject().getRootNode());
+                e
+                        .setDomain((DataChannelDescriptor) controller
+                                .getProject()
+                                .getRootNode());
 
                 controller.fireDataNodeEvent(e);
-                
+
                 break;
             }
             case MAP_FROM_DOMAIN: {
-                CreateDataMapAction action = (CreateDataMapAction) actionManager
-                        .getAction(CreateDataMapAction.getActionName());
+                CreateDataMapAction action = actionManager
+                        .getAction(CreateDataMapAction.class);
                 action.createDataMap(map);
-                
+
                 break;
             }
             case NODE: {
-                CreateNodeAction action = (CreateNodeAction) actionManager
-                        .getAction(CreateNodeAction.getActionName());
+                CreateNodeAction action = actionManager.getAction(CreateNodeAction.class);
                 action.createDataNode(dataNode);
-                
+
                 break;
             }
 
             case EMBEDDABLE: {
-                CreateEmbeddableAction action = (CreateEmbeddableAction) actionManager
-                        .getAction(CreateEmbeddableAction.getActionName());
+                CreateEmbeddableAction action = actionManager
+                        .getAction(CreateEmbeddableAction.class);
                 action.createEmbeddable(map, embeddable);
-                
+
                 break;
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java Tue Aug 24 13:34:35 2010
@@ -40,7 +40,6 @@ import org.apache.cayenne.util.Util;
 /**
  * Superclass of CayenneModeler actions that implements support for some common
  * functionality, exception handling, etc.
- * 
  */
 public abstract class CayenneAction extends AbstractAction {
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java Tue Aug 24 13:34:35 2010
@@ -53,7 +53,7 @@ public abstract class CayenneController 
     protected CayenneController parent;
     protected Application application;
     protected PropertyChangeSupport propertyChangeSupport;
-
+    
     public CayenneController(CayenneController parent) {
         this.application = (parent != null) ? parent.getApplication() : null;
         this.parent = parent;

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java Tue Aug 24 13:34:35 2010
@@ -30,6 +30,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import javax.swing.Action;
 import javax.swing.ImageIcon;
 
 import org.apache.cayenne.access.types.ExtendedTypeMap;
@@ -40,6 +41,7 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ModelerConstants;
 import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.action.ActionManager;
 import org.apache.cayenne.modeler.action.MultipleObjectsAction;
 import org.apache.cayenne.reflect.PropertyUtils;
 import org.apache.cayenne.util.CayenneMapEntry;
@@ -139,7 +141,9 @@ public final class ModelerUtil {
         return finalList;
     }
 
-    public static DataNodeDescriptor getNodeLinkedToMap(DataChannelDescriptor domain, DataMap map) {
+    public static DataNodeDescriptor getNodeLinkedToMap(
+            DataChannelDescriptor domain,
+            DataMap map) {
         Collection<DataNodeDescriptor> nodes = domain.getNodeDescriptors();
 
         // go via an iterator in an indexed loop, since
@@ -151,18 +155,23 @@ public final class ModelerUtil {
 
         return null;
     }
-    
+
     /**
      * Updates MultipleObjectActions' state, depending on number of selected objects
      * (attributes, rel etc.)
      */
-    public static void updateActions(int numSelected, String... actionNames) {
-        for (String actionName : actionNames) {
-            CayenneAction action = Application.getInstance().getAction(actionName);
+    public static void updateActions(int numSelected, Class<? extends Action>... actions) {
+        ActionManager actionManager = Application.getInstance().getActionManager();
+
+        for (Class<? extends Action> actionType : actions) {
+            Action action = actionManager.getAction(actionType);
 
             if (action instanceof MultipleObjectsAction) {
-                action.setEnabled(numSelected > 0);
-                action.setName(((MultipleObjectsAction) action).getActionName(numSelected > 1));
+
+                MultipleObjectsAction multiObjectAction = (MultipleObjectsAction) action;
+                multiObjectAction.setEnabled(numSelected > 0);
+                ((CayenneAction) multiObjectAction).setName(multiObjectAction
+                        .getActionName(numSelected > 1));
             }
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/RecentFileMenu.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/RecentFileMenu.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/RecentFileMenu.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/RecentFileMenu.java Tue Aug 24 13:34:35 2010
@@ -38,6 +38,7 @@ import org.apache.cayenne.swing.control.
  * 
  */
 public class RecentFileMenu extends JMenu implements RecentFileListListener {
+
     /**
      * Constructor for RecentFileMenu.
      */
@@ -57,7 +58,7 @@ public class RecentFileMenu extends JMen
      * preferences.
      */
     public void rebuildFromPreferences() {
-  
+
         List<String> arr = ModelerPreferences.getLastProjFiles();
         while (arr.size() > ModelerPreferences.LAST_PROJ_FILES_SIZE) {
             arr.remove(arr.size() - 1);
@@ -91,7 +92,8 @@ public class RecentFileMenu extends JMen
     }
 
     protected Action findAction() {
-        return Application.getInstance().getAction(OpenProjectAction.getActionName());
+        return Application.getInstance().getActionManager().getAction(
+                OpenProjectAction.class);
     }
 
     public void recentFileListChanged() {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/UpgradeCayennePreference.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/UpgradeCayennePreference.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/UpgradeCayennePreference.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/UpgradeCayennePreference.java Tue Aug 24 13:34:35 2010
@@ -68,10 +68,6 @@ public class UpgradeCayennePreference ex
                                 ep.getBoolean(EDITOR_LOGFILE_ENABLED_OLD));
                         prefEditor.put(ModelerPreferences.EDITOR_LOGFILE, ep
                                 .getString(EDITOR_LOGFILE_OLD));
-                        prefEditor.put(ModelerPreferences.EDITOR_LAFNAME, ep
-                                .getString(EDITOR_LAFNAME_OLD));
-                        prefEditor.put(ModelerPreferences.EDITOR_THEMENAME, ep
-                                .getString(EDITOR_THEMENAME_OLD));
 
                         Preferences frefLastProjFiles = prefEditor.node(LAST_PROJ_FILES);
 

Modified: cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java Tue Aug 24 13:34:35 2010
@@ -41,9 +41,6 @@ import org.apache.velocity.app.VelocityE
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.log.NullLogSystem;
 
-/**
- * @since 3.0
- */
 public class ClassGenerationAction {
     static final String TEMPLATES_DIR_NAME = "templates/v1_2/";
 

Modified: cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/pom.xml?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/pom.xml (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/pom.xml Tue Aug 24 13:34:35 2010
@@ -34,16 +34,46 @@
 	<packaging>jar</packaging>
 
 	<dependencies>
+		
 		<dependency>
 			<groupId>org.apache.cayenne</groupId>
 			<artifactId>cayenne-modeler</artifactId>
 			<version>${version}</version>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.cayenne.unpublished</groupId>
+			<artifactId>cayenne-di-unpublished</artifactId>
+			<version>${version}</version>
+			<scope>provided</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.cayenne.unpublished</groupId>
+			<artifactId>cayenne-jdk1.5-unpublished</artifactId>
+			<version>${version}</version>
+			<scope>provided</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.cayenne.unpublished</groupId>
+			<artifactId>cayenne-project-unpublished</artifactId>
+			<version>${version}</version>
+			<scope>provided</scope>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-deploy-plugin</artifactId>
 				<configuration>
 					<skip>true</skip>

Copied: cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/OSXMain.java (from r988535, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/OSXMain.java?p2=cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/OSXMain.java&p1=cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java&r1=988535&r2=988538&rev=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/OSXMain.java Tue Aug 24 13:34:35 2010
@@ -16,31 +16,39 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.modeler.undo;
 
-import javax.swing.undo.AbstractUndoableEdit;
+package org.apache.cayenne.modeler;
 
-import org.apache.cayenne.modeler.ActionManager;
-import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.ProjectController;
-
-public abstract class CayenneUndoableEdit extends AbstractUndoableEdit {
-    
-	protected ActionManager actionManager;
-	protected ProjectController controller;
-	
-	public CayenneUndoableEdit() {
-		this.actionManager = Application.getInstance().getActionManager();
-		this.controller = Application.getInstance().getFrameController().getProjectController();
+import java.util.Collection;
+
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.modeler.init.OSXCayenneModelerModule;
+
+/**
+ * Main class to start CayenneModeler on MacOSX.
+ */
+public class OSXMain extends Main {
+
+	/**
+	 * Main method that starts the CayenneModeler.
+	 */
+	public static void main(String[] args) {
+		try {
+			new OSXMain(args).launch();
+		} catch (Exception e) {
+			e.printStackTrace();
+			System.exit(1);
+		}
 	}
 
-	@Override
-	public boolean canRedo() {
-		return true;
+	protected OSXMain(String[] args) {
+		super(args);
 	}
 
-    @Override
-    public boolean canUndo() {
-        return true;
-    }
+	@Override
+	protected Collection<Module> appendModules(Collection<Module> modules) {
+		modules = super.appendModules(modules);
+		modules.add(new OSXCayenneModelerModule());
+		return modules;
+	}
 }

Added: cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/OSXCayenneModelerModule.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/OSXCayenneModelerModule.java?rev=988538&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/OSXCayenneModelerModule.java (added)
+++ cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/OSXCayenneModelerModule.java Tue Aug 24 13:34:35 2010
@@ -0,0 +1,13 @@
+package org.apache.cayenne.modeler.init;
+
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.modeler.init.platform.OSXPlatformInitializer;
+import org.apache.cayenne.modeler.init.platform.PlatformInitializer;
+
+public class OSXCayenneModelerModule implements Module {
+
+	public void configure(Binder binder) {
+		binder.bind(PlatformInitializer.class).to(OSXPlatformInitializer.class);
+	}
+}

Added: cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/platform/OSXPlatformInitializer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/platform/OSXPlatformInitializer.java?rev=988538&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/platform/OSXPlatformInitializer.java (added)
+++ cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/platform/OSXPlatformInitializer.java Tue Aug 24 13:34:35 2010
@@ -0,0 +1,103 @@
+package org.apache.cayenne.modeler.init.platform;
+
+import java.awt.Component;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.Action;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.modeler.action.AboutAction;
+import org.apache.cayenne.modeler.action.ActionManager;
+import org.apache.cayenne.modeler.action.ConfigurePreferencesAction;
+import org.apache.cayenne.modeler.action.ExitAction;
+
+import com.apple.eawt.Application;
+import com.apple.eawt.ApplicationAdapter;
+import com.apple.eawt.ApplicationEvent;
+
+public class OSXPlatformInitializer implements PlatformInitializer {
+
+	@Inject
+	protected ActionManager actionManager;
+
+	public void initLookAndFeel() {
+
+		// leave alone the look and feel. Presumably it is Aqua, since this
+		// launcher can only be executed on Mac
+
+		// configure special Mac menu handlers though...
+
+		Application.getApplication().addAboutMenuItem();
+		Application.getApplication().addPreferencesMenuItem();
+		Application.getApplication().setEnabledAboutMenu(true);
+		Application.getApplication().setEnabledPreferencesMenu(true);
+
+		Application.getApplication().addApplicationListener(
+				new MacEventsAdapter());
+	}
+
+	public void setupMenus(JFrame frame) {
+
+		Set<Action> removeActions = new HashSet<Action>();
+		removeActions.add(actionManager.getAction(ExitAction.class));
+		removeActions.add(actionManager.getAction(AboutAction.class));
+		removeActions.add(actionManager
+				.getAction(ConfigurePreferencesAction.class));
+
+		JMenuBar menuBar = frame.getJMenuBar();
+		for (Component menu : menuBar.getComponents()) {
+			if (menu instanceof JMenu) {
+				JMenu jMenu = (JMenu) menu;
+
+				Component[] menuItems = jMenu.getPopupMenu().getComponents();
+				for (int i = 0; i < menuItems.length; i++) {
+
+					if (menuItems[i] instanceof JMenuItem) {
+						JMenuItem jMenuItem = (JMenuItem) menuItems[i];
+
+						if (removeActions.contains(jMenuItem.getAction())) {
+							jMenu.remove(jMenuItem);
+
+							// this algorithm is pretty lame, but it works for
+							// the current (as of 08.2010) menu layout
+							if (i > 0
+									&& i == menuItems.length - 1
+									&& menuItems[i - 1] instanceof JPopupMenu.Separator) {
+								jMenu.remove(i - 1);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	class MacEventsAdapter extends ApplicationAdapter {
+
+		public void handleAbout(ApplicationEvent e) {
+			if (!e.isHandled()) {
+				actionManager.getAction(AboutAction.class).showAboutDialog();
+				e.setHandled(true);
+			}
+		}
+
+		public void handlePreferences(ApplicationEvent e) {
+			actionManager.getAction(ConfigurePreferencesAction.class)
+					.showPreferencesDialog();
+			e.setHandled(true);
+		}
+
+		public void handleQuit(ApplicationEvent e) {
+			if (!e.isHandled()) {
+				e.setHandled(true);
+				actionManager.getAction(ExitAction.class).exit();
+			}
+		}
+	}
+}

Modified: cayenne/main/trunk/modeler/cayenne-modeler-mac/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler-mac/pom.xml?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler-mac/pom.xml (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler-mac/pom.xml Tue Aug 24 13:34:35 2010
@@ -85,7 +85,7 @@
 					<name>CayenneModeler</name>
 					<longName>${version}</longName>
 					<destDir>target/modeler</destDir>
-					<mainClass>org.apache.cayenne.modeler.MacOSXMain</mainClass>
+					<mainClass>org.apache.cayenne.modeler.OSXMain</mainClass>
 					<icon>src/japplication/resources/CayenneModeler.icns</icon>
 					<os>mac</os>
 					<jvm>1.5+</jvm>



Mime
View raw message