diff --git a/tools/eclipse/config_wizard/META-INF/MANIFEST.MF b/tools/eclipse/config_wizard/META-INF/MANIFEST.MF
index fb3d848cd..6b14e432e 100644
--- a/tools/eclipse/config_wizard/META-INF/MANIFEST.MF
+++ b/tools/eclipse/config_wizard/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ChibiOS-RT_Configuration_Support
Bundle-SymbolicName: org.chibios.tools.eclipse.config;singleton:=true
-Bundle-Version: 1.0.4
+Bundle-Version: 1.1.0
Bundle-Activator: config_wizard.Activator
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
diff --git a/tools/eclipse/config_wizard/build.properties b/tools/eclipse/config_wizard/build.properties
index 05b402447..81715159f 100644
--- a/tools/eclipse/config_wizard/build.properties
+++ b/tools/eclipse/config_wizard/build.properties
@@ -32,4 +32,5 @@ bin.includes = plugin.xml,\
resources/gencfg/processors/boards/stm32l1xx/templates/board.h.ftl,\
resources/gencfg/processors/boards/stm32l1xx/templates/board.mk.ftl,\
resources/gencfg/schema/boards/stm32l1xx_board.xsd,\
- resources/gencfg/xml/stm32l1board.xml
+ resources/gencfg/xml/stm32l1board.xml,\
+ resources/gencfg/schema/common/config_settings.xsd
diff --git a/tools/eclipse/config_wizard/plugin.xml b/tools/eclipse/config_wizard/plugin.xml
index e2163c8fb..84ca332e5 100644
--- a/tools/eclipse/config_wizard/plugin.xml
+++ b/tools/eclipse/config_wizard/plugin.xml
@@ -17,14 +17,29 @@
-
+
+ file-extensions="chcfg">
+
+
+
+
+
+
+
+
+
diff --git a/tools/eclipse/config_wizard/resources/gencfg/schema/boards/abstract_board.xsd b/tools/eclipse/config_wizard/resources/gencfg/schema/boards/abstract_board.xsd
index c4c953240..a1c696339 100644
--- a/tools/eclipse/config_wizard/resources/gencfg/schema/boards/abstract_board.xsd
+++ b/tools/eclipse/config_wizard/resources/gencfg/schema/boards/abstract_board.xsd
@@ -3,10 +3,12 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
-
+
+
@@ -21,25 +23,36 @@
-
+
-
-
-
-
+
-
+
-
+
+
-
+
+
+
+
+
-
-
+
+
-
+
+
diff --git a/tools/eclipse/config_wizard/resources/gencfg/schema/boards/stm32f4xx_board.xsd b/tools/eclipse/config_wizard/resources/gencfg/schema/boards/stm32f4xx_board.xsd
index ace3b5acb..072880711 100644
--- a/tools/eclipse/config_wizard/resources/gencfg/schema/boards/stm32f4xx_board.xsd
+++ b/tools/eclipse/config_wizard/resources/gencfg/schema/boards/stm32f4xx_board.xsd
@@ -1,63 +1,61 @@
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
diff --git a/tools/eclipse/config_wizard/resources/gencfg/schema/common/config_settings.xsd b/tools/eclipse/config_wizard/resources/gencfg/schema/common/config_settings.xsd
new file mode 100644
index 000000000..45d228142
--- /dev/null
+++ b/tools/eclipse/config_wizard/resources/gencfg/schema/common/config_settings.xsd
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ Templates resources associated to the configuration.
+
+
+
+
+
+
+
+
+
+
+
+ Output directory relative to the configuration file.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f0board.xml b/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f0board.xml
index 7e4dd5459..843dfe925 100644
--- a/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f0board.xml
+++ b/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f0board.xml
@@ -3,6 +3,10 @@
+
+ resources/gencfg/processors/boards/stm32f0xx/templates
+ .
+
-----human readable board name-----
BOARD_IDENTIFIER
diff --git a/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f4board.xml b/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f4board.xml
index 7becd89df..66a09d0d6 100644
--- a/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f4board.xml
+++ b/tools/eclipse/config_wizard/resources/gencfg/xml/stm32f4board.xml
@@ -3,6 +3,10 @@
+
+ resources/gencfg/processors/boards/stm32f4xx/templates
+ .
+
-----human readable board name-----
BOARD_IDENTIFIER
diff --git a/tools/eclipse/config_wizard/resources/gencfg/xml/stm32l1board.xml b/tools/eclipse/config_wizard/resources/gencfg/xml/stm32l1board.xml
index 1f6554026..00e5b5319 100644
--- a/tools/eclipse/config_wizard/resources/gencfg/xml/stm32l1board.xml
+++ b/tools/eclipse/config_wizard/resources/gencfg/xml/stm32l1board.xml
@@ -3,6 +3,10 @@
+
+ resources/gencfg/processors/boards/stm32l1xx/templates
+ .
+
-----human readable board name-----
BOARD_IDENTIFIER
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 e10d4c667..e6e9b3790 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
@@ -21,9 +21,7 @@
package org.chibios.tools.eclipse.config.handlers;
import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
-import java.util.Properties;
import org.chibios.tools.eclipse.config.utils.TemplateEngine;
import org.chibios.tools.eclipse.config.utils.TemplateException;
@@ -40,6 +38,10 @@ import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.jdom2.Document;
+import org.jdom2.Element;
+import org.jdom2.JDOMException;
+import org.jdom2.input.SAXBuilder;
import org.osgi.framework.Bundle;
import config_wizard.Activator;
@@ -70,53 +72,32 @@ public class GenerateFiles extends AbstractHandler {
if (selection instanceof IStructuredSelection) {
/* Retrieves the full path of the configuration file. */
- IPath cfgfilepath = ((IFile) ((IStructuredSelection) selection)
+ IPath cfgfilepath = ((IFile)((IStructuredSelection)selection)
.getFirstElement()).getLocation();
-
- /* Determines the base path as the parent of the configuration file.*/
- IPath basepath = cfgfilepath.removeLastSegments(1);
- /* Reads the configuration file into a Properties object. */
- Properties cfgfile = new Properties();
+ /* DOM tree creation. */
+ SAXBuilder builder = new SAXBuilder();
+ Document document;
try {
- cfgfile.load(new FileReader(cfgfilepath.toFile()));
+ document = builder.build(cfgfilepath.toFile());
+ } catch (JDOMException e) {
+ return null;
} catch (IOException e) {
- MessageDialog.openInformation(window.getShell(), "I/O Error",
- e.getMessage());
return null;
}
- /* Retrieves source property. */
- String source = cfgfile.getProperty("source");
- if (source == null) {
- MessageDialog.openInformation(window.getShell(), "Properties Error",
- "Property \"source\" not found in configuration file.");
- return null;
- }
-
- /* Retrieves xmlfile property. */
- String xmlfile = cfgfile.getProperty("xmlfile");
- if (xmlfile == null) {
- MessageDialog.openInformation(window.getShell(), "Properties Error",
- "Property \"xmlfile\" not found in configuration file.");
- return null;
- }
-
- /* Retrieves output property. */
- String output = cfgfile.getProperty("output");
- if (output == null) {
- MessageDialog.openInformation(window.getShell(), "Properties Error",
- "Property \"output\" not found in configuration file.");
- return null;
- }
+ /* Retrieving configuration settings info.*/
+ Element settings = document.getRootElement().getChild("configuration_settings");
+ String templates_path = settings.getChildText("templates_path");
+ String output_path = settings.getChildText("output_path");
/* Calculating derived paths. */
- IPath sourcepath = new Path(source);
+ IPath tpath = new Path(templates_path);
IPath libpath = new Path("resources/gencfg/lib");
try {
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
- sourcepath = new Path(FileLocator.toFileURL(
- FileLocator.find(bundle, sourcepath, null)).getFile());
+ 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) {
@@ -127,9 +108,10 @@ public class GenerateFiles extends AbstractHandler {
/* Templates execution. */
try {
- TemplateEngine.process(basepath.addTrailingSeparator().append(xmlfile)
- .toFile(), libpath.toFile(), sourcepath.toFile(),
- basepath.toFile(), new File(output));
+ TemplateEngine.process(cfgfilepath.toFile(),
+ libpath.toFile(),
+ tpath.toFile(),
+ new File(output_path));
} catch (TemplateException e) {
MessageDialog.openInformation(window.getShell(), "Processing Error",
e.getMessage());
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 892c9c99b..272d6a5c2 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
@@ -80,16 +80,15 @@ public class TemplateEngine {
* absolute path to libraries directory
* @param sourcedir
* absolute path to templates directory
- * @param basedir
- * absolute path to project directory
* @param outputdir
- * output directory relative to basedir
+ * output directory relative to xmldata
*
* @throws SettingException
* @throws ProcessingException
*/
- public static void process(java.io.File xmldata, java.io.File libdir,
- java.io.File sourcedir, java.io.File basedir,
+ public static void process(java.io.File xmldata,
+ java.io.File libdir,
+ java.io.File sourcedir,
java.io.File outputdir) throws TemplateException {
/* Finds or creates a named console. */
@@ -110,7 +109,7 @@ public class TemplateEngine {
* events to be logged.
*/
try {
- settings = new Settings(basedir);
+ settings = new Settings(xmldata.getParentFile());
} catch (SettingException e) {
e.printStackTrace();
return;
diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizard.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizard.java
index e6c309b43..28ee7e6e7 100644
--- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizard.java
+++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizard.java
@@ -54,9 +54,6 @@ public class ConfigurationNewWizard extends Wizard implements INewWizard {
private String containerName;
private String projectFileName;
- private String dataFileName;
- private String templatesPath;
- private String outputDirName;
private String defaultDataFile;
/**
@@ -91,9 +88,6 @@ public class ConfigurationNewWizard extends Wizard implements INewWizard {
containerName = page.getContainerName();
projectFileName = page.getProjectFileName();
- dataFileName = page.getDataFileName();
- templatesPath = page.getTemplatesPath();
- outputDirName = page.getOutputDirName();
defaultDataFile = page.getDefaultDataFile();
IRunnableWithProgress op = new IRunnableWithProgress() {
@@ -133,36 +127,20 @@ public class ConfigurationNewWizard extends Wizard implements INewWizard {
throwCoreException("Container \"" + containerName + "\" does not exist.");
}
IContainer container = (IContainer)resource;
- monitor.beginTask("Creating " + projectFileName, 4);
+ monitor.beginTask("Creating " + projectFileName, 3);
/* Step #1, creates the project file.*/
final IFile projectFile = container.getFile(new Path(projectFileName));
- try {
- InputStream stream = openProjectContentStream(templatesPath,
- dataFileName,
- outputDirName);
- if (projectFile.exists()) {
- projectFile.setContents(stream, true, true, monitor);
- } else {
- projectFile.create(stream, true, monitor);
- }
- stream.close();
- } catch (IOException e) {
- }
- monitor.worked(1);
-
- /* Step #2, creates the XML data file.*/
- final IFile dataFile = container.getFile(new Path(dataFileName));
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
IPath path = new Path(defaultDataFile);
String s;
try {
s = FileLocator.toFileURL(FileLocator.find(bundle, path, null)).getFile();
InputStream stream = new FileInputStream(s);
- if (dataFile.exists()) {
- dataFile.setContents(stream, true, true, monitor);
+ if (projectFile.exists()) {
+ projectFile.setContents(stream, true, true, monitor);
} else {
- dataFile.create(stream, true, monitor);
+ projectFile.create(stream, true, monitor);
}
stream.close();
} catch (IOException e) {
@@ -183,29 +161,11 @@ public class ConfigurationNewWizard extends Wizard implements INewWizard {
});
monitor.worked(1);
- /* Step #4, refreshing local resources.*/
+ /* Step #3, refreshing local resources.*/
container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
monitor.worked(1);
}
- /**
- * We will initialize file contents with a sample text.
- */
- private InputStream openProjectContentStream(String templatesPath,
- String dataFileName,
- String outputDirName) {
-
- String contents = "# Automatically generated configuration project file.\n\n" +
- "# Templates path in the configuration plugin resources, do not modify.\n" +
- "source=" + templatesPath + "\n\n" +
- "# XML configuration data file path relative to this configuration file.\n" +
- "xmlfile=" + dataFileName + "\n\n" +
- "# Output directory path relative to directory containing this configuration\n" +
- "# file.\n" +
- "output=" + outputDirName + "\n";
- return new ByteArrayInputStream(contents.getBytes());
- }
-
private void throwCoreException(String message) throws CoreException {
IStatus status = new Status(IStatus.ERROR,
"org.chibios.tools.eclipse.config", IStatus.OK,
diff --git a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizardPage.java b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizardPage.java
index 599c17af0..dde12645b 100644
--- a/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizardPage.java
+++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizardPage.java
@@ -24,8 +24,6 @@ import java.io.IOException;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -65,14 +63,11 @@ public class ConfigurationNewWizardPage extends WizardPage {
private IContainer resourceContainer;
private Document processorsDocument;
- private String currentTemplatesPath;
private String currentDefaultDataFile;
private Composite container;
private Combo configurationTemplatesCombo;
private Text confProjectFilenameText;
- private Text confDataFilenameText;
- private Text confOutputDirectoryText;
/**
* Constructor for SampleNewWizardPage.
@@ -118,43 +113,15 @@ public class ConfigurationNewWizardPage extends WizardPage {
}
});
- Label lbl3 = new Label(container, SWT.NONE);
- lbl3.setText("Configuration data filename:");
-
- confDataFilenameText = new Text(container, SWT.BORDER);
- confDataFilenameText.setText("config.chxml");
- confDataFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
- false, 1, 1));
- confDataFilenameText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- confDataFilenameUpdated();
- }
- });
-
- Label lbl4 = new Label(container, SWT.NONE);
- lbl4.setText("Configuration output directory:");
-
- confOutputDirectoryText = new Text(container, SWT.BORDER);
- confOutputDirectoryText.setText(".");
- confOutputDirectoryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
- true, false, 1, 1));
-
/* Note, it must stay after the creation of the text fields. */
configurationTemplatesCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Element processor = getSelectedTemplate();
String basefilename = processor.getChildText("basefilename");
confProjectFilenameText.setText(basefilename.concat(".chcfg"));
- confDataFilenameText.setText(basefilename.concat(".chxml"));
- currentTemplatesPath = processor.getChildText("path");
currentDefaultDataFile = processor.getChildText("default");
}
});
- confOutputDirectoryText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- confOutputDirectoryUpdated();
- }
- });
populateWizardPanel();
initialize();
@@ -171,21 +138,6 @@ public class ConfigurationNewWizardPage extends WizardPage {
return confProjectFilenameText.getText();
}
- public String getDataFileName() {
-
- return confDataFilenameText.getText();
- }
-
- public String getOutputDirName() {
-
- return confOutputDirectoryText.getText();
- }
-
- public String getTemplatesPath() {
-
- return currentTemplatesPath;
- }
-
public String getDefaultDataFile() {
return currentDefaultDataFile;
@@ -291,52 +243,6 @@ public class ConfigurationNewWizardPage extends WizardPage {
updateStatus(null);
}
- /**
- * Checks the content of the confProjectFilenameText field.
- */
- private void confDataFilenameUpdated() {
- String fileName = getDataFileName();
-
- if (fileName.length() == 0) {
- updateStatus("File name must be specified");
- return;
- }
- if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
- updateStatus("File name must be valid");
- return;
- }
- int dotLoc = fileName.lastIndexOf('.');
- if (dotLoc != -1) {
- String ext = fileName.substring(dotLoc + 1);
- if (ext.equalsIgnoreCase("chxml") == false) {
- updateStatus("Configuration project filename extension must be \"chxml\"");
- return;
- }
- }
- updateStatus(null);
- }
-
- /**
- * Checks the content of the confOutputDirectoryText field.
- */
- private void confOutputDirectoryUpdated() {
-
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IPath outputPath = resourceContainer.getFullPath().addTrailingSeparator()
- .append(getOutputDirName());
- IResource outputContainer = root.findMember(outputPath);
-
- if (outputContainer == null) {
- updateStatus("The directory must exists");
- return;
- }
- if (!(outputContainer instanceof IContainer)) {
- updateStatus("A directory must be specified");
- return;
- }
- updateStatus(null);
- }
-
/**
* Returns the XML Element associated to the current selection in the combo
* box.