diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-08-08 16:45:56 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-08-08 16:45:56 +0000 |
commit | 4bdc2322a82279051981716284f145965321ba07 (patch) | |
tree | 7119ac6ea336975ec65e416db9d51f847b89b6bc /tools/eclipse/config_wizard/src | |
parent | ecc767386f69585107ce4678c2cb0ab01bd4145a (diff) | |
download | ChibiOS-4bdc2322a82279051981716284f145965321ba07.tar.gz ChibiOS-4bdc2322a82279051981716284f145965321ba07.tar.bz2 ChibiOS-4bdc2322a82279051981716284f145965321ba07.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4543 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'tools/eclipse/config_wizard/src')
4 files changed, 116 insertions, 59 deletions
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 e6e9b3790..c742d9072 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 @@ -118,6 +118,7 @@ public class GenerateFiles extends AbstractHandler { return null; } } + /* TODO: refresh output path.*/ return null; } } 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 272d6a5c2..60a33f0e2 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,6 +20,7 @@ package org.chibios.tools.eclipse.config.utils;
+import java.io.File;
import java.io.IOException;
import java.util.HashMap;
@@ -165,9 +166,12 @@ public class TemplateEngine { } catch (ParserConfigurationException e) {
throw new TemplateException(e.getMessage());
}
- Document dom1;
+ Document dom1, dom_snippets;
try {
dom1 = db.parse(xmldata);
+ java.io.File xmlsnippets = new File(libdir.toString() +
+ "/code_snippets.xml");
+ dom_snippets = db.parse(xmlsnippets);
} catch (SAXException e) {
throw new TemplateException(e.getMessage());
} catch (IOException e) {
@@ -176,10 +180,14 @@ public class TemplateEngine { NodeModel.removeComments(dom1);
NodeModel.mergeAdjacentText(dom1);
+ NodeModel.removeComments(dom_snippets);
TemplateNodeModel doc1 = NodeModel.wrap(dom1);
+ NodeModel.mergeAdjacentText(dom_snippets);
+ TemplateNodeModel doc_snippets = NodeModel.wrap(dom_snippets);
HashMap<String, TemplateNodeModel> xmls = new HashMap<String, TemplateNodeModel>();
xmls.put("doc1", doc1);
+ xmls.put("doc_snippets", doc_snippets);
/* Setting libraries path. */
HashMap<String, String> libs = new HashMap<String, String>();
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 2cc7b830b..d503d9748 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 @@ -122,7 +122,6 @@ public class ConfigurationNewWizardPage extends WizardPage { } }); - populateWizardPanel(); initialize(); setControl(container); } @@ -171,18 +170,9 @@ public class ConfigurationNewWizardPage extends WizardPage { container.setEnabled(false); updateStatus("Container for the resource not selected."); } - } - - /** - * Fills the wizard configuration panel from XML data. - * - * @param configurationTemplateCombo - * the combo box to be populated - */ - private void populateWizardPanel() { - String fpath; /* Retrieving the resource path of the processors.xml file. */ + String fpath; try { Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); IPath path = new Path("resources/gencfg/processors/processors.xml"); @@ -205,10 +195,8 @@ public class ConfigurationNewWizardPage extends WizardPage { return; } - /* - * Parsing the content of the processors.xml file in order to populate the - * panel objects. - */ + /* Parsing the content of the processors.xml file in order to populate the + panel objects.*/ Element root = processorsDocument.getRootElement(); for (Element processor : root.getChildren("processor")) { String name = processor.getChildText("name"); 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 d771b68e8..efc377014 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,17 +1,21 @@ package org.chibios.tools.eclipse.config.wizards;
import java.io.File;
+import java.io.IOException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+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.jface.viewers.ISelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
@@ -19,6 +23,15 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.widgets.Combo;
+
+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;
public class NewApplicationProjectWizardPage extends WizardPage {
@@ -26,11 +39,13 @@ public class NewApplicationProjectWizardPage extends WizardPage { private Composite container;
private Text projectParentPathText;
private Button btnBrowse;
- private Label lblProjectName;
+ private Label lbl1;
private Text projectNameText;
private Button useCustomPathButton;
- private Label lblFinalProjectPath;
+ private Label lbl3;
private Text projectFinalPathText;
+ private Label lbl4;
+ private Combo platformCombo;
/**
* Constructor for SampleNewWizardPage.
@@ -53,19 +68,20 @@ public class NewApplicationProjectWizardPage extends WizardPage { container.setLayout(layout);
layout.numColumns = 3;
layout.verticalSpacing = 9;
-
- lblProjectName = new Label(container, SWT.NONE);
- lblProjectName.setText("Project name:");
+ /* Layout row 1.*/
+ lbl1 = new Label(container, SWT.NONE);
+ lbl1.setText("Project name:");
projectNameText = new Text(container, SWT.BORDER);
projectNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- projectNameUpdated();
+ projectPageUpdated();
}
});
projectNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(container, SWT.NONE);
-
+
+ /* Layout row 2.*/
useCustomPathButton = new Button(container, SWT.CHECK);
useCustomPathButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -73,11 +89,13 @@ public class NewApplicationProjectWizardPage extends WizardPage { if (useCustomPathButton.getSelection()) {
projectParentPathText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
projectParentPathText.setEnabled(false);
+ btnBrowse.setEnabled(false);
updateFinalProjectPathText();
}
else {
projectParentPathText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
projectParentPathText.setEnabled(true);
+ btnBrowse.setEnabled(true);
updateFinalProjectPathText();
}
}
@@ -86,33 +104,49 @@ public class NewApplicationProjectWizardPage extends WizardPage { new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
- Label lbl1 = new Label(container, SWT.NULL);
- lbl1.setText("Project parent path:");
-
+ /* Layout row 3.*/
+ Label lbl2 = new Label(container, SWT.NULL);
+ lbl2.setText("Project parent path:");
projectParentPathText = new Text(container, SWT.BORDER | SWT.SINGLE);
projectParentPathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- projectPathUpdated();
+ projectPageUpdated();
}
});
projectParentPathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
btnBrowse = new Button(container, SWT.NONE);
btnBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ /* Prompts the user for a parent directory for the new project.*/
+ DirectoryDialog dlg = new DirectoryDialog(getShell());
+ dlg.setFilterPath(projectParentPathText.getText());
+ dlg.setText("New ChibiOS/RT Project");
+ dlg.setMessage("Select the parent directory for the new ChibiOS/RT application project.");
+ String parent = dlg.open();
+ if (parent != null) {
+ projectParentPathText.setText(parent);
+ projectPageUpdated();
+ }
}
});
btnBrowse.setText("Browse...");
- lblFinalProjectPath = new Label(container, SWT.NONE);
- lblFinalProjectPath.setText("Final project path:");
-
+ /* Layout row 4.*/
+ lbl3 = new Label(container, SWT.NONE);
+ lbl3.setText("Final project path:");
projectFinalPathText = new Text(container, SWT.BORDER);
projectFinalPathText.setEditable(false);
projectFinalPathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ new Label(container, SWT.NONE);
+
+ /* Layout row 5.*/
+ lbl4 = new Label(container, SWT.NONE);
+ lbl4.setText("Target platform:");
+ platformCombo = new Combo(container, SWT.READ_ONLY);
+ platformCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ new Label(container, SWT.NONE);
- populateWizardPanel();
initialize();
setControl(container);
}
@@ -121,49 +155,60 @@ public class NewApplicationProjectWizardPage extends WizardPage { * Tests if the current workbench selection is a suitable container to use.
*/
private void initialize() {
-
+
/* Initial state of the check box and project path text.*/
useCustomPathButton.setSelection(true);
projectParentPathText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
projectParentPathText.setEnabled(false);
+ btnBrowse.setEnabled(false);
- /* Update checks on the fields.*/
- projectNameUpdated();
- }
- /**
- * Fills the wizard configuration panel from XML data.
- *
- * @param configurationTemplateCombo
- * the combo box to be populated
- */
- private void populateWizardPanel() {
-
- }
-
- private void projectNameUpdated() {
- String name = projectNameText.getText();
-
- updateFinalProjectPathText();
-
- if (!isValidFilename(name)) {
- updateStatus("Invalid project name.");
+ /* Retrieving the resource path of the processors.xml file. */
+ String fpath;
+ try {
+ Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
+ IPath path = new Path("resources/gencfg/processors/processors.xml");
+ fpath = FileLocator.toFileURL(FileLocator.find(bundle, path, null)).getFile();
+ } catch (IOException e) {
+ e.printStackTrace();
return;
}
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- if (project.exists()) {
- updateStatus("Project exists.");
+ /* DOM tree creation. */
+ SAXBuilder builder = new SAXBuilder();
+ Document document;
+ try {
+ document = builder.build(fpath);
+ } catch (JDOMException e) {
+ e.printStackTrace();
+ return;
+ } catch (IOException e) {
+ e.printStackTrace();
return;
}
- updateStatus(null);
+
+ /* Parsing the content of the processors.xml file in order to populate the
+ panel objects.*/
+ Element root = document.getRootElement();
+ for (Element processor : root.getChildren("processor")) {
+ String class_attr = processor.getAttributeValue("class", "");
+ if (class_attr.compareToIgnoreCase("build") == 0) {
+ String name = processor.getAttributeValue("target", "internal error");
+ platformCombo.add(name);
+ }
+ }
+ platformCombo.select(0);
+
+ /* Update checks on the fields.*/
+ projectPageUpdated();
}
- private void projectPathUpdated() {
- File path = new File(projectParentPathText.getText());
+ private void projectPageUpdated() {
updateFinalProjectPathText();
+ /* Checks the project location.*/
+ File path = new File(projectParentPathText.getText());
if (!path.exists()) {
updateStatus("Project path is not valid.");
return;
@@ -172,6 +217,21 @@ public class NewApplicationProjectWizardPage extends WizardPage { updateStatus("Project path is a directory.");
return;
}
+
+ /* Checks the project name.*/
+ String name = projectNameText.getText();
+ if (!isValidFilename(name)) {
+ updateStatus("Invalid project name.");
+ return;
+ }
+
+ /* Checks if the project already exists in the workspace.*/
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ if (project.exists()) {
+ updateStatus("Project exists.");
+ return;
+ }
+
updateStatus(null);
}
|