Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java25
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOrientedLabelProvider.java124
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java11
4 files changed, 26 insertions, 138 deletions
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
index 5438af5fce8..8bd9ca901a4 100644
--- 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
@@ -8,7 +8,9 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0"
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.0"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.outline,
org.eclipse.papyrus.infra.gmfdiag.outline.internal;x-internal:=true,
org.eclipse.papyrus.infra.gmfdiag.outline.overview
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java
index 7a4248cb36b..437e8de24d1 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java
@@ -24,7 +24,6 @@ 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;
@@ -32,7 +31,11 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.papyrus.commands.ICreationCommandRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.gmfdiag.outline.internal.Activator;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -60,6 +63,8 @@ public class DiagramNavigator extends Composite {
*/
ICreationCommandRegistry creationCommandRegistry;
+ private final ServicesRegistry registry;
+
/**
* This content provider filters the event from graphical object to only refresh when it's
* needed.
@@ -109,8 +114,9 @@ public class DiagramNavigator extends Composite {
* @param pageSite
* the site
*/
- public DiagramNavigator(Composite parent, IPageSite pageSite) {
+ public DiagramNavigator(Composite parent, IPageSite pageSite, ServicesRegistry registry) {
super(parent, SWT.BORDER);
+ this.registry = registry;
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
@@ -149,15 +155,16 @@ public class DiagramNavigator extends Composite {
* Set the tree providers for the outline
*/
protected void initProviders() {
- AdapterFactoryContentProvider adapterContentProvider = new NavigatorAdapterFactoryContentProvider(
- getAdapterFactory());
+ 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);
+ try {
+ ILabelProvider labelProvider = ServiceUtils.getInstance().getService(LabelProviderService.class, registry).getLabelProvider();
+ ILabelProvider fullLabelProvider = new DecoratingLabelProvider(labelProvider, Activator.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator());
+ viewer.setLabelProvider(fullLabelProvider);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
}
/**
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOrientedLabelProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOrientedLabelProvider.java
deleted file mode 100644
index 28a25a4433f..00000000000
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOrientedLabelProvider.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/***********************************************************************
- * 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.infra.gmfdiag.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.infra.core.editorsfactory.IPageIconsRegistry;
-import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.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/infra/gmfdiag/outline/DiagramOutline.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java
index 1519fff317b..ef0c70d9bb0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java
@@ -222,7 +222,7 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
}
private DiagramNavigator createNavigator(Composite parent, IPageSite pageSite) {
- return new DiagramNavigator(parent, pageSite);
+ return new DiagramNavigator(parent, pageSite, multiEditor.getServicesRegistry());
}
@Override
@@ -281,7 +281,11 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
refreshSelection();
// Refresh outline contents content with the new selection
- refresh();
+ try {
+ refresh(); //When outline breaks, the selectionChangeEvent is borken too. It may prevent the others views from receiving it...
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ }
}
/**
@@ -290,7 +294,7 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
private void refreshSelection() {
if(multiEditor.getActiveEditor() != null) {
- GraphicalViewer viewer = (GraphicalViewer)multiEditor.getActiveEditor().getAdapter(GraphicalViewer.class);
+ GraphicalViewer viewer = (GraphicalViewer)multiEditor.getAdapter(GraphicalViewer.class);
if(viewer == null) { // In case of an editor that is not GEF based.
root = null;
diagram = null;
@@ -324,7 +328,6 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
//FIXME: Sometimes, this method is called before #createControl(), which results in a NPE with sashComp
//Temporary fix : A non-null test has been added to avoid breaking the view
private void refresh() {
-
// Trash and re-Create Overview
if((overview != null) && !(overview.isDisposed())) {
overview.dispose();

Back to the top