Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Show Progress Monitor on commit
[CDO] Show Progress Monitor on commit [message #1001984] Thu, 17 January 2013 16:49 Go to next message
Joao S is currently offline Joao S
Messages: 51
Registered: January 2011
Member
Hello everyone,

I am trying to show a progress monitor during commits however , I can´t find a way of making this work ok.

Does anyone has any experience on this?

I tried something like this:
	
		final ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(
				getShell());

		Display.getDefault().syncExec(new Runnable() {
			public void run() {
				progressMonitor.open();
				try {
					transaction.commit(progressMonitor.getProgressMonitor());
				} catch (CommitException e) {
					e.printStackTrace();
				}
				progressMonitor.close();
			}
		});


But I keep getting an "[ERROR] Invalid thread access" error.
Any ideas on this?

Thanks in advance,
João

Re: [CDO] Show Progress Monitor on commit [message #1002043 is a reply to message #1001984] Thu, 17 January 2013 20:11 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 937
Registered: July 2009
Senior Member
interesting, as an alternative to the ProgressMonitorDialog you perhaps call commit() from the eclipse Job api. This produces a ProgressMonitor. The Job can be setUser() so this would also show a dialog, and as a bonus it can run in background, so no UI blocking.
just a thought.
Christophe
Re: [CDO] Show Progress Monitor on commit [message #1002056 is a reply to message #1001984] Thu, 17 January 2013 21:06 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 750
Registered: July 2009
Senior Member
Joao S wrote on Thu, 17 January 2013 17:49

But I keep getting an "[ERROR] Invalid thread access" error.
Any ideas on this?


Maybe, you could post the stack trace. It is not clear how that is possible as the code is triggered from the ui thread (DIsplay.syncExec)...
Do you have a commit listener that executes outside the ui thread?
Re: [CDO] Show Progress Monitor on commit [message #1002060 is a reply to message #1002056] Thu, 17 January 2013 21:10 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 750
Registered: July 2009
Senior Member
You should try to execute the progress dialog creation inside the runnable as well (just a guess as we dont have the stack trace):


		Display.getDefault().syncExec(new Runnable() {
			public void run() {
				final ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(
				getShell());
				progressMonitor.open();
				try {
					transaction.commit(progressMonitor.getProgressMonitor());
				} catch (CommitException e) {
					e.printStackTrace();
				}
				progressMonitor.close();
			}
		});


BTW: eclipse (3.x) has a IProgressService which should be used instead:

http://wiki.eclipse.org/FAQ_Why_should_I_use_the_new_progress_service%3F
Re: [CDO] Show Progress Monitor on commit [message #1002741 is a reply to message #1001984] Sat, 19 January 2013 09:07 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
You are using the ProgressMonitorDialog wrong! To run the operation you do

ProgressMonitorDialog d = new ProgressMonitorDialog();
d.run(true,false,new IRunnableWithProgress() {
//....
});

Tom

Am 17.01.13 17:49, schrieb Joao S:
> Hello everyone,
>
> I am trying to show a progress monitor during commits however , I can´t
> find a way of making this work ok.
>
> Does anyone has any experience on this?
>
> I tried something like this:
>
> final ProgressMonitorDialog progressMonitor = new
> ProgressMonitorDialog(
> getShell());
>
> Display.getDefault().syncExec(new Runnable() {
> public void run() {
> progressMonitor.open();
> try {
>
> transaction.commit(progressMonitor.getProgressMonitor());
> } catch (CommitException e) {
> e.printStackTrace();
> }
> progressMonitor.close();
> }
> });
>
>
> But I keep getting an "[ERROR] Invalid thread access" error.
> Any ideas on this?
>
> Thanks in advance,
> João
>
>
Re: [CDO] Show Progress Monitor on commit [message #1003969 is a reply to message #1002741] Tue, 22 January 2013 10:41 Go to previous messageGo to next message
Joao S is currently offline Joao S
Messages: 51
Registered: January 2011
Member
Thank you all for your kind answers!


Quote:
BTW: eclipse (3.x) has a IProgressService which should be used instead:


Thanks for the hint!

Quote:
interesting, as an alternative to the ProgressMonitorDialog you perhaps call commit() from the eclipse Job api.


Yes, I will definitely do that =)

Quote:
You are using the ProgressMonitorDialog wrong! To run the operation you do

ProgressMonitorDialog d = new ProgressMonitorDialog();
d.run(true,false,new IRunnableWithProgress() {
//....
});


Yes, you are totaly right. It is working fine now!

One other thing, is it possible to get a little bit more of information in the progress dialog besides de progress bar? Tasks description, maybe subtasks, etc..
Re: [CDO] Show Progress Monitor on commit [message #1004014 is a reply to message #1003969] Tue, 22 January 2013 12:30 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5545
Registered: July 2009
Senior Member
Am 22.01.2013 11:41, schrieb Joao S:
> One other thing, is it possible to get a little bit more of information in the progress dialog besides de progress
> bar? Tasks description, maybe subtasks, etc..
Generally yes. But in the context of a commit(monitor) call we must transport all monitoring-relevant information over
the network. I never considered it that important (compared to the induced performance and bandwidth issues).

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Show Progress Monitor on commit [message #1004703 is a reply to message #1004014] Wed, 23 January 2013 17:43 Go to previous message
Joao S is currently offline Joao S
Messages: 51
Registered: January 2011
Member
Quote:
Generally yes. But in the context of a commit(monitor) call we must transport all monitoring-relevant information over
the network. I never considered it that important (compared to the induced performance and bandwidth issues).


Got it, thanks =)

Joao
Previous Topic:EMF Compare bugzilla change
Next Topic:Can it has bidirectionl sychronization?
Goto Forum:
  


Current Time: Fri Oct 24 18:14:53 GMT 2014

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

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