diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2008-11-25 14:37:10 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2008-11-25 14:37:10 +0000 |
commit | 3a85b457f9e6983b160302338f1ff590c3afcf46 (patch) | |
tree | 126b83f6f0d3853302b0235ba8185c1cb551ac96 /org.rtems.cdt.toolchain2 | |
parent | First try of a new project wizard. (diff) | |
download | rtems-eclipse-plug-in-3a85b457f9e6983b160302338f1ff590c3afcf46.tar.bz2 |
Added preferences.
Diffstat (limited to 'org.rtems.cdt.toolchain2')
9 files changed, 384 insertions, 43 deletions
diff --git a/org.rtems.cdt.toolchain2/META-INF/MANIFEST.MF b/org.rtems.cdt.toolchain2/META-INF/MANIFEST.MF index f60bbae..b4b5e7d 100644 --- a/org.rtems.cdt.toolchain2/META-INF/MANIFEST.MF +++ b/org.rtems.cdt.toolchain2/META-INF/MANIFEST.MF @@ -6,7 +6,13 @@ Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.cdt.managedbuilder.core, org.eclipse.swt, - org.eclipse.ui;bundle-version="3.4.1" + org.eclipse.ui;bundle-version="3.4.1", + org.eclipse.core.resources;bundle-version="3.4.1", + org.eclipse.cdt.ui;bundle-version="5.1.0", + org.eclipse.core.runtime;bundle-version="3.4.0" Bundle-Vendor: Embedded Brains GmbH Import-Package: org.eclipse.cdt.managedbuilder.ui.wizards, - org.eclipse.jface.resource + org.eclipse.jface.resource, + org.eclipse.ui.wizards.newresource +Bundle-Activator: org.rtems.cdt.Activator +Bundle-ActivationPolicy: lazy diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java new file mode 100644 index 0000000..91c0faa --- /dev/null +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * The license and distribution terms for this file may be found in the file + * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + */ + +package org.rtems.cdt; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class Activator extends AbstractUIPlugin { + private static Activator mPlugin; + + public Activator() { + super(); + } + + public void start( BundleContext context) throws Exception { + super.start( context); + mPlugin = this; + } + + public void stop( BundleContext context) throws Exception { + mPlugin = null; + super.stop( context); + } + + public static Activator getDefault() { + return mPlugin; + } +} diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java new file mode 100644 index 0000000..8d71d7e --- /dev/null +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * The license and distribution terms for this file may be found in the file + * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + */ + +package org.rtems.cdt; + +public class Constants { + public static final String [][] TARGETS = { + {"ARM", "arm"}, + {"AVR", "avr"}, + {"Blackfin", "bfin"}, + {"Hitachi H8300", "h8300"}, + {"Intel i386", "i368"}, + {"Intel i686", "i668"}, + {"MIPS", "mips"}, + {"Motorola 68k or Freescale ColdFire", "m68k"}, + {"PowerPC", "powerpc"}, + {"SPARC", "sparc"}, + {"SuperH", "sh"} + }; + + public static final String DEFAULT_BASE_PATH = "/opt/rtems-4.9"; + + public static final String DEFAULT_VERSION = "4.9"; + + public static final int DEFAULT_TARGET_INDEX = 8; + + public static final String DEFAULT_TARGET_NAME = TARGETS [DEFAULT_TARGET_INDEX][0]; + + public static final String DEFAULT_TARGET = TARGETS [DEFAULT_TARGET_INDEX][1]; + + public static final String DEFAULT_BSP_PATH = "/opt/rtems-4.9/powerpc-rtems4.9/psim"; + + public static final String BASE_PATH_KEY = "org.rtems.cdt.key.basePath"; + + public static final String VERSION_KEY = "org.rtems.cdt.key.version"; + + public static final String TARGET_KEY = "org.rtems.cdt.key.target"; + + public static final String BSP_PATH_KEY = "org.rtems.cdt.key.bspPath"; + + private Constants() { + // Do nothing + } +} diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/preferences/PreferenceInitializer.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/preferences/PreferenceInitializer.java new file mode 100644 index 0000000..0214d46 --- /dev/null +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/preferences/PreferenceInitializer.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * The license and distribution terms for this file may be found in the file + * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + */ + +package org.rtems.cdt.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.rtems.cdt.Activator; +import org.rtems.cdt.Constants; + +public class PreferenceInitializer extends AbstractPreferenceInitializer { + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + store.setDefault( Constants.BASE_PATH_KEY, Constants.DEFAULT_BASE_PATH); + store.setDefault( Constants.VERSION_KEY, Constants.DEFAULT_VERSION); + store.setDefault( Constants.TARGET_KEY, Constants.DEFAULT_TARGET); + store.setDefault( Constants.BSP_PATH_KEY, Constants.DEFAULT_BSP_PATH); + } +} diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/preferences/PreferencePage.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/preferences/PreferencePage.java new file mode 100644 index 0000000..edf8580 --- /dev/null +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/preferences/PreferencePage.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * The license and distribution terms for this file may be found in the file + * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + */ + +package org.rtems.cdt.preferences; + +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.rtems.cdt.Activator; +import org.rtems.cdt.Constants; + +public class PreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + public PreferencePage() { + super( GRID); + setPreferenceStore( Activator.getDefault().getPreferenceStore()); + setDescription( "Select the RTEMS base installation path, the RTEMS version, the target architecture and the board support package (BSP) installation path. This provides the default values for new projects."); + } + + public void createFieldEditors() { + addField( + new DirectoryFieldEditor( + Constants.BASE_PATH_KEY, + "Base path:", + getFieldEditorParent() + ) + ); + addField( + new StringFieldEditor( + Constants.VERSION_KEY, + "Version:", + getFieldEditorParent() + ) + ); + addField( + new ComboFieldEditor( + Constants.TARGET_KEY, + "Target:", + Constants.TARGETS, + getFieldEditorParent() + ) + ); + addField( + new DirectoryFieldEditor( + Constants.BSP_PATH_KEY, + "BSP path:", + getFieldEditorParent() + ) + ); + } + + public void init( IWorkbench workbench) { + // Do nothing + } +}
\ No newline at end of file diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java new file mode 100644 index 0000000..2d83e98 --- /dev/null +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * The license and distribution terms for this file may be found in the file + * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + */ + +package org.rtems.cdt.properties; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchPropertyPage; + +public class PropertyPage + extends org.eclipse.ui.dialogs.PropertyPage + implements IWorkbenchPropertyPage { + + public PropertyPage() { + // TODO Auto-generated constructor stub + } + + @Override + protected Control createContents(Composite parent) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/BasicSetup.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/BasicSetup.java index 896ca7d..cabd114 100644 --- a/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/BasicSetup.java +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/BasicSetup.java @@ -13,6 +13,8 @@ package org.rtems.cdt.wizards; import java.util.*; +import org.eclipse.core.resources.*; +import org.eclipse.cdt.ui.wizards.*; import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage; import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; import org.eclipse.jface.resource.ImageDescriptor; @@ -23,8 +25,9 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; import org.eclipse.swt.SWT; -public class BasicSetup extends MBSCustomPage -{ +public class BasicSetup extends MBSCustomPage { + public static final String PAGE_ID = "org.rtems.cdt.wizards.basicsetup"; + private SortedMap<String, String> mTargetMap; private Composite mComposite; @@ -35,9 +38,8 @@ public class BasicSetup extends MBSCustomPage private Combo mTarget; - public BasicSetup() - { - pageID = "org.rtems.cdt.wizards.basicsetup"; + public BasicSetup() { + pageID = PAGE_ID; mTargetMap = new TreeMap<String, String>(); mTargetMap.put( new String( "PowerPC"), new String ("powerpc")); @@ -51,20 +53,21 @@ public class BasicSetup extends MBSCustomPage mTargetMap.put( new String( "Hitachi H8300"), new String ("h8300")); mTargetMap.put( new String( "MIPS"), new String ("mips")); mTargetMap.put( new String( "SuperH"), new String ("sh")); + + //IProject project = ((NewCProjectWizard) getWizard()).getNewProject(); + //MBSCustomPageManager.addPageProperty( PAGE_ID, "project", project); } - public boolean canFlipToNextPage() - { + public boolean canFlipToNextPage() { return MBSCustomPageManager.getNextPage( pageID) != null; } - public String getName() - { + public String getName() { return "Basic Setup Page"; } - public void createControl( Composite parent) - { + public void createControl( Composite parent) { + // Create UI elements mComposite = new Composite( parent, SWT.NULL); GridData gd = new GridData( GridData.FILL_BOTH); @@ -121,81 +124,95 @@ public class BasicSetup extends MBSCustomPage while (targets.hasNext()) { mTarget.add( (String) targets.next()); } - mTarget.select( 0); + mTarget.select( mTarget.indexOf( "PowerPC")); gd = new GridData( GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; mTarget.setLayoutData( gd); new Label( mComposite, SWT.NONE); + + // Connect user input + mInstallationPath.addModifyListener( + new ModifyListener() { + public void modifyText( ModifyEvent e) { + installationPathChanged(); + } + } + ); + mVersion.addModifyListener( + new ModifyListener() { + public void modifyText( ModifyEvent e) { + versionChanged(); + } + } + ); + mTarget.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected( SelectionEvent e) { + targetChanged(); + } + } + ); + + // Trigger initial setup + installationPathChanged(); + versionChanged(); + targetChanged(); } - public void dispose() - { + public void dispose() { mComposite.dispose(); } - public Control getControl() - { + public Control getControl() { return mComposite; } - public String getDescription() - { + public String getDescription() { return "Select your desired RTEMS installation path, version and target architecture."; } - public String getErrorMessage() - { + public String getErrorMessage() { return null; } - public Image getImage() - { + public Image getImage() { return wizard.getDefaultPageImage(); } - public String getMessage() - { + public String getMessage() { return null; } - public String getTitle() - { + public String getTitle() { return "Basic Setup"; } - public void performHelp() - { + public void performHelp() { // Do nothing } - public void setDescription( String description) - { + public void setDescription( String description) { // Do nothing } - public void setImageDescriptor( ImageDescriptor image) - { + public void setImageDescriptor( ImageDescriptor image) { // Do nothing } - public void setTitle(String title) - { + public void setTitle(String title) { // Do nothing } - public void setVisible( boolean visible) - { + public void setVisible( boolean visible) { mComposite.setVisible( visible); } - protected boolean isCustomPageComplete() - { - return true; + protected boolean isCustomPageComplete() { + return false; } - private void browseForInstallationPath() - { + private void browseForInstallationPath() { DirectoryDialog dialog = new DirectoryDialog( mComposite.getShell(), SWT.NONE); dialog.setFilterPath( mInstallationPath.getText()); String text = dialog.open(); @@ -203,4 +220,16 @@ public class BasicSetup extends MBSCustomPage mInstallationPath.setText( text); } } + + private void installationPathChanged() { + MBSCustomPageManager.addPageProperty( pageID, "installationPath", mInstallationPath.getText()); + } + + private void versionChanged() { + MBSCustomPageManager.addPageProperty( pageID, "version", mVersion.getText()); + } + + private void targetChanged() { + MBSCustomPageManager.addPageProperty( pageID, "target", mTarget.getText()); + } }
\ No newline at end of file diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/FinishSetup.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/FinishSetup.java new file mode 100644 index 0000000..2e21e3e --- /dev/null +++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/wizards/FinishSetup.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2008 + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * The license and distribution terms for this file may be found in the file + * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + */ + +package org.rtems.cdt.wizards; + +import org.eclipse.cdt.managedbuilder.ui.wizards.*; +import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.wizard.IWizardPage; + +public class FinishSetup implements Runnable { + public void run() { + String installationPath = (String) MBSCustomPageManager.getPageProperty( BasicSetup.PAGE_ID, "installationPath"); + String version = (String) MBSCustomPageManager.getPageProperty( BasicSetup.PAGE_ID, "version"); + String target = (String) MBSCustomPageManager.getPageProperty( BasicSetup.PAGE_ID, "target"); + + // Get a handle to the wizard + IWizardPage [] pages = MBSCustomPageManager.getPages(); + + if (pages != null && pages.length > 0) { + CDTCommonProjectWizard wizard = (CDTCommonProjectWizard) pages [0].getWizard(); + IProject project = wizard.getLastProject(); + try { + project.setPersistentProperty( + new QualifiedName( "", "XXXxxxXXX"), + installationPath + ); + } catch (CoreException e) { + e.printStackTrace(); + } + } + System.out.println( installationPath); + System.out.println( version); + System.out.println( target); + } +} diff --git a/org.rtems.cdt.toolchain2/plugin.xml b/org.rtems.cdt.toolchain2/plugin.xml index 0a8b673..e2787f6 100644 --- a/org.rtems.cdt.toolchain2/plugin.xml +++ b/org.rtems.cdt.toolchain2/plugin.xml @@ -243,6 +243,48 @@ point="org.eclipse.cdt.managedbuilder.ui.newWizardPages"> <wizardPage ID="org.rtems.cdt.wizards.basicsetup" + operationClass="org.rtems.cdt.wizards.FinishSetup" pageClass="org.rtems.cdt.wizards.BasicSetup"/> </extension> + + <!-- Preferences --> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" + class="org.rtems.cdt.preferences.PreferencePage" + id="org.rtems.cdt.preferences.PreferencePage" + name="RTEMS"> + </page> + </extension> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.rtems.cdt.preferences.PreferenceInitializer"> + </initializer> + </extension> + + <!-- Properties --> + <extension + point="org.eclipse.ui.propertyPages"> + <page + category="org.eclipse.cdt.managedbuilder.ui.properties.Page_head_build" + class="org.rtems.cdt.properties.PropertyPage" + id="org.rtems.cdt.properties.PropertyPage" + name="RTEMS"> + <filter + name="projectNature" + value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/> + <enabledWhen> + <or> + <instanceof value="org.eclipse.core.resources.IProject"/> + <instanceof value="org.eclipse.cdt.core.model.ICProject"/> + <instanceof value="org.eclipse.core.resources.IFolder"/> + <instanceof value="org.eclipse.cdt.core.model.ICContainer"/> + <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/> + <instanceof value="org.eclipse.core.resources.IFile"/> + </or> + </enabledWhen> + </page> + </extension> </plugin> |