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 json.org 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.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
out.write(payload.toString());
out.close();
                         
//Now get the response
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                	
String n = in.readLine();
StringBuffer sbValue = new StringBuffer();
                	
while(n != null){
	sbValue.append(n);
	n = in.readLine();
}
in.close();
                	
final String value = sbValue.toString();
Advertisements

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 Eclipse.org 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:

juno-splash