Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-12-21 15:25:34 +0000
committercletavernie2011-12-21 15:25:34 +0000
commit5e713e19b0785ec75084e8431cae11a8aa88b39d (patch)
tree689e738926e9b00c0fec57a0f8a8d80b25c4afd2 /plugins
parent54c7e674c21bcb73ae921c6ecb1237575d3e04e6 (diff)
downloadorg.eclipse.papyrus-5e713e19b0785ec75084e8431cae11a8aa88b39d.tar.gz
org.eclipse.papyrus-5e713e19b0785ec75084e8431cae11a8aa88b39d.tar.xz
org.eclipse.papyrus-5e713e19b0785ec75084e8431cae11a8aa88b39d.zip
351804: [EMF Embedded Editor] Papyrus shall provide an embedded EMF Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351804
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.classpath7
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.project28
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/META-INF/MANIFEST.MF23
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/about.html28
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/build.properties11
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/icons/papyrus_model.pngbin0 -> 618 bytes
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/plugin.xml25
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/Activator.java92
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/CompoundCommandActionDelegate.java59
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCopyAction.java51
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCutAction.java53
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDeleteAction.java79
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDropAdapter.java68
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoPasteAction.java52
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/ValidationAction.java43
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/ActionBarContributor.java121
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/PapyrusEditor.java258
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/providers/CustomizableContentProvider.java44
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/util/ActionUtil.java97
20 files changed, 1147 insertions, 0 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.classpath b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.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/infra/emf/org.eclipse.papyrus.infra.emf.editor/.project b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.project
new file mode 100644
index 00000000000..04943f396f8
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.emf.editor</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>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..8bca62fefcf
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Jul 27 11:41:38 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..2f8f79371fa
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Papyrus EMF Editor (Incubation)
+Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.editor;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.infra.emf.editor.Activator
+Bundle-Vendor: Eclipse Modeling Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;bundle-version="2.7.0",
+ org.eclipse.emf.ecore.editor;bundle-version="2.7.0",
+ org.eclipse.core.resources;bundle-version="3.7.100",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200",
+ org.eclipse.papyrus.infra.emf.newchild;bundle-version="0.9.0",
+ org.eclipse.emf.facet.infra.browser.custom;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.custom.core;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0",
+ org.eclipse.papyrus.views.properties;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.9.0",
+ org.eclipse.emf.transaction;bundle-version="1.4.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/about.html b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/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>June 5, 2007</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>
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/build.properties b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/build.properties
new file mode 100644
index 00000000000..860d48fe5e6
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.xml,\
+ icons/
+src.includes = META-INF/,\
+ about.html,\
+ icons/,\
+ plugin.xml
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/icons/papyrus_model.png b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/icons/papyrus_model.png
new file mode 100644
index 00000000000..3386d218553
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/icons/papyrus_model.png
Binary files differ
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/plugin.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/plugin.xml
new file mode 100644
index 00000000000..c7319065fed
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/plugin.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
+ <propertyContributor
+ contributorId="CustomizablePropertyView"
+ labelProvider="org.eclipse.papyrus.properties.providers.SelectionLabelProvider"
+ tabDescriptorProvider="org.eclipse.papyrus.properties.xwt.XWTTabDescriptorProvider">
+ </propertyContributor>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.papyrus.infra.emf.editor.part.PapyrusEditor"
+ contributorClass="org.eclipse.papyrus.infra.emf.editor.part.ActionBarContributor"
+ default="false"
+ extensions="xmi"
+ icon="icons/papyrus_model.png"
+ id="org.eclipse.papyrus.emf.editor"
+ name="Papyrus EMF Editor">
+ </editor>
+ </extension>
+
+</plugin>
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/Activator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/Activator.java
new file mode 100644
index 00000000000..2699370af49
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/Activator.java
@@ -0,0 +1,92 @@
+package org.eclipse.papyrus.infra.emf.editor;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+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.papyrus.infra.emf.editor"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ private CustomizationManager fCustomizationManager;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ *
+ * @return the customization manager in charge to adapt element in modisco
+ */
+ public CustomizationManager getCustomizationManager() {
+ if(this.fCustomizationManager == null) {
+ this.fCustomizationManager = new CustomizationManager();
+ init(this.fCustomizationManager);
+ }
+ return this.fCustomizationManager;
+ }
+
+ private void init(final CustomizationManager customizationManager) {
+ customizationManager.setShowContainer(false);
+ customizationManager.setShowDerivedLinks(false);
+ customizationManager.setShowEmptyLinks(false);
+
+ try {
+ List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
+ for(MetamodelView metamodelView : registryDefaultCustomizations) {
+ customizationManager.registerCustomization(metamodelView);
+ }
+
+ customizationManager.loadCustomizations();
+ } catch (Throwable e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error initializing customizations", e)); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/CompoundCommandActionDelegate.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/CompoundCommandActionDelegate.java
new file mode 100644
index 00000000000..b21be463879
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/CompoundCommandActionDelegate.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.edit.command.CommandActionDelegate;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * An EMF Compound Command with support for Images, Tooltip text and description
+ * (From CommandActionDelegate)
+ * The first sub-command should be a CommandActionDelegate
+ *
+ * @author Camille Letavernier
+ */
+public class CompoundCommandActionDelegate extends CompoundCommand implements CommandActionDelegate {
+
+ private Image image;
+
+ /**
+ * Sets the Image for this command
+ *
+ * @param image
+ * The image to display on the command
+ */
+ public void setImage(Image image) {
+ this.image = image;
+ }
+
+ public Object getImage() {
+ if(image == null)
+ return ((CommandActionDelegate)getCommandList().get(0)).getImage();
+ else
+ return image;
+ }
+
+ public String getText() {
+ return ((CommandActionDelegate)getCommandList().get(0)).getText();
+ }
+
+ public String getToolTipText() {
+ return ((CommandActionDelegate)getCommandList().get(0)).getToolTipText();
+ }
+
+ @Override
+ public String getDescription() {
+ return ((CommandActionDelegate)getCommandList().get(0)).getDescription();
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCopyAction.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCopyAction.java
new file mode 100644
index 00000000000..dd9449b01f5
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCopyAction.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.CopyAction;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+
+/**
+ * An adapter for the EMF "Copy" Action, compatible with the
+ * MoDisco customizable content provider.
+ *
+ * @author Camille Letavernier
+ */
+public class MoDiscoCopyAction extends CopyAction {
+
+ /**
+ * Constructor.
+ */
+ public MoDiscoCopyAction() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param domain
+ * The Editing domain on which the action will be executed
+ */
+ public MoDiscoCopyAction(EditingDomain domain) {
+ super(domain);
+ }
+
+ @Override
+ public Command createCommand(Collection<?> selection) {
+ Collection<?> newSelection = ActionUtil.getAdaptedSelection(selection);
+ return super.createCommand(newSelection);
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCutAction.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCutAction.java
new file mode 100644
index 00000000000..277ec47fe2b
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoCutAction.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.CutAction;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+
+/**
+ * An adapter for the EMF "Cut" Action, compatible with the
+ * MoDisco customizable content provider.
+ *
+ * @author Camille Letavernier
+ */
+public class MoDiscoCutAction extends CutAction {
+
+ /**
+ * Constructor.
+ */
+ public MoDiscoCutAction() {
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param domain
+ * The Editing domain on which the command will be executed
+ */
+ public MoDiscoCutAction(EditingDomain domain) {
+ super(domain);
+ }
+
+ @Override
+ public Command createCommand(Collection<?> selection) {
+ Collection<?> newSelection = ActionUtil.getAdaptedSelection(selection);
+ return super.createCommand(newSelection);
+ }
+
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDeleteAction.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDeleteAction.java
new file mode 100644
index 00000000000..0a9a67120bd
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDeleteAction.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.DeleteAction;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+
+/**
+ * An adapter for the EMF "Delete" Action, compatible with the
+ * MoDisco customizable content provider.
+ *
+ * @author Camille Letavernier
+ */
+public class MoDiscoDeleteAction extends DeleteAction {
+
+ /**
+ * Constructor.
+ *
+ * @param domain
+ * The editing domain on which the action will be called
+ * @param removeAllReferences
+ * If true, all references to the deleted object will be removed.
+ * This causes the whole resourceSet to be loaded, which may
+ * lead to performance issues.
+ */
+ public MoDiscoDeleteAction(EditingDomain domain, boolean removeAllReferences) {
+ super(domain, removeAllReferences);
+ }
+
+ /**
+ * Constructor. All references to the deleted object will be removed.
+ *
+ * @param domain
+ * The editing domain on which the action will be called
+ */
+ public MoDiscoDeleteAction(EditingDomain domain) {
+ super(domain);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param removeAllReferences
+ * If true, all references to the deleted object will be removed.
+ * This causes the whole resourceSet to be loaded, which may
+ * lead to performance issues.
+ */
+ public MoDiscoDeleteAction(boolean removeAllReferences) {
+ super(removeAllReferences);
+ }
+
+ /**
+ * Constructor. All references to the deleted object will be removed.
+ */
+ public MoDiscoDeleteAction() {
+ super();
+ }
+
+ @Override
+ public Command createCommand(Collection<?> selection) {
+ Collection<?> newSelection = ActionUtil.getAdaptedSelection(selection);
+ return super.createCommand(newSelection);
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDropAdapter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDropAdapter.java
new file mode 100644
index 00000000000..ab57b1224b3
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoDropAdapter.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * An adapter for Drag & Drop in the Context editor. The default Ecore drag & drop
+ * is not compatible with the EMF Facet Tree Elements
+ *
+ * @author Camille Letavernier
+ */
+public class MoDiscoDropAdapter extends EditingDomainViewerDropAdapter {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param domain
+ * The Editing domain for this Drop Adapter
+ * @param viewer
+ * The Viewer for this Drop Adapter
+ */
+ public MoDiscoDropAdapter(EditingDomain domain, Viewer viewer) {
+ super(domain, viewer);
+ }
+
+ @Override
+ protected Collection<?> extractDragSource(Object object) {
+ if(object instanceof ISelection) {
+ return super.extractDragSource(ActionUtil.getAdaptedSelection((ISelection)object));
+ } else {
+ return super.extractDragSource(object);
+ }
+ }
+
+ @Override
+ protected Object extractDropTarget(Widget item) {
+ Object dropTarget = super.extractDropTarget(item);
+ if(dropTarget instanceof IAdaptable) {
+ Object adapter = ((IAdaptable)dropTarget).getAdapter(EObject.class);
+ if(adapter != null) {
+ return adapter;
+ }
+ }
+
+ return dropTarget;
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoPasteAction.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoPasteAction.java
new file mode 100644
index 00000000000..41345871d9f
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/MoDiscoPasteAction.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.PasteAction;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+
+/**
+ * An adapter for the EMF "Paste" Action, compatible with the
+ * MoDisco customizable content provider.
+ *
+ * @author Camille Letavernier
+ */
+public class MoDiscoPasteAction extends PasteAction {
+
+ /**
+ * Constructor.
+ */
+ public MoDiscoPasteAction() {
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param domain
+ * The editing domain on which the command will be called
+ */
+ public MoDiscoPasteAction(EditingDomain domain) {
+ super(domain);
+ }
+
+ @Override
+ public Command createCommand(Collection<?> selection) {
+ Collection<?> newSelection = ActionUtil.getAdaptedSelection(selection);
+ return super.createCommand(newSelection);
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/ValidationAction.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/ValidationAction.java
new file mode 100644
index 00000000000..7a5108d6caf
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/actions/ValidationAction.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.actions;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+
+/**
+ * An adapter for the EMF "Validate" Action, compatible with the
+ * MoDisco customizable content provider.
+ *
+ * @author Camille Letavernier
+ */
+public class ValidationAction extends ValidateAction {
+
+ public ValidationAction() {
+ //Nothing
+ }
+
+ public ValidationAction(EditingDomain domain) {
+ this.domain = domain;
+ }
+
+ public void setEditingDomain(EditingDomain domain) {
+ this.domain = domain;
+ }
+
+ @Override
+ public boolean updateSelection(IStructuredSelection selection) {
+ return super.updateSelection((IStructuredSelection)ActionUtil.getAdaptedSelection(selection));
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/ActionBarContributor.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/ActionBarContributor.java
new file mode 100644
index 00000000000..fd96e5b918a
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/ActionBarContributor.java
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.part;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.eclipse.emf.ecore.presentation.EcoreActionBarContributor;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.CopyAction;
+import org.eclipse.emf.edit.ui.action.CutAction;
+import org.eclipse.emf.edit.ui.action.DeleteAction;
+import org.eclipse.emf.edit.ui.action.PasteAction;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.papyrus.infra.emf.editor.actions.MoDiscoCopyAction;
+import org.eclipse.papyrus.infra.emf.editor.actions.MoDiscoCutAction;
+import org.eclipse.papyrus.infra.emf.editor.actions.MoDiscoDeleteAction;
+import org.eclipse.papyrus.infra.emf.editor.actions.MoDiscoPasteAction;
+import org.eclipse.papyrus.infra.emf.editor.actions.ValidationAction;
+import org.eclipse.papyrus.infra.emf.editor.util.ActionUtil;
+import org.eclipse.papyrus.infra.emf.newchild.runtime.NewchildManager;
+
+/**
+ * The Action bar contributor for the Context Editor
+ * Mainly serves as an Adapter for the Ecore actions, as the Ecore actions are
+ * not natively compatible with the EMF Facet tree objects
+ *
+ * @author Camille Letavernier
+ */
+public class ActionBarContributor extends EcoreActionBarContributor {
+
+ protected IStructuredSelection lastSelection;
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ActionBarContributor() {
+ super();
+ validateAction = new ValidationAction();
+ }
+
+ public void setEditingDomain(EditingDomain domain) {
+ if(validateAction instanceof ValidationAction) {
+ ((ValidationAction)validateAction).setEditingDomain(domain);
+ }
+ }
+
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
+ super.addGlobalActions(menuManager);
+ }
+
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
+ super.menuAboutToShow(menuManager);
+ menuManager.insertBefore("edit", new Separator(NewchildManager.TOP)); //$NON-NLS-1$
+ NewchildManager.instance.fillMenu(menuManager, lastSelection);
+ }
+
+ @Override
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
+ return new LinkedList<IAction>();
+ }
+
+ @Override
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
+ return new LinkedList<IAction>();
+ }
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection newSelection = ActionUtil.getAdaptedSelection(event.getSelection());
+
+ SelectionChangedEvent newEvent = new SelectionChangedEvent(event.getSelectionProvider(), newSelection);
+
+ super.selectionChanged(newEvent);
+
+ if(newSelection instanceof IStructuredSelection) {
+ this.lastSelection = (IStructuredSelection)newSelection;
+ } else {
+ this.lastSelection = null;
+ }
+ }
+
+ @Override
+ protected DeleteAction createDeleteAction() {
+ return new MoDiscoDeleteAction(removeAllReferencesOnDelete());
+ }
+
+ @Override
+ protected CutAction createCutAction() {
+ return new MoDiscoCutAction();
+ }
+
+ @Override
+ protected CopyAction createCopyAction() {
+ return new MoDiscoCopyAction();
+ }
+
+ @Override
+ protected PasteAction createPasteAction() {
+ return new MoDiscoPasteAction();
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/PapyrusEditor.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/PapyrusEditor.java
new file mode 100644
index 00000000000..3939406c91c
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/part/PapyrusEditor.java
@@ -0,0 +1,258 @@
+package org.eclipse.papyrus.infra.emf.editor.part;
+
+import java.util.EventObject;
+import java.util.HashMap;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.ecore.presentation.EcoreEditor;
+import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.emf.transaction.TransactionalCommandStack;
+import org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl;
+import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.emf.editor.Activator;
+import org.eclipse.papyrus.infra.emf.editor.actions.MoDiscoDropAdapter;
+import org.eclipse.papyrus.infra.emf.editor.providers.CustomizableContentProvider;
+import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
+import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
+import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
+import org.eclipse.papyrus.views.properties.widgets.layout.GridData;
+import org.eclipse.papyrus.views.properties.widgets.layout.PropertiesLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * An extended EMF editor
+ *
+ * This generic editor provides the following features :
+ *
+ * - EMF Facet browser customization
+ * - Papyrus customizable property view
+ * - Papyrus customizable new child
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class PapyrusEditor extends EcoreEditor implements ITabbedPropertySheetPageContributor, CommandStackListener {
+
+ public static final String PROPERTY_VIEW_ID = "CustomizablePropertyView"; //$NON-NLS-1$
+
+ /**
+ * The Property sheet page for this editor
+ */
+ protected IPropertySheetPage iPropertySheetPage;
+
+ @Override
+ public void createPages() {
+ // Creates the model from the editor input
+ //
+ createModel();
+
+ getContainer().setBackground(new Color(getContainer().getDisplay(), 255, 255, 255));
+ getContainer().setBackgroundMode(SWT.INHERIT_DEFAULT);
+
+ Composite gParent = new Composite(getContainer(), SWT.NONE);
+ gParent.setLayout(new FillLayout());
+
+ //SashForm parent = new SashForm(gParent, SWT.VERTICAL | SWT.V_SCROLL | SWT.H_SCROLL);
+ //parent.setLayout(new FillLayout());
+
+ Composite parent = new Composite(gParent, SWT.NONE);
+ parent.setLayout(new PropertiesLayout());
+
+ // Only creates the other pages if there is something that can be edited
+ //
+ if(!getEditingDomain().getResourceSet().getResources().isEmpty()) {
+ // Create a page for the selection tree view.
+ //
+
+ final PatternViewerFilter filter = new PatternViewerFilter();
+ filter.setShowIfHasVisibleParent(true);
+
+ final StringEditor filterPattern = new StringEditor(parent, SWT.NONE, "Filter");
+ filterPattern.addCommitListener(new ICommitListener() {
+
+ public void commit(AbstractEditor editor) {
+ filter.setPattern((String)filterPattern.getValue());
+ selectionViewer.refresh();
+ }
+
+ });
+
+ Tree tree = new Tree(parent, SWT.BORDER | SWT.MULTI);
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ selectionViewer = new TreeViewer(tree);
+ selectionViewer.setFilters(new ViewerFilter[]{ filter });
+ setCurrentViewer(selectionViewer);
+ IStructuredContentProvider contentProvider = createContentProvider();
+ getCustomizationManager().installCustomPainter(tree);
+
+ ILabelProvider labelProvider = createLabelProvider();
+
+ editingDomain.getCommandStack().addCommandStackListener(this);
+
+ selectionViewer.setContentProvider(contentProvider);
+ selectionViewer.setLabelProvider(labelProvider);
+
+ selectionViewer.setInput(editingDomain.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
+
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(selectionViewer);
+ int pageIndex = addPage(gParent);
+ setPageText(pageIndex, "Model"); //$NON-NLS-1$
+
+ setActivePage(0);
+
+ // Preview preview = new Preview(this);
+ // preview.createPartControl(parent);
+ // addPreview(preview);
+
+ parent.layout();
+ }
+
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener(new ControlAdapter() {
+
+ boolean guard = false;
+
+ @Override
+ public void controlResized(ControlEvent event) {
+ if(!guard) {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
+ }
+ });
+
+ if(getActionBarContributor() instanceof ActionBarContributor) {
+ ((ActionBarContributor)getActionBarContributor()).setEditingDomain(getEditingDomain());
+ }
+
+ updateProblemIndication();
+ }
+
+
+ @Override
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new EcoreItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are executed.
+ //
+ TransactionalCommandStack commandStack = new TransactionalCommandStackImpl();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener(new CommandStackListener() {
+
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if(mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ if(propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
+ propertySheetPage.refresh();
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new TransactionalEditingDomainImpl(adapterFactory, commandStack);
+ editingDomain.setResourceToReadOnlyMap(new HashMap<Resource, Boolean>());
+ }
+
+ @Override
+ protected void createContextMenuFor(StructuredViewer viewer) {
+ MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
+ contextMenu.add(new Separator("additions")); //$NON-NLS-1$
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(this);
+ Menu menu = contextMenu.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[]{ LocalTransfer.getInstance() };
+ viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
+ viewer.addDropSupport(dndOperations, transfers, new MoDiscoDropAdapter(editingDomain, viewer));
+ }
+
+ @Override
+ public IPropertySheetPage getPropertySheetPage() {
+ if(iPropertySheetPage == null) {
+ iPropertySheetPage = new TabbedPropertySheetPage(this);
+ }
+ return iPropertySheetPage;
+ }
+
+ protected CustomizationManager getCustomizationManager() {
+ return Activator.getDefault().getCustomizationManager();
+ }
+
+ protected IStructuredContentProvider createContentProvider() {
+ return new CustomizableContentProvider(getCustomizationManager());
+ }
+
+ protected ILabelProvider createLabelProvider() {
+ return new CustomizableModelLabelProvider(getCustomizationManager());
+ }
+
+ public void commandStackChanged(EventObject event) {
+ getViewer().refresh();
+ }
+
+ public String getContributorId() {
+ return PROPERTY_VIEW_ID;
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/providers/CustomizableContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/providers/CustomizableContentProvider.java
new file mode 100644
index 00000000000..b0158b0123d
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/providers/CustomizableContentProvider.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.providers;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelContentProvider;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+
+
+public class CustomizableContentProvider extends CustomizableModelContentProvider {
+
+ public CustomizableContentProvider(CustomizationManager customizationManager) {
+ super(customizationManager);
+ }
+
+ @Override
+ public Object[] getRootElements(final Object inputElement) {
+ if(inputElement instanceof IFile) {
+ return super.getRootElements(inputElement);
+ }
+
+ if(inputElement instanceof ResourceSet) {
+ return ((ResourceSet)inputElement).getResources().get(0).getContents().toArray();
+ }
+
+ return new Object[0];
+ }
+
+ @Override
+ public boolean hasChildren(Object parentElement) {
+ return getChildren(parentElement).length > 0;
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/util/ActionUtil.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/util/ActionUtil.java
new file mode 100644
index 00000000000..2408b404a3e
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.editor/src/org/eclipse/papyrus/infra/emf/editor/util/ActionUtil.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.editor.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/**
+ * Utility class for Actions
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class ActionUtil {
+
+ /**
+ * EMF can only handle collections of EObjects. However, as the
+ * customization plugin relies a lot on EMF Facet, we often have to handle
+ * objects that can be adapted to EObjects, but are not EObjects
+ * themselves. This method adapts a collections of such objects to their
+ * underlying EObjects, so that EMF can handle them.
+ * Objects that cannot be adapted remain as-is in the collection.
+ *
+ * @param selection
+ * The collection to adapt
+ * @return
+ * The adapted selection
+ */
+ public static Collection<Object> getAdaptedSelection(Collection<? extends Object> selection) {
+ Collection<Object> newSelection = new LinkedList<Object>();
+ for(Object o : selection) {
+ if(o instanceof IAdaptable) {
+ EObject eObject = (EObject)((IAdaptable)o).getAdapter(EObject.class);
+ newSelection.add(eObject);
+ } else {
+ newSelection.add(o);
+ }
+ }
+ return newSelection;
+ }
+
+ /**
+ * EMF can only handle ISelection containing EObjects. However, as the
+ * customization plugin relies a lot on EMF Facet, we often have to handle
+ * objects that can be adapted to EObjects, but are not EObjects
+ * themselves. This method adapts a ISelection of such objects to their
+ * underlying EObjects, so that EMF can handle them.
+ * Objects that cannot be adapted remain as-is in the selection.
+ *
+ * @param sourceSelection
+ * The selection to adapt
+ * @return
+ * The adapted selection
+ */
+ public static ISelection getAdaptedSelection(ISelection sourceSelection) {
+ if(sourceSelection instanceof StructuredSelection) {
+ StructuredSelection currentSelection = (StructuredSelection)sourceSelection;
+ List<Object> newSelection = new LinkedList<Object>();
+
+ Iterator<?> it = currentSelection.iterator();
+ while(it.hasNext()) {
+ Object object = it.next();
+ if(object instanceof IAdaptable) {
+ EObject eObject = (EObject)((IAdaptable)object).getAdapter(EObject.class);
+ if(eObject != null) {
+ newSelection.add(eObject);
+ } else {
+ newSelection.add(object);
+ }
+ } else {
+ newSelection.add(object);
+ }
+ }
+
+ StructuredSelection selection = new StructuredSelection(newSelection);
+ return selection;
+ } else {
+ return sourceSelection;
+ }
+ }
+}

Back to the top