• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Eclipse Plugins using timers and running on the background

 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am considering a project for myself, which would require writing an Eclipse plugin that runs on the background and wakes up every now and then to ask the user a question, and depending on the answer activate the plugin's "editor". Is this possible (and how)?
 
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had written you a nice long message with URLs and everything. Apparently I inadvertently included a less than symbol in my message, which offended this BB's code, and it was lost. Here's the brief version:
The Eclipse Platform architecture defers plug-in activation. In exceptional cases, you can override this by extending the org.eclipse.ui.startup extension point. There you could then start a background thread; when your timer goes off, switch over to the UI thread with Display.syncExec. Then it's a simple matter of displaying your dialog or reactivating your editor with IWorkbenchPage.openEditor (it has several variants).
However, I would imagine that the user would find it irritating if a dialog or editor spontaneously surfaced from time-to-time. Rule #1 of good UI design is "the user is in control."
That's enough to get you started, repost if you need further hints.
-- Dan
[ July 15, 2003: Message edited by: Dan Kehn ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Dan.
I do have further questions though, some of which relate to the issues you just mentioned.
1) Could you elaborate on "extending the org.eclipse.ui.startup extension point"? Do you mean extend as in Java keyword? Is org.eclipse.ui.startup a package or something else (and how do I extend a package)?
2) Assuming that I have just switched to the UI thread with syncExec(), how can I execute my code from there? Do I need to extend and override stuff from the Eclipse core?
3) Is it possible to suggest a dialog, e.g. by blinking a tab for my "background editor"? That's actually what I thought of first but then decided to start humble and try to find out whether the simpler (and less user-friendly) way is possible. Also, the interval of these "wake-ups" would be user-configurable, ofcourse, and would incorporate a button for quick "ask me again in X minutes" acknowledgement.
4) Is there a "standard" way of talking to these background threads or should I just write a static getMyBackgroundThread() method for the thread class? I would need to reconfigure intervals, set alarms and so on during runtime...
5) Does your book discuss this kind of questions (background threads, focus/activation stuff)?
Thanks again.
 
Dan Kehn
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) No, I'm referring to a plug-in extension point, specifically org.eclipse.ui.startup. Extensions and extension points are covered in Chapters 7 and 8 in our book.
2) Recall that we're talking about extending Eclipse using plug-ins. So your plug-in code is loaded in the eclipse.exe process and you have full access to the Eclipse APIs (see the Plug-in Developer's Guide in the Eclipse online help). Over twenty chapters of our book are dedicated to teaching you these APIs, so it'd hard to summarize in a single message post.
3) Ah, I see that you're dancing a fine line between an informative and intrusive UI decision. My first inclination would be an enhancement to the status line. Normally extensions to the status line are part of the active editor (i.e., editors use IStatusField to add fields to the status area when they're active). Your case is different, since you want an indicator that's available whether your editor is active or not. This is as much a UI design question as Eclipse programming. I would have to think about it a bit more...
4) All the standard ways of communicating among threads apply here. That is, there's nothing special about Eclipse in this regard -- it's just a Java program.
5) The SWT chapter does cover the need for background threads and includes a nifty example of their use. There is also a number of code examples that demonstrate how you can respond to Workbench events, activation among them. However, these are only examples / starting points that you would adapt to your specific needs.
Your message brings up a general point that Eclipse doesn't yet address: How do you draw the user's attention in a non-intrusive way to important background events? Most examples that immediately come to mind are dialogs that have a "Don't show this message again" checkbox. That's not what you're going for. It may be worth thinking about this problem more generally and proposing a solution / enhancement in bugzilla. For example, I've seen some applications that blink a little icon in the lower corner; when you click on it, it displays the n last message from background threads. I have to admit, however, that I rarely used it.
-- Dan
[ July 15, 2003: Message edited by: Dan Kehn ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I need to shop for an Eclipse book
Thanks for the clarifications!
One more question, though. Can we use sound effects in Eclipse plugins?
 
Dan Kehn
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm almost afraid to ask what you've got in mind.
The standard SWT choice is pretty mundane (Display.beep()), but you can do anything that's possible from Java, right? And since SWT supports ActiveX/OLE (Chapter 24 and 25), you can do exotic Windows-specific stuff -- if you don't mind the lack of portability.
-- Dan
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had written you a nice long message with URLs and everything.
Ouch! Sorry to hear that. I'm a bit surprised to hear you got that message - I didn't realize HTML was allowed in this forum. That is, if we disable HTML you have fewer formatting options, but also fewer problems with the system whining about every < tag. So most of our forums have HTML disabled for convenience, and I'm not sure why this is an exception. One of our admins probably had a reason for... hmmm. I've occasionally tried to make sense of the UBB code (written in Perl) that covers this stuff, but it's pretty ugly. Next time though (if there is one) you can usually recover what you wrote with the back key. Sorry for the inconvenience, and good luck.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The standard SWT choice is pretty mundane (Display.beep()), but you can do anything that's possible from Java, right? And since SWT supports ActiveX/OLE (Chapter 24 and 25), you can do exotic Windows-specific stuff -- if you don't mind the lack of portability.


Ok. I was kinda thinking about the Java Sound API. On the other hand, Display.beep() might be enough.
 
Dan Kehn
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jim Yingst:
I've occasionally tried to make sense of the UBB code (written in Perl) that covers this stuff, but it's pretty ugly. Next time though (if there is one) you can usually recover what you wrote with the back key. Sorry for the inconvenience, and good luck.


The form was empty went I tried the back key. I've worked with other BBs with similar problems and gotten into the habit of doing a quick "copy to clipboard" before submitting the message. I unfortunately forgot that time.
-- Dan
 
reply
    Bookmark Topic Watch Topic
  • New Topic