cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r930672 - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne: modeler/ modeler/action/ modeler/dialog/db/ modeler/dialog/validator/ modeler/editor/ modeler/editor/datanode/ modeler/graph/action/ modeler/undo/ ...
Date Sun, 04 Apr 2010 12:31:59 GMT
Author: aadamchik
Date: Sun Apr  4 12:31:58 2010
New Revision: 930672

URL: http://svn.apache.org/viewvc?rev=930672&view=rev
Log:
CAY-1327 Migrate HSQLDB modeler preferences to Java preferences API

code cleanup
fixing references to deprecated data source factories

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/ProjectController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DataMapErrorMsg.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.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/util/NamingStrategyPreferences.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayenneProjectPreferences.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/ChildrenMapPreference.java

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=930672&r1=930671&r2=930672&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 Sun Apr  4 12:31:58 2010
@@ -43,10 +43,8 @@ import org.apache.cayenne.modeler.undo.C
 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.modeler.util.CayenneUserDir;
 import org.apache.cayenne.pref.CayennePreference;
 import org.apache.cayenne.pref.CayenneProjectPreferences;
-import org.apache.cayenne.pref.Preference;
 import org.apache.cayenne.project2.CayenneProjectModule;
 import org.apache.cayenne.project2.Project;
 import org.apache.cayenne.swing.BindingFactory;
