bibliothek.gui
Class DockUI

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

@Todo(compatibility=BREAK_MAJOR,
      target=VERSION_1_1_0,
      priority=MAJOR,
      description="Use an UIManager instead of bundles to handle text, also applies to the Common library")
public class DockUI
extends Object

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

Author:
Benjamin Sigg

Field Summary
static String OVERFLOW_MENU_ICON
          Key for an Icon stored in the IconManager for an overflow-menu
 
Constructor Summary
protected DockUI()
          Creates a new DockUI
 
Method Summary
 void addLocaleListener(LocaleListener listener)
          Adds a new LocaleListener.
 void addLookAndFeelColorsListener(LookAndFeelColorsListener listener)
          Adds a listener which gets informed when a color of the current LookAndFeelColors changes.
 void fillIcons(IconManager manager)
          Fills all known icons as default-icons into the given manager.
 ResourceBundle getBundle()
          Gets the local resource bundle.
static Color getColor(String key)
          Gets the color key where key is one of the keys specified in LookAndFeelColors.
 LookAndFeelColors getColors()
          Gets the current source of colors that depend on the LookAndFeel.
static Combiner getCombiner(Combiner combiner, DockStation station)
          Gets a Combiner for station.
static DockUI getDefaultDockUI()
          Gets the default instance of DockUI.
 ThemeFactory getDefaultTheme()
          Gets the default-theme to be used by all DockControllers when nothing else is specified.
static DisplayerFactory getDisplayerFactory(DisplayerFactory factory, DockStation station)
          Gets a DisplayerFactory for station.
 Icon getIcon(String key)
          Gets the icon stored under key.
 Locale getLocale()
          Gets the Locale for which the ResourceBundle was loaded.
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.
 void registerColors(String lookAndFeelClassNameRegex, LookAndFeelColors colors)
          Registeres a new LookAndFeelColors.
<T extends DockTheme>
void
registerTheme(Class<T> theme, ResourceBundle bundle)
          Registers a factory for theme.
 void registerTheme(ThemeFactory factory)
          Stores a new theme.
 void removeLocaleListener(LocaleListener listener)
          Removes listener from this DockUI.
 void removeLookAndFeelColorsListener(LookAndFeelColorsListener listener)
          Removes a listener from this DockUI.
protected  LookAndFeelColors selectBestMatchingColors()
          Gets the LookAndFeelColors which matches the current LookAndFeel best.
 void setBundle(Locale locale)
          Deprecated. replaced by setLocale(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 setLocale(Locale locale)
          Sets the locale for which a ResourceBundle should be loaded.
 void unregisterTheme(ThemeFactory factory)
          Removes an earlier added factory from the set of theme-factories.
protected  void updateLookAndFeelColors()
          Updates the currently used LookAndFeelColors to the best matching colors.
static
<D extends DockStation,L>
void
updateTheme(D station, DockFactory<D,L> factory)
          Removes all children of station and then adds the children again.
protected  void updateUI()
          Called when the LookAndFeel changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERFLOW_MENU_ICON

@Todo(compatibility=BREAK_MINOR,
      priority=MINOR,
      target=VERSION_1_1_0,
      description="Instead of just a simple icon allow clients more influence of what an overflow-menu can do. This key may remain, but its value may not be used all the time.")
public static final String OVERFLOW_MENU_ICON
Key for an Icon stored in the IconManager for an overflow-menu

See Also:
Constant Field Values
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

updateUI

protected void updateUI()
Called when the LookAndFeel changed.


getDefaultTheme

public ThemeFactory getDefaultTheme()
Gets the default-theme to be used by all DockControllers when nothing else is specified.

Returns:
the default-theme

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.

Type Parameters:
T - the type of the DockTheme.
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

registerColors

public void registerColors(String lookAndFeelClassNameRegex,
                           LookAndFeelColors colors)
Registeres a new LookAndFeelColors. The lookAndFeelClassNameRegex is a regular expression. If a LookAndFeel is active whose class name matches lookAndFeelClassNameRegex, then colors becomes the selected source for colors. If more then one regex matches, the last one that was added to this DockUI is taken. So generally one would first add the most general regexes, and the more detailed ones later.

Parameters:
lookAndFeelClassNameRegex - a description of a class name
colors - the new set of colors

addLookAndFeelColorsListener

public void addLookAndFeelColorsListener(LookAndFeelColorsListener listener)
Adds a listener which gets informed when a color of the current LookAndFeelColors changes. This listener gets not informed about any changes when the LookAndFeel itself gets replaced. This listener will automatically be transfered when another LookAndFeelColors gets selected.

Parameters:
listener - the new listener, not null

removeLookAndFeelColorsListener

public void removeLookAndFeelColorsListener(LookAndFeelColorsListener listener)
Removes a listener from this DockUI.

Parameters:
listener - the listener to remove

updateLookAndFeelColors

protected void updateLookAndFeelColors()
Updates the currently used LookAndFeelColors to the best matching colors.


selectBestMatchingColors

protected LookAndFeelColors selectBestMatchingColors()
Gets the LookAndFeelColors which matches the current LookAndFeel best.

Returns:
the current set of colors

getColors

public LookAndFeelColors getColors()
Gets the current source of colors that depend on the LookAndFeel.

Returns:
the current source of colors

getColor

public static Color getColor(String key)
Gets the color key where key is one of the keys specified in LookAndFeelColors.

Parameters:
key - the name of the color
Returns:
the color or null

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

setLocale

public void setLocale(Locale locale)
Sets the locale for which a ResourceBundle should be loaded.

Parameters:
locale - the new locale, not null

getLocale

public Locale getLocale()
Gets the Locale for which the ResourceBundle was loaded.

Returns:
the locale, not null

addLocaleListener

public void addLocaleListener(LocaleListener listener)
Adds a new LocaleListener.

Parameters:
listener - the new listener, not null

removeLocaleListener

public void removeLocaleListener(LocaleListener listener)
Removes listener from this DockUI.

Parameters:
listener - the listener to remove

setBundle

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

Parameters:
bundle - the bundle

setBundle

@Deprecated
public void setBundle(Locale locale)
Deprecated. replaced by setLocale(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

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,L> void updateTheme(D station,
                                                         DockFactory<D,L> 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
L - the type of the layout needed to describe the contents 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