From 733166973d4dc88521555e14d4bb118f62989bbc Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 10 Aug 2012 14:01:13 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4551 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/eclipse/config_wizard/META-INF/MANIFEST.MF | 3 +- tools/eclipse/config_wizard/plugin.xml | 33 ++++++++- .../resources/app_templates/c/template.xml | 82 ++++++++++++++++++++++ .../eclipse/config/handlers/CheckDescription.java | 1 + .../eclipse/config/handlers/GenerateFiles.java | 5 -- .../process/ApplicationGeneratorProcessRunner.java | 37 ++++++++++ .../tools/eclipse/config/utils/TemplateEngine.java | 29 ++++++-- .../wizards/NewApplicationProjectWizard.java | 20 ++++++ .../wizards/NewApplicationProjectWizardPage.java | 24 ++++++- 9 files changed, 216 insertions(+), 18 deletions(-) create mode 100644 tools/eclipse/config_wizard/resources/app_templates/c/template.xml create mode 100644 tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/process/ApplicationGeneratorProcessRunner.java (limited to 'tools') diff --git a/tools/eclipse/config_wizard/META-INF/MANIFEST.MF b/tools/eclipse/config_wizard/META-INF/MANIFEST.MF index 09eb9fe72..c65afaa46 100644 --- a/tools/eclipse/config_wizard/META-INF/MANIFEST.MF +++ b/tools/eclipse/config_wizard/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.ui.console;bundle-version="3.5.100", org.eclipse.ui.ide, org.eclipse.cdt.core;bundle-version="5.4.0", - org.eclipse.cdt.managedbuilder.core;bundle-version="8.1.0" + org.eclipse.cdt.managedbuilder.core;bundle-version="8.1.0", + org.eclipse.cdt.ui;bundle-version="5.4.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: chibios.org diff --git a/tools/eclipse/config_wizard/plugin.xml b/tools/eclipse/config_wizard/plugin.xml index 7098032c8..5e8e23e7d 100644 --- a/tools/eclipse/config_wizard/plugin.xml +++ b/tools/eclipse/config_wizard/plugin.xml @@ -25,7 +25,8 @@ - + @@ -33,7 +34,8 @@ - + + + + + + + + + + + + + + + diff --git a/tools/eclipse/config_wizard/resources/app_templates/c/template.xml b/tools/eclipse/config_wizard/resources/app_templates/c/template.xml new file mode 100644 index 000000000..0bcf782ec --- /dev/null +++ b/tools/eclipse/config_wizard/resources/app_templates/c/template.xml @@ -0,0 +1,82 @@ + + diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/CheckDescription.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/CheckDescription.java index f9e8cd6bf..0d7e7e292 100644 --- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/CheckDescription.java +++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/CheckDescription.java @@ -33,6 +33,7 @@ import org.eclipse.jface.dialogs.MessageDialog; * @see org.eclipse.core.commands.AbstractHandler */ public class CheckDescription extends AbstractHandler { + /** * The constructor. */ diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/GenerateFiles.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/GenerateFiles.java index b29237fb0..aad5adfce 100644 --- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/GenerateFiles.java +++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/handlers/GenerateFiles.java @@ -31,7 +31,6 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; @@ -98,13 +97,10 @@ public class GenerateFiles extends AbstractHandler { /* Calculating derived paths. */ IPath tpath = new Path(templates_path); - IPath libpath = new Path("resources/gencfg/lib"); try { Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); tpath = new Path(FileLocator.toFileURL( FileLocator.find(bundle, tpath, null)).getFile()); - libpath = new Path(FileLocator.toFileURL( - FileLocator.find(bundle, libpath, null)).getFile()); } catch (IOException e) { MessageDialog.openInformation(window.getShell(), "Path Error", e.getMessage()); @@ -114,7 +110,6 @@ public class GenerateFiles extends AbstractHandler { /* Templates execution. */ try { TemplateEngine.process(cfgfilepath.toFile(), - libpath.toFile(), tpath.toFile(), new File(output_path)); } catch (TemplateException e) { diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/process/ApplicationGeneratorProcessRunner.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/process/ApplicationGeneratorProcessRunner.java new file mode 100644 index 000000000..e85442d81 --- /dev/null +++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/process/ApplicationGeneratorProcessRunner.java @@ -0,0 +1,37 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +package org.chibios.tools.eclipse.config.process; + +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.core.runtime.IProgressMonitor; + +public class ApplicationGeneratorProcessRunner extends ProcessRunner { + + @Override + public void process(TemplateCore template, ProcessArgument[] args, + String processId, IProgressMonitor monitor) + throws ProcessFailureException { + + } +} diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/utils/TemplateEngine.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/utils/TemplateEngine.java index 60a33f0e2..ce1e5325a 100644 --- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/utils/TemplateEngine.java +++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/utils/TemplateEngine.java @@ -20,7 +20,6 @@ package org.chibios.tools.eclipse.config.utils; -import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -28,6 +27,10 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; @@ -43,9 +46,12 @@ import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.console.MessageConsole; import org.eclipse.ui.console.MessageConsoleStream; +import org.osgi.framework.Bundle; import org.w3c.dom.Document; import org.xml.sax.SAXException; +import config_wizard.Activator; + import fmpp.Engine; import fmpp.ProcessingException; import fmpp.ProgressListener; @@ -77,8 +83,6 @@ public class TemplateEngine { * * @param xmldata * absolute path to XML data file - * @param libdir - * absolute path to libraries directory * @param sourcedir * absolute path to templates directory * @param outputdir @@ -88,7 +92,6 @@ public class TemplateEngine { * @throws ProcessingException */ public static void process(java.io.File xmldata, - java.io.File libdir, java.io.File sourcedir, java.io.File outputdir) throws TemplateException { @@ -105,6 +108,19 @@ public class TemplateEngine { warn = console.newMessageStream(); warn.setColor(DEFAULT_WARNING); + /* + * Calculates the path for FTL libraries. + */ + IPath libpath = new Path("resources/gencfg/lib"); + Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); + try { + libpath = new Path(FileLocator.toFileURL(FileLocator.find(bundle, libpath, null)).getFile()); + } + catch (IOException e1) { + err.println(": FTL libraries path not found."); + return; + } + /* * Instantiates the FMPP Settings engine and associates a listener for * events to be logged. @@ -169,8 +185,7 @@ public class TemplateEngine { Document dom1, dom_snippets; try { dom1 = db.parse(xmldata); - java.io.File xmlsnippets = new File(libdir.toString() + - "/code_snippets.xml"); + java.io.File xmlsnippets = libpath.addTrailingSeparator().append("code_snippets.xml").toFile(); dom_snippets = db.parse(xmlsnippets); } catch (SAXException e) { throw new TemplateException(e.getMessage()); @@ -191,7 +206,7 @@ public class TemplateEngine { /* Setting libraries path. */ HashMap libs = new HashMap(); - libs.put("lib", libdir.toString()); + libs.put("lib", libpath.toString()); /* Other settings. */ try { diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java index f2488b74b..b94df01cc 100644 --- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java +++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java @@ -1,3 +1,23 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + package org.chibios.tools.eclipse.config.wizards; import java.lang.reflect.InvocationTargetException; diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java index 5513bc5bf..b2daabeac 100644 --- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java +++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java @@ -1,3 +1,23 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + package org.chibios.tools.eclipse.config.wizards; import java.io.File; @@ -35,7 +55,6 @@ import config_wizard.Activator; public class NewApplicationProjectWizardPage extends WizardPage { - private ISelection selection; private Composite container; private Text projectParentPathText; private Button btnBrowse; @@ -55,7 +74,6 @@ public class NewApplicationProjectWizardPage extends WizardPage { super("wizardPage"); setTitle("ChibiOS/RT New Application Project Wizard"); setDescription("This wizard creates a new ChibiOS/RT application project."); - this.selection = selection; } /** @@ -200,7 +218,7 @@ public class NewApplicationProjectWizardPage extends WizardPage { /* Update checks on the fields.*/ projectPageUpdated(); - + /* Focus on the first editable field.*/ projectNameText.setFocus(); } -- cgit v1.2.3