Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Discouraged access of RWTLifeCycle.setSessionDisplay(Display)
Discouraged access of RWTLifeCycle.setSessionDisplay(Display) [message #547331] Fri, 16 July 2010 10:16 Go to next message
Philipp Leusmann is currently offline Philipp LeusmannFriend
Messages: 36
Registered: July 2009
Member
Hi,

I would like to extend org.eclipse.swt.widgets.Display with some custom
features, so I subclassed it and call
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.setSessionDi splay(Display)
before the initial call to org.eclipse.ui.PlatformUI.createDisplay().
This way org.eclipse.swt.widgets.Display.getCurrent() always returns my
Display-Subclass.

1) I know this way is kind of a hack, but I could not find a straighter
way to achieve my target. Any comments?

2) In eclipse the call to
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.setSessionDi splay(Display)
shows a warning "Discouraged access". Can you please comment on this
warning? Why is it marked as discouraged? Can I ignore the warning?

Regards,
Philipp
Re: Discouraged access of RWTLifeCycle.setSessionDisplay(Display) [message #547335 is a reply to message #547331] Fri, 16 July 2010 11:01 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi Philipp,

> 1) I know this way is kind of a hack, but I could not find a straighter
> way to achieve my target. Any comments?

If you want to store data per session you could use a SessionSingleton.
What's your use case?

> 2) In eclipse the call to
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.setSessionDi splay(Display)
> shows a warning "Discouraged access". Can you please comment on this
> warning? Why is it marked as discouraged? Can I ignore the warning?

The reason is that you access internal API which might change in
upcoming releases. The convention is that all API with an "internal"
within the package name is internal :-)

Regards,
Stefan.
Re: Discouraged access of RWTLifeCycle.setSessionDisplay(Display) [message #547338 is a reply to message #547335] Fri, 16 July 2010 11:16 Go to previous messageGo to next message
Philipp Leusmann is currently offline Philipp LeusmannFriend
Messages: 36
Registered: July 2009
Member
Am 16.07.2010 13:01, schrieb Stefan Roeck:
> Hi Philipp,
>
>> 1) I know this way is kind of a hack, but I could not find a
>> straighter way to achieve my target. Any comments?
>
> If you want to store data per session you could use a SessionSingleton.
> What's your use case?

Views in our application may receive events to notify them of available
udates.
The common base class we derive all our views from, shows a dialog to
notify the user, but as you can imagine, this dialog should only be
shown once per update.
So i decided to use a semaphore and I thought the display would be a
convenient place to store it. Of course I could put it directly into the
session, but still I think it fits nicely into the Display ;)

You have any other recommendations?

Regards,
Philipp
Re: Discouraged access of RWTLifeCycle.setSessionDisplay(Display) [message #547355 is a reply to message #547338] Fri, 16 July 2010 11:50 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Philipp,

subclassing Display is a misuse of the SWT API. You should definitely
not do that. If you need to attach application data to the Display, you
can use Display#setData. But I'd also feel that the session is the right
place to store it.

Regards, Ralf

Philipp Leusmann wrote:
> Am 16.07.2010 13:01, schrieb Stefan Roeck:
>> Hi Philipp,
>>
>>> 1) I know this way is kind of a hack, but I could not find a
>>> straighter way to achieve my target. Any comments?
>>
>> If you want to store data per session you could use a SessionSingleton.
>> What's your use case?
>
> Views in our application may receive events to notify them of available
> udates.
> The common base class we derive all our views from, shows a dialog to
> notify the user, but as you can imagine, this dialog should only be
> shown once per update.
> So i decided to use a semaphore and I thought the display would be a
> convenient place to store it. Of course I could put it directly into the
> session, but still I think it fits nicely into the Display ;)
>
> You have any other recommendations?
>
> Regards,
> Philipp
Re: Discouraged access of RWTLifeCycle.setSessionDisplay(Display) [message #547356 is a reply to message #547355] Fri, 16 July 2010 12:23 Go to previous message
Philipp Leusmann is currently offline Philipp LeusmannFriend
Messages: 36
Registered: July 2009
Member
Ok guys, you convinced me. A SessionSingleton is even cooler ;)

Am 16.07.2010 13:50, schrieb Ralf Sternberg:
> Hi Philipp,
>
> subclassing Display is a misuse of the SWT API. You should definitely
> not do that. If you need to attach application data to the Display, you
> can use Display#setData. But I'd also feel that the session is the right
> place to store it.
>
> Regards, Ralf
>
> Philipp Leusmann wrote:
>> Am 16.07.2010 13:01, schrieb Stefan Roeck:
>>> Hi Philipp,
>>>
>>>> 1) I know this way is kind of a hack, but I could not find a
>>>> straighter way to achieve my target. Any comments?
>>>
>>> If you want to store data per session you could use a SessionSingleton.
>>> What's your use case?
>>
>> Views in our application may receive events to notify them of available
>> udates.
>> The common base class we derive all our views from, shows a dialog to
>> notify the user, but as you can imagine, this dialog should only be
>> shown once per update.
>> So i decided to use a semaphore and I thought the display would be a
>> convenient place to store it. Of course I could put it directly into the
>> session, but still I think it fits nicely into the Display ;)
>>
>> You have any other recommendations?
>>
>> Regards,
>> Philipp
Previous Topic:Request.js add some codes in RAP1.3 and UICallBackServiceHandler without any response
Next Topic:[menu] menu contributions not updated/shown if they have a visibleWhen expression
Goto Forum:
  


Current Time: Thu Apr 25 23:30:00 GMT 2024

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

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

Back to the top