Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ViewerRefresh.refresh(IViewerNotification notification)
ViewerRefresh.refresh(IViewerNotification notification) [message #1578303] Thu, 22 January 2015 10:09 Go to next message
Christoph Etzel is currently offline Christoph EtzelFriend
Messages: 2
Registered: January 2015
Junior Member
I'm using an extended CommonNavigator to display objects from an EMF model. To display the labels i'm using a label provider which uses some properties of the objects. Additionally if added a commonSorter using the navigatorContent extension point.
The problem is, that if a property is changed the label gets updated, but no sort is performed. I have debugged the application and found that the viewer update is triggered from
ViewerRefresh.refresh(IViewerNotification notification)
with the String[] properties set to null (see [1] else-if-statement). But since properties is null, no sort or filtering is performed by a StructuredViewer (see [2]).

Is this the desired behavior of ViewerRefresh?
Wouldn't it be possible to get the changed properties from the notification and generate the properties String in ViewerRefresh?

I'm very new to EMF, so i might miss something.



if (element != null)
          if (notification.isContentRefresh())
            structuredViewer.refresh(element, notification.isLabelUpdate());
          else if (notification.isLabelUpdate())
            structuredViewer.update(element, null);

Re: ViewerRefresh.refresh(IViewerNotification notification) [message #1580543 is a reply to message #1578303] Fri, 23 January 2015 15:07 Go to previous message
Christoph Etzel is currently offline Christoph EtzelFriend
Messages: 2
Registered: January 2015
Junior Member
I have been thinking to change the code like this:
diff --git a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/ b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/
index d5631ca..4515ecd 100644
--- a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/
+++ b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/
@@ -31,6 +31,7 @@
 import org.eclipse.emf.common.notify.AdapterFactory;
 import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.ENamedElement;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
 import org.eclipse.emf.edit.domain.EditingDomain;
@@ -496,7 +497,8 @@
           else if (notification.isLabelUpdate())
-            structuredViewer.update(element, null);
+              Object feature = notification.getFeature();
+              structuredViewer.update(element, feature instanceof ENamedElement ? new String[] { ((ENamedElement)feature).getName() } : null);
Previous Topic:[Xcore] calling super method from overridden method
Next Topic:Derived Feature and eGet
Goto Forum:

Current Time: Thu Sep 24 16:06:10 GMT 2020

Powered by FUDForum. Page generated in 0.01634 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top