LOGIN:
Username:
Password:
Lost password?
 

Eclipse:EclipseGoodies

Eclipse Goodies is a set of open source released Eclipse-plugins and tools for the Eclipse RCP and other Eclipse projects like BIRT or GEF we believe might be useful to other developers as well.

EclipseGoodies are maintained by Alexander Bieber <alex AT nightlabs DOT de>

If you have questions or suggestions please email Alex or post to the JFire (Free Discussion) forum

Contents

[edit] com.nightlabs.ant

This plugin is a set of Apache Ant Tasks we use within our build files. Currently only one of the Tasks is functional: EclipseVar.

EclipseVar lets you define ant properties within your build file with the same name and value as your Eclipse Classpath Variables defined within your IDE.

com.nightlabs.ant is release under the terms of the Apache License, Version 2.0

Check out the plugin for more documentation and the sourcecodes under

:pserver:anonymous@cvspublic.nightlabs.de:/srv/cvs

[edit] org.nightlabs.birt.jdo

This is a set of plugins providing a custom data source for the BIRT project. Similar to the JDBC plugins for BIRT it lets users connect to JDO repositories and execute JDOQL. As some tasks required for a BIRT datasource are not part of the JDO specification these plugins provide extension points to register vendor-dependent implementations of the JDO connections. Currently the org.nightlabs.birt.jdo feature comes with an implementation for the JDO reference implementation JPOX.

org.nightlabs.birt.jdo has its own wiki page here

[edit] org.nightlabs.rcp.splash

[edit] Overview

sample splash screen
sample splash screen

This plugin integrates with standalone RCP applications. It is able to show a splash screen similar to that Eclipse does but with the possibility to show status messages to the user. By default it will show the name of the plugins the workbench has loaded.

The plugin is released under the terms of the Eclipse Public License v1.0.

[edit] Usage

Detailed Documentation can be found in the Java-Doc of the plugin's classes. Here you'll get a short overview.

This plugin provides a Swing JFrame that comes up as soon as the plugin is loaded. It will display a configurable Image and a messagebar below it to which messages can be sent. Default behaviour is to show wich plugins were loaded.

So to make use of this splash screen you have to make sure the plugin is loaded as early as possible when your application starts. A simple way to do this is to inherit your WorkbenchAdvisor from SplashHandlingWorkbenchAdvisor. Doing so, the plugin will be loaded before you run the workbench and you can be sure that the Frame will also be closed when the Workbench shows up.

Note: If you are using Eclipse 3.1M5 or higher as target-platform there were changes in the WorkbenchAdvisor API. You will then have to override SplashHandlingWorkbenchWindowAdvisor and return an instance in your WorkbenchAdvisors createWorkbenchWindowAdvisor()-method.

Messages can be displayed via static methods in SplashPlugin (e.g):

SplashPlugin.addSplashMessage("Doing custom initialization ...");
// time consuming code
SplashPlugin.addSplashMessage("Doing custom initialization ...DONE");

More customization of the splash screen can be done in the file splashscreen.properties in the root directory of the plugin there you can define the following properties:

  • splashscreen.location a filename relative to the plugin directory pointing to the image you want to be displayed. From version 1.0.2 the wildcard {$nl} is supported for that property. The plugin will replace this with the current locale (eg. en_US, de_DE) and use that as path to the splash. If no file is found for the current locale it will try to find one by replacing {$nl} with "default", so you can provide a fallback image
  • splashscreen.title a String which will be set at the frames title so it appears in the taskbar.
  • splashscreen.messagebar.height Defines the height of the message bar in pixels
  • splashscreen.messages.showloadedplugins A boolean that defines weather a message is shown everytime a plugin is loaded

The splash screen is shown in a Swing JFrame so it will not appear instantly when the VM is started but when all neccessary classes were loaded. We fill the gap between startup and the showing of the splash screen by telling the Eclipse laucher to show a splash that is a screenshot of ours with a meaningfull message like "VM startup ...". When the JFrame is ready to be displayed the splash plugin will hide the splash shown by the launcher.

[edit] Changes for 1.1.0

With this version SplashBundleListener was renamed to SplashScreen. The SplashScreen now displays a JProgressBar instead of a JLabel under its main content. The type of the ProgressBar (indeterminate true/false) and its progress value may be set by static methods here are some examples:

// set progress span
SplashScreen.setProgressMinMax(0,10);
// set the progress value 
SplashScreen.setProgressValue(5);

Setting messages can now also be done via a static method

SplashScreen.addSplashMessage("Progress test");

Additionally the SplashScreen now accepts a custom JPanel that will be displayed above the progress bar. This also can be set and reset by static methods:

 // set the displayed panel to a new one