@@ -89,7 +87,6 @@ public class Application {
 
     protected File initialProject;
     protected String name;
-    protected String preferencesDB;
 
     protected BindingFactory bindingFactory;
     protected AdapterMapping adapterMapping;
@@ -99,7 +96,7 @@ public class Application {
     protected CayenneProjectPreferences cayenneProjectPreferences;
 
     // This is for OS X support
-    private boolean isQuittingApplication = false;
+    private boolean isQuittingApplication;
 
     protected CayennePreference cayennePreference;
 
@@ -124,41 +121,29 @@ public class Application {
         return (CayenneModelerFrame) getInstance().getFrameController().getView();
     }
 
-    public Injector getInjector() {
-        return injector;
-    }
-
-    public static Project getProject() {
-        return getInstance().getFrameController().getProjectController().getProject();
-    }
-
     public Application(File initialProject) {
         this.initialProject = initialProject;
 
-        Module module = new CayenneProjectModule();
-        Module moduleSer = new CayenneServerModule("CayenneModeler");
+        Module projectModule = new CayenneProjectModule();
+        Module serverModule = new CayenneServerModule("CayenneModeler");
 
-        injector = DIBootstrap.createInjector(module, moduleSer);
+        this.injector = DIBootstrap.createInjector(projectModule, serverModule);
 
         // configure startup settings
         String configuredName = System.getProperty(APPLICATION_NAME_PROPERTY);
         this.name = (configuredName != null) ? configuredName : DEFAULT_APPLICATION_NAME;
-
-        String subdir = System.getProperty(PREFERENCES_VERSION_PROPERTY);
-
-        if (subdir == null) {
-            subdir = PREFERENCES_VERSION;
-        }
-
-        File dbDir = new File(CayenneUserDir.getInstance().resolveFile(
-                PREFERENCES_DB_SUBDIRECTORY), subdir);
-        dbDir.mkdirs();
         this.cayennePreference = new CayennePreference();
+    }
+
+    public Injector getInjector() {
+        return injector;
+    }
 
-        this.preferencesDB = new File(dbDir, "db").getAbsolutePath();
+    public Project getProject() {
+        return getFrameController().getProjectController().getProject();
     }
 
-    public Preferences getPreferencesNode(Class className, String path) {
+    public Preferences getPreferencesNode(Class<?> className, String path) {
         return cayennePreference.getNode(className, path);
     }
 
@@ -249,25 +234,23 @@ public class Application {
         return cayenneProjectPreferences;
     }
 
-    public static Preferences getMainPreferenceForProject() {
+    public Preferences getMainPreferenceForProject() {
 
-        DataChannelDescriptor descriptor = (DataChannelDescriptor) getProject()
+        DataChannelDescriptor descriptor = (DataChannelDescriptor) getFrameController()
+                .getProjectController()
+                .getProject()
                 .getRootNode();
 
         // if new project
         if (descriptor.getConfigurationSource() == null) {
-            return Application.getInstance().getPreferencesNode(
-                    getProject().getClass(),
-                    getId());
+            return getPreferencesNode(getProject().getClass(), getId());
         }
 
         String path = CayennePreference.filePathToPrefereceNodePath(descriptor
                 .getConfigurationSource()
                 .getURL()
                 .getPath());
-        Preferences pref = Application.getInstance().getPreferencesNode(
-                getProject().getClass(),
-                "");
+        Preferences pref = getPreferencesNode(getProject().getClass(), "");
         return pref.node(pref.absolutePath() + path);
     }
 

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=930672&r1=930671&r2=930672&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 Sun Apr  4 12:31:58 2010
@@ -52,7 +52,6 @@ import org.apache.cayenne.validation.Val
 
 /**
  * Controller of the main application frame.
- * 
  */
 public class CayenneModelerController extends CayenneController {
 

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=930672&r1=930671&r2=930672&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 Sun Apr  4 12:31:58 2010
@@ -34,6 +34,9 @@ import java.util.prefs.Preferences;
 import javax.swing.event.EventListenerList;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.event.DataMapEvent;
 import org.apache.cayenne.configuration.event.DataMapListener;
 import org.apache.cayenne.configuration.event.DataNodeEvent;
@@ -46,9 +49,6 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.event.ProcedureParameterListener;
 import org.apache.cayenne.configuration.event.QueryEvent;
 import org.apache.cayenne.configuration.event.QueryListener;
-import org.apache.cayenne.configuration.ConfigurationNode;
-import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -121,22 +121,13 @@ import org.apache.cayenne.project2.Confi
 import org.apache.cayenne.project2.Project;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.util.IDUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * A controller that works with the project tree, tracking selection and dispatching
  * project events.
- * <p>
- * TODO: Refactor the event model, so that events are generic and contain "path" to a
- * project node in question. After this is done, EventController should no longer maintain
- * the selection model (currentXYZ ivars), rather it should update internal model.
- * </p>
  */
 public class ProjectController extends CayenneController {
 
-    private static final Log logObj = LogFactory.getLog(ProjectController.class);
-
     /*
      * A snapshot of the current state of the project controller. This was added so that
      * we could support history of recent objects.
@@ -1841,8 +1832,9 @@ public class ProjectController extends C
             Object[] paths = getCurrentPaths();
             List<Object> result = new Vector<Object>();
 
-            ConfigurationNodeParentGetter parentGetter = getApplication().getInjector().getInstance(
-                    ConfigurationNodeParentGetter.class);
+            ConfigurationNodeParentGetter parentGetter = getApplication()
+                    .getInjector()
+                    .getInstance(ConfigurationNodeParentGetter.class);
             Object parent = parentGetter.getParent((ConfigurationNode) paths[0]);
 
             for (Object path : paths) {

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=930672&r1=930671&r2=930672&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 Sun Apr  4 12:31:58 2010
@@ -36,6 +36,9 @@ import javax.swing.tree.MutableTreeNode;
 import javax.swing.tree.TreePath;
 import javax.swing.tree.TreeSelectionModel;
 
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.event.DataMapEvent;
 import org.apache.cayenne.configuration.event.DataMapListener;
 import org.apache.cayenne.configuration.event.DataNodeEvent;
@@ -46,9 +49,6 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.event.ProcedureListener;
 import org.apache.cayenne.configuration.event.QueryEvent;
 import org.apache.cayenne.configuration.event.QueryListener;
-import org.apache.cayenne.configuration.ConfigurationNode;
-import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.Embeddable;
@@ -112,10 +112,6 @@ public class ProjectTreeView extends JTr
 
     protected ProjectController mediator;
     protected TreeSelectionListener treeSelectionListener;
-
-    /**
-     * Popup menu containing basic functions
-     */
     protected JPopupMenu popup;
 
     public ProjectTreeView(ProjectController mediator) {
@@ -124,7 +120,7 @@ public class ProjectTreeView extends JTr
 
         initView();
         initController();
-        initFromModel(Application.getProject());
+        initFromModel(Application.getInstance().getProject());
     }
 
     private void initView() {
@@ -594,6 +590,7 @@ public class ProjectTreeView extends JTr
     public void dataMapRemoved(DataMapEvent e) {
         DataMap map = e.getDataMap();
         DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application
+                .getInstance()
                 .getProject()
                 .getRootNode();
         removeNode(new Object[] {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java Sun Apr  4 12:31:58 2010
@@ -35,7 +35,6 @@ import org.apache.cayenne.modeler.Applic
 import org.apache.cayenne.modeler.dialog.validator.ValidationDisplayHandler;
 import org.apache.cayenne.modeler.dialog.validator.ValidatorDialog;
 import org.apache.cayenne.modeler.util.CayenneAction;
-import org.apache.cayenne.pref.Preference;
 import org.apache.cayenne.pref.RenamedPreferences;
 import org.apache.cayenne.project2.Project;
 import org.apache.cayenne.project2.ProjectSaver;
@@ -104,7 +103,7 @@ public class SaveAsAction extends Cayenn
         URL url = projectDir.toURL();
 
         URLResource res = new URLResource(url);
-        // /!!!!!!!!!!!!!!!!!!! SAVE AS!!!!!!!!!!!!!!
+
         ProjectSaver saver = getApplication().getInjector().getInstance(
                 ProjectSaver.class);
 
@@ -134,18 +133,17 @@ public class SaveAsAction extends Cayenn
         }
         else if (isNewProject) {
             if (tempOldPref != null
-                    && tempOldPref.absolutePath().contains(getApplication().getId())) {
+                    && tempOldPref.absolutePath().contains(Application.getId())) {
 
                 String projPath = tempOldPref.absolutePath().replace(
-                        "/" + getApplication().getId(),
+                        "/" + Application.getId(),
                         "");
                 String newName = p.getConfigurationResource().getURL().getPath().replace(
                         ".xml",
                         "");
 
-                Preferences newPref = getApplication()
-                        .getMainPreferenceForProject()
-                        .node(projPath + newName);
+                Preferences newPref = getApplication().getMainPreferenceForProject().node(
+                        projPath + newName);
 
                 RenamedPreferences.copyPreferences(newPref, tempOldPref, false);
                 tempOldPref.removeNode();

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java Sun Apr  4 12:31:58 2010
@@ -36,7 +36,6 @@ import javax.swing.event.ChangeListener;
 import org.apache.cayenne.access.DbGenerator;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ValidationResultBrowser;
 import org.apache.cayenne.modeler.pref.DBConnectionInfo;
@@ -105,19 +104,24 @@ public class DBGeneratorOptions extends 
         sqlBinding = builder.bindToTextArea(view.getSql(), "textForSQL");
 
         optionBindings = new ObjectBinding[5];
-        optionBindings[0] = builder.bindToStateChangeAndAction(view.getCreateFK(),
+        optionBindings[0] = builder.bindToStateChangeAndAction(
+                view.getCreateFK(),
                 "generatorDefaults.createFK",
                 "refreshSQLAction()");
-        optionBindings[1] = builder.bindToStateChangeAndAction(view.getCreatePK(),
+        optionBindings[1] = builder.bindToStateChangeAndAction(
+                view.getCreatePK(),
                 "generatorDefaults.createPK",
                 "refreshSQLAction()");
-        optionBindings[2] = builder.bindToStateChangeAndAction(view.getCreateTables(),
+        optionBindings[2] = builder.bindToStateChangeAndAction(
+                view.getCreateTables(),
                 "generatorDefaults.createTables",
                 "refreshSQLAction()");
-        optionBindings[3] = builder.bindToStateChangeAndAction(view.getDropPK(),
+        optionBindings[3] = builder.bindToStateChangeAndAction(
+                view.getDropPK(),
                 "generatorDefaults.dropPK",
                 "refreshSQLAction()");
-        optionBindings[4] = builder.bindToStateChangeAndAction(view.getDropTables(),
+        optionBindings[4] = builder.bindToStateChangeAndAction(
+                view.getDropTables(),
                 "generatorDefaults.dropTables",
                 "refreshSQLAction()");
 
@@ -182,7 +186,7 @@ public class DBGeneratorOptions extends 
     }
 
     // ===============
-    //    Actions
+    // Actions
     // ===============
 
     /**
@@ -236,7 +240,8 @@ public class DBGeneratorOptions extends 
             }
             else {
                 new ValidationResultBrowser(this)
-                        .startupAction("Schema Generation Complete",
+                        .startupAction(
+                                "Schema Generation Complete",
                                 "Schema generation finished. The following problem(s) were ignored.",
                                 failures);
             }
@@ -254,7 +259,11 @@ public class DBGeneratorOptions extends 
         fc.setDialogType(JFileChooser.SAVE_DIALOG);
         fc.setDialogTitle("Save SQL Script");
 
-        File projectDir = new File(Application.getProject().getConfigurationResource().getURL().getPath());
+        File projectDir = new File(getApplication()
+                .getProject()
+                .getConfigurationResource()
+                .getURL()
+                .getPath());
 
         if (projectDir != null) {
             fc.setCurrentDirectory(projectDir);

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java Sun Apr  4 12:31:58 2010
@@ -33,6 +33,7 @@ import javax.swing.JOptionPane;
 import javax.swing.WindowConstants;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.dba.DbAdapter;
@@ -52,7 +53,6 @@ import org.apache.cayenne.merge.MergeDir
 import org.apache.cayenne.merge.MergerContext;
 import org.apache.cayenne.merge.MergerToken;
 import org.apache.cayenne.merge.ModelMergeDelegate;
-import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ValidationResultBrowser;
 import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
@@ -165,8 +165,11 @@ public class MergerOptions extends Cayen
                     .getClassLoadingService());
             tokens.setMergerFactory(adapter.mergerFactory());
             merger = new DbMerger();
-            List<MergerToken> mergerTokens = merger.createMergeTokens(adapter, connectionInfo
-                    .makeDataSource(getApplication().getClassLoadingService()), dataMap);
+            List<MergerToken> mergerTokens = merger.createMergeTokens(
+                    adapter,
+                    connectionInfo.makeDataSource(getApplication()
+                            .getClassLoadingService()),
+                    dataMap);
             tokens.setTokens(mergerTokens);
         }
         catch (Exception ex) {
@@ -187,7 +190,7 @@ public class MergerOptions extends Cayen
         final String lineEnd = (batchTerminator != null) ? "\n"
                 + batchTerminator
                 + "\n\n" : "\n\n";
-        
+
         while (it.hasNext()) {
             MergerToken token = it.next();
 
@@ -256,97 +259,156 @@ public class MergerOptions extends Cayen
             JOptionPane.showMessageDialog(getView(), "Nothing to migrate.");
             return;
         }
-        
+
         final ProjectController c = getProjectController();
-        
+
         final Object src = this;
-        final DataChannelDescriptor domain = (DataChannelDescriptor)getProjectController().getProject().getRootNode();
+        final DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController()
+                .getProject()
+                .getRootNode();
         final DataNodeDescriptor node = getProjectController().getCurrentDataNode();
 
-        final ModelMergeDelegate delegate = new ModelMergeDelegate (){
+        final ModelMergeDelegate delegate = new ModelMergeDelegate() {
 
             public void dbAttributeAdded(DbAttribute att) {
                 if (c.getCurrentDbEntity() == att.getEntity()) {
-                    c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(), dataMap, domain));
+                    c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att
+                            .getEntity(), dataMap, domain));
                 }
             }
 
             public void dbAttributeModified(DbAttribute att) {
                 if (c.getCurrentDbEntity() == att.getEntity()) {
-                    c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(), dataMap, domain));
+                    c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att
+                            .getEntity(), dataMap, domain));
                 }
             }
 
             public void dbAttributeRemoved(DbAttribute att) {
                 if (c.getCurrentDbEntity() == att.getEntity()) {
-                    c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(), dataMap, domain));
+                    c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att
+                            .getEntity(), dataMap, domain));
                 }
             }
 
             public void dbEntityAdded(DbEntity ent) {
                 c.fireDbEntityEvent(new EntityEvent(src, ent, MapEvent.ADD));
-                c.fireDbEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node, domain));
+                c.fireDbEntityDisplayEvent(new EntityDisplayEvent(
+                        src,
+                        ent,
+                        dataMap,
+                        node,
+                        domain));
             }
 
             public void dbEntityRemoved(DbEntity ent) {
                 c.fireDbEntityEvent(new EntityEvent(src, ent, MapEvent.REMOVE));
-                c.fireDbEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node, domain));
+                c.fireDbEntityDisplayEvent(new EntityDisplayEvent(
+                        src,
+                        ent,
+                        dataMap,
+                        node,
+                        domain));
             }
 
             public void dbRelationshipAdded(DbRelationship rel) {
                 if (c.getCurrentDbEntity() == rel.getSourceEntity()) {
-                    c.fireDbRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel, rel.getSourceEntity(), dataMap, domain));
+                    c.fireDbRelationshipDisplayEvent(new RelationshipDisplayEvent(
+                            src,
+                            rel,
+                            rel.getSourceEntity(),
+                            dataMap,
+                            domain));
                 }
             }
 
             public void dbRelationshipRemoved(DbRelationship rel) {
                 if (c.getCurrentDbEntity() == rel.getSourceEntity()) {
-                    c.fireDbRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel, rel.getSourceEntity(), dataMap, domain));
+                    c.fireDbRelationshipDisplayEvent(new RelationshipDisplayEvent(
+                            src,
+                            rel,
+                            rel.getSourceEntity(),
+                            dataMap,
+                            domain));
                 }
             }
 
             public void objAttributeAdded(ObjAttribute att) {
                 if (c.getCurrentObjEntity() == att.getEntity()) {
-                    c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(), dataMap, domain));
+                    c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(
+                            src,
+                            att,
+                            att.getEntity(),
+                            dataMap,
+                            domain));
                 }
             }
 
             public void objAttributeModified(ObjAttribute att) {
                 if (c.getCurrentObjEntity() == att.getEntity()) {
-                    c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(), dataMap, domain));
+                    c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(
+                            src,
+                            att,
+                            att.getEntity(),
+                            dataMap,
+                            domain));
                 }
             }
 
             public void objAttributeRemoved(ObjAttribute att) {
                 if (c.getCurrentObjEntity() == att.getEntity()) {
-                    c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(), dataMap, domain));
+                    c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(
+                            src,
+                            att,
+                            att.getEntity(),
+                            dataMap,
+                            domain));
                 }
             }
 
             public void objEntityAdded(ObjEntity ent) {
                 c.fireObjEntityEvent(new EntityEvent(src, ent, MapEvent.ADD));
-                c.fireObjEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node, domain));
+                c.fireObjEntityDisplayEvent(new EntityDisplayEvent(
+                        src,
+                        ent,
+                        dataMap,
+                        node,
+                        domain));
             }
 
             public void objEntityRemoved(ObjEntity ent) {
                 c.fireObjEntityEvent(new EntityEvent(src, ent, MapEvent.REMOVE));
-                c.fireObjEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node, domain));
+                c.fireObjEntityDisplayEvent(new EntityDisplayEvent(
+                        src,
+                        ent,
+                        dataMap,
+                        node,
+                        domain));
             }
 
             public void objRelationshipAdded(ObjRelationship rel) {
                 if (c.getCurrentObjEntity() == rel.getSourceEntity()) {
-                    c.fireObjRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel, rel.getSourceEntity(), dataMap, domain));
+                    c.fireObjRelationshipDisplayEvent(new RelationshipDisplayEvent(
+                            src,
+                            rel,
+                            rel.getSourceEntity(),
+                            dataMap,
+                            domain));
                 }
             }
 
             public void objRelationshipRemoved(ObjRelationship rel) {
                 if (c.getCurrentObjEntity() == rel.getSourceEntity()) {
-                    c.fireObjRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel, rel.getSourceEntity(), dataMap, domain));
+                    c.fireObjRelationshipDisplayEvent(new RelationshipDisplayEvent(
+                            src,
+                            rel,
+                            rel.getSourceEntity(),
+                            dataMap,
+                            domain));
                 }
             }
-            
-        };
 
+        };
 
         try {
             DataSource dataSource = connectionInfo.makeDataSource(getApplication()
@@ -356,7 +418,8 @@ public class MergerOptions extends Cayen
             MergerContext mergerContext = new ExecutingMergerContext(
                     dataMap,
                     dataSource,
-                    adapter, delegate);
+                    adapter,
+                    delegate);
             boolean modelChanged = false;
             for (MergerToken tok : tokensToMigrate) {
                 int numOfFailuresBefore = mergerContext
@@ -376,19 +439,18 @@ public class MergerOptions extends Cayen
                     tokens.removeToken(tok);
                 }
             }
-            
+
             if (modelChanged) {
                 // mark the model as unsaved
-                Project project = Application.getProject();
+                Project project = getApplication().getProject();
                 project.setModified(true);
 
-                ProjectController projectController = Application
-                        .getInstance()
+                ProjectController projectController = getApplication()
                         .getFrameController()
                         .getProjectController();
                 projectController.setDirty(true);
             }
-            
+
             ValidationResult failures = mergerContext.getValidationResult();
 
             if (failures == null || !failures.hasFailures()) {
@@ -413,11 +475,11 @@ public class MergerOptions extends Cayen
         JFileChooser fc = new JFileChooser();
         fc.setDialogType(JFileChooser.SAVE_DIALOG);
         fc.setDialogTitle("Save SQL Script");
-        
-        Resource projectDir = Application.getProject().getConfigurationResource();
+
+        Resource projectDir = getApplication().getProject().getConfigurationResource();
 
         if (projectDir != null) {
-            fc.setCurrentDirectory(new File(projectDir.getURL().getPath()));//projectDir);
+            fc.setCurrentDirectory(new File(projectDir.getURL().getPath()));
         }
 
         if (fc.showSaveDialog(getView()) == JFileChooser.APPROVE_OPTION) {
@@ -436,7 +498,7 @@ public class MergerOptions extends Cayen
             }
         }
     }
-    
+
     private ProjectController getProjectController() {
         return getApplication().getFrameController().getProjectController();
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DataMapErrorMsg.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DataMapErrorMsg.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DataMapErrorMsg.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DataMapErrorMsg.java Sun Apr  4 12:31:58 2010
@@ -40,7 +40,10 @@ public class DataMapErrorMsg extends Val
 
         Object object = result.getSource();
         map = (DataMap) object;
-        domain = (DataChannelDescriptor) Application.getProject().getRootNode();
+        domain = (DataChannelDescriptor) Application
+                .getInstance()
+                .getProject()
+                .getRootNode();
     }
 
     public void displayField(ProjectController mediator, JFrame frame) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java Sun Apr  4 12:31:58 2010
@@ -351,6 +351,7 @@ public class DataDomainView extends JPan
         }
 
         DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application
+                .getInstance()
                 .getProject()
                 .getRootNode();
         Preferences prefs = projectController.getPreferenceForDataDomain();
@@ -361,10 +362,10 @@ public class DataDomainView extends JPan
                 dataChannelDescriptor.getName());
         ProjectUtil.setDataDomainName(dataChannelDescriptor, newName);
 
-        // copy all old preference to new preferences 
+        // copy all old preference to new preferences
         Preferences oldPref = prefs;
         RenamedPreferences.copyPreferences(newName, oldPref);
-        
+
         projectController.fireDomainEvent(e);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java Sun Apr  4 12:31:58 2010
@@ -115,7 +115,7 @@ public class DataMapView extends JPanel 
                 setDefaultSchema(text);
             }
         };
-        
+
         quoteSQLIdentifiers = new JCheckBox();
 
         updateDefaultPackage = new JButton("Update...");
@@ -211,8 +211,8 @@ public class DataMapView extends JPanel 
                 setDataNode();
             }
         });
-        
-        quoteSQLIdentifiers.addActionListener(new ActionListener(){
+
+        quoteSQLIdentifiers.addActionListener(new ActionListener() {
 
             public void actionPerformed(ActionEvent e) {
                 setQuoteSQLIdentifiers(quoteSQLIdentifiers.isSelected());
@@ -289,8 +289,10 @@ public class DataMapView extends JPanel 
 
         quoteSQLIdentifiers.setSelected(map.isQuotingSQLIdentifiers());
         // rebuild data node list
-        
-        Object nodes[] = ((DataChannelDescriptor) eventController.getProject().getRootNode()).getNodeDescriptors().toArray();
+
+        Object nodes[] = ((DataChannelDescriptor) eventController
+                .getProject()
+                .getRootNode()).getNodeDescriptors().toArray();
 
         // add an empty item to the front
         Object[] objects = new Object[nodes.length + 1];
@@ -367,7 +369,7 @@ public class DataMapView extends JPanel 
             eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
         }
     }
-    
+
     void setQuoteSQLIdentifiers(boolean flag) {
         DataMap dataMap = eventController.getCurrentDataMap();
 
@@ -377,7 +379,7 @@ public class DataMapView extends JPanel 
 
         if (dataMap.isQuotingSQLIdentifiers() != flag) {
             dataMap.setQuotingSQLIdentifiers(flag);
-            
+
             eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
         }
     }
@@ -504,7 +506,10 @@ public class DataMapView extends JPanel 
 
         // search for matching map name across domains, as currently they have to be
         // unique globally
-        DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor)Application.getProject().getRootNode();
+        DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application
+                .getInstance()
+                .getProject()
+                .getRootNode();
 
         DataMap matchingMap = dataChannelDescriptor.getDataMap(newName);
 
@@ -522,7 +527,9 @@ public class DataMapView extends JPanel 
         // completely new name, set new name for domain
         DataMapDefaults pref = eventController.getDataMapPreferences("");
         DataMapEvent e = new DataMapEvent(this, map, map.getName());
-        ProjectUtil.setDataMapName((DataChannelDescriptor)eventController.getProject().getRootNode(), map, newName);
+        ProjectUtil.setDataMapName((DataChannelDescriptor) eventController
+                .getProject()
+                .getRootNode(), map, newName);
         pref.copyPreferences(newName);
         eventController.fireDataMapEvent(e);
     }
@@ -536,11 +543,11 @@ public class DataMapView extends JPanel 
             return;
         }
 
-        boolean hasChanges = false;
-
         // unlink map from any nodes
 
-        for (DataNodeDescriptor nextNode : ((DataChannelDescriptor)eventController.getProject().getRootNode()).getNodeDescriptors()) {
+        for (DataNodeDescriptor nextNode : ((DataChannelDescriptor) eventController
+                .getProject()
+                .getRootNode()).getNodeDescriptors()) {
 
             // Theoretically only one node may contain a datamap at each given time.
             // Being paranoid, we will still scan through all.
@@ -549,15 +556,12 @@ public class DataMapView extends JPanel 
 
                 // announce DataNode change
                 eventController.fireDataNodeEvent(new DataNodeEvent(this, nextNode));
-
-                hasChanges = true;
             }
         }
 
         // link to a selected node
         if (node != null) {
             node.getDataMapNames().add(map.getName());
-            hasChanges = true;
 
             // announce DataNode change
             eventController.fireDataNodeEvent(new DataNodeEvent(this, node));

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java Sun Apr  4 12:31:58 2010
@@ -32,16 +32,15 @@ import java.util.Map;
 import javax.swing.DefaultComboBoxModel;
 
 import org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy;
-import org.apache.cayenne.access.dbsync.ThrowOnPartialOrCreateSchemaStrategy;
 import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
+import org.apache.cayenne.access.dbsync.ThrowOnPartialOrCreateSchemaStrategy;
 import org.apache.cayenne.access.dbsync.ThrowOnPartialSchemaStrategy;
-import org.apache.cayenne.conf.DBCPDataSourceFactory;
-import org.apache.cayenne.conf.DriverDataSourceFactory;
-import org.apache.cayenne.conf.JNDIDataSourceFactory;
-import org.apache.cayenne.configuration.event.DataNodeEvent;
+import org.apache.cayenne.configuration.DBCPDataSourceFactory;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.configuration.JNDIDataSourceFactory;
+import org.apache.cayenne.configuration.XMLPoolingDataSourceFactory;
+import org.apache.cayenne.configuration.event.DataNodeEvent;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.pref.PreferenceDialog;
 import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
@@ -64,7 +63,7 @@ public class MainDataNodeEditor extends 
     protected static final String NO_LOCAL_DATA_SOURCE = "Select DataSource for Local Work...";
 
     final static String[] standardDataSourceFactories = new String[] {
-            DriverDataSourceFactory.class.getName(),
+            XMLPoolingDataSourceFactory.class.getName(),
             JNDIDataSourceFactory.class.getName(), DBCPDataSourceFactory.class.getName()
     };
 
@@ -159,9 +158,12 @@ public class MainDataNodeEditor extends 
 
         ProjectController parent = (ProjectController) getParent();
         DataNodeDefaults oldPref = parent.getDataNodePreferences();
-        DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor)Application.getProject().getRootNode();
+        DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) getApplication()
+                .getProject()
+                .getRootNode();
 
-        Collection<DataNodeDescriptor> matchingNode = dataChannelDescriptor.getNodeDescriptors();
+        Collection<DataNodeDescriptor> matchingNode = dataChannelDescriptor
+                .getNodeDescriptors();
 
         Iterator<DataNodeDescriptor> it = matchingNode.iterator();
         while (it.hasNext()) {
@@ -171,21 +173,20 @@ public class MainDataNodeEditor extends 
                 throw new ValidationException("There is another DataNode named '"
                         + newName
                         + "'. Use a different name.");
-            } 
+            }
         }
-        
+
         // passed validation, set value...
 
         // TODO: fixme....there is a slight chance that domain is different than the one
         // cached node belongs to
-        ProjectUtil.setDataNodeName((DataChannelDescriptor)parent.getProject().getRootNode(), node, newName);
-        
-    
+        ProjectUtil.setDataNodeName((DataChannelDescriptor) parent
+                .getProject()
+                .getRootNode(), node, newName);
+
         oldPref.copyPreferences(newName);
     }
 
-    // ======== other stuff
-
     protected void initController() {
         view.getDataSourceDetail().add(defaultSubeditor.getView(), "default");
         view.getFactories().setEditable(true);
@@ -249,7 +250,7 @@ public class MainDataNodeEditor extends 
 
     protected void refreshLocalDataSources() {
         localDataSources.clear();
-        
+
         Map sources = getApplication().getCayenneProjectPreferences().getDetailObject(
                 DBConnectionInfo.class).getChildrenPreferences();
 
@@ -258,13 +259,13 @@ public class MainDataNodeEditor extends 
 
         // a slight chance that a real datasource is called NO_LOCAL_DATA_SOURCE...
         keys[0] = NO_LOCAL_DATA_SOURCE;
-        
+
         Object[] dataSources = sources.keySet().toArray();
         localDataSources.add(dataSources);
-        for(int i=0; i<dataSources.length;i++){
-            keys[i+1] = dataSources[i];
+        for (int i = 0; i < dataSources.length; i++) {
+            keys[i + 1] = dataSources[i];
         }
-        
+
         view.getLocalDataSources().setModel(new DefaultComboBoxModel(keys));
         localDataSourceBinding.updateView();
     }
@@ -298,7 +299,7 @@ public class MainDataNodeEditor extends 
         // create subview dynamically...
         if (c == null) {
 
-            if (DriverDataSourceFactory.class.getName().equals(factoryName)) {
+            if (XMLPoolingDataSourceFactory.class.getName().equals(factoryName)) {
                 c = new JDBCDataSourceEditor(
                         (ProjectController) getParent(),
                         nodeChangeProcessor);

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java Sun Apr  4 12:31:58 2010
@@ -33,30 +33,31 @@ import org.apache.cayenne.modeler.graph.
 import org.apache.cayenne.modeler.util.CayenneAction;
 
 /**
- * Action that displays one of the objects in main tree, 
- * and then fires another action (if specified)
+ * Action that displays one of the objects in main tree, and then fires another action (if
+ * specified)
  */
 public class EntityDisplayAction extends CayenneAction {
+
     /**
      * Action that will be performed after selection
      */
     CayenneAction delegate;
-    
+
     GraphBuilder builder;
-    
+
     public EntityDisplayAction(GraphBuilder builder) {
         super("Show", Application.getInstance());
         this.builder = builder;
         init();
     }
-    
+
     public EntityDisplayAction(GraphBuilder builder, CayenneAction delegate) {
         super((String) delegate.getValue(Action.NAME), Application.getInstance());
         this.delegate = delegate;
         this.builder = builder;
         init();
     }
-    
+
     private void init() {
         setEnabled(true);
 
@@ -77,20 +78,22 @@ public class EntityDisplayAction extends
             }
         }
     }
-    
+
     boolean display() {
         Entity entity = builder.getSelectedEntity();
         if (entity == null) {
             return false;
         }
-        
+
         ProjectController mediator = getProjectController();
-        
-        //we're always in same domain
-        FindDialog.jumpToResult(new Object[] { 
-                Application.getProject(), (DataChannelDescriptor)mediator.getProject().getRootNode(), entity.getDataMap(), entity
+
+        // we're always in same domain
+        FindDialog.jumpToResult(new Object[] {
+                getApplication().getProject(),
+                (DataChannelDescriptor) mediator.getProject().getRootNode(),
+                entity.getDataMap(), entity
         });
-        
+
         return true;
     }
 

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=930672&r1=930671&r2=930672&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 Sun Apr  4 12:31:58 2010
@@ -38,7 +38,10 @@ public class CreateNodeUndoableEdit exte
     private DataChannelDescriptor domain;
 
     public CreateNodeUndoableEdit(Application application, DataNodeDescriptor node) {
-        this.domain = (DataChannelDescriptor) Application.getProject().getRootNode();
+        this.domain = (DataChannelDescriptor) Application
+                .getInstance()
+                .getProject()
+                .getRootNode();
         this.node = node;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NamingStrategyPreferences.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NamingStrategyPreferences.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NamingStrategyPreferences.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NamingStrategyPreferences.java Sun Apr  4 12:31:58 2010
@@ -22,11 +22,8 @@ import java.util.Arrays;
 import java.util.Vector;
 import java.util.prefs.Preferences;
 
-import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.modeler.Application;
 
-import org.apache.cayenne.pref.CayennePreference;
-
 /**
  * Helper class to store/read information about naming strategies have been used
  */
@@ -50,7 +47,7 @@ public class NamingStrategyPreferences {
     }
 
     Preferences getPreference() {
-        return Application.getMainPreferenceForProject();
+        return Application.getInstance().getMainPreferenceForProject();
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayenneProjectPreferences.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayenneProjectPreferences.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayenneProjectPreferences.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayenneProjectPreferences.java Sun Apr  4 12:31:58 2010
@@ -20,7 +20,6 @@ package org.apache.cayenne.pref;
 
 import java.lang.reflect.Constructor;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;
@@ -30,54 +29,48 @@ import org.apache.cayenne.modeler.pref.D
 
 public class CayenneProjectPreferences {
 
-    // for preferences not dependences from project
-    private Map<Class, Object> cayennePreferences;
+    // for preferences not dependent on project
+    private Map<Class<?>, ChildrenMapPreference> cayennePreferences;
 
-    // for preferences dependences from project
-    private HashMap<Preferences, Object> projectCayennePreferences;
+    // for preferences dependent on project
+    private Map<Preferences, CayennePreference> projectCayennePreferences;
 
     public CayenneProjectPreferences() {
-        cayennePreferences = new HashMap<Class, Object>();
+        cayennePreferences = new HashMap<Class<?>, ChildrenMapPreference>();
+
         cayennePreferences.put(DBConnectionInfo.class, new ChildrenMapPreference(
                 new DBConnectionInfo()));
-       
-        projectCayennePreferences = new HashMap<Preferences, Object>();
-        initPreference();
-    }
 
-    private void initPreference() {
-        Iterator it = cayennePreferences.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry pairs = (Map.Entry) it.next();
-            ((ChildrenMapPreference) cayennePreferences.get(pairs.getKey()))
-                    .initChildrenPreferences();
+        projectCayennePreferences = new HashMap<Preferences, CayennePreference>();
+
+        for (ChildrenMapPreference value : cayennePreferences.values()) {
+            value.initChildrenPreferences();
         }
     }
 
-    public ChildrenMapPreference getDetailObject(Class className) {
-        return (ChildrenMapPreference) cayennePreferences.get(className);
+    public ChildrenMapPreference getDetailObject(Class<?> className) {
+        return cayennePreferences.get(className);
     }
 
     public CayennePreference getProjectDetailObject(
-            Class className,
-            Preferences preference) {
-        if (projectCayennePreferences.get(preference) == null) {
+            Class<? extends CayennePreference> objectClass,
+            Preferences preferences) {
+
+        CayennePreference preference = projectCayennePreferences.get(preferences);
+
+        if (preference == null) {
             try {
-                Class cls = className;
-                Class partypes[] = new Class[1];
-                partypes[0] = Preferences.class;
-                Constructor ct = cls.getConstructor(partypes);
-                Object arglist[] = new Object[1];
-                arglist[0] = preference;
-                Object retobj = ct.newInstance(arglist);
-                projectCayennePreferences.put(preference, retobj);
+                Constructor<? extends CayennePreference> ct = objectClass
+                        .getConstructor(Preferences.class);
+                preference = ct.newInstance(preferences);
+                projectCayennePreferences.put(preferences, preference);
             }
             catch (Throwable e) {
-                new CayenneRuntimeException("Error initing preference");
+                new CayenneRuntimeException("Error initialzing preference", e);
             }
         }
 
-        return (CayennePreference) projectCayennePreferences.get(preference);
+        return preference;
     }
 
     // delete property

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/ChildrenMapPreference.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/ChildrenMapPreference.java?rev=930672&r1=930671&r2=930672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/ChildrenMapPreference.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/ChildrenMapPreference.java Sun Apr  4 12:31:58 2010
@@ -65,7 +65,7 @@ public class ChildrenMapPreference exten
                     children.put(names[i], retobj);
                 }
                 catch (Throwable e) {
-                    new CayenneRuntimeException("Error initing preference");
+                    new CayenneRuntimeException("Error initializing preference", e);
                 }
             }
 



Mime
View raw message