Skip to main content



      Home
Home » Modeling » EMF » ViewerRefresh.refresh(IViewerNotification notification)
ViewerRefresh.refresh(IViewerNotification notification) [message #1578303] Thu, 22 January 2015 05:09 Go to next message
Eclipse UserFriend
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.

Regards,

Christoph

[1]: download.eclipse.org/modeling/emf/emf/javadoc/2.8.0/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.ViewerRefresh.html
if (element != null)
        {
          if (notification.isContentRefresh())
          {
            structuredViewer.refresh(element, notification.isLabelUpdate());
          }
          else if (notification.isLabelUpdate())
          {
            structuredViewer.update(element, null);
          }
        }


[2]: help.eclipse.org/luna/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/StructuredViewer.html#update(java.lang.Object,%20java.lang.String%5B%5D)
Re: ViewerRefresh.refresh(IViewerNotification notification) [message #1580543 is a reply to message #1578303] Fri, 23 January 2015 10:07 Go to previous message
Eclipse UserFriend
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/AdapterFactoryContentProvider.java b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java
index d5631ca..4515ecd 100644
--- a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java
+++ b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java
@@ -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);
           }
         }
         else
Previous Topic:[Xcore] calling super method from overridden method
Next Topic:Derived Feature and eGet
Goto Forum:
  


Current Time: Sat Aug 30 20:01:35 EDT 2025

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

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

Back to the top