aboutsummaryrefslogtreecommitdiffstats
path: root/tools/eclipse
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-07 15:12:08 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-07 15:12:08 +0000
commitecc767386f69585107ce4678c2cb0ab01bd4145a (patch)
treefec6742ac4178cd24391a69460a7b1b6e4dd445e /tools/eclipse
parenta5f493c0a15e0942a895e50a5fe9d3cc1209b446 (diff)
downloadChibiOS-ecc767386f69585107ce4678c2cb0ab01bd4145a.tar.gz
ChibiOS-ecc767386f69585107ce4678c2cb0ab01bd4145a.tar.bz2
ChibiOS-ecc767386f69585107ce4678c2cb0ab01bd4145a.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4542 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'tools/eclipse')
-rw-r--r--tools/eclipse/config_wizard/plugin.xml7
-rw-r--r--tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/ConfigurationNewWizardPage.java3
-rw-r--r--tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java42
-rw-r--r--tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java210
4 files changed, 260 insertions, 2 deletions
diff --git a/tools/eclipse/config_wizard/plugin.xml b/tools/eclipse/config_wizard/plugin.xml
index 84ca332e5..7098032c8 100644
--- a/tools/eclipse/config_wizard/plugin.xml
+++ b/tools/eclipse/config_wizard/plugin.xml
@@ -15,6 +15,13 @@
id="org.chibios.tools.eclipse.config.wizards.ConfigurationNewWizard"
name="ChibiOS/RT Configuration Wizard">
</wizard>
+ <wizard
+ category="org.chibios.tools.eclipse.config"
+ class="org.chibios.tools.eclipse.config.wizards.NewApplicationProjectWizard"
+ icon="icons/chibios.gif"
+ id="org.chibios.tools.eclipse.config.wizards.NewApplicationProjectWizard"
+ name="ChibiOS/RT New Application Project Wizard">
+ </wizard>
</extension>
<!-- Registers the file extension .chcfg as an XML type. -->
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 dde12645b..2cc7b830b 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
@@ -71,8 +71,6 @@ public class ConfigurationNewWizardPage extends WizardPage {
/**
* Constructor for SampleNewWizardPage.
- *
- * @param pageName
*/
public ConfigurationNewWizardPage(ISelection selection) {
@@ -85,6 +83,7 @@ public class ConfigurationNewWizardPage extends WizardPage {
/**
* @see IDialogPage#createControl(Composite)
*/
+ @Override
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
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
new file mode 100644
index 000000000..c5e10de81
--- /dev/null
+++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java
@@ -0,0 +1,42 @@
+package org.chibios.tools.eclipse.config.wizards;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class NewApplicationProjectWizard extends Wizard implements INewWizard {
+
+ private ISelection selection;
+ private IWizardPage page;
+
+ /**
+ * Constructor for ConfigurationNewWizard.
+ */
+ public NewApplicationProjectWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+ public void addPages() {
+ page = new NewApplicationProjectWizardPage(selection);
+ addPage(page);
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ @Override
+ public boolean performFinish() {
+
+ return true;
+ }
+
+}
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
new file mode 100644
index 000000000..d771b68e8
--- /dev/null
+++ b/tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java
@@ -0,0 +1,210 @@
+package org.chibios.tools.eclipse.config.wizards;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+
+public class NewApplicationProjectWizardPage extends WizardPage {
+
+ private ISelection selection;
+ private Composite container;
+ private Text projectParentPathText;
+ private Button btnBrowse;
+ private Label lblProjectName;
+ private Text projectNameText;
+ private Button useCustomPathButton;
+ private Label lblFinalProjectPath;
+ private Text projectFinalPathText;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ */
+ public NewApplicationProjectWizardPage(ISelection selection) {
+
+ super("wizardPage");
+ setTitle("ChibiOS/RT New Application Project Wizard");
+ setDescription("This wizard creates a new ChibiOS/RT application project.");
+ this.selection = selection;
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 3;
+ layout.verticalSpacing = 9;
+
+ lblProjectName = new Label(container, SWT.NONE);
+ lblProjectName.setText("Project name:");
+
+ projectNameText = new Text(container, SWT.BORDER);
+ projectNameText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ projectNameUpdated();
+ }
+ });
+ projectNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ new Label(container, SWT.NONE);
+
+ useCustomPathButton = new Button(container, SWT.CHECK);
+ useCustomPathButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (useCustomPathButton.getSelection()) {
+ projectParentPathText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
+ projectParentPathText.setEnabled(false);
+ updateFinalProjectPathText();
+ }
+ else {
+ projectParentPathText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
+ projectParentPathText.setEnabled(true);
+ updateFinalProjectPathText();
+ }
+ }
+ });
+ useCustomPathButton.setText("Use default location");
+ new Label(container, SWT.NONE);
+ new Label(container, SWT.NONE);
+
+ Label lbl1 = new Label(container, SWT.NULL);
+ lbl1.setText("Project parent path:");
+
+ projectParentPathText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ projectParentPathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ projectPathUpdated();
+ }
+ });
+ projectParentPathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ btnBrowse = new Button(container, SWT.NONE);
+ btnBrowse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ }
+ });
+ btnBrowse.setText("Browse...");
+
+ lblFinalProjectPath = new Label(container, SWT.NONE);
+ lblFinalProjectPath.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));
+
+ populateWizardPanel();
+ initialize();
+ setControl(container);
+ }
+
+ /**
+ * 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);
+
+ /* 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.");
+ return;
+ }
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ if (project.exists()) {
+ updateStatus("Project exists.");
+ return;
+ }
+ updateStatus(null);
+ }
+
+ private void projectPathUpdated() {
+ File path = new File(projectParentPathText.getText());
+
+ updateFinalProjectPathText();
+
+ if (!path.exists()) {
+ updateStatus("Project path is not valid.");
+ return;
+ }
+ if (!path.isDirectory()) {
+ updateStatus("Project path is a directory.");
+ return;
+ }
+ updateStatus(null);
+ }
+
+ /**
+ * Updates the status text in the Wizard page.
+ *
+ * @param message
+ * the message to be shown
+ */
+ private void updateStatus(String message) {
+
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ private void updateFinalProjectPathText() {
+
+ IPath parent = new Path(projectParentPathText.getText());
+ IPath project = parent.addTrailingSeparator().append(projectNameText.getText());
+ projectFinalPathText.setText(project.toString());
+ }
+
+ private boolean isValidFilename(String name) {
+
+ if (name.length() == 0)
+ return false;
+ if ((name.indexOf("`") >= 0) || (name.indexOf("?") >= 0) ||
+ (name.indexOf("*") >= 0) || (name.indexOf("<") >= 0) ||
+ (name.indexOf(">") >= 0) || (name.indexOf("|") >= 0) ||
+ (name.indexOf("\"") >= 0) || (name.indexOf(":") >= 0) ||
+ (name.indexOf("#") >= 0) || (name.indexOf("\\") >= 0) ||
+ (name.indexOf("/") >= 0) || (name.indexOf("|") >= 0))
+ return false;
+ return true;
+ }
+}