Search in sources :

Example 6 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class AMPropertySheet method setValuesToEditableList.

private boolean setValuesToEditableList(View view, String name, Object values, AMModel amModel, AMPropertySheetModel model) {
    boolean set = false;
    if (CCEditableList.class.isInstance(view) && !CCUnOrderedList.class.isInstance(view) && !CCMapList.class.isInstance(view)) {
        ((CCEditableList) view).resetStateData();
        CCEditableListModel m = (CCEditableListModel) model.getModel(name);
        if (Set.class.isInstance(values)) {
            m.setOptionList(AMViewBeanBase.createOptionList((Set) values, amModel.getUserLocale(), false));
        }
        set = true;
    }
    return set;
}
Also used : CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) CCUnOrderedList(com.sun.identity.console.ui.view.CCUnOrderedList)

Example 7 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class ActionTiledView method displayEditableListAction.

private boolean displayEditableListAction(ActionSchema actionSchema, String childName, int type, int syntax) {
    boolean display = (type == AMDisplayType.TYPE_LIST);
    if (display) {
        CCEditableList child = (CCEditableList) getChild(childName);
        child.resetStateData();
        CCEditableListModel m = (CCEditableListModel) model.getModel(childName);
        RuleOpViewBeanBase parentVB = (RuleOpViewBeanBase) getParentViewBean();
        Set defaultValues = parentVB.getValues(m.getOptionList());
        if ((defaultValues == null) || defaultValues.isEmpty()) {
            defaultValues = parentVB.getDefaultActionValues(actionSchema);
            m.setOptionList(parentVB.createOptionList(defaultValues));
        }
    }
    return display;
}
Also used : CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) Set(java.util.Set) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel)

Example 8 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class AMPropertySheetModel method clear.

public void clear() {
    super.clear();
    for (Iterator iter = children.iterator(); iter.hasNext(); ) {
        View view = (View) iter.next();
        if (CCAddRemove.class.isInstance(view)) {
            CCAddRemoveModel m = (CCAddRemoveModel) getModel(view.getName());
            m.clear();
            m.setAvailableOptionList(new OptionList());
            m.setSelectedOptionList(new OptionList());
        } else if (CCEditableList.class.isInstance(view)) {
            CCEditableListModel m = (CCEditableListModel) getModel(view.getName());
            m.setOptionList(new OptionList());
            ((CCEditableList) view).resetStateData();
        } else if (CCOrderedList.class.isInstance(view)) {
            CCOrderedListModel m = (CCOrderedListModel) getModel(view.getName());
            m.setSelectedOptionList(new OptionList());
            ((CCOrderedList) view).resetStateData();
        } else if (CCUnOrderedList.class.isInstance(view)) {
            CCUnOrderedListModel m = (CCUnOrderedListModel) getModel(view.getName());
            m.setOptionList(new OptionList());
            ((CCUnOrderedList) view).resetStateData();
        } else if (CCMapList.class.isInstance(view)) {
            CCMapListModel m = (CCMapListModel) getModel(view.getName());
            m.setOptionList(new OptionList());
            ((CCMapList) view).resetStateData();
        } else {
            if (DisplayFieldImpl.class.isInstance(view)) {
                ((DisplayFieldImpl) view).setValues(null);
            }
        }
    }
}
Also used : DisplayFieldImpl(com.iplanet.jato.view.DisplayFieldImpl) CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) CCMapListModel(com.sun.identity.console.ui.model.CCMapListModel) CCOrderedListModel(com.sun.identity.console.ui.model.CCOrderedListModel) CCOrderedList(com.sun.identity.console.ui.view.CCOrderedList) View(com.iplanet.jato.view.View) ContainerView(com.iplanet.jato.view.ContainerView) CCMapList(com.sun.identity.console.ui.view.CCMapList) Iterator(java.util.Iterator) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) CCUnOrderedListModel(com.sun.identity.console.ui.model.CCUnOrderedListModel) OptionList(com.iplanet.jato.view.html.OptionList) CCUnOrderedList(com.sun.identity.console.ui.view.CCUnOrderedList)

Example 9 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class ConditionOpViewBeanBase method getConditionValues.

protected Map getConditionValues(PolicyModel model, String realmName, String conditionType) {
    List propertyNames = model.getConditionPropertyNames(realmName, conditionType);
    Map values = new HashMap(propertyNames.size() * 2);
    for (Iterator iter = propertyNames.iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        View child = getChild(name);
        if (child instanceof CCEditableList) {
            CCEditableList list = (CCEditableList) child;
            list.restoreStateData();
            CCEditableListModel m = (CCEditableListModel) list.getModel();
            Set selected = getValues(m.getOptionList());
            if ((selected != null) && !selected.isEmpty()) {
                values.put(name, selected);
            }
        } else {
            Object[] array = propertySheetModel.getValues(name);
            if ((array != null) && (array.length > 0)) {
                if (array.length == 1) {
                    String v = array[0].toString();
                    if ((v != null) && (v.trim().length() > 0)) {
                        Set val = new HashSet(2);
                        val.add(v.trim());
                        values.put(name, val);
                    }
                } else {
                    values.put(name, AMAdminUtils.toSet(array));
                }
            }
        }
    }
    return values;
}
Also used : CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) View(com.iplanet.jato.view.View) HashSet(java.util.HashSet)

