Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Run a long feature with a ProgressBar
Run a long feature with a ProgressBar [message #1311085] Wed, 23 April 2014 15:38 Go to next message
Antoine Lorence is currently offline Antoine LorenceFriend
Messages: 3
Registered: September 2013
Junior Member
In our project, we have 2 or 3 custom features very important but sometimes long to run (depending on the diagram). This is not a problem, but user often think eclipse is crashing, when the feature is simply doing its job. To avoid that, we want to display a progress bar (we don't care the way to do that).

I tried to perform that with IRunnableWithProgress / ProgressMonitorDialog.
@Override
public void execute(ICustomContext context) {

	IRunnableWithProgress theTask = new IRunnableWithProgress() {

		@Override
		public void run(IProgressMonitor monitor)
				throws InvocationTargetException, InterruptedException {

			monitor.beginTask("My cool feature", 10);

			bigAndLongWork(monitor);

			monitor.done();
		}
	};

	try {
		new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay()
				.getActiveShell()).run(true, false, theTask);
	} catch (InvocationTargetException e) {
		e.printStackTrace();
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}

(full code on Github gists: alorence/11219910, sorry I can't post links)

Obviously, it works with simple code, but fails with a RollbackException "Transaction aborted due to concurrent write" if I modify models in the feature (and we do it ;))

Is there a way to run a Command in the editing domain (or any other solution) with a progress monitor we can update to inform user that the job is running, and the IDE is not dead ?

[BONUS question] In some case, the GUI freeze because our computations can become really heavy. Is it possible to run this job asynchronously, with a progress bar ?
Re: Run a long feature with a ProgressBar [message #1311511 is a reply to message #1311085] Wed, 23 April 2014 21:12 Go to previous message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
I just can give you some hints, but I dont know if it works for you...
If I can't edit the model due to write permissions I'll use this:
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(getDiagram());
ted.getCommandStack().execute(new RecordingCommand(ted) {

    @Override
    protected void doExecute() {
	//edit here				
    }
});


Well, I dont know if it fits into your async problem, but maybe that:

Display.getDefault().asyncExec(new Runnable() {
    public void run() {
        //edit						
    }
});


is able to fix it, good luck Wink

[Updated on: Wed, 23 April 2014 21:14]

Report message to a moderator

Previous Topic:Using RenderingStyles with nested ContainerShape
Next Topic:Remove resize handlers
Goto Forum:
  


Current Time: Wed Apr 24 15:19:43 GMT 2024

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

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

Back to the top