bibliothek.gui
Class DockUI

java.lang.Object
  extended by bibliothek.gui.DockUI

public class DockUI
extends java.lang.Object

A list of icons, text and methods used by the framework.

Author:
Benjamin Sigg

Field Summary
private  java.util.ResourceBundle bundle
          The resource bundle for some text shown in this framework
private  java.util.Map<java.lang.String,javax.swing.Icon> icons
          The icons used in this framework
private  java.util.List<ThemeFactory> themes
          A list of all available themes
private static DockUI ui
          An instance of DockUI
 
Constructor Summary
protected DockUI()
          Creates a new DockUI
 
Method Summary
 void fillIcons(IconManager manager)
          Fills all known icons as default-icons into the given manager.
 java.util.ResourceBundle getBundle()
          Gets the local resource bundle.
static Combiner getCombiner(Combiner combiner, DockStation station)
          Gets a Combiner for station.
static DockUI getDefaultDockUI()
          Gets the default instance of DockUI.
static DisplayerFactory getDisplayerFactory(DisplayerFactory factory, DockStation station)
          Gets a DisplayerFactory for station.
 javax.swing.Icon getIcon(java.lang.String key)
          Gets the icon stored under key.
static StationPaint getPaint(StationPaint paint, DockStation station)
          Gets a StationPaint for station.
 java.lang.String getString(java.lang.String key)
          Gets a string of the current bundle.
 ThemeFactory[] getThemes()
          Gets the list of all available themes.
protected  java.util.Map<java.lang.String,java.lang.String> loadKeyPathMapping()
          Gets a map containing keys and path for icon.
 void registerTheme(java.lang.Class<? extends DockTheme> theme, java.util.ResourceBundle bundle)
          Registers a factory for theme.
 void registerTheme(ThemeFactory factory)
          Stores a new theme.
private  void registerThemes()
           
 void setBundle(java.util.Locale locale)
          Replaces the bundle of this DockUI using the given Locale
 void setBundle(java.util.ResourceBundle bundle)
          Sets the resource bundle which should be used.
 void setIcon(java.lang.String key, javax.swing.Icon icon)
          Sets the icon that is used for a certain key.
static
<D extends DockStation>
void
updateTheme(D station, DockFactory<? super D> factory)
          Removes all children of station and then adds the children again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ui

private static DockUI ui
An instance of DockUI


bundle

private java.util.ResourceBundle bundle
The resource bundle for some text shown in this framework


icons

private java.util.Map<java.lang.String,javax.swing.Icon> icons
The icons used in this framework


themes

private java.util.List<ThemeFactory> themes
A list of all available themes

Constructor Detail

DockUI

protected DockUI()
Creates a new DockUI

Method Detail

getDefaultDockUI

public static DockUI getDefaultDockUI()
Gets the default instance of DockUI.

Returns:
the instance

registerThemes

private void registerThemes()

getThemes

public ThemeFactory[] getThemes()
Gets the list of all available themes.

Returns:
the themes

registerTheme

public void registerTheme(java.lang.Class<? extends DockTheme> theme,
                          java.util.ResourceBundle bundle)
Registers a factory for theme.

Parameters:
theme - A class which must have the annotation ThemeProperties
bundle - The ResourceBundle that should be used to read name and description. This argument can be null, in that case the bundle of this DockUI will be used.

registerTheme

public void registerTheme(ThemeFactory factory)
Stores a new theme.

Parameters:
factory - the new theme

getBundle

public java.util.ResourceBundle getBundle()
Gets the local resource bundle.

Returns:
the bundle

getString

public java.lang.String getString(java.lang.String key)
Gets a string of the current bundle.

Parameters:
key - the key of the string
Returns:
the string

setBundle

public void setBundle(java.util.ResourceBundle bundle)
Sets the resource bundle which should be used.

Parameters:
bundle - the bundle

setBundle

public void setBundle(java.util.Locale locale)
Replaces the bundle of this DockUI using the given Locale

Parameters:
locale - the language of the DockUI

getIcon

public javax.swing.Icon getIcon(java.lang.String key)
Gets the icon stored under key. The keys are stored in a file "icons.ini" in the directory "data".

Parameters:
key - the key for the icon
Returns:
the icon or null

setIcon

public void setIcon(java.lang.String key,
                    javax.swing.Icon icon)
Sets the icon that is used for a certain key.

Parameters:
key - the key
icon - the icon to return if getIcon(String) is invoked

loadKeyPathMapping

protected java.util.Map<java.lang.String,java.lang.String> loadKeyPathMapping()
Gets a map containing keys and path for icon.

Returns:
the icons

fillIcons

public void fillIcons(IconManager manager)
Fills all known icons as default-icons into the given manager.

Parameters:
manager - the manager to fill

getPaint

public static StationPaint getPaint(StationPaint paint,
                                    DockStation station)
Gets a StationPaint for station.

Parameters:
paint - a default value, may be null
station - the station for which a paint is searched
Returns:
paint or another StationPaint, not null

getDisplayerFactory

public static DisplayerFactory getDisplayerFactory(DisplayerFactory factory,
                                                   DockStation station)
Gets a DisplayerFactory for station.

Parameters:
factory - a default value, may be null
station - the station for which a factory is searched
Returns:
factory or another DisplayerFactory, not null

getCombiner

public static Combiner getCombiner(Combiner combiner,
                                   DockStation station)
Gets a Combiner for station.

Parameters:
combiner - a default value, may be null
station - the station for which a combiner is searched
Returns:
combiner or another Combiner, not null

updateTheme

public static <D extends DockStation> void updateTheme(D station,
                                                       DockFactory<? super D> factory)
                        throws java.io.IOException
Removes all children of station and then adds the children again. Reading the children ensures that all components are build up again with the current theme of the station

Type Parameters:
D - the type of the station
Parameters:
station - the station to update
factory - a factory used to remove and to add the elements
Throws:
java.io.IOException - if the factory throws an exception