Search in sources :

Example 1 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class TimeConditionHelper method setTimeZoneOptions.

public void setTimeZoneOptions(boolean canModify, ConditionOpViewBeanBase viewBean, AMModel model) {
    if (canModify) {
        CCDropDownMenu list = (CCDropDownMenu) viewBean.getChild(STANDARDTIMEZONE);
        OptionList optList = new OptionList();
        String[] ids = TimeZone.getAvailableIDs();
        Set set = new HashSet(ids.length * 2);
        Map map = new HashMap(ids.length * 2);
        for (int i = 0; i < ids.length; i++) {
            String displayName = model.getLocalizedString(ids[i]);
            set.add(displayName);
            map.put(displayName, ids[i]);
        }
        List sorted = AMFormatUtils.sortItems(set, model.getUserLocale());
        for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
            String displayName = (String) iter.next();
            optList.add(displayName, (String) map.get(displayName));
        }
        list.setOptions(optList);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) HashMap(java.util.HashMap) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList) HashSet(java.util.HashSet)

Example 2 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class PolicyModelImpl method getAttrRadioBooleanChoiceValue.

private OptionList getAttrRadioBooleanChoiceValue(ActionSchema actionSchema, ResourceBundle rb) {
    OptionList optionList = new OptionList();
    String trueValue = actionSchema.getTrueValue();
    String falseValue = actionSchema.getFalseValue();
    if (trueValue == null) {
        trueValue = "true";
    }
    if (falseValue == null) {
        falseValue = "false";
    }
    String trueI18nKey = actionSchema.getTrueValueI18NKey();
    String falseI18nKey = actionSchema.getFalseValueI18NKey();
    if (trueI18nKey != null) {
        String label = com.sun.identity.shared.locale.Locale.getString(rb, trueI18nKey, debug);
        if ((label == null) || (label.length() == 0)) {
            optionList.add(trueValue, trueValue);
        } else {
            optionList.add(label, trueValue);
        }
    } else {
        optionList.add(trueValue, trueValue);
    }
    if (falseI18nKey != null) {
        String label = com.sun.identity.shared.locale.Locale.getString(rb, falseI18nKey, debug);
        if ((label == null) || (label.length() == 0)) {
            optionList.add(falseValue, falseValue);
        } else {
            optionList.add(label, falseValue);
        }
    } else {
        optionList.add(falseValue, falseValue);
    }
    return optionList;
}
Also used : OptionList(com.iplanet.jato.view.html.OptionList)

Example 3 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class AMPropertySheet method setValuesToAddRemove.

private boolean setValuesToAddRemove(View view, String name, Object values, AMModel amModel, AMPropertySheetModel model) {
    boolean set = false;
    if (CCAddRemove.class.isInstance(view)) {
        CCAddRemoveModel m = (CCAddRemoveModel) model.getModel(name);
        if (Set.class.isInstance(values)) {
            Set selectedSet = (Set) values;
            OptionList possibleOptions = model.getAddRemoveAvailOptions(name);
            if (possibleOptions != null) {
                OptionList availOptions = new OptionList();
                if ((selectedSet != null) && !selectedSet.isEmpty()) {
                    OptionList optList = new OptionList();
                    for (Iterator i = selectedSet.iterator(); i.hasNext(); ) {
                        String val = (String) i.next();
                        optList.add(possibleOptions.getValueLabel(val), val);
                    }
                    m.setSelectedOptionList(optList);
                    for (int i = 0; i < possibleOptions.size(); i++) {
                        Option opt = possibleOptions.get(i);
                        if (!selectedSet.contains(opt.getValue())) {
                            availOptions.add(opt);
                        }
                    }
                    m.setAvailableOptionList(availOptions);
                } else {
                    m.setAvailableOptionList(possibleOptions);
                }
            } else {
                m.setSelectedOptionList(AMViewBeanBase.createOptionList(selectedSet, amModel.getUserLocale()));
            }
        }
        set = true;
    }
    return set;
}
Also used : CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) Iterator(java.util.Iterator) Option(com.iplanet.jato.view.html.Option) OptionList(com.iplanet.jato.view.html.OptionList)

Example 4 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class ReorderAuthChainsViewBean method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    CCOrderableList list = (CCOrderableList) getChild(REORDER_LIST);
    CCOrderableListModel model = (CCOrderableListModel) list.getModel();
    String xml = (String) getPageSessionAttribute(AuthConfigViewBean.ENTRY_LIST);
    List chains = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xml));
    OptionList optList = new OptionList();
    int sz = chains.size();
    for (int i = 0; i < sz; i++) {
        AuthConfigurationEntry entry = (AuthConfigurationEntry) chains.get(i);
        String name = entry.getLoginModuleName();
        String flag = entry.getControlFlag();
        String options = entry.getOptions();
        String displayName = name + " - " + flag;
        if ((options != null) && (options.trim().length() > 0)) {
            displayName += " - " + options;
        }
        optList.add(displayName, Integer.toString(i));
    }
    model.setSelectedOptionList(optList);
}
Also used : CCOrderableListModel(com.sun.web.ui.model.CCOrderableListModel) ArrayList(java.util.ArrayList) CCOrderableList(com.sun.web.ui.view.orderablelist.CCOrderableList) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CCOrderableList(com.sun.web.ui.view.orderablelist.CCOrderableList) OptionList(com.iplanet.jato.view.html.OptionList) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 5 with OptionList

use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.

the class ActionTiledView method displaySingleChoiceAction.

private boolean displaySingleChoiceAction(ActionSchema actionSchema, String childName, int type, int syntax) {
    boolean display = false;
    RuleOpViewBeanBase parentVB = (RuleOpViewBeanBase) getParentViewBean();
    String serviceType = (String) parentVB.propertySheetModel.getValue(RuleOpViewBeanBase.SERVICE_TYPE);
    if (type == AMDisplayType.TYPE_SINGLE_CHOICE) {
        CCDropDownMenu list = (CCDropDownMenu) getChild(childName);
        OptionList optList = parentVB.getChoiceValues(serviceType, actionSchema);
        list.setOptions(optList);
        if ((optList != null) && (optList.size() > 0)) {
            if (!parentVB.isSubmitCycle()) {
                Set set = parentVB.getDefaultActionValues(actionSchema);
                String value = ((set == null) || set.isEmpty()) ? optList.getValue(0) : (String) set.iterator().next();
                list.setValue(value);
            }
            display = true;
        }
    }
    return display;
}
Also used : Set(java.util.Set) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) OptionList(com.iplanet.jato.view.html.OptionList)

Aggregations

OptionList (com.iplanet.jato.view.html.OptionList)75 Set (java.util.Set)35 Iterator (java.util.Iterator)27 CCDropDownMenu (com.sun.web.ui.view.html.CCDropDownMenu)25 Map (java.util.Map)24 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)21 HashSet (java.util.HashSet)17 List (java.util.List)15 HashMap (java.util.HashMap)13 ArrayList (java.util.ArrayList)9 Option (com.iplanet.jato.view.html.Option)7 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)7 CCAddRemove (com.sun.web.ui.view.addremove.CCAddRemove)7 EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)6 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)6 CCRadioButton (com.sun.web.ui.view.html.CCRadioButton)6 TreeSet (java.util.TreeSet)6 IdentitySubjectModel (com.sun.identity.console.policy.model.IdentitySubjectModel)5 TaskModel (com.sun.identity.console.task.model.TaskModel)5 CCSelect (com.sun.web.ui.view.html.CCSelect)5