Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraradermache2013-02-25 09:08:31 +0000
committeraradermache2013-02-25 09:08:31 +0000
commit9d2a100e51a967f18d232cb715d422826c13519e (patch)
treea9b32aa7703321b54cc8b1e3328f13c545208a17 /plugins/developer/org.eclipse.papyrus.gmf.editpartview
parentcfad5896992a96ffbb5923ed22f0c4e3295f6875 (diff)
downloadorg.eclipse.papyrus-9d2a100e51a967f18d232cb715d422826c13519e.tar.gz
org.eclipse.papyrus-9d2a100e51a967f18d232cb715d422826c13519e.tar.xz
org.eclipse.papyrus-9d2a100e51a967f18d232cb715d422826c13519e.zip
Initial import
View that displays hierarchy of edit parts, when an element is selected
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.gmf.editpartview')
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/.classpath7
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/.project28
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/META-INF/MANIFEST.MF18
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/about.html28
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/Activator.classbin0 -> 950 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$1.classbin0 -> 1630 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$2.classbin0 -> 1129 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$3.classbin0 -> 1876 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$EditPolicyDescriptor.classbin0 -> 844 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.classbin0 -> 5234 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.classbin0 -> 2949 bytes
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/build.properties5
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.properties3
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.xml14
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/Activator.java52
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.java231
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.java86
18 files changed, 479 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.classpath b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.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/developer/org.eclipse.papyrus.gmf.editpartview/.project b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.project
new file mode 100644
index 00000000000..4fe341a1c42
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.gmf.editpartview</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/developer/org.eclipse.papyrus.gmf.editpartview/.settings/org.eclipse.jdt.core.prefs b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+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/developer/org.eclipse.papyrus.gmf.editpartview/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a17e015d7f0
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.gmf.editpartview;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.gmf.editpartview.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.facet.common.ui,
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.papyrus.infra.core,
+ org.eclipse.papyrus.editor,
+ org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="0.9.2",
+ org.eclipse.uml2.uml;bundle-version="4.0.1"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/about.html b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/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/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/Activator.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/Activator.class
new file mode 100644
index 00000000000..33c6a0cbb42
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/Activator.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$1.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$1.class
new file mode 100644
index 00000000000..2edace4bca7
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$1.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$2.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$2.class
new file mode 100644
index 00000000000..d1e90634d72
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$2.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$3.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$3.class
new file mode 100644
index 00000000000..52eece78dd3
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$3.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$EditPolicyDescriptor.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$EditPolicyDescriptor.class
new file mode 100644
index 00000000000..dee1ea3190c
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView$EditPolicyDescriptor.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.class
new file mode 100644
index 00000000000..1c472261e1a
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.class b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.class
new file mode 100644
index 00000000000..6d3c878e241
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/bin/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.class
Binary files differ
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/build.properties b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.properties b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.properties
new file mode 100644
index 00000000000..4760ab80448
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.papyrus.emf.commandstack
+providerName = Eclipse Modeling Project
+pluginName = A View for editpolicies
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.xml b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.xml
new file mode 100644
index 00000000000..0a3c6ca0f35
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.papyrus.views.category"
+ class="org.eclipse.papyrus.gmf.editpartview.view.EditPartHierarchyView"
+ id="org.eclipse.papyrus.gmf.editpartview.view"
+ name="Edit part hierarchy view"
+ restorable="true">
+ </view>
+ </extension>
+</plugin>
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/Activator.java b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/Activator.java
new file mode 100644
index 00000000000..e233cd78d69
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/Activator.java
@@ -0,0 +1,52 @@
+package org.eclipse.papyrus.gmf.editpartview;
+
+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.gmf.editpartview"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ 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)
+ */
+ 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;
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.java b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.java
new file mode 100644
index 00000000000..e734e07f4cd
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartHierarchyView.java
@@ -0,0 +1,231 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
+ * Based on edit policy view from patrick.tessier@cea.fr
+ */
+package org.eclipse.papyrus.gmf.editpartview.view;
+
+import java.util.ArrayList;
+
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * This view shows the edit-part hierarchy when an edit part is selected
+ */
+public class EditPartHierarchyView extends ViewPart {
+
+ /**
+ * this a object that represents a line into the table
+ */
+ class EditPolicyDescriptor {
+
+ public String role = "NO ROLE";
+
+ public EditPolicy policy = null;
+ }
+
+
+ private ArrayList<EditPolicyDescriptor> editPolicyList = new ArrayList<EditPolicyDescriptor>();
+
+ private ISelectionListener myEditPartlistener;
+
+ private TreeViewer viewer;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ public void setFocus() {
+ Viewer viewer = getViewer();
+ if(viewer != null && !viewer.getControl().isDisposed()) {
+
+ viewer.getControl().setFocus();
+ }
+ }
+
+ /**
+ * Create the main tree control
+ *
+ * @param parent
+ * @return Tree
+ */
+ protected Tree createTree(Composite parent) {
+ Tree tree = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
+ | SWT.FULL_SELECTION);
+ tree.setLinesVisible(true);
+ return tree;
+ }
+
+ /**
+ * Return the viewer.
+ *
+ * @return TreeViewer
+ */
+ protected TreeViewer getViewer() {
+ return viewer;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public EditPartHierarchyView() {
+ myEditPartlistener = new ISelectionListener() {
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
+ if(selection instanceof IStructuredSelection) {
+ Object selectedobject = ((IStructuredSelection)selection).getFirstElement();
+ if(selectedobject instanceof GraphicalEditPart) {
+ GraphicalEditPart graphicalEP = ((GraphicalEditPart)selectedobject);
+
+ if(viewer != null) {
+ viewer.setInput(new Object[]{ graphicalEP });
+ viewer.expandAll();
+ }
+ }
+ }
+ }
+ };
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ selectionService.addSelectionListener(myEditPartlistener);
+
+ }
+
+ protected void createColumns() {
+ viewer.getTree().setHeaderVisible(true);
+ viewer.getTree().setLinesVisible(true);
+
+ TreeColumn tcName = new TreeColumn(viewer.getTree(), SWT.LEFT);
+ tcName.setText("EditPart");
+ tcName.setWidth(150);
+ TreeColumn tcModelElement = new TreeColumn(viewer.getTree(), SWT.LEFT);
+ tcModelElement.setText("Model element");
+ tcModelElement.setWidth(150);
+ TreeColumn tcFigure = new TreeColumn(viewer.getTree(), SWT.LEFT);
+ tcFigure.setText("Figure");
+ tcFigure.setWidth(150);
+ TreeColumn tcFigBounds = new TreeColumn(viewer.getTree(), SWT.LEFT);
+ tcFigBounds.setText("Figure bounds");
+ tcFigBounds.setWidth(150);
+ }
+
+ @Override
+ public void createPartControl(final org.eclipse.swt.widgets.Composite parent) {
+ final IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
+ tbm.add(getClearViewAction());
+ viewer = new TreeViewer(createTree(parent));
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ createColumns();
+
+ }
+
+ protected ITableLabelProvider getLabelProvider() {
+ return new EditPartLabelProvider();
+ }
+
+ protected Action getClearViewAction() {
+ return new Action() {
+
+ @Override
+ public void run() {
+ clear();
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public String getToolTipText() {
+ return getText();
+ }
+
+ @Override
+ public String getText() {
+ return "Clear the view";
+ }
+
+ };
+ }
+
+
+ protected IContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+
+ public Object[] getElements(final Object inputElement) {
+ if(inputElement instanceof Object[]) {
+ return (Object[])inputElement;
+ }
+ return null;
+ }
+
+ public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
+ // nothing
+ }
+
+ public void dispose() {
+ // nothing
+ }
+
+ public boolean hasChildren(final Object element) {
+
+ return getChildren(element).length != 0;
+ }
+
+ public Object getParent(final Object element) {
+ return null;
+ }
+
+ public Object[] getChildren(final Object parentElement) {
+ if(parentElement instanceof GraphicalEditPart) {
+ return ((GraphicalEditPart)parentElement).getChildren().toArray();
+ }
+ return new Object[0];
+ }
+ };
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ selectionService.removeSelectionListener(myEditPartlistener);
+ clear();
+ }
+
+ private void clear() {
+ this.editPolicyList.clear();
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.java b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.java
new file mode 100644
index 00000000000..217cb1513c3
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmf.editpartview/src/org/eclipse/papyrus/gmf/editpartview/view/EditPartLabelProvider.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
+ * Based on edit policy view from patrick.tessier@cea.fr
+ */
+package org.eclipse.papyrus.gmf.editpartview.view;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.NamedElement;
+
+
+/**
+ * This is the label provider to display edit parts
+ *
+ */
+public class EditPartLabelProvider implements ITableLabelProvider, ITableColorProvider {
+
+ protected Color papyrusColor = new Color(Display.getDefault(), 0, 127, 14);
+
+ protected Color customizableDropEditPolicyColor = new Color(Display.getDefault(), 0, 38, 255);
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void dispose() {
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if(element instanceof GraphicalEditPart) {
+ GraphicalEditPart editPart = (GraphicalEditPart)element;
+ IFigure figure = editPart.getContentPane();
+ Object model = editPart.getAdapter(EObject.class);
+ switch(columnIndex) {
+ case 0:
+ return editPart.getClass().getSimpleName();
+ case 1:
+ if(model instanceof NamedElement) {
+ return ((NamedElement)model).getName();
+ }
+ return "not a named element";
+ case 2:
+ return figure.getClass().getSimpleName();
+ case 3:
+ return figure.getBounds().toString();
+ }
+ }
+ return "cannot display it: " + element;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Color getBackground(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+};

Back to the top