ca.sqlpower.wabit.swingui
Class WabitToolBarBuilder

java.lang.Object
  extended by ca.sqlpower.wabit.swingui.WabitToolBarBuilder

public class WabitToolBarBuilder
extends java.lang.Object

A lot of the JToolBars that were being added to Wabit were coded with a lot of boilerplate code. In particular, buttons were having their text set to be at the bottom and centred, and having a client property set to that they would render without button borders on OS X (Leopard and later (hopefully)) Also, each toolbar was being placed with a 'Wabit Logo' button on the right that opens to the support forum. This class is intended to centralize most of the boilerplate code so that making a JToolBar that looks like all the other JToolBars in the Wabit application doesn't require so much repeated code.


Constructor Summary
WabitToolBarBuilder()
          Creates a WabitToolBarBuilder with a 'Wabit' button on the end of the toolbar that takes you to the support forum when clicked.
WabitToolBarBuilder(boolean addForumButton)
          Creates a WabitToolBarBuilder with the option to add a 'Wabit' button on the end of the toolbar that takes you to the support forum when clicked.
 
Method Summary
 void add(javax.swing.Action action)
          Adds an Action as a button to the toolbar.
 void add(javax.swing.Action a, java.lang.String text)
          Adds an Action as a button to the toolbar.
 void add(javax.swing.Action a, java.lang.String text, javax.swing.Icon icon)
          Add an Action that will be added as a button to the toolbar.
 void add(java.awt.Component component)
          Add a component to the toolbar.
 void add(javax.swing.JButton button)
          Add a button to the tool bar.
 void add(javax.swing.JButton button, java.lang.String text, javax.swing.Icon icon)
          Add a button that will be added as a button to the toolbar.
 void addSeparator()
          Add a separatot to the toolbar.
 void clear()
          This will remove all of the buttons from the button bar of this tool bar.
 javax.swing.JToolBar getToolbar()
          Get the final JToolBar component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WabitToolBarBuilder

public WabitToolBarBuilder()
Creates a WabitToolBarBuilder with a 'Wabit' button on the end of the toolbar that takes you to the support forum when clicked.


WabitToolBarBuilder

public WabitToolBarBuilder(boolean addForumButton)
Creates a WabitToolBarBuilder with the option to add a 'Wabit' button on the end of the toolbar that takes you to the support forum when clicked.

Parameters:
addForumButton - Set to true to include the Wabit forum button. Set to false to not include the Wabit forum button.
Method Detail

getToolbar

public javax.swing.JToolBar getToolbar()
Get the final JToolBar component. Typically you would call this once you're done adding all the buttons and components you want.

Returns:
An instance of JToolBar with specially formatted JButtons and a Wabit button at the end.

add

public void add(javax.swing.Action action)
Adds an Action as a button to the toolbar.

Parameters:
action - The Action to add to the toolbar. Its name will be the button's label

add

public void add(javax.swing.Action a,
                java.lang.String text)
Adds an Action as a button to the toolbar.

Parameters:
a - The Action to add to the toolbar
text - The text to set as the button's label If text is null, toolbar button will get name from a

add

public void add(javax.swing.Action a,
                java.lang.String text,
                javax.swing.Icon icon)
Add an Action that will be added as a button to the toolbar. If the icon is not null it will be placed on the button.

Parameters:
a - The Action which to add to the ToolBar
text - The text to set as the button's label. If text is null, ToolBar button will get name from a
icon - The icon that will be placed on the button. If this is null then the icon defined in the action will be used.

add

public void add(javax.swing.JButton button,
                java.lang.String text,
                javax.swing.Icon icon)
Add a button that will be added as a button to the toolbar. This method will change the look of the given button to have its text below the icon among other things. If the icon is not null it will be placed on the button.

Parameters:
button - The button which to add to the ToolBar
text - The text to set as the button's label. If null, the button's text will not be changed.
icon - The icon that will be placed on the button. If this is null then the icon defined in the action will be used.

add

public void add(javax.swing.JButton button)
Add a button to the tool bar. Sets the button type for OSX to remove borders.


add

public void add(java.awt.Component component)
Add a component to the toolbar.


addSeparator

public void addSeparator()
Add a separatot to the toolbar.


clear

public void clear()
This will remove all of the buttons from the button bar of this tool bar. This will not remove the forum button.



Copyright © 2009. All Rights Reserved.