ProgressMonitorDialog misbehavior in RCP [message #463382] |
Fri, 09 February 2007 11:47  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #463720 is a reply to message #463635] |
Wed, 14 February 2007 16:37  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04256 seconds