aboutsummaryrefslogtreecommitdiffstats
path: root/tools/eclipse
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-09 12:50:17 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-09 12:50:17 +0000
commitc772b5d61e22486616a97e962cb2173c2a536b7d (patch)
tree636a529fbb7b2d0957b702e4ecccb4e741e1506d /tools/eclipse
parent18da3cc76dc7753dbb53f2ecd4cd59c81f96905a (diff)
downloadChibiOS-c772b5d61e22486616a97e962cb2173c2a536b7d.tar.gz
ChibiOS-c772b5d61e22486616a97e962cb2173c2a536b7d.tar.bz2
ChibiOS-c772b5d61e22486616a97e962cb2173c2a536b7d.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4547 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'tools/eclipse')
-rw-r--r--tools/eclipse/config_wizard/META-INF/MANIFEST.MF4
-rw-r--r--tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizard.java127
-rw-r--r--tools/eclipse/config_wizard/src/org/chibios/tools/eclipse/config/wizards/NewApplicationProjectWizardPage.java22
3 files changed, 149 insertions, 4 deletions
diff --git a/tools/eclipse/config_wizard/META-INF/MANIFEST.MF b/tools/eclipse/config_wizard/META-INF/MANIFEST.MF
index b7cea1ead..09eb9fe72 100644
--- a/tools/eclipse/config_wizard/META-INF/MANIFEST.MF
+++ b/tools/eclipse/config_wizard/META-INF/MANIFEST.MF
@@ -8,7 +8,9 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.console;bundle-version="3.5.100",
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.eclipse.cdt.core;bundle-version="5.4.0",
+ org.eclipse.cdt.managedbuilder.core;bundle-version="8.1.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: chibios.org
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 c5e10de81..7df459b3b 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,16 +1,38 @@
package org.chibios.tools.eclipse.config.wizards;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
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;
+ private NewApplicationProjectWizardPage page;
+ private ISelection selection;
+
+ private String projectName;
+ private String finalProjectPath;
+ private String platform;
/**
* Constructor for ConfigurationNewWizard.
@@ -36,7 +58,106 @@ public class NewApplicationProjectWizard extends Wizard implements INewWizard {
@Override
public boolean performFinish() {
+ projectName = page.getProjectName();
+ finalProjectPath = page.getFinalProjectPath();
+ platform = page.getPlatform();
+
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException {
+ try {
+ doFinish(monitor);
+ }
+ catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ }
+ catch (InterruptedException e) {
+ return false;
+ }
+ catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
return true;
}
+ /**
+ * The worker method. It will find the container, create the file if missing
+ * or just replace its contents, and open the editor on the newly created
+ * file.
+ */
+ private void doFinish(IProgressMonitor monitor) throws CoreException {
+
+ monitor.beginTask("Creating " + projectName, 3);
+
+ /* Step #1, creates the project file.*/
+ IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (newProject.exists()) {
+ monitor.done();
+ MessageDialog.openError(getShell(), "Error", "Project " + projectName +
+ " already exists in workspace");
+ return;
+ }
+
+ IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
+ if (finalProjectPath != null)
+ desc.setLocation(new Path(finalProjectPath));
+ CCorePlugin corePlugin = CCorePlugin.getDefault();
+ newProject = corePlugin.createCProject(desc, newProject, null,
+ ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID);
+ IManagedBuildInfo managedBuildInfo = ManagedBuildManager.createBuildInfo(newProject);
+ ManagedCProjectNature.addManagedNature(newProject, null);
+ ManagedCProjectNature.addManagedBuilder(newProject, null);
+
+ IProjectType parentProjectType;
+ try {
+ IManagedProject newManagedProject = ManagedBuildManager
+ .createManagedProject(newProject, ManagedBuildManager.getProjectType(""));
+ }
+ catch (BuildException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return;
+
+
+/*
+ IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
+ if (finalProjectPath != null)
+ desc.setLocation(new Path(finalProjectPath));
+ try {
+ newProject.create(desc, null);
+ if (!newProject.isOpen()) {
+ newProject.open(null);
+ }
+ } catch (CoreException e) {
+ monitor.done();
+ MessageDialog.openError(getShell(), "Error", "Project " + projectName +
+ " creation failed: " + e.getMessage());
+ return;
+ }
+ monitor.worked(1);*/
+
+ /* Step #2, adding builders.*/
+/* desc = newProject.getDescription();
+ String[] build_configs = new String[] {ManagedCProjectNature.BUILDER_ID,
+ "org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder"};
+ desc.setBuildConfigs(build_configs);
+ newProject.setDescription(desc, null);*/
+// CProjectNature.addCNature(newProject, null);
+// ManagedCProjectNature.addNature(newProject, ManagedCProjectNature.MNG_NATURE_ID, null);
+// ManagedCProjectNature.addNature(newProject, "org.eclipse.cdt.managedbuilder.core.ScannerConfigNature", null);
+// ManagedCProjectNature.addManagedBuilder(newProject, null);
+// monitor.worked(1);
+ }
}
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 efc377014..ca22d46c2 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
@@ -203,6 +203,28 @@ public class NewApplicationProjectWizardPage extends WizardPage {
projectPageUpdated();
}
+ public String getProjectName() {
+
+ return projectNameText.getText();
+ }
+
+ public String getProjectParentPath() {
+
+ return projectParentPathText.getText();
+ }
+
+ public String getFinalProjectPath() {
+
+ if (useCustomPathButton.getSelection())
+ return null;
+ return projectFinalPathText.getText();
+ }
+
+ public String getPlatform() {
+
+ return platformCombo.getText();
+ }
+
private void projectPageUpdated() {
updateFinalProjectPathText();