Welcome!

Java IoT Authors: Elizabeth White, Yeshim Deniz, Sanjeev Khurana, Carmen Gonzalez, Patrick Hubbard

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.
SYS-CON Events announced today that HTBase 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. HTBase (Gartner 2016 Cool Vendor) delivers a Composable IT infrastructure solution architected for agility and increased efficiency. It turns compute, storage, and fabric into fluid pools of resources that are easily composed and re-composed to meet each application’s needs. With HTBase, companies can quickly prov...
SYS-CON Events announced today that Outlyer, a monitoring service for DevOps and operations teams, has been named “Bronze 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. Outlyer is a monitoring service for DevOps and Operations teams running Cloud, SaaS, Microservices and IoT deployments. Designed for today's dynamic environments that need beyond cloud-scale monitoring, we make monitoring effortless so you ...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place 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. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex softw...
In his General Session at 17th Cloud Expo, Bruce Swann, Senior Product Marketing Manager for Adobe Campaign, explored the key ingredients of cross-channel marketing in a digital world. Learn how the Adobe Marketing Cloud can help marketers embrace opportunities for personalized, relevant and real-time customer engagement across offline (direct mail, point of sale, call center) and digital (email, website, SMS, mobile apps, social networks, connected objects).
SYS-CON Events announced today that Hitrons Solutions will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Hitrons Solutions Inc. is distributor in the North American market for unique products and services of small and medium-size businesses, including cloud services and solutions, SEO marketing platforms, and mobile applications.
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, will discuss some of the security challenges of the IoT infrastructure and relate how these aspects impact Smart Living. The material will be delivered i...
Your homes and cars can be automated and self-serviced. Why can't your storage? From simply asking questions to analyze and troubleshoot your infrastructure, to provisioning storage with snapshots, recovery and replication, your wildest sci-fi dream has come true. In his session at @DevOpsSummit at 20th Cloud Expo, Dan Florea, Director of Product Management at Tintri, will provide a ChatOps demo where you can talk to your storage and manage it from anywhere, through Slack and similar services ...
SYS-CON Events announced today that Cloudistics, an on-premises cloud computing company, has been named “Bronze 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. Cloudistics delivers a complete public cloud experience with composable on-premises infrastructures to medium and large enterprises. Its software-defined technology natively converges network, storage, compute, virtualization, and management into a ...
Keeping pace with advancements in software delivery processes and tooling is taxing even for the most proficient organizations. Point tools, platforms, open source and the increasing adoption of private and public cloud services requires strong engineering rigor - all in the face of developer demands to use the tools of choice. As Agile has settled in as a mainstream practice, now DevOps has emerged as the next wave to improve software delivery speed and output. To make DevOps work, organization...
My team embarked on building a data lake for our sales and marketing data to better understand customer journeys. This required building a hybrid data pipeline to connect our cloud CRM with the new Hadoop Data Lake. One challenge is that IT was not in a position to provide support until we proved value and marketing did not have the experience, so we embarked on the journey ourselves within the product marketing team for our line of business within Progress. In his session at @BigDataExpo, Sum...
SYS-CON Events announced today that Ocean9will 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. Ocean9 provides cloud services for Backup, Disaster Recovery (DRaaS) and instant Innovation, and redefines enterprise infrastructure with its cloud native subscription offerings for mission critical SAP workloads.
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.
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend @CloudExpo | @ThingsExpo, June 6-8, 2017, at the Javits Center in New York City, NY and October 31 - November 2, 2017, Santa Clara Convention Center, CA. Learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
SYS-CON Events announced today that T-Mobile 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. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on ...
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
SYS-CON Events announced today that CrowdReviews.com 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. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buyers...
The taxi industry never saw Uber coming. Startups are a threat to incumbents like never before, and a major enabler for startups is that they are instantly “cloud ready.” If innovation moves at the pace of IT, then your company is in trouble. Why? Because your data center will not keep up with frenetic pace AWS, Microsoft and Google are rolling out new capabilities In his session at 20th Cloud Expo, Don Browning, VP of Cloud Architecture at Turner, will posit that disruption is inevitable for c...
SYS-CON Events announced today that Infranics 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. Since 2000, Infranics has developed SysMaster Suite, which is required for the stable and efficient management of ICT infrastructure. The ICT management solution developed and provided by Infranics continues to add intelligence to the ICT infrastructure through the IMC (Infra Management Cycle) based on mathemat...