Example 10 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class AMPropertySheet method getAttributeValues.

/**
     * Returns a map of attribute name to values which have different values 
     * from the original values.
     *
     * @param orig Map of attribute to original values.
     * @param modified true to return map of attribute name to values that
     *        have values that is different from values in <code>orig</code>.
     * @param matchPwd true to match password with confirm password value.
     * @param amModel <code>AMModel</code> object.
     * @return a map of attribute name to values.
     * @throws ModelControlException if cannot get model of property sheet.
     * @throws AMConsoleException if password and confirm password values do
     *         not match.
     */
public Map getAttributeValues(Map orig, boolean modified, boolean matchPwd, AMModel amModel) throws ModelControlException, AMConsoleException {
    restoreStateData(orig.keySet());
    AMPropertySheetModel model = (AMPropertySheetModel) getModel();
    Map attrValues = new HashMap(orig.size() * 2);
    Map multipleChoiceValues = getMultipleChoiceValues(model);
    for (Iterator iter = orig.keySet().iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        if (model.isChildSupported(name)) {
            Object tmpValue = orig.get(name);
            Set origValue = null;
            // the element type used in the display
            if (Set.class.isInstance(tmpValue)) {
                origValue = (Set) tmpValue;
            } else {
                // assuming this child is a list
                Map tmp = (Map) tmpValue;
                origValue = (Set) tmp.get("values");
            }
            Object childModel = model.getModel(name);
            Set values = null;
            if (CCAddRemoveModel.class.isInstance(childModel)) {
                values = getValues(((CCAddRemoveModel) childModel).getSelectedOptionList());
            } else if (CCEditableListModel.class.isInstance(childModel)) {
                values = getValues(((CCEditableListModel) childModel).getOptionList());
            } else if (CCOrderedListModel.class.isInstance(childModel)) {
                values = getListValues(((CCOrderedListModel) childModel).getSelectedOptionList());
                if (values == null || values.isEmpty()) {
                    values = new HashSet(1);
                    values.add("[0]=");
                }
            } else if (model.isChildSupported(name + PropertyTemplate.PWD_CONFIRM_SUFFIX)) {
                String pwd = (String) model.getValue(name);
                String confirmPwd = (String) model.getValue(name + PropertyTemplate.PWD_CONFIRM_SUFFIX);
                if (!matchPwd || pwd.equals(confirmPwd)) {
                    if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
                        values = new HashSet(2);
                        values.add(pwd);
                    } else {
                        values = (Set) orig.get(name);
                    }
                } else {
                    throw new AMConsoleException("password-mismatched");
                }
            } else if (model.isChildSupported(PropertyTemplate.DATE_MARKER_NAME + name)) {
                String date = (String) model.getValue(name);
                values = getDateInUserLocale(date, amModel);
            } else {
                values = (Set) multipleChoiceValues.get(name);
                if (values == null) {
                    // Convert to a set of values, excluding any empty strings
                    values = AMAdminUtils.toSetIgnoreEmpty(model.getValues(name));
                }
            }
            if (!modified || !equalsSet(values, origValue)) {
                attrValues.put(name, values);
            }
        }
    }
    return attrValues;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) HashMap(java.util.HashMap) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) Iterator(java.util.Iterator) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) CCOrderedListModel(com.sun.identity.console.ui.model.CCOrderedListModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

CCEditableListModel (com.sun.web.ui.model.CCEditableListModel)13 CCEditableList (com.sun.web.ui.view.editablelist.CCEditableList)7 Set (java.util.Set)6 CCOrderedListModel (com.sun.identity.console.ui.model.CCOrderedListModel)4 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 TreeSet (java.util.TreeSet)4 View (com.iplanet.jato.view.View)3 OptionList (com.iplanet.jato.view.html.OptionList)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)3 CCMapListModel (com.sun.identity.console.ui.model.CCMapListModel)3 CCUnOrderedListModel (com.sun.identity.console.ui.model.CCUnOrderedListModel)3 CCUnOrderedList (com.sun.identity.console.ui.view.CCUnOrderedList)3 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)3 HashMap (java.util.HashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)3 ContainerView (com.iplanet.jato.view.ContainerView)2