summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-05-10 12:22:36 (EDT)
committerpelder2007-05-10 12:22:36 (EDT)
commitcade5efdc011a713c6489870662ee4d48f98f9b4 (patch)
tree4bb81309bb7e0c6ad4659fb967a95c78f02f3560
parent4aaf3f4d25b5a66ef0bd1c9759b36f7492f733b8 (diff)
downloadorg.eclipse.jet-cade5efdc011a713c6489870662ee4d48f98f9b4.zip
org.eclipse.jet-cade5efdc011a713c6489870662ee4d48f98f9b4.tar.gz
org.eclipse.jet-cade5efdc011a713c6489870662ee4d48f98f9b4.tar.bz2
[186351] JET Project Nature not correctly registered
-rw-r--r--plugins/org.eclipse.jet/plugin.xml9
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2ProjectNature.java125
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2TransformProjectNature.java77
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java4
4 files changed, 136 insertions, 79 deletions
diff --git a/plugins/org.eclipse.jet/plugin.xml b/plugins/org.eclipse.jet/plugin.xml
index 1e37d43..b111c05 100644
--- a/plugins/org.eclipse.jet/plugin.xml
+++ b/plugins/org.eclipse.jet/plugin.xml
@@ -1190,6 +1190,15 @@ if 'length' is specified, convert only the specified number of characters, other
</description>
</transform>
</extension>
+ <extension
+ id="jet2Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.eclipse.jet.internal.builder.JET2ProjectNature">
+ </run>
+ </runtime>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2ProjectNature.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2ProjectNature.java
new file mode 100644
index 0000000..2efe0f4
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2ProjectNature.java
@@ -0,0 +1,125 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * 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:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: JET2ProjectNature.java,v 1.1 2007/05/10 16:22:36 pelder Exp $
+ */
+package org.eclipse.jet.internal.builder;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ListIterator;
+
+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;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jet.JET2Platform;
+
+/**
+ * Project Nature class for JET
+ */
+public class JET2ProjectNature implements IProjectNature
+{
+
+ private static final String JAVA_BUILDER_ID = JavaCore.BUILDER_ID;
+ private static final String JET_BUILDER_ID = JET2Platform.PLUGIN_ID + ".builder"; //$NON-NLS-1$
+ private static final String EMF_JET_BUILDER_ID = "org.eclipse.emf.codegen.JETBuilder"; //$NON-NLS-1$
+
+ private IProject project;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#configure()
+ */
+ public void configure() throws CoreException
+ {
+ IProjectDescription description = project.getDescription();
+ ICommand[] buildSpec = description.getBuildSpec();
+ List buildSpecList = new ArrayList(Arrays.asList(buildSpec));
+
+
+ ICommand jetCommand = description.newCommand();
+ jetCommand.setBuilderName(JET_BUILDER_ID);
+
+ boolean jetCommandAdded = false;
+ for (ListIterator i = buildSpecList.listIterator(); i.hasNext();)
+ {
+ ICommand command = (ICommand)i.next();
+ if(EMF_JET_BUILDER_ID.equals(command.getBuilderName()))
+ {
+ i.remove();
+ } else if(JAVA_BUILDER_ID.equals(command.getBuilderName()))
+ {
+ // back up, insert before this builder...
+ i.previous();
+ i.add(jetCommand);
+ // skip both the newly inserted element, and the Java builder...
+ i.next();
+ jetCommandAdded = true;
+ }
+ }
+
+ if(!jetCommandAdded)
+ {
+ buildSpecList.add(jetCommand);
+ }
+
+
+ description.setBuildSpec((ICommand[])buildSpecList.toArray(new ICommand[buildSpecList.size()]));
+
+ project.setDescription(description, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#deconfigure()
+ */
+ public void deconfigure() throws CoreException
+ {
+ IProjectDescription description = project.getDescription();
+
+ ICommand[] buildSpec = description.getBuildSpec();
+ ICommand[] newBuildSpec = new ICommand[Math.max(0, buildSpec.length)];
+
+ int j = 0;
+ for (int i = 0; i < buildSpec.length; i++)
+ {
+ if(!JET_BUILDER_ID.equals(buildSpec[i]))
+ {
+ newBuildSpec[j++] = buildSpec[i];
+ }
+ }
+
+ description.setBuildSpec(newBuildSpec);
+ project.setDescription(description, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#getProject()
+ */
+ public IProject getProject()
+ {
+ return project;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
+ */
+ public void setProject(IProject project)
+ {
+ this.project = project;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2TransformProjectNature.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2TransformProjectNature.java
deleted file mode 100644
index 6c09626..0000000
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/builder/JET2TransformProjectNature.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * 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:
- * IBM - Initial API and implementation
- *
- * </copyright>
- *
- * $Id$
- * /
- *******************************************************************************/
-
-package org.eclipse.jet.internal.builder;
-
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.runtime.CoreException;
-
-
-/**
- * Implement the JET2 Project Nature
- *
- */
-public class JET2TransformProjectNature implements IProjectNature
-{
-
- /**
- *
- */
- public JET2TransformProjectNature()
- {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IProjectNature#configure()
- */
- public void configure() throws CoreException
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IProjectNature#deconfigure()
- */
- public void deconfigure() throws CoreException
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IProjectNature#getProject()
- */
- public IProject getProject()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
- */
- public void setProject(IProject project)
- {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
index d494d79..aa890db 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
@@ -223,11 +223,11 @@ public class ProjectJETBundleProvider implements IResourceChangeListener, IJETBu
}
catch (MalformedURLException e)
{
- e.printStackTrace();
+ InternalJET2Platform.logError(e.getMessage(), e);
}
catch (IOException e)
{
- e.printStackTrace();
+ // didn't find the manifest, not a problem...
}
catch (NotABundleException e)
{