bug 192675
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
index f1e4174..8e0a958 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
@@ -18,4 +18,5 @@
SYNCHRONIZE_CLASSES_JOB=Synchronizing classes
SYNCHRONIZING_CLASSES_TASK=Synchronizing classes ...
INVALID_PERSISTENCE_XML_CONTENT=Invalid persistence.xml content
+ERROR_SYNCHRONIZING_CLASSES_COULD_NOT_VALIDATE=Error synchronizing classes. Could not validate.
ERROR_WRITING_FILE=Could not write to persistence.xml
\ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
index 8a14e5c..fe8dc77 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
@@ -142,7 +142,7 @@
* This is set to false when that job is completed
*/
boolean resynching = false;
-
+
/**
* Flag to indicate that the disposing job has been scheduled or is running
* (or has been run, in some cases)
@@ -515,6 +515,10 @@
resynch();
filled = true;
}
+
+ public boolean isFilled() {
+ return filled;
+ }
/**
* @see IJpaProject#getJpaFile(IFile)
@@ -577,9 +581,10 @@
* Dispose and remove project
*/
void dispose() {
- if (disposing)
- return;
+ if (disposing) return;
+
disposing = true;
+
Job job = new Job("Disposing JPA project ...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
@@ -590,7 +595,7 @@
job.setRule(project);
job.schedule();
}
-
+
private void dispose_() {
Job.getJobManager().removeJobChangeListener(resynchJobListener);
for (IJpaFile jpaFile : new ArrayList<IJpaFile>(getFiles())) {
@@ -677,9 +682,9 @@
//passing it on to the JpaModel. We don't currently support
//multiple projects having cross-references
public void resynch() {
- if (disposing)
- return;
- if (!resynching) {
+ if (disposing) return;
+
+ if (! resynching) {
this.resynching = true;
this.needsToResynch = false;
this.resynchJob.schedule();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
index fa75d97..8121ca9 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
@@ -38,6 +38,8 @@
public static String INVALID_PERSISTENCE_XML_CONTENT;
+ public static String ERROR_SYNCHRONIZING_CLASSES_COULD_NOT_VALIDATE;
+
public static String ERROR_WRITING_FILE;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
index 4f5b65a..c079b69 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
@@ -10,11 +10,18 @@
package org.eclipse.jpt.core.internal.validation;
import java.util.Iterator;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.JpaModelManager;
+import org.eclipse.jpt.core.internal.JpaProject;
+import org.eclipse.jpt.core.internal.JptCoreMessages;
+import org.eclipse.jpt.core.internal.JptCorePlugin;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.core.ValidatorLauncher;
import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
@@ -34,6 +41,22 @@
JpaHelper jpaHelper = (JpaHelper) helper;
IJpaProject jpaProject = jpaHelper.getJpaProject();
+ if (! ((JpaProject) jpaProject).isFilled()) {
+ try {
+ JpaModelManager.instance().fillJpaProject(jpaProject.getProject());
+ }
+ catch (CoreException ce) {
+ return new Status(Status.ERROR, JptCorePlugin.PLUGIN_ID, JptCoreMessages.ERROR_SYNCHRONIZING_CLASSES_COULD_NOT_VALIDATE, ce);
+ }
+
+ JpaHelper newJpaHelper = new JpaHelper();
+ newJpaHelper.setProject(jpaHelper.getProject());
+ newJpaHelper.setValidationFileURIs(jpaHelper.getValidationFileURIs());
+ ValidatorLauncher.getLauncher().start(newJpaHelper, this, reporter);
+
+ return OK_STATUS;
+ }
+
reporter.removeAllMessages(this);
for (Iterator stream = jpaProject.validationMessages(); stream.hasNext(); ) {