OptionGroup
Ausgabe von Class Attributen git-svn-id: https://svn.libreccm.org/ccm/trunk@2478 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
8a7131a612
commit
a62d12d63a
|
|
@ -43,33 +43,27 @@ import org.apache.log4j.Logger;
|
|||
* @author Uday Mathur
|
||||
* @author Rory Solomon
|
||||
* @author Michael Pih
|
||||
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $ */
|
||||
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $
|
||||
*/
|
||||
public abstract class OptionGroup extends Widget
|
||||
implements BebopConstants {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(OptionGroup.class);
|
||||
|
||||
/**
|
||||
* The XML element to be used by individual options belonging to this
|
||||
* group. This variable has to be initialized by every subclass of
|
||||
* OptionGroup.
|
||||
* The XML element to be used by individual options belonging to this group.
|
||||
* This variable has to be initialized by every subclass of OptionGroup.
|
||||
* LEGACY: An abstract method would be the better design, but changing it
|
||||
* would break the API. */
|
||||
* would break the API.
|
||||
*/
|
||||
protected String m_xmlElement;
|
||||
|
||||
// this only needs to be an ArrayList for multiple selection option groups
|
||||
private ArrayList m_selected;
|
||||
|
||||
private ArrayList m_options;
|
||||
|
||||
private Widget m_otherOption = null;
|
||||
|
||||
private Form m_form = null;
|
||||
private boolean m_isDisabled = false;
|
||||
private boolean m_isReadOnly = false;
|
||||
|
||||
public static final String OTHER_OPTION = "__other__";
|
||||
|
||||
// request-local copy of selected elements, options
|
||||
private RequestLocal m_requestOptions = new RequestLocal() {
|
||||
@Override
|
||||
|
|
@ -81,13 +75,13 @@ public abstract class OptionGroup extends Widget
|
|||
public final boolean isCompound() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// this is only used for single selection option groups
|
||||
private final static String TOO_MANY_OPTIONS_SELECTED =
|
||||
"Only one option may be selected by default on this option group.";
|
||||
|
||||
/** The ParameterModel for mutliple OptionGroups is always an array
|
||||
* parameter */
|
||||
/**
|
||||
* The ParameterModel for mutliple OptionGroups is always an array parameter
|
||||
*/
|
||||
protected OptionGroup(ParameterModel model) {
|
||||
super(model);
|
||||
m_options = new ArrayList();
|
||||
|
|
@ -102,8 +96,8 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an Iterator of all the default Options in this group,
|
||||
* plus any request-specific options.
|
||||
* Returns an Iterator of all the default Options in this group, plus any
|
||||
* request-specific options.
|
||||
*/
|
||||
public Iterator getOptions(PageState ps) {
|
||||
ArrayList allOptions = new ArrayList();
|
||||
|
|
@ -125,9 +119,9 @@ public abstract class OptionGroup extends Widget
|
|||
|
||||
/**
|
||||
* Adds a new option.
|
||||
* @param opt The {@link Option} to be added. Note: the argument
|
||||
* is modified and associated with this OptionGroup, regardless of
|
||||
* what its group was.
|
||||
*
|
||||
* @param opt The {@link Option} to be added. Note: the argument is modified
|
||||
* and associated with this OptionGroup, regardless of what its group was.
|
||||
*/
|
||||
public void addOption(Option opt) {
|
||||
addOption(opt, null, false);
|
||||
|
|
@ -139,9 +133,9 @@ public abstract class OptionGroup extends Widget
|
|||
|
||||
/**
|
||||
* Adds a new option.at the beginning of the list
|
||||
* @param opt The {@link Option} to be added. Note: the argument
|
||||
* is modified and associated with this OptionGroup, regardless of
|
||||
* what its group was.
|
||||
*
|
||||
* @param opt The {@link Option} to be added. Note: the argument is modified
|
||||
* and associated with this OptionGroup, regardless of what its group was.
|
||||
*/
|
||||
public void prependOption(Option opt) {
|
||||
addOption(opt, null, true);
|
||||
|
|
@ -156,15 +150,15 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a new option for the scope of the current request, or
|
||||
* to the page as a whole if there is no current request.
|
||||
* Adds a new option for the scope of the current request, or to the page as
|
||||
* a whole if there is no current request.
|
||||
*
|
||||
* @param opt The {@link Option} to be added. Note: the argument
|
||||
* is modified and associated with this OptionGroup, regardless of
|
||||
* what its group was.
|
||||
* @param opt The {@link Option} to be added. Note: the argument is modified
|
||||
* and associated with this OptionGroup, regardless of what its group was.
|
||||
* @param ps the current page state. if ps is null, adds option to the
|
||||
* default option list.
|
||||
* @param prepend If true, prepend option to the list instead of appending it
|
||||
* @param prepend If true, prepend option to the list instead of appending
|
||||
* it
|
||||
*/
|
||||
public void addOption(Option opt, PageState ps, boolean prepend) {
|
||||
ArrayList list = m_options;
|
||||
|
|
@ -182,7 +176,6 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeOption(Option opt, PageState ps) {
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
|
|
@ -198,8 +191,8 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the first option whose key is isEqual
|
||||
* to the key that is passed in.
|
||||
* Removes the first option whose key is isEqual to the key that is passed
|
||||
* in.
|
||||
*/
|
||||
public void removeOption(String key, PageState ps) {
|
||||
// This is not an entirely efficient technique. A more
|
||||
|
|
@ -308,10 +301,13 @@ public abstract class OptionGroup extends Widget
|
|||
});
|
||||
}
|
||||
|
||||
/** Make an option selected by default. Updates the parameter
|
||||
* model for the option group accordingly.
|
||||
/**
|
||||
* Make an option selected by default. Updates the parameter model for the
|
||||
* option group accordingly.
|
||||
*
|
||||
* @param value the value of the option to be added to the
|
||||
* by-default-selected set. */
|
||||
* by-default-selected set.
|
||||
*/
|
||||
public void setOptionSelected(String value) {
|
||||
Assert.isUnlocked(this);
|
||||
if (!isMultiple()) {
|
||||
|
|
@ -326,7 +322,9 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
/** make an option selected by default
|
||||
/**
|
||||
* make an option selected by default
|
||||
*
|
||||
* @param option the option to be added to the by-default-selected set.
|
||||
*/
|
||||
public void setOptionSelected(Option option) {
|
||||
|
|
@ -343,14 +341,14 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
|
||||
/**
|
||||
* Is this a multiple (and not single) selection option group?
|
||||
* Note that this should really be declared abstract, but we can't
|
||||
* because it used to be in the direct subclass Select and making
|
||||
* it abstract could break other subclasses that don't declare
|
||||
* isMultiple. So we have a trivial implementation instead.
|
||||
* Is this a multiple (and not single) selection option group? Note that
|
||||
* this should really be declared abstract, but we can't because it used to
|
||||
* be in the direct subclass Select and making it abstract could break other
|
||||
* subclasses that don't declare isMultiple. So we have a trivial
|
||||
* implementation instead.
|
||||
*
|
||||
* @return true if this OptionGroup can have more than one
|
||||
* selected option; false otherwise.
|
||||
* @return true if this OptionGroup can have more than one selected option;
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isMultiple() {
|
||||
return true;
|
||||
|
|
@ -389,9 +387,7 @@ public abstract class OptionGroup extends Widget
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates the DOM for the select widget
|
||||
* <p>Generates DOM fragment:
|
||||
* <p><pre><code><bebop:* name=... [onXXX=...]>
|
||||
* Generates the DOM for the select widget <p>Generates DOM fragment: <p><pre><code><bebop:* name=... [onXXX=...]>
|
||||
* <bebop:option name=... [selected]> option value </bebop:option%gt;
|
||||
* ...
|
||||
* </bebop:*select></code></pre>
|
||||
|
|
@ -401,6 +397,7 @@ public abstract class OptionGroup extends Widget
|
|||
Element optionGroup =
|
||||
parent.newChildElement(getElementTag(), BEBOP_XML_NS);
|
||||
optionGroup.addAttribute("name", getName());
|
||||
optionGroup.addAttribute("class", getName().replace(".", " "));
|
||||
if (isMultiple()) {
|
||||
optionGroup.addAttribute("multiple", "multiple");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue