Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to customize MessageBox?
How to customize MessageBox? [message #439350] Mon, 12 July 2004 00:00 Go to next message
Yiqun Xu is currently offline Yiqun XuFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,

I am trying to generate a MessageBox/MessageDialog to Show a "Please
wait.... loading Document Image" while load images in the background. This
box is supposed to be no-button, and should close automatically once the
background work is done.

Any advice? Sample code is highly appreicated...

Thanks a lot!

Rich
Re: How to customize MessageBox? [message #439438 is a reply to message #439350] Mon, 12 July 2004 17:59 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet104.html

"Rich" <richard_shu74@yahoo.com> wrote in message
news:ccskbd$nnp$1@eclipse.org...
> Hi,
>
> I am trying to generate a MessageBox/MessageDialog to Show a "Please
> wait.... loading Document Image" while load images in the background. This
> box is supposed to be no-button, and should close automatically once the
> background work is done.
>
> Any advice? Sample code is highly appreicated...
>
> Thanks a lot!
>
> Rich
>
Re: How to customize MessageBox? [message #439513 is a reply to message #439438] Mon, 12 July 2004 22:45 Go to previous messageGo to next message
Yiqun Xu is currently offline Yiqun XuFriend
Messages: 12
Registered: July 2009
Junior Member
Thank you very much, Steve.

I figured out that Progress Bar might satisfy the requirement.

I have tried both ProgressMonitorDialog and ProgressBar. The problem is I
do not know how to Synchronize the two threads. (Progress Bar and the Dos
command). I am assuming that I might need to add some event listener, but
cannot figure out which one is really needed.

The following is my code of the two threads:

...

// Thread for Progress bar
final Display display = getDisplay();
Shell shell = getShell();
final ProgressBar bar = new ProgressBar (shell, SWT.SMOOTH);
bar.setBounds (10, 10, 200, 32);
shell.open ();
final int maximum = bar.getMaximum ();
new Thread () {
public void run () {
for (final int [] i=new int [1]; i [0] <= maximum; i [0]++) {
try {Thread.sleep (100);} catch (Throwable th) {}
display.asyncExec (new Runnable () { public void run () {
if (bar.isDisposed ()) return;
bar.setSelection (i [0]);
}
});
}
}
}.start ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();


// convert PDF to TIFF
try{
String command="C:\\Program Files\\ImageMagick-6.0.1-Q16\\convert.exe
-density "+convertDensity + " "+ filename+" "+ firstFilename+"%02d.tif" ;
Process p= Runtime.getRuntime().exec(command);

try {
int returnVal = p.waitFor();
if (returnVal != 0) {
System.out.println("Not normal terminated//returnVal!=0");
}
} catch (Exception e) {
System.out.println("waitfor() error is" + e);

}

} catch (Exception e) {
System.out.println("convert error is" + e);
}



Thanks a lot.

Rich



Steve Northover wrote:

>
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet104.html

> "Rich" <richard_shu74@yahoo.com> wrote in message
> news:ccskbd$nnp$1@eclipse.org...
> > Hi,
> >
> > I am trying to generate a MessageBox/MessageDialog to Show a "Please
> > wait.... loading Document Image" while load images in the background. This
> > box is supposed to be no-button, and should close automatically once the
> > background work is done.
> >
> > Any advice? Sample code is highly appreicated...
> >
> > Thanks a lot!
> >
> > Rich
> >
Re: How to customize MessageBox? [message #439537 is a reply to message #439513] Tue, 13 July 2004 13:50 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
For one thing, the thread that updates the progress bar needs to be the
thread that is doing the work.

"Rich" <richard_shu74@yahoo.com> wrote in message
news:ccv49i$vjq$1@eclipse.org...
> Thank you very much, Steve.
>
> I figured out that Progress Bar might satisfy the requirement.
>
> I have tried both ProgressMonitorDialog and ProgressBar. The problem is I
> do not know how to Synchronize the two threads. (Progress Bar and the Dos
> command). I am assuming that I might need to add some event listener, but
> cannot figure out which one is really needed.
>
> The following is my code of the two threads:
>
> ..
>
> // Thread for Progress bar
> final Display display = getDisplay();
> Shell shell = getShell();
> final ProgressBar bar = new ProgressBar (shell, SWT.SMOOTH);
> bar.setBounds (10, 10, 200, 32);
> shell.open ();
> final int maximum = bar.getMaximum ();
> new Thread () {
> public void run () {
> for (final int [] i=new int [1]; i [0] <= maximum; i [0]++) {
> try {Thread.sleep (100);} catch (Throwable th) {}
> display.asyncExec (new Runnable () { public void run () {
> if (bar.isDisposed ()) return;
> bar.setSelection (i [0]);
> }
> });
> }
> }
> }.start ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
>
>
> // convert PDF to TIFF
> try{
> String command="C:\\Program Files\\ImageMagick-6.0.1-Q16\\convert.exe
> -density "+convertDensity + " "+ filename+" "+ firstFilename+"%02d.tif" ;
> Process p= Runtime.getRuntime().exec(command);
>
> try {
> int returnVal = p.waitFor();
> if (returnVal != 0) {
> System.out.println("Not normal terminated//returnVal!=0");
> }
> } catch (Exception e) {
> System.out.println("waitfor() error is" + e);
>
> }
>
> } catch (Exception e) {
> System.out.println("convert error is" + e);
> }
>
>
>
> Thanks a lot.
>
> Rich
>
>
>
> Steve Northover wrote:
>
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet104.html
>
> > "Rich" <richard_shu74@yahoo.com> wrote in message
> > news:ccskbd$nnp$1@eclipse.org...
> > > Hi,
> > >
> > > I am trying to generate a MessageBox/MessageDialog to Show a "Please
> > > wait.... loading Document Image" while load images in the background.
This
> > > box is supposed to be no-button, and should close automatically once
the
> > > background work is done.
> > >
> > > Any advice? Sample code is highly appreicated...
> > >
> > > Thanks a lot!
> > >
> > > Rich
> > >
>
>
Re: How to customize MessageBox? [message #439567 is a reply to message #439537] Tue, 13 July 2004 15:38 Go to previous message
Yiqun Xu is currently offline Yiqun XuFriend
Messages: 12
Registered: July 2009
Junior Member
Yes, it is, although it executes a DOS command.

Steve Northover wrote:

> For one thing, the thread that updates the progress bar needs to be the
> thread that is doing the work.

> "Rich" <richard_shu74@yahoo.com> wrote in message
> news:ccv49i$vjq$1@eclipse.org...
> > Thank you very much, Steve.
> >
> > I figured out that Progress Bar might satisfy the requirement.
> >
> > I have tried both ProgressMonitorDialog and ProgressBar. The problem is I
> > do not know how to Synchronize the two threads. (Progress Bar and the Dos
> > command). I am assuming that I might need to add some event listener, but
> > cannot figure out which one is really needed.
> >
> > The following is my code of the two threads:
> >
> > ..
> >
> > // Thread for Progress bar
> > final Display display = getDisplay();
> > Shell shell = getShell();
> > final ProgressBar bar = new ProgressBar (shell, SWT.SMOOTH);
> > bar.setBounds (10, 10, 200, 32);
> > shell.open ();
> > final int maximum = bar.getMaximum ();
> > new Thread () {
> > public void run () {
> > for (final int [] i=new int [1]; i [0] <= maximum; i [0]++) {
> > try {Thread.sleep (100);} catch (Throwable th) {}
> > display.asyncExec (new Runnable () { public void run () {
> > if (bar.isDisposed ()) return;
> > bar.setSelection (i [0]);
> > }
> > });
> > }
> > }
> > }.start ();
> > while (!shell.isDisposed ()) {
> > if (!display.readAndDispatch ()) display.sleep ();
> > }
> > display.dispose ();
> >
> >
> > // convert PDF to TIFF
> > try{
> > String command="C:\Program Files\ImageMagick-6.0.1-Q16\convert.exe
> > -density "+convertDensity + " "+ filename+" "+ firstFilename+"%02d.tif" ;
> > Process p= Runtime.getRuntime().exec(command);
> >
> > try {
> > int returnVal = p.waitFor();
> > if (returnVal != 0) {
> > System.out.println("Not normal terminated//returnVal!=0");
> > }
> > } catch (Exception e) {
> > System.out.println("waitfor() error is" + e);
> >
> > }
> >
> > } catch (Exception e) {
> > System.out.println("convert error is" + e);
> > }
> >
> >
> >
> > Thanks a lot.
> >
> > Rich
> >
> >
> >
> > Steve Northover wrote:
> >
> > >
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet104.html
> >
> > > "Rich" <richard_shu74@yahoo.com> wrote in message
> > > news:ccskbd$nnp$1@eclipse.org...
> > > > Hi,
> > > >
> > > > I am trying to generate a MessageBox/MessageDialog to Show a "Please
> > > > wait.... loading Document Image" while load images in the background.
> This
> > > > box is supposed to be no-button, and should close automatically once
> the
> > > > background work is done.
> > > >
> > > > Any advice? Sample code is highly appreicated...
> > > >
> > > > Thanks a lot!
> > > >
> > > > Rich
> > > >
> >
> >
Previous Topic:Table Scrolling
Next Topic:Fading "Balloon Tip" in SWT, examples?
Goto Forum:
  


Current Time: Thu Apr 25 06:36:00 GMT 2024

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

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

Back to the top