From: Atanas Gegov <atanas.ge...@bmw-carit.de>

Renamed the NewYoctoProjectPostProcess to
NewYoctoAutotoolsProjectPostProcess as it is actually
relevant for Autotools-based projects. Added a check
for the apropriate project nature in the the "process"
method of NewYoctoAutotoolsProjectPostProcess.
---
 plugins/org.yocto.sdk.ide/plugin.xml               |    4 +-
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |    2 +
 .../NewYoctoAutotoolsProjectPostProcess.java       |   77 ++++++++++++++++++++
 .../sdk/ide/wizard/NewYoctoProjectPostProcess.java |   73 -------------------
 .../HelloWorldCAutotoolsProject/template.xml       |    2 +-
 .../HelloWorldCGTKAutotoolsProject/template.xml    |    2 +-
 .../HelloWorldCPPAutotoolsProject/template.xml     |    2 +-
 7 files changed, 84 insertions(+), 78 deletions(-)
 create mode 100644 
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java
 delete mode 100644 
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java

diff --git a/plugins/org.yocto.sdk.ide/plugin.xml 
b/plugins/org.yocto.sdk.ide/plugin.xml
index 6e378bd..1b882a2 100644
--- a/plugins/org.yocto.sdk.ide/plugin.xml
+++ b/plugins/org.yocto.sdk.ide/plugin.xml
@@ -164,8 +164,8 @@
          </simple>
       </processType>
       <processType
-            name="NewYoctoProjectPostProcess"
-            
processRunner="org.yocto.sdk.ide.wizard.NewYoctoProjectPostProcess">
+            name="NewYoctoAutotoolsProjectPostProcess"
+            
processRunner="org.yocto.sdk.ide.wizard.NewYoctoAutotoolsProjectPostProcess">
          <simple
                name="projectName">
          </simple>
diff --git 
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties 
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 780bc90..67087f0 100644
--- 
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ 
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
@@ -98,3 +98,5 @@ LaunchConfig.BuildScope.Attr = 
org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGUR
 LaunchConfig.BuildScope.Value = ${projects:}
 LaunchConfig.Location.Attr = org.eclipse.ui.externaltools.ATTR_LOCATION
 LaunchConfig.Arguments.Attr = org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS;
