Welcome!

Java IoT Authors: Greg Schulz, Elizabeth White, Liz McMillan, Bob Gourley, Antonella Corno

Related Topics: Java IoT, Open Source Cloud, Eclipse

Java IoT: Article

Ship Happens! Insights From the Eclipse SWT Community

Insights from the SWT community

The Standard Widget Toolkit (SWT) is the GUI toolkit used by Eclipse. The same folks that worked on the Common Widget (CW) library for IBM/Smalltalk developed it, this time for Java. Now, it's maintained as part of the Eclipse Platform project and distributed under an open source license, the Eclipse Public License (EPL). One key design point of SWT is that it uses native functionality on each operating system and, at the same time, presents a common, portable API. Joe Winchester, Desktop Java Editor for Java Developer's Journal, asked Steve Northover (SWT Team Lead) recently whether he'd be happy to answer some questions about SWT and, after talking to his colleagues and a few developers, here is the result.

JDJ: SWT supports many different widget toolkits with a common programming API. What's the hardest thing about making all this work?

Steve: Specifying an API that can be implemented natively on a variety of different platforms is very challenging. If you make the wrong choice, you end up with API that is difficult or impossible to implement. To avoid this problem, you need to approach API design with an open mind. Smart programmers want to get the job done and don't care too much about how they do it. Our goal is to get out of the way and get functionality to the programmers. We've been pretty successful doing this and keeping the API reasonable at the same time.

For the implementation, complexity becomes a big issue. It's easy to die the death of 1000 cuts, implementing a native widget toolkit. A sure way to do this is to over-engineer things. We often use the "just do the work" pattern (a favorite of mine). Given two solutions to a problem, I will always choose the one with the fewest classes and lines of code.

Carolyn: The hardest thing is saying "no" to some of the features. Implementation-wise, though, the "devil is in the details."

Silenio: Sometimes it's hard to keep the behavior of the widgets consistent between platforms and still have platform-specific features. For example, on the Macintosh the menu bar is detached from the shell, which is quite different from the other platforms. We needed to come up with a consistent way of integrating this Macintosh feature into the API.

JDJ: When you're dealing with a feature that must be built to work across the different implementations, you have a choice between doing the lowest common denominator, or something you do natively on some platforms and emulated on others. When do you decide which to use, and do you regret any of these decisions?

Steve: There is no decision. If the operating system offers a feature, we make use of it. There's nothing to regret either. We just go ahead and implement whatever is necessary and move on to the next problem.

I'd like to talk about "lowest common denominator" for a minute though. Lowest common denominator is kind of a negative statement. A more positive way to think about it is "highest common multiple." The operating systems provide a lot of functionality that's common, but the native API is different. We expose this functionality, raising the bar rather than lowering it.

JDJ: Do you wish you'd used a different API as your base rather than the Windows one, in particular the way in which window parents can't be changed after construction? For example, if this feature became supported in Windows in the future, it might seem a bit of SWT legacy, whereas if you'd coded reparenting in the C code that SWT sits on top of, you could provide a higher level of API. AWT, for example, allows reparenting by having a wrapper around the peer that can recycle the underlying widget.

Steve: First, I'd like to challenge the notion that SWT is based on the Windows API. It isn't. If you go to MSDN, find the documentation for something like TreeView32 or HDC and check out the SWT API that makes use of these things - you'll see it doesn't look anything like the Windows API. People might get this idea from things like style bits that are found on Windows, but many things in SWT are patterned after other operating systems. For example, the keyboard and mouse API is based on X. We are familiar with many different windowing systems and make API decisions keeping all of them in mind.

Back to reparenting: it's X/Motif that doesn't allow the parent to be changed after a widget is created, not Windows. Whether you are coding in Java, C, or both, either the operating system supports reparenting or it doesn't. If the operating system doesn't support this feature, hiding it in a peer layer doesn't really help that much (actually, it makes it worse because it increases the complexity of the toolkit implementation and adds a level of indirection).

