ILightweightLabelDecorator stops working after a while [message #407646] |
Thu, 08 March 2007 03:24 |
Eclipse User |
|
|
|
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 |
Ed Merks 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 |
Eclipse User |
|
|
|
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 |
Andreas Walter 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
|
|
|
Powered by
FUDForum. Page generated in 0.03641 seconds