use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class AjaxTabbedPanel method findTabs.
/**
* Looks through the child components to locate the AjaxTabbedPanelTabs that are controlled by this panel.
* Tabs without an explicit id attributed are assigned a calculated one.
*
* @param template the graph of elements passed to the constructor.
*/
private void findTabs(WODynamicGroup template) {
if (template == null || template.childrenElements() == null)
return;
NSArray children = template.childrenElements();
for (int i = 0; i < children.count(); i++) {
WOElement child = (WOElement) children.objectAtIndex(i);
if (child instanceof AjaxTabbedPanelTab) {
AjaxTabbedPanelTab childTab = (AjaxTabbedPanelTab) child;
// The tabs need to have an id attribute so we assign one if needed
if (childTab.id() == null) {
childTab.setParentId(id);
childTab.setTabNumber(new WOConstantValueAssociation("_pane_" + tabs.count()));
}
tabs.addObject(childTab);
} else if (child instanceof WODynamicGroup) {
findTabs((WODynamicGroup) child);
}
}
}
use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class AjaxTree method _fillInOpenNodes.
protected void _fillInOpenNodes(Object node, NSMutableArray nodes, boolean showNode) {
if (showNode) {
nodes.addObject(node);
}
if (treeModel().isExpanded(node)) {
NSArray childrenTreeNodes = treeModel().childrenTreeNodes(node);
if (childrenTreeNodes != null) {
int childTreeNodeCount = childrenTreeNodes.count();
for (int childTreeNodeNum = 0; childTreeNodeNum < childTreeNodeCount; childTreeNodeNum++) {
Object childNode = childrenTreeNodes.objectAtIndex(childTreeNodeNum);
_fillInOpenNodes(childNode, nodes, true);
}
}
}
}
use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class AjaxAutoComplete method listeJS.
protected String listeJS() {
StringBuilder str = new StringBuilder();
str.append("new Array(");
NSArray list = (NSArray) valueForBinding("list");
int max = list.count();
boolean hasItem = hasBinding("item");
for (int i = 0; i < max; i++) {
Object ds = list.objectAtIndex(i);
if (i > 0) {
str.append(',');
}
str.append("\n\"");
if (hasItem) {
setValueForBinding(ds, "item");
}
Object displayValue = valueForBinding("displayString", valueForBinding("item", ds));
String escapedValue = displayValue.toString();
if (escapedValue.contains("\"")) {
escapedValue = escapedValue.replaceAll("(?<!\\\\)\"", "\\\\\\\"");
}
str.append(escapedValue);
str.append('"');
}
str.append(')');
return str.toString();
}
use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class AjaxAutoComplete method setStringValue.
public void setStringValue(String strValue) {
if (hasBinding("selection")) {
Object selection = null;
if (strValue != null) {
NSArray values = (NSArray) valueForBinding("list");
int maxItems = maxItems();
int itemsCount = 0;
for (Enumeration e = values.objectEnumerator(); e.hasMoreElements() && itemsCount++ < maxItems; ) {
Object value = e.nextElement();
setValueForBinding(value, "item");
String displayString = displayStringForValue(value);
if (Objects.equals(displayString, strValue)) {
selection = value;
break;
}
}
}
setValueForBinding(selection, "selection");
}
setValueForBinding(strValue, "value");
}
use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class AjaxAutoComplete method handleRequest.
/**
* Handles the Ajax request. Checks for the form value in the edit field,
* pushes it up to the parent and pulls the "list" binding. The parent is
* responsible for returning a list with some items that match the current value.
*/
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
// String inputString = request.contentString();
String fieldValue = context.request().stringFormValueForKey(fieldName);
setValueForBinding(fieldValue, "value");
WOResponse response = AjaxUtils.createResponse(request, context);
response.appendContentString("<ul>");
int maxItems = maxItems();
int itemsCount = 0;
Object values = valueForBinding("list");
WOElement child = _childTemplate();
boolean hasItem = hasBinding("item");
if (values instanceof NSArray) {
for (Enumeration valueEnum = ((NSArray) values).objectEnumerator(); valueEnum.hasMoreElements() && itemsCount++ < maxItems; ) {
appendItemToResponse(valueEnum.nextElement(), child, hasItem, response, context);
}
} else if (values instanceof List) {
for (Iterator iter = ((List) values).iterator(); iter.hasNext() && itemsCount++ < maxItems; ) {
appendItemToResponse(iter.next(), child, hasItem, response, context);
}
} else if (values instanceof Object[]) {
Object[] array = (Object[]) values;
for (int i = 0; i < array.length && i < maxItems; i++) {
appendItemToResponse(array[i], child, hasItem, response, context);
}
} else if (values != null) {
log.warn("Unsupported class type for list: {}", values.getClass().getCanonicalName());
}
response.appendContentString("</ul>");
return response;
}
Aggregations