Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick tessier2014-02-10 12:45:32 +0000
committerPatrick tessier2014-02-10 12:45:32 +0000
commitdf1d4d493dc8ea4b4a81ad8da993f91df220431a (patch)
treef9621c66abaacba819a508e5626c3ced2c43b056 /plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui
parent74550693a485c6ff27748a6c5a9bfdae21b8bd5b (diff)
downloadorg.eclipse.papyrus-df1d4d493dc8ea4b4a81ad8da993f91df220431a.tar.gz
org.eclipse.papyrus-df1d4d493dc8ea4b4a81ad8da993f91df220431a.tar.xz
org.eclipse.papyrus-df1d4d493dc8ea4b4a81ad8da993f91df220431a.zip
386118: [EMF Facet] Papyrus should progressively support EMF Facet 0.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386118 Import EMF Facet
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.checkstyle19
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.classpath7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.pmd7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.project46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/OSGI-INF/l10n/bundle.properties11
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/about.html28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/build.properties19
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/EPackageView.gifbin0 -> 825 bytes
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/ModelIcon.gifbin0 -> 103 bytes
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/catalog.pngbin0 -> 583 bytes
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/logoEmfFacetMini.gifbin0 -> 1078 bytes
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/plugin.xml117
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Activator.java73
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProvider.java140
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProviderFactory.java24
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Messages.java54
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/ResourceUiUtils.java97
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/actions/OpenModelFromEmfRegistryAction.java58
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/CreateInstanceDialog.java76
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/SaveAsDialog.java70
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/URIComposite.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/UriSelectionDialog.java105
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/IEmfLabelProviderFactory.java25
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/composite/EClassifierSelectionControl.java88
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/AbstractGetMetaclassWidget.java163
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/MetamodelSelectionControl.java45
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SelectETypeWizardImpl.java151
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SynchronizedSelectETypeWizard.java65
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEClassifierWizardPage.java188
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEPackageWizardPage.java190
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEClassifierWizardPage.java78
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEPackageWizardPage.java75
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedWizardPage.java260
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEClassifierRuntimeException.java39
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEPackageRuntimeException.java41
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/ISelectETypeWizard.java25
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEClassifierWizardPage.java43
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEPackageWizardPage.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveAsHandler.java94
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveHandler.java95
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/messages.properties40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/preference/pages/DefaultBrowserPreferencePage.java106
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageProvider.java62
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageUtils.java55
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/view/PackageRegistryView.java335
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/util/EditingUtil.java60
47 files changed, 3356 insertions, 0 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.checkstyle b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.checkstyle
new file mode 100644
index 00000000000..11b5e4fd4de
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.checkstyle
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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:
+ Nicolas Guyomar (Mia-Software)
+ Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+ <local-check-config name="EmfFacet" location="/org.eclipse.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.papyrus.emf.facet.util.emf.ui/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.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.papyrus.emf.facet.util.emf.ui/.pmd b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.pmd
new file mode 100644
index 00000000000..a64878bfdf6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.pmd
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pmd>
+ <useProjectRuleSet>true</useProjectRuleSet>
+ <ruleSetFile>../org.eclipse.emf.facet.archi.tech.rules/pmd/ruleset.xml</ruleSetFile>
+ <includeDerivedFiles>false</includeDerivedFiles>
+ <violationsAsErrors>true</violationsAsErrors>
+</pmd>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.project b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.project
new file mode 100644
index 00000000000..c05c70b5a02
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.project
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.emf.facet.util.emf.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>org.eclipse.pde.api.tools.apiAnalysisBuilder</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>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.settings/org.eclipse.core.resources.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..4824b802631
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.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.papyrus.emf.facet.util.emf.ui/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..731ce8b4d04
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,11 @@
+#Properties file for org.eclipse.emf.facet.util.emf.ui
+category.name = EMF Facet
+view.name = EPackage Registry
+actionSet.label = EMF Facet Model Browser Actions
+action.label = Open EPackage
+action.tooltip = Open a model from the EMF EPackage registry
+page.name = Default Browser
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = EMF Facet U.I. Utilities for EMF (Incubation)
+emf.facet.category.name = EMF Facet
+openmodel.command.name = Open Model From EMF Registry \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/about.html b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/about.html
new file mode 100644
index 00000000000..d1714826b27
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.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>January 4, 2011</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.papyrus.emf.facet.util.emf.ui/build.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/build.properties
new file mode 100644
index 00000000000..53d3a9f6a0b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/build.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# 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 333652 Extension point offering the possibility to declare an EPackage browser
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ about.html,\
+ OSGI-INF/
+src.includes = about.html
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/EPackageView.gif b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/EPackageView.gif
new file mode 100644
index 00000000000..ae0cdff0958
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/EPackageView.gif
Binary files differ
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/ModelIcon.gif b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/ModelIcon.gif
new file mode 100644
index 00000000000..239367a3cb0
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/ModelIcon.gif
Binary files differ
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/catalog.png b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/catalog.png
new file mode 100644
index 00000000000..725c0d2fa7d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/catalog.png
Binary files differ
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/logoEmfFacetMini.gif b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/logoEmfFacetMini.gif
new file mode 100644
index 00000000000..19c468b1c61
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/icons/logoEmfFacetMini.gif
Binary files differ
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/plugin.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/plugin.xml
new file mode 100644
index 00000000000..888ec2f0017
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/plugin.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ 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 333652 Extension point offering the possibility to declare an EPackage browser
+ Fabien Giquel (Mia-Software)
+ Gregoire Dupe (Mia-software) - Bug 366155 - [Unit Test Failure][0.2/3.8][0.2/4.2] org.eclipse.emf.facet.util.emf.ui.tests.EPackageRegistryTest.canOpenERegistryView
+ Gregoire Dupe (Mia-Sodtware) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ -->
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.emf.facet.common.ui.views"
+ class="org.eclipse.emf.facet.util.emf.ui.internal.view.PackageRegistryView"
+ icon="icons/EPackageView.gif"
+ id="org.eclipse.emf.facet.infra.common.ui.views.packageRegistry"
+ name="%view.name"
+ restorable="true">
+ </view>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ id="org.eclipse.emf.facet.util.emf.ui.category"
+ name="%emf.facet.category.name">
+ </category>
+ <command
+ categoryId="org.eclipse.emf.facet.util.emf.ui.category"
+ id="org.eclipse.emf.facet.util.emf.ui.OpenModelFromEmfRegistryCommand"
+ name="%openmodel.command.name">
+ </command>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ id="org.eclipse.emf.facet.common.editor.actionSet"
+ label="%actionSet.label"
+ visible="true">
+ <action
+ class="org.eclipse.emf.facet.util.emf.ui.internal.actions.OpenModelFromEmfRegistryAction"
+ definitionId="org.eclipse.emf.facet.util.emf.ui.OpenModelFromEmfRegistryCommand"
+ icon="icons/logoEmfFacetMini.gif"
+ id="org.eclipse.emf.facet.util.emf.actions.OpenModelFromEmfRegistry"
+ label="%action.label"
+ menubarPath="navigate/open.ext2"
+ style="push"
+ toolbarPath="Normal"
+ tooltip="%action.tooltip">
+ </action>
+ </actionSet>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.emf.facet.util.emf.ui.internal.handler.SaveHandler"
+ commandId="org.eclipse.ui.file.save">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.modisco.infra.browser.resourcemanager.ui.expression.isResource">
+ </reference>
+ </activeWhen>
+ <enabledWhen>
+ <reference
+ definitionId="org.eclipse.modisco.infra.browser.resourcemanager.ui.expression.isResource">
+ </reference>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.emf.facet.util.emf.ui.internal.handler.SaveAsHandler"
+ commandId="org.eclipse.ui.file.saveAs">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.modisco.infra.browser.resourcemanager.ui.expression.isResource">
+ </reference>
+ </activeWhen>
+ <enabledWhen>
+ <reference
+ definitionId="org.eclipse.modisco.infra.browser.resourcemanager.ui.expression.isResource">
+ </reference>
+ </enabledWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="org.eclipse.modisco.infra.browser.resourcemanager.ui.expression.isResource">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <adapt
+ type="org.eclipse.emf.ecore.resource.Resource">
+ </adapt>
+ </iterate>
+ </with>
+ </definition>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.emf.facet.common.ui.preference.pages.EmfFacetRootPreferencePage"
+ class="org.eclipse.emf.facet.util.emf.ui.internal.preference.pages.DefaultBrowserPreferencePage"
+ id="org.eclipse.emf.facet.util.emf.ui.DefaultBrowserPreferencePage"
+ name="%page.name">
+ </page>
+ </extension>
+</plugin>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Activator.java
new file mode 100644
index 00000000000..b0a88aaac75
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Activator.java
@@ -0,0 +1,73 @@
+/**
+ * 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 333652 Extension point offering the possibility to declare an EPackage browser
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.emf.facet.util.emf.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ public static AbstractUIPlugin getPlugin() {
+ return Activator.plugin;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ Activator.plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ Activator.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return Activator.plugin;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProvider.java
new file mode 100644
index 00000000000..f2e99371ea2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProvider.java
@@ -0,0 +1,140 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406578 - Generic Label Provider for EMF objects
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.util.emf.core.ModelUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.utils.ImageProvider;
+import org.eclipse.emf.facet.util.emf.ui.internal.utils.ImageUtils;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class EmfLabelProvider extends LabelProvider {
+
+ @Override
+ public String getText(final Object element) {
+ String result = super.getText(element);
+ if (element instanceof ResourceSet) {
+ final ResourceSet resourceSet = (ResourceSet) element;
+ result = getResourceSetLabel(resourceSet);
+ } else if (element instanceof Resource) {
+ final Resource resource = (Resource) element;
+ result = getResourceLabel(resource);
+ } else if (element instanceof EObject) {
+ final EObject eObject = (EObject) element;
+ result = ModelUtils.getName(eObject);
+ } else if (element instanceof IAdaptable) {
+ final IAdaptable adaptable = (IAdaptable) element;
+ result = adaptAndGetResourceLabel(adaptable);
+ if (result == null) {
+ result = adaptAndGetResourceSetLabel(adaptable);
+ }
+ } else {
+ result = element.toString();
+ }
+ return result;
+ }
+
+ private static String adaptAndGetResourceLabel(final IAdaptable adaptable) {
+ String result = null;
+ final Resource resource = (Resource) adaptable
+ .getAdapter(Resource.class);
+ if (resource != null) {
+ result = getResourceLabel(resource);
+ }
+ return result;
+ }
+
+ private static String adaptAndGetResourceSetLabel(final IAdaptable adaptable) {
+ String result = null;
+ final ResourceSet resourceSet = (ResourceSet) adaptable
+ .getAdapter(ResourceSet.class);
+ if (resourceSet != null) {
+ result = getResourceSetLabel(resourceSet);
+ }
+ return result;
+ }
+
+ private static String getResourceSetLabel(final ResourceSet resourceSet) {
+ String result;
+ result = ResourceSet.class.getSimpleName() + ' '
+ + resourceSet.hashCode();
+ return result;
+ }
+
+ private static String getResourceLabel(final Resource resource) {
+ String result;
+ EObject firstRoot = null;
+ if (resource.getContents().size() > 0) {
+ firstRoot = resource.getContents().get(0);
+ }
+ final StringBuffer strBuffer = new StringBuffer();
+ final URI uri = resource.getURI();
+ final String lastSegment = uri.lastSegment();
+ strBuffer.append(lastSegment);
+ if (firstRoot != null) {
+ strBuffer.append(" - "); //$NON-NLS-1$
+ final EPackage ePackage = firstRoot.eClass().getEPackage();
+ final String nsURI = ePackage.getName();
+ strBuffer.append(nsURI);
+ }
+ if (resource.isModified()) {
+ strBuffer.append(" *"); //$NON-NLS-1$
+ }
+ result = strBuffer.toString();
+ return result;
+ }
+
+ @Override
+ public Image getImage(final Object element) {
+ Image result = super.getImage(element);
+ if (element instanceof Resource) {
+ final Resource resource = (Resource) element;
+ result = getResourceImage(resource);
+ } else if (element instanceof IAdaptable) {
+ final IAdaptable adaptable = (IAdaptable) element;
+ result = adaptAndGetResourceImage(adaptable);
+ } else if (element instanceof EObject) {
+ final EObject eObject = (EObject) element;
+ result = ImageUtils.getImage(eObject);
+ }
+ return result;
+ }
+
+ private static Image adaptAndGetResourceImage(final IAdaptable adaptable) {
+ Image result = null;
+ final Resource resource = (Resource) adaptable
+ .getAdapter(Resource.class);
+ if (resource != null) {
+ result = getResourceImage(resource);
+ }
+ return result;
+ }
+
+ private static Image getResourceImage(final Resource resource) {
+ Image result = null;
+ if (resource.getContents().size() > 0) {
+ final EObject firstRoot = resource.getContents().get(0);
+ result = ImageUtils.getImage(firstRoot);
+ if (result == null) {
+ result = ImageProvider.DEFAULT.getImage(ImageProvider.MODEL);
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProviderFactory.java
new file mode 100644
index 00000000000..e460196884c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/EmfLabelProviderFactory.java
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406578 - Generic Label Provider for EMF objects
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal;
+
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.IEmfLabelProviderFactory;
+import org.eclipse.jface.viewers.ILabelProvider;
+
+public class EmfLabelProviderFactory implements
+ IEmfLabelProviderFactory {
+
+ public ILabelProvider createLabelProvider() {
+ return new EmfLabelProvider();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Messages.java
new file mode 100644
index 00000000000..07d35e3fd2c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/Messages.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2011, 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Gregoire Dupe (Mia-Software) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.emf.facet.util.emf.ui.internal.messages"; //$NON-NLS-1$
+ public static String CreateInstanceDialog_selectNewInstanceEClass;
+ public static String PackageRegistryView_initializing;
+ public static String PackageRegistryView_copyNsURI;
+ public static String PackageRegistryView_RefreshingPackageRegistryView;
+ public static String PackageRegistryView_nsURI;
+ public static String PackageRegistryView_Location;
+ public static String PackageRegistryView_Name;
+ public static String DialogUriSelection_RegisteredEPackages;
+ public static String DialogUriSelection_title_OpenModelFromEMFRegistry;
+ public static String EmfFacetRootPreferencePage_default_epackage_browser;
+ public static String EPackageBrowserPreferencePage_defaultEObjectViewer;
+ public static String EPackageBrowserPreferencePage_defaultResourceViewer;
+
+ public static String Select_EClass;
+ public static String Select_EDataType;
+ public static String Select_EClassifier;
+ public static String Select_ETypedElement;
+ public static String Select_EPackage;
+
+ public static String ResourceUiUtils_SavingFailed;
+ public static String ResourceUiUtils_TheResourceSavingFailed;
+ public static String SaveAsDialog_ResourceURI;
+ public static String SaveAsDialog_SaveAs;
+ public static String SaveAsDialog_YouHaveToProvideAValidEMFURI;
+
+ public static String No_result_found;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/ResourceUiUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/ResourceUiUtils.java
new file mode 100644
index 00000000000..8790f34a24a
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/ResourceUiUtils.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Collections;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.ui.internal.dialogs.SaveAsDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IOkDialog;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IOkDialogFactory;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IWithResultDialogCallback;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+
+public final class ResourceUiUtils {
+
+ private ResourceUiUtils() {
+ // Must no be used
+ }
+
+ public static IOkDialog save(final Resource resource, final Shell shell) {
+ IOkDialog dialog = null;
+ try {
+ resource.save(Collections.EMPTY_MAP);
+ } catch (MalformedURLException e) {
+ ResourceUiUtils.openSaveAsDialog(resource, shell);
+ } catch (IOException e) {
+ final IDialogCallback<Void> callBack = new IDialogCallback<Void>() {
+ public void committed(final Void result2) {
+ // Nothing to do.
+ }
+ };
+ dialog = savingFailed(e, shell, callBack);
+ }
+ return dialog;
+ }
+
+ private static IOkDialog savingFailed(final IOException exception,
+ final Shell shell, final IDialogCallback<Void> callBack) {
+ Logger.logError(exception, Activator.getDefault());
+ final String errorMessage = NLS.bind(
+ Messages.ResourceUiUtils_TheResourceSavingFailed,
+ exception.getMessage());
+ return IOkDialogFactory.DEFAULT.openErrorDialog(shell,
+ Messages.ResourceUiUtils_SavingFailed, errorMessage, callBack);
+ }
+
+ public static SaveAsDialog openSaveAsDialog(final Resource resource,
+ final Shell shell) {
+ final IWithResultDialogCallback<String> callBack = new IWithResultDialogCallback<String>() {
+
+ public void commited(final String result) {
+ ResourceUiUtils.saveAs(resource, result, shell);
+ }
+
+ public void canceled(final String result) {
+ // Nothing to do
+ }
+ };
+ final SaveAsDialog dialog = new SaveAsDialog(shell, resource.getURI()
+ .toString(), callBack);
+ dialog.open();
+ return dialog;
+ }
+
+ protected static IOkDialog saveAs(final Resource resource,
+ final String result, final Shell shell) {
+ IOkDialog dialog = null;
+ try {
+ resource.setURI(URI.createURI(result));
+ resource.save(Collections.EMPTY_MAP);
+ } catch (IOException e) {
+ final IDialogCallback<Void> callBack = new IDialogCallback<Void>() {
+ public void committed(final Void result2) {
+ ResourceUiUtils.openSaveAsDialog(resource, shell);
+ }
+ };
+ dialog = savingFailed(e, shell, callBack);
+ }
+ return dialog;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/actions/OpenModelFromEmfRegistryAction.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/actions/OpenModelFromEmfRegistryAction.java
new file mode 100644
index 00000000000..5ab11ed4696
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/actions/OpenModelFromEmfRegistryAction.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010, 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:
+ * Gabriel Barbier (Mia-Software) - initial API and implementation
+ * Nicolas Bros (Mia-Software)
+ * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.actions;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.util.emf.core.IBrowserRegistry;
+import org.eclipse.emf.facet.util.emf.ui.internal.dialogs.UriSelectionDialog;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/**
+ * This is an action class which opens a dialog to select an EPackage to browse
+ */
+public class OpenModelFromEmfRegistryAction implements IWorkbenchWindowActionDelegate {
+
+ private IWorkbenchWindow fWorkbenchWindow;
+
+ public void dispose() {
+ // nothing
+ }
+
+ public void init(final IWorkbenchWindow window) {
+ this.fWorkbenchWindow = window;
+ }
+
+ public void run(final IAction action) {
+ final IWorkbenchPage activePage = this.fWorkbenchWindow.getActivePage();
+ if (activePage != null) {
+ final UriSelectionDialog launcher = new UriSelectionDialog(
+ this.fWorkbenchWindow.getShell());
+ if (launcher.open() == Window.OK) {
+ final String nsURI = launcher.getUriSelected();
+ if (nsURI != null && nsURI.length() > 0) {
+ EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
+ IBrowserRegistry.INSTANCE.browseEPackage(ePackage);
+ }
+ }
+ }
+ }
+
+ public void selectionChanged(final IAction action, final ISelection selection) {
+ // nothing
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/CreateInstanceDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/CreateInstanceDialog.java
new file mode 100644
index 00000000000..7a2b6d72ad9
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/CreateInstanceDialog.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.dialogs;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.util.emf.core.ModelUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+public final class CreateInstanceDialog {
+
+ private CreateInstanceDialog() {
+ //
+ }
+
+ /**
+ * Open a dialog with a list of metaclasses that are subclasses of the given
+ * {@link EClass}. When the user chooses a metaclass, an instance is created
+ * an returned.
+ *
+ * @param shell
+ * the parent shell for the dialog
+ * @param eClass
+ * the {@link EClass} of the new instance
+ * @param labelProvider
+ * label provider for the displayed {@link EClass}es.
+ * @return the created instance, or <code>null</code> if the user cancelled
+ */
+ public static EObject open(final Shell shell, final EClass eClass,
+ final LabelProvider labelProvider) {
+ List<EClass> allSubClasses = ModelUtils.allSubClasses(eClass);
+ allSubClasses.add(eClass);
+ // remove non-instantiable metaclasses
+ ListIterator<EClass> listIterator = allSubClasses.listIterator();
+ while (listIterator.hasNext()) {
+ EClass e = listIterator.next();
+ if (e.isAbstract() || e.isInterface()) {
+ listIterator.remove();
+ }
+ }
+
+ ElementListSelectionDialog eClassSelectionDialog = new ElementListSelectionDialog(shell,
+ labelProvider);
+ eClassSelectionDialog.setTitle(Messages.CreateInstanceDialog_selectNewInstanceEClass);
+ eClassSelectionDialog.setElements(allSubClasses.toArray());
+ eClassSelectionDialog.open();
+ Object selectedElement = eClassSelectionDialog.getFirstResult();
+ if (selectedElement instanceof EClass) {
+ EClass selectedEClass = (EClass) selectedElement;
+ if (!selectedEClass.isInterface() && !selectedEClass.isAbstract()) {
+ EObject eObject = selectedEClass.getEPackage().getEFactoryInstance()
+ .create(selectedEClass);
+ return eObject;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/SaveAsDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/SaveAsDialog.java
new file mode 100644
index 00000000000..c7e13144deb
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/SaveAsDialog.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+
+package org.eclipse.emf.facet.util.emf.ui.internal.dialogs;
+
+
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IWithResultDialogCallback;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class SaveAsDialog extends Dialog {
+
+ private URIComposite uriComposite;
+ private final String initialText;
+ private final IWithResultDialogCallback<String> callBack;
+
+ public SaveAsDialog(final Shell parent, final String initialText,
+ final IWithResultDialogCallback<String> callBack) {
+ super(parent);
+ this.initialText = initialText;
+ this.callBack = callBack;
+ }
+
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+ final Label text = new Label(composite, SWT.NONE);
+ text.setText(Messages.SaveAsDialog_YouHaveToProvideAValidEMFURI);
+ this.uriComposite = new URIComposite(composite, this.initialText);
+ return composite;
+ }
+
+ @Override
+ protected void cancelPressed() {
+ cancelled();
+ }
+
+ public void cancelled() {
+ final String text = this.uriComposite.getText();
+ this.callBack.canceled(text);
+ super.cancelPressed();
+ }
+
+ @Override
+ protected void okPressed() {
+ commit();
+ }
+
+ public void commit() {
+ this.callBack.commited(this.uriComposite.getText());
+ super.okPressed();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/URIComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/URIComposite.java
new file mode 100644
index 00000000000..efa7be78e5c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/URIComposite.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+
+package org.eclipse.emf.facet.util.emf.ui.internal.dialogs;
+
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class URIComposite extends Composite {
+
+ private final Text text;
+
+ public URIComposite(final Composite parent, final String initialText) {
+ super(parent, SWT.NONE);
+ this.setLayout(new GridLayout(2, false));
+ final Label label = new Label(this, SWT.NONE);
+ label.setText(Messages.SaveAsDialog_ResourceURI);
+ this.text = new Text(this, SWT.BORDER);
+ this.text.setText(initialText);
+ this.getShell().setText(Messages.SaveAsDialog_SaveAs);
+ }
+
+ public String getText() {
+ return this.text.getText();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/UriSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/UriSelectionDialog.java
new file mode 100644
index 00000000000..9550028bc36
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/dialogs/UriSelectionDialog.java
@@ -0,0 +1,105 @@
+/**********************************************************************************
+ * 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:
+ * Gabriel Barbier (Mia-Software) - initial API and implementation
+ * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
+ ***********************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.dialogs;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.common.ui.internal.widgets.AnywhereFilterMatcher;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.emf.ui.internal.utils.ImageProvider;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * A dialog which displays a list of URIs from the EMF package registry, and
+ * allows the user to open one of them.
+ *
+ * @author Gabriel Barbier
+ */
+public class UriSelectionDialog extends ElementListSelectionDialog {
+
+ private static final String DIALOG_SETTINGS = "UriSelectionDialogSettings"; //$NON-NLS-1$
+ private String uri = ""; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent shell
+ */
+ public UriSelectionDialog(final Shell parent) {
+ super(parent, new LabelProvider());
+
+ setTitle(Messages.DialogUriSelection_title_OpenModelFromEMFRegistry);
+ setMessage(Messages.DialogUriSelection_RegisteredEPackages);
+
+ final Set<String> uris = new TreeSet<String>();
+ for (final Object name : ((Map<?, ?>) EPackage.Registry.INSTANCE)
+ .keySet()) {
+ uris.add((name).toString());
+ }
+
+ setElements(uris.toArray());
+ }
+
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ this.fFilteredList.setFilterMatcher(new AnywhereFilterMatcher());
+ return composite;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ super.okPressed();
+
+ if (getResult().length > 0) {
+ this.uri = getResult()[0].toString();
+ }
+ }
+
+ public String getUriSelected() {
+ return this.uri;
+ }
+
+ @Override
+ protected void configureShell(final Shell shell) {
+ super.configureShell(shell);
+ shell.setImage(ImageProvider.getInstance().getEmfFacetLogo());
+ }
+
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ IDialogSettings settings = Activator.getPlugin().getDialogSettings();
+ IDialogSettings section = settings
+ .getSection(UriSelectionDialog.DIALOG_SETTINGS);
+ if (section == null) {
+ section = settings
+ .addNewSection(UriSelectionDialog.DIALOG_SETTINGS);
+ }
+ return section;
+ }
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/IEmfLabelProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/IEmfLabelProviderFactory.java
new file mode 100644
index 00000000000..bd98a61644d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/IEmfLabelProviderFactory.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406578 - Generic Label Provider for EMF objects
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal.exported;
+
+import org.eclipse.emf.facet.util.emf.ui.internal.EmfLabelProviderFactory;
+import org.eclipse.jface.viewers.ILabelProvider;
+
+/**
+ * @since 0.4
+ */
+public interface IEmfLabelProviderFactory {
+
+ IEmfLabelProviderFactory DEFAULT = new EmfLabelProviderFactory();
+
+ ILabelProvider createLabelProvider();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/composite/EClassifierSelectionControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/composite/EClassifierSelectionControl.java
new file mode 100644
index 00000000000..1aaebfedb39
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/composite/EClassifierSelectionControl.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011, 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:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.exported.util.composite;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.composite.FilteredElementSelectionComposite;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A control to select an {@link EClass}, that can be filtered using the
+ * associated text field.
+ *
+ * @since 0.3
+ */
+public class EClassifierSelectionControl<T extends EClassifier> extends
+ FilteredElementSelectionComposite {
+
+ private final Map<String, T> stringToEClass = new HashMap<String, T>();
+ private final Class<? extends EClassifier> eTypeSel;
+ private String metamodelNsUri;
+
+ public EClassifierSelectionControl(final Composite parent,
+ final String metamodelNsUri, final Class<? extends T> eTypeSel) {
+ super(parent, true, false);
+ this.eTypeSel = eTypeSel;
+ this.metamodelNsUri = metamodelNsUri;
+ }
+
+ public void updateList(final String metamodelNsUri2) {
+ this.metamodelNsUri = metamodelNsUri2;
+ final EPackage ePackage = EPackage.Registry.INSTANCE
+ .getEPackage(this.metamodelNsUri);
+ if (ePackage != null) {
+ final List<String> eClasses = new ArrayList<String>();
+ final EList<EClassifier> eClassifiers = ePackage.getEClassifiers();
+ addElements(eClasses, eClassifiers);
+ if (eClasses.isEmpty()) {
+ eClasses.add(Messages.No_result_found);
+ setEnabled(false);
+ } else {
+ setEnabled(true);
+ }
+ setElements(eClasses.toArray());
+ }
+ }
+
+ private void addElements(final List<String> eClasses,
+ final EList<? extends EClassifier> eClassifiers) {
+ for (final EClassifier eClassifier : eClassifiers) {
+ if (this.eTypeSel.isInstance(eClassifier)) {
+ eClasses.add(eClassifier.getName());
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings("unchecked") checked by the surrounding if
+ final T eClassifier2 = (T) eClassifier;
+ this.stringToEClass.put(eClassifier.getName(), eClassifier2);
+ }
+ }
+ }
+
+ public T getSelectedEClassifier() {
+ T result = null;
+ final Object[] selectElements = getSelectedElements();
+ if ((selectElements != null) && (selectElements.length > 0)
+ && this.stringToEClass.containsKey(selectElements[0])) {
+ result = this.stringToEClass.get(selectElements[0]);
+ }
+ return result;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/AbstractGetMetaclassWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/AbstractGetMetaclassWidget.java
new file mode 100644
index 00000000000..f8e089dfc56
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/AbstractGetMetaclassWidget.java
@@ -0,0 +1,163 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.util.widget.component.metaclass;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.SelectETypeWizardImpl;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.SynchronizedSelectETypeWizard;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.ISelectETypeWizard;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWithWizardButtonWidget;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement;
+import org.eclipse.emf.facet.util.ui.utils.PropertyElement2;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This abstract class provides a simple way for the selection of a type.
+ *
+ * Label : [ textField ][...] </p>
+ *
+ * The button will display the {@link SelectETypeWizardImpl} wizard when
+ * pressed. </p>
+ *
+ * The {@link #getLabel()} method have to be override and provide the label of
+ * the 'Label'.</p>
+ *
+ * The {@link #createTextField(boolean)} create a non editable text field.</p>
+ *
+ * The {@link #getETypeSelectionOption()} have to be override and type of the
+ * selection in the wizard.</p>
+ *
+ * If the value of the {@link PropertyElement} is null, then the message
+ * returned by {@link #getErrorMessage()} is displayed on the top of the dialog.
+ *
+ * @see SelectETypeWizardImpl
+ * @see ETypeSelectionOptions
+ *
+ * @see GetConformanceMetaclassWidget
+ * @see GetElementTypeWidget
+ * @see GetExtendedMetaclassWidget
+ * @since 0.3
+ */
+public abstract class AbstractGetMetaclassWidget<T extends EClassifier>
+ extends
+ AbstractGetOrCreateElementWithWizardButtonWidget<T, ISelectETypeWizard<T>> {
+
+ private final PropertyElement2<? extends EPackage> ePackagePropery;
+ private final Class<? extends T> eTypeOption;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param typeProperty
+ * the property element that will be edited by this composite.
+ * @param ePackageProperty
+ * the property element to get the super, main, element of the
+ * model.
+ */
+ protected AbstractGetMetaclassWidget(final Composite parent,
+ final PropertyElement2<T> typeProperty,
+ final PropertyElement2<? extends EPackage> ePackageProperty,
+ final Class<? extends T> eTypeOption) {
+ super(parent, typeProperty);
+ this.ePackagePropery = ePackageProperty;
+ this.eTypeOption = eTypeOption;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * the parent of this composite.
+ * @param editingDomain
+ * the current editing domain.
+ * @param propertyElement
+ * the property element that will be edited by this composite.
+ * @param ePackageProperty
+ * the property element to get the super, main, element of the
+ * model.
+ * @param buttonEnabled
+ * boolean to set if the button is enabled or not.
+ */
+ protected AbstractGetMetaclassWidget(final Composite parent,
+ final PropertyElement2<T> propertyElement,
+ final PropertyElement2<EPackage> ePackageProperty,
+ final boolean buttonEnabled, final Class<T> eTypeOption) {
+ this(parent, propertyElement, ePackageProperty, eTypeOption);
+ this.setButtonEnabled(buttonEnabled);
+ }
+
+ /**
+ * @return return the label. Null if no label have to be displayed.
+ */
+ @Override
+ protected abstract String getLabel();
+
+ @Override
+ public String getError() {
+ String error = null;
+ final EClassifier eclassifier = this.getPropertyElement().getValue2();
+ if (eclassifier == null) {
+ error = getErrorMessage();
+ }
+ return error;
+ }
+
+ @Override
+ protected void onWizardCommited(final ISelectETypeWizard<T> wizard) {
+ final T eClassifier = wizard.getSelectedEClassifier();
+ getPropertyElement().setValue2(eClassifier);
+ setText(eClassifier.getName());
+ fireChanged();
+ }
+
+ @Override
+ protected void onWizardCanceled() {
+ fireChanged();
+ }
+
+ /**
+ * Return the EPackage.
+ *
+ * @return the ePackage.
+ */
+ protected abstract EPackage getEPackage();
+
+ /**
+ * @return the facetSetProperty
+ */
+ public PropertyElement2<? extends EPackage> getEPackageProperty() {
+ return this.ePackagePropery;
+ }
+
+ public void setValue(final T eClassifier) {
+ getPropertyElement().setValue2(eClassifier);
+ }
+
+ @Override
+ protected ISelectETypeWizard<T> createIWizard() {
+ final EPackage parent = getEPackage();
+ return new SelectETypeWizardImpl<T>(this.eTypeOption, parent);
+ }
+
+ @Override
+ protected ISelectETypeWizard<T> createSynchronizedWizard(
+ final ISelectETypeWizard<T> wizard) {
+ return new SynchronizedSelectETypeWizard<T>(wizard,
+ this.getDisplay());
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/MetamodelSelectionControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/MetamodelSelectionControl.java
new file mode 100644
index 00000000000..f194a532a46
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/widget/component/metaclass/MetamodelSelectionControl.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
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal.exported.util.widget.component.metaclass;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.composite.FilteredElementSelectionComposite;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A control to select a metamodel from a list of metamodels, that can be
+ * filtered using the associated text field.
+ *
+ * @since 0.3
+ */
+public class MetamodelSelectionControl extends
+ FilteredElementSelectionComposite {
+
+ public MetamodelSelectionControl(final Composite parent) {
+ super(parent, true, false);
+ final Set<String> uris = getUris();
+ setElements(uris.toArray());
+ }
+
+ private static Set<String> getUris() {
+ final Set<String> uris = new TreeSet<String>();
+ for (final Object name : ((Map<?, ?>) EPackage.Registry.INSTANCE)
+ .keySet()) {
+ uris.add(name.toString());
+ }
+ return uris;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SelectETypeWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SelectETypeWizardImpl.java
new file mode 100644
index 00000000000..0b959a04d80
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SelectETypeWizardImpl.java
@@ -0,0 +1,151 @@
+/**
+ * Copyright (c) 2011, 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:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.facet.util.core.DebugUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.SelectEClassifierWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.SelectEPackageWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.SynchronizedSelectEClassifierWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.SynchronizedSelectEPackageWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.ISelectETypeWizard;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEClassifierWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEPackageWizardPage;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 0.3
+ */
+public class SelectETypeWizardImpl<T extends EClassifier> extends Wizard
+ implements ISelectETypeWizard<T> {
+
+ private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator
+ .getDefault());
+ private final WizardDialog dialog;
+ private final ISelectEPackageWizardPage ePackageWP;
+ private final ISelectEClassifierWizardPage<T> eClassifierWP;
+ private T eClassifier;
+
+ public SelectETypeWizardImpl(final Class<? extends T> eTypeOption,
+ final EPackage ePackage) {
+ super();
+ this.dialog = new WizardDialog(new Shell(Display.getDefault()),
+ this);
+ this.ePackageWP = new SelectEPackageWizardPage();
+ this.eClassifierWP = new SelectEClassifierWizardPage<T>(eTypeOption,
+ ePackage);
+ if (eTypeOption == EClass.class) {
+ setWindowTitle(Messages.Select_EClass);
+ } else if (eTypeOption == EDataType.class) {
+ setWindowTitle(Messages.Select_EDataType);
+ } else if (eTypeOption == EClassifier.class) {
+ setWindowTitle(Messages.Select_EClassifier);
+ } else if (eTypeOption == ETypedElement.class) {
+ setWindowTitle(Messages.Select_ETypedElement);
+ }
+ }
+
+ @Override
+ public void addPages() {
+ addPage(this.ePackageWP);
+ addPage(this.eClassifierWP);
+ }
+
+ public int open() {
+ int result = Window.CANCEL;
+
+ if (this.dialog != null) {
+ result = this.dialog.open();
+ }
+ return result;
+ }
+
+ @Override
+ public boolean performFinish() {
+ this.eClassifier = this.eClassifierWP.getSelectedEClassifier();
+ return true;
+ }
+
+ public T getSelectedEClassifier() {
+ return this.eClassifier;
+ }
+
+ public ISelectEClassifierWizardPage<T> getSelectEClassifierWizardPage() {
+ return this.eClassifierWP;
+ }
+
+ public ISelectEPackageWizardPage getSelectEPackageWizardPage() {
+ return this.ePackageWP;
+ }
+
+ public boolean finish() {
+ final boolean result = performFinish();
+ dispose();
+ setContainer(null);
+ this.dialog.close();
+ return result;
+ }
+
+ public IWizardPage getCurrentPage() {
+ return getSynchronizedPage(getContainer().getCurrentPage());
+ }
+
+ public IWizardPage next() {
+ DebugUtils.debug(SelectETypeWizardImpl.DEBUG);
+ final IWizardPage nextPage = getNextPage(getContainer()
+ .getCurrentPage());
+ this.dialog.showPage(nextPage);
+ return getSynchronizedPage(nextPage);
+ }
+
+ public IWizardPage previous() {
+ final IWizardPage previousPage = getPreviousPage(getContainer()
+ .getCurrentPage());
+ this.dialog.showPage(previousPage);
+ return getSynchronizedPage(previousPage);
+ }
+
+ private static IWizardPage getSynchronizedPage(final IWizardPage page) {
+ IWizardPage result = null;
+ if (page instanceof ISelectEClassifierWizardPage) {
+ result = new SynchronizedSelectEClassifierWizardPage(
+ (ISelectEClassifierWizardPage<?>) page,
+ Display.getDefault());
+ } else if (page instanceof ISelectEPackageWizardPage) {
+ result = new SynchronizedSelectEPackageWizardPage(
+ (ISelectEPackageWizardPage) page, Display.getDefault());
+ }
+ return result;
+ }
+
+ public void selectPackage(final String packageName) {
+ getSelectEPackageWizardPage().selectPackage(packageName);
+ }
+
+ public void selectEClassifier(final String eClassifierName) {
+ getSelectEClassifierWizardPage().selectEClassifier(eClassifierName);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SynchronizedSelectETypeWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SynchronizedSelectETypeWizard.java
new file mode 100644
index 00000000000..0ceec885736
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/SynchronizedSelectETypeWizard.java
@@ -0,0 +1,65 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.util.wizard;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.widget.component.metaclass.AbstractGetMetaclassWidget;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.ISelectETypeWizard;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.util.wizard.SynchronizedWizard;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Synchronized class for safe run.
+ *
+ * @see AbstractGetMetaclassWidget
+ * @since 0.3
+ */
+public class SynchronizedSelectETypeWizard<T extends EClassifier> extends
+ SynchronizedWizard<ISelectETypeWizard<T>> implements
+ ISelectETypeWizard<T> {
+
+ /**
+ * Constructor.
+ *
+ * @param object
+ * the to synchronized.
+ * @param display
+ * the display.
+ */
+ public SynchronizedSelectETypeWizard(final ISelectETypeWizard<T> object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public T getSelectedEClassifier() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<T>() {
+ @Override
+ public T safeRun() {
+ return SynchronizedSelectETypeWizard.this
+ .getSynchronizedObject().getSelectedEClassifier();
+ }
+ });
+ }
+
+ @Override
+ public int open() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Integer>() {
+ @Override
+ public Integer safeRun() {
+ return Integer.valueOf(SynchronizedSelectETypeWizard.this
+ .getSynchronizedObject().open());
+ }
+ }).intValue();
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEClassifierWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEClassifierWizardPage.java
new file mode 100644
index 00000000000..d0366e09b1b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEClassifierWizardPage.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011, 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:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.facet.util.core.DebugUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.composite.EClassifierSelectionControl;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.exception.SelectedEClassifierRuntimeException;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEClassifierWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEPackageWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * @since 0.3
+ */
+public class SelectEClassifierWizardPage<T extends EClassifier> extends
+ WizardPage implements ISelectEClassifierWizardPage<T> {
+
+ private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator
+ .getDefault());
+ private EClassifierSelectionControl<T> eClassSelection;
+ private final Class<? extends T> eTypeOption;
+ private String metamodelNsUri;
+
+ public SelectEClassifierWizardPage(final Class<? extends T> eTypeOption,
+ final EPackage ePackage) {
+ super("Whatever"); //$NON-NLS-1$
+ if (eTypeOption == EClass.class) {
+ setTitle(Messages.Select_EClass);
+ } else if (eTypeOption == EDataType.class) {
+ setTitle(Messages.Select_EDataType);
+ } else if (eTypeOption == EClassifier.class) {
+ setTitle(Messages.Select_EClassifier);
+ } else if (eTypeOption == ETypedElement.class) {
+ setTitle(Messages.Select_ETypedElement);
+ }
+ if (ePackage != null) {
+ this.metamodelNsUri = ePackage.getNsURI();
+ }
+ this.eTypeOption = eTypeOption;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return this.eClassSelection.getSelectedEClassifier() != null;
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ super.setVisible(visible);
+ if (getPreviousPage() instanceof SelectEPackageWizardPage) {
+ final ISelectEPackageWizardPage selectEPackage = (ISelectEPackageWizardPage) getPreviousPage();
+ this.metamodelNsUri = selectEPackage.getSelectedEPackage()
+ .getNsURI();
+ if (this.metamodelNsUri != null) {
+ setDescription(selectEPackage.getSelectedEPackage()
+ .getNsURI());
+ }
+ }
+ this.eClassSelection.updateList(this.metamodelNsUri);
+ }
+
+ public void createControl(final Composite parent) {
+ this.eClassSelection = new EClassifierSelectionControl<T>(parent,
+ this.metamodelNsUri, this.eTypeOption);
+ final FilteredList filteredList = this.eClassSelection
+ .getFilteredList();
+
+ filteredList.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent event) {
+ if (event.item != null) {
+ updateButton();
+ // setPageComplete(filteredList.getSelection().length == 1);
+ }
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent event) {
+ if (getWizard().canFinish()) {
+ getWizard().performFinish();
+ }
+ if (getNextPage() != null) {
+ goToNextPage();
+ }
+ }
+ });
+
+ this.eClassSelection.getFilterText().addModifyListener(
+ new ModifyListener() {
+
+ public void modifyText(final ModifyEvent event) {
+ updateButton();
+ }
+ });
+
+ // avoid the page being "complete" when still on a previous page
+ filteredList.setSelection(new int[0]);
+ setPageComplete(false);
+
+ setControl(this.eClassSelection);
+ }
+
+ protected void goToNextPage() {
+ getContainer().showPage(getNextPage());
+ }
+
+ protected void updateButton() {
+ if ((getContainer() != null) && (getContainer().getCurrentPage() != null)) {
+ getContainer().updateButtons();
+ }
+ }
+
+ public T getSelectedEClassifier() {
+ return this.eClassSelection.getSelectedEClassifier();
+ }
+
+ /**
+ * Select the <code>eclassifierName</code> into the list.
+ *
+ * @param eclassifierName
+ * the name of the classifier to select.
+ */
+ public void selectEClassifier(final String eclassifierName) {
+ DebugUtils.debug(DEBUG);
+ boolean doItNow = true;
+ // We get all the jobs
+ for (final Job job : Job.getJobManager().find(null)) {
+ // We check if the job of 'FilteredList' is ended. If not, we
+ // recursively call this method to check again without interfering
+ // with the 'FilteredList' job (doing an asynchrony call).
+ if (job.getClass().getName()
+ .startsWith(FilteredList.class.getName())) {
+ asyncSelectionClassifier(eclassifierName);
+ DebugUtils.debug(DEBUG, "Selection defered."); //$NON-NLS-1$
+ doItNow = false;
+ break;
+ }
+ }
+
+ // If the job 'FilteredList' is done, we can do the selection.
+ if (doItNow) {
+ internalSelectEClassifier(eclassifierName);
+ }
+ }
+
+ private void asyncSelectionClassifier(final String eclassifierName) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ selectEClassifier(eclassifierName);
+ }
+ });
+ }
+
+ private void internalSelectEClassifier(final String packageName) {
+ final FilteredList filteredList = this.eClassSelection
+ .getFilteredList();
+ filteredList.setSelection(new String[] { packageName });
+ if (getSelectedEClassifier() == null) {
+ throw new SelectedEClassifierRuntimeException();
+ }
+ DebugUtils.debug(DEBUG, "Selection setting finished."); //$NON-NLS-1$
+ DebugUtils.debug(DEBUG,
+ "selectedEClassifier=" + getSelectedEClassifier()); //$NON-NLS-1$
+ }
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEPackageWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEPackageWizardPage.java
new file mode 100644
index 00000000000..2027eca4699
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SelectEPackageWizardPage.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011, 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:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.util.core.DebugUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.widget.component.metaclass.MetamodelSelectionControl;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.exception.SelectedEPackageRuntimeException;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEPackageWizardPage;
+import org.eclipse.emf.facet.util.emf.ui.util.EditingUtil;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * @since 0.3
+ */
+public class SelectEPackageWizardPage extends WizardPage implements
+ ISelectEPackageWizardPage {
+
+ private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator
+ .getDefault());
+
+ private MetamodelSelectionControl mmSelectionCtl;
+
+ public SelectEPackageWizardPage() {
+ super("Whatever"); //$NON-NLS-1$
+ setTitle(Messages.Select_EPackage);
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ this.mmSelectionCtl.getFilterText().setFocus();
+ setPageComplete(true);
+ }
+ }
+
+ public void createControl(final Composite parent) {
+ this.mmSelectionCtl = new MetamodelSelectionControl(parent);
+ this.mmSelectionCtl.setLayoutData(new GridData(
+ GridData.FILL_BOTH));
+ final FilteredList filteredList = this.mmSelectionCtl
+ .getFilteredList();
+
+ filteredList.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(final SelectionEvent event) {
+ if (event.item != null) {
+ setPageComplete(filteredList.getSelection().length == 1);
+ }
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent event) {
+ if (getWizard().canFinish()) {
+ getWizard().performFinish();
+ }
+ if (getNextPage() != null) {
+ goToNextPage();
+ }
+ }
+ });
+
+ // prevent the page from being "complete" when still on a previous page
+ filteredList.setSelection(new int[0]);
+ setPageComplete(false);
+ setControl(this.mmSelectionCtl);
+ }
+
+ protected void goToNextPage() {
+ getContainer().showPage(getNextPage());
+ }
+
+ public EPackage getSelectedEPackage() {
+ EPackage ePackage = null;
+ // Only one result
+ if (this.mmSelectionCtl.getSelectedElements() != null) {
+ final Object result = this.mmSelectionCtl
+ .getSelectedElements()[0];
+ if (EPackage.Registry.INSTANCE.containsKey(result.toString())) {
+ ePackage = EPackage.Registry.INSTANCE
+ .getEPackage(result.toString());
+ }
+ }
+ return ePackage;
+ }
+
+ public void loadSelectedMetamodel() {
+ final Object[] results = this.mmSelectionCtl
+ .getSelectedElements();
+ // if user cancel the selection of meta models, results = null
+ if (results != null) {
+ final ResourceSet resourceSet = EditingUtil.getEditingDomain()
+ .getResourceSet();
+ for (final Object result : results) {
+ final URI uri = URI.createURI(result.toString());
+ final Resource resource = resourceSet.getResource(uri, true);
+ if (!resourceSet.getResources().contains(resource)) {
+ final Registry packageRegistry = resourceSet
+ .getPackageRegistry();
+ packageRegistry.putAll(putResourceContents(resource,
+ packageRegistry));
+ resourceSet.getResources().add(resource);
+ }
+ }
+ }
+ }
+
+ private static Registry putResourceContents(final Resource resource,
+ final Registry packageRegistry) {
+ final Registry result = packageRegistry;
+ for (final EObject eObject : resource.getContents()) {
+ if (eObject instanceof EPackage) {
+ final EPackage ePackage = (EPackage) eObject;
+ result.put(ePackage.getNsURI(), ePackage);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Select the <code>packageName</code> into the list.
+ *
+ * @param packageName
+ * the name of the package to select.
+ */
+ public void selectPackage(final String packageName) {
+ DebugUtils.debug(DEBUG);
+ boolean doItNow = true;
+ // We get all the jobs
+ for (final Job job : Job.getJobManager().find(null)) {
+ // We check if the job of 'FilteredList' is ended. If not, we
+ // recursively call this method to check again without interfering
+ // with the 'FilteredList' job (with an asynchrony call).
+ if (job.getClass().getName()
+ .startsWith(FilteredList.class.getName())) {
+ asyncSelectionPackage(packageName);
+ DebugUtils.debug(DEBUG, "Selection defered."); //$NON-NLS-1$
+ doItNow = false;
+ break;
+ }
+ }
+
+ // If the job 'FilteredList' is done, we can do the selection.
+ if (doItNow) {
+ internalSelectPackage(packageName);
+ }
+ }
+
+ private void asyncSelectionPackage(final String packageName) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ selectPackage(packageName);
+ }
+ });
+ }
+
+ private void internalSelectPackage(final String packageName) {
+ final FilteredList filteredList = this.mmSelectionCtl
+ .getFilteredList();
+ filteredList.setSelection(new String[] { packageName });
+ if (getSelectedEPackage() == null) {
+ throw new SelectedEPackageRuntimeException();
+ }
+ DebugUtils.debug(DEBUG, "Selection setting finished."); //$NON-NLS-1$
+ DebugUtils.debug(DEBUG, "selectedEPackage=" + getSelectedEPackage()); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEClassifierWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEClassifierWizardPage.java
new file mode 100644
index 00000000000..c2b2ad3d2c4
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEClassifierWizardPage.java
@@ -0,0 +1,78 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.util.wizard.page;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.facet.util.core.DebugUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEClassifierWizardPage;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Synchronized class for safe run.
+ *
+ * @since 0.3
+ *
+ */
+public class SynchronizedSelectEClassifierWizardPage extends
+ SynchronizedWizardPage<ISelectEClassifierWizardPage> implements
+ ISelectEClassifierWizardPage {
+
+ private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator
+ .getDefault());
+
+ /**
+ * Constructor.
+ *
+ * @param object
+ * the to synchronized.
+ * @param display
+ * the display.
+ */
+ public SynchronizedSelectEClassifierWizardPage(
+ final ISelectEClassifierWizardPage object, final Display display) {
+ super(object, display);
+ }
+
+ public EClassifier getSelectedEClassifier() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<EClassifier>() {
+ @Override
+ public EClassifier safeRun() {
+ return SynchronizedSelectEClassifierWizardPage.this
+ .getSynchronizedObject()
+ .getSelectedEClassifier();
+ }
+ });
+ }
+
+ public void selectEClassifier(final String selection) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedSelectEClassifierWizardPage.this
+ .getSynchronizedObject().selectEClassifier(
+ selection);
+ }
+ });
+
+ // We keep the thread waiting until the selection is not done.
+ // If we release the thread, the selection may not be done and made some
+ // errors
+ while (this.getSelectedEClassifier() == null) {
+ DebugUtils.debug(DEBUG, "Waiting."); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEPackageWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEPackageWizardPage.java
new file mode 100644
index 00000000000..630d4746115
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedSelectEPackageWizardPage.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
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.util.core.DebugUtils;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.wizard.page.ISelectEPackageWizardPage;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Synchronized class for safe run.
+ *
+ * @author amenager_stage
+ * @since 0.3
+ *
+ */
+public class SynchronizedSelectEPackageWizardPage extends
+ SynchronizedWizardPage<ISelectEPackageWizardPage> implements
+ ISelectEPackageWizardPage {
+
+ private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator
+ .getDefault());
+
+ /**
+ * Constructor.
+ *
+ * @param object
+ * the to synchronized.
+ * @param display
+ * the display.
+ */
+ public SynchronizedSelectEPackageWizardPage(
+ final ISelectEPackageWizardPage object, final Display display) {
+ super(object, display);
+ }
+
+ public EPackage getSelectedEPackage() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<EPackage>() {
+ @Override
+ public EPackage safeRun() {
+ return SynchronizedSelectEPackageWizardPage.this
+ .getSynchronizedObject().getSelectedEPackage();
+ }
+ });
+ }
+
+ public void selectPackage(final String selection) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedSelectEPackageWizardPage.this
+ .getSynchronizedObject().selectPackage(selection);
+ }
+ });
+
+ // We keep the thread waiting until the selection is not done.
+ // If we release the thread, the selection may not be done and made some
+ // errors
+ while (this.getSelectedEPackage() == null) {
+ DebugUtils.debug(DEBUG, "Waiting."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedWizardPage.java
new file mode 100644
index 00000000000..33f4a15904e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/SynchronizedWizardPage.java
@@ -0,0 +1,260 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.util.wizard.page;
+
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
+import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Synchronized class for safe run.
+ *
+ * @author amenager_stage
+ * @since 0.3
+ *
+ */
+public class SynchronizedWizardPage<WP extends IWizardPage> extends
+ SynchronizedObject<WP>
+ implements IWizardPage {
+
+ /**
+ * Constructor.
+ *
+ * @param object
+ * the to synchronized.
+ * @param display
+ * the display.
+ */
+ public SynchronizedWizardPage(final WP object,
+ final Display display) {
+ super(object, display);
+ }
+
+ public void createControl(final Composite parent) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject()
+ .createControl(parent);
+ }
+ });
+ }
+
+ public void dispose() {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject().dispose();
+ }
+ });
+ }
+
+ public Control getControl() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Control>() {
+ @Override
+ public Control safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getControl();
+ }
+ });
+ }
+
+ public String getDescription() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getDescription();
+ }
+ });
+ }
+
+ public String getErrorMessage() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getErrorMessage();
+ }
+ });
+ }
+
+ public Image getImage() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Image>() {
+ @Override
+ public Image safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getImage();
+ }
+ });
+ }
+
+ public String getMessage() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getMessage();
+ }
+ });
+ }
+
+ public String getTitle() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getTitle();
+ }
+ });
+ }
+
+ public void performHelp() {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject()
+ .performHelp();
+ }
+ });
+ }
+
+ public void setDescription(final String description) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject()
+ .setDescription(description);
+ }
+ });
+ }
+
+ public void setImageDescriptor(final ImageDescriptor image) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject()
+ .setImageDescriptor(image);
+ }
+ });
+ }
+
+ public void setTitle(final String title) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject().setTitle(
+ title);
+ }
+ });
+ }
+
+ public void setVisible(final boolean visible) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject().setVisible(
+ visible);
+ }
+ });
+ }
+
+ public boolean canFlipToNextPage() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizardPage.this
+ .getSynchronizedObject()
+ .canFlipToNextPage());
+ }
+ }).booleanValue();
+ }
+
+ public IWizardPage getNextPage() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizardPage.this
+ .getSynchronizedObject().getNextPage();
+ }
+ });
+ }
+
+ public IWizardPage getPreviousPage() {
+ return this
+ .safeSyncExec(new AbstractExceptionFreeRunnable<IWizardPage>() {
+ @Override
+ public IWizardPage safeRun() {
+ return SynchronizedWizardPage.this
+ .getSynchronizedObject().getPreviousPage();
+ }
+ });
+ }
+
+ public IWizard getWizard() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<IWizard>() {
+ @Override
+ public IWizard safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getWizard();
+ }
+ });
+ }
+
+ public boolean isPageComplete() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
+ @Override
+ public Boolean safeRun() {
+ return Boolean.valueOf(SynchronizedWizardPage.this
+ .getSynchronizedObject().isPageComplete());
+ }
+ }).booleanValue();
+ }
+
+ public void setPreviousPage(final IWizardPage page) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject()
+ .setPreviousPage(page);
+ }
+ });
+ }
+
+ public void setWizard(final IWizard newWizard) {
+ this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
+ @Override
+ public void voidSafeRun() {
+ SynchronizedWizardPage.this.getSynchronizedObject().setWizard(
+ newWizard);
+ }
+ });
+ }
+
+ public String getName() {
+ return this.safeSyncExec(new AbstractExceptionFreeRunnable<String>() {
+ @Override
+ public String safeRun() {
+ return SynchronizedWizardPage.this.getSynchronizedObject()
+ .getName();
+ }
+ });
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEClassifierRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEClassifierRuntimeException.java
new file mode 100644
index 00000000000..383775db9a0
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEClassifierRuntimeException.java
@@ -0,0 +1,39 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.util.wizard.page.exception;
+
+/**
+ * @since 0.3
+ */
+public class SelectedEClassifierRuntimeException extends RuntimeException {
+
+
+ private static final long serialVersionUID = -1021467669726982508L;
+
+ public SelectedEClassifierRuntimeException() {
+ super(
+ "List not totally loaded. Check if the list's job is done before doing the selection."); //$NON-NLS-1$
+ }
+
+ public SelectedEClassifierRuntimeException(final String message) {
+ super(message);
+ }
+
+ public SelectedEClassifierRuntimeException(final String message,
+ final Throwable cause) {
+ super(message, cause);
+ }
+
+ public SelectedEClassifierRuntimeException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEPackageRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEPackageRuntimeException.java
new file mode 100644
index 00000000000..0c8f96d705e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/util/wizard/page/exception/SelectedEPackageRuntimeException.java
@@ -0,0 +1,41 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.util.wizard.page.exception;
+
+/**
+ * Exception when the list (where the selection has to be done) is not totally
+ * loaded.
+ *
+ * @since 0.3
+ */
+public class SelectedEPackageRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = -5317379187255054199L;
+
+ public SelectedEPackageRuntimeException() {
+ super(
+ "List not totally loaded. Check if the list's job is done before doing the selection."); //$NON-NLS-1$
+ }
+
+ public SelectedEPackageRuntimeException(final String message) {
+ super(message);
+ }
+
+ public SelectedEPackageRuntimeException(final String message,
+ final Throwable cause) {
+ super(message, cause);
+ }
+
+ public SelectedEPackageRuntimeException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/ISelectETypeWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/ISelectETypeWizard.java
new file mode 100644
index 00000000000..fdbf283324c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/ISelectETypeWizard.java
@@ -0,0 +1,25 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.wizard;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.facet.util.ui.internal.exported.wizard.IExtendedWizard;
+
+/**
+ * @since 0.3
+ */
+public interface ISelectETypeWizard<T extends EClassifier> extends
+ IExtendedWizard {
+
+ T getSelectedEClassifier();
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEClassifierWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEClassifierWizardPage.java
new file mode 100644
index 00000000000..29e736b583f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEClassifierWizardPage.java
@@ -0,0 +1,43 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.wizard.page;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.facet.util.emf.ui.internal.exported.util.wizard.page.SelectEClassifierWizardPage;
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * Interface for {@link SelectEClassifierWizardPage}.
+ *
+ * @see SelectEClassifierWizardPage
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ISelectEClassifierWizardPage<T extends EClassifier> extends
+ IWizardPage {
+
+ /**
+ * @return the selected {@link EClassifier}.
+ */
+ T getSelectedEClassifier();
+
+ /**
+ * Set the {@link EClassifier}.
+ *
+ * @param selection
+ * the name of the {@link EClassifier} to select.
+ */
+ void selectEClassifier(final String selection);
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEPackageWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEPackageWizardPage.java
new file mode 100644
index 00000000000..c0cd3dc2c88
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/exported/wizard/page/ISelectEPackageWizardPage.java
@@ -0,0 +1,40 @@
+/**
+ * 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.emf.facet.util.emf.ui.internal.exported.wizard.page;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * Interface for {@link SelectEPackageWizardPage}.
+ *
+ * @see SelectEPackageWizardPage
+ * @since 0.3
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ISelectEPackageWizardPage extends IWizardPage {
+
+ /**
+ * @return the first {@link EPackage} selected in the list.
+ */
+ EPackage getSelectedEPackage();
+
+ /**
+ * Set the {@link EPackage} to select.
+ *
+ * @param selection
+ * the name of the {@link EPackage} to select.
+ */
+ void selectPackage(final String selection);
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveAsHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveAsHandler.java
new file mode 100644
index 00000000000..326818b5cb2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveAsHandler.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.util.emf.ui.internal.ResourceUiUtils;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class SaveAsHandler implements IHandler {
+
+ public void addHandlerListener(final IHandlerListener handlerListener) {
+ // Nothing to do
+ }
+
+ public void dispose() {
+ // Nothing to do
+ }
+
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final Shell shell = HandlerUtil.getActiveShell(event);
+ for (Object object : getSelection()) {
+ if (object instanceof Resource) {
+ final Resource resource = (Resource) object;
+ ResourceUiUtils.openSaveAsDialog(resource, shell);
+ } else if (object instanceof IAdaptable) {
+ final IAdaptable adaptable = (IAdaptable) object;
+ final Resource resource = (Resource) adaptable
+ .getAdapter(Resource.class);
+ if (resource != null) {
+ ResourceUiUtils.openSaveAsDialog(resource, shell);
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isHandled() {
+ return isEnabled();
+ }
+
+ public void removeHandlerListener(final IHandlerListener handlerListener) {
+ // Nothing to do
+ }
+
+ private static <E> List<E> getSelection() {
+ final List<E> result = new ArrayList<E>();
+ final IWorkbenchWindow wWindow = getActiveWindow();
+ final ISelectionService selectService = wWindow.getSelectionService();
+ final ISelection selection = selectService.getSelection();
+ if (selection instanceof StructuredSelection) {
+ final StructuredSelection structS = (StructuredSelection) selection;
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings This cast is unsafe but the framework does not
+ // provide other way to do
+ final List<E> list = structS.toList();
+ result.addAll(list);
+ }
+ return result;
+ }
+
+ private static IWorkbenchWindow getActiveWindow() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ return workbench.getActiveWorkbenchWindow();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveHandler.java
new file mode 100644
index 00000000000..cf9585fa18f
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/handler/SaveHandler.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (c) 2013 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) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+ */
+package org.eclipse.emf.facet.util.emf.ui.internal.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.util.emf.ui.internal.ResourceUiUtils;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class SaveHandler implements IHandler {
+
+ public void addHandlerListener(final IHandlerListener handlerListener) {
+ // Nothing to do
+ }
+
+ public void dispose() {
+ // Nothing to do
+ }
+
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final Shell shell = HandlerUtil.getActiveShell(event);
+ for (Object object : getSelection()) {
+ if (object instanceof Resource) {
+ final Resource resource = (Resource) object;
+ ResourceUiUtils.save(resource, shell);
+ } else if (object instanceof IAdaptable) {
+ final IAdaptable adaptable = (IAdaptable) object;
+ final Resource resource = (Resource) adaptable
+ .getAdapter(Resource.class);
+ if (resource != null) {
+ ResourceUiUtils.save(resource, shell);
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isHandled() {
+ return isEnabled();
+ }
+
+ public void removeHandlerListener(final IHandlerListener handlerListener) {
+ // Nothing to do
+ }
+
+ private static <E> List<E> getSelection() {
+ final List<E> result = new ArrayList<E>();
+ final IWorkbenchWindow wWindow = getActiveWindow();
+ final ISelectionService selectService = wWindow.getSelectionService();
+ wWindow.getActivePage().getActivePart();
+ final ISelection selection = selectService.getSelection();
+ if (selection instanceof StructuredSelection) {
+ final StructuredSelection structS = (StructuredSelection) selection;
+ @SuppressWarnings("unchecked")
+ // @SuppressWarnings This cast is unsafe but the framework does not
+ // provide other way to do
+ final List<E> list = structS.toList();
+ result.addAll(list);
+ }
+ return result;
+ }
+
+ private static IWorkbenchWindow getActiveWindow() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ return workbench.getActiveWorkbenchWindow();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/messages.properties
new file mode 100644
index 00000000000..f37b671b4c5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/messages.properties
@@ -0,0 +1,40 @@
+###############################################################################
+# Copyright (c) 2011, 2012 Mia-Software and 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:
+# Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
+# Nicolas Bros (Mia-Software) - Copy of data form /org.eclipse.emf.facet.infra.common.ui/src/org/eclipse/emf/facet/infra/common/ui/messages.properties
+# Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+# Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
+# Gregoire Dupe (Mia-Software) - Bug 406570 - Handlers to Save and SaveAs EMF resources
+###############################################################################
+PackageRegistryView_copyNsURI=Copy nsURI
+PackageRegistryView_initializing=Initializing...
+PackageRegistryView_Location=Location
+PackageRegistryView_Name=Name
+PackageRegistryView_nsURI=nsUri
+PackageRegistryView_RefreshingPackageRegistryView=Refreshing EPackage Registry View
+DialogUriSelection_RegisteredEPackages=Registered EPackages:
+DialogUriSelection_title_OpenModelFromEMFRegistry=Open Model From EMF Registry
+EmfFacetRootPreferencePage_default_epackage_browser=Default EPackage Model Viewer
+EPackageBrowserPreferencePage_defaultEObjectViewer=Default EObject Model Viewer
+EPackageBrowserPreferencePage_defaultResourceViewer=Default Resource Model Viewer
+CreateInstanceDialog_selectNewInstanceEClass=Select new instance metaclass
+
+Select_EClass=Select an EClass
+Select_EClassifier=Select an EClassifier
+Select_EDataType=Select an EDataType
+Select_EPackage=Select an EPackage
+Select_ETypedElement= Select an ETypedElement
+
+No_result_found=No result found
+
+ResourceUiUtils_SavingFailed=Saving failed
+ResourceUiUtils_TheResourceSavingFailed=The resource saving failed: {0} \n See error for more details.
+SaveAsDialog_ResourceURI=Resource URI
+SaveAsDialog_SaveAs=Save As
+SaveAsDialog_YouHaveToProvideAValidEMFURI=You have to provide a valid EMF URI such as:\n - file:/C:/my_file.xmi\n - platform:/resource/my_projet/my_folder/my_file.xmi
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/preference/pages/DefaultBrowserPreferencePage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/preference/pages/DefaultBrowserPreferencePage.java
new file mode 100644
index 00000000000..b31b5002faf
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/preference/pages/DefaultBrowserPreferencePage.java
@@ -0,0 +1,106 @@
+/**********************************************************************************
+ * Copyright (c) 2009, 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 Bros (Mia-Software)
+ * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
+ * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
+ ***********************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.preference.pages;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.emf.facet.util.emf.core.IBrowserRegistry;
+import org.eclipse.emf.facet.util.emf.core.IEObjectBrowserOpener;
+import org.eclipse.emf.facet.util.emf.core.IEPackageBrowserOpener;
+import org.eclipse.emf.facet.util.emf.core.IResourceBrowserOpener;
+import org.eclipse.emf.facet.util.emf.core.internal.preferences.PreferenceConstants;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * This class implements a preference page that allows the user to choose which EPackage Browser
+ * they want to use.
+ */
+public class DefaultBrowserPreferencePage extends FieldEditorPreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public DefaultBrowserPreferencePage() {
+ super(FieldEditorPreferencePage.GRID);
+ ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(
+ new InstanceScope(),
+ org.eclipse.emf.facet.util.emf.core.internal.Activator.PLUGIN_ID);
+ setPreferenceStore(scopedPreferenceStore);
+ }
+
+ /**
+ * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to
+ * manipulate various types of preferences. Each field editor knows how to save and restore
+ * itself.
+ */
+ @Override
+ public void createFieldEditors() {
+ createResourceOpenerField();
+ createEObjectOpenerField();
+ createEPackageOpenerField();
+ }
+
+ private void createEPackageOpenerField() {
+ List<IEPackageBrowserOpener> openers = IBrowserRegistry.INSTANCE
+ .getAllRegisteredEPackageBrowsers();
+ int size = openers.size();
+ String[][] entryNamesAndValues = new String[size][2];
+ for (int i = 0; i < size; i++) {
+ IEPackageBrowserOpener opener = openers.get(i);
+ entryNamesAndValues[i][0] = opener.getBrowserName();
+ entryNamesAndValues[i][1] = opener.getClass().getName();
+ }
+ addField(new ComboFieldEditor(PreferenceConstants.P_DEFAULT_EPACKAGE_VIEWER,
+ Messages.EmfFacetRootPreferencePage_default_epackage_browser, entryNamesAndValues,
+ getFieldEditorParent()));
+ }
+
+ private void createEObjectOpenerField() {
+ List<IEObjectBrowserOpener> openers = IBrowserRegistry.INSTANCE
+ .getAllRegisteredEObjectBrowsers();
+ int size = openers.size();
+ String[][] entryNamesAndValues = new String[size][2];
+ for (int i = 0; i < size; i++) {
+ IEObjectBrowserOpener opener = openers.get(i);
+ entryNamesAndValues[i][0] = opener.getBrowserName();
+ entryNamesAndValues[i][1] = opener.getClass().getName();
+ }
+ addField(new ComboFieldEditor(PreferenceConstants.P_DEFAULT_EOBJECT_VIEWER,
+ Messages.EPackageBrowserPreferencePage_defaultEObjectViewer, entryNamesAndValues,
+ getFieldEditorParent()));
+ }
+
+ private void createResourceOpenerField() {
+ List<IResourceBrowserOpener> openers = IBrowserRegistry.INSTANCE
+ .getAllRegisteredResourceBrowsers();
+ int size = openers.size();
+ String[][] entryNamesAndValues = new String[size][2];
+ for (int i = 0; i < size; i++) {
+ IResourceBrowserOpener opener = openers.get(i);
+ entryNamesAndValues[i][0] = opener.getBrowserName();
+ entryNamesAndValues[i][1] = opener.getClass().getName();
+ }
+ addField(new ComboFieldEditor(PreferenceConstants.P_DEFAULT_RESOURCE_VIEWER,
+ Messages.EPackageBrowserPreferencePage_defaultResourceViewer, entryNamesAndValues,
+ getFieldEditorParent()));
+ }
+
+ public void init(final IWorkbench workbench) {
+ // Nothing to do
+ }
+
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageProvider.java
new file mode 100644
index 00000000000..da2d7f4de11
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageProvider.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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 333652 Extension point offering the possibility to declare an EPackage browser
+ * Gregoire Dupe (Mia-Software) - Bug 406578 - Generic Label Provider for EMF objects
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.utils;
+
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.swt.imageprovider.IImageProvider;
+import org.eclipse.emf.facet.util.swt.imageprovider.IImageProviderFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Provides icons for EMF Facet, and caches them.
+ */
+public final class ImageProvider {
+ public static final String EMFFACET_LOGO = "icons/logoEmfFacetMini.gif"; //$NON-NLS-1$
+ public static final String CATALOG = "icons/catalog.png"; //$NON-NLS-1$
+ public static final String MODEL = "icons/ModelIcon.gif"; //$NON-NLS-1$
+
+ private static final ImageProvider SINGLETON = new ImageProvider();
+ public static final IImageProvider DEFAULT = IImageProviderFactory.DEFAULT
+ .createIImageProvider(Activator.getDefault());
+
+ private ImageProvider() {
+ // Must not be used
+ }
+
+ @Deprecated
+ public static ImageProvider getInstance() {
+ return ImageProvider.SINGLETON;
+ }
+
+ @SuppressWarnings("static-method")
+ // @SuppressWarnings("static-method") This warning is caused by the
+ // redirection code associated to the deprecation of this method.
+ @Deprecated
+ public Image getEmfFacetLogo() {
+ return DEFAULT.getImage(EMFFACET_LOGO);
+ }
+
+ @Deprecated
+ public static ImageDescriptor getEmfFacetLogoDescriptor() {
+ return DEFAULT.createImageDescriptor(ImageProvider.EMFFACET_LOGO);
+ }
+
+ /** Return the icon representing a bidirectional link */
+ @SuppressWarnings("static-method")
+ // @SuppressWarnings("static-method") This warning is caused by the
+ // redirection code associated to the deprecation of this method.
+ @Deprecated
+ public Image getCatalogIcon() {
+ return DEFAULT.getImage(CATALOG);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageUtils.java
new file mode 100644
index 00000000000..75bee2e0186
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/utils/ImageUtils.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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)
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.utils;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Utility class for handling {@link Image}s.
+ *
+ * @author Gregoire Dupe
+ */
+public final class ImageUtils {
+ private static AdapterFactory composedAdapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ private ImageUtils() {
+ // Nothing to do
+ }
+
+ /**
+ * Returns an image for the given model element from the EMF global
+ * registry.
+ *
+ * @param object
+ * an {@link EObject} for which an {@link Image} is required
+ * @return an image or <code>null</code> if none was found for the given
+ * element, or the element is not an {@link EObject}
+ */
+ public static Image getImage(final Object object) {
+ Image result = null;
+ if (object instanceof EObject) {
+ EObject eObject = (EObject) object;
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) ImageUtils.composedAdapterFactory
+ .adapt(eObject, IItemLabelProvider.class);
+ if (itemLabelProvider != null) {
+ Object image = itemLabelProvider.getImage(eObject);
+ result = ExtendedImageRegistry.getInstance().getImage(image);
+ }
+ }
+ return result;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/view/PackageRegistryView.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/view/PackageRegistryView.java
new file mode 100644
index 00000000000..a2c185caac2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/internal/view/PackageRegistryView.java
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010, 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:
+ * Gregoire Dupe (Mia-Software) - initial API and implementation
+ * Nicolas Bros (Mia-Software)
+ * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
+ *******************************************************************************/
+package org.eclipse.emf.facet.util.emf.ui.internal.view;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.facet.common.ui.internal.views.AbstractTreeView;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.emf.core.IBrowserRegistry;
+import org.eclipse.emf.facet.util.emf.ui.internal.Activator;
+import org.eclipse.emf.facet.util.emf.ui.internal.Messages;
+import org.eclipse.emf.facet.util.emf.ui.internal.utils.ImageUtils;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchActionConstants;
+
+/**
+ * An Eclipse view that displays a list of available Ecore meta-models.
+ */
+public class PackageRegistryView extends AbstractTreeView implements IMenuListener {
+
+ private static final String NAME_COLUMN = "PackageRegistryView_NameColumn"; //$NON-NLS-1$
+ private static final String NSURI_COLUMN = "PackageRegistryView_NsURIColumn"; //$NON-NLS-1$
+
+ private static final int COLUMN_WIDTH = 200;
+
+ private static final String DEBUG_ID = "org.eclipse.emf.facet.infra.common.ui/debug/PackageRegistryView/event_debug"; //$NON-NLS-1$
+ private static final boolean DEBUG = Activator.getDefault().isDebugging()
+ && new Boolean(Platform.getDebugOption(PackageRegistryView.DEBUG_ID)).booleanValue();
+
+ @Override
+ public void createPartControl(final Composite parent) {
+ super.createPartControl(parent);
+ createContextMenu();
+ }
+
+ @Override
+ protected void createContextMenu() {
+ final MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
+ contextMenu.add(this.actionCopyNsURI);
+ contextMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ contextMenu.addMenuListener(this);
+ final Menu menu = contextMenu.createContextMenu(getViewer().getControl());
+ getViewer().getControl().setMenu(menu);
+ getSite().registerContextMenu(contextMenu, getViewer());
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ @Override
+ protected void createColumns() {
+ createNameColumn();
+ createNsUriColumn();
+ }
+
+ private void createNameColumn() {
+ ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
+ @Override
+ public String getText(final Object element) {
+ if (element instanceof EPackage) {
+ EPackage ePackage = (EPackage) element;
+ return ePackage.getName();
+ } else if (element instanceof String) {
+ return (String) element;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public Image getImage(final Object element) {
+ return ImageUtils.getImage(element);
+ }
+ };
+ createColumn(Messages.PackageRegistryView_Name, PackageRegistryView.NAME_COLUMN,
+ PackageRegistryView.COLUMN_WIDTH, columnLabelProvider);
+ }
+
+ private void createNsUriColumn() {
+ ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
+ @Override
+ public String getText(final Object element) {
+ if (!(element instanceof EPackage)) {
+ return ""; //$NON-NLS-1$
+ }
+ EPackage ePackage = (EPackage) element;
+ return ePackage.getNsURI();
+ }
+ };
+ createColumn(Messages.PackageRegistryView_nsURI, PackageRegistryView.NSURI_COLUMN,
+ PackageRegistryView.COLUMN_WIDTH * 2, columnLabelProvider);
+ }
+
+ /**
+ * Reads the registry in a non-UI thread, so that the UI thread will be able to access it faster
+ *
+ * @param registry
+ * the registry to preload
+ */
+ private static void preloadRegistry(final Registry registry) {
+ // avoid ConcurrentModificationException
+ List<String> keys = new ArrayList<String>();
+ keys.addAll(registry.keySet());
+ for (String nsURI : keys) {
+ try {
+ registry.getEPackage(nsURI);
+ } catch (Exception e) {
+ Logger.logWarning(e,
+ "An error happened while loading an EPackage from Package.Registry.INSTANCE: " //$NON-NLS-1$
+ + nsURI, Activator.getDefault());
+ } catch (LinkageError e) {
+ Logger.logError(e, "An error prevented an EPackage from being loaded: " //$NON-NLS-1$
+ + nsURI, Activator.getDefault());
+ }
+ }
+ }
+
+ /**
+ * An {@link EObject} was added to the package registry
+ *
+ * @param eObject
+ * @param file
+ */
+ public void added(final EObject eObject, final IFile file) {
+ if (PackageRegistryView.DEBUG) {
+ System.out.println(this.getClass().getSimpleName() + ".added(EObject,IFile)"); //$NON-NLS-1$
+ }
+ refresh(true);
+ }
+
+ /**
+ * An {@link EObject} was changed in the package registry
+ *
+ * @param eObject
+ * @param file
+ */
+ public void changed(final EObject eObject, final IFile file) {
+ if (PackageRegistryView.DEBUG) {
+ System.out.println(this.getClass().getSimpleName() + ".changed(EObject,IFile)"); //$NON-NLS-1$
+ }
+ refresh(true);
+ }
+
+ /**
+ * A file was removed from the package registry
+ *
+ * @param file
+ */
+ public void removed(final IFile file) {
+ if (PackageRegistryView.DEBUG) {
+ System.out.println(this.getClass().getSimpleName() + ".removed(EObject,IFile)"); //$NON-NLS-1$
+ }
+ refresh(true);
+ }
+
+ @Override
+ protected IContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+ public Object[] getElements(final Object inputElement) {
+ if (inputElement instanceof EPackage.Registry) {
+ EPackage.Registry registry = (EPackage.Registry) inputElement;
+ List<EPackage> ePackages = new ArrayList<EPackage>();
+ // avoid a ConcurrentModificationException
+ List<String> keys = new ArrayList<String>();
+ keys.addAll(registry.keySet());
+ for (String nsURI : keys) {
+ try {
+ EPackage ePackage = registry.getEPackage(nsURI);
+ if (ePackage == null) {
+ throw new Exception("ePackage is null for : " //$NON-NLS-1$
+ + nsURI);
+ }
+ ePackages.add(ePackage);
+ } catch (Exception e) {
+ Logger.logWarning(e,
+ "An error happened while loading an EPackage from Package.Registry.INSTANCE: " //$NON-NLS-1$
+ + nsURI, Activator.getDefault());
+ }
+ }
+ return ePackages.toArray();
+ } else if (inputElement == null) {
+ return new Object[] {};
+ } else if (inputElement instanceof String) {
+ String message = (String) inputElement;
+ return new Object[] { message };
+ } else {
+ throw new RuntimeException("Unexpected element type: " //$NON-NLS-1$
+ + inputElement.getClass().getName());
+ }
+ }
+
+ public void inputChanged(final Viewer viewer, final Object oldInput,
+ final Object newInput) {
+ // Nothing to do
+ }
+
+ public Object[] getChildren(final Object parentElement) {
+ if (parentElement instanceof EPackage.Registry) {
+ EPackage.Registry registry = (EPackage.Registry) parentElement;
+ return registry.values().toArray();
+ } else if (parentElement == null || parentElement instanceof String) {
+ return new Object[] {};
+ } else {
+ throw new RuntimeException("Unexpected element type: " //$NON-NLS-1$
+ + parentElement.getClass().getName());
+ }
+ }
+
+ public Object getParent(final Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(final Object element) {
+ if (element instanceof EPackage.Registry) {
+ return true;
+ }
+ return false;
+ }
+
+ public void dispose() {
+ // Nothing to do
+ }
+ };
+ }
+
+ @Override
+ protected void openElement(final Object element) {
+ if (element instanceof EPackage) {
+ EPackage ePackage = (EPackage) element;
+ IBrowserRegistry.INSTANCE.browseEPackage(ePackage);
+ }
+ }
+
+ @Override
+ protected String getRefreshMessage() {
+ return Messages.PackageRegistryView_RefreshingPackageRegistryView;
+ }
+
+ @Override
+ protected void doRefresh() {
+ // display a message while initializing
+ // (initialization can take a while)
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ getViewer().setInput(Messages.PackageRegistryView_initializing);
+ }
+ });
+ final EPackage.Registry registry = EPackage.Registry.INSTANCE;
+ // Read a first time in a non-UI thread so as to avoid
+ // blocking. Then it will be cached for the UI thread.
+ preloadRegistry(registry);
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ // the control might be disposed if the view was closed
+ // in the meantime
+ if (!getViewer().getControl().isDisposed()) {
+ getViewer().setInput(registry);
+ getViewer().refresh();
+ }
+ }
+ });
+ }
+
+ @Override
+ protected Object getInput() {
+ return EPackage.Registry.INSTANCE;
+ }
+
+ private final Action actionCopyNsURI = new Action(Messages.PackageRegistryView_copyNsURI,
+ IAction.AS_PUSH_BUTTON) {
+ @Override
+ public void run() {
+ EPackage selectedPackage = PackageRegistryView.this.getSelectedPackage();
+ if (selectedPackage != null) {
+ String nsURI = selectedPackage.getNsURI();
+ Clipboard clipboard = new Clipboard(Display.getDefault());
+ clipboard.setContents(new Object[] { nsURI },
+ new Transfer[] { TextTransfer.getInstance() });
+ clipboard.dispose();
+ }
+ }
+ };
+
+ protected EPackage getSelectedPackage() {
+ ISelection selection = getViewer().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object element = structuredSelection.getFirstElement();
+ if (element instanceof EPackage) {
+ EPackage ePackage = (EPackage) element;
+ return ePackage;
+ }
+ }
+ return null;
+ }
+
+ public void menuAboutToShow(final IMenuManager manager) {
+ this.actionCopyNsURI.setEnabled(getSelectedPackage() != null);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/util/EditingUtil.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/util/EditingUtil.java
new file mode 100644
index 00000000000..2de24b13036
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.ui/src/org/eclipse/emf/facet/util/emf/ui/util/EditingUtil.java
@@ -0,0 +1,60 @@
+/**
+ * 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.emf.facet.util.emf.ui.util;
+
+import java.io.File;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @since 0.3
+ */
+public final class EditingUtil {
+
+ private EditingUtil() {
+ // Hidden constructor.
+ }
+
+ /**
+ * Return the current editing domain.
+ *
+ * @return the current editing domain.
+ */
+ public static EditingDomain getEditingDomain() {
+ // Retrieve the editor
+ final IWorkbenchPart editor = PlatformUI.getWorkbench()
+ .getWorkbenchWindows()[0].getPages()[0].getActivePart();
+ // Retrieve the editing domain
+ final IEditingDomainProvider edProvider = (IEditingDomainProvider) editor
+ .getAdapter(IEditingDomainProvider.class);
+ EditingDomain editingDomain = null;
+ if (edProvider != null) {
+ editingDomain = edProvider.getEditingDomain();
+ }
+ return editingDomain;
+ }
+
+ /**
+ * Create and return a new {@link Resource}.
+ *
+ * @return the new {@link Resource}.
+ */
+ public static Resource createDefaultResource(final File file) {
+ return getEditingDomain().getResourceSet().createResource(
+ URI.createFileURI(file.getPath()));
+ }
+}

Back to the top