diff options
Diffstat (limited to 'org.genivi.commonapi.core.ui')
18 files changed, 534 insertions, 947 deletions
diff --git a/org.genivi.commonapi.core.ui/.classpath b/org.genivi.commonapi.core.ui/.classpath index ad32c83..1fa3e68 100644 --- a/org.genivi.commonapi.core.ui/.classpath +++ b/org.genivi.commonapi.core.ui/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/org.genivi.commonapi.core.ui/.gitignore b/org.genivi.commonapi.core.ui/.gitignore index ea8c4bf..ad19da6 100644 --- a/org.genivi.commonapi.core.ui/.gitignore +++ b/org.genivi.commonapi.core.ui/.gitignore @@ -1 +1,3 @@ +*~ +/bin /target diff --git a/org.genivi.commonapi.core.ui/.settings/org.eclipse.core.resources.prefs b/org.genivi.commonapi.core.ui/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/org.genivi.commonapi.core.ui/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/org.genivi.commonapi.core.ui/.settings/org.eclipse.core.runtime.prefs b/org.genivi.commonapi.core.ui/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000..5a0ad22 --- /dev/null +++ b/org.genivi.commonapi.core.ui/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.genivi.commonapi.core.ui/.settings/org.eclipse.jdt.core.prefs b/org.genivi.commonapi.core.ui/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8000cd6..0000000 --- a/org.genivi.commonapi.core.ui/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.genivi.commonapi.core.ui/LICENSE b/org.genivi.commonapi.core.ui/LICENSE deleted file mode 100644 index 14e2f77..0000000 --- a/org.genivi.commonapi.core.ui/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - 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/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF index b89ed62..5882593 100644 --- a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF +++ b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF @@ -2,25 +2,24 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: GENIVI Common API UI Bundle-SymbolicName: org.genivi.commonapi.core.ui;singleton:=true -Bundle-Version: 2.1.6.qualifier +Bundle-Version: 3.1.1.qualifier Bundle-Activator: org.genivi.commonapi.core.ui.CommonApiUiPlugin Bundle-Vendor: BMW AG -Require-Bundle: org.eclipse.ui, - org.eclipse.core.expressions;bundle-version="3.4.400", - org.eclipse.core.resources, - org.eclipse.core.runtime, - org.eclipse.xtext.builder;bundle-version="2.4.0", - org.eclipse.xtext.generator;bundle-version="2.4.0", - org.eclipse.xtext.ui;bundle-version="2.4.0", - org.eclipse.xtext.ui.ecore;bundle-version="2.4.0", - com.google.inject;bundle-version="3.0.0", - org.genivi.commonapi.core;bundle-version="2.1.5", - org.eclipse.cdt.ui;bundle-version="5.5.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.10.0,4.0.0)";visibility:=reexport, + org.eclipse.core.resources;bundle-version="[3.9.0,4.0.0)";visibility:=reexport, + org.eclipse.core.expressions;bundle-version="[3.4.400,4.0.0)";visibility:=reexport, + org.eclipse.ui, + org.eclipse.cdt.ui;bundle-version="[5.5.0,6.0.0)";visibility:=reexport, + org.eclipse.xtext.ui;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, + org.eclipse.xtext.ui.ecore;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, + org.eclipse.xtext.builder;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, + org.eclipse.xtext.generator;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, + com.google.inject;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, + org.genivi.commonapi.core;bundle-version="3.1.1";visibility:=reexport, + org.franca.core.dsl.ui;bundle-version="0.9.1", + org.franca.deploymodel.dsl.ui;bundle-version="0.9.1" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy -Import-Package: javax.inject, - org.franca.core.dsl.validation, - org.franca.core.franca, - org.franca.core.utils -Export-Package: org.genivi.commonapi.core.ui,org.genivi.commonapi.core - .ui.handler +Export-Package: org.genivi.commonapi.core.ui, + org.genivi.commonapi.core.ui.handler, + org.genivi.commonapi.core.ui.preferences diff --git a/org.genivi.commonapi.core.ui/build.properties b/org.genivi.commonapi.core.ui/build.properties index 2b0d95b..32c2330 100644 --- a/org.genivi.commonapi.core.ui/build.properties +++ b/org.genivi.commonapi.core.ui/build.properties @@ -1,3 +1,4 @@ +javacDefaultEncoding.. = UTF-8 source.. = src/ output.. = bin/ bin.includes = plugin.xml,\ diff --git a/org.genivi.commonapi.core.ui/plugin.xml b/org.genivi.commonapi.core.ui/plugin.xml index 1b8ef6f..57352fd 100644 --- a/org.genivi.commonapi.core.ui/plugin.xml +++ b/org.genivi.commonapi.core.ui/plugin.xml @@ -66,6 +66,23 @@ </iterate> </or> </definition> + <definition + id="org.genivi.commonapi.core.ui.FrancaIDL.Resources.fdepl.selected"> + <or> + <reference + definitionId="org.franca.core.dsl.FrancaIDL.Editor.opened"> + </reference> + <iterate> + <adapt + type="org.eclipse.core.resources.IResource"> + <test + property="org.eclipse.core.resources.name" + value="*.fdepl"> + </test> + </adapt> + </iterate> + </or> + </definition> </extension> <extension point="org.eclipse.ui.preferencePages"> diff --git a/org.genivi.commonapi.core.ui/pom.xml b/org.genivi.commonapi.core.ui/pom.xml index 186dd2f..98884aa 100644 --- a/org.genivi.commonapi.core.ui/pom.xml +++ b/org.genivi.commonapi.core.ui/pom.xml @@ -6,8 +6,8 @@ <packaging>eclipse-plugin</packaging> <parent> <groupId>commonapi</groupId> - <artifactId>org.genivi.commonapi.releng</artifactId> - <version>2.1.6-SNAPSHOT</version> - <relativePath>../org.genivi.commonapi.releng</relativePath> + <artifactId>org.genivi.commonapi.core.releng</artifactId> + <version>3.1.1-SNAPSHOT</version> + <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> -</project>
\ No newline at end of file +</project> 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(); } /* |