Lengthy process in Netbeans - Sample plugin

In my previous blog Preventing user interaction during lengthy operation in netbeans, I gave a tip on how to use Window.glassPane to prevent the user interaction during lengthy process. Geertjan has requested if I could provide a plug-in, as a context for my tip. So I wrote this small plugin as a sample. You can download the NBM from here. This plugin adds a menu item called "A simple lengthy process" to the Tools menu. This menu item fires a process to calculate some prime numbers. The process takes about 15-20 secs to finish. During that time the user is prevented from interacting with the IDE.

When I was creating the module, I noticed that user could still interact with the UI even after I made the glasspane visible. So I had to do a small trick by adding the following line of code for the glasspane to grab the mouse focus.

mainWin.getGlassPane().addMouseListener( new MouseAdapter() {});

Also I've added the progress indicator at the status bar as shown in the picture below. Adding the progress bar is very easy. All you need to do is to use the Progress API. The code snippet I used is very simple

ProgressHandle handle = ProgressHandleFactory.createHandle("Prime number calculator");
handle.start(100);
int progressValue = <calculated value>;
...
handle.progress(progressValue );


Comments:

Very cool. Could you send me (or make available somehow) the source code of this plugin?

Posted by Geertjan on March 31, 2006 at 12:02 AM PST #

Hi Winston, I've noticed you've done quite some work for the Creator team, This si a little off topic, but in this post you have used the addMouseListener. I am trying to run some complex procedures from a mouseEntered/MouseOver a Static Text, it doesn't like the addMouseListner command, is there a workaround? Cheers, sorry if it's a little off topic, but havn't seen an awnser for this with creator2

Posted by 3P on May 15, 2006 at 02:38 PM PDT #

Hi 3P, this is for a swing application. You can not use mouse listeners in the StaticText (JSF tag). Instead you should use onMouse and onBlur javascript to do similar actions in the StaticText

Posted by guest on June 16, 2006 at 12:06 AM PDT #

ProgressHandle handle = ProgressHandleFactory.createHandle("User"); handle.start(); for(int i=0;i<10000;i++){ if(i%100==0) handle.progress(i/100); } handle.finish();

Posted by Mayank Patel on October 17, 2006 at 09:32 PM PDT #

i have writen the following code but it is not working please give me the solution, ProgressHandle handle = ProgressHandleFactory.createHandle("User"); handle.start(); for(int i=0;i<10000;i++){ if(i%100==0) handle.progress(i/100); } handle.finish();

Posted by Mayank Patel on October 17, 2006 at 09:34 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today