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;
}
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;
}
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);
}
}
}
}
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;
}
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;
}
Aggregations