bibliothek.gui
Class DockUI

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

public class DockUI
extends Object

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

Author:
Benjamin Sigg

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.
 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.
 Icon getIcon(String key)
          Gets the icon stored under key.
static StationPaint getPaint(StationPaint paint, DockStation station)
          Gets a StationPaint for station.
 String getString(String key)
          Gets a string of the current bundle.
 ThemeFactory[] getThemes()
          Gets the list of all available themes.
protected  Map<String,String> loadKeyPathMapping()
          Gets a map containing keys and path for icon.
<T extends DockTheme>
void
registerTheme(Class<T> theme, ResourceBundle bundle)
          Registers a factory for theme.
 void registerTheme(ThemeFactory factory)
          Stores a new theme.
 void setBundle(Locale locale)
          Replaces the bundle of this DockUI using the given Locale
 void setBundle(ResourceBundle bundle)
          Sets the resource bundle which should be used.
 void setIcon(String key, Icon icon)
          Sets the icon that is used for a certain key.
 void unregisterTheme(ThemeFactory factory)
          Removes an earlier added factory from the set of theme-factories.
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
 

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

getThemes

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

Returns:
the themes

registerTheme

public <T extends DockTheme> void registerTheme(Class<T> theme,
                                                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

unregisterTheme

public void unregisterTheme(ThemeFactory factory)
Removes an earlier added factory from the set of theme-factories.

Parameters:
factory - the factory to remove

getBundle

public ResourceBundle getBundle()
Gets the local resource bundle.

Returns:
the bundle

getString

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

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

setBundle

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

Parameters:
bundle - the bundle

setBundle

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

Parameters:
locale - the language of the DockUI

getIcon

public Icon getIcon(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(String key,
                    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 Map<String,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 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:
IOException - if the factory throws an exception