SplashScreen.setSplashPanel(new JPanel());
// reset the display to the panel showing the splash image
// and set the progress type to indeterminate
SplashScreen.resetSplashPanel();

[edit] Changes for 1.2.0

With this version SplashScreen does no logner use a JProgressBar. I comes now with an own JProgressPanel capable of aligning messages left, right and centered as well as accepting a word cut behaviour. The word cut behavoir defines where messages are cut when they do not fit into the progress panel possible values are:

  • right (default): messages will be cut at the end of the panel, so their beginning will be visible
  • left: messages will be cut at the beginning, so only their end will be visble
  • center: messages will be cut in the middle of the panel, so parts from the front and parts from the end will be visible
  • slide the point where the message will be cut moves with time between left and right. Use this only with fixed width fonts.

Additionally the progress panel now can be customized in font and colors by splashscreen.properties file.

Splash messages are not logner added to a list, but written instantly to the progress panel, so the API changed here as well. Use now:

SplashScreen.setSplashMessage("My very important message");

[edit] Changes 2006-11-18

[edit] New name and new repository

The project has been renamed to org.nightlabs.rcp.splash and is now located in the JFire SVN repository. It has not yet been officially released (sorry, lack of time), hence no version number. You can check it out directly from SVN using Subclipse.

[edit] Fragment based configuration

From today on (current SVN version), the splash can be configured using a fragment. Therefore, the lookup mechanism has been changed to search for the file splashscreen.properties first via the SplashPlugin's classloader. If this file cannot be found, it takes the default splashscreen.properties (within the project org.nightlabs.rcp.splash).

In order to specify your own splashscreen.properties, you simply place a file with this name into your fragment's src folder (directly into the root without any subdirectory).

The image file referenced in your properties (key splashscreen.location) is resolved via the same mechanism: First the classloader is called, second the bundle (which seems to find only files directly within org.nightlabs.rcp.splash).

[edit] Example Fragment

Directory Structure

org.myself.mysplash
  |
  |--src
  |   |
  |   |--splashscreen.properties
  |   ---MyApplication-Splash.png
  |
  |--META-INF
  |   |
  |   ---MANIFEST.MF
  |
  |--.classpath
  |--.project
  ---build.properties

splashscreen.properties

splashscreen.location = MyApplication-Splash.png
splashscreen.title = My Application
splashscreen.endnative = true
splashscreen.messages.showloadedplugins = true
progresspanel.height = 20

Of course, your splashscreen.properties could look different (take a look at the default splashscreen.properties in org.nightlabs.rcp.splash for a complete list of supported keys).

