diff options
author | Johannes Schanda <schanda@itestra.de> | 2013-05-13 14:08:45 +0200 |
---|---|---|
committer | Johannes Schanda <schanda@itestra.de> | 2013-05-13 14:08:45 +0200 |
commit | 918366c01d0e1005dca3c8381c4c28b9da99377b (patch) | |
tree | 44de790241f8b9598ca41b473547cb9c114aa5cf | |
parent | 445c9a09ffe144c9d5120703de5b19d95fb4c31d (diff) | |
download | genivi-common-api-runtime-918366c01d0e1005dca3c8381c4c28b9da99377b.tar.gz |
Dev properties
7 files changed, 115 insertions, 4 deletions
diff --git a/org.genivi.commonapi.core.ui/plugin.xml b/org.genivi.commonapi.core.ui/plugin.xml index db9e46a..d5b4594 100644 --- a/org.genivi.commonapi.core.ui/plugin.xml +++ b/org.genivi.commonapi.core.ui/plugin.xml @@ -67,4 +67,18 @@ </or> </definition> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + class="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage" + id="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage" + name="CommonAPI Preferences"> + </page> + </extension> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.genivi.commonapi.core.ui.preferences.PreferenceInitializer"> + </initializer> + </extension> </plugin> diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/CommonApiUiPlugin.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/CommonApiUiPlugin.java index 13481b2..1afe578 100644 --- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/CommonApiUiPlugin.java +++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/CommonApiUiPlugin.java @@ -6,7 +6,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.genivi.commonapi.core.ui; +import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.xtext.ui.ecore.Activator; import org.osgi.framework.BundleContext; public class CommonApiUiPlugin extends AbstractUIPlugin { @@ -32,4 +34,8 @@ public class CommonApiUiPlugin extends AbstractUIPlugin { public static CommonApiUiPlugin getInstance() { return INSTANCE; } + + public static CommonApiUiPlugin getDefault() { + return INSTANCE; + } } diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java new file mode 100644 index 0000000..0947a6d --- /dev/null +++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java @@ -0,0 +1,53 @@ +package org.genivi.commonapi.core.ui.preferences; + +import java.io.IOException; + +import org.eclipse.core.runtime.preferences.ConfigurationScope; +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.genivi.commonapi.core.ui.CommonApiUiPlugin; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing <samp>FieldEditorPreferencePage</samp>, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class CommonAPIPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public CommonAPIPreferencePage() { + super(GRID); + setPreferenceStore(new ScopedPreferenceStore(ConfigurationScope.INSTANCE, "org.genivi.commonapi.core")); + setDescription("Preferences for CommonAPI"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField( + new StringFieldEditor(PreferenceConstants.P_LICENSE, "The header to insert for all generated files", 60, getFieldEditorParent())); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +}
\ No newline at end of file diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceConstants.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceConstants.java new file mode 100644 index 0000000..4e5d72a --- /dev/null +++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceConstants.java @@ -0,0 +1,10 @@ +package org.genivi.commonapi.core.ui.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_LICENSE = "licenseHeader"; + +} diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java new file mode 100644 index 0000000..7489496 --- /dev/null +++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java @@ -0,0 +1,25 @@ +package org.genivi.commonapi.core.ui.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IEclipsePreferences store = DefaultScope.INSTANCE.getNode("org.genivi.commonapi.core"); + store.put(PreferenceConstants.P_LICENSE, + "* This Source Code Form is subject to the terms of the Mozilla Public\n" + + "* License, v. 2.0. If a copy of the MPL was not distributed with this\n" + + "* file, You can obtain one at http://mozilla.org/MPL/2.0/."); + } + +} diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend index 2724c28..8678261 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend @@ -35,7 +35,9 @@ import org.franca.deploymodel.dsl.fDeploy.FDInterface import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessorWrapper +import static extension org.eclipse.emf.ecore.plugin.EcorePlugin.* import static com.google.common.base.Preconditions.* +import org.eclipse.core.resources.ResourcesPlugin class FrancaGenerator implements IGenerator { @Inject private extension FTypeCollectionGenerator @@ -127,7 +129,7 @@ class FrancaGenerator implements IGenerator { } val platformPath = new Path(resource.URI.toPlatformString(true)) - val file = EcorePlugin::workspaceRoot.getFile(platformPath) + val file = ResourcesPlugin::getWorkspace().getRoot().getFile(platformPath); return file.location.toString } diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend index 013fadb..c88cad8 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend @@ -10,7 +10,6 @@ import com.google.common.primitives.Ints import java.util.List import org.eclipse.core.runtime.Path import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.plugin.EcorePlugin import org.eclipse.emf.ecore.resource.Resource import org.franca.core.franca.FArrayType import org.franca.core.franca.FAttribute @@ -33,6 +32,8 @@ import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$ import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$EnumBackingType import static com.google.common.base.Preconditions.* +import org.eclipse.core.resources.ResourcesPlugin +import org.eclipse.core.runtime.preferences.ConfigurationScope class FrancaGeneratorExtensions { def String getFullyQualifiedName(FModelElement fModelElement) { @@ -573,7 +574,7 @@ class FrancaGeneratorExtensions { return resource.URI.toFileString val platformPath = new Path(resource.URI.toPlatformString(true)) - val file = EcorePlugin::workspaceRoot.getFile(platformPath) + val file = ResourcesPlugin::getWorkspace().getRoot().getFile(platformPath); return file.location.toString } @@ -582,7 +583,7 @@ class FrancaGeneratorExtensions { /* * This file was generated by the CommonAPI Generators. * - * Insert license header here. + «ConfigurationScope::INSTANCE.getNode("org.genivi.commonapi.core").get("licenseHeader", "")» */ ''' }
\ No newline at end of file |