bibliothek.gui.dock.common.theme
Class ThemeMap

java.lang.Object
  extended by bibliothek.gui.dock.common.theme.ThemeMap

@FrameworkOnly
public class ThemeMap
extends java.lang.Object

A map of ThemeFactorys. This map can change the DockTheme of its associated CControl. New factories can be added or removed from the map.

Author:
Benjamin Sigg

Field Summary
static java.lang.String KEY_BASIC_THEME
          standard key for the CBasicTheme
static java.lang.String KEY_BUBBLE_THEME
          standard key for the CBubbleTheme
static java.lang.String KEY_ECLIPSE_THEME
          standard key for the CEclipseTheme
static java.lang.String KEY_FLAT_THEME
          standard key for the CFlatTheme
static java.lang.String KEY_SMOOTH_THEME
          standard key for the CSmoothTheme
 
Constructor Summary
ThemeMap()
          Creates a new empty map.
ThemeMap(CControl control)
          Creates a new map and wires this map to control.
 
Method Summary
 void add(java.lang.String key, ThemeFactory factory)
          Adds factory at the end of this map.
 void addThemeMapListener(ThemeMapListener listener)
          Adds a new listener to this map.
 ThemeFactory getFactory(int index)
          Gets the index'th factory.
 ThemeFactory getFactory(java.lang.String key)
          Searches the factory which is associated with key.
 java.lang.String getKey(int index)
          Gets the key of the index'th element.
 DockThemeModifier getModifier()
          Gets the object which will modify the DockTheme before applying the theme to the DockController.
 ThemeFactory getSelectedFactory()
          Gets the currently selected factory.
 java.lang.String getSelectedKey()
          Gets the name of the currently selected factory.
 int indexOf(java.lang.String key)
          Searches for key and returns its location.
 int indexOf(ThemeFactory factory)
          Searches for factory and returns its index.
 void insert(int index, java.lang.String key, ThemeFactory factory)
          Inserts a new factory into this map.
protected  ThemeMapListener[] listeners()
          Gets an array containing all ThemeMapListeners of this map.
 void put(java.lang.String key, ThemeFactory factory)
          Searches for an entry named key and changes its factory.
 void remove(int index)
          Removes the index'th entry of this map.
 boolean remove(java.lang.String key)
          Deletes the factory associated with key.
 void removeThemeMapListener(ThemeMapListener listener)
          Removes a listener from this map.
 void select(int index)
          Changes the selected factory.
 void select(int index, boolean force)
          Changes the selected factory.
 void select(java.lang.String key)
          Changes the selected factory.
 void select(java.lang.String key, boolean force)
          Changes the selected factory.
 void select(ThemeFactory factory)
          Changes the selected factory to factory.
 void setModifier(DockThemeModifier modifier)
          Sets the object which will modify the DockTheme before applying the theme to the DockController.
 int size()
          Gets the number of elements of this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_BASIC_THEME

public static final java.lang.String KEY_BASIC_THEME
standard key for the CBasicTheme

See Also:
Constant Field Values

KEY_BUBBLE_THEME

public static final java.lang.String KEY_BUBBLE_THEME
standard key for the CBubbleTheme

See Also:
Constant Field Values

KEY_ECLIPSE_THEME

public static final java.lang.String KEY_ECLIPSE_THEME
standard key for the CEclipseTheme

See Also:
Constant Field Values

KEY_FLAT_THEME

public static final java.lang.String KEY_FLAT_THEME
standard key for the CFlatTheme

See Also:
Constant Field Values

KEY_SMOOTH_THEME

public static final java.lang.String KEY_SMOOTH_THEME
standard key for the CSmoothTheme

See Also:
Constant Field Values
Constructor Detail

ThemeMap

public ThemeMap()
Creates a new empty map.


ThemeMap

public ThemeMap(CControl control)
Creates a new map and wires this map to control. Ensures that the standard themes are available.
Every change of the selected factory will change the theme of control, and this map will ensure that the name of the theme is stored in the ApplicationResourceManager.

