Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-03-04 15:06:57 +0000
committerptessier2014-03-04 15:06:57 +0000
commit7e597be478eb26ea14533d06c580be9da689c698 (patch)
tree687e802e30eb9771e88759604991b468b2064de3 /plugins/facet
parent0f98b3bfa2fe4ae6942e82fd0aca4a7bfbcc427d (diff)
downloadorg.eclipse.papyrus-7e597be478eb26ea14533d06c580be9da689c698.tar.gz
org.eclipse.papyrus-7e597be478eb26ea14533d06c580be9da689c698.tar.xz
org.eclipse.papyrus-7e597be478eb26ea14533d06c580be9da689c698.zip
Bug 386118 - [EMF Facet] Papyrus should progressively support EMF Facet
0.2 add 2 plugins to edit queries
Diffstat (limited to 'plugins/facet')
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.checkstyle8
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.classpath7
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.pmd7
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.project40
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF27
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/OSGI-INF/l10n/bundle.properties13
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/about.html28
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/build.properties20
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/plugin.xml23
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Activator.java51
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/JavaQueryUIRuntimeException.java23
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Messages.java55
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/dialog/JavaQueryStrategy.java73
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/messages.properties39
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetMultiValuesWidgetComposite.java56
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetOrCreateJavaImplementationWidgetComposite.java113
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/query/JavaQueryWidget.java75
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JavaQueryUtils.java45
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JdtUtils.java264
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/SelectOrCreateJavaClassWizard.java172
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/CreateQueryClassWizardPage.java127
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/NewClassWizardPage.java68
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectJavaClassWizardPage.java116
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectOrCreateJavaClassWizardPage.java72
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.checkstyle8
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.classpath7
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.pmd7
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.project40
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/META-INF/MANIFEST.MF23
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/OSGI-INF/l10n/bundle.properties13
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/about.html28
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/build.properties20
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/plugin.xml23
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/dialog/IOclDialogFactory.java20
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Activator.java51
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Messages.java48
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/dialog/OclDialogFactory.java77
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/exception/OclQueryRuntimeException.java23
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/messages.properties104
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryContextWidget.java62
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryReturnTypeWidget.java62
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/oclexpression/OclExpressionWidgetSimple.java95
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/OclQueryWidget.java107
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/SynchonizedOclQueryWidget.java82
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/IOclQueryWidget.java18
-rw-r--r--plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/oclexpression/IOCLExpressionWidget.java28
49 files changed, 2483 insertions, 0 deletions
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.checkstyle b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.checkstyle
new file mode 100644
index 00000000000..2664c7abd61
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.checkstyle
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="EmfFacet" location="/org.eclipse.papyrus.emf.facet.archi.tech.rules/checkstyle/EmfFacet.checkstyle" type="project" description=""/>
+ <fileset name="all" enabled="true" check-config-name="EmfFacet" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ <file-match-pattern match-pattern="Messages.java" include-pattern="false"/>
+ </fileset>
+</fileset-config>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.classpath b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.classpath
@@ -0,0 +1,7 @@
+<?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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.pmd b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.pmd
new file mode 100644
index 00000000000..e8d3e27588f
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.pmd
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pmd>
+ <useProjectRuleSet>true</useProjectRuleSet>
+ <ruleSetFile>../org.eclipse.papyrus.emf.facet.archi.tech.rules/pmd/ruleset.xml</ruleSetFile>
+ <includeDerivedFiles>false</includeDerivedFiles>
+ <violationsAsErrors>true</violationsAsErrors>
+</pmd>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.project b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.project
new file mode 100644
index 00000000000..994c6376423
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.project
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.emf.facet.query.java.sdk.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ <nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.settings/org.eclipse.core.resources.prefs b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..4824b802631
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..8c925255961
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.query.java.sdk.ui;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.emf.facet.efacet.sdk.ui;bundle-version="0.2.0",
+ org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="0.2.0",
+ org.eclipse.papyrus.emf.facet.query.java.metamodel;bundle-version="0.2.0",
+ org.eclipse.papyrus.emf.facet.util.ui;bundle-version="0.3.0",
+ org.eclipse.papyrus.emf.facet.util.core;bundle-version="0.2.0",
+ org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="0.2.0",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.emf.ecore;bundle-version="2.6.0",
+ org.eclipse.emf.common.ui;bundle-version="2.6.0",
+ org.eclipse.emf;bundle-version="2.6.0",
+ org.eclipse.jdt.core;bundle-version="3.6.0",
+ org.eclipse.emf.codegen.ecore;bundle-version="2.6.0",
+ org.eclipse.emf.edit;bundle-version="2.6.0",
+ org.eclipse.jdt.ui;bundle-version="3.6.0",
+ org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="0.3.0",
+ org.eclipse.papyrus.emf.facet.util.pde.core;bundle-version="0.4.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %Bundle-Vendor
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..42058f0e1c2
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2012 Mia-Software.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+###############################################################################
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = EMF Facet Java Query UI (Incubation) \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/about.html b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/about.html
new file mode 100644
index 00000000000..aacf0cfd3b9
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>August 17, 2012</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/build.properties b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/build.properties
new file mode 100644
index 00000000000..b28b108392b
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/build.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2012 Mia-Software.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ OSGI-INF/,\
+ about.html
+javacDefaultEncoding.. = UTF-8
+src.includes = about.html
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/plugin.xml b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/plugin.xml
new file mode 100644
index 00000000000..35fe2b8d723
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2012 Mia-Software.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+-->
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.emf.facet.efacet.sdk.ui.queryFactoryDialogRegistration">
+ <queryDialogFactory
+ dialogFactory="org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.dialog.JavaQueryStrategy"
+ managedQueryTypeName="JavaQuery 0.2">
+ </queryDialogFactory>
+ </extension>
+
+</plugin>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Activator.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Activator.java
new file mode 100644
index 00000000000..1c6a310e3a5
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Activator.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+// Copied from /org.eclipse.papyrus.emf.facet.aggregate.metamodel.notgenerated/src/org/eclipse/emf/facet/aggregate/metamodel/notgenerated/internal/Activator.java
+@SuppressWarnings("PMD.UseSingleton")
+// @SuppressWarnings("PMD.UseSingleton") We cannot conforms to this rule because
+// this class is an Eclipse plug-in activator which will be instantiated by the
+// Eclipse framework.
+public class Activator extends Plugin {
+
+ private static Activator plugin;
+
+ @Override
+ @SuppressWarnings("PMD.SignatureDeclareThrowsException")
+ // @SuppressWarnings("PMD.SignatureDeclareThrowsException") We have to use
+ // this signature because this is an override of an Eclipse framework's
+ // method.
+ public void start(final BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ Activator.plugin = this;
+ }
+
+ @Override
+ @SuppressWarnings("PMD.SignatureDeclareThrowsException")
+ // @SuppressWarnings("PMD.SignatureDeclareThrowsException") We have to use
+ // this signature because this is an override of an Eclipse framework's
+ // method.
+ public void stop(final BundleContext bundleContext) throws Exception {
+ // NOPMD: PMD say "Assigning an Object to null is a code smell."
+ // No choice to right it in another way : this is an Eclipse pattern.
+ Activator.plugin = null; // NOPMD by gdupe on 30/03/12 10:19
+ super.stop(bundleContext);
+ }
+
+ public static Plugin getDefault() {
+ return Activator.plugin;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/JavaQueryUIRuntimeException.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/JavaQueryUIRuntimeException.java
new file mode 100644
index 00000000000..6eb074e8919
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/JavaQueryUIRuntimeException.java
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal;
+
+public class JavaQueryUIRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = 8815972557940912330L;
+
+ public JavaQueryUIRuntimeException(final Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Messages.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Messages.java
new file mode 100644
index 00000000000..b7efde8d365
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/Messages.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349556 - EMF Facet Java Query wizard
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+// copy from /org.eclipse.papyrus.emf.facet.query.java.sdk.ui/src/org/eclipse/emf/facet/query/java/sdk/ui/internal/Messages.java
+public final class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.messages"; //$NON-NLS-1$
+ public static String Choose_an_operation;
+ public static String Choose_an_operation_desc;
+ public static String Create_new_java_class;
+ public static String JavaQueryWizardPage_Can_be_cached;
+ public static String JavaQueryWizardPage_has_side_effect;
+ public static String JavaQueryWizardPage_Java_Class_Name;
+ public static String JavaQueryWizardPage_Java_Query;
+ public static String JavaQueryWizardPage_Java_query_creation_page;
+ public static String JavaQueryWizardPage_lower_bound;
+ public static String JavaQueryWizardPage_Query_name;
+ public static String JavaQueryWizardPage_Browse;
+ public static String JavaQueryWizardPage_Create;
+ public static String JavaQueryWizardPage_interface_constraints;
+ public static String JavaQueryWizardPage_Please_select_a_scope;
+ public static String JavaQueryWizardPage_Please_select_create_IJavaQuery_Class;
+ public static String JavaQueryWizardPage_Scope;
+ public static String JavaQueryWizardPage_upper_bound;
+ public static String NewClassWizardPage_CreateANewJavaClass;
+ public static String NewClassWizardPage_JavaClass;
+ public static String NewQueryClassWizardPage_Failed_to_create_java_class;
+ public static String NewQueryClassWizardPage_Failed_to_create_query_implementation;
+ public static String Select_existing_java_class;
+ public static String SelectJavaClassWizardPage_SeclectAJavaClassLongDescription;
+ public static String SelectJavaClassWizardPage_SelectAJavaClass;
+ public static String Upper_bound;
+ public static String Multi_Values;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/dialog/JavaQueryStrategy.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/dialog/JavaQueryStrategy.java
new file mode 100644
index 00000000000..63e0f7b379a
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/dialog/JavaQueryStrategy.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.dialog;
+
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryDialogFactoryStrategy;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.query.AbstractQueryDialogFactory;
+import org.eclipse.papyrus.emf.facet.query.java.metamodel.v0_2_0.javaquery.JavaQuery;
+import org.eclipse.papyrus.emf.facet.query.java.metamodel.v0_2_0.javaquery.JavaQueryFactory;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.widget.query.JavaQueryWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class will be used for the creation of a java query.
+ *
+ * @see AbstractQueryDialogFactory
+ * @see JavaQueryWidget
+ */
+public class JavaQueryStrategy implements IQueryDialogFactoryStrategy {
+
+ private final PropertyElement2<String> implClassNameProp;
+
+ public JavaQueryStrategy() {
+ this.implClassNameProp = new PropertyElement2<String>(true);
+ }
+
+ public IAbstractWidget createWidget(
+ final Composite parent, final IQueryContext queryContext) {
+ return new JavaQueryWidget(parent, queryContext,
+ this.implClassNameProp);
+ }
+
+ public Query createQuery(final boolean canBeCached,
+ final boolean sideEffects, final IQueryContext queryContext) {
+ JavaQuery result = null;
+ final String implClassName = (String) this.implClassNameProp.getValue();
+ final JavaQuery query = JavaQueryFactory.eINSTANCE.createJavaQuery();
+ query.setCanBeCached(canBeCached);
+ query.setCanHaveSideEffects(sideEffects);
+ if (implClassName != null) {
+ query.setImplementationClassName(implClassName);
+ result = query;
+ }
+ return result;
+ }
+
+ public String getDialogMessage() {
+ return Messages.JavaQueryWizardPage_Java_query_creation_page;
+ }
+
+ public String getDialogTitle() {
+ return Messages.JavaQueryWizardPage_Java_Query;
+ }
+
+ public String getConclusionText() {
+ return this.implClassNameProp.getValue2();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/messages.properties b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/messages.properties
new file mode 100644
index 00000000000..b4b09cf65ab
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/messages.properties
@@ -0,0 +1,39 @@
+##########################################################################
+# Copyright (c) 2011 Mia-Software.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Nicolas Guyomar (Mia-Software) - Bug 349556 - EMF Facet Java Query wizard
+# Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+###########################################################################
+# Copy from /org.eclipse.papyrus.emf.facet.query.java.sdk.ui/src/org/eclipse/emf/facet/query/java/sdk/ui/internal/messages.properties
+Choose_an_operation=Choose an operation:
+Choose_an_operation_desc=Choose whether you want to create a new Java class, or to select an existing one
+Create_new_java_class=Create a new Java Class
+JavaQueryWizardPage_Can_be_cached=Can be cached:
+JavaQueryWizardPage_has_side_effect=Has side effect:
+JavaQueryWizardPage_Java_Class_Name=Java Class name:
+JavaQueryWizardPage_Java_Query=Java Query
+JavaQueryWizardPage_Java_query_creation_page=Java query creation page
+JavaQueryWizardPage_lower_bound=Lower bound:
+JavaQueryWizardPage_Query_name=Query name:
+JavaQueryWizardPage_Browse=Browse
+JavaQueryWizardPage_upper_bound=Upper bound:
+JavaQueryWizardPage_Create=Create
+JavaQueryWizardPage_interface_constraints=The selected class has to implements
+JavaQueryWizardPage_Please_select_a_scope=Please select a scope for this query
+JavaQueryWizardPage_Please_select_create_IJavaQuery_Class=Please select or create an IJavaQuery Class
+JavaQueryWizardPage_Scope=Scope:
+NewClassWizardPage_CreateANewJavaClass=Create a new Java class.
+NewClassWizardPage_JavaClass=Java Class
+NewQueryClassWizardPage_Failed_to_create_java_class=Failed to create a Java class
+NewQueryClassWizardPage_Failed_to_create_query_implementation=Failed to create the Java model query implementation class.
+Select_existing_java_class=Select an existing Java Class
+SelectJavaClassWizardPage_SeclectAJavaClassLongDescription=Select a Java class
+SelectJavaClassWizardPage_SelectAJavaClass=Select a Java class
+Upper_bound=Upper Bound:
+Multi_Values=Multi-values: \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetMultiValuesWidgetComposite.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetMultiValuesWidgetComposite.java
new file mode 100644
index 00000000000..b65d86e53d7
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetMultiValuesWidgetComposite.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.widget;
+
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.component.properties.AbstractGetPropertyWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class create a boolean widget to check if the returned value is multiple
+ * or not (1 or *).
+ */
+public class GetMultiValuesWidgetComposite extends AbstractGetPropertyWidget {
+
+ private static final int LABEL_WIDTH_HINT = 110;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param propertyElement
+ * the property element edited by this widget.
+ */
+ public GetMultiValuesWidgetComposite(final Composite parent,
+ final PropertyElement propertyElement) {
+ super(parent, propertyElement);
+ setLabelWidthHint(LABEL_WIDTH_HINT);
+ }
+
+ @Override
+ protected String getLabel() {
+ return Messages.Multi_Values;
+ }
+
+ @Override
+ public String getError() {
+ return null;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing.
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetOrCreateJavaImplementationWidgetComposite.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetOrCreateJavaImplementationWidgetComposite.java
new file mode 100644
index 00000000000..cc52135a9e8
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/GetOrCreateJavaImplementationWidgetComposite.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.widget;
+
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.JavaQueryUIRuntimeException;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.SelectOrCreateJavaClassWizard;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWithWizardButtonWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Widget for the recovery or creation of a java query class.
+ */
+public class GetOrCreateJavaImplementationWidgetComposite extends
+ AbstractGetOrCreateElementWithWizardButtonWidget<String, SelectOrCreateJavaClassWizard> {
+
+ private final IQueryContext queryContext;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param properties
+ * the properties.
+ * @param queryContext
+ * the main queryContext of the model.
+ * @param facet
+ * the current facet of the model.
+ */
+ public GetOrCreateJavaImplementationWidgetComposite(final Composite parent,
+ final PropertyElement2<String> implClassNameProp,
+ final IQueryContext queryContext) {
+ super(parent, implClassNameProp);
+ this.queryContext = queryContext;
+ }
+
+ @Override
+ protected String getLabel() {
+ return Messages.JavaQueryWizardPage_Java_Class_Name;
+ }
+
+ @Override
+ protected String getErrorMessage() {
+ return Messages.JavaQueryWizardPage_Please_select_create_IJavaQuery_Class;
+ }
+
+ @Override
+ protected String getTextFieldInitialText() {
+ return null;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing to do.
+ }
+
+ @Override
+ protected SelectOrCreateJavaClassWizard createIWizard() {
+ SelectOrCreateJavaClassWizard classCreation = null;
+ final IDialogCallback<String> callBack = new IDialogCallback<String>() {
+ public void committed(final String result) {
+ GetOrCreateJavaImplementationWidgetComposite.this
+ .onWizardCommited(result);
+ }
+ };
+ try {
+ classCreation = new SelectOrCreateJavaClassWizard(this.queryContext,
+ callBack);
+ } catch (Exception e) {
+ throw new JavaQueryUIRuntimeException(e);
+ }
+ return classCreation;
+ }
+
+ protected final void onWizardCommited(final String classQAName) {
+ this.getPropertyElement().setValue(classQAName);
+ this.getTextField().setText(classQAName);
+ }
+
+ @Override
+ protected void onWizardCanceled() {
+ // Not used because SelectOrCreateJavaClassWizard manage event using
+ // the call back pattern.
+ }
+
+ @Override
+ protected void onWizardCommited(final SelectOrCreateJavaClassWizard wizard) {
+ // Not used because SelectOrCreateJavaClassWizard manage event using
+ // the call back pattern.
+ }
+
+ @Override
+ protected SelectOrCreateJavaClassWizard createSynchronizedWizard(
+ final SelectOrCreateJavaClassWizard wizard) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/query/JavaQueryWidget.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/query/JavaQueryWidget.java
new file mode 100644
index 00000000000..642b08e2bb3
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/widget/query/JavaQueryWidget.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.widget.query;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.widget.GetOrCreateJavaImplementationWidgetComposite;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.query.AbstractQueryWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class provide the main widget for the creation of a Java query.
+ */
+public class JavaQueryWidget extends AbstractQueryWidget<ETypedElement> {
+
+ private final PropertyElement2<String> implClassNameProp;
+ private final IQueryContext queryContext;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param editingDomain
+ * the current editing domain.
+ * @param properties
+ * the properties.
+ * @param facetSet
+ * the main facetSet of the model.
+ * @param facet
+ * the current facet of the model.
+ */
+ public JavaQueryWidget(final Composite parent,
+ final IQueryContext queryContext,
+ final PropertyElement2<String> implClassNameProp) {
+ super(parent);
+ this.implClassNameProp = implClassNameProp;
+ this.queryContext = queryContext;
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ final GetOrCreateJavaImplementationWidgetComposite widget = new GetOrCreateJavaImplementationWidgetComposite(this,
+ this.implClassNameProp, this.queryContext);
+ addSubWidget(widget);
+ }
+
+ @Override
+ public Command getCommand() {
+ // No Command to return.
+ return null;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing to do.
+ }
+
+ @Override
+ public void onDialogValidation() {
+ // Nothing to do.
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JavaQueryUtils.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JavaQueryUtils.java
new file mode 100644
index 00000000000..41ec6e22f63
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JavaQueryUtils.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard;
+
+import java.util.Locale;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.jdt.core.IJavaProject;
+
+public final class JavaQueryUtils {
+
+ private JavaQueryUtils() {
+ // Must no be used
+ }
+
+ private static final String UNKONWN = "unkonwn"; //$NON-NLS-1$
+
+ public static String getDefaultPackageName(
+ final IQueryContext queryContext,
+ final IJavaProject javaProject) {
+ String sourceClassName = UNKONWN;
+ final Facet facet = queryContext.getFacet();
+ final EClass eClass = FacetUtils.findExtendedEClass(facet);
+ if (eClass != null) {
+ sourceClassName = eClass.getName();
+ }
+ final String packageName = javaProject.getProject().getName()
+ + ".queries." + sourceClassName.toLowerCase(Locale.getDefault()); //$NON-NLS-1$
+ return packageName;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JdtUtils.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JdtUtils.java
new file mode 100644
index 00000000000..69078668e7b
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/JdtUtils.java
@@ -0,0 +1,264 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Manifest;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Activator;
+import org.eclipse.papyrus.emf.facet.util.core.Logger;
+import org.eclipse.papyrus.emf.facet.util.core.internal.JavaUtils;
+import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.PluginUtils;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.ManifestElement;
+
+public final class JdtUtils {
+
+ private JdtUtils() {
+ // Must no be used
+ }
+
+ public static ICompilationUnit createJavaClass(
+ final EClassifier returnTypeClass,
+ final boolean multiValues, final EClassifier scope,
+ final IPackageFragment packageFragment,
+ final IPackageFragmentRoot root,
+ final String typeName, final String cuName)
+ throws JavaModelException {
+ IPackageFragment packgeFragment2;
+ if (packageFragment == null) {
+ packgeFragment2 = root.getPackageFragment(""); //$NON-NLS-1$
+ } else {
+ packgeFragment2 = packageFragment;
+ }
+ final String packageName = packgeFragment2.getElementName();
+ if (!packgeFragment2.exists()) {
+ packgeFragment2 = root.createPackageFragment(packageName, true,
+ new NullProgressMonitor());
+ }
+ final StringBuilder contents = new StringBuilder();
+ createJavaClassContents(contents, typeName, packageName,
+ returnTypeClass, multiValues, scope);
+ return packgeFragment2.createCompilationUnit(cuName,
+ contents.toString(),
+ false, new NullProgressMonitor());
+ }
+
+ private static void createJavaClassContents(final StringBuilder contents,
+ final String name, final String packageName,
+ final EClassifier returnTypeClass, final boolean multiValues,
+ final EClassifier scope) {
+ if (packageName.length() > 0) {
+ contents.append("package "); //$NON-NLS-1$
+ contents.append(packageName);
+ contents.append(";\n\n"); //$NON-NLS-1$
+ }
+ boolean importCollection = false;
+
+ String returnType;
+ String shortReturnType;
+ if (returnTypeClass == null) {
+ returnType = "java.lang.Object"; //$NON-NLS-1$
+ shortReturnType = "Object"; //$NON-NLS-1$
+ } else {
+ returnType = returnTypeClass.getInstanceClassName();
+ returnType = JavaUtils.objectType(returnType);
+ final int lastDotPos = returnType.lastIndexOf('.');
+ if (multiValues) {
+ importCollection = true;
+ shortReturnType = "Collection<" + returnType.substring(lastDotPos + 1) + ">"; //$NON-NLS-1$//$NON-NLS-2$
+ } else {
+ shortReturnType = returnType.substring(lastDotPos + 1);
+ }
+ }
+
+ // EList<EClass> scope = modelQuery.getScope();
+ String scopeType;
+ String shortScopeType;
+ // if (scope != null && scope.size() == 1) {
+ if (scope == null) {
+ scopeType = "org.eclipse.emf.ecore.EObject"; //$NON-NLS-1$
+ shortScopeType = "EObject"; //$NON-NLS-1$
+ } else {
+ scopeType = scope.getInstanceClassName();
+ scopeType = JavaUtils.objectType(scopeType);
+ shortScopeType = scopeType
+ .substring(scopeType.lastIndexOf('.') + 1);
+ }
+
+ if (importCollection) {
+ contents.append("import java.util.Collection;\n"); //$NON-NLS-1$
+ }
+ if (mustImport(returnType)) {
+ contents.append("import " + returnType + ";\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (!returnType.equals(scopeType) && mustImport(scopeType)) {
+ contents.append("import " + scopeType + ";\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ contents.append("import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;\n"); //$NON-NLS-1$
+ contents.append("import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;\n"); //$NON-NLS-1$
+ contents.append("import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;\n"); //$NON-NLS-1$
+ contents.append("import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;\n"); //$NON-NLS-1$
+ contents.append("\n"); //$NON-NLS-1$
+ contents.append("public class " + name + " implements IJavaQuery2<" + shortScopeType + ", " + shortReturnType + "> {\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ contents.append(" public " + shortReturnType + " evaluate(final " + shortScopeType + " context, \n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ contents.append(" final IParameterValueList2 parameterValues,\n"); //$NON-NLS-1$
+ contents.append(" final IFacetManager facetManager)\n"); //$NON-NLS-1$
+ contents.append(" throws DerivedTypedElementException {\n"); //$NON-NLS-1$
+ contents.append(" // TODO Auto-generated method stub\n"); //$NON-NLS-1$
+ contents.append(" return null;\n"); //$NON-NLS-1$
+ contents.append(" }\n"); //$NON-NLS-1$
+ contents.append("}\n"); //$NON-NLS-1$
+ }
+
+ private static boolean mustImport(final String type) {
+ return type.contains(".") && !type.startsWith("java.lang."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Setup the given project's Manifest so that metamodels referenced by the
+ * query's <code>returnType</code> and <code>scope</code> are available on
+ * the classpath.
+ */
+ public static void setupProject(final IProject project,
+ final EClassifier returnType, final EClassifier scope) {
+ try {
+ final String[] requiredBundles = findRequiredBundles(returnType,
+ scope);
+ // start with all and then remove those already present
+ final List<String> missingBundles = new ArrayList<String>();
+ for (final String requiredBundle : requiredBundles) {
+ missingBundles.add(requiredBundle);
+ }
+ missingBundles.add("org.eclipse.papyrus.emf.facet.efacet.core"); //$NON-NLS-1$
+ missingBundles.add("org.eclipse.papyrus.emf.facet.query.java.core"); //$NON-NLS-1$
+
+ PluginUtils.configureAsPluginProject(project);
+ final IFile manifestResource = (IFile) project.findMember(new Path(
+ "/META-INF/MANIFEST.MF")); //$NON-NLS-1$
+ manifestResource.refreshLocal(IResource.DEPTH_ONE,
+ new NullProgressMonitor());
+ final InputStream contents = manifestResource.getContents();
+ final Manifest manifest = new Manifest(contents);
+ final String requires = manifest.getMainAttributes().getValue(
+ "Require-Bundle"); //$NON-NLS-1$
+ if (requires != null) {
+ final ManifestElement[] manifestElements = ManifestElement
+ .parseHeader("Require-Bundle", requires); //$NON-NLS-1$
+ for (final ManifestElement manifestElement : manifestElements) {
+ // make sure it won't be duplicated
+ missingBundles.remove(manifestElement.getValue());
+ }
+ }
+
+ final StringBuilder newRequires = new StringBuilder();
+ if (requires != null) {
+ newRequires.append(requires);
+ }
+ for (int i = 0; i < missingBundles.size(); i++) {
+ final String missingBundle = missingBundles.get(i);
+ if ((i != 0) || (requires != null)) {
+ newRequires.append(","); //$NON-NLS-1$
+ }
+ newRequires.append(missingBundle);
+ }
+
+ manifest.getMainAttributes().putValue(
+ "Require-Bundle", newRequires.toString()); //$NON-NLS-1$
+
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ manifest.write(outputStream);
+ final ByteArrayInputStream inputStream = new ByteArrayInputStream(
+ outputStream.toByteArray());
+ manifestResource.setContents(inputStream, true, true,
+ new NullProgressMonitor());
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+
+ /**
+ * Find the bundles containing the implementations of the metamodels
+ * referenced by the given classifiers.
+ */
+ private static String[] findRequiredBundles(final EClassifier returnType,
+ final EClassifier scope) {
+ final Set<String> requiredBundles = new HashSet<String>();
+ final Set<EPackage> requiredEPackages = new HashSet<EPackage>();
+ if (returnType != null) {
+ requiredEPackages.add(returnType.getEPackage());
+ }
+ if (scope != null) {
+ requiredEPackages.add(scope.getEPackage());
+ }
+
+ final Map<String, URI> genModelLocMap = EcorePlugin
+ .getEPackageNsURIToGenModelLocationMap();
+
+ for (final EPackage ePackage : requiredEPackages) {
+ try {
+ final URI genModelURI = genModelLocMap.get(ePackage.getNsURI());
+ if (genModelURI == null) {
+ Logger.logWarning(
+ "Couldn't add the metamodel implementation plug-in" //$NON-NLS-1$
+ + " to the dependencies automatically because" //$NON-NLS-1$
+ + " the corresponding genmodel couldn't be found: " //$NON-NLS-1$
+ + ePackage.getNsURI(),
+ Activator.getDefault());
+ } else {
+ final ResourceSet resourceSet = createResource();
+ final Resource resource = resourceSet
+ .createResource(genModelURI);
+ resource.load(Collections.emptyMap());
+ final GenModel genModel = (GenModel) resource.getContents()
+ .get(0);
+ final String modelPluginID = genModel.getModelPluginID();
+ if (modelPluginID != null) {
+ requiredBundles.add(modelPluginID);
+ }
+ }
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+ return requiredBundles.toArray(new String[requiredBundles.size()]);
+ }
+
+ private static ResourceSetImpl createResource() {
+ return new ResourceSetImpl();
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/SelectOrCreateJavaClassWizard.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/SelectOrCreateJavaClassWizard.java
new file mode 100644
index 00000000000..d5ce0b41458
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/SelectOrCreateJavaClassWizard.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software)
+ * Nicolas Bros (Mia-Software)
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.query.java.core.internal.exceptions.ClassAlreadyExistsException;
+import org.eclipse.papyrus.emf.facet.query.java.core.internal.exceptions.ResourceURIExpectedException;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Activator;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page.CreateQueryClassWizardPage;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page.SelectJavaClassWizardPage;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page.SelectOrCreateJavaClassWizardPage;
+import org.eclipse.papyrus.emf.facet.util.core.Logger;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.wizard.IExtendedWizard;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+
+// Copied from org.eclipse.papyrus.emf.facet.query.java.ui.internal.wizard.SelectOrCreateJavaClassWizard
+public class SelectOrCreateJavaClassWizard extends Wizard implements
+ IExtendedWizard {
+
+
+ private final WizardDialog dialog;
+ private CreateQueryClassWizardPage createClassPage;
+ private SelectOrCreateJavaClassWizardPage firstPage;
+
+ private final IDialogCallback<String> callBack;
+ private SelectJavaClassWizardPage selectClassPage;
+ private final IQueryContext queryContext;
+
+ public SelectOrCreateJavaClassWizard(final IQueryContext queryContext,
+ final IDialogCallback<String> callBack)
+ throws ClassAlreadyExistsException, ResourceURIExpectedException,
+ JavaModelException {
+ super();
+ this.queryContext = queryContext;
+ this.callBack = callBack;
+ this.dialog = new WizardDialog(getShell(), this);
+ setWindowTitle(Messages.Choose_an_operation);
+
+ // check that the resource is from a platform URI
+ final Resource resource = queryContext.getResource();
+ final URI uri = resource.getURI();
+ if (!uri.isPlatformResource()) {
+ throw new ResourceURIExpectedException();
+ }
+ // check that the class doesn't already exist
+ final String projectName = uri.segment(1);
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IProject project = workspace.getRoot().getProject(projectName);
+ final IJavaProject javaProject = JavaCore.create(project);
+ final StringBuffer implClassName = new StringBuffer(
+ this.queryContext.getDerivedTypedElementName());
+ final EObject intermediate = this.queryContext.getIntermediateEObject();
+ if (intermediate instanceof ETypedElementCase) {
+ final ETypedElementCase eTECase = (ETypedElementCase) intermediate;
+ if (eTECase.getCase() != null) {
+ implClassName.append(eTECase.getCase().getName());
+ }
+ }
+ implClassName.append("Query"); //$NON-NLS-1$
+ if (javaProject.findType(implClassName.toString()) != null) {
+ throw new ClassAlreadyExistsException();
+ }
+ }
+
+ @Override
+ public void addPages() {
+ this.firstPage = new SelectOrCreateJavaClassWizardPage();
+ addPage(this.firstPage);
+ this.createClassPage = new CreateQueryClassWizardPage(
+ this.queryContext);
+ addPage(this.createClassPage);
+ this.selectClassPage = new SelectJavaClassWizardPage();
+ addPage(this.selectClassPage);
+ }
+
+ private String createJavaClass() {
+ return this.createClassPage.apply(this.queryContext.getReturnType(),
+ this.queryContext.getUpperBound() > 1,
+ this.queryContext.getExtendedEClass());
+ }
+
+ @Override
+ public boolean canFinish() {
+ return getContainer().getCurrentPage().isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ return finish();
+ }
+
+ public int open() {
+ return this.dialog.open();
+ }
+
+ public IWizardPage getCurrentPage() {
+ return getContainer().getCurrentPage();
+ }
+
+ public IWizardPage next() {
+ final IWizardPage nextPage = getNextPage(this.getCurrentPage());
+ this.dialog.showPage(nextPage);
+ return nextPage;
+ }
+
+ public IWizardPage previous() {
+ final IWizardPage previousPage = getPreviousPage(this.getCurrentPage());
+ this.dialog.showPage(previousPage);
+ return previousPage;
+ }
+
+ public boolean finish() {
+ boolean result = true;
+ try {
+ if (getContainer().getCurrentPage() == this.createClassPage) {
+ final String classQName = createJavaClass();
+ this.callBack.committed(classQName);
+ } else if (getContainer().getCurrentPage() == this.selectClassPage) {
+ this.callBack.committed(this.selectClassPage.getResult()
+ .toString());
+ }
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ result = false;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean performCancel() {
+ return true;
+ }
+
+ @Override
+ public IWizardPage getNextPage(final IWizardPage page) {
+ IWizardPage result = null;
+ if (page == this.firstPage) {
+ if (this.firstPage.isSelect()) {
+ result = this.selectClassPage;
+ } else {
+ result = this.createClassPage;
+ }
+ }
+ return result;
+
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/CreateQueryClassWizardPage.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/CreateQueryClassWizardPage.java
new file mode 100644
index 00000000000..50a9f950506
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/CreateQueryClassWizardPage.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software)
+ * Nicolas Bros (Mia-Software)
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Activator;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.JavaQueryUtils;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.JdtUtils;
+import org.eclipse.papyrus.emf.facet.util.core.Logger;
+import org.eclipse.papyrus.emf.facet.util.core.internal.exported.StringUtils;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.MessageDialog;
+
+// Copied from org.eclipse.papyrus.emf.facet.query.java.ui.internal.wizard.page.NewQueryClassWizardPage
+public class CreateQueryClassWizardPage extends NewClassWizardPage {
+
+ // This class has been copied from
+ // org.eclipse.papyrus.emf.facet.infra.query.ui.wizards.NewQueryClassWizardPage
+
+ public CreateQueryClassWizardPage(final IQueryContext queryContainer) {
+ super();
+ final IJavaProject javaProject = JavaCore.create(queryContainer
+ .getProject());
+ final List<String> interfaceList = new ArrayList<String>();
+ interfaceList.add(IJavaQuery2.class.getName());
+ setSuperInterfaces(interfaceList, false);
+ final String packageName = JavaQueryUtils.getDefaultPackageName(
+ queryContainer,
+ javaProject);
+ final String typeName = getClassName(queryContainer);
+ setTypeName(typeName, true);
+ selectPackage(javaProject, packageName);
+ setModifiers(this.F_PUBLIC, false);
+ setSuperClass("", false); //$NON-NLS-1$
+ setEnclosingTypeSelection(false, false);
+ setAddComments(false, false);
+ }
+
+ private static String getClassName(final IQueryContext queryContext) {
+ final StringBuffer result = new StringBuffer();
+ final EObject intermediate = queryContext.getIntermediateEObject();
+ if (intermediate instanceof ETypedElementCase) {
+ final ETypedElementCase eteCase = (ETypedElementCase) intermediate;
+ String caseLabel = ""; //$NON-NLS-1$
+ if (eteCase.getCase() != null) {
+ caseLabel = eteCase.getCase().getName();
+ }
+ result.append(StringUtils.firstLetterToUpperCase(caseLabel));
+ }
+ result.append(StringUtils.firstLetterToUpperCase(queryContext
+ .getDerivedTypedElementName()));
+ result.append("Query"); //$NON-NLS-1$
+ return result.toString();
+ }
+
+ private void selectPackage(final IJavaProject javaProject,
+ final String packageName) {
+ try {
+ for (final IPackageFragmentRoot packageFragmentRootToTest : javaProject
+ .getPackageFragmentRoots()) {
+ if (packageFragmentRootToTest.getKind() == IPackageFragmentRoot.K_SOURCE) {
+ final IPackageFragmentRoot pkgFragmentRoot = packageFragmentRootToTest;
+ setPackageFragmentRoot(pkgFragmentRoot, false);
+ final IPackageFragment packageFragment = pkgFragmentRoot
+ .getPackageFragment(packageName);
+ setPackageFragment(packageFragment, true);
+ break;
+ }
+ }
+ } catch (final JavaModelException e1) {
+ Logger.logError(e1, Activator.getDefault());
+ }
+ }
+
+ public String apply(final EClassifier returnType,
+ final boolean multiValues,
+ final EClassifier scope) {
+ String result = ""; //$NON-NLS-1$
+ try {
+ final IPackageFragmentRoot root = getPackageFragmentRoot();
+ final IPackageFragment packageFragment = getPackageFragment();
+ final String typeName = getTypeName();
+ final String cuName = getCompilationUnitName(typeName);
+ final ICompilationUnit javaClass = JdtUtils.createJavaClass(
+ returnType, multiValues, scope, packageFragment, root,
+ typeName, cuName);
+ final IProject project = javaClass.getCorrespondingResource()
+ .getProject();
+ JdtUtils.setupProject(project, returnType, scope);
+ result = packageFragment.getElementName() + '.' + typeName;
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ MessageDialog
+ .openError(
+ getShell(),
+ Messages.NewQueryClassWizardPage_Failed_to_create_java_class,
+ Messages.NewQueryClassWizardPage_Failed_to_create_query_implementation);
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/NewClassWizardPage.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/NewClassWizardPage.java
new file mode 100644
index 00000000000..7e9d8ac5e12
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/NewClassWizardPage.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349556 - EMF Facet Java Query wizard
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page;
+
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+// Copied from org.eclipse.papyrus.emf.facet.query.java.ui.internal.wizard.page.NewClassWizardPage
+public class NewClassWizardPage extends NewTypeWizardPage {
+
+ private static final String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
+ private static final int COLUMN_NB = 4;
+
+ public NewClassWizardPage() {
+ super(true, NewClassWizardPage.PAGE_NAME);
+ setTitle(Messages.NewClassWizardPage_JavaClass);
+ setDescription(Messages.NewClassWizardPage_CreateANewJavaClass);
+ }
+
+ public void init(final IStructuredSelection selection) {
+ final IJavaElement javaElement = getInitialJavaElement(selection);
+ initContainerPage(javaElement);
+ initTypePage(javaElement);
+ }
+
+ public void createControl(final Composite parent) {
+ initializeDialogUnits(parent);
+
+ final Composite composite = new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+
+ final GridLayout layout = new GridLayout();
+ layout.numColumns = COLUMN_NB;
+ composite.setLayout(layout);
+
+ createContainerControls(composite, COLUMN_NB);
+ createPackageControls(composite, COLUMN_NB);
+
+ createSeparator(composite, COLUMN_NB);
+
+ createTypeNameControls(composite, COLUMN_NB);
+ createModifierControls(composite, COLUMN_NB);
+
+ createSuperInterfacesControls(composite, COLUMN_NB);
+
+ setControl(composite);
+
+ Dialog.applyDialogFont(composite);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectJavaClassWizardPage.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectJavaClassWizardPage.java
new file mode 100644
index 00000000000..3d8704adc50
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectJavaClassWizardPage.java
@@ -0,0 +1,116 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349556 - EMF Facet Java Query wizard
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page;
+
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Activator;
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.util.core.Logger;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+// Copied from org.eclipse.papyrus.emf.facet.query.java.ui.internal.wizard.page.SelectOrCreateJavaClassWizardPage
+public class SelectJavaClassWizardPage extends WizardPage {
+
+ private String result;
+ private Text text;
+
+ public SelectJavaClassWizardPage() {
+ super("SelectJavaClass"); //$NON-NLS-1$
+ setTitle(Messages.SelectJavaClassWizardPage_SelectAJavaClass);
+ setDescription(Messages.SelectJavaClassWizardPage_SeclectAJavaClassLongDescription);
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ final Button dialogBtn = new Button(composite, SWT.PUSH);
+ dialogBtn.setText("Open the class selection wizard..."); //$NON-NLS-1$
+ final SelectionListener listener = new SelectionListener() {
+ public void widgetSelected(final SelectionEvent event) {
+ SelectJavaClassWizardPage.this.openSelectionDialog();
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent event) {
+ // Noting to do
+ }
+ };
+ dialogBtn.addSelectionListener(listener);
+ this.text = new Text(composite, SWT.BORDER);
+ setControl(composite);
+ setPageComplete(false);
+ }
+
+ protected void openSelectionDialog() {
+ final Display display = Display.getDefault();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ final Shell shell = new Shell(display);
+ SelectionDialog dialog;
+ try {
+ dialog = JavaUI.createTypeDialog(shell,
+ new ProgressMonitorDialog(shell),
+ SearchEngine.createWorkspaceScope(),
+ IJavaElementSearchConstants.CONSIDER_CLASSES, false);
+ dialog.open();
+ final boolean cancelled = (dialog.getReturnCode() == Window.CANCEL);
+ Object dilaogResult = null;
+ if (!cancelled && dialog.getResult()[0] instanceof IType) {
+ final IType type = (IType) dialog.getResult()[0];
+ dilaogResult = type.getFullyQualifiedName();
+ }
+ SelectJavaClassWizardPage.this.dialogClosed(dilaogResult,
+ cancelled);
+ } catch (JavaModelException e) {
+ Logger.logError(e, Activator.getDefault());
+ SelectJavaClassWizardPage.this.dialogClosed(null, true);
+ }
+ }
+ });
+ }
+
+ protected void dialogClosed(final Object dialogResult, final boolean cancelled) {
+ if (cancelled) {
+ this.getPreviousPage();
+ } else {
+ if (dialogResult != null && dialogResult.toString().length() > 0) {
+ this.result = dialogResult.toString();
+ this.text.setText(dialogResult.toString());
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+ }
+ }
+
+ public String getResult() {
+ return this.result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectOrCreateJavaClassWizardPage.java b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectOrCreateJavaClassWizardPage.java
new file mode 100644
index 00000000000..51943050be3
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.java.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/java/sdk/ui/internal/wizard/page/SelectOrCreateJavaClassWizardPage.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349556 - EMF Facet Java Query wizard
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.page;
+
+import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+// Copied from org.eclipse.papyrus.emf.facet.query.java.ui.internal.wizard.page.SelectOrCreateJavaClassWizardPage
+public class SelectOrCreateJavaClassWizardPage extends WizardPage {
+
+ private Button selectButton;
+
+ private final SelectionListener selectionListener = new SelectionListener() {
+ public void widgetSelected(final SelectionEvent event) {
+ onSelection();
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent event) {
+ // Nothing
+ }
+ };
+
+ public SelectOrCreateJavaClassWizardPage() {
+ super("Whatever"); //$NON-NLS-1$
+ setTitle(Messages.Choose_an_operation);
+ setDescription(Messages.Choose_an_operation_desc);
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NONE);
+ container.setLayout(new GridLayout(1, false));
+ // Create the creation radio button
+ final Button createButton = new Button(container, SWT.RADIO);
+ createButton.setText(Messages.Create_new_java_class);
+ createButton.addSelectionListener(this.selectionListener);
+ // Create the creation radio button
+ this.selectButton = new Button(container, SWT.RADIO);
+ this.selectButton.setText(Messages.Select_existing_java_class);
+ this.selectButton.addSelectionListener(this.selectionListener);
+ setControl(container);
+ }
+
+ public boolean canFinish() {
+ return this.selectButton.getSelection();
+ }
+
+
+ protected void onSelection() {
+ getContainer().updateButtons();
+ }
+
+ public boolean isSelect() {
+ return this.selectButton.getSelection();
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.checkstyle b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.checkstyle
new file mode 100644
index 00000000000..2664c7abd61
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.checkstyle
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="EmfFacet" location="/org.eclipse.papyrus.emf.facet.archi.tech.rules/checkstyle/EmfFacet.checkstyle" type="project" description=""/>
+ <fileset name="all" enabled="true" check-config-name="EmfFacet" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ <file-match-pattern match-pattern="Messages.java" include-pattern="false"/>
+ </fileset>
+</fileset-config>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.classpath b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.classpath
@@ -0,0 +1,7 @@
+<?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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.pmd b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.pmd
new file mode 100644
index 00000000000..e8d3e27588f
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.pmd
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pmd>
+ <useProjectRuleSet>true</useProjectRuleSet>
+ <ruleSetFile>../org.eclipse.papyrus.emf.facet.archi.tech.rules/pmd/ruleset.xml</ruleSetFile>
+ <includeDerivedFiles>false</includeDerivedFiles>
+ <violationsAsErrors>true</violationsAsErrors>
+</pmd>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.project b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.project
new file mode 100644
index 00000000000..580b1b197df
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.project
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.core.resources.prefs b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..4824b802631
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..060c5ee3d2e
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+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.5
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..08af2bcab71
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.emf.facet.util.ui;bundle-version="0.3.0",
+ org.eclipse.papyrus.emf.facet.efacet.sdk.ui;bundle-version="0.3.0",
+ org.eclipse.emf.ecore;bundle-version="2.6.0",
+ org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="0.3.0",
+ org.eclipse.papyrus.emf.facet.query.ocl.metamodel;bundle-version="0.3.0",
+ org.eclipse.emf.edit;bundle-version="2.6.0",
+ org.eclipse.papyrus.emf.facet.query.ocl.core;bundle-version="0.3.0",
+ org.eclipse.ocl.ecore;bundle-version="3.0.0",
+ org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="0.3.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.dialog,
+ org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget,
+ org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget.oclexpression
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..7f61301e5ee
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2012 Mia-Software.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+###############################################################################
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = EMF Facet OCL Query SDK UI (Incubation) \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/about.html b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/about.html
new file mode 100644
index 00000000000..aacf0cfd3b9
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>August 17, 2012</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/build.properties b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/build.properties
new file mode 100644
index 00000000000..341fc62b2b9
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/build.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2012 Mia-Software.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ plugin.xml,\
+ about.html
+javacDefaultEncoding.. = UTF-8
+src.includes = about.html
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/plugin.xml b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/plugin.xml
new file mode 100644
index 00000000000..753e8a41f19
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2012 Mia-Software.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+-->
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.emf.facet.efacet.sdk.ui.queryFactoryDialogRegistration">
+ <queryDialogFactory
+ dialogFactory="org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.dialog.OclDialogFactory"
+ managedQueryTypeName="OCL Query">
+ </queryDialogFactory>
+ </extension>
+
+</plugin>
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/dialog/IOclDialogFactory.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/dialog/IOclDialogFactory.java
new file mode 100644
index 00000000000..cc1bac601c7
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/dialog/IOclDialogFactory.java
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.dialog;
+
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.dialog.query.IQueryDialogFactory;
+
+public interface IOclDialogFactory extends IQueryDialogFactory {
+
+ void setExpression(final String expression);
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Activator.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Activator.java
new file mode 100644
index 00000000000..333502ad9b4
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Activator.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+// Copied from org.eclipse.papyrus.emf.facet.aggregate.metamodel.notgenerated
+@SuppressWarnings("PMD.UseSingleton")
+// @SuppressWarnings("PMD.UseSingleton") We cannot conforms to this rule because
+// this class is an Eclipse plug-in activator which will be instantiated by the
+// Eclipse framework.
+public class Activator extends Plugin {
+
+ private static Activator plugin;
+
+ @Override
+ @SuppressWarnings("PMD.SignatureDeclareThrowsException")
+ // @SuppressWarnings("PMD.SignatureDeclareThrowsException") We have to use
+ // this signature because this is an override of an Eclipse framework's
+ // method.
+ public void start(final BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ Activator.plugin = this;
+ }
+
+ @Override
+ @SuppressWarnings("PMD.SignatureDeclareThrowsException")
+ // @SuppressWarnings("PMD.SignatureDeclareThrowsException") We have to use
+ // this signature because this is an override of an Eclipse framework's
+ // method.
+ public void stop(final BundleContext bundleContext) throws Exception {
+ // NOPMD: PMD say "Assigning an Object to null is a code smell."
+ // No choice to right it in another way : this is an Eclipse pattern.
+ Activator.plugin = null; // NOPMD by gdupe on 30/03/12 10:19
+ super.stop(bundleContext);
+ }
+
+ public static Plugin getDefault() {
+ return Activator.plugin;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Messages.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Messages.java
new file mode 100644
index 00000000000..68cd5a4df3a
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/Messages.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.messages"; //$NON-NLS-1$
+
+ public static String Query_Context;
+ public static String Return_type;
+ public static String Type_returned;
+
+ public static String OclDialogFactory_OclExpression;
+
+ public static String OclExpression_Error;
+ public static String OclQueryDialogFactory_Dialog_Desc;
+ public static String OclQueryDialogFactory_Dialog_Title;
+ public static String Expression;
+ public static String Expression_return_type_not_valid;
+ public static String Expression_not_valid;
+
+ // OCL expression
+ public static String Create_Ocl_expression;
+ public static String Create_the;
+ public static String OclExpression_Error_type;
+
+ // OCL
+ public static String console_badContextForQuery;
+ public static String console_badContextForConstraint;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/dialog/OclDialogFactory.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/dialog/OclDialogFactory.java
new file mode 100644
index 00000000000..3c84dbc8340
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/dialog/OclDialogFactory.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.dialog;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryDialogFactoryStrategy;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.query.AbstractQueryDialogFactory;
+import org.eclipse.papyrus.emf.facet.query.ocl.metamodel.oclquery.OclQuery;
+import org.eclipse.papyrus.emf.facet.query.ocl.metamodel.oclquery.OclQueryFactory;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.query.OclQueryWidget;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.query.SynchonizedOclQueryWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Concrete implementation of {@link AbstractQueryDialogFactory} for the
+ * creation of OCLExpression.
+ *
+ * @see AbstractQueryDialogFactory
+ */
+public class OclDialogFactory implements IQueryDialogFactoryStrategy {
+
+ private final PropertyElement2<String> oclExpressionProp;
+
+ public OclDialogFactory() {
+ this.oclExpressionProp = new PropertyElement2<String>(false,
+ Messages.OclDialogFactory_OclExpression);
+ }
+
+ public IAbstractWidget createWidget(
+ final Composite parent, final IQueryContext queryContext) {
+ // An OCL query by definition can't have side effects.
+ return new SynchonizedOclQueryWidget(new OclQueryWidget(parent,
+ this.oclExpressionProp, queryContext), parent.getDisplay());
+ }
+
+ public String getDialogMessage() {
+ return Messages.OclQueryDialogFactory_Dialog_Desc;
+ }
+
+ public String getDialogTitle() {
+ return Messages.OclQueryDialogFactory_Dialog_Title;
+ }
+
+ public String getConclusionText() {
+ return this.oclExpressionProp.getValue2();
+ }
+
+ public OclQuery createQuery(final boolean canBeCached,
+ final boolean sideEffects, final IQueryContext queryContext) {
+ OclQuery query = null;
+ final String oclExpression = (String) this.oclExpressionProp.getValue();
+ final EClassifier context = queryContext.getExtendedEClass();
+ if ((oclExpression != null) && (context != null)) {
+ query = OclQueryFactory.eINSTANCE.createOclQuery();
+ query.setCanBeCached(true);
+ query.setCanHaveSideEffects(false);
+ query.setOclExpression(oclExpression);
+ query.setContext(context);
+ }
+ return query;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/exception/OclQueryRuntimeException.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/exception/OclQueryRuntimeException.java
new file mode 100644
index 00000000000..39d6967b0e1
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/exception/OclQueryRuntimeException.java
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.exception;
+
+public class OclQueryRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = -3675130124806299967L;
+
+ public OclQueryRuntimeException(final String message) {
+ super(message);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/messages.properties b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/messages.properties
new file mode 100644
index 00000000000..8a5cb9243d9
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/messages.properties
@@ -0,0 +1,104 @@
+########################################################################
+# Copyright (c) 2012 Mia-Software.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+# Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+########################################################################
+OclDialogFactory_OclExpression=OCL expression
+OclQueryDialogFactory_Dialog_Desc=Create a new OCL query
+OclQueryDialogFactory_Dialog_Title=New OCL query
+OclExpression_Error=You must create a valid OCL expression
+Expression=Expression :
+Edition_Group=Edition
+Previous=Previous
+Next=Next
+Expression_return_type_not_valid=The type returned by the expression is not valid
+Expression_not_valid=The OCL expression is not valid
+Return_type=Expected type :
+Type_returned=Type returned :
+Select_choice=You must select an element
+Select_option= = Select an option =
+
+Create_next_step=Add an new element at the expression
+
+New_wizard=New Element
+
+Can_finish=OR you can rather finish the expression
+
+#### Wizard Pages
+Choice_step_name=Select an option
+Choice_step_message=Select an option for the current expression.
+String_step_name=String comparison
+String_step_message=Compare the string to an other one.
+Operation_step_name=Create the operation expression
+Operation_step_message=Create the operation expression for the selected operation
+
+#### OCL Expression
+Create_Ocl_expression=Create an OCL Expression
+Create_the=Create the parameter
+OclExpression_Error_type=The type returned by the expression is not correct, expected :
+
+#### Booleans
+Add_a_boolean_expression=Add a boolean expression
+
+Or_tree_item=OR
+Or_menu_item=Or
+
+And_tree_item=AND
+And_menu_item=And
+
+Not_tree_item=NOT
+Not_menu_item=Not
+
+#### Comparator
+Add_a_comparator=Add a comparator
+
+Equal==
+Different=<>
+Gretter=>
+Gretter_equal=>=
+Lower=<
+Lower_equal=<=
+
+#### Constant
+Add_constant=Add a constant
+Create_new_constant=Create a new constant
+
+String=String
+Integer=Integer
+Real=Real
+Real_error=You must enter a real number (like 42.1337)
+Real_can_be_null=The real can't be null
+Boolean=Boolean
+
+#### Dynamic Menu Attributes
+Attributes_of=Attributes of
+
+#### OCL
+
+console_badContextForQuery = Must select a model element on which to evaluate the query.
+console_badContextForConstraint = Must select a classifier, operation, or attribute on which to parse the constraint.
+
+
+#### Let
+Create_Let_expression=Create a let Expression
+Variable_Name=Name :
+Variable_Type=Type :
+Variable_Select_Type: Select a type
+Variable_Expression=Expression :
+
+Variable_Name_Error=You must set a name for the variable
+Variable_Type_Error=You must set a type for the variable
+
+#### Variables
+Variable=Variables
+
+Query_Context=Context :
+Delete_Item=Delete item
+Parameters_for : Parameters for \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryContextWidget.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryContextWidget.java
new file mode 100644
index 00000000000..89606dfb085
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryContextWidget.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.component.properties.name.AbstractPrintElementWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Widget for the display of the expected type. Display a simple text field, not
+ * editable with the type expected in it.
+ */
+public class PrintQueryContextWidget extends
+ AbstractPrintElementWidget<EClassifier> {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param propertyElement
+ * the {@link PropertyElement} that this widget will edit.
+ */
+ public PrintQueryContextWidget(final Composite parent,
+ final PropertyElement2<EClassifier> propertyElement) {
+ super(parent, propertyElement);
+ }
+
+ @Override
+ protected String getLabel() {
+ return Messages.Query_Context;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing.
+ }
+
+ @Override
+ protected String getErrorMessage() {
+ return null;
+ }
+
+ @Override
+ protected String getTextFieldInitialText() {
+ return this.getPropertyElement().getValue2().getName();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryReturnTypeWidget.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryReturnTypeWidget.java
new file mode 100644
index 00000000000..b78b0aadfaf
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/PrintQueryReturnTypeWidget.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.component.properties.name.AbstractPrintElementWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Widget for the display of the expected type. Display a simple text field, not
+ * editable with the type expected in it.
+ */
+public class PrintQueryReturnTypeWidget extends
+ AbstractPrintElementWidget<EClassifier> {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param propertyElement
+ * the {@link PropertyElement} that this widget will edit.
+ */
+ public PrintQueryReturnTypeWidget(final Composite parent,
+ final PropertyElement2<EClassifier> propertyElement) {
+ super(parent, propertyElement);
+ }
+
+ @Override
+ protected String getLabel() {
+ return Messages.Return_type;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing.
+ }
+
+ @Override
+ protected String getErrorMessage() {
+ return null;
+ }
+
+ @Override
+ protected String getTextFieldInitialText() {
+ return this.getPropertyElement().getValue2().getName();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/oclexpression/OclExpressionWidgetSimple.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/oclexpression/OclExpressionWidgetSimple.java
new file mode 100644
index 00000000000..7afe5e0d520
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/oclexpression/OclExpressionWidgetSimple.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.oclexpression;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.papyrus.emf.facet.query.ocl.core.util.OclQueryUtil;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.Messages;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget.oclexpression.IOCLExpressionWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.ocl.ParserException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Simple widget for the edition of a complexe OCl expression.
+ */
+public class OclExpressionWidgetSimple extends AbstractWidget implements
+ IOCLExpressionWidget {
+
+ private static final String UNREC_VAR = "Unrecognized variable"; //$NON-NLS-1$
+ private static final int TEXT_HEIGHT = 100;
+ private final EClassifier context;
+ private final String expression;
+ private Text text;
+ private final PropertyElement oclExpressionProp;
+
+ public OclExpressionWidgetSimple(final Composite parent,
+ final EClassifier context, final String expression,
+ final PropertyElement oclExpressionProp) {
+ super(parent);
+ this.context = context;
+ this.expression = expression;
+ this.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.oclExpressionProp = oclExpressionProp;
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ this.text = new Text(this, SWT.MULTI | SWT.V_SCROLL);
+ final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.heightHint = TEXT_HEIGHT;
+ this.text.setLayoutData(gridData);
+
+ if (this.expression != null) {
+ this.text.setText(this.expression);
+ }
+ }
+
+ @Override
+ public String getError() {
+ String result = null;
+
+ final String textExpression = this.text.getText().trim();
+ if ("".equals(textExpression)) { //$NON-NLS-1$
+ result = Messages.OclExpression_Error;
+ } else {
+ try {
+ OclQueryUtil.createOCLExpression(this.context, textExpression);
+ this.oclExpressionProp.setValue(textExpression);
+ } catch (final ParserException exception) {
+ if (exception.getMessage().contains(UNREC_VAR)) {
+ this.oclExpressionProp.setValue(textExpression);
+ } else {
+ result = Messages.OclExpression_Error
+ + " :\n - " + exception.getMessage(); //$NON-NLS-1$
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing to do.
+ }
+
+ public void setExpression(final String expression) {
+ this.text.setText(expression);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/OclQueryWidget.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/OclQueryWidget.java
new file mode 100644
index 00000000000..de95018922c
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/OclQueryWidget.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.query;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
+import org.eclipse.papyrus.emf.facet.query.ocl.metamodel.oclquery.OclQuery;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.PrintQueryContextWidget;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.PrintQueryReturnTypeWidget;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.oclexpression.OclExpressionWidgetSimple;
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget.IOclQueryWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.query.AbstractQueryWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * It is the main widget of the main dialog. This widget add the expected return
+ * type and display the tree.
+ */
+public class OclQueryWidget extends AbstractQueryWidget<ETypedElement> implements IOclQueryWidget {
+
+ private final PropertyElement oclExpressionProp;
+ private OclExpressionWidgetSimple oclExprWidget;
+ private final IQueryContext queryContext;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this widget.
+ * @param properties
+ * the properties for this widget.
+ * @param context
+ * the context of the OCL expression.
+ * @param returnType
+ * the type that the OCL expression must return.
+ * @param initialQuery
+ * the initial {@link OclQuery} if there is one (can be null).
+ * @param facet
+ */
+ public OclQueryWidget(final Composite parent,
+ final PropertyElement oclExpressionProp,
+ final IQueryContext queryContext) {
+ super(parent);
+ this.queryContext = queryContext;
+ this.oclExpressionProp = oclExpressionProp;
+ }
+
+ @Override
+ protected void addSubWidgets() {
+ final EClassifier extendedEClass = this.queryContext
+ .getExtendedEClass();
+ addSubWidget(new PrintQueryContextWidget(this,
+ new PropertyElement2<EClassifier>(false, extendedEClass)));
+ final EClassifier returnType = this.queryContext.getReturnType();
+ addSubWidget(new PrintQueryReturnTypeWidget(this,
+ new PropertyElement2<EClassifier>(false, returnType)));
+ String expression;
+ final Query initialQuery = this.queryContext.getQuery();
+ if (initialQuery instanceof OclQuery) {
+ final OclQuery oclQuery = (OclQuery) initialQuery;
+ expression = oclQuery.getOclExpression();
+ } else {
+ expression = (String) this.oclExpressionProp.getValue();
+ }
+ this.oclExprWidget = new OclExpressionWidgetSimple(this,
+ extendedEClass, expression, this.oclExpressionProp);
+ addSubWidget(this.oclExprWidget);
+ }
+
+ @Override
+ public Command getCommand() {
+ // This widget doesn't create any command.
+ return null;
+ }
+
+ @Override
+ public void notifyChanged() {
+ // Nothing to do.
+ }
+
+ @Override
+ public void onDialogValidation() {
+ // Nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.query.IOclQueryWidget#setExpression(java.lang.String)
+ */
+ public void setExpression(final String expression) {
+ this.oclExprWidget.setExpression(expression);
+ }
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/SynchonizedOclQueryWidget.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/SynchonizedOclQueryWidget.java
new file mode 100644
index 00000000000..0e5a6fdeeb9
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/internal/widget/query/SynchonizedOclQueryWidget.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.internal.widget.query;
+
+import org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget.IOclQueryWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.AbstractWidget;
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+import org.eclipse.swt.widgets.Display;
+
+public class SynchonizedOclQueryWidget extends
+ SynchronizedObject<OclQueryWidget> implements IOclQueryWidget,
+ IAbstractWidget {
+
+ public SynchonizedOclQueryWidget(final OclQueryWidget widget,
+ final Display display) {
+ super(widget, display);
+ }
+
+ public void setExpression(final String expression) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchonizedOclQueryWidget.this.getSynchronizedObject()
+ .setExpression(expression);
+ }
+ });
+ }
+
+ public void addListener(final AbstractWidget abstractWidget) {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchonizedOclQueryWidget.this.getSynchronizedObject()
+ .addListener(abstractWidget);
+ }
+ });
+ }
+
+ public void notifyChanged() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchonizedOclQueryWidget.this.getSynchronizedObject()
+ .notifyChanged();
+ }
+ });
+ }
+
+ public void createWidgetContent() {
+ voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchonizedOclQueryWidget.this.getSynchronizedObject()
+ .createWidgetContent();
+ }
+ });
+ }
+
+ public String getError() {
+ return safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ // TODO Auto-generated method stub
+ return SynchonizedOclQueryWidget.this.getSynchronizedObject()
+ .getError();
+ }
+ });
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/IOclQueryWidget.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/IOclQueryWidget.java
new file mode 100644
index 00000000000..ff2d5696139
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/IOclQueryWidget.java
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget;
+
+public interface IOclQueryWidget {
+
+ void setExpression(final String expression);
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/oclexpression/IOCLExpressionWidget.java b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/oclexpression/IOCLExpressionWidget.java
new file mode 100644
index 00000000000..d9ee22f4934
--- /dev/null
+++ b/plugins/facet/org.eclipse.emf.facet.query.ocl.sdk.ui/src/org/eclipse/papyrus/emf/facet/query/ocl/sdk/ui/widget/oclexpression/IOCLExpressionWidget.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2012 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alban MĂ©nager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.papyrus.emf.facet.query.ocl.sdk.ui.widget.oclexpression;
+
+import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.widget.IAbstractWidget;
+
+/**
+ * @see OCLExpressionWidget
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IOCLExpressionWidget extends IAbstractWidget {
+
+ /**
+ * @param expression
+ */
+ void setExpression(String expression);
+
+} \ No newline at end of file

Back to the top