Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-11-02 09:39:30 +0000
committercletavernie2011-11-02 09:39:30 +0000
commitb30ccd9faa91fb46165234860034f153122ea263 (patch)
tree13fc64345a9ce6a162afe043fec0682ca70ae2a0 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline
parentf371b929b8e4498a1a2794dbbbdc7bfeca62f21b (diff)
downloadorg.eclipse.papyrus-b30ccd9faa91fb46165234860034f153122ea263.tar.gz
org.eclipse.papyrus-b30ccd9faa91fb46165234860034f153122ea263.tar.xz
org.eclipse.papyrus-b30ccd9faa91fb46165234860034f153122ea263.zip
362162: [Architecture - Refactoring] The plug-ins should be renamed to match their layer's qualified name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362162
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.classpath7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.project28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/META-INF/MANIFEST.MF17
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/about.html28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/build.properties7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/all_co.gifbin0 -> 896 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/overview_co.gifbin0 -> 901 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/tree_co.gifbin0 -> 133 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.properties14
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.xml25
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramNavigator.java223
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedContentProvider.java108
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedLabelProvider.java124
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOutline.java395
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Activator.java85
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Messages.java35
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/messages.properties3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/overview/OverviewComposite.java130
19 files changed, 1236 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.classpath b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.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/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.project b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.project
new file mode 100644
index 00000000000..a96d0f5d7e8
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.outline</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/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f1afb54a431
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Fri Nov 07 11:53:20 CET 2008
+eclipse.preferences.version=1
+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/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..e0d801c0c5b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.papyrus.core;bundle-version="0.9.0",
+ org.eclipse.uml2.uml.editor;bundle-version="2.2.0",
+ org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="1.2.0"
+Export-Package: org.eclipse.papyrus.outline,
+ org.eclipse.papyrus.outline.internal;x-internal:=true,
+ org.eclipse.papyrus.outline.overview
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.outline.internal.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.outline;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/about.html b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/about.html
new file mode 100644
index 00000000000..5e091b3cb58
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/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>February 17, 2009</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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/build.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/build.properties
new file mode 100644
index 00000000000..355fd4a174d
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:30:00 CEST 2011
+bin.includes=META-INF/,.,plugin.xml,plugin.properties,icons/,about.html
+output..=bin/
+src.includes=META-INF/,.,plugin.xml,plugin.properties,icons/,about.html
+source..=src/
+bin..=bin/
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/all_co.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/all_co.gif
new file mode 100644
index 00000000000..327ea888764
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/all_co.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/overview_co.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/overview_co.gif
new file mode 100644
index 00000000000..8173b81a322
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/overview_co.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/tree_co.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/tree_co.gif
new file mode 100644
index 00000000000..852dc81ba6a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/icons/elcl16/tree_co.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.properties
new file mode 100644
index 00000000000..390ec30cd06
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.properties
@@ -0,0 +1,14 @@
+########################################################################################
+#
+# Copyright (c) 2009 Obeo.
+# 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:
+# Obeo - initial API and implementation
+########################################################################################
+pluginName=Papyrus Outline (Incubation)
+providerName=Eclipse Modeling Project
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.xml
new file mode 100644
index 00000000000..b08115a9c8e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/plugin.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<!--
+########################################################################################
+#
+# Copyright (c) 2009 Obeo.
+# 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:
+# Obeo - initial API and implementation
+########################################################################################
+-->
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.core.papyrusContentOutline">
+ <contentoutline
+ class="org.eclipse.papyrus.outline.DiagramOutline"
+ priority="2">
+ </contentoutline>
+ </extension>
+
+</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramNavigator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramNavigator.java
new file mode 100644
index 00000000000..f925168edf2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramNavigator.java
@@ -0,0 +1,223 @@
+/***********************************************************************
+ * Copyright (c) 2007, 2008, 2009 Anyware Technologies, Obeo.
+ *
+ * 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:
+ * Anyware Technologies - initial API and implementation
+ * Obeo
+ *
+ **********************************************************************/
+package org.eclipse.papyrus.outline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IViewerNotification;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.core.extension.commands.ICreationCommandRegistry;
+import org.eclipse.papyrus.outline.internal.Activator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+
+/**
+ * <b>Diagram navigator :</b><br>
+ * Display the content of the current diagram. <br>
+ *
+ * Updated : 18 feb. 2008
+ *
+ * @author <a href="mailto:david.sciamma@anyware-tech.com">David Sciamma</a>
+ * @author <a href="mailto:jacques.lescot@anyware-tech.com">Jacques LESCOT</a>
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ */
+public class DiagramNavigator extends Composite {
+
+ private TreeViewer viewer;
+
+ /**
+ * The creation command registry
+ */
+ ICreationCommandRegistry creationCommandRegistry;
+
+ /**
+ * This content provider filters the event from graphical object to only refresh when it's
+ * needed.
+ *
+ * @author <a href="david.sciamma@anyware-tech.com">David Sciamma</a>
+ */
+ protected class NavigatorAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
+
+ /**
+ * Constructor
+ *
+ * @param adapterFactory
+ * the factory
+ */
+ public NavigatorAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ if(notification instanceof IViewerNotification) {
+ Object element = ((IViewerNotification)notification).getElement();
+ if(!(element instanceof View)) {
+ // Filter only non-graphical object events
+ super.notifyChanged(notification);
+ } else if((element instanceof Diagram) && ((IViewerNotification)notification).isLabelUpdate()) {
+ // A diagram or a Diagrams is added or removed : refresh the
+ // whole tree
+ refreshViewer(true);
+ }
+ } else {
+ super.notifyChanged(notification);
+ }
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param parent
+ * the parent composite
+ * @param diagEditor
+ * the viewer to edit as tree
+ * @param pageSite
+ * the site
+ */
+ public DiagramNavigator(Composite parent, IPageSite pageSite) {
+ super(parent, SWT.BORDER);
+ GridLayout gl = new GridLayout();
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ setLayout(gl);
+ createContents(this);
+ }
+
+ /**
+ * Returns the TreeViewer used as navigator
+ *
+ * @return the navigable tree
+ */
+ public TreeViewer getTreeViewer() {
+ return viewer;
+ }
+
+ public void setSelection(ISelection selection) {
+ getTreeViewer().setSelection(selection, true);
+ }
+
+ /**
+ * Create the contents of the widget
+ *
+ * @param parent
+ * the current widget
+ */
+ protected void createContents(Composite parent) {
+ this.viewer = new TreeViewer(parent, SWT.MULTI);
+ this.viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ initProviders();
+ refreshViewer();
+ }
+
+ /**
+ * Set the tree providers for the outline
+ */
+ protected void initProviders() {
+ AdapterFactoryContentProvider adapterContentProvider = new NavigatorAdapterFactoryContentProvider(
+ getAdapterFactory());
+ adapterContentProvider.inputChanged(viewer, null, null);
+ viewer.setContentProvider(new DiagramOrientedContentProvider(adapterContentProvider));
+ ILabelProvider labelProvider = new DiagramOrientedLabelProvider(new AdapterFactoryLabelProvider(
+ getAdapterFactory()));
+ ILabelProvider fullLabelProvider = new DecoratingLabelProvider(labelProvider, Activator.getDefault()
+ .getWorkbench().getDecoratorManager().getLabelDecorator());
+ viewer.setLabelProvider(fullLabelProvider);
+ }
+
+ /**
+ * Refresh the tree viewer in the UI thread if we are in a different thread
+ */
+ protected final void refreshViewer() {
+ refreshViewer(false);
+ }
+
+ /**
+ * Refresh the tree viewer in the UI thread if we are in a different thread
+ *
+ * @param updateLabel
+ * <code>true</code> if the label must be refreshed
+ */
+ protected final void refreshViewer(final boolean updateLabel) {
+ if((viewer != null) && !viewer.getTree().isDisposed()) {
+ if(Display.getCurrent() != Display.getDefault()) {
+ syncRefreshViewer(updateLabel);
+ } else {
+ viewer.refresh(updateLabel);
+ }
+ }
+ }
+
+ /**
+ * Refresh the tree viewer in the UI thread
+ *
+ * @param updateLabel
+ * <code>true</code> if the label must be refreshed
+ */
+ private void syncRefreshViewer(final boolean updateLabel) {
+ viewer.getControl().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ viewer.refresh(updateLabel);
+ }
+ });
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Widget#dispose()
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ /**
+ * Get the AdapterFactory associated with an editor
+ *
+ * @return AdapterFactory
+ */
+ protected AdapterFactory getAdapterFactory() {
+ List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
+ factories.add(new UMLItemProviderAdapterFactory());
+ factories.add(new EcoreItemProviderAdapterFactory());
+ factories.add(new ResourceItemProviderAdapterFactory());
+ factories.add(new ReflectiveItemProviderAdapterFactory());
+ return new ComposedAdapterFactory(factories);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedContentProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedContentProvider.java
new file mode 100644
index 00000000000..99046b156e4
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedContentProvider.java
@@ -0,0 +1,108 @@
+/***********************************************************************
+ * Copyright (c) 2008, 2009 Anyware Technologies, Obeo
+ *
+ * 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:
+ * Jacques Lescot (Anyware Technologies) - initial API and implementation
+ * Obeo
+ *
+ **********************************************************************/
+package org.eclipse.papyrus.outline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Provide the content of the given diagram.
+ *
+ * @author <a href="mailto:david.sciamma@anyware-tech.com">David Sciamma</a>
+ * @author <a href="mailto:jacques.lescot@anyware-tech.com">Jacques Lescot</a>
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ */
+public class DiagramOrientedContentProvider implements ITreeContentProvider {
+
+ private AdapterFactoryContentProvider myAdapterFactoryContentProvider;
+
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+
+ private Diagram diagram;
+
+ public DiagramOrientedContentProvider(AdapterFactoryContentProvider adapterContentProvider) {
+ this.myAdapterFactoryContentProvider = adapterContentProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ // Dispose objects
+ myAdapterFactoryContentProvider.dispose();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ myAdapterFactoryContentProvider.inputChanged(viewer, oldInput, newInput);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof Diagram) {
+ this.diagram = (Diagram)inputElement;
+ List<Object> children = new ArrayList<Object>();
+ for(Object object : diagram.getChildren()) {
+ if(object instanceof View) {
+ View view = (View)object;
+ EObject modelElement = ViewUtil.resolveSemanticElement(view);
+ if (modelElement != null)
+ {
+ children.add(modelElement);
+ }
+ }
+ }
+ return children.toArray();
+ }
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getChildren(Object parentElement) {
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getParent(Object element) {
+ // The parent of a diagram is the model object that contains it.
+ if(element instanceof Diagram) {
+ return ((Diagram)element).getElement();
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedLabelProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedLabelProvider.java
new file mode 100644
index 00000000000..3c8e15b5519
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOrientedLabelProvider.java
@@ -0,0 +1,124 @@
+/***********************************************************************
+ * Copyright (c) 2008, 2009 Anyware Technologies, Obeo
+ *
+ * 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:
+ * David Sciamma (Anyware Technologies) - initial API and implementation
+ *
+ **********************************************************************/
+package org.eclipse.papyrus.outline;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.papyrus.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.papyrus.core.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Compute the label of the elements contained by the current diagram.
+ *
+ * @author <a href="mailto:david.sciamma@anyware-tech.com">David Sciamma</a>
+ * @author <a href="mailto:jacques.lescot@anyware-tech.com">Jacques Lescot</a>
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ */
+public class DiagramOrientedLabelProvider implements ILabelProvider {
+
+ private AdapterFactoryLabelProvider myAdapterFactoryLabelProvider;
+
+ /** Registry to store editor factories */
+ private IPageIconsRegistry editorRegistry;
+
+ public DiagramOrientedLabelProvider(AdapterFactoryLabelProvider adapterFactoryLabelProvider) {
+ this.myAdapterFactoryLabelProvider = adapterFactoryLabelProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Image getImage(Object element) {
+ if(element instanceof Diagram) {
+ return getEditorRegistry().getEditorIcon(element);
+ }
+
+ return myAdapterFactoryLabelProvider.getImage(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getText(Object element) {
+ if(element instanceof Diagram) {
+ Diagram diagram = (Diagram)element;
+ return myAdapterFactoryLabelProvider.getText(diagram.getElement());
+ }
+
+ return myAdapterFactoryLabelProvider.getText(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addListener(ILabelProviderListener listener) {
+ myAdapterFactoryLabelProvider.addListener(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ myAdapterFactoryLabelProvider.dispose();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ return myAdapterFactoryLabelProvider.isLabelProperty(element, property);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ myAdapterFactoryLabelProvider.removeListener(listener);
+ }
+
+ /**
+ * Get the EditorRegistry used to create editor instances. This default implementation return
+ * the singleton eINSTANCE. This method can be subclassed to return another registry.
+ *
+ * @return the singleton eINSTANCE of editor registry
+ * @throws ServiceException
+ */
+ protected IPageIconsRegistry getEditorRegistry() {
+ if(editorRegistry == null) {
+ editorRegistry = createEditorRegistry();
+ }
+ return editorRegistry;
+ }
+
+ /**
+ * Return the EditorRegistry for nested editor descriptors. Subclass should implements this
+ * method in order to return the registry associated to the extension point namespace.
+ *
+ * @return the EditorRegistry for nested editor descriptors
+ * @throws ServiceException
+ */
+ protected IPageIconsRegistry createEditorRegistry() {
+ try {
+ return EditorUtils.getServiceRegistry().getService(IPageIconsRegistry.class);
+ } catch (ServiceException e) {
+ // Not found, return an empty one which return null for each request.
+ return new PageIconsRegistry();
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOutline.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOutline.java
new file mode 100644
index 00000000000..879a6ff6c1b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/DiagramOutline.java
@@ -0,0 +1,395 @@
+/***********************************************************************
+ * Copyright (c) 2008, 2009 Anyware Technologies, Obeo, 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:
+ * Anyware Technologies - initial API and implementation
+ * Obeo
+ * CEA LIST - synchronization between selection and outline content
+ *
+ **********************************************************************/
+package org.eclipse.papyrus.outline;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.RootEditPart;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.render.editparts.RenderedDiagramRootEditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.papyrus.core.contentoutline.IPapyrusContentOutlinePage;
+import org.eclipse.papyrus.core.editor.BackboneException;
+import org.eclipse.papyrus.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.outline.internal.Activator;
+import org.eclipse.papyrus.outline.internal.Messages;
+import org.eclipse.papyrus.outline.overview.OverviewComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * An outline in order to navigate in current diagram.
+ *
+ * @author <a href="mailto:david.sciamma@anyware-tech.com">David Sciamma</a>
+ * @author <a href="mailto:jacques.lescot@anyware-tech.com">Jacques Lescot</a>
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ * @author <a href="mailto:yann.tanguy@cea.fr">Yann Tanguy</a>
+ */
+public class DiagramOutline extends Page implements IPapyrusContentOutlinePage, ISelectionListener {
+
+ protected EditingDomain editingDomain;
+
+ private IMultiDiagramEditor multiEditor;
+
+ private SashForm sashComp;
+
+ private DiagramNavigator navigator;
+
+ /** Current selection */
+ private RenderedDiagramRootEditPart root = null;
+
+ private Diagram diagram = null;
+
+ /** Outline mode */
+ public final static int SHOW_TREE = 1;
+
+ public final static int SHOW_OVERVIEW = 2;
+
+ public final static int SHOW_BOTH = 0;
+
+ private Composite overview;
+
+ /** Actions */
+ private IAction showTreeAction;
+
+ private IAction showOverviewAction;
+
+ private IAction showAllAction;
+
+ public DiagramOutline() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init(IMultiDiagramEditor multiEditor) throws BackboneException {
+
+ // Get TransactionalEditingDomain
+ try {
+ this.editingDomain = multiEditor.getServicesRegistry().getService(TransactionalEditingDomain.class);
+ } catch (ServiceException e) {
+ throw new BackboneException("Can't get TransactionalEditingDomain", e);
+ }
+
+ // Set multieditor.
+ this.multiEditor = multiEditor;
+
+ // Add listener to detect selection change
+ multiEditor.getSite().getPage().addPostSelectionListener(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void createControl(Composite parent) {
+
+ // Create SashForm
+ sashComp = new SashForm(parent, SWT.VERTICAL);
+ sashComp.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // Update selection (diagram and root edit part in active EditorTile)
+ refreshSelection();
+
+ // Create Overview
+ if(root != null) {
+ overview = createOverview(sashComp, root);
+ overview.setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ // Create Navigator
+ navigator = createNavigator(sashComp, getSite());
+ if(diagram != null) {
+ navigator.getTreeViewer().setInput(diagram);
+ }
+
+ // Slip SashForm in two sections
+ if(overview != null) {
+ sashComp.setWeights(new int[]{ 30, 70 });
+ }
+
+ createActions();
+ }
+
+ /**
+ * Create the composite that shows an overview of the model
+ *
+ * @param parent
+ * the parent
+ * @param rootEditPart
+ * the root edit part
+ * @return the overview composite
+ */
+ protected Composite createOverview(Composite parent, ScalableFreeformRootEditPart rootEditPart) {
+ return new OverviewComposite(parent, rootEditPart);
+ }
+
+ /**
+ * Add the actions to the view toolbar
+ */
+ protected void createActions() {
+ IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
+ tbm.add(new Separator());
+ createShowOutlineActions(tbm);
+ }
+
+ /**
+ * Create the show outline actions in the given tool bar manager.
+ *
+ * @param tbm
+ * the outline tool bar manager
+ */
+ private void createShowOutlineActions(IToolBarManager tbm) {
+
+ // Show Tree action
+ showTreeAction = new Action(Messages.DiagramOutline_ShowNavigator, IAction.AS_RADIO_BUTTON) {
+
+ @Override
+ public void run() {
+ if(navigator != null && !navigator.isDisposed()) {
+ performShowAction();
+ }
+ }
+ };
+ showTreeAction.setToolTipText(showTreeAction.getText());
+ showTreeAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/elcl16/tree_co.gif")); //$NON-NLS-1$
+ tbm.add(showTreeAction);
+
+ // Show overview action
+ showOverviewAction = new Action(Messages.DiagramOutline_ShowOverview, IAction.AS_RADIO_BUTTON) {
+
+ @Override
+ public void run() {
+ if(overview != null && !overview.isDisposed()) {
+ performShowAction();
+ }
+ }
+ };
+ showOverviewAction.setToolTipText(showOverviewAction.getText());
+ showOverviewAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/elcl16/overview_co.gif")); //$NON-NLS-1$
+ tbm.add(showOverviewAction);
+
+ // Show All (Tree and Overview) action
+ showAllAction = new Action(Messages.DiagramOutline_ShowBoth, IAction.AS_RADIO_BUTTON) {
+
+ @Override
+ public void run() {
+ if(sashComp != null && !sashComp.isDisposed()) {
+ performShowAction();
+ }
+ }
+ };
+ showAllAction.setToolTipText(showAllAction.getText());
+ showAllAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/elcl16/all_co.gif")); //$NON-NLS-1$
+ tbm.add(showAllAction);
+
+ // Set overview as default choice
+ showOverviewAction.setChecked(true);
+ performShowAction();
+ }
+
+ private DiagramNavigator createNavigator(Composite parent, IPageSite pageSite) {
+ return new DiagramNavigator(parent, pageSite);
+ }
+
+ @Override
+ public Control getControl() {
+ return sashComp;
+ }
+
+ @Override
+ public void setFocus() {
+ getControl().setFocus();
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ if(navigator != null && !navigator.isDisposed()) {
+ navigator.getTreeViewer().addSelectionChangedListener(listener);
+ }
+ }
+
+ public ISelection getSelection() {
+ return navigator.getTreeViewer().getSelection();
+ }
+
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ if(navigator != null && !navigator.isDisposed()) {
+ navigator.getTreeViewer().removeSelectionChangedListener(listener);
+ }
+ }
+
+ public void setSelection(ISelection selection) {
+ navigator.getTreeViewer().setSelection(selection);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ // Navigator, overview... can be null
+ if(navigator != null) {
+ navigator.dispose();
+ }
+ if(overview != null) {
+ overview.dispose();
+ }
+
+ if(multiEditor != null) {
+ // Remove selection change listener
+ multiEditor.getSite().getPage().removePostSelectionListener(this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
+ // Update selection (diagram and root edit part in active EditorTile)
+ refreshSelection();
+
+ // Refresh outline contents content with the new selection
+ refresh();
+ }
+
+ /**
+ * Refresh the selected root edit part and diagram
+ */
+ private void refreshSelection() {
+
+ if(multiEditor.getActiveEditor() != null) {
+ GraphicalViewer viewer = (GraphicalViewer)multiEditor.getActiveEditor().getAdapter(GraphicalViewer.class);
+ if( viewer == null)
+ { // In case of an editor that is not GEF based.
+ root = null;
+ diagram = null;
+ return;
+ }
+
+ RootEditPart rootEditPart = viewer.getRootEditPart();
+
+ if(rootEditPart instanceof RenderedDiagramRootEditPart) {
+ root = (RenderedDiagramRootEditPart)rootEditPart;
+ if(rootEditPart.getContents() != null) {
+ diagram = (Diagram)rootEditPart.getContents().getModel();
+ } else {
+ diagram = null;
+ }
+
+ } else {
+ root = null;
+ diagram = null;
+ }
+
+ } else {
+ root = null;
+ diagram = null;
+ }
+ }
+
+ /**
+ * Refresh the outline view
+ */
+ private void refresh() {
+
+ // Trash and re-Create Overview
+ if((overview != null) && !(overview.isDisposed())) {
+ overview.dispose();
+ }
+
+ if(root != null) {
+ overview = createOverview(sashComp, root);
+ overview.setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ // Update navigator content
+ if(diagram != null) {
+ navigator.getTreeViewer().setInput(diagram);
+ }
+
+ // Slip SashForm in two sections
+ if((overview != null) && !(overview.isDisposed())) {
+ sashComp.setWeights(new int[]{ 30, 70 });
+ }
+
+ // Refresh outline without changing mode
+ performShowAction();
+ }
+
+ /**
+ * Show outline in selected mode
+ */
+ private void performShowAction() {
+
+ // Select the kind of outline to show content
+ Control control = null;
+ control = null;
+ switch(getShowActionMode()) {
+ case SHOW_TREE:
+ control = navigator;
+ break;
+ case SHOW_OVERVIEW:
+ control = overview;
+ break;
+ case SHOW_BOTH:
+ control = null;
+ break;
+ default:
+ control = overview;
+ }
+
+ // Update outline view
+ if(sashComp != null && !sashComp.isDisposed()) {
+ sashComp.setMaximizedControl(control);
+ }
+ }
+
+ /**
+ * Get current contents representation of the outline
+ *
+ * @return current Outline show mode
+ */
+ private int getShowActionMode() {
+ int showActionMode = -1;
+
+ if(showTreeAction.isChecked()) {
+ showActionMode = SHOW_TREE;
+ }
+ if(showOverviewAction.isChecked()) {
+ showActionMode = SHOW_OVERVIEW;
+ }
+ if(showAllAction.isChecked()) {
+ showActionMode = SHOW_BOTH;
+ }
+
+ return showActionMode;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Activator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Activator.java
new file mode 100644
index 00000000000..bc356cce566
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Activator.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.outline.internal;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.outline";
+
+ // 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;
+ }
+
+ /**
+ * get the image desciptor from a string path
+ *
+ * @param pathString
+ * path of the image
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String pathString) {
+
+ IPath path = new Path(pathString);
+ URL uri = FileLocator.find(Activator.plugin.getBundle(), path, null);
+ if(uri == null)
+ return null;
+ return ImageDescriptor.createFromURL(uri);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Messages.java
new file mode 100644
index 00000000000..3215b997a1e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/Messages.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.outline.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ */
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.outline.internal.messages"; //$NON-NLS-1$
+
+ public static String DiagramOutline_ShowNavigator;
+
+ public static String DiagramOutline_ShowOverview;
+
+ public static String DiagramOutline_ShowBoth;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/messages.properties
new file mode 100644
index 00000000000..32feda231df
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/internal/messages.properties
@@ -0,0 +1,3 @@
+DiagramOutline_ShowNavigator=Show Navigator
+DiagramOutline_ShowOverview=Show Overview
+DiagramOutline_ShowBoth=Show Both \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/overview/OverviewComposite.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/overview/OverviewComposite.java
new file mode 100644
index 00000000000..a23a3699a89
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/outline/overview/OverviewComposite.java
@@ -0,0 +1,130 @@
+/***********************************************************************
+ * Copyright (c) 2007, 2008, 2009 Anyware Technologies, Obeo
+ *
+ * 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:
+ * Anyware Technologies - initial API and implementation
+ * Obeo
+ *
+ **********************************************************************/
+package org.eclipse.papyrus.outline.overview;
+
+import org.eclipse.draw2d.LightweightSystem;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.parts.ScrollableThumbnail;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * This class is an outline control showing an overview of a graphical editor. <br>
+ *
+ * @author <a href="mailto:david.sciamma@anyware-tech.com">David Sciamma </a>
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ */
+public class OverviewComposite extends Composite {
+
+ /** the control of the overview */
+ private Canvas overview;
+
+ /** the root edit part */
+ private ScalableFreeformRootEditPart rootEditPart;
+
+ /** the thumbnail */
+ private ScrollableThumbnail thumbnail;
+
+ /**
+ * Creates a new OverviewOutlinePage instance.
+ *
+ * @param parent
+ * the parent composite
+ * @param rootEditPart
+ * the root edit part
+ */
+ public OverviewComposite(Composite parent, ScalableFreeformRootEditPart rootEditPart) {
+ super(parent, SWT.BORDER);
+ this.rootEditPart = rootEditPart;
+
+ GridLayout layout = new GridLayout();
+ layout.horizontalSpacing = 0;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ setLayout(layout);
+ setLayoutData(new GridData(GridData.FILL_BOTH));
+ createControl(this);
+ }
+
+ /**
+ * Creates the inner controls
+ *
+ * @param parent
+ * the parent composite
+ */
+ public void createControl(Composite parent) {
+ // An swt canvas and lws drawing the figure.
+ overview = new Canvas(parent, SWT.NONE);
+ overview.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // A draw2d object linking swt and draw2d
+ LightweightSystem lightweightSystem = new LightweightSystem(overview);
+
+ // create the thumbnail
+ thumbnail = new ScrollableThumbnail((Viewport)rootEditPart.getFigure());
+ thumbnail.setBorder(new MarginBorder(3));
+ thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS/* SCALABLE_LAYERS */));
+ lightweightSystem.setContents(thumbnail);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(null != thumbnail) {
+ thumbnail.deactivate();
+ thumbnail = null;
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setVisible(boolean state) {
+ thumbnail.setVisible(state);
+ super.setVisible(state);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return the main control
+ */
+ public Control getControl() {
+ return overview;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return <code>true</code> if the focus succeed
+ */
+ public boolean setFocus() {
+ if(getControl() != null) {
+ return getControl().setFocus();
+ }
+ return false;
+ }
+
+}

Back to the top