Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Progress Service Not Working(Progress service doesn't display a progress dialog when called from WorkbenchWindowAdvisor.postWindowOpen())
Progress Service Not Working [message #989868] Sat, 08 December 2012 14:37 Go to next message
Steve Biggs is currently offline Steve Biggs
Messages: 5
Registered: November 2012
Junior Member
I'm using the progress service and am having a problem with it under certain circumstances. I call the same method from two different places in my application and in one case the progress service displays a dialog as expected and in the other it doesn't. Nothing fails and there's no exceptions, it just never displays the progress dialog.

Here's the method I'm calling that runs an IRunnableWithProgress using the progress service.

public static void loginWithProgress(Shell parent) {
   // The login job
   IRunnableWithProgress job=new IRunnableWithProgress() {
      public void run(IProgressMonitor monitor) throws InvocationTargetException {
         ApplicationManager.getSessionManager().login(intranetId,password,monitor);
      }
   };
		
   try {
      PlatformUI.getWorkbench().getProgressService().busyCursorWhile(job);
   } catch (InvocationTargetException e) {
      e.printStackTrace();
   } catch (InterruptedException e) {
      ApplicationManager.getSessionManager().loginCancelled();
   }
}


When I call this from a handler it works fine and the progress dialog is displayed after 800 ms (as expected).

public class Connect extends AbstractHandler {
   public class Connect extends AbstractHandler {
      public Connect() {
   }

   @Override
   public Object execute(ExecutionEvent event) throws ExecutionException {
      Application.loginWithProgress(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
      return null;
   }
}


But when I call this same method from the WorkbenchWindowAdvisor.postWindowOpen() method the IRunnableWithProgress will execute successfully but no progress dialog appears.

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

   // A bunch of stuff removed from here for brevity

   @Override
   public void postWindowOpen() {

      // A bunch of stuff removed from here for brevity	
		
      Application.loginWithProgress(getWindowConfigurer().getWindow().getShell());
      super.postWindowOpen();
   }
}


Any suggestions as to why the progress dialog isn't appearing when called in the manner outlined above?

Thanks.


Steve Biggs
Re: Progress Service Not Working [message #989934 is a reply to message #989868] Mon, 10 December 2012 02:14 Go to previous messageGo to next message
sumit singh is currently offline sumit singh
Messages: 129
Registered: October 2012
Location: Bangalore
Senior Member

I'm not sure because it doesn't make sense but still did you tried like this.
   @Override
   public void postWindowOpen() {

      // A bunch of stuff removed from here for brevity	
		
      Application.loginWithProgress(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
      super.postWindowOpen();
   }



And one more thing in your public static void loginWithProgress(Shell parent) what is the use of Shell parent. Are you using it some where.?

[Updated on: Mon, 10 December 2012 02:17]

Report message to a moderator

Re: Progress Service Not Working [message #990043 is a reply to message #989934] Mon, 10 December 2012 11:17 Go to previous messageGo to next message
Steve Biggs is currently offline Steve Biggs
Messages: 5
Registered: November 2012
Junior Member
Hi Sumit,

Thanks for the suggestion. As expected, that change makes no difference as the parent parameter is not used when running the job with the progress service. I make use of parent elsewhere in the postWindowOpen() method for other purposes.


Steve Biggs
Re: Progress Service Not Working [message #992930 is a reply to message #990043] Sat, 22 December 2012 21:31 Go to previous message
Steve Biggs is currently offline Steve Biggs
Messages: 5
Registered: November 2012
Junior Member
In case anyone is experiencing the same issue, I have figured out my problem.

It seems that while the workbench is starting, PlatformUI.getWorkbench().getProgressService() will return an instance of the progress service even though it's not ready to be used yet. According to the documentation for PlatformUI.getWorkbench().isStarting():

Quote:

isStarting

boolean isStarting()

Returns a boolean indicating whether the workbench is in the process of starting. During this phase, it is not safe to make calls to other methods of the workbench, or of objects owned by the workbench. To delay work until after the workbench has been initialized, use IStartup or Display.asyncExec(Runnable).


The code below delays executing the call to run the progress service until the workbench has started, fixing my problem.

Display.getDefault().asyncExec(new Runnable() {
   public void run() {
      IRunnableWithProgress job=new IRunnableWithProgress() {
         public void run(IProgressMonitor monitor) throws InvocationTargetException,InterruptedException {
                           
            // Do some work here

         }
      };
	
      try {
         PlatformUI.getWorkbench().getProgressService().busyCursorWhile(job);
      } catch (InvocationTargetException e) {
         e.printStackTrace();
      } catch (InterruptedException e) {
         // Job was cancelled
      }
   }
});		


Steve Biggs
Previous Topic:IFolderLayout folder vanishes...
Next Topic:How to prompt dialog when closing editor ?
Goto Forum:
  


Current Time: Wed Jul 23 12:12:18 EDT 2014

Powered by FUDForum. Page generated in 0.02448 seconds