|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.randgestalten.toolbar.AbstractToolbarBuilder<V,T>
public abstract class AbstractToolbarBuilder<V extends AbstractToolbarBuilder,T extends JComponent>
AbstractToolbarBuilder provides the basic abilities to create a custom TBuilder. If you extend this, be careful with the generic signature of the class. If you add methods to your new class, you have to make sure that all methods properly return your new implementation. Thats why the generics on the class are so ugly :)
You have to specify the return type for all builder methods and the type of the component that is created by the builder.
See AbstractSegmentedToolbarBuilder for an example.
The builder can use a custom component factory (use withComponentFactory(de.randgestalten.toolbar.AbstractToolbarBuilder.ComponentFactory)
to create components (i.e. Buttons from Actions, Seperators and group containers).
You can switch to custom ButtonUI implementations using withUI(Class). The UI is applied if you add Buttons
to the toolbar.
See ToolbarBuilder for a simple usage example.
| Nested Class Summary | |
|---|---|
static interface |
AbstractToolbarBuilder.ComponentFactory
The ConponentFactory is used to create group containers, Seperators and Buttons from actions. |
protected static class |
AbstractToolbarBuilder.DefaultComponentFactory
Default implementation. |
| Field Summary | |
|---|---|
protected V |
builder
Reference to the builder |
protected AbstractToolbarBuilder.ComponentFactory |
componentFactory
The current component factory |
protected Map<String,Object> |
componentProperties
Store component properties that are applied to all components |
protected boolean |
focusPainting
Should button focus be painted |
protected int |
orientation
The toolbar orientation |
protected V |
parent
A possible parent builder |
protected T |
toolbar
The toolbar component |
protected Class<? extends ButtonUI> |
uiclass
UI Class used for buttons |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Constructor Summary | |
|---|---|
|
AbstractToolbarBuilder()
Create a new Builder that create a JToolBar |
|
AbstractToolbarBuilder(JComponent toolbar)
Crate a builder that fills the given component. |
|
AbstractToolbarBuilder(JComponent toolbar,
int orientation)
Create a new builder that fills the given component with given direction. |
|
AbstractToolbarBuilder(JComponent toolbar,
int orientation,
Class<? extends ButtonUI> uiclass)
Create a new builder with given component, orientation and a default button ui class. |
|
AbstractToolbarBuilder(JToolBar toolbar)
Crate a builder that fills a given JToolBar |
protected |
AbstractToolbarBuilder(V parent,
JComponent container)
Craete groups using this constructor |
| Method Summary | |
|---|---|
V |
add(AbstractButton[] buttons)
Add all buttons to a new group. |
V |
add(Action action)
Craetes a Button for the given action using the component factory and add the button to the toolbar. |
V |
add(Action[] actions)
Create and adds buttons for all actions. |
V |
add(ButtonGroup group)
Create a group for all the buttons in the given ButtonGroup. |
V |
add(JComponent component)
Adds the given component to the toolbar |
protected void |
addImpl(JComponent component)
Internal method that adds component to the toolbar container |
V |
addSeperator()
Adds a default separator to the toolbar |
V |
addSeperator(Dimension dimension)
Adds a seperator with given size to the toolbar |
V |
close()
Close the builder. |
V |
createGroup()
Create a new group |
protected abstract V |
createGroup(JComponent container)
Create a new buidler group |
V |
createGroupContainer()
Create a new group that is based in a seperate container. |
V |
createGroupContainer(JComponent container)
Create a group that uses the given container |
protected V |
getBuilder()
Returns this builder. |
T |
getToolbar()
|
protected void |
initBuilder()
Initialize the builder |
protected JComponent |
installUI(AbstractButton button,
Class<? extends ButtonUI> ui)
Install the button UI for all AbstractButtons except JCheckBox and JRadioButton. |
protected void |
prepareComponent(JComponent component)
Called for each compoennt before added. |
V |
withComponentFactory(AbstractToolbarBuilder.ComponentFactory factory)
Sets the component factory used to create toolbar components. |
V |
withFocusPainting(boolean focusPainting)
Enable/Disable focus painting for buttons. |
V |
withProperty(String key,
Object value)
Add a property key value pair that is applied to each component added to the toolbar. |
V |
withUI(Class<? extends ButtonUI> uiclass)
Switch the button UI class used for buttons added. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Class<? extends ButtonUI> uiclass
protected T extends JComponent toolbar
protected int orientation
protected AbstractToolbarBuilder.ComponentFactory componentFactory
protected Map<String,Object> componentProperties
protected boolean focusPainting
protected V extends AbstractToolbarBuilder builder
protected V extends AbstractToolbarBuilder parent
| Constructor Detail |
|---|
public AbstractToolbarBuilder()
public AbstractToolbarBuilder(JToolBar toolbar)
toolbar - the toolbarpublic AbstractToolbarBuilder(JComponent toolbar)
toolbar - the toolabr component
public AbstractToolbarBuilder(JComponent toolbar,
int orientation)
toolbar - the componentorientation - the direction (HORIZONTAL or VERTICAL)
public AbstractToolbarBuilder(JComponent toolbar,
int orientation,
Class<? extends ButtonUI> uiclass)
toolbar - the toolbarorientation - the orientationuiclass - the ui class (null permited)
protected AbstractToolbarBuilder(V parent,
JComponent container)
parent - the parent buildercontainer - the container| Method Detail |
|---|
protected void initBuilder()
public V withProperty(String key,
Object value)
key - propety keyvalue - property value
public V withUI(Class<? extends ButtonUI> uiclass)
uiclass - the ui class or null
public V withComponentFactory(AbstractToolbarBuilder.ComponentFactory factory)
factory - the factory (null not permitted)
public V withFocusPainting(boolean focusPainting)
focusPainting - enable/disable focus painting
public V add(JComponent component)
component - the component
public V addSeperator()
public V addSeperator(Dimension dimension)
dimension - the prefered size of the toolbar
public V add(Action action)
action - the action
public V add(ButtonGroup group)
group - the button group
public V add(Action[] actions)
actions - the actions
public V add(AbstractButton[] buttons)
buttons - the buttons
public V createGroup()
public V createGroupContainer()
public V createGroupContainer(JComponent container)
container - the container
public T getToolbar()
protected V getBuilder()
protected void addImpl(JComponent component)
component - protected abstract V createGroup(JComponent container)
container - the container
public V close()
protected void prepareComponent(JComponent component)
component - the componet
protected JComponent installUI(AbstractButton button,
Class<? extends ButtonUI> ui)
button - the buttonui - the ui class
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||