Sciology = Science + Technology

Commonsense in Technology

Archive for the ‘SWT’ Category

UI Designers dilemma !!!

Posted by sureshkrishna on December 7, 2007

Eclipse Visual Editor, NetBeans Matisse project and Instantiations SWT Designer are wonderful WYSIWYG editors that i have used till now. With few projects that i have done, i have always hand coded the UI’s. And of course i have done UI development on the Eclipse through out. So all the perspectives, views, editors, wizards, preferences and properties are hand coded and i am quite comfortable with it. I do agree that probably it takes more time for me to hand code but i feel “personally” satisfied.

When i discuss this with few of my colleagues, there are for and against the UI Designers. For me and many others, Layouts and adjusting the controls on the screen are the challenges. I do spend a lot of time in adjusting the controls in a layout.

Why they like UI Designers…

  •  UI can be build very very fast, without knowing whats in the code
  • With the advanced UI Designers, its easy to adjust/auto-adjust the Layouts
  • The easy-to-use drag-and-drop paradigm makes it easy to quickly visualize
  • Properties are set in the palette and the same is reflected dynamically on the UI preview
  • Control and Widget hierarchy is what many appreciate. I know precisely, which controls are in UI

Why they want to handcode…

  • I can code. I am a developer. I am used to it.
  • Code generated by UI Designers are not optimized. I want my code to be optimized.
  • Many a times, generated code is not readable to customize.
  • It might make me less creative and insecure, as i do not know whats happening at the code level.

I am sure many of us share some of the above views and you might definitely have great experience in building UIs. Its really interesting to know, if there are really more number of developers who would use UI Designers. For now i would stick to the hand-coding. Do share your experiences with the UI Designers …

Posted in Eclipse, Java, Net Beans 6.0, SWT | Tagged: , , , | 7 Comments »

How to position Eclipse Dialogs and Messages at ceter of screen.

Posted by sureshkrishna on September 5, 2007

I want to share a common issues that most of the UI programmers come across. When we program with lots of dialogs and messages in any kind of applications, for the usability and predictability we would want most of them to be centered to the screen. In many cases when we use constructors for Dialogs, MessageDialogs, etc… very often we pass newly constructed Shell.

e.g. MessageDialog.openInfo(new Shell(), “Hi This is a test Message Dialog.”);

In the above case remember that we have not specified any of the co-ordinates and often we see that it takes different coordinates depending on the number of times that we invoke it. And each time you invoke, you wonder where the dialog will appear. I have been using a simple solution that solves this issue… Hope some of you will be able to use this code right away. I hope the following code is self explanatory 🙂

I have tested this with all screen resolutions and on Windows XP and OSX.

