You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2010/03/11 15:13:03 UTC
svn commit: r921856 - in
/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler:
./ action/
Author: aadamchik
Date: Thu Mar 11 14:13:03 2010
New Revision: 921856
URL: http://svn.apache.org/viewvc?rev=921856&view=rev
Log:
CAY-1339 Remove org.apache.cayenne.project package from runtime
* Modeler: check the project load status for real, stop using Configuration
Removed:
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ModelerProjectConfiguration.java
Modified:
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/action/NewProjectAction.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
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=921856&r1=921855&r2=921856&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 Thu Mar 11 14:13:03 2010
@@ -29,13 +29,13 @@ import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import javax.swing.WindowConstants;
-import org.apache.cayenne.conf.ConfigStatus;
import org.apache.cayenne.conf.Configuration;
import org.apache.cayenne.modeler.action.ExitAction;
import org.apache.cayenne.modeler.action.OpenProjectAction;
@@ -46,6 +46,7 @@ import org.apache.cayenne.modeler.pref.F
import org.apache.cayenne.modeler.util.CayenneController;
import org.apache.cayenne.project2.Project;
import org.apache.cayenne.project2.validation.ProjectValidator;
+import org.apache.cayenne.validation.ValidationFailure;
import org.apache.cayenne.validation.ValidationResult;
/**
@@ -203,10 +204,8 @@ public class CayenneModelerController ex
/**
* Handles project opening control. Updates main frame, then delegates control to
* child controllers.
- *
- * @param config
*/
- public void projectOpenedAction(Project project, Configuration config) {
+ public void projectOpenedAction(Project project) {
projectController.setProject(project);
@@ -234,26 +233,27 @@ public class CayenneModelerController ex
frame.fireRecentFileListChanged();
}
- ConfigStatus loadStatus = (config != null)
- ? config.getLoadStatus()
- : new ConfigStatus();
+ // for validation purposes combine load failures with post-load validation (not
+ // usre if that'll cause duplicate messages?).
+ List<ValidationFailure> allFailures = new ArrayList<ValidationFailure>();
+ List<ValidationFailure> loadFailures = project.getLoadFailures();
- // --- check for load errors
- if (loadStatus.hasFailures()) {
+ if (!loadFailures.isEmpty()) {
// mark project as unsaved
project.setModified(true);
projectController.setDirty(true);
+ allFailures.addAll(loadFailures);
+ }
- ProjectValidator projectValidator = getApplication()
- .getInjector()
- .getInstance(ProjectValidator.class);
- ValidationResult validationResults = projectValidator.validate(project
- .getRootNode());
+ ProjectValidator projectValidator = getApplication().getInjector().getInstance(
+ ProjectValidator.class);
+ ValidationResult validationResult = projectValidator.validate(project
+ .getRootNode());
+ allFailures.addAll(validationResult.getFailures());
- // show warning dialog
- ValidatorDialog.showDialog(frame, validationResults.getFailures());
+ if (!allFailures.isEmpty()) {
+ ValidatorDialog.showDialog(frame, validationResult.getFailures());
}
-
}
/** Adds path to the list of last opened projects in preferences. */
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/NewProjectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/NewProjectAction.java?rev=921856&r1=921855&r2=921856&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/NewProjectAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/NewProjectAction.java Thu Mar 11 14:13:03 2010
@@ -25,7 +25,6 @@ import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
-import org.apache.cayenne.conf.Configuration;
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.modeler.Application;
import org.apache.cayenne.modeler.CayenneModelerController;
@@ -50,7 +49,9 @@ public class NewProjectAction extends Pr
}
public KeyStroke getAcceleratorKey() {
- return KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ return KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit
+ .getDefaultToolkit()
+ .getMenuShortcutKeyMask());
}
public void performAction(ActionEvent e) {
@@ -63,19 +64,15 @@ public class NewProjectAction extends Pr
return;
}
- Configuration config = buildProjectConfiguration(null);
-
DataChannelDescriptor domain = new DataChannelDescriptor();
-
- String name = NamedObjectFactory.createName(
- DataChannelDescriptor.class,
- domain);
-
+
+ String name = NamedObjectFactory.createName(DataChannelDescriptor.class, domain);
+
domain.setName(name);
-
+
Project project = new Project(domain);
- controller.projectOpenedAction(project, config);
+ controller.projectOpenedAction(project);
// select default domain
getProjectController().fireDomainDisplayEvent(
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java?rev=921856&r1=921855&r2=921856&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java Thu Mar 11 14:13:03 2010
@@ -28,7 +28,6 @@ import java.net.URL;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
-import org.apache.cayenne.conf.Configuration;
import org.apache.cayenne.modeler.Application;
import org.apache.cayenne.modeler.CayenneModelerController;
import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
@@ -131,8 +130,6 @@ public class OpenProjectAction extends P
.getFrameController();
controller.addToLastProjListAction(file.getAbsolutePath());
- Configuration config = buildProjectConfiguration(file);
-
URL url = file.toURL();
Resource rootSource = new URLResource(url);
@@ -168,10 +165,7 @@ public class OpenProjectAction extends P
logObj.info("Will upgrade project " + url.getPath());
Resource upgraded = handler.performUpgrade();
if (upgraded != null) {
- Project project = openProjectResourse(
- upgraded,
- config,
- controller);
+ Project project = openProjectResourse(upgraded, controller);
getProjectController().getProjectWatcher().pauseWatching();
getProjectController().getProjectWatcher().reconfigure();
@@ -193,7 +187,7 @@ public class OpenProjectAction extends P
}
}
else {
- openProjectResourse(rootSource, config, controller);
+ openProjectResourse(rootSource, controller);
}
}
catch (Exception ex) {
@@ -204,14 +198,13 @@ public class OpenProjectAction extends P
private Project openProjectResourse(
Resource resource,
- Configuration config,
CayenneModelerController controller) {
Project project = getApplication()
.getInjector()
.getInstance(ProjectLoader.class)
.loadProject(resource);
- controller.projectOpenedAction(project, config);
+ controller.projectOpenedAction(project);
return project;
}
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java?rev=921856&r1=921855&r2=921856&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java Thu Mar 11 14:13:03 2010
@@ -20,9 +20,7 @@
package org.apache.cayenne.modeler.action;
import java.awt.event.ActionEvent;
-import java.io.File;
-import org.apache.cayenne.conf.Configuration;
import org.apache.cayenne.modeler.Application;
import org.apache.cayenne.modeler.CayenneModelerController;
import org.apache.cayenne.modeler.ProjectController;
@@ -58,15 +56,6 @@ public class ProjectAction extends Cayen
closeProject(true);
}
- /**
- * Creates a configuration suitable for use in the Modeler. Used mainly by subclasses.
- *
- * @since 1.2
- */
- protected Configuration buildProjectConfiguration(File projectFile) {
- return new ModelerProjectConfiguration(projectFile);
- }
-
/** Returns true if successfully closed project, false otherwise. */
public boolean closeProject(boolean checkUnsaved) {
// check if there is a project...