Author: scabanovich
Date: 2007-10-22 08:05:35 -0400 (Mon, 22 Oct 2007)
New Revision: 4405
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamRuntimeValidation.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
JBIDE-982
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2007-10-22 11:58:56 UTC (rev
4404)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2007-10-22 12:05:35 UTC (rev
4405)
@@ -282,7 +282,8 @@
id="seamProblem"
name="Seam Problem"
point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.wst.validation.problemmarker"/>
+ <super type="org.eclipse.wst.validation.problemmarker"/>
+ <attribute name="kind"/>
<persistent
value="true">
</persistent>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-10-22
11:58:56 UTC (rev 4404)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-10-22
12:05:35 UTC (rev 4405)
@@ -26,6 +26,7 @@
import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
import org.jboss.tools.seam.internal.core.scanner.lib.LibraryScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
+import org.jboss.tools.seam.internal.core.validation.SeamRuntimeValidation;
public class SeamCoreBuilder extends IncrementalProjectBuilder {
public static String BUILDER_ID = "org.jboss.tools.seam.core.seambuilder";
//$NON-NLS-1$
@@ -85,7 +86,9 @@
if(sp.getClassPath().update()) {
sp.getClassPath().process();
}
-
+
+ new SeamRuntimeValidation().validate(sp);
+
if (kind == FULL_BUILD) {
fullBuild(monitor);
} else {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-10-22
11:58:56 UTC (rev 4404)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-10-22
12:05:35 UTC (rev 4405)
@@ -18,11 +18,14 @@
import java.util.Map;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreferenceInitializer;
+import org.jboss.tools.seam.internal.core.validation.SeamRuntimeValidation;
/**
* @author eskimo
@@ -36,6 +39,8 @@
private SeamRuntime defaultRt = null;
+ private SeamRuntimeValidation validator = new SeamRuntimeValidation();
+
/**
*
*/
@@ -100,6 +105,7 @@
}
runtimes.put(runtime.getName(),runtime);
save();
+ validateProjects();
}
/**
@@ -136,6 +142,7 @@
*/
public void removeRuntime(SeamRuntime rt) {
runtimes.remove(rt.getName());
+ validateProjects();
}
/**
@@ -193,4 +200,18 @@
}
return result;
}
+
+ private void validateProjects() {
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0; i < ps.length; i++) {
+ ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
+ if(sp == null) continue;
+ try {
+ validator.validate(sp);
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-10-22
11:58:56 UTC (rev 4404)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-10-22
12:05:35 UTC (rev 4405)
@@ -139,6 +139,11 @@
factory.setValue(new XMLValueInfo(os[i], "value")); //$NON-NLS-1$
factory.setMethod(new XMLValueInfo(os[i], "method")); //$NON-NLS-1$
ds.getFactories().add(factory);
+ } else if(os[i].getModelEntity().getName().startsWith("SeamImport")) {
//$NON-NLS-1$
+ String v = os[i].getAttributeValue("import");
+ if(v != null && v.length() > 0 && !ds.getImports().contains(v)) {
+ ds.getImports().add(v);
+ }
}
}
return ds;
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamRuntimeValidation.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamRuntimeValidation.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamRuntimeValidation.java 2007-10-22
12:05:35 UTC (rev 4405)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamRuntimeValidation {
+ static final String TYPE = "org.jboss.tools.seam.core.seamProblem";
+ static final String ATTR_KIND = "kind";
+ static final String RUNTIME_KIND = "SeamRuntimeProblem";
+
+ public SeamRuntimeValidation() {}
+
+ public void validate(ISeamProject project) throws CoreException {
+ IMarker marker = findErrorMarker(project);
+ String runtimeName = project.getRuntimeName();
+ SeamRuntime runtime = project.getRuntime();
+ if(runtime != null || runtimeName == null || runtimeName.length() == 0) {
+ if(marker == null) return;
+ removeMarker(marker);
+ return;
+ }
+ String message = "Seam runtime " + runtimeName + " does not
exist.";
+ if(marker != null) {
+ if(message.equals(marker.getAttribute(IMarker.MESSAGE, null))) {
+ return;
+ }
+ marker.setAttribute(IMarker.MESSAGE, message);
+ } else {
+ createMarker(project, message);
+ }
+ }
+
+ private IMarker findErrorMarker(ISeamProject project) throws CoreException {
+ IMarker[] ms = project.getProject().findMarkers(TYPE, true, IResource.DEPTH_ZERO);
+ if(ms == null) return null;
+ for (int i = 0; i < ms.length; i++) {
+ int s = ms[i].getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ if(s != IMarker.SEVERITY_WARNING) continue;
+ String kind = ms[i].getAttribute(ATTR_KIND, null);
+ if(kind == null) continue;
+ if(kind.equals(RUNTIME_KIND)) {
+ return ms[i];
+ }
+ }
+ return null;
+ }
+
+ private void removeMarker(final IMarker marker) {
+ IWorkspaceRunnable r = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ marker.delete();
+ }
+ };
+ run(r);
+ }
+
+ private void createMarker(final ISeamProject project, final String message) throws
CoreException {
+ IWorkspaceRunnable r = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ doCreateMarker(project, message);
+ }
+ };
+ run(r);
+ }
+
+ private void doCreateMarker(ISeamProject project, String message) throws CoreException
{
+ IMarker marker = project.getProject().createMarker(TYPE);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+ marker.setAttribute(IMarker.MESSAGE, message);
+ marker.setAttribute(ATTR_KIND, RUNTIME_KIND);
+ }
+
+ private void run(IWorkspaceRunnable r) {
+ try {
+ ResourcesPlugin.getWorkspace().run(r, null,IWorkspace.AVOID_UPDATE, null);
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
+}