Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 16:06
Andy Maleh is currently offline Andy MalehFriend
Messages: 75
Registered: March 2020
Location: Montreal, Quebec, Canada
Member
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!


EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT

[Updated on: Tue, 23 February 2021 20:36]

Report message to a moderator

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


Current Time: Mon May 06 23:15:35 GMT 2024

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

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

Back to the top