Search in sources :

Example 1 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel 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 CCEditableListModel

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

the class AMPropertySheetModel method parseNodeList.

private void parseNodeList(NodeList nodeList) {
    if (nodeList != null) {
        int length = nodeList.getLength();
        mapOptionList = new HashMap<String, OptionList>();
        for (int i = 0; i < length; i++) {
            Node node = nodeList.item(i);
            // Check node for name attribute.
            if (node.hasAttributes()) {
                NamedNodeMap nodeAttrs = node.getAttributes();
                Node nameNode = nodeAttrs.getNamedItem(NAME_ATTRIBUTE);
                Node tagclassNode = nodeAttrs.getNamedItem(CCDescriptor.CC_ELEMENT_TAGCLASS);
                if ((nameNode != null) && (tagclassNode != null)) {
                    String name = nameNode.getNodeValue();
                    String v = tagclassNode.getNodeValue();
                    if (name.startsWith(DATE_MARKER_NAME)) {
                        String dateName = name.substring(DATE_MARKER_NAME.length());
                        dateComponents.add(dateName);
                    } else if (v != null) {
                        if (v.equals(CCTagClass.EDITABLELIST)) {
                            setModel(name, new CCEditableListModel());
                        } else if (v.equals(CCTagClass.PASSWORD)) {
                            passwordComponents.add(name);
                        } else if (v.equals(CCTagClass.RADIOBUTTON)) {
                            String def = getNodeDefaultValue(node);
                            if (def != null) {
                                radioDefaultValue.put(name, def);
                            }
                        }
                        childMap.put(name, v);
                        NodeList optionElements = ((Element) node).getElementsByTagName(VALUE_OPTION_TAG_NAME);
                        if (optionElements.getLength() > 0) {
                            OptionList optionList = new OptionList();
                            int numOptions = optionElements.getLength();
                            for (int j = 0; j < numOptions; j++) {
                                Node option = optionElements.item(j);
                                if (option.hasAttributes()) {
                                    NamedNodeMap optAttrs = option.getAttributes();
                                    optionList.add(j, optAttrs.getNamedItem(OPTION_LABEL_ATTR_NAME).getNodeValue(), optAttrs.getNamedItem(OPTION_VALUE_ATTR_NAME).getNodeValue());
                                }
                            }
                            mapOptionList.put(name, optionList);
                        }
                    }
                    if (name.equals(TBL_SUB_CONFIG)) {
                        hasSubConfigTable = true;
                    }
                }
            }
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) OptionList(com.iplanet.jato.view.html.OptionList)

Example 3 with CCEditableListModel

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

the class RuleOpViewBeanBase method createTableModels.

private void createTableModels() {
    tblActionsModel = new CCActionTableModel(getClass().getClassLoader().getResourceAsStream("com/sun/identity/console/tblPMRulesActions.xml"));
    tblActionsModel.setTitleLabel("label.items");
    tblActionsModel.setActionValue(TBL_ACTIONS_COL_NAME, "policy.rules.actions.table.column.name");
    tblActionsModel.setActionValue(TBL_ACTIONS_COL_VALUE, "policy.rules.actions.table.column.value");
    tblActionsModel.setModel(TBL_ACTIONS_EDITABLE_LIST, new CCEditableListModel());
    propertySheetModel.setModel(TBL_ACTIONS, tblActionsModel);
}
Also used : CCActionTableModel(com.sun.web.ui.model.CCActionTableModel) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel)

Example 4 with CCEditableListModel

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

the class SiteEditViewBean method getFailoverURLs.

private void getFailoverURLs(String siteName, ServerSiteModel model) throws AMConsoleException {
    if (!submitCycle) {
        Set failoverURLs = model.getSiteFailoverURLs(siteName);
        CCEditableList elist = (CCEditableList) getChild(EDITABLE_FAILOVER_URLS);
        CCEditableListModel m = (CCEditableListModel) elist.getModel();
        elist.resetStateData();
        m.setOptionList(failoverURLs);
    }
}
Also used : CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) Set(java.util.Set) TreeSet(java.util.TreeSet) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel)

Example 5 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.
     *
     * @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)

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