views:

107

answers:

1

Hello,

I am using the Eclipse RCP trayitem, which is described in Vogellas tutorials.

The requirement now is not only to show the name of the app in the tooltip but also a percentage while doing lengthy operations.

I understand that the trayitem attribute is a private from ApplicationWorkbenchWindowAdvisor, so I added a getter and setter method.

The only thing missing is a possibility to access the trayitem instance from my ProgressMonitorDialog instance.

Can you tell me, how you would solve this puzzle?
Thanks

+1  A: 

Since you can build a TrayItem around the SystemTray from any windows:

final Tray tray = window.getShell().getDisplay().getSystemTray();
TrayItem trayItem = new TrayItem(tray, SWT.NONE);

, do you have to access that TrayItem instance from ApplicationWorkbenchWindowAdvisor?

You could put it in a more accessible class or even build one where and when you need it.


Speaking of showing percentage while doing lengthy operations, I just wanted to mentioned the latest tasks icons improvements in Eclipse3.6M6 (not system tray, but related at they now can provide a good status indicator). See Snippet 336 for an example.

  • TaskItem overlay image

The new API TaskItem#setOverlayImage(Image) allows clients to set an image to be displayed on top of the application button in the taskbar.

alt text

  • TaskItem overlay text

The new API TaskItem#setOverlayText(String) allows clients to set a short text to be displayed on top of the application button in the taskbar.

alt text

  • TaskItem progress

The new APIs TaskItem#setProgress(int) and TaskItem#setProgressState(int) allows clients to show progress indication in the application button in the taskbar.

alt text

VonC
Thanks! As far as I know within the ProgressMonitorDialog class/thread I have no display or window access....I tried also to open a messagebox with this class and it failed because of this. Or am I doing something wrong?
Raven
@Raven: I don't understand: a `Dialog` is a `Window`. the `getShell()` method should be available.
VonC
Caused by: org.eclipse.swt.SWTException: Invalid thread accessThats the errormessage i get, after accessing the shell/display.I am using the ProgressDialog from this tutorial: http://www.vogella.de/articles/EclipseJobs/article.html
Raven
@Raven, off course, you need to do it within the GUI Thread. See for instance http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg16800.html
VonC
Yes, this works, just I get two trayicons now :-(. The one which was already there plus the one in the lengthy operation. I thought getTrayIcon() would get the ONE and not create another one...
Raven
@Raven: true, that is an issue. You could try and find a way to store "globally" the first `TrayItem` created by `ApplicationWorkbenchWindowAdvisor` (through some kind of resources accessible through the shell). The idea remains: access to that `TrayItem` within the GUI thread.
VonC