Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ProgressMonitorDialog misbehavior in RCP
ProgressMonitorDialog misbehavior in RCP [message #463382] Fri, 09 February 2007 11:47 Go to next message
Eclipse UserFriend
R3.2.1, WinXP

It may well be that what I am seeing is smehow WAD (e.g., maybe ProgressMonitorDialog is not
intended to be used with IProgressMonitor.UNKNOWN), but it sure seems wrong to me.

In the preStartup() method of my WorkbenchAdvisor, I need to start up a remote service; this can
take some while, but my RCP app must try to start it before it can display anything reasonable. So,
I execute some code as below -- but the "bar" of the ProgressMonitorDialog never moves at all. (The
subtask gets updated.) Also, if I move some other window in front of the ProgressMonitorDialog, then
minimize that other window, the whole dialog area of the ProgressMonitorDialog goes white
(window-title bar is ok).

What is wrong here?

thanks
Paul

try {
if (!TheServerOAM.isServerReady()) {
final String fullPath = ...;
final String text = "Starting Server at: " + fullPath;

final ProgressMonitorDialog pmd = new ProgressMonitorDialog(null);
pmd.open();
final Shell shell = pmd.getShell();

final GC gc = new GC(shell);
gc.setFont(JFaceResources.getDialogFont());
int avgWidth = gc.getFontMetrics().getAverageCharWidth();
gc.dispose();
// the position (300, 300) and height (200) are somewhat arbitrary
// the width-offset of 100 allows for the dialog's "info" image
shell.setBounds(300, 300, 100 + avgWidth * text.length(), 200);

shell.setText("Starting The Server");
shell.update();

final IRunnableWithProgress rwp = new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
monitor.beginTask(text, IProgressMonitor.UNKNOWN);
final long start = System.currentTimeMillis() / 1000;
TheServerOAM.startServer(fullPath);

while (!TheServerOAM.isServerReady()) {
final long delta =
(System.currentTimeMillis() / 1000) - start;
monitor.subTask("Waiting... " + delta);
shell.update(): // makes no difference
}

} catch (ServerException se) {
throw new InvocationTargetException(se);

} finally {
monitor.done();
}
}
};
pmd.run(true, false, rwp);

shell.dispose();
}

} catch (Exception exn) {
exn.printStackTrace();
}
Re: ProgressMonitorDialog misbehavior in RCP [message #463418 is a reply to message #463382] Sun, 11 February 2007 17:59 Go to previous messageGo to next message
Eclipse UserFriend
There is this line in the IDEWorkbenchAdvisor.preStartup method:

Platform.getJobManager().suspend();

If you have it in your code, try to start your remote service earlier.

Snjeza

Paul Keyser wrote:
> R3.2.1, WinXP
>
> It may well be that what I am seeing is smehow WAD (e.g., maybe
> ProgressMonitorDialog is not intended to be used with
> IProgressMonitor.UNKNOWN), but it sure seems wrong to me.
>
> In the preStartup() method of my WorkbenchAdvisor, I need to start up a
> remote service; this can take some while, but my RCP app must try to
> start it before it can display anything reasonable. So, I execute some
> code as below -- but the "bar" of the ProgressMonitorDialog never moves
> at all. (The subtask gets updated.) Also, if I move some other window in
> front of the ProgressMonitorDialog, then minimize that other window, the
> whole dialog area of the ProgressMonitorDialog goes white (window-title
> bar is ok).
>
> What is wrong here?
>
> thanks
> Paul
>
> try {
> if (!TheServerOAM.isServerReady()) {
> final String fullPath = ...;
> final String text = "Starting Server at: " + fullPath;
>
> final ProgressMonitorDialog pmd = new ProgressMonitorDialog(null);
> pmd.open();
> final Shell shell = pmd.getShell();
>
> final GC gc = new GC(shell);
> gc.setFont(JFaceResources.getDialogFont());
> int avgWidth = gc.getFontMetrics().getAverageCharWidth();
> gc.dispose();
> // the position (300, 300) and height (200) are somewhat arbitrary
> // the width-offset of 100 allows for the dialog's "info" image
> shell.setBounds(300, 300, 100 + avgWidth * text.length(), 200);
>
> shell.setText("Starting The Server");
> shell.update();
>
> final IRunnableWithProgress rwp = new IRunnableWithProgress() {
> public void run(final IProgressMonitor monitor)
> throws InvocationTargetException, InterruptedException {
> try {
> monitor.beginTask(text, IProgressMonitor.UNKNOWN);
> final long start = System.currentTimeMillis() / 1000;
> TheServerOAM.startServer(fullPath);
>
> while (!TheServerOAM.isServerReady()) {
> final long delta =
> (System.currentTimeMillis() / 1000) - start;
> monitor.subTask("Waiting... " + delta);
> shell.update(): // makes no difference
> }
>
> } catch (ServerException se) {
> throw new InvocationTargetException(se);
>
> } finally {
> monitor.done();
> }
> }
> };
> pmd.run(true, false, rwp);
>
> shell.dispose();
> }
>
> } catch (Exception exn) {
> exn.printStackTrace();
> }
Re: ProgressMonitorDialog misbehavior in RCP [message #463480 is a reply to message #463418] Mon, 12 February 2007 10:47 Go to previous messageGo to next message
Eclipse UserFriend
Nope, nothing like that in my code (not using IDE at all).

Other ideas?

Paul
Re: ProgressMonitorDialog misbehavior in RCP [message #463507 is a reply to message #463480] Mon, 12 February 2007 20:13 Go to previous messageGo to next message
Eclipse UserFriend
Try to call
shell.getDisplay().update();
instead of
shell.update();

Snjeza

Paul Keyser wrote:
> Nope, nothing like that in my code (not using IDE at all).
>
> Other ideas?
>
> Paul
Re: ProgressMonitorDialog misbehavior in RCP [message #463632 is a reply to message #463507] Tue, 13 February 2007 16:28 Go to previous messageGo to next message
Eclipse UserFriend
Cool -- that helped a lot! The "whitening" now vanishes after a second at most, and the prog-mon
does advance (slowly); although now the window cannot be moved.

thanks,
Paul
Re: ProgressMonitorDialog misbehavior in RCP [message #463635 is a reply to message #463632] Tue, 13 February 2007 18:06 Go to previous messageGo to next message
Eclipse UserFriend
I suppose that your isServerReady method takes some time.
You can add a listener to the TheServerOAM class. It would be called
when the server is ready.
You need to make an event loop that will be finished when the listener
is called.

Regards,
Snjeza

Paul Keyser wrote:
> Cool -- that helped a lot! The "whitening" now vanishes after a second
> at most, and the prog-mon does advance (slowly); although now the window
> cannot be moved.
>
> thanks,
> Paul
Re: ProgressMonitorDialog misbehavior in RCP [message #463720 is a reply to message #463635] Wed, 14 February 2007 16:37 Go to previous message
Eclipse UserFriend
Well, the isServerReady() must be returning pretty quickly, since the *text* set by the call to
monitor.subTask("...") updates quite nicely, counting off the seconds. But the blue-bar either never
(some runs) or rarely (other runs) updates, and if it does update, it only moves once or two steps
over the course of about 100 seconds.

Paul
Previous Topic:How to check editor input for external changes?
Next Topic:implementing undo actions
Goto Forum:
  


Current Time: Tue Apr 15 02:29:27 EDT 2025

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

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

Back to the top