Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Stop ProgressBar which is running SWT.INDETERMINATE
Stop ProgressBar which is running SWT.INDETERMINATE [message #372004] Sat, 26 July 2003 07:31 Go to next message
Eclipse UserFriend
Originally posted by: simon.rutishauser.gmx.ch

hi,

does anyone know how I can stop a progressbar created like this:

ProgressBar p = new ProgressBar(parent, SWT.INDETERMINATE);

now I'd like to stop it at some time. Just like setting
p.setRedraw(false), but actually this also prevents the bar from being
redrawn when it should (another window temporarily before progressbar)

Peschmä
Re: Stop ProgressBar which is running SWT.INDETERMINATE [message #372012 is a reply to message #372004] Sun, 27 July 2003 01:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: burner.zclipse.org

On Sat, 26 Jul 2003 13:31:08 +0200, Simon Rutishauser wrote:

> hi,
>
> does anyone know how I can stop a progressbar created like this:
>
> ProgressBar p = new ProgressBar(parent, SWT.INDETERMINATE);
>
> now I'd like to stop it at some time. Just like setting
> p.setRedraw(false), but actually this also prevents the bar from being
> redrawn when it should (another window temporarily before progressbar)

setRedraw() is definitely not what you want.

It sounds like what you want is p.setEnabled(false), but that doesn't seem
to work (at least on linux/gtk2, the progressbar continues to update after
setEnabled(false) is called). Perhaps this is a bug, or maybe my
understanding of what setEnabled() does for a ProgressBar is off.

Could you live with p.setVisible(false), and just have the progressbar
disappear?


> Peschmä

--
http://zclipse.org
Re: Stop ProgressBar which is running SWT.INDETERMINATE [message #372013 is a reply to message #372012] Sun, 27 July 2003 03:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: burner.zclipse.org

On Sun, 27 Jul 2003 01:58:02 -0400, Michael R Head wrote:

> It sounds like what you want is p.setEnabled(false), but that doesn't seem
> to work (at least on linux/gtk2, the progressbar continues to update after
> setEnabled(false) is called). Perhaps this is a bug, or maybe my
> understanding of what setEnabled() does for a ProgressBar is off.
>

I just checked this out with a native GTK app, and the progress bar
doesn't seem to honor the gtk_widget_set_sensitive call, so
ProgressBar.setEnabled() can't work under GTK.

My suggestion would be to either use setVisible() or swap out the
SWT.INDETERMINATE progress bar for a standard progress bar when you want
to show that the process is complete. (that is, use the indeterminate one
while the process is proceeding, but when the process is complete, remove
the indeterminate one and add a determinate one with
setSelection(getMaximum()) or thereabouts.

mike

>
>
>> Peschmä

--
http://zclipse.org
Re: Stop ProgressBar which is running SWT.INDETERMINATE [message #372014 is a reply to message #372012] Sun, 27 July 2003 03:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.rutishauser.gmx.ch

Hi,

>> does anyone know how I can stop a progressbar created like this:
>>
>> ProgressBar p = new ProgressBar(parent, SWT.INDETERMINATE);
>>
>> now I'd like to stop it at some time. Just like setting
>> p.setRedraw(false), but actually this also prevents the bar from being
>> redrawn when it should (another window temporarily before progressbar)
>
> setRedraw() is definitely not what you want.

of course not. Just to illustrate what I really want as it (before the
window needs any redrawing) looks like what I want ;)

> It sounds like what you want is p.setEnabled(false), but that doesn't seem
> to work (at least on linux/gtk2, the progressbar continues to update after
> setEnabled(false) is called). Perhaps this is a bug, or maybe my
> understanding of what setEnabled() does for a ProgressBar is off.

setEnabled() isn't exactly described in the APIDoc. There's just written
that you can't click on a Button which is setEnabled(false)

I don't think this is a bug. It would rather be a feature request as
setEnabled(false) does not yet do anything with a progressbar. But I think
this wouldn't be a really clever function to place there because it
_only_ is for ProgressBar with SWT.INDETERMINATE and not for the rest

> Could you live with p.setVisible(false), and just have the progressbar
> disappear?

no, definitely not.

It looks like the easiest way is for me to use the Bar _without_
SWT.INDETERMINATE and to make it move with an own thread which is easily
stoppable

Peschmä
Re: Stop ProgressBar which is running SWT.INDETERMINATE [message #372015 is a reply to message #372004] Sun, 27 July 2003 03:23 Go to previous message
Eclipse UserFriend
Originally posted by: burner.zclipse.org

OK, last time replying to this thread (for some reason it piqued my
interest).

Anyway, I don't think there's a good way to do exactly what you want, but
you might be able to use this to get close to the same effect:

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;

public class ProgressBarTest {

public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
final org.eclipse.swt.widgets.Composite comp = new org.eclipse.swt.widgets.Composite(shell, SWT.NONE);
final ProgressBar bar = new ProgressBar(comp, SWT.INDETERMINATE);
final ProgressBar barComplete = new ProgressBar(comp, SWT.SMOOTH);
barComplete.setMaximum(2);
bar.setSize(300, 20);
barComplete.setSize(300, 20);
shell.setLayout(new RowLayout());
shell.pack();
shell.open();

new Thread() {
public void run() {
try {sleep(5000);} catch (InterruptedException e) {}
display.syncExec(new Runnable() {
public void run() {
barComplete.setSelection(1);
barComplete.moveAbove(bar);
}
});
try {sleep(5000);} catch (InterruptedException e) {}
display.syncExec(new Runnable() {
public void run() {
barComplete.moveBelow(bar);
}
});
}
}.start();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}


--
http://zclipse.org
Re: Stop ProgressBar which is running SWT.INDETERMINATE [message #372016 is a reply to message #372013] Sun, 27 July 2003 03:23 Go to previous message
Eclipse UserFriend
Originally posted by: simon.rutishauser.gmx.ch

....
> My suggestion would be to either use setVisible() or swap out the
> SWT.INDETERMINATE progress bar for a standard progress bar when you want
> to show that the process is complete. (that is, use the indeterminate one
> while the process is proceeding, but when the process is complete, remove
> the indeterminate one and add a determinate one with
> setSelection(getMaximum()) or thereabouts.

not really, as I only have to stop the bar if the thing _fails_ and
therefore is not complete. But as I pointed out in my other posting I'll
try it with using a standard bar and simulating the INTDETERMINATE style
on my own

Peschmä
Previous Topic:coolbar limit to 1 line?
Next Topic:subclassing
Goto Forum:
  


Current Time: Mon Sep 22 13:32:55 EDT 2025

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

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

Back to the top