Carolyn: By not having peers, we simplified the toolkit tremendously. Also, peers are somewhat slower and take up more space. And setParent() [mostly] works.

JDJ: What's your favorite native platform to work with, and which do you most loathe having to code on?

Silenio: My favorite platform to work with is the one I have been working on most at the moment. That's because it's the platform I understand best and I can achieve faster results.

Carolyn: Windows has the best doc, so that makes it "friendlier" to work with. We use Google for GTK doc. I don't loathe coding on any of the platforms - the variety is what makes it interesting.

Kevin: Every platform presents unique challenges to SWT so it's difficult to single out any as being better or worse than the others. My favorite platform really depends on the problem that I'm trying to solve.

JDJ: At JavaOne you were walking around with the letters 67384 tatoo'd on your arm. What's the story behind this particular bug?

Florian: SWT contains a piece of code called the SWT_AWT bridge that lets you embed an AWT/Swing component in an SWT shell and vice versa. Prior to 3.2, this didn't work on the Mac due to architectural difficulties. Basically, SWT uses the Carbon API while AWT is implemented in terms of Cocoa, with implications on how UI events are handled. Making the event threads of the two widget toolkits cooperate smoothly and avoiding deadlocks proved to be a rather tricky issue that required changes to both SWT and Apple's Java implementation. The discussion about all of this took place in the aforementioned bug report and spanned a ton of comments from various users. While some people vented their frustration or put forth conspiracy theories, others actually presented ideas on how to fix the problem. In the end, Scott Kovatch, an excellent engineer at Apple, worked out and implemented the necessary steps in cooperation with the SWT team, allowing us to finally mark that bug as "RESOLVED FIXED". Obviously everyone is very happy about that. One user on the bug report even went as far as articulating his excitement over the fix in a rather unique way. For more details, see Bugzilla.

Steve: Although Eclipse and most other SWT applications didn't use AWT/Swing, there were some applications that did and this was holding them back. I hate that because we take pride in helping people ship, not telling them which technology they should use. SWT normally integrates really well with native code but the Mac supports only one GUI thread and both toolkits expected to have their own. That was the technical issue. Somehow, Scott and Silenio got it to work.

Carolyn: "SWT_AWT not implemented for Mac" https://bugs.eclipse.org/bugs/show_bug.cgi?id=67384#c170. It was very exciting to have this one fixed...

JDJ: What's the story behind the naming of the classes CoolBar and CoolItem?

Steve: They're cool. Personally, I hate them.

Carolyn: That's what Microsoft called them. (I know, their control is called a "Rebar," but they used the term CoolBar when describing the control. See this article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_rebar.asp.)

Silenio: Usually when we add a new widget to the toolkit, we decide its name by taking into consideration the names used by all platforms as well as our own ideas. We choose the one that best describes the widget and that's most known by everyone. In this particular case, there were two main options: CoolBar (MFC) and ReBar (Win32). I must admit that CoolBar is strange, but it's a bit better than the other option.


More Stories By Joe Winchester

Joe Winchester, Editor-in-Chief of Java Developer's Journal, was formerly JDJ's longtime Desktop Technologies Editor and is a software developer working on development tools for IBM in Hursley, UK.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Vince Marco 03/11/07 05:43:41 PM EDT

> Carolyn: You have to get an interface exactly right the first time,
> because you can't change it without breaking binary compatibility.

Exactly how is this different with classes? API is an exact contract, whether it is done through interface or class (abstract or concrete). As a developer I can either depend upon the API or I can't. API management is difficult, period. And yet it must be done or we have to throw out everything for a whole new framework every so often. The difference is that with interfaces I can separate out dependence on how to do something (the API) from the implemented behavior.

Good discussion, BTW.

