use of com.sun.identity.console.ui.view.CCOrderedList in project OpenAM by OpenRock.
the class CCOrderedListTag method getHTMLStringInternal.
protected String getHTMLStringInternal(Tag parent, PageContext pageContext, View view) throws JspException {
CCOrderedList field = (CCOrderedList) super.init(parent, pageContext, view, CCOrderedList.class);
initChildViews(field);
String strHTML = super.getHTMLStringInternal(parent, pageContext, view);
includeJavascriptFile(CCJavascript.EDITABLELIST_JS);
int idx = strHTML.lastIndexOf("class=\"Btn2Dis\"");
idx = strHTML.indexOf("/>", idx) + 2;
strHTML = strHTML.substring(0, idx) + "\n<div class=\"" + CCStyle.ADDREMOVE_HORIZONTAL_BETWEEN + "\">\n" + deleteBtnString + "\n</div>" + strHTML.substring(idx);
strHTML += getJavascript(view);
idx = strHTML.indexOf("handleSelectedOnChange();");
int idx2 = strHTML.lastIndexOf("javascript", idx);
idx = strHTML.indexOf("return", idx);
String js = strHTML.substring(idx2, idx);
js = js.replaceAll("CCOrderableList_", "Editable_");
strHTML = strHTML.substring(0, idx) + js + strHTML.substring(idx);
strHTML = swapNameSpace(strHTML, "removeFromList();");
idx = strHTML.lastIndexOf("handleReload();");
idx2 = strHTML.lastIndexOf("Editable_", idx);
js = strHTML.substring(idx2, idx);
js += "selectedHiddenText = document.forms['" + getFormName() + "'].elements['" + jsNameQualifier + ".SelectedTextField'];";
strHTML = strHTML.substring(0, idx + 15) + js + strHTML.substring(idx + 15);
textfieldString = textfieldTag.getHTMLString(parent, pageContext, textfield);
idx = strHTML.lastIndexOf("</tr>");
strHTML = strHTML.substring(0, idx + 5) + "<tr><td> </td><td colspan=\"2\">" + "<table title=\"\" border=\"0\" cellspacing=\"0\" " + "cellpadding=\"0\" class=\"" + CCStyle.EDITABLELIST_ADD_TABLE + "\"><tr><td>" + textfieldString + " " + addBtnString + "</div></td></tr></table></td></tr>" + strHTML.substring(idx + 5);
strHTML = swapNameSpace(strHTML, "addToList();");
return strHTML;
}
use of com.sun.identity.console.ui.view.CCOrderedList 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;
}
use of com.sun.identity.console.ui.view.CCOrderedList in project OpenAM by OpenRock.
the class AMPropertySheet method restoreStateData.
/**
* Automates the restoring of store data in some children. This is required
* for some special children such as <code>CCAddRemvoe</code>.
*
* @throws ModelControlException if cannot get model of property sheet.
*/
public void restoreStateData(Collection participatingChildren) throws ModelControlException {
ViewBean parent = getParentViewBean();
String[] names = parent == null ? null : parent.getChildNames();
if ((names != null) && (names.length > 0)) {
for (int i = 0; i < names.length; i++) {
String name = names[i];
if (participatingChildren.contains(name)) {
View child = parent.getChild(name);
if (CCAddRemove.class.isInstance(child)) {
((CCAddRemove) child).restoreStateData();
} else if (CCUnOrderedList.class.isInstance(child)) {
((CCUnOrderedList) child).restoreStateData();
} else if (CCMapList.class.isInstance(child)) {
((CCMapList) child).restoreStateData();
} else if (CCEditableList.class.isInstance(child)) {
((CCEditableList) child).restoreStateData();
} else if (CCOrderedList.class.isInstance(child)) {
((CCOrderedList) child).restoreStateData();
} else if (CCActionTable.class.isInstance(child)) {
((CCActionTable) child).restoreStateData();
}
}
}
}
}
use of com.sun.identity.console.ui.view.CCOrderedList in project OpenAM by OpenRock.
the class AMPropertySheet method setValuesToOrderedList.
private boolean setValuesToOrderedList(View view, String name, Object values, AMModel amModel, AMPropertySheetModel model) {
boolean set = false;
if (CCOrderedList.class.isInstance(view)) {
((CCOrderedList) view).resetStateData();
CCOrderedListModel m = (CCOrderedListModel) model.getModel(name);
if (Set.class.isInstance(values)) {
Set sorted = new TreeSet(new OrderedListComparator());
sorted.addAll((Set) values);
if (sorted.size() == 1) {
String tmp = (String) sorted.iterator().next();
if (tmp.equals("[0]=")) {
sorted.clear();
}
}
List list = new ArrayList();
for (Iterator i = sorted.iterator(); i.hasNext(); ) {
String val = (String) i.next();
int idx = val.indexOf(']');
idx = val.indexOf('=', idx);
list.add(val.substring(idx + 1).trim());
}
m.setSelectedOptionList(AMViewBeanBase.createOptionList(list, amModel.getUserLocale(), false));
}
set = true;
}
return set;
}
use of com.sun.identity.console.ui.view.CCOrderedList 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);
}
}
}
}
Aggregations