Using Watson Translation service in an Eclipse SWT application Part 2

The next follow-up to the last article is the code I used to communicate with the Watson Translation service. But first I want to show the flow of the data:

So basically the SWT client sends a JSON string to the server in the body of the message. You can do this as long as you specify application/json as the Content-Type. For JSON, I use the JSON library for Java over at and its been perfect. I have even begun using this library for all of my in memory objects because then I can easily serialize it out for storage or over the network.

Below you will see the primary code to send this message:

JSONObject payload = new JSONObject();
payload.put("toLang", obj.get("to"));
payload.put("text", obj.get("text"));
URL url = new URL(pet_bluemix_translation_service);
URLConnection connection = url.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
//Now get the response
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String n = in.readLine();
StringBuffer sbValue = new StringBuffer();
while(n != null){
	n = in.readLine();
final String value = sbValue.toString();

Using Watson Translation service in an Eclipse SWT application

Image (3) flow-680x156.png for post 5379

In this video I show how I used Watson Translation services in IBM Bluemix to translate an entire catalog of products and categories. I used a simple Node-Red flow to achieve this with little programming on the server-side.

2015 Lunar Eclipse with a blood moon pictures

Last night my son Nathan and I used the telescope and an iPhone 6 to take pictures of the eclipse and then the following blood moon. They came out pretty good but my brother Tom (who owns Balfe’s photography) took even better ones! Check out the pictures below:

Eclipse and SWT to the rescue

For the past week or so I have been able to do some Eclipse and SWT programming. I have a tool here for technical sellers written in Java and what has been requested for a couple of years is a front end UI to that tool. One thing that really stuck out was the Window Builder and the information on the internet. You see, when I started Eclipse development it was very new. Unless you knew where to look it was often difficult to find answers or great examples. Almost 13 years later and its a very different story.

window_builderFirst off, Window Builder is amazing, it works, and the amount of functionality in it is very impressive. I remember early on with was pretty bug ridden and we ended up coding by hand. Now, you can do all kinds of really cool things right in the user interface. I was able to completely use the WindowBuilder editor for all of my windows and dialogs – piece of cake! I especially like the Menu and Table editors – makes creating these things a snap.

Next, I have to mention the internet, StackOverFlow, and all of the blogs and articles out there. It seems no matter what I search for someone has written about it or asked about it. Great job Eclipse Community!.

CKEditor comes to the Eclipse platform!

I am not sure if this is the first time the CKEditor has been ported to the Eclipse platform but today I noticed on the marketplace site there is a new plugin for editing HTML files using the CKEditor. I do know years ago we considered doing this for the Lotus Notes client. This also means if you bundle this feature with your RCP application you can also have the CKEditor!

Screen Shot 2013-11-25 at 10.16.46 PM

What I really like about the way this plugin is bundled is it actually uses the CKEditor directory structure as is. Meaning, you can enhance the editor with its own plugins if you want. Sort of like a plugin within a plugin.

Screen Shot 2013-11-25 at 10.22.09 PM

Great job to Konstantin Zaitcev for getting this done!

Eclipse and Java in schools oh my!

juno-splashHave you ever had your child come to you with school work and feel like, “wow, I have no idea how to do that” or you have to read the chapter to remember how to do something? Well for the first time in a long time I was able to whip an answer out in seconds. I get a text from my son asking if I can help him and his friend with some college homework and he mentions they are Eclipse questions. My first thought was “wow, they are using Eclipse in school?”. And I was correct, they are using Eclipse and even programming in Java! I was pretty shocked but apparently after scouring the internet a lot of colleges are now using Java and Eclipse.

Continue reading

What’s new in Eclipse Juno?

juno-iconFinally got around to installing Eclipse Juno. It has the long anticipated E4 modules that I was playing with a couple of years ago. Check out the E4 page to learn about the underlying SDK.

First off, it has a new shiny logo (on the right) and a pretty cool looking splash screen, see below.

I was able to simply download the zip file and run it! I installed the 64bit for Java EE Developers, check out the page here. You have to love that install model – so simple. I even loaded my older workspaces and everything “just worked”. The entire UI has pretty much been revamped with a lot of little goodies spread throughout. Here is a list of some of my favorite features:

  • The new UI
  • Multi-drag sash
  • Detached Editors
  • Flexible part layout – You can now mix views and editors!
  • The common event bus – very cool, check out the plugin page for “what’s new”. You can also check out the new event model here.
  • Trim styling, since the UI is based on CSS, you can do some pretty slick things now.

Check out the new splash screen:


Gamification for coders, how cool would this be?

After some dialog with Facebook friends I thought it would be entertaining to write this post. Imagine an extension to Eclipse that connects to a leader board where you can see what “badges” coders are awarded through daily coding. While this is just for fun, I actually think this could end up being valuable in the end. Similar to the way people +1 your skills on LinkedIn, this could give anyone a very good idea of your skills.

Continue reading

Eclipse SWT ImageData to the rescue for image resizing!

A little side project I have here at work has taken a life on of its own. Most recently with the launch of the new Aurora storefront I once again enhanced an internal tool to automatically size product images to adhere to the size requirements for the store. I ended up using Eclipses SWT (The Standard Widget Toolkit) that comes with Eclipse to do this. What I wanted to share today was how easy this was using the SWT API’s.

Continue reading

Work life balance and my current side project

After reading this blog post I realized I am very similar in mindset as the author. I pretty much always have a side project, whether it is for my real job or one of my hobby projects I have written about on this blog. I do think the “best” employees in a technical role are the ones who are always playing. Playing with technology, concepts, API’s etc. The idea is the breadth of the individual grows and has ancillary benefit to their primary job. This has certainly been true for me throughout my entire career.

I remember I was in a client meeting and they expressed the desire to use Drupal as a content management. Because of my several side projects with Drupal, going through several versions of the system, and knowing in depth what it can and can’t do I was very prepared to argue both for and against the idea.

My latest project is something that has also had great benefit in my current job – mainly because I knew there was “a better way” to do this when I started creating demos. I started a project called PET (product extractor tool) that can pull products from an existing web site and then import those products, images, prices, etc into a WebSphere Commerce database. This allows us to create proof of concepts for customers using a familiar product set, product attributes, and terminology in scenarios the customer can understand (ie. speak their language). Prior to PET it could take days if not weeks creating products and all of the surrounding data around them – it really depended how detailed your scenarios were. A heavy focus in the commerce space is navigation and specifically faceted navigation (those options on retail sites down the left that let you narrow down your search results). As you can imagine, creating a full product set with many attributes could be daunting. Not to mention price lists and then inventory – if you have to show that.

I have recently modified the tool to export a set of XML files for Sterling Order Management. This means the same PET model can now be used for both WebSphere Commerce and Order Management – essentially making integrated proof of concepts between the two systems seamless (at least that is the current theory). I am still working on it but it is getting there. Because I used object oriented programming I simply use the same object model PET built from the HTML and pipe that model out as XML versus comma delimited files.

I still have a bit to go with this tool but the point of this post is I am now getting extremely familiar with the Sterling Order Management side of the equation. Diving on the underlying data model and the service API’s to get information in and out of the system.