|
|
|
Re: How to customize MessageBox? [message #439537 is a reply to message #439513] |
Tue, 13 July 2004 13:50 |
Steve Northover 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 |
Yiqun Xu 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
> > > >
> >
> >
|
|
|
Powered by
FUDForum. Page generated in 0.03535 seconds