summaryrefslogtreecommitdiff
path: root/org.genivi.commonapi.core.ui/src/org/genivi
diff options
context:
space:
mode:
Diffstat (limited to 'org.genivi.commonapi.core.ui/src/org/genivi')
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/CommonApiUiPlugin.java6
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java538
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java92
-rwxr-xr-xorg.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java320
-rwxr-xr-xorg.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties14
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineTextField.java37
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java6
-rwxr-xr-xorg.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PropertyStore.java13
8 files changed, 487 insertions, 539 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 452c147..fbeb93d 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,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.genivi.commonapi.core.ui;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -48,4 +49,9 @@ public class CommonApiUiPlugin extends AbstractUIPlugin {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
+ public static IPreferenceStore getValidatorPreferences() {
+ return INSTANCE.getPreferenceStore();
+ }
+
+
}
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 ec6fe7f..5bd5b38 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
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
@@ -36,9 +37,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
-import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.resource.IResourceDescriptions;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
@@ -46,233 +45,320 @@ import org.eclipse.xtext.util.concurrent.IUnitOfWork;
import org.genivi.commonapi.core.preferences.FPreferences;
import org.genivi.commonapi.core.preferences.PreferenceConstants;
import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
-import org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage;
-import org.genivi.commonapi.core.ui.preferences.FieldEditorOverlayPage;
import com.google.inject.Provider;
public class GenerationCommand extends AbstractHandler {
- @Inject
- private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
- @Inject
- private IResourceDescriptions resourceDescriptions;
- @Inject
- private IResourceSetProvider resourceSetProvider;
- @Inject
- private IGenerator francaGenerator;
-
- @Override
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- final ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- if (!selection.isEmpty())
- executeGeneratorForSelection((IStructuredSelection) selection);
- } else {
- final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
- if (activeEditor instanceof XtextEditor)
- executeGeneratorForXtextEditor((XtextEditor) activeEditor);
- else
- throw new ExecutionException("Cannot handle ExecutionEvent: "
- + event);
- }
-
- return null;
- }
-
- private void executeGeneratorForSelection(
- final IStructuredSelection structuredSelection) {
- IProject project = null;
- for (Iterator<?> iterator = structuredSelection.iterator(); iterator
- .hasNext();) {
- final Object selectiobObject = iterator.next();
- if (selectiobObject instanceof IFile) {
- final IFile file = (IFile) selectiobObject;
- final URI uri = URI.createPlatformResourceURI(file
- .getFullPath().toString(), true);
- final ResourceSet rs = resourceSetProvider.get(file
- .getProject());
- final Resource r = rs.getResource(uri, true);
-
- project = file.getProject();
- FieldEditorOverlayPage page = new CommonAPIPreferencePage();
- page.setElement(project);
- page.createControl(null);
- FPreferences.init(page.getPreferenceStore(), CommonApiUiPlugin
- .getDefault().getPreferenceStore(), project);
- final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess(project);
- fileSystemAccess.setProject(project);
- Job job = new Job("validation and generation") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("handle " + file.getName(),
- IProgressMonitor.UNKNOWN);
- monitor.subTask("validation");
- int i = 0;
- try {
- for (IMarker m : ((IResource) file).findMarkers(
- IMarker.PROBLEM, true, 2)) {
- if ((Integer) m.getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR) {
- i++;
- break;
- }
- }
-
- } catch (CoreException ce) {
- }
- if (r.getErrors().size() == 0 && i == 0) {
- monitor.subTask("Generate");
- try {
- francaGenerator.doGenerate(r, fileSystemAccess);
- } catch (Exception e) {
- exceptionPopUp(e, file);
- return Status.CANCEL_STATUS;
- } catch (Error e) {
- errorPopUp(e, file);
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- } else {
- markerPopUp(file);
- return Status.CANCEL_STATUS;
- }
-
- }
-
- };
- job.schedule();
- }
- }
- }
-
- private void executeGeneratorForXtextEditor(final XtextEditor xtextEditor) {
- final Object fileObject = xtextEditor.getEditorInput().getAdapter(
- IFile.class);
- if (fileObject instanceof IFile) {
- IProject project = ((IResource) fileObject).getProject();
- final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess(project);
- fileSystemAccess.setProject(project);
-
- xtextEditor.getDocument().readOnly(
- new IUnitOfWork<Boolean, XtextResource>() {
- @Override
- public Boolean exec(XtextResource xtextResource)
- throws Exception {
- final XtextResource xtextRes = xtextResource;
- Job job = new Job("validation and generation") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
-
- monitor.beginTask(
- "handle "
- + ((IResource) fileObject)
- .getName(),
- IProgressMonitor.UNKNOWN);
- monitor.subTask("validation");
- int i = 0;
- try {
- for (IMarker m : ((IResource) fileObject)
- .findMarkers(IMarker.PROBLEM,
- true, 2)) {
- if ((Integer) m
- .getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR) {
- i++;
- break;
- }
- }
- } catch (CoreException ce) {
- }
- if (xtextRes.getErrors().size() == 0
- && i == 0) {
- monitor.subTask("Generate");
- try {
- francaGenerator.doGenerate(
- xtextRes, fileSystemAccess);
- } catch (Exception e) {
- exceptionPopUp(e,
- (IFile) fileObject);
- return Status.CANCEL_STATUS;
- } catch (Error e) {
- errorPopUp(e, (IFile) fileObject);
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- } else {
- markerPopUp((IFile) fileObject);
- return Status.CANCEL_STATUS;
- }
- }
-
- };
- job.schedule();
- return Boolean.TRUE;
- }
- });
- }
- }
-
- private void exceptionPopUp(Exception e, IFile f) {
- final Exception ex = e;
- final IFile file = f;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ex.printStackTrace();
- MessageDialog.openError(
- null,
- "Error by generating file " + file.getName(),
- "Couldn't generate file. Exception occured:\n"
- + ex.toString()
- + "\n\nSee console for stack trace.");
- }
- });
- }
-
- private void markerPopUp(IFile f) {
- final IFile file = f;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openError(
- null,
- "Error in file " + file.getName(),
- "Couldn't generate file. File still holds errors!\n\nSee Problems view for details.");
- }
- });
- }
-
- private void errorPopUp(Error e, IFile f) {
- final Error er = e;
- final IFile file = f;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- er.printStackTrace();
- MessageDialog.openError(
- null,
- "Error by generating file " + file.getName(),
- "Couldn't generate file. Error occured:\n"
- + er.toString()
- + "\n\nSee console for stack trace.");
- }
- });
- }
-
- private EclipseResourceFileSystemAccess2 createFileSystemAccess(
- IProject project) {
- IPreferenceStore store = CommonApiUiPlugin.getDefault()
- .getPreferenceStore();
- String outputDir = store.getString(PreferenceConstants.P_OUTPUT_PROXIES);
- if (FPreferences.getInstance().getPreference(project, PreferenceConstants.P_OUTPUT_PROXIES, null) != null)
- {
- outputDir = FPreferences.getInstance().getPreference(project, PreferenceConstants.P_OUTPUT_PROXIES, null);
- }
- final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
-
- fsa.setOutputPath(outputDir);
- fsa.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT)
- .setCreateOutputDirectory(true);
- fsa.setMonitor(new NullProgressMonitor());
-
- return fsa;
- }
+ @Inject
+ protected Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
+ @Inject
+ private IResourceSetProvider resourceSetProvider;
+ @Inject
+ private IGenerator francaGenerator;
+
+ @Override
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ if (!selection.isEmpty())
+ executeGeneratorForSelection((IStructuredSelection) selection);
+ } else {
+ final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
+ if (activeEditor instanceof XtextEditor)
+ executeGeneratorForXtextEditor((XtextEditor) activeEditor);
+ else
+ throw new ExecutionException("Cannot handle ExecutionEvent: "
+ + event);
+ }
+
+ return null;
+ }
+
+ private void executeGeneratorForSelection(
+ final IStructuredSelection structuredSelection) {
+ IProject project = null;
+ for (Iterator<?> iterator = structuredSelection.iterator(); iterator
+ .hasNext();) {
+ final Object selectiobObject = iterator.next();
+ if (selectiobObject instanceof IFile) {
+ final IFile file = (IFile) selectiobObject;
+ final URI uri = URI.createPlatformResourceURI(file
+ .getFullPath().toString(), true);
+ final ResourceSet rs = resourceSetProvider.get(file
+ .getProject());
+ final Resource r = rs.getResource(uri, true);
+
+ project = file.getProject();
+
+ setupPreferences(file);
+
+ final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
+ fileSystemAccess.setProject(project);
+ Job job = new Job("validation and generation") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("handle " + file.getName(),
+ IProgressMonitor.UNKNOWN);
+ monitor.subTask("validation");
+ int i = 0;
+ try {
+ for (IMarker m : ((IResource) file).findMarkers(
+ IMarker.PROBLEM, true, 2)) {
+ if ((Integer) m.getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR) {
+ i++;
+ break;
+ }
+ }
+
+ } catch (CoreException ce) {
+ }
+ if (r.getErrors().size() == 0 && i == 0) {
+ monitor.subTask("Generate");
+ try {
+ francaGenerator.doGenerate(r, fileSystemAccess);
+ } catch (Exception e) {
+ exceptionPopUp(e, file);
+ return Status.CANCEL_STATUS;
+ } catch (Error e) {
+ errorPopUp(e, file);
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ } else {
+ markerPopUp(file);
+ return Status.CANCEL_STATUS;
+ }
+
+ }
+
+ };
+ job.schedule();
+ }
+ }
+ }
+
+ /**
+ * Init core preferences
+ * @param file
+ * @param page
+ * @param project
+ */
+ protected void setupPreferences(IFile file) {
+
+ initPreferences(file, CommonApiUiPlugin.getDefault().getPreferenceStore());
+ }
+
+ private void executeGeneratorForXtextEditor(final XtextEditor xtextEditor) {
+ final Object fileObject = xtextEditor.getEditorInput().getAdapter(
+ IFile.class);
+ if (fileObject instanceof IFile) {
+ IProject project = ((IResource) fileObject).getProject();
+ final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
+ fileSystemAccess.setProject(project);
+
+ xtextEditor.getDocument().readOnly(
+ new IUnitOfWork<Boolean, XtextResource>() {
+ @Override
+ public Boolean exec(XtextResource xtextResource)
+ throws Exception {
+ final XtextResource xtextRes = xtextResource;
+ Job job = new Job("validation and generation") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ monitor.beginTask(
+ "handle "
+ + ((IResource) fileObject)
+ .getName(),
+ IProgressMonitor.UNKNOWN);
+ monitor.subTask("validation");
+ int i = 0;
+ try {
+ for (IMarker m : ((IResource) fileObject)
+ .findMarkers(IMarker.PROBLEM,
+ true, 2)) {
+ if ((Integer) m
+ .getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR) {
+ i++;
+ break;
+ }
+ }
+ } catch (CoreException ce) {
+ }
+ if (xtextRes.getErrors().size() == 0
+ && i == 0) {
+ monitor.subTask("Generate");
+ try {
+ francaGenerator.doGenerate(
+ xtextRes, fileSystemAccess);
+ } catch (Exception e) {
+ exceptionPopUp(e,
+ (IFile) fileObject);
+ return Status.CANCEL_STATUS;
+ } catch (Error e) {
+ errorPopUp(e, (IFile) fileObject);
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ } else {
+ markerPopUp((IFile) fileObject);
+ return Status.CANCEL_STATUS;
+ }
+ }
+
+ };
+ job.schedule();
+ return Boolean.TRUE;
+ }
+ });
+ }
+ }
+
+ private void exceptionPopUp(Exception e, IFile f) {
+ final Exception ex = e;
+ final IFile file = f;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ ex.printStackTrace();
+ MessageDialog.openError(
+ null,
+ "Error by generating file " + file.getName(),
+ "Couldn't generate file. Exception occured:\n"
+ + ex.toString()
+ + "\n\nSee console for stack trace.");
+ }
+ });
+ }
+
+ private void markerPopUp(IFile f) {
+ final IFile file = f;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openError(
+ null,
+ "Error in file " + file.getName(),
+ "Couldn't generate file. File still holds errors!\n\nSee Problems view for details.");
+ }
+ });
+ }
+
+ private void errorPopUp(Error e, IFile f) {
+ final Error er = e;
+ final IFile file = f;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ er.printStackTrace();
+ MessageDialog.openError(
+ null,
+ "Error by generating file " + file.getName(),
+ "Couldn't generate file. Error occured:\n"
+ + er.toString()
+ + "\n\nSee console for stack trace.");
+ }
+ });
+ }
+
+ protected EclipseResourceFileSystemAccess2 createFileSystemAccess() {
+
+ final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
+
+ fsa.setOutputConfigurations(FPreferences.getInstance().getOutputpathConfiguration());
+
+ fsa.setMonitor(new NullProgressMonitor());
+
+ return fsa;
+ }
+
+ /**
+ * Set the properties for the code generation from the resource properties (set with the property page, via the context menu).
+ * Take default values from the eclipse preference page.
+ * @param file
+ * @param store - the eclipse preference store
+ */
+ private void initPreferences(IFile file, IPreferenceStore store) {
+ FPreferences instance = FPreferences.getInstance();
+
+ String outputFolderCommon = null;
+ String outputFolderProxies = null;
+ String outputFolderStubs = null;
+ String outputFolderSkeleton = null;
+ String licenseHeader = null;
+ String generateProxy = null;
+ String generatStub = null;
+ String generatSkeleton = null;
+ String skeletonPostfix = null;
+ String enumPrefix = null;
+
+ IProject project = file.getProject();
+ IResource resource = file;
+
+ try {
+ // Should project or file specific properties be used ?
+ String useProject1 = project.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_USEPROJECTSETTINGS));
+ String useProject2 = file.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_USEPROJECTSETTINGS));
+ if("true".equals(useProject1) || "true".equals(useProject2)) {
+ resource = project;
+ }
+ outputFolderCommon = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_COMMON));
+ outputFolderSkeleton = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_SKELETON));
+ outputFolderProxies = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_PROXIES));
+ outputFolderStubs = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_STUBS));
+ licenseHeader = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_LICENSE));
+ generateProxy = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATEPROXY));
+ generatStub = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATESTUB));
+ generatSkeleton = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATESKELETON));
+ skeletonPostfix = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_SKELETONPOSTFIX));
+ enumPrefix = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_ENUMPREFIX));
+ } catch (CoreException ce) {
+ System.err.println("Failed to get property for " + resource.getName());
+ }
+
+ // Set defaults in the case, where nothing was specified from the user.
+ if(outputFolderCommon == null) {
+ outputFolderCommon = store.getString(PreferenceConstants.P_OUTPUT_COMMON);
+ }
+ if(outputFolderProxies == null) {
+ outputFolderProxies = store.getString(PreferenceConstants.P_OUTPUT_PROXIES);
+ }
+ if(outputFolderStubs == null) {
+ outputFolderStubs = store.getString(PreferenceConstants.P_OUTPUT_STUBS);
+ }
+ if(outputFolderSkeleton == null) {
+ outputFolderSkeleton = store.getString(PreferenceConstants.P_OUTPUT_SKELETON);
+ }
+ if(skeletonPostfix == null) {
+ skeletonPostfix = store.getString(PreferenceConstants.P_SKELETONPOSTFIX);
+ }
+ if(enumPrefix == null) {
+ enumPrefix = store.getString(PreferenceConstants.P_ENUMPREFIX);
+ }
+ if(licenseHeader == null) {
+ licenseHeader = store.getString(PreferenceConstants.P_LICENSE);
+ }
+ if(generateProxy == null) {
+ generateProxy = "true";
+ }
+ if(generatStub == null) {
+ generatStub = "true";
+ }
+ if(generatSkeleton == null) {
+ generatSkeleton = "false";
+ }
+
+ // finally, store the properties for the code generator
+ instance.setPreference(PreferenceConstants.P_OUTPUT_COMMON, outputFolderCommon);
+ instance.setPreference(PreferenceConstants.P_OUTPUT_PROXIES, outputFolderProxies);
+ instance.setPreference(PreferenceConstants.P_OUTPUT_STUBS, outputFolderStubs);
+ instance.setPreference(PreferenceConstants.P_OUTPUT_SKELETON, outputFolderSkeleton);
+ instance.setPreference(PreferenceConstants.P_LICENSE, licenseHeader);
+ instance.setPreference(PreferenceConstants.P_GENERATEPROXY, generateProxy);
+ instance.setPreference(PreferenceConstants.P_GENERATESTUB, generatStub);
+ instance.setPreference(PreferenceConstants.P_GENERATESKELETON, generatSkeleton);
+ instance.setPreference(PreferenceConstants.P_SKELETONPOSTFIX, skeletonPostfix);
+ instance.setPreference(PreferenceConstants.P_ENUMPREFIX, enumPrefix);
+ }
+
}
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 9afa5f6..e825c86 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
@@ -8,10 +8,16 @@
package org.genivi.commonapi.core.ui.preferences;
+import org.eclipse.cdt.ui.newui.MultiLineTextFieldEditor;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.genivi.commonapi.core.preferences.PreferenceConstants;
@@ -19,25 +25,27 @@ import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
/**
* This class represents a preference page that is contributed to the
- * Preferences dialog. By subclassing <samp>FieldEditorOverlayPage</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.
+ * Preferences dialog. By subclassing <samp>FieldEditorOverlayPage</samp>.
* <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.
+ * This page is used to modify preferences. They are stored in the preference store that
+ * belongs to the main plug-in class.
*/
public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements IWorkbenchPreferencePage
{
- private FieldEditor license = null;
+ private MultiLineTextFieldEditor license = null;
private FieldEditor proxyOutput = null;
private FieldEditor stubOutput = null;
-
+ private FieldEditor commonOutput = null;
+ private FieldEditor skeletonOutput = null;
+ private StringFieldEditor postFix = null;
+ private BooleanFieldEditor generatSkeleton = null;
+ private StringFieldEditor enumPrefix = null;
+
public CommonAPIPreferencePage()
{
super(GRID);
- setDescription("Preferences for CommonAPI");
}
/**
@@ -47,24 +55,54 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
*/
public void createFieldEditors()
{
- license = new MultiLineTextField(PreferenceConstants.P_LICENSE, "The header to insert for all generated files", 60,
+ generatSkeleton = new BooleanFieldEditor(PreferenceConstants.P_GENERATESKELETON, "Generate skeleton code", getFieldEditorParent());
+ addField(generatSkeleton);
+
+ license = new MultiLineTextFieldEditor(PreferenceConstants.P_LICENSE, "The license header to be inserted in all generated files", 30,
getFieldEditorParent());
+ license.setLabelText(""); // need to set this parameter (seems to be a bug)
addField(license);
- proxyOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_PROXIES, "Output directory for proxies inside project", 30,
+
+ // output directory definitions
+ commonOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_COMMON, "Output directory for the common code", 30,
+ getFieldEditorParent());
+ addField(commonOutput);
+ proxyOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_PROXIES, "Output directory for proxy code", 30,
getFieldEditorParent());
addField(proxyOutput);
- stubOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_STUBS, "Output directory for stubs inside project", 30,
+ stubOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_STUBS, "Output directory for stub code", 30,
+ getFieldEditorParent());
+ addField(stubOutput);
+ skeletonOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_SKELETON, "Output directory for the skeleton code", 30,
getFieldEditorParent());
- addField(stubOutput);
+ addField(skeletonOutput);
+
+ postFix = new StringFieldEditor(PreferenceConstants.P_SKELETONPOSTFIX, "Postfix for skeleton filenames", 30, getFieldEditorParent());
+ addField(postFix);
+ postFix.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
+
+ enumPrefix = new StringFieldEditor(PreferenceConstants.P_ENUMPREFIX, "Prefix for enumeration literals", 30, getFieldEditorParent());
+ addField(enumPrefix);
}
@Override
protected void performDefaults()
{
- DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_OUTPUT_PROXIES,
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, "true");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, "true");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESKELETON, "false");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_SKELETONPOSTFIX, "Default");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_ENUMPREFIX, "");
+
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_OUTPUT_PROXIES,
PreferenceConstants.DEFAULT_OUTPUT);
DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE)
.put(PreferenceConstants.P_OUTPUT_STUBS, PreferenceConstants.DEFAULT_OUTPUT);
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE)
+ .put(PreferenceConstants.P_OUTPUT_COMMON, PreferenceConstants.DEFAULT_OUTPUT);
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE)
+ .put(PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants.DEFAULT_OUTPUT);
+
super.performDefaults();
}
@@ -86,4 +124,32 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
return CommonApiUiPlugin.getDefault().getPreferenceStore();
}
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+
+ String preferenceName = ((FieldEditor) event.getSource()).getPreferenceName();
+ // was the skeletonOutput field editor changed ?
+ if(preferenceName != null && preferenceName.equals(PreferenceConstants.P_SKELETONPOSTFIX)) {
+ boolean enableSkeletonCode = !event.getNewValue().toString().isEmpty();
+ generatSkeleton.setEnabled(enableSkeletonCode, getFieldEditorParent());
+
+ if(!enableSkeletonCode) {
+ // disable skeleton code generation
+ generatSkeleton.loadDefault();
+
+ IResource resource = (IResource) getElement();
+ try
+ {
+ resource.setPersistentProperty(new QualifiedName(getPageId(), PreferenceConstants.P_GENERATESKELETON), "false");
+ }
+ catch (CoreException e)
+ {
+ }
+ }
+ }
+ // will be disposed from FieldEditorPreferencePage !
+ }
+
+
}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java
index aad4ba0..7a859df 100755
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java
@@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -32,25 +31,17 @@ import org.eclipse.jface.preference.PreferenceNode;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.genivi.commonapi.core.preferences.PreferenceConstants;
public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage
{
-
- /***
- * Name of resource property for the selection of workbench or project
- * settings
- ***/
- // public static final String USEPROJECTSETTINGS = "useProjectSettings"; //$NON-NLS-1$
-
private static final String FALSE = "false"; //$NON-NLS-1$
private static final String TRUE = "true"; //$NON-NLS-1$
@@ -61,19 +52,14 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
private Button checkboxproxy = null;
private Button checkboxstub = null;
+ private Button checkboxProject = null;
// Stores owning element of properties
private IAdaptable element;
- // Additional buttons for property pages
- private Button useWorkspaceSettingsButton, useProjectSettingsButton, configureButton;
-
// Overlay preference store for property pages
private IPreferenceStore overlayStore;
- // The image descriptor of this pages title image
- private ImageDescriptor image;
-
// Cache for page id
private String pageId;
@@ -114,7 +100,6 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
public FieldEditorOverlayPage(String title, ImageDescriptor image, int style)
{
super(title, image, style);
- this.image = image;
}
/**
@@ -167,11 +152,6 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
super.addField(editor);
}
- protected void addButton(Button button)
- {
- buttons.add(button);
- }
-
/**
* We override the createControl method. In case of property pages we create
* a new PropertyStore as local preference store. After all control have
@@ -209,7 +189,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
super.createControl(parent);
// Update state of all subclass controls
if (isPropertyPage())
- updateFieldEditors();
+ enableControls();
}
}
@@ -221,78 +201,9 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
*/
protected Control createContents(Composite parent)
{
- if (isPropertyPage())
- {
- createSelectionGroup(parent);
- updateFieldEditors();
- }
- else
- createButtons(parent);
- return super.createContents(parent);
- }
-
- /**
- * Creates and initializes a selection group with two choice buttons and one
- * push button.
- *
- * @param parent
- * - the parent composite
- */
- private void createSelectionGroup(Composite parent)
- {
- Composite comp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- comp.setLayout(layout);
- comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Composite radioGroup = new Composite(comp, SWT.NONE);
- radioGroup.setLayout(new GridLayout());
- radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- String msg = Messages.getString("OverlayPage.Use_Workspace_Settings");
- if (element instanceof IFile)
- msg = Messages.getString("OverlayPage.Use_Project_Settings");
- useWorkspaceSettingsButton = createRadioButton(radioGroup, msg); //$NON-NLS-1$
- msg = Messages.getString("OverlayPage.Use_Project_Settings");
- if (element instanceof IFile)
- msg = Messages.getString("OverlayPage.Use_File_Settings");
- useProjectSettingsButton = createRadioButton(radioGroup, msg); //$NON-NLS-1$
- configureButton = new Button(comp, SWT.PUSH);
- msg = Messages.getString("OverlayPage.Configure_Workspace_Settings");
- if (element instanceof IFile)
- msg = Messages.getString("OverlayPage.Configure_Project_Settings");
- configureButton.setText(msg); //$NON-NLS-1$
- configureButton.addSelectionListener(new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent e)
- {
- configureWorkspaceSettings();
- }
- });
createButtons(parent);
- // Set workspace/project radio buttons
- try
- {
- String use = ((IResource) element).getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.USEPROJECTSETTINGS));
- if (use == null)
- {
- ((IResource) element).setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.USEPROJECTSETTINGS),
- Boolean.FALSE.toString());
- use = FALSE;
- }
- if (TRUE.equals(use))
- {
- useProjectSettingsButton.setSelection(true);
- configureButton.setEnabled(false);
- }
- else
- useWorkspaceSettingsButton.setSelection(true);
- }
- catch (CoreException e)
- {
- useWorkspaceSettingsButton.setSelection(true);
- }
+ enableControls();
+ return super.createContents(parent);
}
public void createButtons(Composite parent)
@@ -306,103 +217,70 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
Composite radioGroup = new Composite(comp, SWT.BOTTOM);
radioGroup.setLayout(new GridLayout());
radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Group settingsGroup = new Group(radioGroup, SWT.SHADOW_IN);
+ //settingsGroup.setText("Scope of properties: ");
+ settingsGroup.setLayout(new GridLayout());
+ settingsGroup.setLayoutData(new GridData());
+
+ checkboxProject = new Button(settingsGroup, SWT.CHECK);
+ checkboxProject.setText("Enable project specific settings");
+
checkboxproxy = new Button(radioGroup, SWT.CHECK);
checkboxproxy.setText(Messages.getString("OverlayPage.Generate_Proxy"));
checkboxstub = new Button(radioGroup, SWT.CHECK);
checkboxstub.setText(Messages.getString("OverlayPage.Generate_Stub"));
+
+ buttons.add(checkboxproxy);
+ buttons.add(checkboxproxy);
+ buttons.add(checkboxProject);
+
+ String genProxy = TRUE;
+ String genStub = TRUE;
+ String project = FALSE;
+
if (isPropertyPage())
{
+ // get values from the persistent properties of theses resources and set the button states
try
{
- String use = ((IResource) getElement())
+ genProxy = ((IResource) getElement())
.getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATEPROXY));
- if (TRUE.equals(use))
- checkboxproxy.setSelection(true);
+ genStub = ((IResource) getElement())
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATESTUB));
+ project = ((IResource) getElement())
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_USEPROJECTSETTINGS));
}
catch (CoreException e)
{
- checkboxproxy.setSelection(true);
+ // failed to access this resource...
}
- try
- {
- String use = ((IResource) getElement())
- .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATESTUB));
- if (TRUE.equals(use))
- checkboxstub.setSelection(true);
- else if (!checkboxproxy.getSelection())
- {
- checkboxproxy.setSelection(true);
- checkboxstub.setSelection(true);
- }
+ // Not all properties are set for this resource
+ if(genProxy == null) {
+ genProxy = TRUE;
}
- catch (CoreException e)
- {
- checkboxstub.setSelection(true);
+ if(genStub == null) {
+ genStub = TRUE;
}
- }
- else
- {
- String use = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATEPROXY, "");
- use = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATEPROXY, use);
- if (TRUE.equals(use))
- checkboxproxy.setSelection(true);
- use = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATESTUB, "");
- use = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATESTUB, use);
- if (TRUE.equals(use))
- checkboxstub.setSelection(true);
- if (!checkboxproxy.getSelection() && !checkboxstub.getSelection())
- {
- checkboxproxy.setSelection(true);
- checkboxstub.setSelection(true);
+ if(project == null) {
+ project = FALSE;
}
}
- checkboxproxy.addSelectionListener(new SelectionAdapter()
- {
-
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- if (!checkboxproxy.getSelection() && !checkboxstub.getSelection())
- checkboxstub.setSelection(true);
- }
-
- });
- checkboxstub.addSelectionListener(new SelectionAdapter()
+ else // is a preference page
{
+ genProxy = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATEPROXY, "");
+ genProxy = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATEPROXY, genProxy);
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- if (!checkboxproxy.getSelection() && !checkboxstub.getSelection())
- checkboxproxy.setSelection(true);
- }
- });
- addButton(checkboxproxy);
- addButton(checkboxstub);
- }
+ genStub = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATESTUB, "");
+ genStub = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATESTUB, genStub);
- /**
- * Convenience method creating a radio button
- *
- * @param parent
- * - the parent composite
- * @param label
- * - the button label
- * @return - the new button
- */
- private Button createRadioButton(Composite parent, String label)
- {
- final Button button = new Button(parent, SWT.RADIO);
- button.setText(label);
- button.addSelectionListener(new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent e)
- {
- configureButton.setEnabled(button == useWorkspaceSettingsButton);
- updateFieldEditors();
- }
- });
- return button;
+ project = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_USEPROJECTSETTINGS, "");
+ project = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_USEPROJECTSETTINGS, project);
+ }
+ // set the selection state of the buttons
+ checkboxproxy.setSelection(TRUE.equals(genProxy));
+ checkboxstub.setSelection(TRUE.equals(genStub));
+ checkboxProject.setSelection(TRUE.equals(project));
}
/**
@@ -413,40 +291,27 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
*/
public IPreferenceStore getPreferenceStore()
{
- if (isPropertyPage())
+ if (isPropertyPage()) {
return overlayStore;
+ }
return super.getPreferenceStore();
}
- /*
- * Enables or disables the field editors and buttons of this page
- */
- private void updateFieldEditors()
- {
- // We iterate through all field editors
- boolean enabled = useProjectSettingsButton.getSelection();
- updateFieldEditors(enabled);
- }
-
/**
- * Enables or disables the field editors and buttons of this page Subclasses
- * may override.
- *
- * @param enabled
- * - true if enabled
+ * Enables the field editors and buttons of this page
*/
- protected void updateFieldEditors(boolean enabled)
+ protected void enableControls()
{
Composite parent = getFieldEditorParent();
Iterator<FieldEditor> it = editors.iterator();
while (it.hasNext())
{
FieldEditor editor = it.next();
- editor.setEnabled(enabled, parent);
+ editor.setEnabled(true, parent);
}
for (Button button : buttons)
{
- button.setEnabled(enabled);
+ button.setEnabled(true);
}
}
@@ -460,79 +325,46 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
public boolean performOk()
{
boolean result = super.performOk();
+ String genProxy = (checkboxproxy.getSelection()) ? TRUE : FALSE;
+ String genStub = (checkboxstub.getSelection()) ? TRUE : FALSE;
+ String project = (checkboxProject.getSelection()) ? TRUE : FALSE;
+
if (result && isPropertyPage())
{
- // Save state of radio buttons in project properties
IResource resource = (IResource) getElement();
try
{
- String value = (useProjectSettingsButton.getSelection()) ? TRUE : FALSE;
- resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.USEPROJECTSETTINGS), value);
- value = (checkboxproxy.getSelection()) ? TRUE : FALSE;
- resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATEPROXY), value);
- value = (checkboxstub.getSelection()) ? TRUE : FALSE;
- resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATESTUB), value);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_USEPROJECTSETTINGS), project);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATEPROXY), genProxy);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATESTUB), genStub);
}
catch (CoreException e)
{
+ result = false;
}
}
else if (result)
{
- String value = (checkboxproxy.getSelection()) ? TRUE : FALSE;
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, value);
- value = (checkboxstub.getSelection()) ? TRUE : FALSE;
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, value);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, genProxy);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, genStub);
}
return result;
}
/**
- * We override the performDefaults method. In case of property pages we
- * switch back to the workspace settings and disable the field editors.
- *
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
+ * In case of property page set checkboxes to true
+ */
protected void performDefaults()
{
- if (isPropertyPage())
- {
- useWorkspaceSettingsButton.setSelection(true);
- useProjectSettingsButton.setSelection(false);
- configureButton.setEnabled(true);
- checkboxproxy.setSelection(true);
- checkboxstub.setSelection(true);
- updateFieldEditors();
- }
- super.performDefaults();
- }
-
- /**
- * Creates a new preferences page and opens it
- *
- * @see com.bdaum.SpellChecker.preferences.SpellCheckerPreferencePage#configureWorkspaceSettings()
- */
- protected void configureWorkspaceSettings()
- {
- try
- {
- // create a new instance of the current class
- FieldEditorOverlayPage page = (FieldEditorOverlayPage) this.getClass().newInstance();
- page.setTitle(getTitle());
- if (element instanceof IFile)
- page.setElement(((IFile) element).getProject());
- page.setImageDescriptor(image);
- // and show it
- showPreferencePage(pageId, page);
- }
- catch (InstantiationException e)
- {
- e.printStackTrace();
- }
- catch (IllegalAccessException e)
- {
- e.printStackTrace();
- }
+ enableControls();
+ checkboxproxy.setSelection(true);
+ checkboxstub.setSelection(true);
+ checkboxProject.setSelection(false);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, "true");
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, "true");
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_USEPROJECTSETTINGS, "false");
+
+ super.performDefaults();
}
/**
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties
index 673a828..081c072 100755
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties
@@ -1,9 +1,9 @@
-OverlayPage.Use_Workspace_Settings=Use workspace settings
-OverlayPage.Use_Project_Settings=Use project settings
-OverlayPage.Configure_Workspace_Settings=Configure Workspace Settings ...
-OverlayPage.Configure_Project_Settings=Configure Project Settings ...
+
+
+
PropertyStore.Cannot_write_resource_property=Cannot write resource property
PropertyStore.Cannot_read_resource_property=Cannot read resource property
-OverlayPage.Generate_Proxy=Generate with ProxyGenerator
-OverlayPage.Generate_Stub=Generate with StubGenerator
-OverlayPage.Use_File_Settings=Use file settings \ No newline at end of file
+
+OverlayPage.Generate_Proxy=Generate proxy code
+OverlayPage.Generate_Stub=Generate stub code
+
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineTextField.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineTextField.java
deleted file mode 100644
index 4a91157..0000000
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineTextField.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2013 BMW Group Author: Manfred Bathelt (manfred.bathelt@bmw.de)
- * Author: Juergen Gehring (juergen.gehring@bmw.de) This Source Code Form is
- * subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the
- * MPL was not distributed with this file, You can obtain one at
- * http://mozilla.org/MPL/2.0/.
- */
-
-package org.genivi.commonapi.core.ui.preferences;
-
-import org.eclipse.cdt.ui.newui.MultiLineTextFieldEditor;
-import org.eclipse.swt.widgets.Composite;
-
-public class MultiLineTextField extends MultiLineTextFieldEditor {
-
- public MultiLineTextField() {
- super();
- }
-
- public MultiLineTextField(String name, String labelText, Composite parent) {
- super(name, labelText, parent);
- }
-
- public MultiLineTextField(String name, String labelText, int width, Composite parent) {
- super(name, labelText, width, parent);
- }
-
- public MultiLineTextField(String name, String labelText, int width, int strategy, Composite parent) {
- super(name, labelText, width, strategy, parent);
- }
-
- @Override
- public void setEnabled(boolean enabled, Composite parent) {
- // super.setEnabled(enabled, parent);
- getTextControl(parent).setEnabled(enabled);
- }
-} \ No newline at end of file
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 eea41a1..0d33ecd 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
@@ -26,12 +26,16 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = CommonApiUiPlugin.getDefault().getPreferenceStore();
- store.setDefault(PreferenceConstants.USEPROJECTSETTINGS, true);
store.setDefault(PreferenceConstants.P_LICENSE, PreferenceConstants.DEFAULT_LICENSE);
store.setDefault(PreferenceConstants.P_OUTPUT_PROXIES, PreferenceConstants.DEFAULT_OUTPUT);
store.setDefault(PreferenceConstants.P_OUTPUT_STUBS, PreferenceConstants.DEFAULT_OUTPUT);
+ store.setDefault(PreferenceConstants.P_OUTPUT_COMMON, PreferenceConstants.DEFAULT_OUTPUT);
+ store.setDefault(PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants.DEFAULT_OUTPUT);
store.setDefault(PreferenceConstants.P_GENERATEPROXY, true);
store.setDefault(PreferenceConstants.P_GENERATESTUB, true);
+ store.setDefault(PreferenceConstants.P_GENERATESKELETON, false);
+ store.setDefault(PreferenceConstants.P_SKELETONPOSTFIX, PreferenceConstants.DEFAULT_SKELETONPOSTFIX);
+ store.setDefault(PreferenceConstants.P_USEPROJECTSETTINGS, false);
}
}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PropertyStore.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PropertyStore.java
index 180bfbd..e7d4d2d 100755
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PropertyStore.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PropertyStore.java
@@ -16,8 +16,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceStore;
-import org.genivi.commonapi.core.preferences.FPreferences;
-import org.genivi.commonapi.core.preferences.PreferenceConstants;
public class PropertyStore extends PreferenceStore {
@@ -31,8 +29,6 @@ public class PropertyStore extends PreferenceStore {
this.resource = resource;
this.workbenchStore = workbenchStore;
this.pageId = pageId;
- FPreferences pref = FPreferences.getInstance();
- pref.addPreferences(resource);
}
/*** Write modified values back to properties ***/
@@ -42,13 +38,8 @@ public class PropertyStore extends PreferenceStore {
* @see org.eclipse.jface.preference.IPersistentPreferenceStore#save()
*/
public void save() throws IOException {
- try {
- if (getProperty(PreferenceConstants.USEPROJECTSETTINGS).equals(Boolean.TRUE.toString()))
- writeProperties();
- } catch (CoreException e) {
- throw new IOException(Messages.getString("PropertyStore.Cannot_read_resource_property")
- + PreferenceConstants.USEPROJECTSETTINGS); //$NON-NLS-1$
- }
+
+ writeProperties();
}
/*