Author: scabanovich
Date: 2007-07-11 10:53:30 -0400 (Wed, 11 Jul 2007)
New Revision: 2390
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/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
Log:
EXIN-221 natures and build added to new seam project
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-07-11
14:32:54 UTC (rev 2389)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-11
14:53:30 UTC (rev 2390)
@@ -35,7 +35,9 @@
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
-public class SeamCoreBuilder extends IncrementalProjectBuilder {
+public class SeamCoreBuilder extends IncrementalProjectBuilder {
+ public static String BUILDER_ID = "org.jboss.tools.seam.core.seambuilder";
+
static IFileScanner[] FILE_SCANNERS = {
new JavaScanner(),
new XMLScanner(),
@@ -111,8 +113,6 @@
}
}
- public static final String BUILDER_ID =
"org.jboss.tools.seam.core.seam.core";
-
private static final String MARKER_TYPE =
"org.jboss.tools.seam.core.xmlProblem";
private SAXParserFactory parserFactory;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-11
14:32:54 UTC (rev 2389)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-11
14:53:30 UTC (rev 2390)
@@ -20,8 +20,10 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -38,6 +40,7 @@
import org.jboss.tools.seam.core.ISeamScope;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
+import org.jboss.tools.seam.core.SeamCoreBuilder;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.event.Change;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
@@ -79,9 +82,11 @@
public SeamProject() {}
public void configure() throws CoreException {
+ addToBuildSpec(SeamCoreBuilder.BUILDER_ID);
}
public void deconfigure() throws CoreException {
+ removeFromBuildSpec(SeamCoreBuilder.BUILDER_ID);
}
public IProject getProject() {
@@ -633,7 +638,47 @@
fireChanges(changes);
}
-}
-class InnerBuilder {
+ 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];
+ System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
+ newCommands[oldCommands.length] = command;
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+
+ static String EXTERNAL_TOOL_BUILDER =
"org.eclipse.ui.externaltools.ExternalToolBuilder";
+ static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle";
+
+ protected void removeFromBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ String builderName = commands[i].getBuilderName();
+ if (!builderName.equals(builderID)) {
+ if(!builderName.equals(EXTERNAL_TOOL_BUILDER)) continue;
+ Object handle = commands[i].getArguments().get(LAUNCH_CONFIG_HANDLE);
+ if(handle == null || handle.toString().indexOf(builderID) < 0) continue;
+ }
+ ICommand[] newCommands = new ICommand[commands.length - 1];
+ System.arraycopy(commands, 0, newCommands, 0, i);
+ System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ return;
+ }
+ }
+
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-07-11
14:32:54 UTC (rev 2389)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-07-11
14:53:30 UTC (rev 2390)
@@ -37,6 +37,8 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
public class SeamFacetInstallDelegete extends Object implements IDelegate {
@@ -300,6 +302,11 @@
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+
+ //TODO check if template file org.jboss.tools.jst.web.xml is added to .settings
+ EclipseResourceUtil.addNatureToProject(project,
"org.jboss.tools.jsf.jsfnature");
+ EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
+
}
public static void copyFiles(File source, File dest, FileFilter filter) {