* All dialogs and messages will be passed with the centered shell.
* @return Shell
public static Shell getScreenCentredShell() {
Display display = PlatformUI.getWorkbench().getDisplay();
Shell centreShell = new Shell(display);
Point size = centreShell.computeSize(-1, -1);
Rectangle screen = display.getMonitors()[0].getBounds();
centreShell.setBounds((screen.width-size.x)/2, (screen.height-size.y)/2, size.x, size.y);
return centreShell;

Posted in Eclipse, Java, Plug-ins, Plugin, RCP, SWT | 50 Comments »

org.eclipse.swt.SWTException: Unable to load graphics library [GDI+ is required] (java.lang.NoClassDefFoundError)

Posted by sureshkrishna on August 25, 2007

This is the SWTException that you might see on the W2K machine. This cause for this exception is absence of GDI+ library (gdiplus.dll) on Windows 2000. On WindowsXP and Vista they come by default and its taken care of.

Don’t be dis-hearted by this, you can download from Microsoft site and every thing should work fine. For those who want to have some additional information…〈=en&rss=ct2357lotus

Posted in Eclipse, Exceptions, Plug-ins, Plugin, PShelf, RCP, SWT, Uncategorized | 4 Comments »

Eclipse SWT Browser and Cross Browser compatibility

Posted by sureshkrishna on August 22, 2007

I have been using the Browser widget from past 1 year in my project which is targetted on AJAX and SOA kind of integration environments in Eclipse. As one can imagnine that the inbuilt browser capabilities are necessary on AJAX environement.

It was quite interesting in the initial stages to use the Browser and render the html and other widgets in the Windows environment. In time we moved on to the Linux and Mac OSX and then we had to really face some major challenges.

Especially the way Browser Widget renders the widgets on the Internal Browsers is weird. The same HTML DOM is rendered by an external browser in a different way on OSX and Linux and in external browser everything looks fine.

Some of the DOM rendering capabilities, Draggable events, etc…are kind of strange in the internal Browser. In that case the only thing we had to do was to support the External Browser invokation also when ever the internal Browser fails.

In the end becareful in “Why you want to use Browser Widget” and also “What you want to display” in it.

Posted in Browser, Eclipse, Java, Plug-ins, Plugin, RCP, SWT | 4 Comments »

At what level do you use eclipse ?

Posted by sureshkrishna on August 7, 2007

 Eclipse the ubiquitous platform has survived another challenge by releasing the Europa and i am already seeing the # of downloads. Initially it was Java IDE then RCP Platform then Tool Building Platform and now as i know its an eco-system of major frameworks, tools, runtimes and platform which can be extended for ANYTHING an NOTHING in particular. OK, i am not going to define what eclipse does and what not. The scope of my article is to highlight the problems i am solving with eclipse platform.
I have been using eclipse right from 2003 and built tools on Automotive Domain and Ajax&SOA Domain. I have been closely following the other implementations on different verticals. Several OEMs, ISVs, Startups, Universities and individuals have adopted the eclipse “principles” and they know what they are doing soon after they use it. All the content in this article is purely my personal views from my professional experience and do not correlate to any ones opinions dead or alive 😉
What can i do with Eclipse : I would want to start with highlighting the tasks which can be accomplished with eclipse. I am hoping that we will understand the differences between using the eclipse, developing the plugins, making an IDE out of eclipse and eclipse as an integration platform.

Eclipse an IDE
: This is what many of us know about the eclipse and what can it do. Its a Java IDE and java developers can create, modify, build the java projects in eclipse. It provides different features like code refactoring (one of the gr8 feature), syntax highlighting, syntax/code checks, code completion, code suggestions, compile, debug, jarring, etc… I have used for an year with out knowing what ELSE can eclipse do. In this use-case we are primarily involved in using the eclipse IDE features as is. I am sure that you are aware of different eclipse language ides like, JDT, CDT, Cobol, PHP editors amongst the most popular ones.
Eclipse Happy User.

Eclipse does Plugins : By this time you know that eclipse can be used to develop plugins and bootstrap in eclipse. Design Plugins in Eclipse -> Develop Plugins in Eclipse -> Test in Eclipse -> Run in Eclipse. A plugin is a logical group of some functionality that in turn can be run in eclipse. If there is no UI part that is associated, it can be used as a simple jar file. In any case its pretty common that we have some UI associated with the plugin. This can be run either on a normal eclipse platform or on a RCP environment.
A simplest plugin you can think of it is a Hello World application (damn…why always HelloWorld). You basically want to contribute an action item to the toolbar of eclipse and on click of that button you want to display a dialog with Hello World Message. Thus in this plugin, you just USEd the eclipse platform to add some functionality your current eclipse runtime.
Basic Plugin Developer.

Eclipse as a Platform :All of us know about the JDT, CDT, PHP language plugins. On this level of platform usage, we as developers are building the different kind of plugins and these they will be used by target audience, who in turn develop some applications with our language kit. Its like one of my colleague had developed Cobol Language toolkit for Fujitsu customer (of course they have released it to open source after some time). In my view i think of the some of the editors like JSF Editor, XML Editors, JSP Editor, JS Editor that fall under this category.
There are many companies that are using the Eclipse as their real time application configuration platform. Its like they have the metadata and the configuration of metadata is a big deal.
Advanced Plugin Developer.

Eclipse an Integration Framework :This is the highest level of integration and complex applications that i have seen with Eclipse. Here i am talking about different usecases. One of the nice example is to be able to create the entire development life cycle of your complex engineering activities in to the eclipse. Starting from System Requirements, Software Requirements, Component Design, Function Design, Coding, Unit Testing, Integration Testing, System Testing, Delivery and finally Issue Tracking into Eclipse. Dont feel apprehensive about the possibility, i am aware of some companies who have done this. This on the ground level means, to integrate different tools [editors, compilers, debuggers, configurators] into eclipse. The integration can be done done on sharing different data models/formats primarily on the EMF models.
Many companies have integrated some AJAX and SOA kind of applications. A typical of these applications would use Platform, WTP, ATF, DTP. The final application could be a RCP application or a plugin distributed via internet/intranet.
I also knew of many Data ETL companies that have started adopting the eclipse as their integration platform of their next generation tooling platform. Many have migrated from their conventional COM/DCOM and Perl based applications to java/eclipse.
Happy Application Integrator.

In the next article i want to highlight the different usecases that are prevailing in the automobile and web 2.0 industries.
In the end you need to know that Eclipse is an ECO System.
You have almost all plugins, tools and frameworks that you want to build/integrate your applications.

Till then Happy Application Integration with Eclipse.

Posted in AJAX, Automobile, Eclipse, EMF, GEF, GMF, Java, Plug-ins, Plugin, RCP, SOA, SWT, TPTP, Web Services | Leave a Comment »

Europa launched…

Posted by sureshkrishna on July 2, 2007

The long awaited europa launched few days ago and its really really cool. Releasing 21 eclipse projects at the same time is a tremendous work and they have did it again. I was very apprehensive about the initial stages of Callisto, whether it will be able to make it or not. Callisto it self was a great success and Europa has broken these records too.

Looks like europa has 17 million lines of code and the real nice thing i found is that now we have 2 different distributions for Java Developers and C/C++ Developers. That’s so cool, is nt it. Now the developers need to not remove/disable the parts that they dont want. And most importantly its slim.

Long live Eclipse. !!!

Posted in Eclipse, EMF, GEF, GMF, Plug-ins, Plugin, RCP, SWT | Leave a Comment »

PShelf Widget in Eclipse

Posted by sureshkrishna on December 21, 2006

PShelf Widget is really cool, if you want to implement a kind of Accordion widget in Eclipse. The Accordion widget is been gaining popularity in the end user community, especially with the AJAX and SOA presence.

Currently for simple implementations it looks quite stable. I had no problems till now. I have no idea when this project nebula is going to get integrated, but i am looking forward to it.

One good thing about this widget is that we can increase or decrease the time delay in the shelf roll-out. It also gives a very smooth transition from shelf to shelf. Can be very easily embedded into a View.

I am just adding a small snippet for the PShelf usage in a View. Hope this helps. Also this widget library it self is very very small, so you can include it very easily.

public void createPartControl(Composite parent) {
/* Create a grid layout object so the text and treeviewer
* are layed out the way I want. */
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.verticalSpacing = 2;
layout.marginWidth = 0;
layout.marginHeight = 2;
text = new Text(parent, SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER);
// layout the text field above the treeviewer
GridData layoutData = new GridData();
layoutData.grabExcessHorizontalSpace = true;
layoutData.horizontalAlignment = GridData.FILL;
PShelf shelf = new PShelf(parent, SWT.BORDER);
PShelfItem shelfGroup1 = new PShelfItem(shelf, SWT.NONE);
shelfGroup1.setText("Group 1");
shelfGroup1.getBody().setLayout(new FillLayout());
Table componentTable = new Table(shelfGroup1.getBody(), SWT.NONE);
createTableItem(componentTable, "Item11");
PShelfItem shelfGroup2 = new PShelfItem(shelf, SWT.NONE);
shelfGroup2.setText("Group 2");
shelfGroup2.getBody().setLayout(new FillLayout());
Table containerTable = new Table(shelfGroup2.getBody(), SWT.NONE);
createTableItem(containerTable, "Item21");
PShelfItem shelfGroup3 = new PShelfItem(shelf, SWT.NONE);
shelfGroup3.setText("Group 3");
shelfGroup3.getBody().setLayout(new FillLayout());
Table advancedWidgets = new Table(shelfGroup3.getBody(), SWT.NONE);
createTableItem(advancedWidgets, "Item31");
GridData shelfLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);

Posted in Eclipse, JFace, PShelf, SWT | 1 Comment »

Showing Hierarchical data in Eclipse

Posted by sureshkrishna on December 9, 2006

Withe the introduction of RCP, EMF-RCP, GEF and GMF, now there are plethora of choices to display hierarchical or grouped data. I have been struggling with all these varieties to choose one amongst them. Its quite clear why would you choose a viewer (Tree, Table, etc…), so i am not going to write much about it. The real challenge is to choose between the available widgets appropriate for your application.

The Hierarchical data that need to be presented to the end user can be in many ways. It can be a TreeView, TableView, TableTreeView, Nebula PShelf Widget, ExpandBar. Probably there can be more viewers/widgets that i am not aware of.

The real important difference is to make sure that we have the right Widget and right Viewer to represent the data. Pretty clearly, many of the widgets from SWT can not manage the complex data manipulation. That’s the reason we have a very user friendly layer called JFace on the top of it 🙂

Recently i also fiddled around with the PaletteView in GEF. This is also a very good starting point to represent collection of artifacts, from which we are going to select a specific action or tool. To provide a select-drag-create kind of scenario, i love to use PaletteView, TreeView, PShelf.

A more dynamic scenario is supported by the TreeView (as it has the providers behind) . If we are sure of the artifacts to be represented at the design and development time, its better to go with the PaletteView, PShelf kind.

Posted in Eclipse, EMF, ExpandBar, GEF, GMF, JFace, PShelf, RCP, SWT, TableTreeView, TableView, TreeView | Leave a Comment »