Author: akazakov
Date: 2011-05-30 12:47:09 -0400 (Mon, 30 May 2011)
New Revision: 31640
Added:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/plugin.xml
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.classpath
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.project
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/bin/
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/src/
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/BuilderTest.java
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestBuilder.java
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestNature.java
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebModelPlugin.java
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamUtil.java
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
Log:
https://issues.jboss.org/browse/JBIDE-9021 Fixed
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF 2011-05-30
16:47:09 UTC (rev 31640)
@@ -23,7 +23,8 @@
org.eclipse.equinox.preferences,
org.eclipse.wst.sse.core,
org.eclipse.jdt.ui,
- org.apache.ant
+ org.apache.ant,
+ org.jboss.tools.jst.web
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -55,13 +55,13 @@
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.jboss.tools.cdi.internal.core.impl.ClassBean;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.common.zip.UnzipOperation;
+import org.jboss.tools.jst.web.WebModelPlugin;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.osgi.framework.Bundle;
@@ -83,8 +83,7 @@
if (!project.hasNature(IKbProject.NATURE_ID)) {
EclipseResourceUtil.addNatureToProject(project, IKbProject.NATURE_ID);
}
- EclipseUtil.addNatureToProject(project, CDICoreNature.NATURE_ID);
- EclipseResourceUtil.addBuilderToProject(project,
ValidationPlugin.VALIDATION_BUILDER_ID);
+ WebModelPlugin.addNatureToProjectWithValidationSupport(project,
CDICoreBuilder.BUILDER_ID, CDICoreNature.NATURE_ID);
if(genearteBeansXml) {
File beansXml = getBeansXml(project);
if(beansXml!=null && !beansXml.exists()) {
Modified:
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF 2011-05-30
16:47:09 UTC (rev 31640)
@@ -21,7 +21,8 @@
org.eclipse.ltk.core.refactoring,
org.eclipse.jst.jsp.core,
org.eclipse.jst.j2ee.core;bundle-version="1.1.300",
- org.eclipse.wst.common.project.facet.core;bundle-version="1.4.0"
+ org.eclipse.wst.common.project.facet.core;bundle-version="1.4.0",
+ org.eclipse.wst.validation;bundle-version="1.2.201"
Bundle-Version: 3.2.1.qualifier
Export-Package:
org.jboss.tools.jst.web,
Modified:
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebModelPlugin.java
===================================================================
---
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebModelPlugin.java 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebModelPlugin.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -13,6 +13,9 @@
import java.util.Iterator;
import java.util.Properties;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
@@ -20,6 +23,7 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
import org.jboss.tools.common.model.XModel;
@@ -116,4 +120,114 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+
+ private final static String JAVA_BUILDER_ID =
"org.eclipse.jdt.core.javabuilder"; //$NON-NLS-1$
+
+ /**
+ * Adds the nature/builder to the project. Also adds WST validation builder. Sort
Java, WST and the new builder in the following order: Java, WST, the new builder.
+ * @param project
+ * @param builderId
+ * @param natureId
+ * @throws CoreException
+ */
+ public static void addNatureToProjectWithValidationSupport(IProject project, String
builderId, String natureId) throws CoreException {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] existing = desc.getBuildSpec();
+ boolean updated = false;
+ int javaBuilderIndex = -1;
+ ICommand javaBuilder = null;
+ int wstValidationBuilderIndex = -1;
+ ICommand wstValidationBuilder = null;
+ int builderIndex = -1;
+ ICommand builder = null;
+ for (int i = 0; i < existing.length; i++) {
+ if(JAVA_BUILDER_ID.equals(existing[i].getBuilderName())) {
+ javaBuilderIndex = i;
+ javaBuilder = existing[i];
+ } else
if(ValidationPlugin.VALIDATION_BUILDER_ID.equals(existing[i].getBuilderName())) {
+ wstValidationBuilderIndex = i;
+ wstValidationBuilder = existing[i];
+ } else if(builderId.equals(existing[i].getBuilderName())) {
+ builderIndex = i;
+ builder = existing[i];
+ }
+ }
+
+ if(javaBuilderIndex==-1) {
+ getDefault().logError("Can't enable " + builderId + " support on
the project " + project.getName() + " without Java builder.");
//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ return;
+ }
+
+ if(wstValidationBuilderIndex!=-1 &&
wstValidationBuilderIndex<javaBuilderIndex) {
+ existing[javaBuilderIndex] = wstValidationBuilder;
+ existing[wstValidationBuilderIndex] = javaBuilder;
+ int oldWstIndex = wstValidationBuilderIndex;
+ wstValidationBuilderIndex = javaBuilderIndex;
+ javaBuilderIndex = oldWstIndex;
+ updated = true;
+ }
+
+ if(builderIndex==-1) {
+ if(updated) {
+ desc.setBuildSpec(existing);
+ project.setDescription(desc, null);
+ updated = false;
+ }
+ EclipseResourceUtil.addNatureToProject(project, natureId);
+ desc = project.getDescription();
+ existing = desc.getBuildSpec();
+ builderIndex = existing.length-1;
+ builder = getBuilder(project, builderId);
+ }
+
+ if(wstValidationBuilderIndex==-1) {
+ existing = appendBuilder(project, existing,
ValidationPlugin.VALIDATION_BUILDER_ID);
+ wstValidationBuilderIndex = existing.length-1;
+ wstValidationBuilder = existing[wstValidationBuilderIndex];
+ updated = true;
+ }
+
+ if(wstValidationBuilderIndex<builderIndex) {
+ existing[wstValidationBuilderIndex] = builder;
+ existing[builderIndex] = wstValidationBuilder;
+ int oldWstIndex = wstValidationBuilderIndex;
+ wstValidationBuilderIndex = builderIndex;
+ builderIndex = oldWstIndex;
+ updated = true;
+ }
+
+ if(builderIndex<javaBuilderIndex) {
+ existing[javaBuilderIndex] = builder;
+ existing[builderIndex] = javaBuilder;
+ int oldJavaIndex = javaBuilderIndex;
+ javaBuilderIndex = builderIndex;
+ builderIndex = oldJavaIndex;
+ updated = true;
+ }
+
+ if(updated) {
+ desc.setBuildSpec(existing);
+ project.setDescription(desc, null);
+ }
+ }
+
+ private static ICommand getBuilder(IProject project, String builderId) throws
CoreException {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] existing = desc.getBuildSpec();
+ for (ICommand command : existing) {
+ if(builderId.equals(command.getBuilderName())) {
+ return command;
+ }
+ }
+ return null;
+ }
+
+ private static ICommand[] appendBuilder(IProject project, ICommand[] commands, String
builderId) throws CoreException {
+ ICommand[] cmds = new ICommand[commands.length + 1];
+ ICommand newcmd = project.getDescription().newCommand();
+ newcmd.setBuilderName(builderId);
+ cmds[commands.length] = newcmd;
+ System.arraycopy(commands, 0, cmds, 0, commands.length);
+ return cmds;
+ }
}
\ No newline at end of file
Modified:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF 2011-05-30
16:47:09 UTC (rev 31640)
@@ -1,12 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
-Bundle-SymbolicName: org.jboss.tools.jst.web.test
+Bundle-SymbolicName: org.jboss.tools.jst.web.test;singleton:=true
Bundle-Version: 3.2.0.qualifier
Require-Bundle: org.jboss.tools.jst.web,
org.junit,
org.jboss.tools.tests,
- org.eclipse.jst.standard.schemas
+ org.eclipse.jst.standard.schemas,
+ org.eclipse.ui,
+ org.eclipse.wst.validation
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.jst.web.test
Added: branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/plugin.xml
===================================================================
--- branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/plugin.xml
(rev 0)
+++ branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/plugin.xml 2011-05-30
16:47:09 UTC (rev 31640)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ id="testbuilder"
+ name="JBoss Tools JST Test Builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ hasNature="false">
+ <run
+ class="org.jboss.tools.jst.web.test.TestBuilder">
+ </run>
+ </builder>
+ </extension>
+ <extension
+ id="testnature"
+ name="JBoss Tools JST Test Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.jboss.tools.jst.web.test.TestNature">
+ </run>
+ </runtime>
+ <builder
+ id="org.jboss.tools.jst.web.test.testbuilder">
+ </builder>
+ </extension>
+</plugin>
\ No newline at end of file
Property changes on:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.classpath
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.classpath
(rev 0)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.classpath 2011-05-30
16:47:09 UTC (rev 31640)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.project
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.project
(rev 0)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.project 2011-05-30
16:47:09 UTC (rev 31640)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>testProject</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/projects/testProject/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/BuilderTest.java
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/BuilderTest.java
(rev 0)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/BuilderTest.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.jst.web.test;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.jst.web.WebModelPlugin;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class BuilderTest extends TestCase {
+
+ private static final String PLUGIN_ID = "org.jboss.tools.jst.web.test";
+ private static final String PROJECT_PATH = "/projects/testProject";
+ private static final String JAVA_BUILDER_ID =
"org.eclipse.jdt.core.javabuilder"; //$NON-NLS-1$
+
+ protected IProject project;
+
+ @Override
+ protected void setUp() throws Exception {
+ project = ResourcesUtils.importProject(PLUGIN_ID, PROJECT_PATH);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ResourcesUtils.deleteProject(project.getName());
+ JobUtils.waitForIdle();
+ }
+
+ public void testJavaProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ assertEquals(1, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(JAVA_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testJavaWstProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ addBuilderToProject(false, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ assertEquals(2, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testWstJavaProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ addBuilderToProject(true, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ assertEquals(2, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(JAVA_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testJavaTestProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ assertEquals(2, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(TestBuilder.ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testTestJavaProject() throws Exception {
+ TestNature.APPEND_BUILDER = false;
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ assertEquals(2, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(TestBuilder.ID));
+ assertEquals(1, getBuilderIndex(JAVA_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testJavaWstTestProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ addBuilderToProject(false, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+ assertEquals(2, getBuilderIndex(TestBuilder.ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testWstJavaTestProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ addBuilderToProject(true, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(2, getBuilderIndex(TestBuilder.ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testTestJavaWstProject() throws Exception {
+ TestNature.APPEND_BUILDER = false;
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ addBuilderToProject(false, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(TestBuilder.ID));
+ assertEquals(1, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(2, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testWstTestJavaProject() throws Exception {
+ TestNature.APPEND_BUILDER = false;
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ addBuilderToProject(true, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(TestBuilder.ID));
+ assertEquals(2, getBuilderIndex(JAVA_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testTestWstJavaProject() throws Exception {
+ TestNature.APPEND_BUILDER = false;
+ addBuilderToProject(true, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(TestBuilder.ID));
+ assertEquals(1, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+ assertEquals(2, getBuilderIndex(JAVA_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void testJavaTestWstProject() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ EclipseUtil.addNatureToProject(project, TestNature.ID);
+ addBuilderToProject(false, project, ValidationPlugin.VALIDATION_BUILDER_ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(TestBuilder.ID));
+ assertEquals(2, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+
+ asserBuilderOrder();
+ }
+
+ public void asserBuilderOrder() throws Exception {
+ TestNature.APPEND_BUILDER = true;
+ WebModelPlugin.addNatureToProjectWithValidationSupport(project, TestBuilder.ID,
TestNature.ID);
+ assertEquals(3, getBuilderNumbers());
+ assertEquals(0, getBuilderIndex(JAVA_BUILDER_ID));
+ assertEquals(1, getBuilderIndex(TestBuilder.ID));
+ assertEquals(2, getBuilderIndex(ValidationPlugin.VALIDATION_BUILDER_ID));
+ }
+
+ public static void addBuilderToProject(boolean beginning, IProject project, String
builderId) throws CoreException {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] existing = desc.getBuildSpec();
+ ICommand[] cmds = new ICommand[existing.length + 1];
+ ICommand newcmd = project.getDescription().newCommand();
+ newcmd.setBuilderName(builderId);
+ if(beginning) {
+ cmds[0] = newcmd;
+ System.arraycopy(existing, 0, cmds, 1, existing.length );
+ } else {
+ cmds[existing.length] = newcmd;
+ System.arraycopy(existing, 0, cmds, 0, existing.length);
+ }
+ desc.setBuildSpec(cmds);
+ project.setDescription(desc, null);
+ }
+
+ public int getBuilderIndex(String builderId) throws CoreException {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] commands = desc.getBuildSpec();
+ for (int i = 0; i < commands.length; i++) {
+ if(builderId.equals(commands[i].getBuilderName())) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int getBuilderNumbers() throws CoreException {
+ IProjectDescription desc = project.getDescription();
+ return desc.getBuildSpec().length;
+ }
+}
\ No newline at end of file
Property changes on:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/BuilderTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -18,6 +18,7 @@
public static Test suite() {
TestSuite suite = new TestSuite(JstWebAllTests.class.getName());
suite.addTestSuite(WebContentAssistProviderTest.class);
+ suite.addTestSuite(BuilderTest.class);
return suite;
}
}
\ No newline at end of file
Added:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestBuilder.java
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestBuilder.java
(rev 0)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestBuilder.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.test;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class TestBuilder extends IncrementalProjectBuilder {
+
+ public static final String ID = "org.jboss.tools.jst.web.test.testbuilder";
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map,
org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IProject[] build(int arg0, Map arg1, IProgressMonitor arg2)
+ throws CoreException {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestBuilder.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestNature.java
===================================================================
---
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestNature.java
(rev 0)
+++
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestNature.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.jst.web.test;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class TestNature implements IProjectNature {
+
+ IProject project;
+ static String ID = "org.jboss.tools.jst.web.test.testnature";
+ static boolean APPEND_BUILDER = true;
+
+ public void configure() throws CoreException {
+ addToBuildSpec(TestBuilder.ID);
+ }
+
+ public void deconfigure() throws CoreException {
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ protected void addToBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand command = null;
+ ICommand commands[] = description.getBuildSpec();
+ for (int i = 0; i < commands.length && command == null; ++i) {
+ if (commands[i].getBuilderName().equals(builderID))
+ command = commands[i];
+ }
+ if (command == null) {
+ command = description.newCommand();
+ command.setBuilderName(builderID);
+ ICommand[] oldCommands = description.getBuildSpec();
+ ICommand[] newCommands = new ICommand[oldCommands.length + 1];
+
+ if(APPEND_BUILDER) {
+ System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
+ newCommands[oldCommands.length] = command;
+ } else {
+ System.arraycopy(oldCommands, 0, newCommands, 1, oldCommands.length);
+ newCommands[0] = command;
+ }
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
branches/jbosstools-3.2.x/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/TestNature.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamUtil.java
===================================================================
---
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamUtil.java 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamUtil.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -20,6 +20,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaProject;
@@ -36,6 +37,8 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ITextSourceReference;
+import org.jboss.tools.jst.web.WebModelPlugin;
+import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.internal.core.AbstractContextVariable;
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
@@ -45,6 +48,22 @@
*/
public class SeamUtil {
+ public static void enableSeamSupport(IProject project) {
+ if(project==null) {
+ return;
+ }
+ try {
+// EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
+ if(!project.hasNature(IKbProject.NATURE_ID)) {
+ EclipseResourceUtil.addNatureToProject(project, IKbProject.NATURE_ID);
+ }
+// EclipseResourceUtil.addBuilderToProject(project,
ValidationPlugin.VALIDATION_BUILDER_ID);
+ WebModelPlugin.addNatureToProjectWithValidationSupport(project,
SeamCoreBuilder.BUILDER_ID, ISeamProject.NATURE_ID);
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
/**
* Returns Seam version from <Seam
Runtime>/lib/jboss-seam.jar/META-INF/MANIFEST.MF
* from Seam Runtime which is set for the project.
Modified:
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
===================================================================
---
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2011-05-30
16:17:53 UTC (rev 31639)
+++
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2011-05-30
16:47:09 UTC (rev 31640)
@@ -53,14 +53,12 @@
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.ui.IValidator;
import org.jboss.tools.common.ui.preferences.SettingsPage;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditorFactory;
import org.jboss.tools.common.ui.wizard.IParameter;
-import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamProjectsSet;
@@ -758,8 +756,8 @@
@Override
public boolean performOk() {
if (isSeamSupported()) {
- addSeamSupport(project);
- addSeamSupport(warProject);
+ SeamUtil.enableSeamSupport(project);
+ SeamUtil.enableSeamSupport(warProject);
if (warProject != null) {
IEclipsePreferences prefs = SeamCorePlugin.getSeamPreferences(warProject);
prefs.putBoolean(ISeamFacetDataModelProperties.SEAM_SETTINGS_CHANGED_BY_USER, true);
@@ -957,21 +955,6 @@
}
}
- private void addSeamSupport(IProject project) {
- if(project==null) {
- return;
- }
- try {
- EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
- if(!project.hasNature(IKbProject.NATURE_ID)) {
- EclipseResourceUtil.addNatureToProject(project, IKbProject.NATURE_ID);
- }
- EclipseResourceUtil.addBuilderToProject(project,
ValidationPlugin.VALIDATION_BUILDER_ID);
- } catch (CoreException e) {
- SeamGuiPlugin.getPluginLog().logError(e);
- }
- }
-
private SeamVersion[] getSeamVersions() {
// Let's allow user to select any available seam version regardless of installed
seam facet. But we should warn user if he selects different versions of facet and seam
runtime.
return SeamVersion.ALL_VERSIONS;