Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[graphiti-dev] Improvement request: execute a feature in an asynchronous job

Hi,

At some point our projects have Graphiti custom features which can take some time to finish (depending on the diagram size). In the basic CustomFeature context, execution of such features freezes Eclipse GUI. We wanted to:
 1. Run it asynchronously
 2. Be able to provide progress information to user

To achieve that, we tried to execute the feature in a Job instance. But to be able to perform updates on models, we had to define and execute a RecordingCommand in the Job. Indeed, the CustomFeature only schedule it and ends before this Job has really finished.

Please find the abstract class we wrote to get rid of these issues on http://pastebin.com/XBjmy2sP

Information about this feature:
- it defines a new execute(ICustomContext, IProgressMonitor) abstract method - it set other execute() methods to final, to prevent users from overriding it - hasDoneChange() always returns false, since the feature itself does nothing but launching the Job. This ensures only 1 command will be added on the CommandStack after the full execution - getDiagramBehavior().getDiagramContainer().updateDirtyState(); is executed just after the inner command, to update diagram state only when it has been executed

The example code I provides is probably redundant (run a command in a job in a command) but this is maybe the best I can do from a user point of view. I don't have enough skills to hack Graphiti source by myself, so I give you the code. Maybe it will be useful for users to be able to define some CustomFeature to be asynchronous and to use a IProgressMonitor. At least, having this by default in Graphiti SDL could be helpful for us ;)

Best regards,

Antoine Lorence

--
INSA de Rennes - Département EII
IETR - Groupe Image

Bureau 214 - Bat. 10
20, Avenue des Buttes de Coësmes
CS 70839
35708 Rennes Cedex 7



Back to the top