Archive for October, 2012

Java FX HTML Editor in Eclipse!

I did not care about JavaFX, Because It did not support OSX, and there was no legal OSGi bundle for it.

Now, JDK7 shipped with JavaFX, So there is no bundle problem anymore. JDK7 for OSX is also available now. And I heard that Oracle provides Embedding API for SWT.

So I’v tried to make a HTML Editor for Eclipse using JavaFX.

I could make a HTML WYSIWYG Edtior which supports HTML5/CSS3. Codes were unbelievably easy and short.

See in HD to improve readability.


Source codes(part):

<pre>public class HtmlEditor extends EditorPart {

	public void createPartControl(Composite parent) {
		canvas = new FXCanvas(parent, SWT.NONE);
		editor = new HTMLEditor();
		Scene scene = new Scene(editor);

		IDocument doc = documentProvider.getDocument(getEditorInput());

		editor.setOnKeyPressed(new EventHandler() {
			public void handle(KeyEvent event) {

I think we can use JavaFX Scene graph as a view of GEF too. It must be cool! It provides very high quality rendering results with performance. I will challenge this later.

Categories: JavaFX, SWT

Dark Side of SWT, #1 Peer Communication

2012/10/22 1 comment

I began JAVA since 1995, And I loved Swing then SWT.

Now I am a big fan of SWT since 2002. And I have some worries about SWT that I want to share with you.


For long time, SWT is best solution for Java UI. The primary reasons are:

  • Native Look & Feel, Performance
  • JFace

Native Look&Feel, Performance

In early stage of Java, Standard UI for Java, AWT was very ugly and slow.

There was a big war around Java UI. Primary topic in the war was Unified Experience VS Native Experience.

  • Unified Experience, Same Look&Feel in all kind of platform: Swing
  • Native Experience, Native Look&Feel in each platform: AWT, SWT

Since one of primary philosophy in Java is “Write once run everywhere(in same way!)”, Sun raised hand of Amy Fowler who is leader of Swing, and denied standard proposal of SWT. (I think actual reason is little bit different. Hint: Sun developed NetBeans.)

All UI Objects in SWT are just proxies to OS’s UI Objects. So application looks very harmonious with their native OS because all UIs are actually native. It is why do we have to dispose SWT Resources and Widgets.

In other words, It is working slightly different for each platform. ex:

  • In OSX, Closing shell not dispatching focus out or modify event from text field in shell
  • In OSX, Buttons can’t take keyboard focus, So what if some wizard page contains only buttons, it can’t have context help.
  • In windows 95, Adavnaced Graphics may not work
  • … and so many things …

You have to test every platform what if you have choose SWT.

Behavior of widgets are handled by Native OS, ex: expanding/collapsing tree. So it is very fast. SWT translates Native Events to SWT Events(Display#readAndDispatch), So developer can extend behavior of widgets using Java.


JFace is most elegant and easy, and well designed library for UI. JFace provides awesome MVC patterns for SWT. So SWT can stay very simple and low-level. Most good experience of Eclipse Application are came with JFace. Swing is much more complex then SWT because there is nothing likes JFace.

JFace is also good tutorial or guide about how to use SWT smart. It’s big heritage.

Peer communication: Is it really fast?

SWT translates messages between Java and OS world. It called as “Peer Communication”. In General, Peer communications between different machine are very slow since it requires:

  • Synchronization
  • Data conversion

When you commit a command through SWT, SWT translate it and send to OS. OS will work what you ordered. What if amount of work is larger than cost of peer communication, It’s Okay. In other case, It’s not.

In general, OS doing not much since almost controllers are written with Java in SWT. When you click the button, OS generate event, SWT will translate it and dispatch, Java Listener will do some job.

AWT’s Peer communication uses same strategy, buy it is very buggy and slow because they tried to accomplish Write Once Run Everywhere. So communications costs much than SWT. But, Natives are natives, differents are differents. So it was failed.

Example of terrible peer communication performance

public class Example {
   public static void main(String[] args) {
      long start = System.currentTimeMillis();
      Display display = Display.getDefault();
      Image image = new Image(display, 640, 480);
      GC gc = new GC(image);
      for(int x=0; x<640; x++){
         for(int y=0; y<480; y++){
            gc.drawPoint(x, y);
      long elpasedTime = System.currentTimeMillis() - start;
      System.out.println("done:" + elpasedTime);

It fills red pixels into a 640*480 image using SWT. It costs more then 2000 milliseconds! Because Line 12 cause Peer Communication 307,200 times!

How about this, Let replace line 10~14 to below:

gc.fillRectangle(0, 0, 640, 480);

It costs about 300 milliseconds now. They are semantically same task but peer communications are reduced. There was a big difference in performance.

Someone may think first example is too inefficient to compare, see next.

Remove Peer Communication

public class Example {
   public static void main(String[] args) {
      long start = System.currentTimeMillis();
      PaletteData palette = new PaletteData(0xff0000, 0xff00, 0xff);
      ImageData data = new ImageData(640, 480, 32, palette);
      RGB red = new RGB(255, 0, 0);
      for (int x = 0; x < 640; x++) {
         for (int y = 0; y < 480; y++) {
            data.setPixel(x, y, palette.getPixel(red));
      long elapsed = System.currentTimeMillis() - start;
      System.out.println("done:" + elapsed);

This codes are exactly same with first example except there is no peer communication since PaletteData, RGB and ImageData are pure java objects.

It costs only 193 milliseconds. And this code can be executed in Non-UI thread. So we don’t have to block UI when we create images.

We know Reducing peer communication or eliminating peer communication is very important topic to develop UI Applications with SWT now. However, in many case, We can’t reduce peer communication. Consider situation that we have to update all TreeItems by it’s model change. We have to perform below codes for all TreeItems:

TreeItem item = ...;
Model model = item.getData();

Number of peer communications are increased as count of tree items. It’s a reason for that why TreeViewer#refresh() is so slow.

In this case, We can use Deferred Update Strategy, Lazy Content Providing or Virtual FLAG to improve performance. But these techniques are pretty tough to developers.

Lightweight UI

In these days, Swing is super fast since it uses GPU. Native performance is not important anymore since native behavior is tend to be smaller than actual business task or rendering codes. And almost machine has it’s own GPU.

For instance, GEF needs to manipulate very complex UI without Peer Cost, So they developed Draw2d(light-weight, Pure Java UI Library which is rendered on FigureCanvas). So we can use various UIs without loosing performance in GEF Editors.

Figures in Draw2D are almost same with Swing. Swing UIs are rendered by JVM, Figures in Draw2d are rendered by FigureCanvas(LightWeightSystem). So there are no peer cost.

(Actually Figure Canvas uses Native GC when it render, So it uses peer communications. But Figure Updater optimizes this context to reduce peer communication. Defining or manipulating UI elements are toll free! not like SWT)

For same purpose, Nebula provides some widgets like Grid. It can takes massive amount of model and massive number of UI elements.


SWT is fast? Yes! and No!! You have to care about peer communication to make your application support massive scale.

Categories: SWT Tags:

Make System.out.println() Rocks!

2012/10/18 15 comments

System.out.println() is very strong and useful debug tool for long time.
The problem is that we tend to don’t remove this code after we debug.

What if do we have a lots of codes which we forgot to remove, finally debug messages can be useless trashes.
But tracing location of println() code is very difficult since we can’t use break points on system console stream.

So, Here is a cool solution:

 * @author Jeeeyul 2011. 11. 1. 오후 4:36:51
 * @since M1.10
public class DebugStream extends PrintStream {
   private static final DebugStream INSTANCE = new DebugStream();

   public static void activate() {

   private DebugStream() {

   public void println(Object x) {

   public void println(String x) {

   private void showLocation() {
      StackTraceElement element = Thread.currentThread().getStackTrace()[3];
      super.print(MessageFormat.format("({0}:{1, number,#}) : ", element.getFileName(), element.getLineNumber()));

Just call DebugStream.activate() when your application start.

It converts messages in console view from:

Hello World.


( : Hello World.

Yes, you can click and jump to your System.out.println() code in Eclipse console view. It makes debugging so easy.

Categories: Eclipse, Java

Make your IDE more Awesome with PDE-Tools

2012/10/16 12 comments

이 문서는 한국어 버전이 제공됩니다.

I developed commercial Eclipse plugins for 5 years. With this experiences, I made a tools which helps Eclipse Plugin Developers for me and my team.

And I call it “PDE-Tools“, And I love to share this tool to you.

Let me introduce features:

Clipboard History

You don’t have to waste time anymore to just keep current clipboard contents. (Many people doing this)

Just press Control + Shift + V instead of Control + V, then you can paste contents from history of Clipboard.

It supports RTF contents, and It also provides view which supports DND. You can customize various options(sort order, acceptance style).

Icon Preview

It’s pretty insightful function. It just allows to you see icons with your favorite navigator. It’s fast and light-weight, content change sensitive.

Shared Image Generator

This is my favorite feature of PDE-Tools. It generates SharedImages class with given monitored folder. It also supports structural palette according to sub folders.

  1. Select a plugin project, and press right mouse button.
  2. Select “Configure > Enable Shared Image Generator”
  3. That’s all

It also generates icon preview in Java doc, and it also supports Graphiti Image Provider, Re-factoring.

Bundle Image Navigator

Bundle Image View lets you can re-use eclipse image resources. Just drag them into your project.

Wokspace Launcher

This feature is very useful to OSX users. It adds “Launch Workspace” menu below “Switch Workspace”. So you can easily launch another workspace without quitting current one.

Crazy Outline

This cute crazy view provides insightful way to navigate source code.

Snapshot tool (WIP)

You can find small camera on toolbar, It allows you to capture part or toolbar easily. With Ctrl(or command) key, you can capture entire shell with Shadow.

It is very useful when you write some manual about your plugins. It also supports cute camera flash animation and shutter sound 🙂


  1. open market place client (press Ctrl + 3, and type marketplace)
  2. type “Jeeeyul” into search field.
  3. press “install” button next to “PDE-tools”


Categories: My Product

Jeeeyul’s Eclipse Themes – Chrome supports Juno SR1

2012/10/09 1 comment

I created an alternative theme for Eclipse Juno 3 months ago, Now it supports Juno SR1 fully.

  • You can customize very many things in lightweight.
  • Inelegant drag handle for perspective switcher is removed.
  • Much more harmonious drag handles with your configuration.
  • Space next to Quick Access has integrated under line.
  • See more from project page on github.

This update also contains enhancement for Linux:

  • Inelegant image stretching for drag handle was removed.

Categories: e4, My Product