package org.pietschy.command.demo;
import org.pietschy.command.ExclusiveGroupCommand;
import org.pietschy.command.CommandContainer;
import org.pietschy.command.Face;
import com.l2fprod.common.swing.JButtonBar;
/**
* This class extends {@link ToggleCommandGroup} to provide a widget based on the
* JButtonBar component from http://l2fprod.com/.
* @version $Revision: 1.5 $
* @author andrewp
*/
public class
PageSelectorGroup
extends ToggleCommandGroup
{
private static final String SELECTOR_FACE = "page-selector";
/**
* Creates a new group with the specified Id and that uses the specified {@link CommandManager}.
* @param groupId the id of the group.
* @param container the {@link CommandManager} the group is to use.
*/
public PageSelectorGroup(CommandManager container, String groupId)
{
super(container, groupId);
setExclusive(true);
}
/**
* Creates a new vertical JButtonBar using the "page-selector" face.
* @return a new JButtonBar for this group.
*/
public JButtonBar createButtonBar()
{
return createButtonBar(JButtonBar.VERTICAL);
}
/**
* Creates a new JButtonBar with the specified orientation using the "page-selector" face.
* @param orientation the orientation of the bar, either {@link JButtonBar#VERTICAL} or
* {@link JButtonBar#HORIZONTAL}.
*
* @return a new JButtonBar for this group.
*/
public JButtonBar createButtonBar(int orientation)
{
return createButtonBar(orientation, SELECTOR_FACE);
}
/**
* Creates a new JButtonBar with the specified orientation using the specified face.
* @param orientation the orientation of the bar, either {@link JButtonBar#VERTICAL} or
* {@link JButtonBar#HORIZONTAL}.
* @param faceName the face for button bar and its members to use.
*
* @return a new JButtonBar for this group.
*/
public JButtonBar createButtonBar(int orientation, String faceName)
{
JButtonBar buttonBar = new JButtonBar(orientation);
bindMembers(buttonBar, buttonBar, getButtonFactory(), faceName);
return buttonBar;
}
/**
* Overrides the default implementation to provide defaults for the page-selector face if
* it hasn't been specified.
* @param face the desired face name
* @return a String array with the alternate faces in preferred order.
*/
public String[]
getAlternativeFaceNames(String face)
{
if (SELECTOR_FACE.equals(face))
return new String[]{Face.BUTTON, Face.DEFAULT};
return super.getAlternativeFaceNames(face);
}
}