wiki:Branding

Brand your servicia environment

What can be branded?

Currently the following things are brandable:

  • Splashscreen image
  • Tray icon image
  • Tray icon menue

How do I brand?

Branding is done by a class implementing the interface de.dfki.km.workspace.branding.Branding. The class will provide resource names for imgages (splashscreen and tray icon) and will create the conroller classes to "drive" the splashscreen and to handle the self-defined tray icon menue.

/**
 * Interface to access branding-related information like splashscreen image or trayicon stuff.
 * 
 * @author lauer
 */
public interface Branding
{
    /** Returns absolute splash screen image resource identifier (no leading slash). */ 
    String getSpashScreenImageResource();

    /** Returns absolute tray icon image resource identifier (no leading slash). */ 
    String getTrayIconImageResource();
    
    /** 
     * Creates the controller for the tray icon.
     * @return may return null in case tray icons are not supported. 
     */
    TrayIconControllerApi createTrayIconController();
    
    /** Creates the controller for the splash screen. */
    SplashScreenController createSplashScreenController(); 
}

A possible implementation my look like this:

public class DefaultBranding implements Branding
{
    public final static String SERVICIA_SPLASHSCREEN = "de/dfki/km/workspace/splashscreen/servicia_logo_v_2_6.png";
    public final static String SERVICIA_TRAY_ICON = "de/dfki/km/workspace/trayicon/servicia_trayicon.gif";

    public DefaultBranding()
    {
    }

    public String getSpashScreenImageResource()
    {
        return( SERVICIA_SPLASHSCREEN );
    }

    public String getTrayIconImageResource()
    {
        return( SERVICIA_TRAY_ICON );
    }

    public TrayIconControllerApi createTrayIconController()
    {
        try
        {   //tray icons available?
            Class.forName( "java.awt.TrayIcon" );
        }
        catch (Exception e) 
        {
            return( null );  //no
        }
        
        final TrayIconControllerApi serviciaTrayController = new AbstractTrayIconController()
        {
            @Override
            public String getTrayIconImageResource()
            {
                return( DefaultBranding.this.getTrayIconImageResource() );
            }
            
            @Override
            protected PopupMenu createPopupMenu()
            {
                PopupMenu popupMenu = new PopupMenu();
                popupMenu.add( getShudownMenuItem() );
                popupMenu.add( getLoggingConsoleItem() );

                return ( popupMenu );
            }
        };
        
        return( serviciaTrayController );
    }
    
    public SplashScreenController createSplashScreenController()
    {
        SplashScreenController serviciaSplashScreenController = new SplashScreenController()
            {
                @Override
                public String getSplashScreenImageResource()
                {
                    return ( DefaultBranding.this.getSpashScreenImageResource() );
                }
            };
        return ( serviciaSplashScreenController );
    }
}

How do I enable the new branding?

There are two ways to enable the new branding:

Branding packages

The branding class and associated resources can be packaged into a jar-file. When the package conatains a resource named

META-INF/services/de.dfki.km.workspace.branding.Branding

which contains the class name of the Branding implementation to use, the banding will automatically used as default branding for the runtime. CAUTION: There must not be two branding packages in the classpath at the same time since the system cannot decide which branding to use. In this case the command-line option has to resolve the ambiguity.

Command-line option '-branding'

With the command-line option -branding <branding-class> it is possible to set a branding class directly. The core service loaded by the launcher has to contain this class.

HINT You can use the system property de.dfki.km.workspace.launch.external_jar to specify a branding bundle directly. It is then loaded into the core. If it is the only branding package it will be applied automatically. If not you have to set the -branding option too.

Last modified 9 years ago Last modified on 01/15/09 14:01:04