diff options
Diffstat (limited to 'org.genivi.commonapi.core.ui/src')
5 files changed, 37 insertions, 26 deletions
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"); } } |