Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Display.syncExec in Threads is HISTORY in Glimmer DSL for SWT!!!
Display.syncExec in Threads is HISTORY in Glimmer DSL for SWT!!! [message #1838340] Mon, 22 February 2021 11:06
Eclipse UserFriend
One of the first things that surprised me in SWT when I first used for client work about a decade and a half ago was that when writing multi-threaded code, I could not update GUI with normal method calls, yet I had to use Display.syncExec (or asyncExec). This has plagued me for many years and I always felt that an appropriate solution was missing, waiting to be discovered and implemented.

Thankfully, these days are over since Glimmer DSL for SWT just had a relatively major release in version 4.18.5.0, fully enabling a new option called auto_sync_exec

It basically detects if you are in a thread other than the main GUI thread and automatically calls sync_exec (the JRuby method syntax) for you when invoking SWT widget methods through Ruby meta-programming interception (a form of Aspect Oriented Programming). Otherwise, if you are in the main GUI thread or inside a larger sync_exec or async_exec call, it behaves normally.

This is implemented through a new method called auto_exec, which gets called behind the scenes, but could be used explicitly too just like sync_exec in case you'd like to have SWT batch a number of GUI updates together within a single `sync_exec` call.

Here is the blog post announcement for this Glimmer DSL for SWT version, which mentions other things such as the Canvas Shape DSL and the Hello, Tree! sample demonstrating one-line data-binding of tree (unheard of before)

https://andymaleh.blogspot.com/2021/02/glimmer-dsl-for-swt-hello-tree-and.html

Quick Example of Tree Data-Binding in Glimmer DSL for SWT (just one line of declarative data-binding code per property):
tree {
  items bind(Employee, :ceo), tree_properties(children: :subordinates, text: :to_s)
  selection bind(Employee, :selected_employee)
}


https://1.bp.blogspot.com/-Xul-2MHlyd4/YDPIx8R5BKI/AAAAAAAABns/rkwjYHiiK1QWdALa6cCLvI42T6HTTPLIgCLcBGAsYHQ/s900/glimmer-hello-tree.png

Basically, Employee.ceo is the root node of the tree. Children are fetched via the subordinates method and tree node text is fetched via the to_s method.

Happy Glimmering!

[Updated on: Tue, 23 February 2021 15:36] by Moderator

Previous Topic:Scrolled Composite does not work in MultipageEditor
Next Topic:Mandelbrot Fractal with Glimmer DSL for SWT
Goto Forum:
  


Current Time: Tue Jul 01 03:48:14 EDT 2025

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

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

Back to the top