Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-10-26 12:21:46 +0000
committercletavernie2012-10-26 12:21:46 +0000
commit1d496ba56efd3786e74e38482c1f2867a299d461 (patch)
treece48ba0e7c692245163ab91abf3c1e5d45e7d6ce /plugins
parent4b5547218d558df2971afbe788818adc9d98de48 (diff)
downloadorg.eclipse.papyrus-1d496ba56efd3786e74e38482c1f2867a299d461.tar.gz
org.eclipse.papyrus-1d496ba56efd3786e74e38482c1f2867a299d461.tar.xz
org.eclipse.papyrus-1d496ba56efd3786e74e38482c1f2867a299d461.zip
392438: [Core Services] Papyrus should provide a LabelProvider service
https://bugs.eclipse.org/bugs/show_bug.cgi?id=392438 Missing files from the previous commit
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/file.gifbin0 -> 577 bytes
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/hyperlink.gifbin0 -> 596 bytes
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/plugin.xml7
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java71
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java37
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java16
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java102
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorNavigationDialog.java35
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java21
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkFilteredLabelProvider.java25
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkLabelProvider.java114
12 files changed, 185 insertions, 246 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF
index 3b5e3264d9f..232fd92ac35 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF
@@ -10,9 +10,8 @@ Require-Bundle: org.eclipse.emf.transaction,
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0",
- org.eclipse.papyrus.views.modelexplorer;bundle-version="0.10.0",
org.eclipse.ui.navigator;bundle-version="3.5.200",
- org.eclipse.papyrus.infra.table.instance;bundle-version="0.10.0"
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0"
Export-Package: org.eclipse.papyrus.infra.hyperlink,
org.eclipse.papyrus.infra.hyperlink.commands,
org.eclipse.papyrus.infra.hyperlink.helper,
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/file.gif b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/file.gif
new file mode 100644
index 00000000000..ef302880717
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/file.gif
Binary files differ
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/hyperlink.gif b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/hyperlink.gif
new file mode 100644
index 00000000000..1e09d979520
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/icons/hyperlink.gif
Binary files differ
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/plugin.xml
index 651c3298570..dfadcf345a2 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/plugin.xml
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/plugin.xml
@@ -30,5 +30,12 @@
tab="org.eclipse.papyrus.infra.hyperlink.ui.DefaultHyperLinkTab">
</hyperlinktab>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
+ <labelProvider
+ priority="40"
+ provider="org.eclipse.papyrus.infra.hyperlink.util.HyperLinkFilteredLabelProvider">
+ </labelProvider>
+ </extension>
</plugin>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java
index 3b5f134d1cc..637cd502085 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java
@@ -18,56 +18,16 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistryExtended;
-import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
-import org.eclipse.papyrus.infra.hyperlink.internal.IEditorLabelProvider;
import org.eclipse.papyrus.infra.hyperlink.ui.EditorHyperLinkEditorShell;
-public abstract class HyperLinkEditor extends HyperLinkObject implements IEditorLabelProvider{
- /**
- * the icon registry
- */
- private static IPageIconsRegistry editorRegistry;
-
- /**
- * 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
- */
- protected IPageIconsRegistryExtended getEditorRegistry() {
- if(editorRegistry == null) {
- editorRegistry = createEditorRegistry();
- }
- if(!(editorRegistry instanceof IPageIconsRegistryExtended)) {
- throw new RuntimeException("The editor registry do not implement IPageIconsRegistryExtended");////$NON-NLS-1$
- }
- return (IPageIconsRegistryExtended)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
- * FIXME : use a deprecated method
- */
- 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();
- }
- }
+public class HyperLinkEditor extends HyperLinkObject {
/**
*
@@ -76,27 +36,30 @@ public abstract class HyperLinkEditor extends HyperLinkObject implements IEditor
*/
@Override
public void executeSelectPressed() {
- IPageMngr pageMngr = EditorUtils.getIPageMngr();
- try {
- pageMngr.openPage(getObject());
- } catch (Exception e) {
- Activator.log.error(e);
+ EObject context = EMFHelper.getEObject(getObject());
+ if(context != null) {
+ try {
+ IPageMngr pageMngr = ServiceUtilsForEObject.getInstance().getIPageMngr(context);
+ pageMngr.openPage(getObject());
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ }
}
}
-
+
/**
*
* @see org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject#executeEditMousePressed(java.util.List, org.eclipse.emf.ecore.EObject)
- *
+ *
* @param list
* @param amodel
*/
@Override
public void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel) {
- IPageIconsRegistry editorRegistry=null;
- IMultiDiagramEditor papyrusEditor=EditorUtils.getMultiDiagramEditor();
+ IPageIconsRegistry editorRegistry = null;
+ IMultiDiagramEditor papyrusEditor = EditorUtils.getMultiDiagramEditor();
try {
- editorRegistry= papyrusEditor.getServicesRegistry().getService(IPageIconsRegistry.class);
+ editorRegistry = papyrusEditor.getServicesRegistry().getService(IPageIconsRegistry.class);
} catch (ServiceException e) {
Activator.log.error(e);
}
@@ -106,7 +69,7 @@ public abstract class HyperLinkEditor extends HyperLinkObject implements IEditor
if(editor.getHyperLinkEditor() != null) {
int index = list.indexOf(this);
list.remove(this);
- list.add(index,editor.getHyperLinkEditor());
+ list.add(index, editor.getHyperLinkEditor());
}
}
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java
index 166f0905a33..11b9b49b0b5 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java
@@ -18,17 +18,19 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkContentProvider;
-import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
@@ -275,29 +277,32 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
defaultHleft.setImage(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.papyrus.uml.diagram.common", "/icons/obj16/ArrowLeft_16x16.gif").createImage()); //$NON-NLS-1$ //$NON-NLS-2$
defaultHRight.setImage(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.papyrus.uml.diagram.common", "/icons/obj16/ArrowRight_16x16.gif").createImage()); //$NON-NLS-1$ //$NON-NLS-2$
+ EObject contextElement = EMFHelper.getEObject(element);
+ ILabelProvider provider = null;
+ if(contextElement != null) {
+ try {
+ provider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, contextElement).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+ }
- IPageIconsRegistry editorRegistry = null;
- IMultiDiagramEditor papyrusEditor = EditorUtils.getMultiDiagramEditor();
- try {
- editorRegistry = papyrusEditor.getServicesRegistry().getService(IPageIconsRegistry.class);
- } catch (ServiceException e) {
- e.printStackTrace();
+ if(provider == null) {
+ provider = new LabelProvider();
}
+
+
//init tableviewer
availableHyperLinkViewer = new TableViewer(availableHyperLink);
- availableHyperLinkViewer.setLabelProvider(new HyperLinkLabelProvider(editorRegistry));
+ availableHyperLinkViewer.setLabelProvider(provider);
availableHyperLinkViewer.setContentProvider(new HyperLinkContentProvider());
availableHyperLinkViewer.setInput(hyperlinkObjects);
defaultHyperLinkViewer = new TableViewer(defaultHyperLink);
- defaultHyperLinkViewer.setLabelProvider(new HyperLinkLabelProvider(editorRegistry));
+ defaultHyperLinkViewer.setLabelProvider(provider);
defaultHyperLinkViewer.setContentProvider(new HyperLinkContentProvider());
-
-
-
-
}
/**
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java
index b5177d6335c..a5dd2ebf566 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java
@@ -15,13 +15,17 @@ package org.eclipse.papyrus.infra.hyperlink.ui;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.helper.EditorHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
-import org.eclipse.papyrus.views.modelexplorer.DecoratingLabelProviderWTooltips;
-import org.eclipse.papyrus.views.modelexplorer.MoDiscoLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Display;
@@ -124,7 +128,13 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
hyperLinkEditor.setObject(selection);
//TODO : remove this dependency
- DecoratingLabelProviderWTooltips labelProvider = new DecoratingLabelProviderWTooltips(new MoDiscoLabelProvider());
+ ILabelProvider labelProvider;
+ try {
+ labelProvider = ServiceUtilsForEObject.getInstance().getServiceRegistry(amodel).getService(LabelProviderService.class).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ labelProvider = new LabelProvider();
+ }
getObjectLabeltext().setText(labelProvider.getText(selection));
if(usedefaultTooltip) {
getTooltipInputText().setText(getObjectLabeltext().getText());
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
index e8993729538..e95ea10fb97 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
@@ -22,16 +22,14 @@ import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.papyrus.commands.CreationCommandDescriptor;
import org.eclipse.papyrus.commands.CreationCommandRegistry;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.commands.ICreationCommandRegistry;
-import org.eclipse.papyrus.infra.core.editor.BackboneException;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistryExtended;
-import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry;
import org.eclipse.papyrus.infra.core.extension.NotFoundException;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
@@ -40,18 +38,17 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkEditorHelper;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
import org.eclipse.papyrus.infra.hyperlink.util.EditorListContentProvider;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkEditorHelpersRegistrationUtil;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.views.modelexplorer.DecoratingLabelProviderWTooltips;
-import org.eclipse.papyrus.views.modelexplorer.MoDiscoLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
@@ -134,8 +131,7 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
EObject elt = (EObject)((IStructuredSelection)treeViewer.getSelection()).getFirstElement();
setContainer(elt);
- ServicesRegistry servicesRegistry = EditorUtils.getServiceRegistry();
- ModelSet modelSet = servicesRegistry.getService(ModelSet.class);
+ ModelSet modelSet = ServiceUtilsForEObject.getInstance().getModelSet(elt);
ICreationCommand creationCommand = iCreationCommandRegistry.getCommand(commandDescriptor.getCommandId());
creationCommand.createDiagram(modelSet, container, null);
@@ -146,11 +142,9 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
getModeFilteredTree().getViewer().setInput(null);
getModeFilteredTree().getViewer().setInput(model.eResource());
} catch (NotFoundException ex) {
- ex.printStackTrace();
- } catch (BackboneException ex) {
- ex.printStackTrace();
+ Activator.log.error(ex);
} catch (ServiceException ex) {
- ex.printStackTrace();
+ Activator.log.error(ex);
}
}
@@ -219,13 +213,24 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
//// return null;
// }
// });
- ILabelProvider labelProvider = new LocalLabelProvider();
+
+ ILabelProvider labelProvider;
+ ServicesRegistry registry = null;
+
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(model);
+ labelProvider = registry.getService(LabelProviderService.class).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ labelProvider = new LabelProvider();
+ }
+
treeViewer.setLabelProvider(labelProvider);
//treeViewer.setContentProvider(new CustomAdapterFactoryContentProvider(adapterFactory));
treeViewer.setContentProvider(new SemanticEMFContentProvider(new EObject[]{ amodel }));
// treeViewer.setContentProvider(new CustomizableModelContentProvider());
//treeViewer.setInput(model.eResource());
- treeViewer.setInput(EditorUtils.getServiceRegistry());
+ treeViewer.setInput(registry);
// install diagramlist
diagramListTreeViewer = getDiagramfilteredTree().getViewer();
@@ -236,7 +241,6 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
//diagramListTreeViewer.setLabelProvider(new ObjectLabelProvider(null));
//we can't reuse the same instance of the label provider see bug 385599: [Hyperlink] We can't select the diagram/table for referencing them
- labelProvider = new LocalLabelProvider();
diagramListTreeViewer.setLabelProvider(labelProvider);
@@ -368,70 +372,4 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
return false;
}
- //TODO Refactoring delete this class to remove the PapyrusTable dependencies!
- private class LocalLabelProvider extends DecoratingLabelProviderWTooltips {
-
- public LocalLabelProvider() {
- super(new MoDiscoLabelProvider());
- }
-
- /**
- * 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
- * FIXME : use a deprecated method
- */
- 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();
- }
- }
-
- /**
- * the icon registry
- */
- private IPageIconsRegistry editorRegistry;
-
- /**
- * 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
- */
- protected IPageIconsRegistryExtended getEditorRegistry() {
- if(editorRegistry == null) {
- editorRegistry = createEditorRegistry();
- }
- if(!(editorRegistry instanceof IPageIconsRegistryExtended)) {
- throw new RuntimeException("The editor registry do not implement IPageIconsRegistryExtended");////$NON-NLS-1$
- }
- return (IPageIconsRegistryExtended)editorRegistry;
- }
-
- @Override
- public String getText(Object element) {
- if(element instanceof PapyrusTableInstance) {
- return ((PapyrusTableInstance)element).getName();
- }
- return super.getText(element);
- }
-
-
- @Override
- public Image getImage(Object element) {
- if(element instanceof PapyrusTableInstance) {
- return getEditorRegistry().getEditorIcon(element);
- }
- return super.getImage(element);
- }
- }
-
-
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorNavigationDialog.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorNavigationDialog.java
index 43ea13d5556..a62149b2921 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorNavigationDialog.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorNavigationDialog.java
@@ -15,16 +15,18 @@ package org.eclipse.papyrus.infra.hyperlink.ui;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkContentProvider;
-import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -57,6 +59,8 @@ public class EditorNavigationDialog extends Dialog {
protected List<HyperLinkObject> hyperlinkResult = new ArrayList<HyperLinkObject>();
+ protected EObject contextElement;
+
/**
*
* dialog to display a list of hyperlinks. the button ok is use to excute
@@ -67,9 +71,10 @@ public class EditorNavigationDialog extends Dialog {
* @param hyperlinkObjects
* the list of hyperlinkObjects
*/
- public EditorNavigationDialog(Shell parentShell, ArrayList<HyperLinkObject> hyperlinkObjects) {
+ public EditorNavigationDialog(Shell parentShell, ArrayList<HyperLinkObject> hyperlinkObjects, EObject contextElement) {
super(parentShell);
this.hyperlinkObjects = hyperlinkObjects;
+ this.contextElement = contextElement;
parentShell.setText(Messages.DiagramNavigationDialog_ChooseHyperLinks);
}
@@ -97,14 +102,20 @@ public class EditorNavigationDialog extends Dialog {
tableViewer.setContentProvider(contentProvider);
// set the label provider
- IPageIconsRegistry editorRegistry = null;
- IMultiDiagramEditor papyrusEditor = EditorUtils.getMultiDiagramEditor();
- try {
- editorRegistry = papyrusEditor.getServicesRegistry().getService(IPageIconsRegistry.class);
- } catch (ServiceException e) {
- e.printStackTrace();
+ ILabelProvider provider = null;
+ if(contextElement != null) {
+ try {
+ provider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, contextElement).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
}
- tableViewer.setLabelProvider(new HyperLinkLabelProvider(editorRegistry));
+
+ if(provider == null) {
+ provider = new LabelProvider();
+ }
+
+ tableViewer.setLabelProvider(provider);
tableViewer.setInput(this.hyperlinkObjects);
//Check the first element by default
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java
index 98bf26bfc19..afaa710665b 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java
@@ -17,18 +17,21 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkContentProvider;
-import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.CTabFolder;
@@ -209,7 +212,21 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
Activator.log.error(e);
}
this.hyperlinkObjects = hyperLinkHelper.getFilteredObject(hyperlinkObjects);
- tableViewer.setLabelProvider(new HyperLinkLabelProvider(editorRegistry));
+
+ ILabelProvider provider = null;
+ if(element != null) {
+ try {
+ provider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, element).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+ }
+
+ if(provider == null) {
+ provider = new LabelProvider();
+ }
+
+ tableViewer.setLabelProvider(provider);
getTableViewer().setInput(this.hyperlinkObjects);
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkFilteredLabelProvider.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkFilteredLabelProvider.java
new file mode 100644
index 00000000000..9a9eda9235f
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkFilteredLabelProvider.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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.hyperlink.util;
+
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.papyrus.infra.widgets.providers.IFilteredLabelProvider;
+
+
+public class HyperLinkFilteredLabelProvider extends HyperLinkLabelProvider implements IFilteredLabelProvider {
+
+ public boolean accept(Object element) {
+ return element instanceof HyperLinkObject;
+ }
+
+
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkLabelProvider.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkLabelProvider.java
index d9b8c2f0b31..95533c6acf7 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkLabelProvider.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/HyperLinkLabelProvider.java
@@ -13,41 +13,32 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.util;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkDocument;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkWeb;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The Class DocumentLabelProvider.
*/
-public class HyperLinkLabelProvider implements ILabelProvider {
+public class HyperLinkLabelProvider extends LabelProvider {
/** The HYPERLIN k_ we b_ ico n_ path. */
- protected final String HYPERLINK_WEB_ICON_PATH = "/icons/obj16/hyperlink.gif"; //$NON-NLS-1$
+ protected final String HYPERLINK_WEB_ICON_PATH = "/icons/hyperlink.gif"; //$NON-NLS-1$
/** The HYPERLIN k_ documen t_ ico n_ path. */
- protected final String HYPERLINK_DOCUMENT_ICON_PATH = "/icons/obj16/file.gif"; //$NON-NLS-1$
+ protected final String HYPERLINK_DOCUMENT_ICON_PATH = "/icons/file.gif"; //$NON-NLS-1$
+
/** The SEP. */
private final String SEP = " - "; //$NON-NLS-1$
-
- /** The editor registry. */
- private IPageIconsRegistry editorRegistry;
-
- /**
- * Instantiates a new object label provider.
- *
- * @param imagePath
- * the image path
- */
- public HyperLinkLabelProvider(IPageIconsRegistry editorFactoryRegistry ) {
- this.editorRegistry = editorFactoryRegistry;
- }
/**
* {@inheritedDoc}.
@@ -57,19 +48,28 @@ public class HyperLinkLabelProvider implements ILabelProvider {
*
* @return the image
*/
+ @Override
public Image getImage(Object element) {
- //TODO remove the uml.diagram.common call
if(element instanceof HyperLinkDocument) {
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.papyrus.uml.diagram.common", HYPERLINK_DOCUMENT_ICON_PATH).createImage(); //$NON-NLS-1$
+ return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, HYPERLINK_DOCUMENT_ICON_PATH);
}
- else if(element instanceof HyperLinkWeb) {
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.papyrus.uml.diagram.common", HYPERLINK_WEB_ICON_PATH).createImage(); //$NON-NLS-1$
+
+ if(element instanceof HyperLinkWeb) {
+ return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, HYPERLINK_WEB_ICON_PATH);
}
- else if(element instanceof HyperLinkEditor){
- return ((HyperLinkEditor)element).getImage(((HyperLinkEditor)element).getObject());
+ if(element instanceof HyperLinkEditor) {
+ EObject editorContext = EMFHelper.getEObject(((HyperLinkEditor)element).getObject());
+ if(editorContext != null) {
+ try {
+ return ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, editorContext).getLabelProvider().getImage(editorContext);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+ }
}
- return null;
+
+ return super.getImage(element);
}
/**
@@ -80,64 +80,28 @@ public class HyperLinkLabelProvider implements ILabelProvider {
*
* @return the text
*/
+ @Override
public String getText(Object element) {
String out = ""; //$NON-NLS-1$
if(element instanceof HyperLinkDocument) {
out = ((HyperLinkDocument)element).getHyperlinkDocument();
} else if(element instanceof HyperLinkWeb) {
out = ((HyperLinkWeb)element).getHyperLinkWeb();
- }else if(element instanceof HyperLinkEditor){
- out = ((HyperLinkEditor)element).getText(((HyperLinkEditor)element).getObject());
+ } else if(element instanceof HyperLinkEditor) {
+ EObject editorContext = EMFHelper.getEObject(((HyperLinkEditor)element).getObject());
+ if(editorContext != null) {
+ try {
+ return ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, editorContext).getLabelProvider().getText(editorContext);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+ }
} else {
- return null;
+ return super.getText(element);
}
+
out = out + SEP + ((HyperLinkObject)element).getTooltipText();
return out;
}
-
- public String getTooltipText(Object element){
- return ((HyperLinkObject)element).getTooltipText();
- }
-
- /**
- * {@inheritedDoc}.
- *
- * @param listener
- * the listener
- */
- public void addListener(ILabelProviderListener listener) {
- }
-
- /**
- * {@inheritedDoc}.
- */
- public void dispose() {
- }
-
- /**
- * {@inheritedDoc}.
- *
- * @param element
- * the element
- * @param property
- * the property
- *
- * @return true, if checks if is label property
- */
- public boolean isLabelProperty(Object element, String property) {
- // TODO Auto-generated method stub
- return false;
- }
-
- /**
- * {@inheritedDoc}.
- *
- * @param listener
- * the listener
- */
- public void removeListener(ILabelProviderListener listener) {
- // TODO Auto-generated method stub
-
- }
}

Back to the top