@ThingsExpo Stories
SYS-CON Events announced today that CA Technologies has been named “Platinum Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY, and the 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business – from apparel to energy – is being rewritten by software. From ...
Web Real-Time Communication APIs have quickly revolutionized what browsers are capable of. In addition to video and audio streams, we can now bi-directionally send arbitrary data over WebRTC's PeerConnection Data Channels. With the advent of Progressive Web Apps and new hardware APIs such as WebBluetooh and WebUSB, we can finally enable users to stitch together the Internet of Things directly from their browsers while communicating privately and securely in a decentralized way.
"A lot of times people will come to us and have a very diverse set of requirements or very customized need and we'll help them to implement it in a fashion that you can't just buy off of the shelf," explained Nick Rose, CTO of Enzu, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm.
You think you know what’s in your data. But do you? Most organizations are now aware of the business intelligence represented by their data. Data science stands to take this to a level you never thought of – literally. The techniques of data science, when used with the capabilities of Big Data technologies, can make connections you had not yet imagined, helping you discover new insights and ask new questions of your data. In his session at @ThingsExpo, Sarbjit Sarkaria, data science team lead ...
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform and how we integrate our thinking to solve complicated problems. In his session at 19th Cloud Expo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and sh...
Big Data, cloud, analytics, contextual information, wearable tech, sensors, mobility, and WebRTC: together, these advances have created a perfect storm of technologies that are disrupting and transforming classic communications models and ecosystems. In his session at @ThingsExpo, Erik Perotti, Senior Manager of New Ventures on Plantronics’ Innovation team, provided an overview of this technological shift, including associated business and consumer communications impacts, and opportunities it m...
WebRTC is about the data channel as much as about video and audio conferencing. However, basically all commercial WebRTC applications have been built with a focus on audio and video. The handling of “data” has been limited to text chat and file download – all other data sharing seems to end with screensharing. What is holding back a more intensive use of peer-to-peer data? In her session at @ThingsExpo, Dr Silvia Pfeiffer, WebRTC Applications Team Lead at National ICT Australia, looked at differ...
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo 2016 in New York. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place June 6-8, 2017, at the Javits Center in New York City, New York, is co-located with 20th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry p...
SYS-CON Events announced today that IoT Now has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. IoT Now explores the evolving opportunities and challenges facing CSPs, and it passes on some lessons learned from those who have taken the first steps in next-gen IoT services.
SYS-CON Events announced today that WineSOFT will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Based in Seoul and Irvine, WineSOFT is an innovative software house focusing on internet infrastructure solutions. The venture started as a bootstrap start-up in 2010 by focusing on making the internet faster and more powerful. WineSOFT’s knowledge is based on the expertise of TCP/IP, VPN, SSL, peer-to-peer, mob...
The Internet of Things can drive efficiency for airlines and airports. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Sudip Majumder, senior director of development at Oracle, discussed the technical details of the connected airline baggage and related social media solutions. These IoT applications will enhance travelers' journey experience and drive efficiency for the airlines and the airports.
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
WebRTC sits at the intersection between VoIP and the Web. As such, it poses some interesting challenges for those developing services on top of it, but also for those who need to test and monitor these services. In his session at WebRTC Summit, Tsahi Levent-Levi, co-founder of testRTC, reviewed the various challenges posed by WebRTC when it comes to testing and monitoring and on ways to overcome them.
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settle...
In his session at @ThingsExpo, Steve Wilkes, CTO and founder of Striim, will delve into four enterprise-scale, business-critical case studies where streaming analytics serves as the key to enabling real-time data integration and right-time insights in hybrid cloud, IoT, and fog computing environments. As part of this discussion, he will also present a demo based on its partnership with Fujitsu, highlighting their technologies in a healthcare IoT use-case. The demo showcases the tracking of patie...
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
SYS-CON Events announced today that Cloud Academy will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud computing technologies. Ge...
20th Cloud Expo, taking place June 6-8, 2017, at the Javits Center in New York City, NY, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy.