summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--org.genivi.commonapi.core.ui/plugin.xml7
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/CommonApiUiPlugin.java14
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java12
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java16
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceConstants.java10
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java11
-rw-r--r--org.genivi.commonapi.core/META-INF/MANIFEST.MF2
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend11
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java13
9 files changed, 63 insertions, 33 deletions
diff --git a/org.genivi.commonapi.core.ui/plugin.xml b/org.genivi.commonapi.core.ui/plugin.xml
index d5b4594..317fedb 100644
--- a/org.genivi.commonapi.core.ui/plugin.xml
+++ b/org.genivi.commonapi.core.ui/plugin.xml
@@ -72,12 +72,11 @@
<page
class="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage"
id="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage"
- name="CommonAPI Preferences">
+ name="CommonAPI">
</page>
- </extension>
- <extension
+ </extension> <extension
point="org.eclipse.core.runtime.preferences">
- <initializer
+ <initializer
class="org.genivi.commonapi.core.ui.preferences.PreferenceInitializer">
</initializer>
</extension>
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 1afe578..452c147 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,9 +6,8 @@
* 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.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.xtext.ui.ecore.Activator;
import org.osgi.framework.BundleContext;
public class CommonApiUiPlugin extends AbstractUIPlugin {
@@ -38,4 +37,15 @@ public class CommonApiUiPlugin extends AbstractUIPlugin {
public static CommonApiUiPlugin getDefault() {
return INSTANCE;
}
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
index d6cad91..8345811 100644
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
@@ -31,12 +32,13 @@ import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
+import org.genivi.commonapi.core.preferences.PreferenceConstants;
+import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
import com.google.inject.Provider;
public class GenerationCommand extends AbstractHandler {
- public static final String OUTPUT_DIRECTORY = "src-gen";
-
+
@Inject private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
@Inject private IResourceDescriptions resourceDescriptions;
@Inject private IResourceSetProvider resourceSetProvider;
@@ -94,9 +96,13 @@ public class GenerationCommand extends AbstractHandler {
}
private EclipseResourceFileSystemAccess2 createFileSystemAccess() {
+
+ IPreferenceStore store = CommonApiUiPlugin.getDefault().getPreferenceStore();
+ String outputDir = store.getString(PreferenceConstants.P_OUTPUT);
+
final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
- fsa.setOutputPath(OUTPUT_DIRECTORY);
+ fsa.setOutputPath(outputDir);
fsa.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT).setCreateOutputDirectory(true);
fsa.setMonitor(new NullProgressMonitor());
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
index 0947a6d..64421b0 100644
--- 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
@@ -1,13 +1,10 @@
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;
+import org.genivi.commonapi.core.preferences.PreferenceConstants;
/**
* This class represents a preference page that
@@ -26,10 +23,9 @@ import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
public class CommonAPIPreferencePage
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
-
+
public CommonAPIPreferencePage() {
super(GRID);
- setPreferenceStore(new ScopedPreferenceStore(ConfigurationScope.INSTANCE, "org.genivi.commonapi.core"));
setDescription("Preferences for CommonAPI");
}
@@ -41,13 +37,19 @@ public class CommonAPIPreferencePage
*/
public void createFieldEditors() {
addField(
- new StringFieldEditor(PreferenceConstants.P_LICENSE, "The header to insert for all generated files", 60, getFieldEditorParent()));
+ new StringFieldEditor(PreferenceConstants.P_LICENSE, "The header to insert for all generated files", 60, getFieldEditorParent()));
+ addField(
+ new StringFieldEditor(PreferenceConstants.P_OUTPUT, "Output directory inside project", 30, getFieldEditorParent()));
}
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
+ //PreferenceInitializer init = new PreferenceInitializer();
+ //init.initializeDefaultPreferences();
+ setPreferenceStore(CommonApiUiPlugin.getDefault().getPreferenceStore());
}
} \ 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
deleted file mode 100644
index 4e5d72a..0000000
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceConstants.java
+++ /dev/null
@@ -1,10 +0,0 @@
-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
index 7489496..2eb7c3f 100644
--- 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
@@ -1,8 +1,9 @@
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;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.genivi.commonapi.core.preferences.PreferenceConstants;
+import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
/**
* Class used to initialize default preference values.
@@ -15,11 +16,13 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
* @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,
+ IPreferenceStore store = CommonApiUiPlugin.getDefault().getPreferenceStore();
+ store.setDefault(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/.");
+
+ store.setDefault(PreferenceConstants.P_OUTPUT, "src-gen");
}
}
diff --git a/org.genivi.commonapi.core/META-INF/MANIFEST.MF b/org.genivi.commonapi.core/META-INF/MANIFEST.MF
index 338b59e..c6c242f 100644
--- a/org.genivi.commonapi.core/META-INF/MANIFEST.MF
+++ b/org.genivi.commonapi.core/META-INF/MANIFEST.MF
@@ -15,4 +15,4 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="3.8.0",
Import-Package: javax.inject;version="1.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.genivi.commonapi.core.deployment,
- org.genivi.commonapi.core.generator
+ org.genivi.commonapi.core.generator, org.genivi.commonapi.core.preferences
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 c88cad8..fb47cf8 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
@@ -33,7 +33,9 @@ import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$
import static com.google.common.base.Preconditions.*
import org.eclipse.core.resources.ResourcesPlugin
-import org.eclipse.core.runtime.preferences.ConfigurationScope
+import org.eclipse.core.runtime.preferences.InstanceScope
+import org.eclipse.core.runtime.preferences.DefaultScope
+import org.genivi.commonapi.core.preferences.PreferenceConstants
class FrancaGeneratorExtensions {
def String getFullyQualifiedName(FModelElement fModelElement) {
@@ -578,12 +580,17 @@ class FrancaGeneratorExtensions {
return file.location.toString
}
+
+ def getHeader() {
+ val deflt = DefaultScope::INSTANCE.getNode(PreferenceConstants::SCOPE).get(PreferenceConstants::P_LICENSE, "");
+ return InstanceScope::INSTANCE.getNode(PreferenceConstants::SCOPE).get(PreferenceConstants::P_LICENSE, deflt);
+ }
def generateCommonApiLicenseHeader() '''
/*
* This file was generated by the CommonAPI Generators.
*
- «ConfigurationScope::INSTANCE.getNode("org.genivi.commonapi.core").get("licenseHeader", "")»
+ «getHeader()»
*/
'''
} \ No newline at end of file
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..68d0c47
--- /dev/null
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java
@@ -0,0 +1,13 @@
+package org.genivi.commonapi.core.preferences;
+
+/**
+ * Constant definitions for plug-in preferences
+ */
+public class PreferenceConstants {
+
+ public static final String SCOPE = "org.genivi.commonapi.core.ui";
+
+ public static final String P_LICENSE = "licenseHeader";
+ public static final String P_OUTPUT = "outputDir";
+
+}