+
+AutotoolsProjectPostProcess.WrongProjectNature = {0} is not an Autotools 
project
diff --git 
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java
 
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java
new file mode 100644
index 0000000..9bc042a
--- /dev/null
+++ 
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Intel Corporation.
+ * 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:
+ * Intel - initial API and implementation
+ 
*******************************************************************************/
+package org.yocto.sdk.ide.wizard;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+import org.eclipse.cdt.core.templateengine.process.processes.Messages;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.natures.YoctoSDKAutotoolsProjectNature;
+
+public class NewYoctoAutotoolsProjectPostProcess extends ProcessRunner {
+
+       public NewYoctoAutotoolsProjectPostProcess() {}
+
+       public void process(TemplateCore template, ProcessArgument[] args, 
String processId, IProgressMonitor monitor) throws ProcessFailureException {
+
+               String projectName = args[0].getSimpleValue();
+
+               IProject project = 
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+               try {
+                       if (!project.exists()) {
+                               throw new 
ProcessFailureException(Messages.getString("NewManagedProject.4") + 
projectName); //$NON-NLS-1$
+                       } else if 
(!project.hasNature(YoctoSDKAutotoolsProjectNature.YoctoSDK_AUTOTOOLS_NATURE_ID))
 {
+                               throw new 
ProcessFailureException(Messages.getString("NewManagedProject.3") + 
//$NON-NLS-1$
+                                               
YoctoSDKMessages.getFormattedString("AutotoolsProjectPostProcess.WrongProjectNature",
 //$NON-NLS-1$
+                                                               projectName));
+                       } else {
+                               IPath path = project.getLocation();
+                               String path_str = path.toString();
+                               String autogen_cmd = "chmod +x " + path_str + 
"/autogen.sh";
+                               try {
+                                       Runtime rt = Runtime.getRuntime();
+                                       Process proc = rt.exec(autogen_cmd);
+                                       InputStream stdin = 
proc.getInputStream();
+                                       InputStreamReader isr = new 
InputStreamReader(stdin);
+                                       BufferedReader br = new 
BufferedReader(isr);
+                                       String line = null;
+                                       String error_message = "";
+
+                                       while ( (line = br.readLine()) != null) 
{
+                                               error_message = error_message + 
line;
+                                       }
+
+                                       int exitVal = proc.waitFor();
+                                       if (exitVal != 0) {
+                                               throw new 
ProcessFailureException("Failed to make autogen.sh executable for project: " + 
projectName);
+                                       }
+                               } catch (Throwable t) {
+                                       t.printStackTrace();
+
+                               }
+                       }
+               }
+               catch (Exception e)
+               {
+                       throw new 
ProcessFailureException(Messages.getString("NewManagedProject.3") + 
e.getMessage(), e); //$NON-NLS-1$
+               }
+       }
+}
diff --git 
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java
 
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java
deleted file mode 100644
index d028ee6..0000000
--- 
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Intel Corporation.
- * 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:
- * Intel - initial API and implementation
- 
*******************************************************************************/
-package org.yocto.sdk.ide.wizard;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.eclipse.cdt.core.templateengine.TemplateCore;
-import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
-import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
-import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
-import org.eclipse.cdt.core.templateengine.process.processes.Messages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-@SuppressWarnings("restriction")
-public class NewYoctoProjectPostProcess extends ProcessRunner {
-       
-       public NewYoctoProjectPostProcess() {}
-       
-       public void process(TemplateCore template, ProcessArgument[] args, 
String processId, IProgressMonitor monitor) throws ProcessFailureException {
-
-               String projectName = args[0].getSimpleValue();
-               
-               IProject project = 
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-               try {
-                       if (!project.exists()) {
-                                       throw new 
ProcessFailureException(Messages.getString("NewManagedProject.4") + 
projectName); //$NON-NLS-1$
-                               } else {
-                                       IPath path = project.getLocation();
-                                       String path_str = path.toString();
-                                       String autogen_cmd = "chmod +x " + 
path_str + "/autogen.sh";
-                                       try {
-                                               Runtime rt = 
Runtime.getRuntime();
-                                               Process proc = 
rt.exec(autogen_cmd);
-                                               InputStream stdin = 
proc.getInputStream();
-                                               InputStreamReader isr = new 
InputStreamReader(stdin);
-                                               BufferedReader br = new 
BufferedReader(isr);
-                                               String line = null;
-                                               String error_message = "";
-                                               
-                                               while ( (line = br.readLine()) 
!= null) {
-                                                       error_message = 
error_message + line;
-                                               }
-                                               
-                                               int exitVal = proc.waitFor();
-                                               if (exitVal != 0) {
-                                                       throw new 
ProcessFailureException("Failed to make autogen.sh executable for project: " + 
projectName);
-                                               } 
-                                       } catch (Throwable t) {
-                                               t.printStackTrace();
-                                               
-                                       }
-                               }
-               }
-               catch (Exception e)
-               {
-                       throw new 
ProcessFailureException(Messages.getString("NewManagedProject.3") + 
e.getMessage(), e); //$NON-NLS-1$
-               } 
-       }
-}
diff --git 
a/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCAutotoolsProject/template.xml
 
b/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCAutotoolsProject/template.xml
index 7693080..70c9910 100644
--- 
a/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCAutotoolsProject/template.xml
+++ 
b/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCAutotoolsProject/template.xml
@@ -135,7 +135,7 @@
         </complex-array>
        </process>
 
-       <process type="org.yocto.sdk.ide.NewYoctoProjectPostProcess">
+       <process type="org.yocto.sdk.ide.NewYoctoAutotoolsProjectPostProcess">
                <simple name="projectName" value="$(projectName)" /> 
        </process>
 
diff --git 
a/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCGTKAutotoolsProject/template.xml
 
b/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCGTKAutotoolsProject/template.xml
index d55a904..8933add 100644
--- 
a/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCGTKAutotoolsProject/template.xml
+++ 
b/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCGTKAutotoolsProject/template.xml
@@ -135,7 +135,7 @@
         </complex-array>
        </process>
 
-       <process type="org.yocto.sdk.ide.NewYoctoProjectPostProcess">
+       <process type="org.yocto.sdk.ide.NewYoctoAutotoolsProjectPostProcess">
                <simple name="projectName" value="$(projectName)" /> 
        </process>
 </template>
diff --git 
a/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCPPAutotoolsProject/template.xml
 
b/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCPPAutotoolsProject/template.xml
index 83e6fda..9d1914c 100644
--- 
a/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCPPAutotoolsProject/template.xml
+++ 
b/plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCPPAutotoolsProject/template.xml
@@ -135,7 +135,7 @@
         </complex-array>
        </process>
 
-       <process type="org.yocto.sdk.ide.NewYoctoProjectPostProcess">
+       <process type="org.yocto.sdk.ide.NewYoctoAutotoolsProjectPostProcess">
                <simple name="projectName" value="$(projectName)" /> 
        </process>
 </template>
-- 
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to