SLF4J on Java Google App Engine

This article suggest a recipe to configure SLF4J on Google App Engine for Java.

This article was first published at techtavern.wordpress.com

Google App Engine for Java offers a restricted Java 6 API, which includes just the cumbersome Java Utils Logging. Fortunately, SLF4J works as well. The recipe is the standard one. Nearly no configuration is required.

Just add following SLF4J libraries into the applications WEB-INF/lib directory: slfj4-api-1.7.7.jar and slf4j-jdk14-1.7.7.jar (version number may vary). This will redirect all your SLF4J logging statements to the Java Utils Logging controlled by the App Engine.

Optionally you may also add jcl-over-slf4j-1.7.7.jar and log4j-over-slf4j-1.7.7.jar libraries, that will redirect both Apache Commons Logging and Log4J to SLF4J (and thus to App Engine’s Java Utils Logging).

View TopComponents with icons on Netbeans RCP

This article explains an approach to enable tabs with icons to ‘view’ TopComponents.

This article appeared first on techtavern.wordpress.com

The Problem

A typical Netbeans RCP application always displays TopComponents with ‘editor’ mode with their icon and their title, even if the tab runs out of space. Here is an example:

EditorTopComponentTab

Tabs of editor TopComponents

 

TopComponents with other modes are displayed as ‘views’. Their tabs are extremely simplistic: they never show their icon and their title is shortened or even omitted in case of less space. Here is an example:

ViewTopComponentTab

Tabs of view TopComponents (observe that the title of the focused tab is missing!)

 

 

Some thoughts about

Geertjan’s Blog explains in his blog how to completely hide tabs for ‘editor’ TopComponents, by setting the ‘EditorTabDisplayerUI’ UIManager property and overriding the inherited Look and Feel that renders the tab.

If there is an ‘editor’ tab displayer, wouldn’t there be a ‘view’ tab displayer? After some research, I found the analogous ‘ViewTabDisplayerUI’ UIManager property. But what would be the proper value? A self crafted class like Geertjan’s one? That would require too much work and it would not follow the current Look and Feel.

The Solution

As the editor tab displayer looks fine, I decided to reuse it as a view tab displayer provided by the current Look and Feel. That was quite simple, though audacious. To preserve the look and feel, copy the the EditorTabDisplayerUI property’s value to the ViewTabDisplayerUI UIManager property. This hack requires scheduling the code from an module installer to execute later in the UI thread, when the Look and Feel is already defined.

public class Installer extends ModuleInstall {
 @Override
 public void restored() {
   SwingUtilities.invokeLater(new Runnable() {
     @Override
     public void run() {
       final Object view = UIManager.get("ViewTabDisplayerUI");
       final Object editor = UIManager.get("EditorTabDisplayerUI");
       System.out.println("invokeLater: "+view);
       System.out.println("invokeLater: " +editor);
       UIManager.put("ViewTabDisplayerUI", editor);
     }
   });
 }
}

I admit that it is a dirty hack, but it worked.