Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2008-12-08 19:44:00 +0000
committerpfullbright2008-12-08 19:44:00 +0000
commit9979ddd04df6150fc5222168333fbf67a27c17c1 (patch)
treef1cabfad625faedc81e3113fdc104fe95a669e3f
parentce6183ae87e2c8a56c46a5538b9f0e5b9870ae12 (diff)
downloadwebtools.dali-9979ddd04df6150fc5222168333fbf67a27c17c1.tar.gz
webtools.dali-9979ddd04df6150fc5222168333fbf67a27c17c1.tar.xz
webtools.dali-9979ddd04df6150fc5222168333fbf67a27c17c1.zip
[252891] - moved to v2 validator framework
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/plugin.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/plugin.xml70
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java180
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/TextRange.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml2
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java51
11 files changed, 184 insertions, 178 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.properties b/jpa/plugins/org.eclipse.jpt.core/plugin.properties
index ed3f8e734b..a6057573cb 100644
--- a/jpa/plugins/org.eclipse.jpt.core/plugin.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/plugin.properties
@@ -36,5 +36,6 @@ JPA_PRESET_LABEL=Utility JPA project with Java 5.0
JPA_TEMPLATE_LABEL=JPA Project
JPA_VALIDATOR=JPA Validator
+BASE_JPA_CONTENT = Base JPA Content
ORM_XML_CONTENT = ORM XML Content
PERSISTENCE_XML_CONTENT = Persistence XML Content
diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
index ea984a162f..6b1c46922b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
@@ -51,22 +51,6 @@
<extension
- point="org.eclipse.core.resources.markers"
- id="jpaProblemMarker"
- name="%JPA_PROBLEM_MARKER">
-
- <persistent value="true"/>
-
- <!-- Can't use text marker until we have specific models for each input type (XML, java)
- <super type="org.eclipse.core.resources.textmarker"/>
- -->
-
- <super type="org.eclipse.wst.validation.problemmarker"/>
-
- </extension>
-
-
- <extension
point="org.eclipse.core.runtime.adapters">
<factory
@@ -87,10 +71,19 @@
<extension
point="org.eclipse.core.runtime.contentTypes">
+ <!-- "abstract" content type to be extended by all JPA XML file content types -->
+ <content-type
+ id="org.eclipse.jpt.core.content.baseJpaContent"
+ name="%BASE_JPA_CONTENT"
+ base-type="org.eclipse.core.runtime.xml">
+ <describer
+ class="org.eclipse.jpt.core.internal.resource.IndeterminateContentDescriber"/>
+ </content-type>
+
<content-type
id="org.eclipse.jpt.core.content.orm"
name="%ORM_XML_CONTENT"
- base-type="org.eclipse.core.runtime.xml">
+ base-type="org.eclipse.jpt.core.content.baseJpaContent">
<describer
class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
<parameter
@@ -102,7 +95,7 @@
<content-type
id="org.eclipse.jpt.core.content.persistence"
name="%PERSISTENCE_XML_CONTENT"
- base-type="org.eclipse.core.runtime.xml"
+ base-type="org.eclipse.jpt.core.content.baseJpaContent"
file-names="persistence.xml">
<describer
class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
@@ -253,36 +246,23 @@
<extension
- point="org.eclipse.wst.validation.validator"
+ point="org.eclipse.wst.validation.validatorV2"
id="jpaValidator"
name="%JPA_VALIDATOR">
- <validator>
- <enablement>
- <and>
- <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa"/>
- </and>
- </enablement>
-
- <filter
- objectClass="org.eclipse.core.resources.IFile"
- nameFilter="orm.xml"/>
- <filter
- objectClass="org.eclipse.core.resources.IFile"
- nameFilter="persistence.xml"/>
- <filter
- objectClass="org.eclipse.core.resources.IFile"
- nameFilter="*.java"/>
-
- <run class="org.eclipse.jpt.core.internal.validation.JpaValidator"/>
- <helper class="org.eclipse.jpt.core.internal.validation.JpaHelper"/>
-
- <markerId markerIdValue="jpaProblemMarker"/>
-
- <!-- don't know what this does
- <dependentValidator depValValue="true"/>
- -->
-
+ <validator
+ class="org.eclipse.jpt.core.internal.validation.JpaValidator">
+ <include>
+ <rules>
+ <facet id="jpt.jpa"/>
+ </rules>
+ </include>
+ <include>
+ <rules>
+ <contentType id="org.eclipse.jdt.core.javaSource"/>
+ <contentType id="org.eclipse.jpt.core.content.baseJpaContent" exactMatch="false"/>
+ </rules>
+ </include>
</validator>
</extension>
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 84481494a8..7a20df2b98 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
@@ -9,6 +9,7 @@
################################################################################
NONE=<None>
+VALIDATE_JOB=Validation
VALIDATE_PROJECT_NOT_SPECIFIED=Project must be specified
VALIDATE_SOURCE_FOLDER_NOT_SPECIFIED=Source folder must be specified
VALIDATE_SOURCE_FOLDER_ILLEGAL=Source folder path is illegal
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
index 7ff05f9885..e1f4f492aa 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
@@ -93,7 +93,7 @@ public class JptCorePlugin extends Plugin {
* The identifier for the JPA validation marker
* (value <code>"org.eclipse.jpt.core.jpaProblemMarker"</code>).
*/
- public static final String VALIDATION_MARKER_ID = PLUGIN_ID + ".jpaProblemMarker"; //$NON-NLS-1$
+ public static final String VALIDATOR_ID = PLUGIN_ID + ".jpaValidator"; //$NON-NLS-1$
/**
* Value of the content-type for orm.xml mappings files. Use this value to retrieve
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java
index f5f31e8d77..2d0a331135 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java
@@ -78,6 +78,9 @@ public abstract class AbstractJpaNode
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
+ if (adapter == IResource.class) {
+ return getResource();
+ }
return Platform.getAdapterManager().getAdapter(this, adapter);
}
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 adb0d5bb0f..149c6a2ffc 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
@@ -17,6 +17,7 @@ import org.eclipse.osgi.util.NLS;
public class JptCoreMessages {
public static String NONE;
+ public static String VALIDATE_JOB;
public static String VALIDATE_PROJECT_NOT_SPECIFIED;
public static String VALIDATE_SOURCE_FOLDER_NOT_SPECIFIED;
public static String VALIDATE_SOURCE_FOLDER_ILLEGAL;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java
new file mode 100644
index 0000000000..2017cff129
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Oracle.
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.core.internal.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.ITextContentDescriber;
+
+/**
+ * This class simply returns INDETERMINATE for any contents it receives.
+ *
+ * It is used currently for org.eclipse.jpt.core.content.baseJpaContent in order
+ * to make that content type act as an "abstract" content type.
+ */
+public class IndeterminateContentDescriber implements ITextContentDescriber
+{
+ public int describe(InputStream contents, IContentDescription description) throws IOException {
+ return INDETERMINATE;
+ }
+
+ public int describe(Reader contents, IContentDescription description) throws IOException {
+ return INDETERMINATE;
+ }
+
+ public QualifiedName[] getSupportedOptions() {
+ return new QualifiedName[0];
+ }
+}
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 83c6794a10..308b38030f 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
@@ -13,46 +13,87 @@ import java.util.Iterator;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jpt.core.JpaModel;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
+import org.eclipse.wst.validation.AbstractValidator;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.eclipse.wst.validation.internal.ValConstants;
import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IProjectValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
+import org.eclipse.wst.validation.internal.provisional.core.IValidator;
/**
* This class is referenced in the JPA extension for the
* WTP validator extension point.
*/
-public class JpaValidator implements IValidatorJob {
-
+public class JpaValidator extends AbstractValidator implements IValidator {
+
// ********** IValidator implementation **********
public void validate(IValidationContext context, IReporter reporter) throws ValidationException {
+ validate(reporter, project(context));
+ }
+
+ public void cleanup(IReporter reporter) {
+ // nothing to do
+ }
+
+
+ // **************** AbstractValidator impl *********************************
+
+ @Override
+ public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
+ if (resource.getType() != IResource.FILE)
+ return null;
+ ValidationResult result = new ValidationResult();
+ IReporter reporter = result.getReporter(monitor);
+ IProject project = resource.getProject();
+ try {
+ clearMarkers(project);
+ }
+ catch (CoreException ce) {
+ JptCorePlugin.log(ce);
+ }
+ result.setSuspendValidation(project);
+ validate(reporter, project);
+ return result;
+ }
+
+
+ // **************** internal conv. *****************************************
+
+ private void clearMarkers(IProject project) throws CoreException {
+ IMarker[] markers = project.findMarkers(ValConstants.ProblemMarker, true, IResource.DEPTH_INFINITE);
+ String valId = JptCorePlugin.VALIDATOR_ID;
+ for (IMarker marker : markers) {
+ String id = marker.getAttribute(ValidatorMessage.ValidationId, null);
+ if (valId.equals(id)) marker.delete();
+ }
+ }
+
+ private void validate(IReporter reporter, IProject project) {
reporter.removeAllMessages(this);
-
- for (Iterator<IMessage> stream = this.validationMessages(context); stream.hasNext(); ) {
- reporter.addMessage(this, stream.next());
+
+ for (Iterator<IMessage> stream = this.validationMessages(project); stream.hasNext(); ) {
+ reporter.addMessage(this, adjustMessage(stream.next()));
}
}
-
- private Iterator<IMessage> validationMessages(IValidationContext context) {
- IProject project = ((IProjectValidationContext) context).getProject();
+
+ private IProject project(IValidationContext context) {
+ return ((IProjectValidationContext) context).getProject();
+ }
+
+ private Iterator<IMessage> validationMessages(IProject project) {
JpaProject jpaProject = JptCorePlugin.getJpaProject(project);
if (jpaProject != null) {
return jpaProject.validationMessages();
@@ -64,101 +105,14 @@ public class JpaValidator implements IValidatorJob {
project
));
}
-
- public void cleanup(IReporter reporter) {
- // nothing to do
- }
-
-
- // ********** IValidatorJob implementation **********
-
- public ISchedulingRule getSchedulingRule(IValidationContext context) {
- // don't know what to return here. my guess is that we want to return
- // the resource that is possibly being changed during our validation,
- // and since many resources in the project may be changed during this
- // validation, returning the project makes the most sense.
- return ((IWorkbenchContext) context).getProject();
- }
-
- public IStatus validateInJob(IValidationContext context, IReporter reporter) throws ValidationException {
- if (reporter.isCancelled()) {
- return Status.CANCEL_STATUS;
- }
- this.validate(context, reporter);
- return OK_STATUS;
- }
-
-
- // ********** marker clean-up **********
-
- private static final CollectionChangeListener JPA_MODEL_LISTENER = new LocalCollectionChangeListener();
-
- static {
- JptCorePlugin.getJpaModel().addCollectionChangeListener(JpaModel.JPA_PROJECTS_COLLECTION, JPA_MODEL_LISTENER);
- }
-
- /**
- * When a JPA project is removed this listener will schedule a job to
- * remove all the markers associated with the JPA project.
- */
- private static class LocalCollectionChangeListener implements CollectionChangeListener {
-
- LocalCollectionChangeListener() {
- super();
- }
-
- public void itemsAdded(CollectionChangeEvent event) {
- // ignore
- }
-
- /**
- * For now, we expect JPA projects to be removed one at a time.
- */
- public void itemsRemoved(CollectionChangeEvent event) {
- @SuppressWarnings("unchecked")
- Iterator<JpaProject> items = (Iterator<JpaProject>) event.items();
- Job j = new DeleteMarkersJob(items.next());
- j.schedule();
- if (items.hasNext()) {
- throw new UnsupportedOperationException("unexpected event");
- }
- }
-
- public void collectionCleared(CollectionChangeEvent event) {
- throw new UnsupportedOperationException("unexpected event");
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- throw new UnsupportedOperationException("unexpected event");
- }
-
- }
-
- /**
- * Delete all the markers associated with the specified JPA project.
- */
- private static class DeleteMarkersJob extends Job {
- private final JpaProject jpaProject;
-
- DeleteMarkersJob(JpaProject jpaProject) {
- super("Delete Markers");
- this.jpaProject = jpaProject;
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IProject project = this.jpaProject.getProject();
- if (project.isOpen()) {//no need to remove markers if project has been closed
- try {
- IMarker[] markers = project.findMarkers(JptCorePlugin.VALIDATION_MARKER_ID, true, IResource.DEPTH_INFINITE);
- ResourcesPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- JptCorePlugin.log(ex); // not much else we can do
- }
- }
- return Status.OK_STATUS;
+
+ private IMessage adjustMessage(IMessage message) {
+ IAdaptable targetObject = (IAdaptable) message.getTargetObject();
+ IResource targetResource = (IResource) targetObject.getAdapter(IResource.class);
+ message.setTargetObject(targetResource);
+ if (message.getLineNumber() == IMessage.LINENO_UNSET) {
+ message.setAttribute(IMarker.LOCATION, " ");
}
-
+ return message;
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/TextRange.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/TextRange.java
index 0c6505572b..89295081e5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/TextRange.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/TextRange.java
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.core.utility;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+
/**
* A text range defines the offset into, length of, and line of a piece
* of text.
@@ -74,11 +76,14 @@ public interface TextRange {
private Empty() {
super();
}
+ public int getLineNumber() {
+ return IMessage.LINENO_UNSET;
+ }
public int getOffset() {
- return 0;
+ return IMessage.OFFSET_UNSET;
}
public int getLength() {
- return 0;
+ return IMessage.OFFSET_UNSET;
}
public boolean includes(int index) {
return false;
@@ -86,9 +91,6 @@ public interface TextRange {
public boolean touches(int index) {
return index == 0; // ???
}
- public int getLineNumber() {
- return 0;
- }
@Override
public boolean equals(Object o) {
if (o == this) {
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml
index c2ec232587..afeda14119 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml
@@ -8,7 +8,7 @@
<content-type
id="org.eclipse.jpt.eclipselink.core.content.orm"
name="%ECLIPSELINK_ORM_XML_CONTENT"
- base-type="org.eclipse.core.runtime.xml">
+ base-type="org.eclipse.jpt.core.content.baseJpaContent">
<describer
class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
<parameter
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
index 37f00f3f40..3d61e00c66 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
@@ -16,12 +16,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -36,8 +38,7 @@ import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jpt.core.JpaPlatform;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.internal.validation.JpaHelper;
-import org.eclipse.jpt.core.internal.validation.JpaValidator;
+import org.eclipse.jpt.core.internal.JptCoreMessages;
import org.eclipse.jpt.db.ConnectionProfile;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.connection.Connection;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization;
@@ -46,7 +47,7 @@ import org.eclipse.jpt.eclipselink.core.internal.context.persistence.logging.Log
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.schema.generation.DdlGenerationType;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.schema.generation.OutputMode;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.schema.generation.SchemaGeneration;
-import org.eclipse.wst.validation.internal.operations.ValidatorJob;
+import org.eclipse.wst.validation.ValidationFramework;
/**
* EclipseLinkDLLGenerator launches the EclipseLink DDL generator in a separate VM.
@@ -188,15 +189,10 @@ public class EclipseLinkDDLGenerator
}
protected void validateProject() {
- JpaValidator validator = new JpaValidator();
- IProject project = this.jpaProject.getProject();
- JpaHelper helper = new JpaHelper();
- helper.setProject(project);
-
- ValidatorJob validatorJob = new ValidatorJob(validator, "JPA Validator", "", project, helper);
- validatorJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
- validatorJob.setUser(true);
- validatorJob.schedule();
+ IProject project = this.jpaProject.getProject();
+ ValidateJob job = new ValidateJob(project);
+ job.setRule(project);
+ job.schedule();
}
private IPath buildJdbcJarPath() {
@@ -466,4 +462,33 @@ public class EclipseLinkDDLGenerator
private String buildDebugArgument() {
return (this.isDebug) ? " -debug" : "";
}
+
+
+ /**
+ * Performs validation after tables have been generated
+ */
+ private class ValidateJob extends Job
+ {
+ private IProject project;
+
+
+ public ValidateJob(IProject project) {
+ super(JptCoreMessages.VALIDATE_JOB);
+ this.project = project;
+ }
+
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ ValidationFramework.getDefault().validate(
+ new IProject[] {this.project}, true, false, monitor);
+ }
+ catch (CoreException ce) {
+ status = Status.CANCEL_STATUS;
+ }
+ return status;
+ }
+ }
}

Back to the top