Note, that the MyApplication-Splash.png is referenced without any path as it is found by the ClassLoader in the root (because it's located directly within src without subdirectories).

MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Splash Fragment
Bundle-SymbolicName: org.myself.mysplash
Bundle-Version: 1.0.0
Bundle-ClassPath: org.myself.mysplash.jar
Bundle-Vendor: myself.org
Fragment-Host: org.nightlabs.rcp.splash;bundle-version="1.2.1"
Bundle-Localization: plugin

[edit] Download

  • Source can be obtained via CVS:
:pserver:anonymous@cvspublic.nightlabs.de:/srv/cvs

The CVS version references classes not known by Eclipse <3.1M5. If you want to use the plugin with Eclipse versions up to 3.1M4 you can use the binary distributions.

Binary Downloads for Eclipse >=3.1M5

These distributions contain SplashHandlingWorkbenchWindowAdvisor

Binary Downloads for Eclipse <3.1M5

Note that these distributions require JDK 1.5 or later. Newer releases (and CVS version) should work with nearly every JDK ...

[edit] Embedded GUI

Some operations should be done already during boot - e.g. login:

Image:EclipseGoodies_IpanemaSplash_Login.png

Image:EclipseGoodies_IpanemaSplash_Normal.png

[edit] Examples

com.nightlabs.spalshapp is a small example project. It provides a simple application demonstrating the usage of the splash with an Eclipse application. The example is a RCP-plugin with OSGI bundle manifest and plugin.xml together with a product configuration.

Get the source from our public CVS:

:pserver:anonymous@cvspublic.nightlabs.de:/srv/cvs

or download the source-archive here com.nightlabs.splashapp.tar.gz

splashapp-linux-gtk.tar.gz is the resulting application for a quick tryout.

[edit] com.nightlabs.classsharing (outdated)

[edit] Overview

This plugin interacts with the Ipanema class loader (project IpanemaBoot). It provides a RCP extension-point where other plugins can register resources which then are accessible from all other plugins.

This is useful if you have to instanciate classes of other plugins you don't know at compile time. We use it for our configuration management (project NightLabsBase).

com.nightlabs.classharing is released under the GNU LGPL Licence.

The Eclipse framework now provides a mechanism called buddy class loading that can be used to achieve the same results as with org.nightlabs.classsharing. Use something like this in your MANIFEST.MF:

Eclipse-BuddyPolicy: dependent 
# So all plugins you are dependent from 
# will ask your bundle, too, when they
# can not find a class
# or use
Eclipse-BuddyPolicy: registered 
# So only the registered plugin will
# ask your bundle if it can't find
# classes. 
# Register a buddy bundle as follows:
Eclipse-RegisterBuddy: org.nightlabs.base

[edit] Usage and Configuration

With the extension-point com.nightlabs.classsharing.globalclasspublish plugin developers can publish a set of their plugins classes to the whole application. The classharing plugin requires the DelegatingClassLoader of IpanemaBoot to be the OSGI parent class-loader thus the startup of RCP needs some preparations:

  • Make IpanemaBoot.jar part of your bootstrap-classpath when running the RCP. If runned out of the PDE this can be done in the "Bootstrap Entries" text-field in your run-configuration under "Run/Run...".
  • Make DelegatingClassLoader the OSGI parent class-loader by using the following command-line arguments (text-field "VM Arguments" in the run-configuration"):
-Djava.system.class.loader=com.nightlabs.ipanema.boot.DelegatingClassLoader
-Dosgi.parentClassloader=app

Note, that there was a change of the classloader handling in Eclipse 3.1M5. This might cause a behaviour as if -Dosgi.parentClassloader=app was ignored. The reason is that 3.1M5 (or later) loads FIRST with the plugin's CL and THEN with the system loader. Hence, you must make sure that the classsharing libraries itself are NOT available by the plugin.xml declarations but only by the system CL.

  • Register the Classsharing delegate by making a call to the static method initializeClassSharing(); of ClasssharingPlugin when your application starts, or your plugin is loaded.
ClasssharingPlugin.initializeClassSharing();

This causes the globalclasspublish extension to be processed and the delegate to be registered. Only after this call the published classes are accessable. Alternatively you could directly call

EPClassLoaderDelegate.getSharedInstance().register();

If you have an RCP-application we recommend calling this before you run the workbench. If you simply have an plugin make sure you initialize before you access published classes. Multiple calls to initializeClassSharing are unproblematic.

  • For your plugins define a new extension to point com.nightlabs.classsharing.globalclasspublish and add as many globalClassPublish elements to it you like. With a regular expression each element defines resources accessible form all plugins. Here is an example of publishing all resources under com.nightlabs.config (in this case also including com.nightlabs.config.fictive.Fiction etc.)
<extension point="com.nightlabs.classsharing.globalclasspublish">
  <globalClassPublish pattern="com\.nightlabs\.config\..*"/>
</extension>

[edit] Download


[edit] org.nightlabs.log4j

[edit] Overview

This is a small plugin to display Log4J messages either in the ConsoleView or, if not available in a more simple view the Log4JView.

The plugin adds a custom Appender to the root logger of Log4J and stores the messages. The Appender accepts registrations of ILog4JDisplay that display the log messages.

org.nightlabs.log4j adds an Action to the "Window" menu that will open the ConsoleView with an IConsole displaying Log4J messages. If the ConsoleView is not available (the plugin is not deployed) the plugin will show an own View with the log output.


[edit] Screenshots

Log4J output in the Eclipse ConsoleView (with its features like pin, scroll-lock, clear)

Log4J output in the simple Log4JView (with currently no extra features)

PreferencePage for the Log4J plugin where you can define the threshold and logging conversion pattern for the views:

[edit] Usage

To install the plugin, simply copy the release file into the plugins directory of your Eclipse installation or RCP application. Note, that the Log4J Plugin needs access to the Log4J classes in its classpath. To provide this classes it has an optional dependency to org.apache.log4j. This means it will be resolved but not functional if this plugin is not installed. Alternatively to the org.apache.log4j plugin you can provide the Log4J classes by making an other bundle buddy of org.nightlabs.log4j that exports these classes. To do this add the following line to your MANIFEST.MF:

Eclipse-RegisterBuddy: org.nightlabs.log4j

[edit] Build Notes

The Log4J plugin assumes that the Log4J classes somehow make it into its classpath, so in order to build correctly it has (as an Eclipse-PDE project) a classpath dependency to a classpath variable called LOG4J. This has to be defined and has to point to a log4j.jar when trying to build or export the SVN version of org.nightlabs.log4j

[edit] Download