Parameters:
control - the control to monitor
Method Detail

addThemeMapListener

public void addThemeMapListener(ThemeMapListener listener)
Adds a new listener to this map. The listener will be informed when a factory is changed or the theme changes.

Parameters:
listener - the new listener

removeThemeMapListener

public void removeThemeMapListener(ThemeMapListener listener)
Removes a listener from this map.

Parameters:
listener - the listener to remove

listeners

protected ThemeMapListener[] listeners()
Gets an array containing all ThemeMapListeners of this map.

Returns:
the list of listeners

setModifier

public void setModifier(DockThemeModifier modifier)
Sets the object which will modify the DockTheme before applying the theme to the DockController.

Parameters:
modifier - the new modifier, can be null

getModifier

public DockThemeModifier getModifier()
Gets the object which will modify the DockTheme before applying the theme to the DockController.

Returns:
the modifier, can be null

select

public void select(java.lang.String key)
Changes the selected factory. If there is no factory with name key or key is null, then the null-factory is selected.

Parameters:
key - the name of the newly selected factory, can be null

select

public void select(java.lang.String key,
                   boolean force)
Changes the selected factory. If there is no factory with name key or key is null, then the null-factory is selected.

Parameters:
key - the name of the newly selected factory, can be null
force - true if the theme is to be loaded even if it is already selected

select

public void select(ThemeFactory factory)
Changes the selected factory to factory.

Parameters:
factory - the factory to select
Throws:
java.lang.IllegalArgumentException - if factory is not registered in this map.

select

public void select(int index)
Changes the selected factory.

Parameters:
index - the index of the newly selected factory, -1 will deselect any factory

select

public void select(int index,
                   boolean force)
Changes the selected factory.

Parameters:
index - the index of the newly selected factory, -1 will deselect any factory
force - true if an update should be forced even if there seems not to be a change

getSelectedKey

public java.lang.String getSelectedKey()
Gets the name of the currently selected factory.

Returns:
the name or null

getSelectedFactory

public ThemeFactory getSelectedFactory()
Gets the currently selected factory.

Returns:
the factory or null

size

public int size()
Gets the number of elements of this map.

Returns:
the number of elements

put

public void put(java.lang.String key,
                ThemeFactory factory)
Searches for an entry named key and changes its factory. If no such entry is found, then factory is added at the end of this map.

Parameters:
key - the name of the factory
factory - the new factory

add

public void add(java.lang.String key,
                ThemeFactory factory)
Adds factory at the end of this map. If there is already a factory named key, then that other factory is first removed.

Parameters:
key - the key of the new factory
factory - the new factory

insert

public void insert(int index,
                   java.lang.String key,
                   ThemeFactory factory)
Inserts a new factory into this map. If there is already a factory key in this map, then that other factory is removed.

Parameters:
index - the index where to insert the new factory
key - the key of the new factory
factory - the new factory

remove

public void remove(int index)
Removes the index'th entry of this map.

Parameters:
index - the name of the element to remove

remove

public boolean remove(java.lang.String key)
Deletes the factory associated with key.

Parameters:
key - the name of the element to remove
Returns:
true if the element was deleted, false if no element named key was found

indexOf

public int indexOf(ThemeFactory factory)
Searches for factory and returns its index.

Parameters:
factory - the factory to search
Returns:
its index or -1

indexOf

public int indexOf(java.lang.String key)
Searches for key and returns its location.

Parameters:
key - the key to search
Returns:
the index or -1

getKey

public java.lang.String getKey(int index)
Gets the key of the index'th element.

Parameters:
index - the index of the element
Returns:
the key to that element

getFactory

public ThemeFactory getFactory(int index)
Gets the index'th factory.

Parameters:
index - the index of the factory
Returns:
the factory, not null

getFactory

public ThemeFactory getFactory(java.lang.String key)
Searches the factory which is associated with key.

Parameters:
key - the unique name of a factory
Returns:
the factory, may be null