Search in sources :

Example 1 with CCMapListModel

use of com.sun.identity.console.ui.model.CCMapListModel in project OpenAM by OpenRock.

the class AMPropertySheetModel method createChild.

public View createChild(View parent, String name, AMModel model) {
    String tagName = (String) childMap.get(name);
    View view = null;
    if (tagName != null) {
        if (tagName.equals(ORDERED_LIST)) {
            CCOrderedListModel m = new CCOrderedListModel();
            view = new CCOrderedList((ContainerView) parent, m, name);
            m.setAddButtonLabel(model.getLocalizedString("addremove.orderable.list.add.button"));
            m.setDeleteButtonLabel(model.getLocalizedString("addremove.orderable.list.delete.button"));
            setModel(name, m);
        } else if (tagName.equals(UNORDERED_LIST)) {
            CCUnOrderedListModel m = new CCUnOrderedListModel();
            view = new CCUnOrderedList((ContainerView) parent, m, name);
            setModel(name, m);
        } else if (tagName.equals(MAP_LIST) || tagName.equals(GLOBAL_MAP_LIST)) {
            CCMapListModel m = new CCMapListModel();
            view = new CCMapList((ContainerView) parent, m, name);
            m.setValueOptionList(mapOptionList.get(name));
            m.setKeyLabel(model.getLocalizedString("maplist.key.label"));
            m.setValueLabel(model.getLocalizedString("maplist.value.label"));
            m.setMsgInvalidEntry(model.getLocalizedString("maplist.msg.invalid.entry"));
            m.setMsgInvalidKey(model.getLocalizedString("maplist.msg.invalid.key"));
            m.setMsgInvalidValue(model.getLocalizedString("maplist.msg.invalid.value"));
            m.setMsgInvalidNoKey(model.getLocalizedString("maplist.msg.invalid.nokey"));
            setModel(name, m);
        } else if (tagName.equals(ADDREMOVE_LIST)) {
            CCAddRemoveModel m = (CCAddRemoveModel) getModel(name);
            if (m == null) {
                setModel(name, new CCAddRemoveModel());
            }
        }
    }
    if (view == null) {
        view = super.createChild(parent, name);
    }
    if (CCEditableList.class.isInstance(view)) {
        CCEditableList editable = (CCEditableList) view;
        CCEditableListModel m = (CCEditableListModel) editable.getModel();
        m.setAddBtnLabel(model.getLocalizedString("editableList.addButtonLabel"));
        m.setRemoveBtnLabel(model.getLocalizedString("editableList.deleteButtonLabel"));
    }
    children.add(view);
    return view;
}
Also used : CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) CCMapListModel(com.sun.identity.console.ui.model.CCMapListModel) CCMapList(com.sun.identity.console.ui.view.CCMapList) CCUnOrderedListModel(com.sun.identity.console.ui.model.CCUnOrderedListModel) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) ContainerView(com.iplanet.jato.view.ContainerView) 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) CCUnOrderedList(com.sun.identity.console.ui.view.CCUnOrderedList)

Example 2 with CCMapListModel

use of com.sun.identity.console.ui.model.CCMapListModel in project OpenAM by OpenRock.

the class AMPropertySheet method setValuesToMapList.

private boolean setValuesToMapList(View view, String name, Object values, AMModel amModel, AMPropertySheetModel model) {
    boolean set = false;
    if (CCMapList.class.isInstance(view)) {
        ((CCMapList) view).resetStateData();
        CCMapListModel m = (CCMapListModel) model.getModel(name);
        if (Set.class.isInstance(values)) {
            Set v = new LinkedHashSet();
            v.addAll((Set) values);
            v.remove("[]=");
            m.setOptionList(AMViewBeanBase.createOptionList(v, amModel.getUserLocale(), false));
        }
        set = true;
    }
    return set;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCMapListModel(com.sun.identity.console.ui.model.CCMapListModel) CCMapList(com.sun.identity.console.ui.view.CCMapList)

Example 3 with CCMapListModel

use of com.sun.identity.console.ui.model.CCMapListModel in project OpenAM by OpenRock.

the class AMPropertySheet method getAttributeValues.

/**
     * Returns a map of attribute name to values.
     *
     * @param attrNames Set of attribute names to retrieve.
     * @return 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(Collection attrNames) throws ModelControlException, AMConsoleException {
    restoreStateData(attrNames);
    AMPropertySheetModel model = (AMPropertySheetModel) getModel();
    Map attrValues = new HashMap(attrNames.size() * 2);
    Map multipleChoiceValues = getMultipleChoiceValues(model);
    for (Iterator iter = attrNames.iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        Object childModel = model.getModel(name);
        Set values = null;
        if (CCAddRemoveModel.class.isInstance(childModel)) {
            values = getValues(((CCAddRemoveModel) childModel).getSelectedOptionList());
        } else if (CCUnOrderedListModel.class.isInstance(childModel)) {
            values = getListValues(((CCUnOrderedListModel) childModel).getOptionList());
            if ((values == null) || values.isEmpty()) {
                values = new HashSet(2);
                values.add("[0]=");
            }
        } else if (CCMapListModel.class.isInstance(childModel)) {
            values = getValues(((CCMapListModel) childModel).getOptionList());
            if ((values == null) || values.isEmpty()) {
                values = new HashSet(2);
                values.add("[]=");
            }
        } 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(2);
                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 (pwd.equals(confirmPwd)) {
                if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
                    values = new HashSet(2);
                    values.add(pwd);
                }
            } else {
                throw new AMConsoleException("password-mismatched");
            }
        } else {
            values = (Set) multipleChoiceValues.get(name);
            if (values == null) {
                values = AMAdminUtils.toSetIgnoreEmpty(model.getValues(name));
            }
        }
        if (values != null) {
            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) CCMapListModel(com.sun.identity.console.ui.model.CCMapListModel) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) CCOrderedListModel(com.sun.identity.console.ui.model.CCOrderedListModel) Iterator(java.util.Iterator) CCUnOrderedListModel(com.sun.identity.console.ui.model.CCUnOrderedListModel) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 4 with CCMapListModel

use of com.sun.identity.console.ui.model.CCMapListModel 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)

Aggregations

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