Thursday, January 25, 2007

Run Basic in web using Smalltalk

As Carl Gundel, author of Liberty BASIC announced on the seaside mailinglist there is a Seaside app to bring BASIC programming to the web:

http://www.runbasic.com

Yet another nice Smalltalk application that shows the power of the Seaside Smalltalk web application framework...

Tuesday, January 16, 2007

Blog conversion and Planet Smalltalk

I converted my Blog to the new Blogger.com release. Looks like this automated conversion made some (if not all) of the postings reappear on http://planet.smalltalk.org. Sorry for any inconvenience ...

RCP Plugin startup in 3.3M4

This evening I'm updating some old code I've written in Java/Eclipse RCP to be prepared for the new Eclipse Europa release (successor of Callisto).

As you can read on the "News and Noteworthy" of Eclipse 3.3M4 a new Application Model is introduced. Eclipse now implements the Application Admin Service from the OSGi specification.

When building RCP applications with Eclipse that means that the old IPlatformRunnable interface is deprecated and you should now use org.eclipse.equinox.app.IApplication. Instead of run() we should now provide a start() and stop() method.

To fix your main RCP plugin you may want to change your application class to
look like this:


import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

/**
* This class controls all aspects of the application's execution
*/
public class Application implements IApplication {

/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
*/
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}

/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#stop()
*/
public void stop() {
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null)
return;
final Display display = workbench.getDisplay();
display.syncExec(new Runnable() {
public void run() {
if (!display.isDisposed())
workbench.close();
}
});
}
}

Wednesday, January 10, 2007

Thursday, January 04, 2007

Disappointing Swing

Wrote yet another small utility today.

Since I wanted to reuse a lib written in Java I decided against a the most productive OO System and also came over other temptations. Call me nuts but I wanted to build the user interface in Java with Swing...

I had installed the "Java Mustang" (JDK 1.6 release) last month to play with the new Scripting support (Java now includes the Rhino JavaScript implementation). So I had the latest and greatest Swing on my machine - time for Desktop Java. At that time I was also eager to play with the promised new Desktop integration. Unfortunately this "integration" was nothing more than open the web browser, open mail, and open/edit a document with the associated program. Something the Win32 API had since the days of the ShellExecute() function. But that's another story.

Back to my little Swing utility: I started Eclipse since the IDE supports Swing, SWT and AWT GUI building with the VisualEditor project.

I easily generated a simple JFrame window together with some code for a simple application menu. Some typing here, some coding there I managed to complete my small tool. Work was done so I decided to beautify the UI.

First I switched to the correct Windows L&F since the tool is used "Win only":

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")

After that I wanted to add icons to the menu items. So I imported a gif into a package and added it as menu icon resource using the property palette.

When I hit the "Run" button I was surprised that the image was too close to the text.



What a waste of space on the left side. I think it is intended for menu items with check boxes (JCheckBoxMenuItem) and an additional image. But I have no checked menu item here. Also not very "winlike". I would have expected something like this (screenshot from a native application):



I played with setHorizontalTextAlignment() to align the text to the right. But the situation got worse:



The image disappeared. Time for Google: Ahhh - Bug 6385358
revealed it: in JDK 1.5. the text overlaps the shortcut text and in the latest Mustang build, ONLY the shortcut text appears (without the menu item text).

The bug was submitted 14-FEB-2006 and in 2007 it is still in progress! Maybe they have to fix the other 222+221+216+214+213+211+210+29+27+26+23+22+20 bugs first.

How sad - have to move on without menu icons or switch to SWT. Very disappointing! Anything I wanted was a simple windows like UI in Swing ...

The language (and IDE) is built in

Huw and Demot talking about OOP. They also talk about Smalltalk.

I agree - in Smalltalk, the code and its environment work together.
Thats why you are so productive with it and why so many things have their roots in Smalltalk. You can easily extend both: the language and the IDE.

Most people do not understand that Smalltalk is not only a language. They see the syntax and compare it to curly brace languages.

But Smalltalk is a dynamic object system with a language built in. Everything is an object, even the language is implemented using objects and messages. Control structures are just messages. Classes are objects as well, therefore they understand messages (a "static" construct is not necessary) implemented in class methods.

Unfortunately most "modern" language designer missed this opportunity (otherwise we wouldnt have a debate about complicated Java Language extensions or yet another new language)

Others try to emulate the IDE. Unfortunately even with Eclipse they will not come close.

I dont know what the future will bring - but hopefully it is a lean, modular Smalltalk like dynamic object system that nicely play with other technologies. Maybe Ian's work can help here.