cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r988538 [1/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
Author: aadamchik
Date: Tue Aug 24 13:34:35 2010
New Revision: 988538

URL: http://svn.apache.org/viewvc?rev=988538&view=rev
Log:
CAY-1474 Straightening CayenneModeler platform-specific builds

* removing unused modeler.sh
* removing modeler.log creation code. Modeler hasn't been logging to this file since 3.0
* removing Java version check... The code is compiled with Java 1.5 setttings, so that code is a complete noop

* starting Modeler via Injector
* Switching ActionManager to DI, implementing type-safe action lookup
* DI based Launcher and PlatformInitializer services
* Mac-based assembly does the right thing

Added:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ActionManager.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
      - copied, changed from r988535, 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/init/
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/CayenneModelerModule.java
      - copied, changed from r988535, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/platform/
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/platform/GenericPlatformInitializer.java
      - copied, changed from r988535, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/platform/PlatformInitializer.java
      - copied, changed from r988535, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/OSXMain.java
      - copied, changed from r988535, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/OSXCayenneModelerModule.java
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/platform/
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/init/platform/OSXPlatformInitializer.java
Removed:
    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/action/package.html
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/bin/
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/MacOSXMain.java
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/src/main/java/org/apache/cayenne/modeler/MacOSXSetup.java
Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.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/Main.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.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/ProjectWatchdog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/WelcomeScreen.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/CutAction.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/CutProcedureParameterAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutRelationshipAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExitAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportEOModelAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RevertAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ConfirmRemoveDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/GeneratorController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/pref/GeneralPreferences.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/ValidatorDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapCallbackListenersTab.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/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/editor/ObjEntityAttributeTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackListenersTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityRelationshipTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.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/editor/ProcedureParameterTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTabbedView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityAttributeTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityRelationshipTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTabbedView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/BaseGraphBuilder.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoManager.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateAttributeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapEntityListenerUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDbEntityUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbAttributeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbeddableUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEntityListenerUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateObjEntityUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/RecentFileMenu.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/UpgradeCayennePreference.java
    cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
    cayenne/main/trunk/modeler/cayenne-modeler-mac-ext/pom.xml
    cayenne/main/trunk/modeler/cayenne-modeler-mac/pom.xml

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java Tue Aug 24 13:34:35 2010
@@ -33,19 +33,16 @@ import javax.swing.JRootPane;
 import javax.swing.SwingUtilities;
 
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.server.ServerModule;
-import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.di.Module;
+import org.apache.cayenne.modeler.action.ActionManager;
 import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.dialog.pref.ClasspathPreferences;
 import org.apache.cayenne.modeler.undo.CayenneUndoManager;
 import org.apache.cayenne.modeler.util.AdapterMapping;
-import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.CayenneDialog;
 import org.apache.cayenne.pref.CayennePreference;
 import org.apache.cayenne.pref.CayenneProjectPreferences;
-import org.apache.cayenne.project.CayenneProjectModule;
 import org.apache.cayenne.project.Project;
 import org.apache.cayenne.swing.BindingFactory;
 import org.apache.cayenne.util.IDUtil;
@@ -72,13 +69,12 @@ public class Application {
     public static final String APPLICATION_NAME_PROPERTY = "cayenne.modeler.application.name";
     public static final String DEFAULT_APPLICATION_NAME = "CayenneModeler";
 
-    protected static Application instance;
+    private static Application instance;
 
     protected FileClassLoadingService modelerClassLoader;
-    protected ActionManager actionManager;
+
     protected CayenneModelerController frameController;
 
-    protected File initialProject;
     protected String name;
 
     protected BindingFactory bindingFactory;
@@ -88,11 +84,9 @@ public class Application {
 
     protected CayenneProjectPreferences cayenneProjectPreferences;
 
-    // This is for OS X support
-    private boolean isQuittingApplication;
-
     protected CayennePreference cayennePreference;
 
+    @Inject
     protected Injector injector;
 
     private String newProjectTemporaryName;
@@ -101,6 +95,10 @@ public class Application {
         return instance;
     }
 
+    public static void setInstance(Application instance) {
+        Application.instance = instance;
+    }
+
     // static methods that should probably go away eventually...
     public static CayenneModelerFrame getFrame() {
         return (CayenneModelerFrame) getInstance().getFrameController().getView();
@@ -120,15 +118,7 @@ public class Application {
         return newProjectTemporaryName;
     }
 
-    public Application(File initialProject) {
-        this.initialProject = initialProject;
-
-        Module projectModule = new CayenneProjectModule();
-        Module serverModule = new ServerModule("CayenneModeler");
-
-        this.injector = DIBootstrap.createInjector(projectModule, serverModule);
-
-        // configure startup settings
+    public Application() {
         String configuredName = System.getProperty(APPLICATION_NAME_PROPERTY);
         this.name = (configuredName != null) ? configuredName : DEFAULT_APPLICATION_NAME;
         this.cayennePreference = new CayennePreference();
@@ -159,17 +149,10 @@ public class Application {
     }
 
     /**
-     * Returns an action for key.
-     */
-    public CayenneAction getAction(String key) {
-        return getActionManager().getAction(key);
-    }
-
-    /**
      * Returns action controller.
      */
     public ActionManager getActionManager() {
-        return actionManager;
+        return injector.getInstance(ActionManager.class);
     }
 
     /**
@@ -204,13 +187,9 @@ public class Application {
         UIStrings.setPropertiesName(ModelerConstants.DEFAULT_MESSAGE_BUNDLE);
         ViewContext.clearThreadContext();
 
-        // init actions before the frame, as it will attempt to build menus out of
-        // actions.
-        this.actionManager = new ActionManager(this);
-        this.undoManager = new org.apache.cayenne.modeler.undo.CayenneUndoManager(this);
+        this.undoManager = new CayenneUndoManager(this);
 
-        // ...create main frame
-        this.frameController = new CayenneModelerController(this, initialProject);
+        this.frameController = new CayenneModelerController(this);
 
         // update Scope to work nicely with main frame
         ViewContext.setGlobalContext(new ModelerContext(frameController.getFrame()));
@@ -218,9 +197,7 @@ public class Application {
         // open up
         frameController.startupAction();
 
-        /**
-         * After prefs have been loaded, we can now show the console if needed
-         */
+        // After prefs have been loaded, we can now show the console if needed
         LogConsole.getInstance().showConsoleIfNeeded();
         getFrame().setVisible(true);
     }
@@ -396,12 +373,4 @@ public class Application {
             return frame;
         }
     }
-
-    public boolean isQuittingApplication() {
-        return isQuittingApplication;
-    }
-
-    public void setQuittingApplication(boolean isQuittingApplication) {
-        this.isQuittingApplication = isQuittingApplication;
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java Tue Aug 24 13:34:35 2010
@@ -42,6 +42,7 @@ import org.apache.cayenne.modeler.action
 import org.apache.cayenne.modeler.action.OpenProjectAction;
 import org.apache.cayenne.modeler.dialog.validator.ValidatorDialog;
 import org.apache.cayenne.modeler.editor.EditorView;
+import org.apache.cayenne.modeler.init.platform.PlatformInitializer;
 import org.apache.cayenne.modeler.pref.ComponentGeometry;
 import org.apache.cayenne.modeler.pref.FSPath;
 import org.apache.cayenne.modeler.util.CayenneController;
@@ -59,13 +60,17 @@ public class CayenneModelerController ex
     protected ProjectController projectController;
 
     protected CayenneModelerFrame frame;
-    protected File initialProject;
 
-    public CayenneModelerController(Application application, File initialProject) {
+    public CayenneModelerController(Application application) {
         super(application);
 
-        this.initialProject = initialProject;
         this.frame = new CayenneModelerFrame(application.getActionManager());
+
+        application
+                .getInjector()
+                .getInstance(PlatformInitializer.class)
+                .setupMenus(frame);
+
         this.projectController = new ProjectController(this);
     }
 
@@ -99,8 +104,7 @@ public class CayenneModelerController ex
         frame.addWindowListener(new WindowAdapter() {
 
             public void windowClosing(WindowEvent e) {
-                ((ExitAction) getApplication().getAction(ExitAction.getActionName()))
-                        .exit();
+                getApplication().getActionManager().getAction(ExitAction.class).exit();
             }
         });
 
@@ -129,7 +133,7 @@ public class CayenneModelerController ex
         File transferFile = fileList.get(0);
 
         if (transferFile.isFile()) {
-            
+
             FileFilter filter = FileFilters.getApplicationFilter();
 
             if (filter.accept(transferFile)) {
@@ -137,10 +141,8 @@ public class CayenneModelerController ex
                         transferFile,
                         ActionEvent.ACTION_PERFORMED,
                         "OpenProject");
-                Application
-                        .getInstance()
-                        .getAction(OpenProjectAction.getActionName())
-                        .actionPerformed(e);
+                Application.getInstance().getActionManager().getAction(
+                        OpenProjectAction.class).actionPerformed(e);
                 return true;
             }
         }
@@ -151,13 +153,6 @@ public class CayenneModelerController ex
     public void startupAction() {
         initBindings();
         frame.setVisible(true);
-
-        // open project
-        if (initialProject != null) {
-            OpenProjectAction openAction = (OpenProjectAction) getApplication()
-                    .getAction(OpenProjectAction.getActionName());
-            openAction.openProject(initialProject);
-        }
     }
 
     public void projectModifiedAction() {

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=988538&r1=988537&r2=988538&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 Tue Aug 24 13:34:35 2010
@@ -32,6 +32,7 @@ import java.awt.event.KeyListener;
 import java.util.List;
 import java.util.Vector;
 
+import javax.swing.Action;
 import javax.swing.Box;
 import javax.swing.BoxLayout;
 import javax.swing.JCheckBoxMenuItem;
@@ -45,6 +46,7 @@ import javax.swing.JTextField;
 import javax.swing.JToolBar;
 
 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.CopyAction;
 import org.apache.cayenne.modeler.action.CreateDataMapAction;
@@ -99,9 +101,7 @@ import org.apache.cayenne.modeler.event.
 import org.apache.cayenne.modeler.event.QueryDisplayListener;
 import org.apache.cayenne.modeler.event.RecentFileListListener;
 import org.apache.cayenne.modeler.pref.ComponentGeometry;
-import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.ModelerUtil;
-import org.apache.cayenne.modeler.util.OperatingSystem;
 import org.apache.cayenne.modeler.util.RecentFileMenu;
 import org.apache.commons.logging.LogFactory;
 
@@ -165,8 +165,8 @@ public class CayenneModelerFrame extends
     /**
      * Returns an action object associated with the key.
      */
-    private CayenneAction getAction(String key) {
-        return actionManager.getAction(key);
+    private <T extends Action> T getAction(Class<T> type) {
+        return actionManager.getAction(type);
     }
 
     protected void initMenus() {
@@ -178,71 +178,66 @@ public class CayenneModelerFrame extends
         JMenu toolMenu = new JMenu("Tools");
         JMenu helpMenu = new JMenu("Help");
 
-        if (OperatingSystem.getOS() != OperatingSystem.MAC_OS_X) {
-            fileMenu.setMnemonic(KeyEvent.VK_F);
-            editMenu.setMnemonic(KeyEvent.VK_E);
-            projectMenu.setMnemonic(KeyEvent.VK_P);
-            toolMenu.setMnemonic(KeyEvent.VK_T);
-            helpMenu.setMnemonic(KeyEvent.VK_H);
-        }
-
-        fileMenu.add(getAction(NewProjectAction.getActionName()).buildMenu());
-        fileMenu.add(getAction(OpenProjectAction.getActionName()).buildMenu());
-        fileMenu.add(getAction(ProjectAction.getActionName()).buildMenu());
-        fileMenu.add(getAction(ImportDataMapAction.getActionName()).buildMenu());
+        fileMenu.setMnemonic(KeyEvent.VK_F);
+        editMenu.setMnemonic(KeyEvent.VK_E);
+        projectMenu.setMnemonic(KeyEvent.VK_P);
+        toolMenu.setMnemonic(KeyEvent.VK_T);
+        helpMenu.setMnemonic(KeyEvent.VK_H);
+
+        fileMenu.add(getAction(NewProjectAction.class).buildMenu());
+        fileMenu.add(getAction(OpenProjectAction.class).buildMenu());
+        fileMenu.add(getAction(ProjectAction.class).buildMenu());
+        fileMenu.add(getAction(ImportDataMapAction.class).buildMenu());
         fileMenu.addSeparator();
-        fileMenu.add(getAction(SaveAction.getActionName()).buildMenu());
-        fileMenu.add(getAction(SaveAsAction.getActionName()).buildMenu());
-        fileMenu.add(getAction(RevertAction.getActionName()).buildMenu());
+        fileMenu.add(getAction(SaveAction.class).buildMenu());
+        fileMenu.add(getAction(SaveAsAction.class).buildMenu());
+        fileMenu.add(getAction(RevertAction.class).buildMenu());
         fileMenu.addSeparator();
 
-        editMenu.add(getAction(UndoAction.getActionName()).buildMenu());
-        editMenu.add(getAction(RedoAction.getActionName()).buildMenu());
-        editMenu.add(getAction(CutAction.getActionName()).buildMenu());
-        editMenu.add(getAction(CopyAction.getActionName()).buildMenu());
-        editMenu.add(getAction(PasteAction.getActionName()).buildMenu());
+        editMenu.add(getAction(UndoAction.class).buildMenu());
+        editMenu.add(getAction(RedoAction.class).buildMenu());
+        editMenu.add(getAction(CutAction.class).buildMenu());
+        editMenu.add(getAction(CopyAction.class).buildMenu());
+        editMenu.add(getAction(PasteAction.class).buildMenu());
 
         recentFileMenu = new RecentFileMenu("Recent Projects");
         addRecentFileListListener(recentFileMenu);
         fileMenu.add(recentFileMenu);
 
-        // Mac OS X doesn't use File->Exit, it uses CayenneModeler->Quit (command-Q)
-        if (OperatingSystem.getOS() != OperatingSystem.MAC_OS_X) {
-            fileMenu.addSeparator();
-            fileMenu.add(getAction(ExitAction.getActionName()).buildMenu());
-        }
+        fileMenu.addSeparator();
+        fileMenu.add(getAction(ExitAction.class).buildMenu());
 
-        projectMenu.add(getAction(ValidateAction.getActionName()).buildMenu());
+        projectMenu.add(getAction(ValidateAction.class).buildMenu());
         projectMenu.addSeparator();
-        projectMenu.add(getAction(CreateNodeAction.getActionName()).buildMenu());
-        projectMenu.add(getAction(CreateDataMapAction.getActionName()).buildMenu());
+        projectMenu.add(getAction(CreateNodeAction.class).buildMenu());
+        projectMenu.add(getAction(CreateDataMapAction.class).buildMenu());
 
-        projectMenu.add(getAction(CreateObjEntityAction.getActionName()).buildMenu());
-        projectMenu.add(getAction(CreateEmbeddableAction.getActionName()).buildMenu());
-        projectMenu.add(getAction(CreateDbEntityAction.getActionName()).buildMenu());
+        projectMenu.add(getAction(CreateObjEntityAction.class).buildMenu());
+        projectMenu.add(getAction(CreateEmbeddableAction.class).buildMenu());
+        projectMenu.add(getAction(CreateDbEntityAction.class).buildMenu());
 
-        projectMenu.add(getAction(CreateProcedureAction.getActionName()).buildMenu());
-        projectMenu.add(getAction(CreateQueryAction.getActionName()).buildMenu());
+        projectMenu.add(getAction(CreateProcedureAction.class).buildMenu());
+        projectMenu.add(getAction(CreateQueryAction.class).buildMenu());
 
         projectMenu.addSeparator();
-        projectMenu.add(getAction(ObjEntitySyncAction.getActionName()).buildMenu());
+        projectMenu.add(getAction(ObjEntitySyncAction.class).buildMenu());
         projectMenu.addSeparator();
-        projectMenu.add(getAction(RemoveAction.getActionName()).buildMenu());
+        projectMenu.add(getAction(RemoveAction.class).buildMenu());
 
-        toolMenu.add(getAction(ImportDBAction.getActionName()).buildMenu());
-        toolMenu.add(getAction(InferRelationshipsAction.getActionName()).buildMenu());
-        toolMenu.add(getAction(ImportEOModelAction.getActionName()).buildMenu());
+        toolMenu.add(getAction(ImportDBAction.class).buildMenu());
+        toolMenu.add(getAction(InferRelationshipsAction.class).buildMenu());
+        toolMenu.add(getAction(ImportEOModelAction.class).buildMenu());
         toolMenu.addSeparator();
-        toolMenu.add(getAction(GenerateCodeAction.getActionName()).buildMenu());
-        toolMenu.add(getAction(GenerateDBAction.getActionName()).buildMenu());
-        toolMenu.add(getAction(MigrateAction.getActionName()).buildMenu());
+        toolMenu.add(getAction(GenerateCodeAction.class).buildMenu());
+        toolMenu.add(getAction(GenerateDBAction.class).buildMenu());
+        toolMenu.add(getAction(MigrateAction.class).buildMenu());
 
         /**
          * Menu for opening Log console
          */
         toolMenu.addSeparator();
 
-        logMenu = getAction(ShowLogConsoleAction.getActionName()).buildCheckBoxMenu();
+        logMenu = getAction(ShowLogConsoleAction.class).buildCheckBoxMenu();
 
         if (!LogConsole.getInstance().getConsoleProperty(LogConsole.DOCKED_PROPERTY)
                 && LogConsole.getInstance().getConsoleProperty(
@@ -255,18 +250,11 @@ public class CayenneModelerFrame extends
         updateLogConsoleMenu();
         toolMenu.add(logMenu);
 
-        // Mac OS X has it's own Preferences menu item under the application menu
-        if (OperatingSystem.getOS() != OperatingSystem.MAC_OS_X) {
-            toolMenu.addSeparator();
-            toolMenu.add(getAction(ConfigurePreferencesAction.getActionName())
-                    .buildMenu());
-        }
+        toolMenu.addSeparator();
+        toolMenu.add(getAction(ConfigurePreferencesAction.class).buildMenu());
 
-        // Mac OS X "About CayenneModeler" appears under the application menu, per Apple
-        // GUI standards
-        if (OperatingSystem.getOS() != OperatingSystem.MAC_OS_X)
-            helpMenu.add(getAction(AboutAction.getActionName()).buildMenu());
-        helpMenu.add(getAction(DocumentationAction.getActionName()).buildMenu());
+        helpMenu.add(getAction(AboutAction.class).buildMenu());
+        helpMenu.add(getAction(DocumentationAction.class).buildMenu());
 
         JMenuBar menuBar = new JMenuBar();
 
@@ -360,44 +348,44 @@ public class CayenneModelerFrame extends
     protected void initToolbar() {
         JToolBar toolBar = new JToolBar();
 
-        toolBar.add(getAction(NewProjectAction.getActionName()).buildButton());
-        toolBar.add(getAction(OpenProjectAction.getActionName()).buildButton());
-        toolBar.add(getAction(SaveAction.getActionName()).buildButton());
+        toolBar.add(getAction(NewProjectAction.class).buildButton());
+        toolBar.add(getAction(OpenProjectAction.class).buildButton());
+        toolBar.add(getAction(SaveAction.class).buildButton());
 
         toolBar.addSeparator();
-        toolBar.add(getAction(RemoveAction.getActionName()).buildButton());
+        toolBar.add(getAction(RemoveAction.class).buildButton());
 
         toolBar.addSeparator();
 
-        toolBar.add(getAction(CutAction.getActionName()).buildButton());
-        toolBar.add(getAction(CopyAction.getActionName()).buildButton());
-        toolBar.add(getAction(PasteAction.getActionName()).buildButton());
+        toolBar.add(getAction(CutAction.class).buildButton());
+        toolBar.add(getAction(CopyAction.class).buildButton());
+        toolBar.add(getAction(PasteAction.class).buildButton());
 
         toolBar.addSeparator();
 
-        toolBar.add(getAction(UndoAction.getActionName()).buildButton());
-        toolBar.add(getAction(RedoAction.getActionName()).buildButton());
+        toolBar.add(getAction(UndoAction.class).buildButton());
+        toolBar.add(getAction(RedoAction.class).buildButton());
 
         toolBar.addSeparator();
 
-        toolBar.add(getAction(CreateNodeAction.getActionName()).buildButton());
-        toolBar.add(getAction(CreateDataMapAction.getActionName()).buildButton());
+        toolBar.add(getAction(CreateNodeAction.class).buildButton());
+        toolBar.add(getAction(CreateDataMapAction.class).buildButton());
 
         toolBar.addSeparator();
 
-        toolBar.add(getAction(CreateDbEntityAction.getActionName()).buildButton());
-        toolBar.add(getAction(CreateProcedureAction.getActionName()).buildButton());
+        toolBar.add(getAction(CreateDbEntityAction.class).buildButton());
+        toolBar.add(getAction(CreateProcedureAction.class).buildButton());
 
         toolBar.addSeparator();
 
-        toolBar.add(getAction(CreateObjEntityAction.getActionName()).buildButton());
-        toolBar.add(getAction(CreateEmbeddableAction.getActionName()).buildButton());
-        toolBar.add(getAction(CreateQueryAction.getActionName()).buildButton());
+        toolBar.add(getAction(CreateObjEntityAction.class).buildButton());
+        toolBar.add(getAction(CreateEmbeddableAction.class).buildButton());
+        toolBar.add(getAction(CreateQueryAction.class).buildButton());
 
         toolBar.addSeparator();
 
-        toolBar.add(getAction(NavigateBackwardAction.getActionName()).buildButton());
-        toolBar.add(getAction(NavigateForwardAction.getActionName()).buildButton());
+        toolBar.add(getAction(NavigateBackwardAction.class).buildButton());
+        toolBar.add(getAction(NavigateForwardAction.class).buildButton());
 
         JPanel east = new JPanel(new BorderLayout()); // is used to place search feature
         // components the most right on a
@@ -418,7 +406,7 @@ public class CayenneModelerFrame extends
             }
 
         });
-        findField.setAction(getAction(FindAction.getActionName()));
+        findField.setAction(getAction(FindAction.class));
         JLabel findLabel = new JLabel("Search:");
         findLabel.setLabelFor(findField);
         Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@@ -439,7 +427,8 @@ public class CayenneModelerFrame extends
         },
                 AWTEvent.KEY_EVENT_MASK);
 
-        JPanel box = new JPanel(); // is used to place label and text field one after another
+        JPanel box = new JPanel(); // is used to place label and text field one after
+        // another
         box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
         box.add(findLabel);
         box.add(findField);
@@ -473,7 +462,9 @@ public class CayenneModelerFrame extends
         actionManager.procedureSelected();
     }
 
-    public void currentObjectsChanged(MultipleObjectsDisplayEvent e, Application application) {
+    public void currentObjectsChanged(
+            MultipleObjectsDisplayEvent e,
+            Application application) {
         actionManager.multipleObjectsSelected(e.getNodes(), application);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java Tue Aug 24 13:34:35 2010
@@ -20,284 +20,127 @@
 package org.apache.cayenne.modeler;
 
 import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.prefs.Preferences;
 
-import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
 
-import org.apache.cayenne.gen.ClassGenerationAction;
+import org.apache.cayenne.configuration.server.ServerModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Module;
 import org.apache.cayenne.modeler.action.OpenProjectAction;
 import org.apache.cayenne.modeler.dialog.pref.GeneralPreferences;
-import org.apache.cayenne.modeler.util.CayenneUserDir;
+import org.apache.cayenne.modeler.init.CayenneModelerModule;
+import org.apache.cayenne.modeler.init.platform.PlatformInitializer;
+import org.apache.cayenne.project.CayenneProjectModule;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import com.jgoodies.looks.plastic.PlasticLookAndFeel;
-import com.jgoodies.looks.plastic.PlasticTheme;
-
 /**
  * Main class responsible for starting CayenneModeler.
- * 
- * @since 1.1
  */
 public class Main {
 
     private static Log logger = LogFactory.getLog(Main.class);
 
+    protected String[] args;
+
     /**
      * Main method that starts the CayenneModeler.
      */
     public static void main(String[] args) {
-        Main main = new Main();
-
-        // if configured, redirect all logging to the log file
-        main.configureLogging();
-
-        // check jdk version
-        if (!main.checkJDKVersion()) {
+        try {
+            new Main(args).launch();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
             System.exit(1);
         }
-
-        File projectFile = projectFileFromArgs(args);
-        main.runModeler(projectFile);
     }
 
-    protected static File projectFileFromArgs(String[] args) {
-        if (args.length == 1) {
-            File f = new File(args[0]);
-
-            if (f.isFile()
-                    && f.getName().startsWith("cayenne")
-                    && f.getName().endsWith(".xml")) {
-                return f;
-            }
-        }
-
-        return null;
+    protected Main(String[] args) {
+        this.args = args;
     }
 
-    protected static File projectFileFromPrefs() {
-        // This must be run after the application has already been bootstrapped.
-        // Otherwise, the returned
-        // app instance will be null.
+    protected void launch() {
+        final Injector injector = DIBootstrap
+                .createInjector(appendModules(new ArrayList<Module>()));
 
-        Preferences autoLoadPref = Application.getInstance().getPreferencesNode(
-                ClassGenerationAction.class,
-                "");
-
-        if ((autoLoadPref != null)
-                && (true == autoLoadPref.getBoolean(
-                        GeneralPreferences.AUTO_LOAD_PROJECT_PREFERENCE,
-                        false))) {
-
-            List<String> arr = ModelerPreferences.getLastProjFiles();
-            if (arr.size() > 0) {
-                return new File((String) arr.get(0));
-            }
-        }
-        return null;
-    }
-
-    protected void runModeler(final File projectFile) {
         logger.info("Starting CayenneModeler.");
+        logger.info("JRE v."
+                + System.getProperty("java.version")
+                + " at "
+                + System.getProperty("java.home"));
 
-        // set up UI
-        configureLookAndFeel();
+        // init look and feel before starting any Swing classes...
+        injector.getInstance(PlatformInitializer.class).initLookAndFeel();
 
-        Application.instance = new Application(projectFile);
-
-        // start frame and load project from EventDispatchThread...
-        Runnable runnable = new Runnable() {
+        SwingUtilities.invokeLater(new Runnable() {
 
             public void run() {
-                Application.instance.startup();
 
-                if (null == projectFile) {
-                    File projectFileFromPrefs = projectFileFromPrefs();
+                Application application = injector.getInstance(Application.class);
+                Application.setInstance(application);
+                application.startup();
+
+                // start initial project AFTER the app startup, as we need Application
+                // preferences to be bootstrapped.
+
+                File project = initialProjectFromArgs();
+                if (project == null) {
+                    project = initialProjectFromPreferences();
+                }
 
-                    if (null != projectFileFromPrefs) {
-                        OpenProjectAction action = new OpenProjectAction(
-                                Application.instance);
-                        action.openProject(projectFileFromPrefs);
-                    }
+                if (project != null) {
+                    new OpenProjectAction(application).openProject(project);
                 }
             }
-        };
+        });
 
-        SwingUtilities.invokeLater(runnable);
     }
 
-    protected boolean checkJDKVersion() {
-        try {
-            Class.forName("java.lang.StringBuilder");
-            return true;
-        }
-        catch (Exception ex) {
-            logger.fatal("CayenneModeler requires JDK 1.5.");
-            logger.fatal("Found : '"
-                    + System.getProperty("java.version")
-                    + "' at "
-                    + System.getProperty("java.home"));
-
-            JOptionPane.showMessageDialog(
-                    null,
-                    "Unsupported JDK at "
-                            + System.getProperty("java.home")
-                            + ". Set JAVA_HOME to the JDK1.5 location.",
-                    "Unsupported JDK Version",
-                    JOptionPane.ERROR_MESSAGE);
-            return false;
-        }
+    protected Collection<Module> appendModules(Collection<Module> modules) {
+        modules.add(new ServerModule("CayenneModeler"));
+        modules.add(new CayenneProjectModule());
+        modules.add(new CayenneModelerModule());
+
+        return modules;
     }
 
-    /**
-     * Configures Log4J appenders to perform logging to $HOME/.cayenne/modeler.log.
-     */
-    protected void configureLogging() {
+    protected File initialProjectFromPreferences() {
 
-        // get preferences
-        Preferences prefs = ModelerPreferences.getEditorPreferences();
+        Preferences autoLoadLastProject = Application.getInstance().getPreferencesNode(
+                GeneralPreferences.class,
+                "");
 
-        // check whether to set up logging to a file
-        boolean logfileEnabled = prefs.getBoolean(
-                ModelerPreferences.EDITOR_LOGFILE_ENABLED,
-                true);
-        prefs.put(ModelerPreferences.EDITOR_LOGFILE_ENABLED, String
-                .valueOf(logfileEnabled));
-
-        if (logfileEnabled) {
-            String defaultPath = getLogFile().getPath();
-            String logfilePath = prefs
-                    .get(ModelerPreferences.EDITOR_LOGFILE, defaultPath);
-            try {
-                // use logfile from preferences or default
-
-                File logfile = new File(logfilePath);
-
-                if (logfile != null) {
-                    if (!logfile.exists()) {
-                        // create dir path first
-                        File parent = logfile.getParentFile();
-                        if (parent != null) {
-                            parent.mkdirs();
-                        }
-
-                        if (!logfile.createNewFile()) {
-                            return;
-                        }
-                    }
+        if ((autoLoadLastProject != null)
+                && autoLoadLastProject.getBoolean(
+                        GeneralPreferences.AUTO_LOAD_PROJECT_PREFERENCE,
+                        false)) {
 
-                    // remember working path
-                    prefs.put(ModelerPreferences.EDITOR_LOGFILE, logfilePath);
-                }
-            }
-            catch (IOException ioex) {
-                logger.warn("Error setting logging - " + logfilePath, ioex);
+            List<String> lastFiles = ModelerPreferences.getLastProjFiles();
+            if (!lastFiles.isEmpty()) {
+                return new File(lastFiles.get(0));
             }
         }
-    }
 
-    protected String getLookAndFeelName() {
-        Preferences prefs = ModelerPreferences.getEditorPreferences();
-        return prefs.get(
-                ModelerPreferences.EDITOR_LAFNAME,
-                ModelerConstants.DEFAULT_LAF_NAME);
-    }
-
-    protected String getThemeName() {
-        Preferences prefs = ModelerPreferences.getEditorPreferences();
-        return prefs.get(
-                ModelerPreferences.EDITOR_THEMENAME,
-                ModelerConstants.DEFAULT_THEME_NAME);
+        return null;
     }
 
-    /**
-     * Set up the UI Look & Feel according to $HOME/.cayenne/modeler.preferences
-     */
-    protected void configureLookAndFeel() {
-        // get preferences
-        Preferences prefs = ModelerPreferences.getEditorPreferences();
-        String lfName = getLookAndFeelName();
-        String themeName = getThemeName();
-
-        try {
-            // only install theme if L&F is Plastic;
-            // bomb out if the L&F class cannot be found at all.
-            Class lf = Class.forName(lfName);
-            if (PlasticLookAndFeel.class.isAssignableFrom(lf)) {
-                PlasticTheme foundTheme = themeWithName(themeName);
-                if (foundTheme == null) {
-                    logger.warn("Could not set selected theme '"
-                            + themeName
-                            + "' - using default '"
-                            + ModelerConstants.DEFAULT_THEME_NAME
-                            + "'.");
-
-                    themeName = ModelerConstants.DEFAULT_THEME_NAME;
-                    foundTheme = themeWithName(themeName);
-                }
-
-                // try to configure theme
-                PlasticLookAndFeel.setMyCurrentTheme(foundTheme);
-            }
-
-            // try to set set L&F
-            UIManager.setLookAndFeel(lfName);
-        }
-        catch (Exception e) {
-            logger.warn("Could not set selected LookAndFeel '"
-                    + lfName
-                    + "' - using default '"
-                    + ModelerConstants.DEFAULT_LAF_NAME
-                    + "'.");
-
-            // re-try with defaults
-            lfName = ModelerConstants.DEFAULT_LAF_NAME;
-            themeName = ModelerConstants.DEFAULT_THEME_NAME;
-            PlasticTheme defaultTheme = themeWithName(themeName);
-            PlasticLookAndFeel.setMyCurrentTheme(defaultTheme);
+    protected File initialProjectFromArgs() {
+        if (args != null && args.length == 1) {
+            File f = new File(args[0]);
 
-            try {
-                UIManager.setLookAndFeel(lfName);
-            }
-            catch (Exception retry) {
-                // give up, continue as-is
+            if (f.isFile()
+                    && f.getName().startsWith("cayenne")
+                    && f.getName().endsWith(".xml")) {
+                return f;
             }
         }
-        finally {
-            // remember L&F settings
-            prefs.put(ModelerPreferences.EDITOR_LAFNAME, UIManager
-                    .getLookAndFeel()
-                    .getClass()
-                    .getName());
-
-            prefs.put(ModelerPreferences.EDITOR_THEMENAME, themeName);
-        }
-    }
 
-    protected PlasticTheme themeWithName(String themeName) {
-        List availableThemes = PlasticLookAndFeel.getInstalledThemes();
-        for (Iterator i = availableThemes.iterator(); i.hasNext();) {
-            PlasticTheme aTheme = (PlasticTheme) i.next();
-            if (themeName.equals(aTheme.getName())) {
-                return aTheme;
-            }
-        }
         return null;
     }
-
-    /**
-     * Returns a file corresponding to $HOME/.cayenne/modeler.log
-     */
-    protected File getLogFile() {
-        if (!CayenneUserDir.getInstance().canWrite()) {
-            return null;
-        }
-
-        return CayenneUserDir.getInstance().resolveFile("modeler.log");
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java Tue Aug 24 13:34:35 2010
@@ -51,10 +51,6 @@ public class ModelerPreferences implemen
     /** List of the last 12 opened project files. */
     public static final int LAST_PROJ_FILES_SIZE = 12;
 
-    /** GUI layout */
-    public static final String EDITOR_LAFNAME = "lookAndFeel";
-    public static final String EDITOR_THEMENAME = "theme";
-
     /** Log file */
     public static final String EDITOR_LOGFILE_ENABLED = "logfileEnabled";
     public static final String EDITOR_LOGFILE = "logfile";

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=988538&r1=988537&r2=988538&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 Tue Aug 24 13:34:35 2010
@@ -1661,8 +1661,11 @@ public class ProjectController extends C
         if (this.dirty != dirty) {
             this.dirty = dirty;
 
-            application.getAction(SaveAction.getActionName()).setEnabled(dirty);
-            application.getAction(RevertAction.getActionName()).setEnabled(dirty);
+            application.getActionManager().getAction(SaveAction.class).setEnabled(dirty);
+            application
+                    .getActionManager()
+                    .getAction(RevertAction.class)
+                    .setEnabled(dirty);
 
             if (dirty) {
                 ((CayenneModelerController) getParent()).projectModifiedAction();
@@ -1671,7 +1674,7 @@ public class ProjectController extends C
     }
 
     /**
-     * @return currently selecte entity listener class
+     * @return currently selected entity listener class
      */
     public String getCurrentListenerClass() {
         return currentState.listenerClass;

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=988538&r1=988537&r2=988538&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 Tue Aug 24 13:34:35 2010
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 
+import javax.swing.Action;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
 import javax.swing.JTree;
@@ -88,6 +89,7 @@ import org.apache.cayenne.modeler.event.
 import org.apache.cayenne.modeler.event.ProcedureDisplayListener;
 import org.apache.cayenne.modeler.event.QueryDisplayEvent;
 import org.apache.cayenne.modeler.event.QueryDisplayListener;
+import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.CellRenderers;
 import org.apache.cayenne.modeler.util.Comparators;
 import org.apache.cayenne.project.Project;
@@ -183,10 +185,10 @@ public class ProjectTreeView extends JTr
         mediator.addQueryListener(this);
         mediator.addQueryDisplayListener(this);
 
-        mediator.getApplication().getActionManager().setupCCP(
+        mediator.getApplication().getActionManager().setupCutCopyPaste(
                 this,
-                CutAction.getActionName(),
-                CopyAction.getActionName());
+                CutAction.class,
+                CopyAction.class);
     }
 
     private void initFromModel(Project project) {
@@ -927,23 +929,23 @@ public class ProjectTreeView extends JTr
     private JPopupMenu createJPopupMenu() {
         JPopupMenu popup = new JPopupMenu();
 
-        popup.add(buildMenu(CreateNodeAction.getActionName()));
-        popup.add(buildMenu(CreateDataMapAction.getActionName()));
+        popup.add(buildMenu(CreateNodeAction.class));
+        popup.add(buildMenu(CreateDataMapAction.class));
 
-        popup.add(buildMenu(CreateObjEntityAction.getActionName()));
-        popup.add(buildMenu(CreateEmbeddableAction.getActionName()));
-        popup.add(buildMenu(CreateDbEntityAction.getActionName()));
+        popup.add(buildMenu(CreateObjEntityAction.class));
+        popup.add(buildMenu(CreateEmbeddableAction.class));
+        popup.add(buildMenu(CreateDbEntityAction.class));
 
-        popup.add(buildMenu(CreateProcedureAction.getActionName()));
-        popup.add(buildMenu(CreateQueryAction.getActionName()));
+        popup.add(buildMenu(CreateProcedureAction.class));
+        popup.add(buildMenu(CreateQueryAction.class));
         popup.addSeparator();
-        popup.add(buildMenu(ObjEntitySyncAction.getActionName()));
+        popup.add(buildMenu(ObjEntitySyncAction.class));
         popup.addSeparator();
-        popup.add(buildMenu(RemoveAction.getActionName()));
+        popup.add(buildMenu(RemoveAction.class));
         popup.addSeparator();
-        popup.add(buildMenu(CutAction.getActionName()));
-        popup.add(buildMenu(CopyAction.getActionName()));
-        popup.add(buildMenu(PasteAction.getActionName()));
+        popup.add(buildMenu(CutAction.class));
+        popup.add(buildMenu(CopyAction.class));
+        popup.add(buildMenu(PasteAction.class));
 
         return popup;
     }
@@ -953,8 +955,12 @@ public class ProjectTreeView extends JTr
      * 
      * @param key action key
      */
-    private JMenuItem buildMenu(String key) {
-        return mediator.getApplication().getAction(key).buildMenu();
+    private JMenuItem buildMenu(Class<? extends Action> actionType) {
+        CayenneAction action = (CayenneAction) mediator
+                .getApplication()
+                .getActionManager()
+                .getAction(actionType);
+        return action.buildMenu();
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectWatchdog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectWatchdog.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectWatchdog.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectWatchdog.java Tue Aug 24 13:34:35 2010
@@ -66,15 +66,18 @@ public class ProjectWatchdog extends Fil
         if (project != null // project opened
                 && project.getConfigurationResource() != null) // not new project
         {
-            String projectPath = project.getConfigurationResource().getURL().getPath() + File.separator;
+            String projectPath = project.getConfigurationResource().getURL().getPath()
+                    + File.separator;
             addFile(projectPath);
 
-            Iterator<DataMap> it = ((DataChannelDescriptor)project.getRootNode()).getDataMaps().iterator();
+            Iterator<DataMap> it = ((DataChannelDescriptor) project.getRootNode())
+                    .getDataMaps()
+                    .iterator();
             while (it.hasNext()) {
                 DataMap dm = it.next();
                 addFile(dm.getConfigurationSource().getURL().getPath());
             }
-            
+
         }
 
         resumeWatching();
@@ -84,14 +87,17 @@ public class ProjectWatchdog extends Fil
     protected void doOnChange(FileInfo fileInfo) {
         if (showConfirmation("One or more project files were changed by external program. "
                 + "Do you want to load the changes?")) {
-            /**
-             * Currently we are reloading all project
-             */
+
+            // Currently we are reloading all project
             if (mediator.getProject() != null) {
-                
-                File fileDirectory = new File(mediator.getProject().getConfigurationResource().getURL().getPath());
-                ((OpenProjectAction) Application.getInstance().getAction(
-                        OpenProjectAction.getActionName())).openProject(fileDirectory);
+
+                File fileDirectory = new File(mediator
+                        .getProject()
+                        .getConfigurationResource()
+                        .getURL()
+                        .getPath());
+                Application.getInstance().getActionManager().getAction(
+                        OpenProjectAction.class).openProject(fileDirectory);
             }
 
         }
@@ -101,15 +107,15 @@ public class ProjectWatchdog extends Fil
 
     @Override
     protected void doOnRemove(FileInfo fileInfo) {
-        if (mediator.getProject() != null
-                /*&& fileInfo.getFile().equals(mediator.getProject().getMainFile()) */ ) {
+        if (mediator.getProject() != null) {
             FileDeletedDialog dialog = new FileDeletedDialog(Application.getFrame());
             dialog.show();
 
             if (dialog.shouldSave()) {
                 Application
                         .getInstance()
-                        .getAction(SaveAction.getActionName())
+                        .getActionManager()
+                        .getAction(SaveAction.class)
                         .performAction(null);
             }
             else if (dialog.shouldClose()) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/WelcomeScreen.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/WelcomeScreen.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/WelcomeScreen.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/WelcomeScreen.java Tue Aug 24 13:34:35 2010
@@ -50,8 +50,8 @@ import org.apache.cayenne.modeler.event.
 import org.apache.cayenne.modeler.util.ModelerUtil;
 
 /**
- * Welcome screen (CAY-894) is a panel shown when no project is open.
- * User can quickly create new project or open an existing one.
+ * Welcome screen (CAY-894) is a panel shown when no project is open. User can quickly
+ * create new project or open an existing one.
  */
 public class WelcomeScreen extends JPanel implements RecentFileListListener {
 
@@ -64,7 +64,7 @@ public class WelcomeScreen extends JPane
      * Bottom color of gradient background
      */
     private static final Color BOTTOM_GRADIENT = new Color(230, 230, 230);
-    
+
     /**
      * List of recent projects
      */
@@ -94,14 +94,24 @@ public class WelcomeScreen extends JPane
         buttonsPane.setOpaque(false);
 
         JButton newButton = createButton(newOutIcon, newOverIcon);
-        newButton.addActionListener(Application.getInstance().getAction(NewProjectAction.getActionName()));
-        
-        JLabel newLabel = new JLabel(NewProjectAction.getActionName(), SwingConstants.CENTER);
+        newButton.addActionListener(Application
+                .getInstance()
+                .getActionManager()
+                .getAction(NewProjectAction.class));
+
+        JLabel newLabel = new JLabel(
+                NewProjectAction.getActionName(),
+                SwingConstants.CENTER);
 
         JButton openButton = createButton(openOutIcon, openOverIcon);
-        openButton.addActionListener(Application.getInstance().getAction(OpenProjectAction.getActionName()));
-        
-        JLabel openLabel = new JLabel(OpenProjectAction.getActionName(), SwingConstants.CENTER);
+        openButton.addActionListener(Application
+                .getInstance()
+                .getActionManager()
+                .getAction(OpenProjectAction.class));
+
+        JLabel openLabel = new JLabel(
+                OpenProjectAction.getActionName(),
+                SwingConstants.CENTER);
 
         imageLabel.setLayout(new BorderLayout());
 
@@ -109,8 +119,10 @@ public class WelcomeScreen extends JPane
         buttonsPane.add(newButton);
 
         newLabel.setLocation(newButton.getX()
-                + newButton.getWidth() / 2 - newLabel.getPreferredSize().width / 2, 
-                newButton.getY() + newButton.getHeight());
+                + newButton.getWidth()
+                / 2
+                - newLabel.getPreferredSize().width
+                / 2, newButton.getY() + newButton.getHeight());
         newLabel.setSize(newLabel.getPreferredSize());
         buttonsPane.add(newLabel);
 
@@ -118,27 +130,30 @@ public class WelcomeScreen extends JPane
         buttonsPane.add(openButton);
 
         openLabel.setLocation(openButton.getX()
-                + openButton.getWidth() / 2 - openLabel.getPreferredSize().width / 2, 
-                openButton.getY() + openButton.getHeight());
+                + openButton.getWidth()
+                / 2
+                - openLabel.getPreferredSize().width
+                / 2, openButton.getY() + openButton.getHeight());
         openLabel.setSize(openLabel.getPreferredSize());
         buttonsPane.add(openLabel);
-        
+
         JLabel recents = new JLabel("Recent Projects:");
         recents.setLocation(207, newButton.getY());
         recents.setSize(recents.getPreferredSize());
         recents.setHorizontalTextPosition(10);
-        
+
         buttonsPane.add(recents);
-        
+
         recentsList = new JList();
         recentsList.setOpaque(false);
-        
+
         recentsList.setLocation(recents.getX(), recents.getY() + 2 * recents.getHeight());
-        recentsList.setSize(welcome.getIconWidth() - recentsList.getX() - 1, 
-                welcome.getIconHeight() - recentsList.getY());
-        
+        recentsList.setSize(welcome.getIconWidth() - recentsList.getX() - 1, welcome
+                .getIconHeight()
+                - recentsList.getY());
+
         recentsList.setCellRenderer(new RecentFileListRenderer(recentsList));
-        
+
         buttonsPane.add(recentsList);
 
         imageLabel.add(buttonsPane);
@@ -173,7 +188,8 @@ public class WelcomeScreen extends JPane
     @Override
     public void paintComponent(Graphics g) {
         Graphics2D g2 = (Graphics2D) g.create();
-        g2.setPaint(new GradientPaint(
+        g2
+                .setPaint(new GradientPaint(
                         0,
                         0,
                         TOP_GRADIENT,
@@ -184,53 +200,60 @@ public class WelcomeScreen extends JPane
 
         g2.dispose();
     }
-    
+
     public void recentFileListChanged() {
 
         final List<String> arr = ModelerPreferences.getLastProjFiles();
-        
-        recentsList.setModel(
-            new AbstractListModel() {
-                public int getSize() { return arr.size(); }
-                public Object getElementAt(int i) { return arr.get(i); }
-            });
+
+        recentsList.setModel(new AbstractListModel() {
+
+            public int getSize() {
+                return arr.size();
+            }
+
+            public Object getElementAt(int i) {
+                return arr.get(i);
+            }
+        });
     }
-    
+
     /**
-     * Renderer for the list of last files. Ignores the selection, instead paints
-     * with ROLLOVER_BACKGROUND (currently red) the row mouse is hovering over
+     * Renderer for the list of last files. Ignores the selection, instead paints with
+     * ROLLOVER_BACKGROUND (currently red) the row mouse is hovering over
      */
-    class RecentFileListRenderer extends DefaultListCellRenderer implements MouseInputListener {
+    class RecentFileListRenderer extends DefaultListCellRenderer implements
+            MouseInputListener {
+
         /**
          * Color for background of row mouse is over
          */
         final Color ROLLOVER_BACKGROUND = Color.RED;
-        
+
         /**
          * Color for foreground of row mouse is over
          */
         final Color ROLLOVER_FOREGROUND = Color.WHITE;
-        
+
         /**
          * List which is rendered
          */
         private JList list;
-        
+
         /**
          * Row mouse is over
          */
         private int rolloverRow;
-        
+
         public RecentFileListRenderer(JList list) {
             list.addMouseListener(this);
             list.addMouseMotionListener(this);
-            
+
             this.list = list;
             rolloverRow = -1;
-            
+
             setHorizontalTextPosition(10);
         }
-        
+
         @Override
         public Component getListCellRendererComponent(
                 JList list,
@@ -238,9 +261,9 @@ public class WelcomeScreen extends JPane
                 int index,
                 boolean isSelected,
                 boolean cellHasFocus) {
-            //selection is ignored
+            // selection is ignored
             super.getListCellRendererComponent(list, value, index, false, false);
-            
+
             if (rolloverRow == index) {
                 setOpaque(true);
                 setForeground(ROLLOVER_FOREGROUND);
@@ -249,7 +272,7 @@ public class WelcomeScreen extends JPane
             else {
                 setOpaque(false);
             }
-            
+
             return this;
         }
 
@@ -271,14 +294,15 @@ public class WelcomeScreen extends JPane
         public void mouseReleased(MouseEvent e) {
             if (SwingUtilities.isLeftMouseButton(e) && rolloverRow != -1) {
                 File file = new File((String) list.getModel().getElementAt(rolloverRow));
-                
+
                 /**
                  * Fire an action with the file as source
                  */
-                Application.getInstance().getAction(OpenProjectAction.getActionName()).performAction(
+                Application.getInstance().getActionManager().getAction(
+                        OpenProjectAction.class).performAction(
                         new ActionEvent(file, 0, null));
-                
-                rolloverRow = -1; //clear selection
+
+                rolloverRow = -1; // clear selection
             }
         }
 
@@ -287,19 +311,20 @@ public class WelcomeScreen extends JPane
 
         public void mouseMoved(MouseEvent e) {
             int newRow;
-            
+
             /**
-             * Check that a row boundary contains the mouse point, so that rolloverRow would
-             * be -1 if we are below last row
+             * Check that a row boundary contains the mouse point, so that rolloverRow
+             * would be -1 if we are below last row
              */
-            if (list.getModel().getSize() > 0 && 
-                    !list.getCellBounds(0, list.getModel().getSize() - 1).contains(e.getPoint())) {
+            if (list.getModel().getSize() > 0
+                    && !list.getCellBounds(0, list.getModel().getSize() - 1).contains(
+                            e.getPoint())) {
                 newRow = -1;
             }
             else {
-                newRow = list.locationToIndex(e.getPoint()); 
+                newRow = list.locationToIndex(e.getPoint());
             }
-            
+
             if (rolloverRow != newRow) {
                 rolloverRow = newRow;
                 list.repaint();

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ActionManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ActionManager.java?rev=988538&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ActionManager.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ActionManager.java Tue Aug 24 13:34:35 2010
@@ -0,0 +1,78 @@
+/*****************************************************************
+ *   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 javax.swing.Action;
+import javax.swing.JComponent;
+
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.modeler.Application;
+
+/**
+ * Stores a map of modeler actions, and deals with activating/deactivating those actions
+ * on state changes.
+ */
+public interface ActionManager {
+
+    /**
+     * Returns an action for key.
+     */
+    <T extends Action> T getAction(Class<T> actionClass);
+
+    /**
+     * Updates actions state to reflect an open project.
+     */
+    void projectOpened();
+
+    void projectClosed();
+
+    /**
+     * Updates actions state to reflect DataDomain selection.
+     */
+    void domainSelected();
+
+    void dataNodeSelected();
+
+    void dataMapSelected();
+
+    void objEntitySelected();
+
+    void dbEntitySelected();
+
+    void procedureSelected();
+
+    void querySelected();
+
+    void embeddableSelected();
+
+    /**
+     * Invoked when several objects were selected in ProjectTree at time
+     */
+    void multipleObjectsSelected(ConfigurationNode[] objects, Application application);
+
+    /**
+     * Replaces standard Cut, Copy and Paste action maps, so that accelerators like
+     * Ctrl+X, Ctrl+C, Ctrl+V would work.
+     */
+    void setupCutCopyPaste(
+            JComponent comp,
+            Class<? extends Action> cutActionType,
+            Class<? extends Action> copyActionType);
+}

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=988538&r1=988537&r2=988538&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 Tue Aug 24 13:34:35 2010
@@ -49,6 +49,7 @@ import org.apache.cayenne.util.XMLSerial
  * Action for copying entities, queries etc. into system buffer
  */
 public class CopyAction extends CayenneAction {
+
     public static String getActionName() {
         return "Copy";
     }
@@ -59,7 +60,7 @@ public class CopyAction extends CayenneA
     public CopyAction(Application application) {
         this(getActionName(), application);
     }
-    
+
     /**
      * Constructor for descendants
      */
@@ -71,10 +72,12 @@ public class CopyAction extends CayenneA
     public String getIconName() {
         return "icon-copy.gif";
     }
-    
+
     @Override
     public KeyStroke getAcceleratorKey() {
-        return KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+        return KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit
+                .getDefaultToolkit()
+                .getMenuShortcutKeyMask());
     }
 
     /**
@@ -83,32 +86,32 @@ public class CopyAction extends CayenneA
     @Override
     public void performAction(ActionEvent e) {
         ProjectController mediator = getProjectController();
-        
+
         Object content = copy(mediator);
-        
+
         if (content != null) {
             Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
             sysClip.setContents(new CayenneTransferable(content), null);
         }
-        
-        //update paste button
-        ((PasteAction) getApplication().getAction(PasteAction.getActionName())).updateState();
+
+        // update paste button
+        getApplication().getActionManager().getAction(PasteAction.class).updateState();
     }
-    
+
     /**
      * Detects selected objects and returns them
      */
     public Object copy(ProjectController mediator) {
         return mediator.getCurrentObject();
     }
-    
+
     /**
      * Prints an object in XML format to an output stream
      */
     protected void print(XMLEncoder encoder, XMLSerializable object) {
         object.encodeAsXML(encoder);
     }
-    
+
     /**
      * Returns <code>true</code> if last object in the path contains a removable object.
      */
@@ -117,13 +120,19 @@ public class CopyAction extends CayenneA
         if (object == null) {
             return false;
         }
-        
-        if (object instanceof DataMap || object instanceof Query
-                || object instanceof DbEntity || object instanceof ObjEntity
-                || object instanceof Embeddable || object instanceof EmbeddableAttribute
-                || object instanceof DbAttribute || object instanceof DbRelationship
-                || object instanceof ObjAttribute || object instanceof ObjRelationship
-                || object instanceof Procedure || object instanceof ProcedureParameter) {
+
+        if (object instanceof DataMap
+                || object instanceof Query
+                || object instanceof DbEntity
+                || object instanceof ObjEntity
+                || object instanceof Embeddable
+                || object instanceof EmbeddableAttribute
+                || object instanceof DbAttribute
+                || object instanceof DbRelationship
+                || object instanceof ObjAttribute
+                || object instanceof ObjRelationship
+                || object instanceof Procedure
+                || object instanceof ProcedureParameter) {
             return true;
         }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAction.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutAction.java Tue Aug 24 13:34:35 2010
@@ -68,9 +68,10 @@ public class CutAction extends CayenneAc
      */
     @Override
     public void performAction(ActionEvent e) {
-        application.getAction(CopyAction.getActionName()).performAction(e);
-        ((RemoveAction) application.getAction(RemoveAction.getActionName()))
-                .performAction(e, false);
+        application.getActionManager().getAction(CopyAction.class).performAction(e);
+        application.getActionManager().getAction(RemoveAction.class).performAction(
+                e,
+                false);
     }
 
     /**
@@ -78,6 +79,7 @@ public class CutAction extends CayenneAc
      */
     @Override
     public boolean enableForPath(ConfigurationNode object) {
-        return application.getAction(CopyAction.getActionName()).enableForPath(object);
+        return application.getActionManager().getAction(CopyAction.class).enableForPath(
+                object);
     }
 }

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=988538&r1=988537&r2=988538&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 Tue Aug 24 13:34:35 2010
@@ -71,8 +71,13 @@ public class CutAttributeAction extends 
      */
     @Override
     public void performAction(ActionEvent e) {
-        application.getAction(CopyAttributeAction.getActionName()).performAction(e);
-        ((RemoveAction) application.getAction(RemoveAttributeAction.getActionName()))
+        application
+                .getActionManager()
+                .getAction(CopyAttributeAction.class)
+                .performAction(e);
+        application
+                .getActionManager()
+                .getAction(RemoveAttributeAction.class)
                 .performAction(e, false);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutProcedureParameterAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutProcedureParameterAction.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutProcedureParameterAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutProcedureParameterAction.java Tue Aug 24 13:34:35 2010
@@ -68,9 +68,12 @@ public class CutProcedureParameterAction
     @Override
     public void performAction(ActionEvent e) {
         application
-                .getAction(CopyProcedureParameterAction.getActionName())
+                .getActionManager()
+                .getAction(CopyProcedureParameterAction.class)
                 .performAction(e);
-        ((RemoveAction) application.getAction(RemoveProcedureParameterAction
-                .getActionName())).performAction(e, false);
+        application
+                .getActionManager()
+                .getAction(RemoveProcedureParameterAction.class)
+                .performAction(e, false);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutRelationshipAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutRelationshipAction.java?rev=988538&r1=988537&r2=988538&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutRelationshipAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CutRelationshipAction.java Tue Aug 24 13:34:35 2010
@@ -66,8 +66,13 @@ public class CutRelationshipAction exten
      */
     @Override
     public void performAction(ActionEvent e) {
-        application.getAction(CopyRelationshipAction.getActionName()).performAction(e);
-        ((RemoveAction) application.getAction(RemoveRelationshipAction.getActionName()))
+        application
+                .getActionManager()
+                .getAction(CopyRelationshipAction.class)
+                .performAction(e);
+        application
+                .getActionManager()
+                .getAction(RemoveRelationshipAction.class)
                 .performAction(e, false);
     }
 }



Mime
View raw message