Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ILightweightLabelDecorator stops working after a while
ILightweightLabelDecorator stops working after a while [message #407646] Thu, 08 March 2007 03:24 Go to next message
Eclipse UserFriend
Originally posted by: regent.larcheveque.space.gc.ca

Hi,

I have a simple EMF model:

-Items
-Item (EClass)
-Status (EReference: StatusOK, StatusWarning, StatusError)

I use a TreeViewer with a decorator that decorates Item based on the
actual Item.getStatus(). When I edit the model, the decorator works
into initialy properly. But after some operations, copy/paste/delete
actions, the decorator stop refreshing. The StatusItemProvider.getText()
is working properly (I output the status value to debug). I digged a bit
into the AdapterFactoryContentProvider. I override
AdapterFactoryContentProvider.notifyChanged():

if (viewer != null && viewer.getControl() != null &&
!viewer.getControl().isDisposed())
{
// If the notification is an IViewerNotification, it specifies how
// ViewerRefresh should behave. Otherwise fall
// back to NotifyChangedToViewerRefresh, which determines how to
// refresh the viewer directly from the model notification.
//
if (notification instanceof IViewerNotification)
{
// if (viewerRefresh == null) <------ REMOVE THIS LINE
{
viewerRefresh = new ViewerRefresh(viewer);
// } <------ REMOVE THIS LINE

if
(viewerRefresh.addNotification((IViewerNotification)notifica tion))
{
viewer.getControl().getDisplay().asyncExec(viewerRefresh);
}
}


This seems to resolve the problem. I suspect that
viewerRefresh.addNotification() does not take into account the
ViewerNotification. Before further digging in ViewerRefresh() I would
like to have some tips and helps.

Thanks
Re: ILightweightLabelDecorator stops working after a while [message #407650 is a reply to message #407646] Thu, 08 March 2007 09:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Regent,

This seems pretty vague. I'd need to be able to reproduce a problem to
comment on it with any kind of insight.


Regent L'Archeveque wrote:
> Hi,
>
> I have a simple EMF model:
>
> -Items
> -Item (EClass)
> -Status (EReference: StatusOK, StatusWarning, StatusError)
>
> I use a TreeViewer with a decorator that decorates Item based on the
> actual Item.getStatus(). When I edit the model, the decorator works
> into initialy properly. But after some operations, copy/paste/delete
> actions, the decorator stop refreshing. The
> StatusItemProvider.getText() is working properly (I output the status
> value to debug). I digged a bit into the
> AdapterFactoryContentProvider. I override
> AdapterFactoryContentProvider.notifyChanged():
>
> if (viewer != null && viewer.getControl() != null &&
> !viewer.getControl().isDisposed())
> {
> // If the notification is an IViewerNotification, it specifies how
> // ViewerRefresh should behave. Otherwise fall
> // back to NotifyChangedToViewerRefresh, which determines how to
> // refresh the viewer directly from the model notification.
> //
> if (notification instanceof IViewerNotification)
> {
> // if (viewerRefresh == null) <------ REMOVE THIS LINE
> {
> viewerRefresh = new ViewerRefresh(viewer);
> // } <------ REMOVE THIS LINE
>
> if
> (viewerRefresh.addNotification((IViewerNotification)notifica tion))
> {
> viewer.getControl().getDisplay().asyncExec(viewerRefresh);
> }
> }
>
>
> This seems to resolve the problem. I suspect that
> viewerRefresh.addNotification() does not take into account the
> ViewerNotification. Before further digging in ViewerRefresh() I would
> like to have some tips and helps.
>
> Thanks


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ILightweightLabelDecorator stops working after a while [message #407667 is a reply to message #407650] Fri, 09 March 2007 05:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: regent.larcheveque.space.gc.ca

I finally found the problem. I realized that some references did not
have the attribute "derived" set to true. Then copy / paste commands
copied these references and this caused the problem. Sharing the same
references among the copies did not raise proper viewer notification.

Thanks

Ed Merks wrote:
> Regent,
>
> This seems pretty vague. I'd need to be able to reproduce a problem to
> comment on it with any kind of insight.
>
>
> Regent L'Archeveque wrote:
>
>> Hi,
>>
>> I have a simple EMF model:
>>
>> -Items
>> -Item (EClass)
>> -Status (EReference: StatusOK, StatusWarning, StatusError)
>>
>> I use a TreeViewer with a decorator that decorates Item based on the
>> actual Item.getStatus(). When I edit the model, the decorator works
>> into initialy properly. But after some operations, copy/paste/delete
>> actions, the decorator stop refreshing. The
>> StatusItemProvider.getText() is working properly (I output the status
>> value to debug). I digged a bit into the
>> AdapterFactoryContentProvider. I override
>> AdapterFactoryContentProvider.notifyChanged():
>>
>> if (viewer != null && viewer.getControl() != null &&
>> !viewer.getControl().isDisposed())
>> {
>> // If the notification is an IViewerNotification, it specifies how
>> // ViewerRefresh should behave. Otherwise fall
>> // back to NotifyChangedToViewerRefresh, which determines how to
>> // refresh the viewer directly from the model notification.
>> //
>> if (notification instanceof IViewerNotification)
>> {
>> // if (viewerRefresh == null) <------ REMOVE THIS LINE
>> {
>> viewerRefresh = new ViewerRefresh(viewer);
>> // } <------ REMOVE THIS LINE
>>
>> if
>> (viewerRefresh.addNotification((IViewerNotification)notifica tion))
>> {
>> viewer.getControl().getDisplay().asyncExec(viewerRefresh);
>> }
>> }
>>
>>
>> This seems to resolve the problem. I suspect that
>> viewerRefresh.addNotification() does not take into account the
>> ViewerNotification. Before further digging in ViewerRefresh() I would
>> like to have some tips and helps.
>>
>> Thanks
Re: ILightweightLabelDecorator stops working after a while [message #407688 is a reply to message #407646] Sat, 10 March 2007 19:20 Go to previous message
Andreas Walter is currently offline Andreas WalterFriend
Messages: 8
Registered: July 2009
Junior Member
You should consider using registration and notification of
ILabelProviderListeners in your LabelDecorator implementation.
Methods for that are declared in interface
IBaseLabelProvider. That way, the LabelDecorator itself can cause
refreshing of the Viewer when decorations are to be refreshed...
Note that in Eclipse, label decorations are often used to display
information which is kind of "orthogonal" to the state of the
object that is displayed in a viewer, e.g., label decorations for
resources that are under version control. So, sometimes, the object
whose visualization is decorated "knows nothing about the reason
for the decoration". If that's the case in your application, you could
consider following the approach mentioned above.
Greetings,
Andreas
> Hi,
>
> I have a simple EMF model:
>
> -Items
> -Item (EClass)
> -Status (EReference: StatusOK, StatusWarning, StatusError)
>
> I use a TreeViewer with a decorator that decorates Item based on the
> actual Item.getStatus(). When I edit the model, the decorator works
> into initialy properly. But after some operations, copy/paste/delete
> actions, the decorator stop refreshing. The StatusItemProvider.getText()
> is working properly (I output the status value to debug). I digged a bit
> into the AdapterFactoryContentProvider. I override
> AdapterFactoryContentProvider.notifyChanged():
>
> if (viewer != null && viewer.getControl() != null &&
> !viewer.getControl().isDisposed())
> {
> // If the notification is an IViewerNotification, it specifies how
> // ViewerRefresh should behave. Otherwise fall
> // back to NotifyChangedToViewerRefresh, which determines how to
> // refresh the viewer directly from the model notification.
> //
> if (notification instanceof IViewerNotification)
> {
> // if (viewerRefresh == null) <------ REMOVE THIS LINE
> {
> viewerRefresh = new ViewerRefresh(viewer);
> // } <------ REMOVE THIS LINE
>
> if
> (viewerRefresh.addNotification((IViewerNotification)notifica tion))
> {
> viewer.getControl().getDisplay().asyncExec(viewerRefresh);
> }
> }
>
>
> This seems to resolve the problem. I suspect that
> viewerRefresh.addNotification() does not take into account the
> ViewerNotification. Before further digging in ViewerRefresh() I would
> like to have some tips and helps.
>
> Thanks
Previous Topic:ECORE API example
Next Topic:Preventing editor generation
Goto Forum:
  


Current Time: Mon Sep 23 04:40:37 GMT 2024

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

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

Back to the top