Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to close Jface wizard while progress bar is running for a long time
How to close Jface wizard while progress bar is running for a long time [message #335336] Thu, 02 April 2009 14:14 Go to next message
Naag is currently offline NaagFriend
Messages: 19
Registered: July 2009
Junior Member
Hi

How to close the Jface wizard while progress bar is running doing a job
for a longer time.Since fewer times call to database is taking time i want
to close the Jface wizard but i am getting the following message
"wizard can not be closed due to an active operation. you must cancel the
operation before you can close the wizard".

How to cancel the operation from the UI.

Regards
NAAG
Re: How to close Jface wizard while progress bar is running for a long time [message #335346 is a reply to message #335336] Fri, 03 April 2009 03:54 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
> How to cancel the operation from the UI.

When you are running the operation thru the getContainer().run(...), you
should set the cancellable parameter to true. That would enable the Cancel
button

- Prakash
--
http://blog.eclipse-tips.com
Re: How to close Jface wizard while progress bar is running for a long time [message #335347 is a reply to message #335346] Fri, 03 April 2009 09:11 Go to previous messageGo to next message
Naag is currently offline NaagFriend
Messages: 19
Registered: July 2009
Junior Member
Hi prakash

I have set the cancelled flag as true. I couldnt see any cancel image
enabled next to progressbar.

I am using a long run operation in wizard page. getContainer().run method


//Sample code
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws
InvocationTargetException, InterruptedException {
monitor.begintask("");
//SDK and DB calls to fill the data to UI

monitor.done();
}

what should i do now? please help me out

Thanks for the eclipse tips site
NAAG
Re: How to close Jface wizard while progress bar is running for a long time [message #335348 is a reply to message #335347] Fri, 03 April 2009 10:23 Go to previous messageGo to next message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
Naag wrote:
> Hi prakash
>
> I have set the cancelled flag as true. I couldnt see any cancel image
> enabled next to progressbar.
>
> I am using a long run operation in wizard page. getContainer().run method
>
>
> //Sample code
> getContainer().run(true, true, new IRunnableWithProgress() {
This is correct. By providing cancelable=true, the Cancel Button will be
enabled while the operation is running.
> public void run(IProgressMonitor monitor) throws
> InvocationTargetException, InterruptedException {
> monitor.begintask("");
> //SDK and DB calls to fill the data to UI
Here, you have to check monitor.isCanceled() after each call and throw
an InteruptedException when it is true. See the JavaDoc of
IRunnableWithProgress.
>
> monitor.done();
> }
>
> what should i do now? please help me out
You have to catch the InteruptedException and close the wizard with
getShell().close().
This is a little bit ugly, as you make an assumption that the shell is
owned by the WizardDialog. In fact, a Wizard could be run by a container
that is no WizardDialog. For example, it could be run embedded in the
workbench window. Calling shell.close() here would have another meaning.
Anyway, WizardDialog is the only container I was using so far, and
AFAICS shell.close() is the only way of closing the wizard programmatically
>
> Thanks for the eclipse tips site
> NAAG
>

Regards, Sebastian
Re: How to close Jface wizard while progress bar is running for a long time [message #335349 is a reply to message #335348] Fri, 03 April 2009 10:40 Go to previous messageGo to next message
Naag is currently offline NaagFriend
Messages: 19
Registered: July 2009
Junior Member
Thanks for the reply. When i make the isCancelled flag as true there is no
cancel button enabled.
Re: How to close Jface wizard while progress bar is running for a long time [message #335351 is a reply to message #335349] Fri, 03 April 2009 11:42 Go to previous message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
Naag wrote:
> Thanks for the reply. When i make the isCancelled flag as true there
> is no cancel button enabled.
>
No, this is not what I said. You called getContainer().run(true, true,
new IRunnableWithProgress() {...} ). By providing true for the first two
arguments, the operation is cancelable and does not run on the UI thread
(in other words: the UI still responds while the op is running).
This alone should make your cancel button enabled, what means it can
actually be pressed. When the button is pressed by the user, the
IProgressMonitor.isCanceled() becomes true. Your Runnable should poll
this between method calls and break when it becomes true. The break can
be implemented by just throwing an InteruptedException.

Sebastian
Previous Topic:LTK: Need to replace DeleteResourcedRefactoringContribution
Next Topic:Problem updating Ganymede
Goto Forum:
  


Current Time: Tue Jul 30 20:28:05 GMT 2024

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

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

Back to the top