id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
139,000
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/JavaDocText.java
JavaDocText.stripAsterisk
private void stripAsterisk(final StringBuilder javaDoc) { int index = javaDoc.indexOf("*"); while (index != -1) { javaDoc.replace(index, index + 1, ""); index = javaDoc.indexOf("*"); } }
java
private void stripAsterisk(final StringBuilder javaDoc) { int index = javaDoc.indexOf("*"); while (index != -1) { javaDoc.replace(index, index + 1, ""); index = javaDoc.indexOf("*"); } }
[ "private", "void", "stripAsterisk", "(", "final", "StringBuilder", "javaDoc", ")", "{", "int", "index", "=", "javaDoc", ".", "indexOf", "(", "\"*\"", ")", ";", "while", "(", "index", "!=", "-", "1", ")", "{", "javaDoc", ".", "replace", "(", "index", ",", "index", "+", "1", ",", "\"\"", ")", ";", "index", "=", "javaDoc", ".", "indexOf", "(", "\"*\"", ")", ";", "}", "}" ]
This method removes the additional astrisks from the java doc. @param javaDoc the string builder containing the javadoc.
[ "This", "method", "removes", "the", "additional", "astrisks", "from", "the", "java", "doc", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/JavaDocText.java#L78-L84
139,001
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/JavaDocText.java
JavaDocText.parseLink
private String parseLink(final String link) { String[] tokens = link.substring(7, link.length() - 1).split("\\s"); if (tokens.length == 1) { return tokens[0]; } StringBuilder result = new StringBuilder(); boolean parametersSeen = false; boolean inParameters = false; for (int index = 0; index < tokens.length; index++) { result.append(" ").append(tokens[index]); if (tokens[index].indexOf('(') != -1 && !parametersSeen) { inParameters = true; } if (index == 1 && !inParameters) { result = new StringBuilder(tokens[index]); } if (tokens[index].indexOf(')') != -1 && !parametersSeen) { parametersSeen = true; if (index != tokens.length - 1) { result = new StringBuilder(); } } } return result.toString().trim(); }
java
private String parseLink(final String link) { String[] tokens = link.substring(7, link.length() - 1).split("\\s"); if (tokens.length == 1) { return tokens[0]; } StringBuilder result = new StringBuilder(); boolean parametersSeen = false; boolean inParameters = false; for (int index = 0; index < tokens.length; index++) { result.append(" ").append(tokens[index]); if (tokens[index].indexOf('(') != -1 && !parametersSeen) { inParameters = true; } if (index == 1 && !inParameters) { result = new StringBuilder(tokens[index]); } if (tokens[index].indexOf(')') != -1 && !parametersSeen) { parametersSeen = true; if (index != tokens.length - 1) { result = new StringBuilder(); } } } return result.toString().trim(); }
[ "private", "String", "parseLink", "(", "final", "String", "link", ")", "{", "String", "[", "]", "tokens", "=", "link", ".", "substring", "(", "7", ",", "link", ".", "length", "(", ")", "-", "1", ")", ".", "split", "(", "\"\\\\s\"", ")", ";", "if", "(", "tokens", ".", "length", "==", "1", ")", "{", "return", "tokens", "[", "0", "]", ";", "}", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "parametersSeen", "=", "false", ";", "boolean", "inParameters", "=", "false", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "tokens", ".", "length", ";", "index", "++", ")", "{", "result", ".", "append", "(", "\" \"", ")", ".", "append", "(", "tokens", "[", "index", "]", ")", ";", "if", "(", "tokens", "[", "index", "]", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", "&&", "!", "parametersSeen", ")", "{", "inParameters", "=", "true", ";", "}", "if", "(", "index", "==", "1", "&&", "!", "inParameters", ")", "{", "result", "=", "new", "StringBuilder", "(", "tokens", "[", "index", "]", ")", ";", "}", "if", "(", "tokens", "[", "index", "]", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", "&&", "!", "parametersSeen", ")", "{", "parametersSeen", "=", "true", ";", "if", "(", "index", "!=", "tokens", ".", "length", "-", "1", ")", "{", "result", "=", "new", "StringBuilder", "(", ")", ";", "}", "}", "}", "return", "result", ".", "toString", "(", ")", ".", "trim", "(", ")", ";", "}" ]
a helper method to process the links as they are found. @param link the string representing the original link. @return a new string to replace the old link.
[ "a", "helper", "method", "to", "process", "the", "links", "as", "they", "are", "found", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/JavaDocText.java#L108-L137
139,002
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WTabAndCollapsibleExample.java
WTabAndCollapsibleExample.newVisibilityToggleForTab
private WButton newVisibilityToggleForTab(final int idx) { WButton toggleButton = new WButton("Toggle visibility of tab " + (idx + 1)); toggleButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { boolean tabVisible = tabset.isTabVisible(idx); tabset.setTabVisible(idx, !tabVisible); } }); return toggleButton; }
java
private WButton newVisibilityToggleForTab(final int idx) { WButton toggleButton = new WButton("Toggle visibility of tab " + (idx + 1)); toggleButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { boolean tabVisible = tabset.isTabVisible(idx); tabset.setTabVisible(idx, !tabVisible); } }); return toggleButton; }
[ "private", "WButton", "newVisibilityToggleForTab", "(", "final", "int", "idx", ")", "{", "WButton", "toggleButton", "=", "new", "WButton", "(", "\"Toggle visibility of tab \"", "+", "(", "idx", "+", "1", ")", ")", ";", "toggleButton", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "boolean", "tabVisible", "=", "tabset", ".", "isTabVisible", "(", "idx", ")", ";", "tabset", ".", "setTabVisible", "(", "idx", ",", "!", "tabVisible", ")", ";", "}", "}", ")", ";", "return", "toggleButton", ";", "}" ]
Creates a button to toggle the visibility of a tab. @param idx the index of the tab. @return a button which toggles the visibility of the tab.
[ "Creates", "a", "button", "to", "toggle", "the", "visibility", "of", "a", "tab", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WTabAndCollapsibleExample.java#L68-L80
139,003
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/WTableOptionsExample.java
WTableOptionsExample.createRadioButtonGroup
private <T extends Enum<T>> EnumerationRadioButtonSelect<T> createRadioButtonGroup( final T[] options) { EnumerationRadioButtonSelect<T> rbSelect = new EnumerationRadioButtonSelect<>(options); rbSelect.setButtonLayout(EnumerationRadioButtonSelect.Layout.FLAT); rbSelect.setFrameless(true); return rbSelect; }
java
private <T extends Enum<T>> EnumerationRadioButtonSelect<T> createRadioButtonGroup( final T[] options) { EnumerationRadioButtonSelect<T> rbSelect = new EnumerationRadioButtonSelect<>(options); rbSelect.setButtonLayout(EnumerationRadioButtonSelect.Layout.FLAT); rbSelect.setFrameless(true); return rbSelect; }
[ "private", "<", "T", "extends", "Enum", "<", "T", ">", ">", "EnumerationRadioButtonSelect", "<", "T", ">", "createRadioButtonGroup", "(", "final", "T", "[", "]", "options", ")", "{", "EnumerationRadioButtonSelect", "<", "T", ">", "rbSelect", "=", "new", "EnumerationRadioButtonSelect", "<>", "(", "options", ")", ";", "rbSelect", ".", "setButtonLayout", "(", "EnumerationRadioButtonSelect", ".", "Layout", ".", "FLAT", ")", ";", "rbSelect", ".", "setFrameless", "(", "true", ")", ";", "return", "rbSelect", ";", "}" ]
Create a radio button select containing the options. @param <T> the enumeration type. @param options the list of options @return a radioButtonSelect with the options
[ "Create", "a", "radio", "button", "select", "containing", "the", "options", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/WTableOptionsExample.java#L302-L308
139,004
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/WTableOptionsExample.java
WTableOptionsExample.displaySelected
private void displaySelected() { copySelection(table1, selected1); copySelection(table2, selected2); copySelection(table3, selected3); }
java
private void displaySelected() { copySelection(table1, selected1); copySelection(table2, selected2); copySelection(table3, selected3); }
[ "private", "void", "displaySelected", "(", ")", "{", "copySelection", "(", "table1", ",", "selected1", ")", ";", "copySelection", "(", "table2", ",", "selected2", ")", ";", "copySelection", "(", "table3", ",", "selected3", ")", ";", "}" ]
Display the rows that have been selected.
[ "Display", "the", "rows", "that", "have", "been", "selected", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/WTableOptionsExample.java#L439-L443
139,005
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java
WNumberField.convertValue
private BigDecimal convertValue(final Object value) { if (value == null) { return null; } else if (value instanceof BigDecimal) { return (BigDecimal) value; } // Try and convert "String" value String dataString = value.toString(); if (Util.empty(dataString)) { return null; } try { return new BigDecimal(dataString); } catch (NumberFormatException ex) { throw new SystemException( "Could not convert data of type " + value.getClass() + " with String value " + dataString + " to BigDecimal", ex); } }
java
private BigDecimal convertValue(final Object value) { if (value == null) { return null; } else if (value instanceof BigDecimal) { return (BigDecimal) value; } // Try and convert "String" value String dataString = value.toString(); if (Util.empty(dataString)) { return null; } try { return new BigDecimal(dataString); } catch (NumberFormatException ex) { throw new SystemException( "Could not convert data of type " + value.getClass() + " with String value " + dataString + " to BigDecimal", ex); } }
[ "private", "BigDecimal", "convertValue", "(", "final", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "else", "if", "(", "value", "instanceof", "BigDecimal", ")", "{", "return", "(", "BigDecimal", ")", "value", ";", "}", "// Try and convert \"String\" value", "String", "dataString", "=", "value", ".", "toString", "(", ")", ";", "if", "(", "Util", ".", "empty", "(", "dataString", ")", ")", "{", "return", "null", ";", "}", "try", "{", "return", "new", "BigDecimal", "(", "dataString", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "throw", "new", "SystemException", "(", "\"Could not convert data of type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" with String value \"", "+", "dataString", "+", "\" to BigDecimal\"", ",", "ex", ")", ";", "}", "}" ]
Attempts to convert a value to a BigDecimal. Throws a SystemException on error. @param value the value to convert. @return the converted value, or null if <code>value</code> was null/empty.
[ "Attempts", "to", "convert", "a", "value", "to", "a", "BigDecimal", ".", "Throws", "a", "SystemException", "on", "error", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java#L131-L151
139,006
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java
WNumberField.setMinValue
public void setMinValue(final BigDecimal minValue) { BigDecimal currMin = getMinValue(); if (!Objects.equals(minValue, currMin)) { getOrCreateComponentModel().minValue = minValue; } }
java
public void setMinValue(final BigDecimal minValue) { BigDecimal currMin = getMinValue(); if (!Objects.equals(minValue, currMin)) { getOrCreateComponentModel().minValue = minValue; } }
[ "public", "void", "setMinValue", "(", "final", "BigDecimal", "minValue", ")", "{", "BigDecimal", "currMin", "=", "getMinValue", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "minValue", ",", "currMin", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "minValue", "=", "minValue", ";", "}", "}" ]
Sets the minimum allowable value for this number field. @param minValue the minimum allowable value, or null for no minimum.
[ "Sets", "the", "minimum", "allowable", "value", "for", "this", "number", "field", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java#L283-L288
139,007
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java
WNumberField.setMaxValue
public void setMaxValue(final BigDecimal maxValue) { BigDecimal currMax = getMaxValue(); if (!Objects.equals(maxValue, currMax)) { getOrCreateComponentModel().maxValue = maxValue; } }
java
public void setMaxValue(final BigDecimal maxValue) { BigDecimal currMax = getMaxValue(); if (!Objects.equals(maxValue, currMax)) { getOrCreateComponentModel().maxValue = maxValue; } }
[ "public", "void", "setMaxValue", "(", "final", "BigDecimal", "maxValue", ")", "{", "BigDecimal", "currMax", "=", "getMaxValue", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "maxValue", ",", "currMax", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "maxValue", "=", "maxValue", ";", "}", "}" ]
Sets the maximum allowable value for this number field. @param maxValue the maximum allowable value, or null for no maximum.
[ "Sets", "the", "maximum", "allowable", "value", "for", "this", "number", "field", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java#L323-L328
139,008
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java
WNumberField.validateComponent
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isValidNumber()) { super.validateComponent(diags); validateNumber(diags); } else { diags.add(createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_INVALID, this)); } }
java
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isValidNumber()) { super.validateComponent(diags); validateNumber(diags); } else { diags.add(createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_INVALID, this)); } }
[ "@", "Override", "protected", "void", "validateComponent", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "if", "(", "isValidNumber", "(", ")", ")", "{", "super", ".", "validateComponent", "(", "diags", ")", ";", "validateNumber", "(", "diags", ")", ";", "}", "else", "{", "diags", ".", "add", "(", "createErrorDiagnostic", "(", "InternalMessages", ".", "DEFAULT_VALIDATION_ERROR_INVALID", ",", "this", ")", ")", ";", "}", "}" ]
Override WInput's validateComponent to perform futher validation on email addresses. @param diags the list into which any validation diagnostics are added.
[ "Override", "WInput", "s", "validateComponent", "to", "perform", "futher", "validation", "on", "email", "addresses", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WNumberField.java#L416-L424
139,009
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/validation/ValidatingAction.java
ValidatingAction.containsError
private static boolean containsError(final List<Diagnostic> diags) { if (diags == null || diags.isEmpty()) { return false; } for (Diagnostic diag : diags) { if (diag.getSeverity() == Diagnostic.ERROR) { return true; } } return false; }
java
private static boolean containsError(final List<Diagnostic> diags) { if (diags == null || diags.isEmpty()) { return false; } for (Diagnostic diag : diags) { if (diag.getSeverity() == Diagnostic.ERROR) { return true; } } return false; }
[ "private", "static", "boolean", "containsError", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "if", "(", "diags", "==", "null", "||", "diags", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "for", "(", "Diagnostic", "diag", ":", "diags", ")", "{", "if", "(", "diag", ".", "getSeverity", "(", ")", "==", "Diagnostic", ".", "ERROR", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Indicates whether the given list of diagnostics contains any errors. @param diags the list into which any validation diagnostics were added. @return true if any of the diagnostics in the list are errors, false otherwise.
[ "Indicates", "whether", "the", "given", "list", "of", "diagnostics", "contains", "any", "errors", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/validation/ValidatingAction.java#L130-L142
139,010
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTextField.java
WTextField.doHandleRequest
@Override protected boolean doHandleRequest(final Request request) { String value = getRequestValue(request); String current = getValue(); boolean changed = !Util.equals(value, current); if (changed) { setData(value); } return changed; }
java
@Override protected boolean doHandleRequest(final Request request) { String value = getRequestValue(request); String current = getValue(); boolean changed = !Util.equals(value, current); if (changed) { setData(value); } return changed; }
[ "@", "Override", "protected", "boolean", "doHandleRequest", "(", "final", "Request", "request", ")", "{", "String", "value", "=", "getRequestValue", "(", "request", ")", ";", "String", "current", "=", "getValue", "(", ")", ";", "boolean", "changed", "=", "!", "Util", ".", "equals", "(", "value", ",", "current", ")", ";", "if", "(", "changed", ")", "{", "setData", "(", "value", ")", ";", "}", "return", "changed", ";", "}" ]
Override handleRequest in order to perform processing for this component. This implementation updates the text field's text if it has changed. @param request the request being responded to. @return true if the text field has changed, otherwise false
[ "Override", "handleRequest", "in", "order", "to", "perform", "processing", "for", "this", "component", ".", "This", "implementation", "updates", "the", "text", "field", "s", "text", "if", "it", "has", "changed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTextField.java#L43-L55
139,011
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxPageShellInterceptor.java
AjaxPageShellInterceptor.preparePaint
@Override public void preparePaint(final Request request) { UIContext uic = UIContextHolder.getCurrent(); Headers headers = uic.getUI().getHeaders(); headers.reset(); headers.setContentType(WebUtilities.CONTENT_TYPE_XML); super.preparePaint(request); }
java
@Override public void preparePaint(final Request request) { UIContext uic = UIContextHolder.getCurrent(); Headers headers = uic.getUI().getHeaders(); headers.reset(); headers.setContentType(WebUtilities.CONTENT_TYPE_XML); super.preparePaint(request); }
[ "@", "Override", "public", "void", "preparePaint", "(", "final", "Request", "request", ")", "{", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "Headers", "headers", "=", "uic", ".", "getUI", "(", ")", ".", "getHeaders", "(", ")", ";", "headers", ".", "reset", "(", ")", ";", "headers", ".", "setContentType", "(", "WebUtilities", ".", "CONTENT_TYPE_XML", ")", ";", "super", ".", "preparePaint", "(", "request", ")", ";", "}" ]
Override to set the content type of the response and reset the headers. @param request The request being serviced.
[ "Override", "to", "set", "the", "content", "type", "of", "the", "response", "and", "reset", "the", "headers", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxPageShellInterceptor.java#L30-L38
139,012
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxPageShellInterceptor.java
AjaxPageShellInterceptor.paint
@Override public void paint(final RenderContext renderContext) { WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext; XmlStringBuilder xml = webRenderContext.getWriter(); AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation == null) { // the request attribute that we place in the ui contenxt in the action phase can't be null throw new SystemException( "Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation."); } UIContext uic = UIContextHolder.getCurrent(); String focusId = uic.getFocussedId(); xml.append(XMLUtil.getXMLDeclarationWithThemeXslt(uic)); xml.appendTagOpen("ui:ajaxresponse"); xml.append(XMLUtil.STANDARD_NAMESPACES); xml.appendOptionalAttribute("defaultFocusId", uic.isFocusRequired() && !Util.empty(focusId), focusId); xml.appendClose(); getBackingComponent().paint(renderContext); xml.appendEndTag("ui:ajaxresponse"); }
java
@Override public void paint(final RenderContext renderContext) { WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext; XmlStringBuilder xml = webRenderContext.getWriter(); AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation == null) { // the request attribute that we place in the ui contenxt in the action phase can't be null throw new SystemException( "Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation."); } UIContext uic = UIContextHolder.getCurrent(); String focusId = uic.getFocussedId(); xml.append(XMLUtil.getXMLDeclarationWithThemeXslt(uic)); xml.appendTagOpen("ui:ajaxresponse"); xml.append(XMLUtil.STANDARD_NAMESPACES); xml.appendOptionalAttribute("defaultFocusId", uic.isFocusRequired() && !Util.empty(focusId), focusId); xml.appendClose(); getBackingComponent().paint(renderContext); xml.appendEndTag("ui:ajaxresponse"); }
[ "@", "Override", "public", "void", "paint", "(", "final", "RenderContext", "renderContext", ")", "{", "WebXmlRenderContext", "webRenderContext", "=", "(", "WebXmlRenderContext", ")", "renderContext", ";", "XmlStringBuilder", "xml", "=", "webRenderContext", ".", "getWriter", "(", ")", ";", "AjaxOperation", "operation", "=", "AjaxHelper", ".", "getCurrentOperation", "(", ")", ";", "if", "(", "operation", "==", "null", ")", "{", "// the request attribute that we place in the ui contenxt in the action phase can't be null", "throw", "new", "SystemException", "(", "\"Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation.\"", ")", ";", "}", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "String", "focusId", "=", "uic", ".", "getFocussedId", "(", ")", ";", "xml", ".", "append", "(", "XMLUtil", ".", "getXMLDeclarationWithThemeXslt", "(", "uic", ")", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxresponse\"", ")", ";", "xml", ".", "append", "(", "XMLUtil", ".", "STANDARD_NAMESPACES", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"defaultFocusId\"", ",", "uic", ".", "isFocusRequired", "(", ")", "&&", "!", "Util", ".", "empty", "(", "focusId", ")", ",", "focusId", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "getBackingComponent", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:ajaxresponse\"", ")", ";", "}" ]
Paints the targeted ajax regions. The format of the response is an agreement between the server and the client side handling our AJAX response. @param renderContext the renderContext to send the output to.
[ "Paints", "the", "targeted", "ajax", "regions", ".", "The", "format", "of", "the", "response", "is", "an", "agreement", "between", "the", "server", "and", "the", "client", "side", "handling", "our", "AJAX", "response", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxPageShellInterceptor.java#L46-L71
139,013
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractMutableContainer.java
AbstractMutableContainer.add
@Deprecated @Override public void add(final WComponent component, final String tag) { super.add(component, tag); }
java
@Deprecated @Override public void add(final WComponent component, final String tag) { super.add(component, tag); }
[ "@", "Deprecated", "@", "Override", "public", "void", "add", "(", "final", "WComponent", "component", ",", "final", "String", "tag", ")", "{", "super", ".", "add", "(", "component", ",", "tag", ")", ";", "}" ]
Add the given component as a child of this component. The tag is used to identify the child in this component's velocity template. @param component the component to add. @param tag the tag used to identify the component. @deprecated Use {@link WTemplate} instead
[ "Add", "the", "given", "component", "as", "a", "child", "of", "this", "component", ".", "The", "tag", "is", "used", "to", "identify", "the", "child", "in", "this", "component", "s", "velocity", "template", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractMutableContainer.java#L32-L36
139,014
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WAudioRenderer.java
WAudioRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WAudio audioComponent = (WAudio) component; XmlStringBuilder xml = renderContext.getWriter(); Audio[] audio = audioComponent.getAudio(); if (audio == null || audio.length == 0) { return; } WAudio.Controls controls = audioComponent.getControls(); int duration = audio[0].getDuration(); // Check for alternative text String alternativeText = audioComponent.getAltText(); if (alternativeText == null) { LOG.warn("Audio should have a description."); alternativeText = null; } else { alternativeText = I18nUtilities.format(null, alternativeText); } xml.appendTagOpen("ui:audio"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("alt", alternativeText); xml.appendOptionalAttribute("autoplay", audioComponent.isAutoplay(), "true"); xml.appendOptionalAttribute("mediagroup", audioComponent.getMediaGroup()); xml.appendOptionalAttribute("loop", audioComponent.isLoop(), "true"); xml.appendOptionalAttribute("hidden", audioComponent.isHidden(), "true"); xml.appendOptionalAttribute("disabled", audioComponent.isDisabled(), "true"); xml.appendOptionalAttribute("toolTip", audioComponent.getToolTip()); xml.appendOptionalAttribute("duration", duration > 0, duration); switch (audioComponent.getPreload()) { case NONE: xml.appendAttribute("preload", "none"); break; case META_DATA: xml.appendAttribute("preload", "metadata"); break; case AUTO: default: break; } if (controls != null && !WAudio.Controls.NATIVE.equals(controls)) { switch (controls) { case NONE: xml.appendAttribute("controls", "none"); break; case ALL: xml.appendAttribute("controls", "all"); break; case PLAY_PAUSE: xml.appendAttribute("controls", "play"); break; case DEFAULT: xml.appendAttribute("controls", "default"); break; default: LOG.error("Unknown control type: " + controls); } } xml.appendClose(); String[] urls = audioComponent.getAudioUrls(); for (int i = 0; i < urls.length; i++) { xml.appendTagOpen("ui:src"); xml.appendUrlAttribute("uri", urls[i]); xml.appendOptionalAttribute("type", audio[i].getMimeType()); xml.appendEnd(); } xml.appendEndTag("ui:audio"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WAudio audioComponent = (WAudio) component; XmlStringBuilder xml = renderContext.getWriter(); Audio[] audio = audioComponent.getAudio(); if (audio == null || audio.length == 0) { return; } WAudio.Controls controls = audioComponent.getControls(); int duration = audio[0].getDuration(); // Check for alternative text String alternativeText = audioComponent.getAltText(); if (alternativeText == null) { LOG.warn("Audio should have a description."); alternativeText = null; } else { alternativeText = I18nUtilities.format(null, alternativeText); } xml.appendTagOpen("ui:audio"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("alt", alternativeText); xml.appendOptionalAttribute("autoplay", audioComponent.isAutoplay(), "true"); xml.appendOptionalAttribute("mediagroup", audioComponent.getMediaGroup()); xml.appendOptionalAttribute("loop", audioComponent.isLoop(), "true"); xml.appendOptionalAttribute("hidden", audioComponent.isHidden(), "true"); xml.appendOptionalAttribute("disabled", audioComponent.isDisabled(), "true"); xml.appendOptionalAttribute("toolTip", audioComponent.getToolTip()); xml.appendOptionalAttribute("duration", duration > 0, duration); switch (audioComponent.getPreload()) { case NONE: xml.appendAttribute("preload", "none"); break; case META_DATA: xml.appendAttribute("preload", "metadata"); break; case AUTO: default: break; } if (controls != null && !WAudio.Controls.NATIVE.equals(controls)) { switch (controls) { case NONE: xml.appendAttribute("controls", "none"); break; case ALL: xml.appendAttribute("controls", "all"); break; case PLAY_PAUSE: xml.appendAttribute("controls", "play"); break; case DEFAULT: xml.appendAttribute("controls", "default"); break; default: LOG.error("Unknown control type: " + controls); } } xml.appendClose(); String[] urls = audioComponent.getAudioUrls(); for (int i = 0; i < urls.length; i++) { xml.appendTagOpen("ui:src"); xml.appendUrlAttribute("uri", urls[i]); xml.appendOptionalAttribute("type", audio[i].getMimeType()); xml.appendEnd(); } xml.appendEndTag("ui:audio"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WAudio", "audioComponent", "=", "(", "WAudio", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "Audio", "[", "]", "audio", "=", "audioComponent", ".", "getAudio", "(", ")", ";", "if", "(", "audio", "==", "null", "||", "audio", ".", "length", "==", "0", ")", "{", "return", ";", "}", "WAudio", ".", "Controls", "controls", "=", "audioComponent", ".", "getControls", "(", ")", ";", "int", "duration", "=", "audio", "[", "0", "]", ".", "getDuration", "(", ")", ";", "// Check for alternative text", "String", "alternativeText", "=", "audioComponent", ".", "getAltText", "(", ")", ";", "if", "(", "alternativeText", "==", "null", ")", "{", "LOG", ".", "warn", "(", "\"Audio should have a description.\"", ")", ";", "alternativeText", "=", "null", ";", "}", "else", "{", "alternativeText", "=", "I18nUtilities", ".", "format", "(", "null", ",", "alternativeText", ")", ";", "}", "xml", ".", "appendTagOpen", "(", "\"ui:audio\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"alt\"", ",", "alternativeText", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"autoplay\"", ",", "audioComponent", ".", "isAutoplay", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"mediagroup\"", ",", "audioComponent", ".", "getMediaGroup", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"loop\"", ",", "audioComponent", ".", "isLoop", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "audioComponent", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "audioComponent", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "audioComponent", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"duration\"", ",", "duration", ">", "0", ",", "duration", ")", ";", "switch", "(", "audioComponent", ".", "getPreload", "(", ")", ")", "{", "case", "NONE", ":", "xml", ".", "appendAttribute", "(", "\"preload\"", ",", "\"none\"", ")", ";", "break", ";", "case", "META_DATA", ":", "xml", ".", "appendAttribute", "(", "\"preload\"", ",", "\"metadata\"", ")", ";", "break", ";", "case", "AUTO", ":", "default", ":", "break", ";", "}", "if", "(", "controls", "!=", "null", "&&", "!", "WAudio", ".", "Controls", ".", "NATIVE", ".", "equals", "(", "controls", ")", ")", "{", "switch", "(", "controls", ")", "{", "case", "NONE", ":", "xml", ".", "appendAttribute", "(", "\"controls\"", ",", "\"none\"", ")", ";", "break", ";", "case", "ALL", ":", "xml", ".", "appendAttribute", "(", "\"controls\"", ",", "\"all\"", ")", ";", "break", ";", "case", "PLAY_PAUSE", ":", "xml", ".", "appendAttribute", "(", "\"controls\"", ",", "\"play\"", ")", ";", "break", ";", "case", "DEFAULT", ":", "xml", ".", "appendAttribute", "(", "\"controls\"", ",", "\"default\"", ")", ";", "break", ";", "default", ":", "LOG", ".", "error", "(", "\"Unknown control type: \"", "+", "controls", ")", ";", "}", "}", "xml", ".", "appendClose", "(", ")", ";", "String", "[", "]", "urls", "=", "audioComponent", ".", "getAudioUrls", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "urls", ".", "length", ";", "i", "++", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:src\"", ")", ";", "xml", ".", "appendUrlAttribute", "(", "\"uri\"", ",", "urls", "[", "i", "]", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "audio", "[", "i", "]", ".", "getMimeType", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:audio\"", ")", ";", "}" ]
Paints the given WAudio. @param component the WAudio to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WAudio", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WAudioRenderer.java#L32-L117
139,015
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ColumnLayoutExample.java
ColumnLayoutExample.addResponsiveExample
private void addResponsiveExample() { add(new WHeading(HeadingLevel.H2, "Default responsive design")); add(new ExplanatoryText("This example applies the theme's default responsive design rules for ColumnLayout.\n " + "The columns have width and alignment and there is also a hgap and a vgap.")); WPanel panel = new WPanel(); panel.setLayout(new ColumnLayout(new int[]{33, 33, 33}, new Alignment[]{Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT}, 12, 18)); panel.setHtmlClass(HtmlClassProperties.RESPOND); add(panel); panel.add(new BoxComponent("Left")); panel.add(new BoxComponent("Center")); panel.add(new BoxComponent("Right")); panel.add(new BoxComponent("Left")); panel.add(new BoxComponent("Center")); panel.add(new BoxComponent("Right")); }
java
private void addResponsiveExample() { add(new WHeading(HeadingLevel.H2, "Default responsive design")); add(new ExplanatoryText("This example applies the theme's default responsive design rules for ColumnLayout.\n " + "The columns have width and alignment and there is also a hgap and a vgap.")); WPanel panel = new WPanel(); panel.setLayout(new ColumnLayout(new int[]{33, 33, 33}, new Alignment[]{Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT}, 12, 18)); panel.setHtmlClass(HtmlClassProperties.RESPOND); add(panel); panel.add(new BoxComponent("Left")); panel.add(new BoxComponent("Center")); panel.add(new BoxComponent("Right")); panel.add(new BoxComponent("Left")); panel.add(new BoxComponent("Center")); panel.add(new BoxComponent("Right")); }
[ "private", "void", "addResponsiveExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"Default responsive design\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"This example applies the theme's default responsive design rules for ColumnLayout.\\n \"", "+", "\"The columns have width and alignment and there is also a hgap and a vgap.\"", ")", ")", ";", "WPanel", "panel", "=", "new", "WPanel", "(", ")", ";", "panel", ".", "setLayout", "(", "new", "ColumnLayout", "(", "new", "int", "[", "]", "{", "33", ",", "33", ",", "33", "}", ",", "new", "Alignment", "[", "]", "{", "Alignment", ".", "LEFT", ",", "Alignment", ".", "CENTER", ",", "Alignment", ".", "RIGHT", "}", ",", "12", ",", "18", ")", ")", ";", "panel", ".", "setHtmlClass", "(", "HtmlClassProperties", ".", "RESPOND", ")", ";", "add", "(", "panel", ")", ";", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"Left\"", ")", ")", ";", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"Center\"", ")", ")", ";", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"Right\"", ")", ")", ";", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"Left\"", ")", ")", ";", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"Center\"", ")", ")", ";", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"Right\"", ")", ")", ";", "}" ]
Add a column layout which will change its rendering on small screens.
[ "Add", "a", "column", "layout", "which", "will", "change", "its", "rendering", "on", "small", "screens", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ColumnLayoutExample.java#L72-L87
139,016
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ColumnLayoutExample.java
ColumnLayoutExample.getTitle
private static String getTitle(final int[] widths) { StringBuffer buf = new StringBuffer("Column widths: "); for (int i = 0; i < widths.length; i++) { if (i > 0) { buf.append(", "); } buf.append(widths[i]); } return buf.toString(); }
java
private static String getTitle(final int[] widths) { StringBuffer buf = new StringBuffer("Column widths: "); for (int i = 0; i < widths.length; i++) { if (i > 0) { buf.append(", "); } buf.append(widths[i]); } return buf.toString(); }
[ "private", "static", "String", "getTitle", "(", "final", "int", "[", "]", "widths", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "\"Column widths: \"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "widths", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "\", \"", ")", ";", "}", "buf", ".", "append", "(", "widths", "[", "i", "]", ")", ";", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Concatenates column widths to form the heading text for the example. @param widths the widths to concatenate. @return the title text.
[ "Concatenates", "column", "widths", "to", "form", "the", "heading", "text", "for", "the", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ColumnLayoutExample.java#L95-L107
139,017
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ColumnLayoutExample.java
ColumnLayoutExample.addHgapVGapExample
private void addHgapVGapExample(final Size hgap, final Size vgap) { add(new WHeading(HeadingLevel.H2, "Column Layout: hgap=" + hgap.toString() + " vgap=" + vgap.toString())); WPanel panel = new WPanel(); panel.setLayout(new ColumnLayout(new int[]{25, 25, 25, 25}, hgap, vgap)); add(panel); for (int i = 0; i < 8; i++) { panel.add(new BoxComponent("25%")); } add(new WHorizontalRule()); }
java
private void addHgapVGapExample(final Size hgap, final Size vgap) { add(new WHeading(HeadingLevel.H2, "Column Layout: hgap=" + hgap.toString() + " vgap=" + vgap.toString())); WPanel panel = new WPanel(); panel.setLayout(new ColumnLayout(new int[]{25, 25, 25, 25}, hgap, vgap)); add(panel); for (int i = 0; i < 8; i++) { panel.add(new BoxComponent("25%")); } add(new WHorizontalRule()); }
[ "private", "void", "addHgapVGapExample", "(", "final", "Size", "hgap", ",", "final", "Size", "vgap", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"Column Layout: hgap=\"", "+", "hgap", ".", "toString", "(", ")", "+", "\" vgap=\"", "+", "vgap", ".", "toString", "(", ")", ")", ")", ";", "WPanel", "panel", "=", "new", "WPanel", "(", ")", ";", "panel", ".", "setLayout", "(", "new", "ColumnLayout", "(", "new", "int", "[", "]", "{", "25", ",", "25", ",", "25", ",", "25", "}", ",", "hgap", ",", "vgap", ")", ")", ";", "add", "(", "panel", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "8", ";", "i", "++", ")", "{", "panel", ".", "add", "(", "new", "BoxComponent", "(", "\"25%\"", ")", ")", ";", "}", "add", "(", "new", "WHorizontalRule", "(", ")", ")", ";", "}" ]
Build an example using hgap and vgap. @param hgap the hgap width @param vgap the vgap width
[ "Build", "an", "example", "using", "hgap", "and", "vgap", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/ColumnLayoutExample.java#L115-L126
139,018
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTableRowRendererRenderer.java
WTableRowRendererRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTableRowRenderer renderer = (WTableRowRenderer) component; XmlStringBuilder xml = renderContext.getWriter(); WTable table = renderer.getTable(); TableModel dataModel = table.getTableModel(); int[] columnOrder = table.getColumnOrder(); final int numCols = columnOrder == null ? table.getColumnCount() : columnOrder.length; // Get current row details RowIdWrapper wrapper = renderer.getCurrentRowIdWrapper(); List<Integer> rowIndex = wrapper.getRowIndex(); boolean tableSelectable = table.getSelectMode() != SelectMode.NONE; boolean rowSelectable = tableSelectable && dataModel.isSelectable(rowIndex); boolean rowSelected = rowSelectable && table.getSelectedRows().contains(wrapper.getRowKey()); boolean tableExpandable = table.getExpandMode() != WTable.ExpandMode.NONE; boolean rowExpandable = tableExpandable && dataModel.isExpandable(rowIndex) && wrapper. hasChildren(); boolean rowExpanded = rowExpandable && table.getExpandedRows().contains(wrapper.getRowKey()); String rowIndexAsString = TableUtil.rowIndexListToString(rowIndex); xml.appendTagOpen("ui:tr"); xml.appendAttribute("rowIndex", rowIndexAsString); xml.appendOptionalAttribute("unselectable", !rowSelectable, "true"); xml.appendOptionalAttribute("selected", rowSelected, "true"); xml.appendOptionalAttribute("expandable", rowExpandable && !rowExpanded, "true"); xml.appendClose(); // wrote the column cell. boolean isRowHeader = table.isRowHeaders(); // need this before we get into the loop for (int i = 0; i < numCols; i++) { int colIndex = columnOrder == null ? i : columnOrder[i]; WTableColumn col = table.getColumn(colIndex); String cellTag = "ui:td"; if (col.isVisible()) { if (isRowHeader) { // The first rendered column will be the row header. cellTag = "ui:th"; isRowHeader = false; // only set one col as the row header. } xml.appendTag(cellTag); renderer.getRenderer(colIndex).paint(renderContext); xml.appendEndTag(cellTag); } } if (rowExpandable) { xml.appendTagOpen("ui:subtr"); xml.appendOptionalAttribute("open", rowExpanded, "true"); xml.appendClose(); if (rowExpanded || table.getExpandMode() == ExpandMode.CLIENT) { renderChildren(renderer, renderContext, wrapper.getChildren()); } xml.appendEndTag("ui:subtr"); } xml.appendEndTag("ui:tr"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTableRowRenderer renderer = (WTableRowRenderer) component; XmlStringBuilder xml = renderContext.getWriter(); WTable table = renderer.getTable(); TableModel dataModel = table.getTableModel(); int[] columnOrder = table.getColumnOrder(); final int numCols = columnOrder == null ? table.getColumnCount() : columnOrder.length; // Get current row details RowIdWrapper wrapper = renderer.getCurrentRowIdWrapper(); List<Integer> rowIndex = wrapper.getRowIndex(); boolean tableSelectable = table.getSelectMode() != SelectMode.NONE; boolean rowSelectable = tableSelectable && dataModel.isSelectable(rowIndex); boolean rowSelected = rowSelectable && table.getSelectedRows().contains(wrapper.getRowKey()); boolean tableExpandable = table.getExpandMode() != WTable.ExpandMode.NONE; boolean rowExpandable = tableExpandable && dataModel.isExpandable(rowIndex) && wrapper. hasChildren(); boolean rowExpanded = rowExpandable && table.getExpandedRows().contains(wrapper.getRowKey()); String rowIndexAsString = TableUtil.rowIndexListToString(rowIndex); xml.appendTagOpen("ui:tr"); xml.appendAttribute("rowIndex", rowIndexAsString); xml.appendOptionalAttribute("unselectable", !rowSelectable, "true"); xml.appendOptionalAttribute("selected", rowSelected, "true"); xml.appendOptionalAttribute("expandable", rowExpandable && !rowExpanded, "true"); xml.appendClose(); // wrote the column cell. boolean isRowHeader = table.isRowHeaders(); // need this before we get into the loop for (int i = 0; i < numCols; i++) { int colIndex = columnOrder == null ? i : columnOrder[i]; WTableColumn col = table.getColumn(colIndex); String cellTag = "ui:td"; if (col.isVisible()) { if (isRowHeader) { // The first rendered column will be the row header. cellTag = "ui:th"; isRowHeader = false; // only set one col as the row header. } xml.appendTag(cellTag); renderer.getRenderer(colIndex).paint(renderContext); xml.appendEndTag(cellTag); } } if (rowExpandable) { xml.appendTagOpen("ui:subtr"); xml.appendOptionalAttribute("open", rowExpanded, "true"); xml.appendClose(); if (rowExpanded || table.getExpandMode() == ExpandMode.CLIENT) { renderChildren(renderer, renderContext, wrapper.getChildren()); } xml.appendEndTag("ui:subtr"); } xml.appendEndTag("ui:tr"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTableRowRenderer", "renderer", "=", "(", "WTableRowRenderer", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "WTable", "table", "=", "renderer", ".", "getTable", "(", ")", ";", "TableModel", "dataModel", "=", "table", ".", "getTableModel", "(", ")", ";", "int", "[", "]", "columnOrder", "=", "table", ".", "getColumnOrder", "(", ")", ";", "final", "int", "numCols", "=", "columnOrder", "==", "null", "?", "table", ".", "getColumnCount", "(", ")", ":", "columnOrder", ".", "length", ";", "// Get current row details", "RowIdWrapper", "wrapper", "=", "renderer", ".", "getCurrentRowIdWrapper", "(", ")", ";", "List", "<", "Integer", ">", "rowIndex", "=", "wrapper", ".", "getRowIndex", "(", ")", ";", "boolean", "tableSelectable", "=", "table", ".", "getSelectMode", "(", ")", "!=", "SelectMode", ".", "NONE", ";", "boolean", "rowSelectable", "=", "tableSelectable", "&&", "dataModel", ".", "isSelectable", "(", "rowIndex", ")", ";", "boolean", "rowSelected", "=", "rowSelectable", "&&", "table", ".", "getSelectedRows", "(", ")", ".", "contains", "(", "wrapper", ".", "getRowKey", "(", ")", ")", ";", "boolean", "tableExpandable", "=", "table", ".", "getExpandMode", "(", ")", "!=", "WTable", ".", "ExpandMode", ".", "NONE", ";", "boolean", "rowExpandable", "=", "tableExpandable", "&&", "dataModel", ".", "isExpandable", "(", "rowIndex", ")", "&&", "wrapper", ".", "hasChildren", "(", ")", ";", "boolean", "rowExpanded", "=", "rowExpandable", "&&", "table", ".", "getExpandedRows", "(", ")", ".", "contains", "(", "wrapper", ".", "getRowKey", "(", ")", ")", ";", "String", "rowIndexAsString", "=", "TableUtil", ".", "rowIndexListToString", "(", "rowIndex", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:tr\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"rowIndex\"", ",", "rowIndexAsString", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"unselectable\"", ",", "!", "rowSelectable", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"selected\"", ",", "rowSelected", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"expandable\"", ",", "rowExpandable", "&&", "!", "rowExpanded", ",", "\"true\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// wrote the column cell.", "boolean", "isRowHeader", "=", "table", ".", "isRowHeaders", "(", ")", ";", "// need this before we get into the loop", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numCols", ";", "i", "++", ")", "{", "int", "colIndex", "=", "columnOrder", "==", "null", "?", "i", ":", "columnOrder", "[", "i", "]", ";", "WTableColumn", "col", "=", "table", ".", "getColumn", "(", "colIndex", ")", ";", "String", "cellTag", "=", "\"ui:td\"", ";", "if", "(", "col", ".", "isVisible", "(", ")", ")", "{", "if", "(", "isRowHeader", ")", "{", "// The first rendered column will be the row header.", "cellTag", "=", "\"ui:th\"", ";", "isRowHeader", "=", "false", ";", "// only set one col as the row header.", "}", "xml", ".", "appendTag", "(", "cellTag", ")", ";", "renderer", ".", "getRenderer", "(", "colIndex", ")", ".", "paint", "(", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "cellTag", ")", ";", "}", "}", "if", "(", "rowExpandable", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:subtr\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"open\"", ",", "rowExpanded", ",", "\"true\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "if", "(", "rowExpanded", "||", "table", ".", "getExpandMode", "(", ")", "==", "ExpandMode", ".", "CLIENT", ")", "{", "renderChildren", "(", "renderer", ",", "renderContext", ",", "wrapper", ".", "getChildren", "(", ")", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:subtr\"", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:tr\"", ")", ";", "}" ]
Paints the given WTableRowRenderer. @param component the WTableRowRenderer to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTableRowRenderer", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTableRowRendererRenderer.java#L34-L97
139,019
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/HtmlSanitizerUtil.java
HtmlSanitizerUtil.createPolicy
public static Policy createPolicy(final String resourceName) { if (StringUtils.isBlank(resourceName)) { throw new SystemException("AntiSamy Policy resourceName cannot be null "); } URL resource = HtmlSanitizerUtil.class.getClassLoader().getResource(resourceName); if (resource == null) { throw new SystemException("Could not find AntiSamy Policy XML resource."); } try { return Policy.getInstance(resource); } catch (PolicyException ex) { throw new SystemException("Could not create AntiSamy Policy" + ex.getMessage(), ex); } }
java
public static Policy createPolicy(final String resourceName) { if (StringUtils.isBlank(resourceName)) { throw new SystemException("AntiSamy Policy resourceName cannot be null "); } URL resource = HtmlSanitizerUtil.class.getClassLoader().getResource(resourceName); if (resource == null) { throw new SystemException("Could not find AntiSamy Policy XML resource."); } try { return Policy.getInstance(resource); } catch (PolicyException ex) { throw new SystemException("Could not create AntiSamy Policy" + ex.getMessage(), ex); } }
[ "public", "static", "Policy", "createPolicy", "(", "final", "String", "resourceName", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "resourceName", ")", ")", "{", "throw", "new", "SystemException", "(", "\"AntiSamy Policy resourceName cannot be null \"", ")", ";", "}", "URL", "resource", "=", "HtmlSanitizerUtil", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResource", "(", "resourceName", ")", ";", "if", "(", "resource", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"Could not find AntiSamy Policy XML resource.\"", ")", ";", "}", "try", "{", "return", "Policy", ".", "getInstance", "(", "resource", ")", ";", "}", "catch", "(", "PolicyException", "ex", ")", "{", "throw", "new", "SystemException", "(", "\"Could not create AntiSamy Policy\"", "+", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}" ]
Create a Policy from a named local resource. @param resourceName the path to AntiSamy policy file @return the AntiSamy Policy
[ "Create", "a", "Policy", "from", "a", "named", "local", "resource", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/HtmlSanitizerUtil.java#L150-L163
139,020
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataRenderer.java
WDataRenderer.handleRequest
@Override public void handleRequest(final Request request) { // Let the wcomponent gather data from the request. super.handleRequest(request); Object data = getData(); if (data != null) { // Now update the data object (bound to this wcomponent) by copying // values from this wcomponent and its children into the data object. updateData(data); } }
java
@Override public void handleRequest(final Request request) { // Let the wcomponent gather data from the request. super.handleRequest(request); Object data = getData(); if (data != null) { // Now update the data object (bound to this wcomponent) by copying // values from this wcomponent and its children into the data object. updateData(data); } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "// Let the wcomponent gather data from the request.", "super", ".", "handleRequest", "(", "request", ")", ";", "Object", "data", "=", "getData", "(", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "// Now update the data object (bound to this wcomponent) by copying", "// values from this wcomponent and its children into the data object.", "updateData", "(", "data", ")", ";", "}", "}" ]
The handleRequest method has been overridden to keep the data object bound to this wcomponent in sync with any changes the user has entered. @param request the Request being responded to.
[ "The", "handleRequest", "method", "has", "been", "overridden", "to", "keep", "the", "data", "object", "bound", "to", "this", "wcomponent", "in", "sync", "with", "any", "changes", "the", "user", "has", "entered", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataRenderer.java#L73-L85
139,021
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ThemeServlet.java
ThemeServlet.doGet
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { ServletUtil.handleThemeResourceRequest(req, resp); }
java
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { ServletUtil.handleThemeResourceRequest(req, resp); }
[ "@", "Override", "protected", "void", "doGet", "(", "final", "HttpServletRequest", "req", ",", "final", "HttpServletResponse", "resp", ")", "throws", "ServletException", ",", "IOException", "{", "ServletUtil", ".", "handleThemeResourceRequest", "(", "req", ",", "resp", ")", ";", "}" ]
Serves up a file from the theme. @param req the request with the file name in parameter "f", or following the servlet path. @param resp the response to write to. @throws ServletException on error. @throws IOException if there is an error reading the file / writing the response.
[ "Serves", "up", "a", "file", "from", "the", "theme", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ThemeServlet.java#L46-L51
139,022
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WCollapsibleToggleRenderer.java
WCollapsibleToggleRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WCollapsibleToggle toggle = (WCollapsibleToggle) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:collapsibletoggle"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("groupName", toggle.getGroupName()); xml.appendEnd(); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WCollapsibleToggle toggle = (WCollapsibleToggle) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:collapsibletoggle"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("groupName", toggle.getGroupName()); xml.appendEnd(); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WCollapsibleToggle", "toggle", "=", "(", "WCollapsibleToggle", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:collapsibletoggle\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"groupName\"", ",", "toggle", ".", "getGroupName", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}" ]
Paints the given WCollapsibleToggle. @param component the WCollapsibleToggle to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WCollapsibleToggle", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WCollapsibleToggleRenderer.java#L22-L33
139,023
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java
Util.empty
public static boolean empty(final String aString) { if (aString != null) { final int len = aString.length(); for (int i = 0; i < len; i++) { // This mirrors String.trim(), which removes ASCII // control characters as well as whitespace. if (aString.charAt(i) > ' ') { return false; } } } return true; }
java
public static boolean empty(final String aString) { if (aString != null) { final int len = aString.length(); for (int i = 0; i < len; i++) { // This mirrors String.trim(), which removes ASCII // control characters as well as whitespace. if (aString.charAt(i) > ' ') { return false; } } } return true; }
[ "public", "static", "boolean", "empty", "(", "final", "String", "aString", ")", "{", "if", "(", "aString", "!=", "null", ")", "{", "final", "int", "len", "=", "aString", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "// This mirrors String.trim(), which removes ASCII", "// control characters as well as whitespace.", "if", "(", "aString", ".", "charAt", "(", "i", ")", ">", "'", "'", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Determines whether the given string is null or "empty". @param aString the string to check. @return true if the given String is null or contains only whitespace.
[ "Determines", "whether", "the", "given", "string", "is", "null", "or", "empty", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java#L23-L37
139,024
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java
Util.compareAllowNull
public static int compareAllowNull(final Comparable c1, final Comparable c2) { if (c1 == null && c2 == null) { return 0; } else if (c1 == null) { return -1; } else if (c2 == null) { return 1; } else { return c1.compareTo(c2); } }
java
public static int compareAllowNull(final Comparable c1, final Comparable c2) { if (c1 == null && c2 == null) { return 0; } else if (c1 == null) { return -1; } else if (c2 == null) { return 1; } else { return c1.compareTo(c2); } }
[ "public", "static", "int", "compareAllowNull", "(", "final", "Comparable", "c1", ",", "final", "Comparable", "c2", ")", "{", "if", "(", "c1", "==", "null", "&&", "c2", "==", "null", ")", "{", "return", "0", ";", "}", "else", "if", "(", "c1", "==", "null", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "c2", "==", "null", ")", "{", "return", "1", ";", "}", "else", "{", "return", "c1", ".", "compareTo", "(", "c2", ")", ";", "}", "}" ]
Compares two comparable objects where either may be null. Null is regarded as the smallest value, and 2 nulls are considered equal. @param c1 the first comparable @param c2 the second comparable @return a negative integer, zero, or a positive integer if c1 is less than, equal to, or greater than the c2.
[ "Compares", "two", "comparable", "objects", "where", "either", "may", "be", "null", ".", "Null", "is", "regarded", "as", "the", "smallest", "value", "and", "2", "nulls", "are", "considered", "equal", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java#L66-L76
139,025
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java
Util.rightTrim
public static String rightTrim(final String aString) { if (aString == null) { return null; } int end = aString.length() - 1; while ((end >= 0) && (aString.charAt(end) <= ' ')) { end--; } if (end == aString.length() - 1) { return aString; } return aString.substring(0, end + 1); }
java
public static String rightTrim(final String aString) { if (aString == null) { return null; } int end = aString.length() - 1; while ((end >= 0) && (aString.charAt(end) <= ' ')) { end--; } if (end == aString.length() - 1) { return aString; } return aString.substring(0, end + 1); }
[ "public", "static", "String", "rightTrim", "(", "final", "String", "aString", ")", "{", "if", "(", "aString", "==", "null", ")", "{", "return", "null", ";", "}", "int", "end", "=", "aString", ".", "length", "(", ")", "-", "1", ";", "while", "(", "(", "end", ">=", "0", ")", "&&", "(", "aString", ".", "charAt", "(", "end", ")", "<=", "'", "'", ")", ")", "{", "end", "--", ";", "}", "if", "(", "end", "==", "aString", ".", "length", "(", ")", "-", "1", ")", "{", "return", "aString", ";", "}", "return", "aString", ".", "substring", "(", "0", ",", "end", "+", "1", ")", ";", "}" ]
Copies this String removing white space characters from the end of the string. @param aString the String to trim. @return a new String with characters <code>\\u0020</code> removed from the end
[ "Copies", "this", "String", "removing", "white", "space", "characters", "from", "the", "end", "of", "the", "string", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java#L98-L110
139,026
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java
Util.leftTrim
public static String leftTrim(final String aString) { if (aString == null) { return null; } int start = 0; while ((start < aString.length()) && (aString.charAt(start) <= ' ')) { start++; } if (start == 0) { return aString; } return aString.substring(start); }
java
public static String leftTrim(final String aString) { if (aString == null) { return null; } int start = 0; while ((start < aString.length()) && (aString.charAt(start) <= ' ')) { start++; } if (start == 0) { return aString; } return aString.substring(start); }
[ "public", "static", "String", "leftTrim", "(", "final", "String", "aString", ")", "{", "if", "(", "aString", "==", "null", ")", "{", "return", "null", ";", "}", "int", "start", "=", "0", ";", "while", "(", "(", "start", "<", "aString", ".", "length", "(", ")", ")", "&&", "(", "aString", ".", "charAt", "(", "start", ")", "<=", "'", "'", ")", ")", "{", "start", "++", ";", "}", "if", "(", "start", "==", "0", ")", "{", "return", "aString", ";", "}", "return", "aString", ".", "substring", "(", "start", ")", ";", "}" ]
Copies this String removing white space characters from the beginning of the string. @param aString the String to trim. @return a new String with characters <code>\\u0020</code> removed from the beginning
[ "Copies", "this", "String", "removing", "white", "space", "characters", "from", "the", "beginning", "of", "the", "string", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Util.java#L118-L130
139,027
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextHolder.java
UIContextHolder.getCurrent
public static UIContext getCurrent() { Stack<UIContext> stack = CONTEXT_STACK.get(); if (stack == null || stack.isEmpty()) { return null; } return getStack().peek(); }
java
public static UIContext getCurrent() { Stack<UIContext> stack = CONTEXT_STACK.get(); if (stack == null || stack.isEmpty()) { return null; } return getStack().peek(); }
[ "public", "static", "UIContext", "getCurrent", "(", ")", "{", "Stack", "<", "UIContext", ">", "stack", "=", "CONTEXT_STACK", ".", "get", "(", ")", ";", "if", "(", "stack", "==", "null", "||", "stack", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "return", "getStack", "(", ")", ".", "peek", "(", ")", ";", "}" ]
Retrieves the current effective UIContext. Note that this method will return null if called from outside normal request processing, for example during the intial application UI construction. @return the current effective UIContext.
[ "Retrieves", "the", "current", "effective", "UIContext", ".", "Note", "that", "this", "method", "will", "return", "null", "if", "called", "from", "outside", "normal", "request", "processing", "for", "example", "during", "the", "intial", "application", "UI", "construction", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextHolder.java#L102-L110
139,028
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextHolder.java
UIContextHolder.getStack
private static Stack<UIContext> getStack() { Stack<UIContext> stack = CONTEXT_STACK.get(); if (stack == null) { stack = new Stack<>(); CONTEXT_STACK.set(stack); } return stack; }
java
private static Stack<UIContext> getStack() { Stack<UIContext> stack = CONTEXT_STACK.get(); if (stack == null) { stack = new Stack<>(); CONTEXT_STACK.set(stack); } return stack; }
[ "private", "static", "Stack", "<", "UIContext", ">", "getStack", "(", ")", "{", "Stack", "<", "UIContext", ">", "stack", "=", "CONTEXT_STACK", ".", "get", "(", ")", ";", "if", "(", "stack", "==", "null", ")", "{", "stack", "=", "new", "Stack", "<>", "(", ")", ";", "CONTEXT_STACK", ".", "set", "(", "stack", ")", ";", "}", "return", "stack", ";", "}" ]
Retrieves the internal stack, creating it if necessary. @return the internal stack
[ "Retrieves", "the", "internal", "stack", "creating", "it", "if", "necessary", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextHolder.java#L117-L126
139,029
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java
ReflectionUtil.getAllFields
public static List getAllFields(final Object obj, final boolean excludeStatic, final boolean excludeTransient) { List fieldList = new ArrayList(); for (Class clazz = obj.getClass(); clazz != null; clazz = clazz.getSuperclass()) { Field[] declaredFields = clazz.getDeclaredFields(); for (int i = 0; i < declaredFields.length; i++) { int mods = declaredFields[i].getModifiers(); if ((!excludeStatic || !Modifier.isStatic(mods)) && (!excludeTransient || !Modifier.isTransient(mods))) { declaredFields[i].setAccessible(true); fieldList.add(declaredFields[i]); } } } return fieldList; }
java
public static List getAllFields(final Object obj, final boolean excludeStatic, final boolean excludeTransient) { List fieldList = new ArrayList(); for (Class clazz = obj.getClass(); clazz != null; clazz = clazz.getSuperclass()) { Field[] declaredFields = clazz.getDeclaredFields(); for (int i = 0; i < declaredFields.length; i++) { int mods = declaredFields[i].getModifiers(); if ((!excludeStatic || !Modifier.isStatic(mods)) && (!excludeTransient || !Modifier.isTransient(mods))) { declaredFields[i].setAccessible(true); fieldList.add(declaredFields[i]); } } } return fieldList; }
[ "public", "static", "List", "getAllFields", "(", "final", "Object", "obj", ",", "final", "boolean", "excludeStatic", ",", "final", "boolean", "excludeTransient", ")", "{", "List", "fieldList", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Class", "clazz", "=", "obj", ".", "getClass", "(", ")", ";", "clazz", "!=", "null", ";", "clazz", "=", "clazz", ".", "getSuperclass", "(", ")", ")", "{", "Field", "[", "]", "declaredFields", "=", "clazz", ".", "getDeclaredFields", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "declaredFields", ".", "length", ";", "i", "++", ")", "{", "int", "mods", "=", "declaredFields", "[", "i", "]", ".", "getModifiers", "(", ")", ";", "if", "(", "(", "!", "excludeStatic", "||", "!", "Modifier", ".", "isStatic", "(", "mods", ")", ")", "&&", "(", "!", "excludeTransient", "||", "!", "Modifier", ".", "isTransient", "(", "mods", ")", ")", ")", "{", "declaredFields", "[", "i", "]", ".", "setAccessible", "(", "true", ")", ";", "fieldList", ".", "add", "(", "declaredFields", "[", "i", "]", ")", ";", "}", "}", "}", "return", "fieldList", ";", "}" ]
Retrieves all the fields contained in the given object and its superclasses. @param obj the object to examine @param excludeStatic if true, static fields will be omitted @param excludeTransient if true, transient fields will be omitted @return a list of fields for the given object
[ "Retrieves", "all", "the", "fields", "contained", "in", "the", "given", "object", "and", "its", "superclasses", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java#L93-L112
139,030
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java
ReflectionUtil.setProperty
public static void setProperty(final Object object, final String property, final Class propertyType, final Object value) { Class[] paramTypes = new Class[]{propertyType}; Object[] params = new Object[]{value}; String methodName = "set" + property.substring(0, 1).toUpperCase() + property.substring(1); ReflectionUtil.invokeMethod(object, methodName, params, paramTypes); }
java
public static void setProperty(final Object object, final String property, final Class propertyType, final Object value) { Class[] paramTypes = new Class[]{propertyType}; Object[] params = new Object[]{value}; String methodName = "set" + property.substring(0, 1).toUpperCase() + property.substring(1); ReflectionUtil.invokeMethod(object, methodName, params, paramTypes); }
[ "public", "static", "void", "setProperty", "(", "final", "Object", "object", ",", "final", "String", "property", ",", "final", "Class", "propertyType", ",", "final", "Object", "value", ")", "{", "Class", "[", "]", "paramTypes", "=", "new", "Class", "[", "]", "{", "propertyType", "}", ";", "Object", "[", "]", "params", "=", "new", "Object", "[", "]", "{", "value", "}", ";", "String", "methodName", "=", "\"set\"", "+", "property", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "property", ".", "substring", "(", "1", ")", ";", "ReflectionUtil", ".", "invokeMethod", "(", "object", ",", "methodName", ",", "params", ",", "paramTypes", ")", ";", "}" ]
This method sets a property on an object via reflection. @param object The object on which the property is to be set. @param property The name of the property to be set. @param propertyType The type of the property being set. @param value The value of the property being set.
[ "This", "method", "sets", "a", "property", "on", "an", "object", "via", "reflection", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java#L122-L129
139,031
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java
ReflectionUtil.getProperty
public static Object getProperty(final Object object, final String property) { Class[] paramTypes = new Class[]{}; Object[] params = new Object[]{}; String methodName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1); return ReflectionUtil.invokeMethod(object, methodName, params, paramTypes); }
java
public static Object getProperty(final Object object, final String property) { Class[] paramTypes = new Class[]{}; Object[] params = new Object[]{}; String methodName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1); return ReflectionUtil.invokeMethod(object, methodName, params, paramTypes); }
[ "public", "static", "Object", "getProperty", "(", "final", "Object", "object", ",", "final", "String", "property", ")", "{", "Class", "[", "]", "paramTypes", "=", "new", "Class", "[", "]", "{", "}", ";", "Object", "[", "]", "params", "=", "new", "Object", "[", "]", "{", "}", ";", "String", "methodName", "=", "\"get\"", "+", "property", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "property", ".", "substring", "(", "1", ")", ";", "return", "ReflectionUtil", ".", "invokeMethod", "(", "object", ",", "methodName", ",", "params", ",", "paramTypes", ")", ";", "}" ]
This method gets a property from an object via reflection. @param object The object from which the property is to be retrieved. @param property The name of the property to be retrieved. @return The value of the specified <em>property</em>.
[ "This", "method", "gets", "a", "property", "from", "an", "object", "via", "reflection", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ReflectionUtil.java#L139-L145
139,032
podio/podio-java
src/main/java/com/podio/rating/RatingAPI.java
RatingAPI.createRating
public int createRating(Reference reference, RatingType type, int value) { return getResourceFactory() .getApiResource("/rating/" + reference.toURLFragment() + type) .entity(Collections.singletonMap("value", value), MediaType.APPLICATION_JSON_TYPE) .post(RatingCreateResponse.class).getId(); }
java
public int createRating(Reference reference, RatingType type, int value) { return getResourceFactory() .getApiResource("/rating/" + reference.toURLFragment() + type) .entity(Collections.singletonMap("value", value), MediaType.APPLICATION_JSON_TYPE) .post(RatingCreateResponse.class).getId(); }
[ "public", "int", "createRating", "(", "Reference", "reference", ",", "RatingType", "type", ",", "int", "value", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/rating/\"", "+", "reference", ".", "toURLFragment", "(", ")", "+", "type", ")", ".", "entity", "(", "Collections", ".", "singletonMap", "(", "\"value\"", ",", "value", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", "RatingCreateResponse", ".", "class", ")", ".", "getId", "(", ")", ";", "}" ]
Add a new rating of the user to the object. The rating can be one of many different types. For more details see the area. Ratings can be changed by posting a new rating, and deleted by doing a DELETE. @param reference The reference to the object the rating should be created on @param type The type of the rating @param value The value for the rating @return The id of the newly created rating @see RatingValue
[ "Add", "a", "new", "rating", "of", "the", "user", "to", "the", "object", ".", "The", "rating", "can", "be", "one", "of", "many", "different", "types", ".", "For", "more", "details", "see", "the", "area", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/rating/RatingAPI.java#L41-L47
139,033
podio/podio-java
src/main/java/com/podio/rating/RatingAPI.java
RatingAPI.deleteRating
public void deleteRating(Reference reference, RatingType type) { getResourceFactory().getApiResource( "/rating/" + reference.toURLFragment() + type).delete(); }
java
public void deleteRating(Reference reference, RatingType type) { getResourceFactory().getApiResource( "/rating/" + reference.toURLFragment() + type).delete(); }
[ "public", "void", "deleteRating", "(", "Reference", "reference", ",", "RatingType", "type", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/rating/\"", "+", "reference", ".", "toURLFragment", "(", ")", "+", "type", ")", ".", "delete", "(", ")", ";", "}" ]
Deletes the rating of the given type on the object by the active user @param reference The reference ot the object @param type The type of the rating
[ "Deletes", "the", "rating", "of", "the", "given", "type", "on", "the", "object", "by", "the", "active", "user" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/rating/RatingAPI.java#L57-L60
139,034
podio/podio-java
src/main/java/com/podio/rating/RatingAPI.java
RatingAPI.getAllRatings
public RatingValuesMap getAllRatings(Reference reference) { return getResourceFactory().getApiResource( "/rating/" + reference.toURLFragment()).get( RatingValuesMap.class); }
java
public RatingValuesMap getAllRatings(Reference reference) { return getResourceFactory().getApiResource( "/rating/" + reference.toURLFragment()).get( RatingValuesMap.class); }
[ "public", "RatingValuesMap", "getAllRatings", "(", "Reference", "reference", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/rating/\"", "+", "reference", ".", "toURLFragment", "(", ")", ")", ".", "get", "(", "RatingValuesMap", ".", "class", ")", ";", "}" ]
Returns all the ratings for the given object. It will only return the ratings that are enabled for the object. @param reference The reference to the object to get ratings for @return The map of rating types and their values
[ "Returns", "all", "the", "ratings", "for", "the", "given", "object", ".", "It", "will", "only", "return", "the", "ratings", "that", "are", "enabled", "for", "the", "object", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/rating/RatingAPI.java#L198-L202
139,035
podio/podio-java
src/main/java/com/podio/rating/RatingAPI.java
RatingAPI.getRating
public int getRating(Reference reference, RatingType type, int userId) { return getResourceFactory() .getApiResource( "/rating/" + reference.toURLFragment() + type + "/" + userId).get(SingleRatingValue.class) .getValue(); }
java
public int getRating(Reference reference, RatingType type, int userId) { return getResourceFactory() .getApiResource( "/rating/" + reference.toURLFragment() + type + "/" + userId).get(SingleRatingValue.class) .getValue(); }
[ "public", "int", "getRating", "(", "Reference", "reference", ",", "RatingType", "type", ",", "int", "userId", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/rating/\"", "+", "reference", ".", "toURLFragment", "(", ")", "+", "type", "+", "\"/\"", "+", "userId", ")", ".", "get", "(", "SingleRatingValue", ".", "class", ")", ".", "getValue", "(", ")", ";", "}" ]
Returns the rating value for the given rating type, object and user. @param reference The reference to the object to get ratings for @param type The type of rating to return @param userId The id of the user for which to return the rating for @return The value of the rating
[ "Returns", "the", "rating", "value", "for", "the", "given", "rating", "type", "object", "and", "user", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/rating/RatingAPI.java#L231-L237
139,036
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubMenuRenderer.java
WSubMenuRenderer.getMenuType
private String getMenuType(final WSubMenu submenu) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, submenu); switch (menu.getType()) { case BAR: return "bar"; case FLYOUT: return "flyout"; case TREE: return "tree"; case COLUMN: return "column"; default: throw new IllegalStateException("Invalid menu type: " + menu.getType()); } }
java
private String getMenuType(final WSubMenu submenu) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, submenu); switch (menu.getType()) { case BAR: return "bar"; case FLYOUT: return "flyout"; case TREE: return "tree"; case COLUMN: return "column"; default: throw new IllegalStateException("Invalid menu type: " + menu.getType()); } }
[ "private", "String", "getMenuType", "(", "final", "WSubMenu", "submenu", ")", "{", "WMenu", "menu", "=", "WebUtilities", ".", "getAncestorOfClass", "(", "WMenu", ".", "class", ",", "submenu", ")", ";", "switch", "(", "menu", ".", "getType", "(", ")", ")", "{", "case", "BAR", ":", "return", "\"bar\"", ";", "case", "FLYOUT", ":", "return", "\"flyout\"", ";", "case", "TREE", ":", "return", "\"tree\"", ";", "case", "COLUMN", ":", "return", "\"column\"", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "\"Invalid menu type: \"", "+", "menu", ".", "getType", "(", ")", ")", ";", "}", "}" ]
Get the string value of a WMenu.MenuType. @param submenu he WSubMenu currently being rendered @return the menu type as a string
[ "Get", "the", "string", "value", "of", "a", "WMenu", ".", "MenuType", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubMenuRenderer.java#L48-L62
139,037
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubMenuRenderer.java
WSubMenuRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WSubMenu menu = (WSubMenu) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:submenu"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); if (isTree(menu)) { xml.appendAttribute("open", String.valueOf(isOpen(menu))); } xml.appendOptionalAttribute("disabled", menu.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", menu.isHidden(), "true"); if (menu.isTopLevelMenu()) { xml.appendOptionalAttribute("accessKey", menu.getAccessKeyAsString()); } else { xml.appendAttribute("nested", "true"); } xml.appendOptionalAttribute("type", getMenuType(menu)); switch (menu.getMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case LAZY: xml.appendAttribute("mode", "lazy"); break; case EAGER: xml.appendAttribute("mode", "eager"); break; case DYNAMIC: case SERVER: // mode server mapped to mode dynamic as per https://github.com/BorderTech/wcomponents/issues/687 xml.appendAttribute("mode", "dynamic"); break; default: throw new SystemException("Unknown menu mode: " + menu.getMode()); } xml.appendClose(); // Paint label menu.getDecoratedLabel().paint(renderContext); MenuMode mode = menu.getMode(); // Paint submenu items xml.appendTagOpen("ui:content"); xml.appendAttribute("id", component.getId() + "-content"); xml.appendClose(); // Render content if not EAGER Mode or is EAGER and is the current AJAX request if (mode != MenuMode.EAGER || AjaxHelper.isCurrentAjaxTrigger(menu)) { // Visibility of content set in prepare paint menu.paintMenuItems(renderContext); } xml.appendEndTag("ui:content"); xml.appendEndTag("ui:submenu"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WSubMenu menu = (WSubMenu) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:submenu"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); if (isTree(menu)) { xml.appendAttribute("open", String.valueOf(isOpen(menu))); } xml.appendOptionalAttribute("disabled", menu.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", menu.isHidden(), "true"); if (menu.isTopLevelMenu()) { xml.appendOptionalAttribute("accessKey", menu.getAccessKeyAsString()); } else { xml.appendAttribute("nested", "true"); } xml.appendOptionalAttribute("type", getMenuType(menu)); switch (menu.getMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case LAZY: xml.appendAttribute("mode", "lazy"); break; case EAGER: xml.appendAttribute("mode", "eager"); break; case DYNAMIC: case SERVER: // mode server mapped to mode dynamic as per https://github.com/BorderTech/wcomponents/issues/687 xml.appendAttribute("mode", "dynamic"); break; default: throw new SystemException("Unknown menu mode: " + menu.getMode()); } xml.appendClose(); // Paint label menu.getDecoratedLabel().paint(renderContext); MenuMode mode = menu.getMode(); // Paint submenu items xml.appendTagOpen("ui:content"); xml.appendAttribute("id", component.getId() + "-content"); xml.appendClose(); // Render content if not EAGER Mode or is EAGER and is the current AJAX request if (mode != MenuMode.EAGER || AjaxHelper.isCurrentAjaxTrigger(menu)) { // Visibility of content set in prepare paint menu.paintMenuItems(renderContext); } xml.appendEndTag("ui:content"); xml.appendEndTag("ui:submenu"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WSubMenu", "menu", "=", "(", "WSubMenu", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:submenu\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "isTree", "(", "menu", ")", ")", "{", "xml", ".", "appendAttribute", "(", "\"open\"", ",", "String", ".", "valueOf", "(", "isOpen", "(", "menu", ")", ")", ")", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "menu", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "menu", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "menu", ".", "isTopLevelMenu", "(", ")", ")", "{", "xml", ".", "appendOptionalAttribute", "(", "\"accessKey\"", ",", "menu", ".", "getAccessKeyAsString", "(", ")", ")", ";", "}", "else", "{", "xml", ".", "appendAttribute", "(", "\"nested\"", ",", "\"true\"", ")", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "getMenuType", "(", "menu", ")", ")", ";", "switch", "(", "menu", ".", "getMode", "(", ")", ")", "{", "case", "CLIENT", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"client\"", ")", ";", "break", ";", "case", "LAZY", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"lazy\"", ")", ";", "break", ";", "case", "EAGER", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"eager\"", ")", ";", "break", ";", "case", "DYNAMIC", ":", "case", "SERVER", ":", "// mode server mapped to mode dynamic as per https://github.com/BorderTech/wcomponents/issues/687", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"dynamic\"", ")", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown menu mode: \"", "+", "menu", ".", "getMode", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "// Paint label", "menu", ".", "getDecoratedLabel", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "MenuMode", "mode", "=", "menu", ".", "getMode", "(", ")", ";", "// Paint submenu items", "xml", ".", "appendTagOpen", "(", "\"ui:content\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", "+", "\"-content\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Render content if not EAGER Mode or is EAGER and is the current AJAX request", "if", "(", "mode", "!=", "MenuMode", ".", "EAGER", "||", "AjaxHelper", ".", "isCurrentAjaxTrigger", "(", "menu", ")", ")", "{", "// Visibility of content set in prepare paint", "menu", ".", "paintMenuItems", "(", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:content\"", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:submenu\"", ")", ";", "}" ]
Paints the given WSubMenu. @param component the WSubMenu to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WSubMenu", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubMenuRenderer.java#L70-L131
139,038
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiDropdown.java
WMultiDropdown.getNewSelections
@Override protected List getNewSelections(final Request request) { List selections = super.getNewSelections(request); if (selections != null) { // Ensure that there are no duplicates for (int i = 0; i < selections.size(); i++) { Object selection = selections.get(i); for (int j = i + 1; j < selections.size(); j++) { if (Util.equals(selection, selections.get(j))) { selections.remove(j--); } } } } return selections; }
java
@Override protected List getNewSelections(final Request request) { List selections = super.getNewSelections(request); if (selections != null) { // Ensure that there are no duplicates for (int i = 0; i < selections.size(); i++) { Object selection = selections.get(i); for (int j = i + 1; j < selections.size(); j++) { if (Util.equals(selection, selections.get(j))) { selections.remove(j--); } } } } return selections; }
[ "@", "Override", "protected", "List", "getNewSelections", "(", "final", "Request", "request", ")", "{", "List", "selections", "=", "super", ".", "getNewSelections", "(", "request", ")", ";", "if", "(", "selections", "!=", "null", ")", "{", "// Ensure that there are no duplicates", "for", "(", "int", "i", "=", "0", ";", "i", "<", "selections", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Object", "selection", "=", "selections", ".", "get", "(", "i", ")", ";", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "selections", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "Util", ".", "equals", "(", "selection", ",", "selections", ".", "get", "(", "j", ")", ")", ")", "{", "selections", ".", "remove", "(", "j", "--", ")", ";", "}", "}", "}", "}", "return", "selections", ";", "}" ]
Override getNewSelections to ensure that the max number of inputs is honoured and that there are no duplicates. This should not normally occur, as the client side js should prevent it. @param request the current request @return a list of selections that have been added in the given request.
[ "Override", "getNewSelections", "to", "ensure", "that", "the", "max", "number", "of", "inputs", "is", "honoured", "and", "that", "there", "are", "no", "duplicates", ".", "This", "should", "not", "normally", "occur", "as", "the", "client", "side", "js", "should", "prevent", "it", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiDropdown.java#L93-L111
139,039
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TableUtil.java
TableUtil.rowIndexListToString
public static String rowIndexListToString(final List<Integer> row) { if (row == null || row.isEmpty()) { return null; } StringBuffer index = new StringBuffer(); boolean addDelimiter = false; for (Integer lvl : row) { if (addDelimiter) { index.append(INDEX_DELIMITER); } index.append(lvl); addDelimiter = true; } return index.toString(); }
java
public static String rowIndexListToString(final List<Integer> row) { if (row == null || row.isEmpty()) { return null; } StringBuffer index = new StringBuffer(); boolean addDelimiter = false; for (Integer lvl : row) { if (addDelimiter) { index.append(INDEX_DELIMITER); } index.append(lvl); addDelimiter = true; } return index.toString(); }
[ "public", "static", "String", "rowIndexListToString", "(", "final", "List", "<", "Integer", ">", "row", ")", "{", "if", "(", "row", "==", "null", "||", "row", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "StringBuffer", "index", "=", "new", "StringBuffer", "(", ")", ";", "boolean", "addDelimiter", "=", "false", ";", "for", "(", "Integer", "lvl", ":", "row", ")", "{", "if", "(", "addDelimiter", ")", "{", "index", ".", "append", "(", "INDEX_DELIMITER", ")", ";", "}", "index", ".", "append", "(", "lvl", ")", ";", "addDelimiter", "=", "true", ";", "}", "return", "index", ".", "toString", "(", ")", ";", "}" ]
Convert the row index to its string representation. @param row the row index @return the string representation of the row index
[ "Convert", "the", "row", "index", "to", "its", "string", "representation", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TableUtil.java#L46-L63
139,040
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TableUtil.java
TableUtil.rowIndexStringToList
public static List<Integer> rowIndexStringToList(final String row) { if (row == null) { return null; } List<Integer> rowIndex = new ArrayList<>(); try { // Convert StringId to array String[] rowIdString = row.split(INDEX_DELIMITER); for (int i = 0; i < rowIdString.length; i++) { rowIndex.add(Integer.parseInt(rowIdString[i])); } } catch (NumberFormatException e) { LOG.warn("Invalid row id: " + row); } return rowIndex; }
java
public static List<Integer> rowIndexStringToList(final String row) { if (row == null) { return null; } List<Integer> rowIndex = new ArrayList<>(); try { // Convert StringId to array String[] rowIdString = row.split(INDEX_DELIMITER); for (int i = 0; i < rowIdString.length; i++) { rowIndex.add(Integer.parseInt(rowIdString[i])); } } catch (NumberFormatException e) { LOG.warn("Invalid row id: " + row); } return rowIndex; }
[ "public", "static", "List", "<", "Integer", ">", "rowIndexStringToList", "(", "final", "String", "row", ")", "{", "if", "(", "row", "==", "null", ")", "{", "return", "null", ";", "}", "List", "<", "Integer", ">", "rowIndex", "=", "new", "ArrayList", "<>", "(", ")", ";", "try", "{", "// Convert StringId to array", "String", "[", "]", "rowIdString", "=", "row", ".", "split", "(", "INDEX_DELIMITER", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rowIdString", ".", "length", ";", "i", "++", ")", "{", "rowIndex", ".", "add", "(", "Integer", ".", "parseInt", "(", "rowIdString", "[", "i", "]", ")", ")", ";", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Invalid row id: \"", "+", "row", ")", ";", "}", "return", "rowIndex", ";", "}" ]
Convert the string representation of a row index to a list. @param row the string representation of the row index @return the row index
[ "Convert", "the", "string", "representation", "of", "a", "row", "index", "to", "a", "list", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TableUtil.java#L71-L90
139,041
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TableUtil.java
TableUtil.sortData
public static void sortData(final Object[] data, final Comparator<Object> comparator, final boolean ascending, final int lowIndex, final int highIndex, final int[] sortIndices) { if (lowIndex >= highIndex) { return; // 1 element, so sorted already! } Object midValue = data[sortIndices[(lowIndex + highIndex) >>> 1]]; int i = lowIndex - 1; int j = highIndex + 1; int sign = ascending ? 1 : -1; for (;;) { do { i++; } while (comparator.compare(data[sortIndices[i]], midValue) * sign < 0); do { j--; } while (comparator.compare(data[sortIndices[j]], midValue) * sign > 0); if (i >= j) { break; // crossover, good! } // Out of order - swap! int temp = sortIndices[i]; sortIndices[i] = sortIndices[j]; sortIndices[j] = temp; } // now determine the split point... if (i > j) { i = j; } sortData(data, comparator, ascending, lowIndex, i, sortIndices); sortData(data, comparator, ascending, i + 1, highIndex, sortIndices); }
java
public static void sortData(final Object[] data, final Comparator<Object> comparator, final boolean ascending, final int lowIndex, final int highIndex, final int[] sortIndices) { if (lowIndex >= highIndex) { return; // 1 element, so sorted already! } Object midValue = data[sortIndices[(lowIndex + highIndex) >>> 1]]; int i = lowIndex - 1; int j = highIndex + 1; int sign = ascending ? 1 : -1; for (;;) { do { i++; } while (comparator.compare(data[sortIndices[i]], midValue) * sign < 0); do { j--; } while (comparator.compare(data[sortIndices[j]], midValue) * sign > 0); if (i >= j) { break; // crossover, good! } // Out of order - swap! int temp = sortIndices[i]; sortIndices[i] = sortIndices[j]; sortIndices[j] = temp; } // now determine the split point... if (i > j) { i = j; } sortData(data, comparator, ascending, lowIndex, i, sortIndices); sortData(data, comparator, ascending, i + 1, highIndex, sortIndices); }
[ "public", "static", "void", "sortData", "(", "final", "Object", "[", "]", "data", ",", "final", "Comparator", "<", "Object", ">", "comparator", ",", "final", "boolean", "ascending", ",", "final", "int", "lowIndex", ",", "final", "int", "highIndex", ",", "final", "int", "[", "]", "sortIndices", ")", "{", "if", "(", "lowIndex", ">=", "highIndex", ")", "{", "return", ";", "// 1 element, so sorted already!", "}", "Object", "midValue", "=", "data", "[", "sortIndices", "[", "(", "lowIndex", "+", "highIndex", ")", ">>>", "1", "]", "]", ";", "int", "i", "=", "lowIndex", "-", "1", ";", "int", "j", "=", "highIndex", "+", "1", ";", "int", "sign", "=", "ascending", "?", "1", ":", "-", "1", ";", "for", "(", ";", ";", ")", "{", "do", "{", "i", "++", ";", "}", "while", "(", "comparator", ".", "compare", "(", "data", "[", "sortIndices", "[", "i", "]", "]", ",", "midValue", ")", "*", "sign", "<", "0", ")", ";", "do", "{", "j", "--", ";", "}", "while", "(", "comparator", ".", "compare", "(", "data", "[", "sortIndices", "[", "j", "]", "]", ",", "midValue", ")", "*", "sign", ">", "0", ")", ";", "if", "(", "i", ">=", "j", ")", "{", "break", ";", "// crossover, good!", "}", "// Out of order - swap!", "int", "temp", "=", "sortIndices", "[", "i", "]", ";", "sortIndices", "[", "i", "]", "=", "sortIndices", "[", "j", "]", ";", "sortIndices", "[", "j", "]", "=", "temp", ";", "}", "// now determine the split point...", "if", "(", "i", ">", "j", ")", "{", "i", "=", "j", ";", "}", "sortData", "(", "data", ",", "comparator", ",", "ascending", ",", "lowIndex", ",", "i", ",", "sortIndices", ")", ";", "sortData", "(", "data", ",", "comparator", ",", "ascending", ",", "i", "+", "1", ",", "highIndex", ",", "sortIndices", ")", ";", "}" ]
Sorts the data using the given comparator, using a quick-sort. @param data the data for the column. @param comparator the comparator to use for sorting. @param ascending true for an ascending sort, false for descending. @param lowIndex the start index for sub-sorting @param highIndex the end index for sub-sorting @param sortIndices the row indices, which will be updated as a result of the sort
[ "Sorts", "the", "data", "using", "the", "given", "comparator", "using", "a", "quick", "-", "sort", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TableUtil.java#L139-L178
139,042
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/TableCellWithActionExample.java
TableCellWithActionExample.parse
private static Date parse(final String dateString) { try { return new SimpleDateFormat("dd/mm/yyyy").parse(dateString); } catch (ParseException e) { LOG.error("Error parsing date: " + dateString, e); return null; } }
java
private static Date parse(final String dateString) { try { return new SimpleDateFormat("dd/mm/yyyy").parse(dateString); } catch (ParseException e) { LOG.error("Error parsing date: " + dateString, e); return null; } }
[ "private", "static", "Date", "parse", "(", "final", "String", "dateString", ")", "{", "try", "{", "return", "new", "SimpleDateFormat", "(", "\"dd/mm/yyyy\"", ")", ".", "parse", "(", "dateString", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "LOG", ".", "error", "(", "\"Error parsing date: \"", "+", "dateString", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Parses a date string. @param dateString the date string to parse @return a date corresponding to the given dateString, or null on error.
[ "Parses", "a", "date", "string", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/TableCellWithActionExample.java#L89-L96
139,043
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/TableCellWithActionExample.java
TableCellWithActionExample.createTableModel
private TableDataModel createTableModel() { return new AbstractTableDataModel() { /** * Column id for the first name column. */ private static final int FIRST_NAME = 0; /** * Column id for the last name column. */ private static final int LAST_NAME = 1; /** * Column id for the date of birth column. */ private static final int DOB = 2; /** * Column id for the action column. */ private static final int BUTTON = 3; private final List<Person> data = Arrays.asList(new Person[]{new Person(123, "Joe", "Bloggs", parse("01/02/1973")), new Person(456, "Jane", "Bloggs", parse("04/05/1976")), new Person(789, "Kid", "Bloggs", parse("31/12/1999"))}); /** * {@inheritDoc} */ @Override public Object getValueAt(final int row, final int col) { Person person = data.get(row); switch (col) { case FIRST_NAME: return person.getFirstName(); case LAST_NAME: return person.getLastName(); case DOB: { if (person.getDateOfBirth() == null) { return null; } return person.getDateOfBirth(); } case BUTTON: { return person; } default: return null; } } /** * {@inheritDoc} */ @Override public int getRowCount() { return data.size(); } }; }
java
private TableDataModel createTableModel() { return new AbstractTableDataModel() { /** * Column id for the first name column. */ private static final int FIRST_NAME = 0; /** * Column id for the last name column. */ private static final int LAST_NAME = 1; /** * Column id for the date of birth column. */ private static final int DOB = 2; /** * Column id for the action column. */ private static final int BUTTON = 3; private final List<Person> data = Arrays.asList(new Person[]{new Person(123, "Joe", "Bloggs", parse("01/02/1973")), new Person(456, "Jane", "Bloggs", parse("04/05/1976")), new Person(789, "Kid", "Bloggs", parse("31/12/1999"))}); /** * {@inheritDoc} */ @Override public Object getValueAt(final int row, final int col) { Person person = data.get(row); switch (col) { case FIRST_NAME: return person.getFirstName(); case LAST_NAME: return person.getLastName(); case DOB: { if (person.getDateOfBirth() == null) { return null; } return person.getDateOfBirth(); } case BUTTON: { return person; } default: return null; } } /** * {@inheritDoc} */ @Override public int getRowCount() { return data.size(); } }; }
[ "private", "TableDataModel", "createTableModel", "(", ")", "{", "return", "new", "AbstractTableDataModel", "(", ")", "{", "/**\n\t\t\t * Column id for the first name column.\n\t\t\t */", "private", "static", "final", "int", "FIRST_NAME", "=", "0", ";", "/**\n\t\t\t * Column id for the last name column.\n\t\t\t */", "private", "static", "final", "int", "LAST_NAME", "=", "1", ";", "/**\n\t\t\t * Column id for the date of birth column.\n\t\t\t */", "private", "static", "final", "int", "DOB", "=", "2", ";", "/**\n\t\t\t * Column id for the action column.\n\t\t\t */", "private", "static", "final", "int", "BUTTON", "=", "3", ";", "private", "final", "List", "<", "Person", ">", "data", "=", "Arrays", ".", "asList", "(", "new", "Person", "[", "]", "{", "new", "Person", "(", "123", ",", "\"Joe\"", ",", "\"Bloggs\"", ",", "parse", "(", "\"01/02/1973\"", ")", ")", ",", "new", "Person", "(", "456", ",", "\"Jane\"", ",", "\"Bloggs\"", ",", "parse", "(", "\"04/05/1976\"", ")", ")", ",", "new", "Person", "(", "789", ",", "\"Kid\"", ",", "\"Bloggs\"", ",", "parse", "(", "\"31/12/1999\"", ")", ")", "}", ")", ";", "/**\n\t\t\t * {@inheritDoc}\n\t\t\t */", "@", "Override", "public", "Object", "getValueAt", "(", "final", "int", "row", ",", "final", "int", "col", ")", "{", "Person", "person", "=", "data", ".", "get", "(", "row", ")", ";", "switch", "(", "col", ")", "{", "case", "FIRST_NAME", ":", "return", "person", ".", "getFirstName", "(", ")", ";", "case", "LAST_NAME", ":", "return", "person", ".", "getLastName", "(", ")", ";", "case", "DOB", ":", "{", "if", "(", "person", ".", "getDateOfBirth", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "return", "person", ".", "getDateOfBirth", "(", ")", ";", "}", "case", "BUTTON", ":", "{", "return", "person", ";", "}", "default", ":", "return", "null", ";", "}", "}", "/**\n\t\t\t * {@inheritDoc}\n\t\t\t */", "@", "Override", "public", "int", "getRowCount", "(", ")", "{", "return", "data", ".", "size", "(", ")", ";", "}", "}", ";", "}" ]
Creates a table data model containing some dummy person data. @return a new data model.
[ "Creates", "a", "table", "data", "model", "containing", "some", "dummy", "person", "data", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/TableCellWithActionExample.java#L103-L170
139,044
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/PageContentHelper.java
PageContentHelper.addAllHeadlines
public static void addAllHeadlines(final PrintWriter writer, final Headers headers) { PageContentHelper.addHeadlines(writer, headers.getHeadLines()); PageContentHelper.addJsHeadlines(writer, headers.getHeadLines(Headers.JAVASCRIPT_HEADLINE)); PageContentHelper.addCssHeadlines(writer, headers.getHeadLines(Headers.CSS_HEADLINE)); }
java
public static void addAllHeadlines(final PrintWriter writer, final Headers headers) { PageContentHelper.addHeadlines(writer, headers.getHeadLines()); PageContentHelper.addJsHeadlines(writer, headers.getHeadLines(Headers.JAVASCRIPT_HEADLINE)); PageContentHelper.addCssHeadlines(writer, headers.getHeadLines(Headers.CSS_HEADLINE)); }
[ "public", "static", "void", "addAllHeadlines", "(", "final", "PrintWriter", "writer", ",", "final", "Headers", "headers", ")", "{", "PageContentHelper", ".", "addHeadlines", "(", "writer", ",", "headers", ".", "getHeadLines", "(", ")", ")", ";", "PageContentHelper", ".", "addJsHeadlines", "(", "writer", ",", "headers", ".", "getHeadLines", "(", "Headers", ".", "JAVASCRIPT_HEADLINE", ")", ")", ";", "PageContentHelper", ".", "addCssHeadlines", "(", "writer", ",", "headers", ".", "getHeadLines", "(", "Headers", ".", "CSS_HEADLINE", ")", ")", ";", "}" ]
Shortcut method for adding all the headline entries stored in the WHeaders. @param writer the writer to write to. @param headers contains all the headline entries.
[ "Shortcut", "method", "for", "adding", "all", "the", "headline", "entries", "stored", "in", "the", "WHeaders", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/PageContentHelper.java#L33-L37
139,045
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WButtonRenderer.java
WButtonRenderer.paintAjax
private void paintAjax(final WButton button, final XmlStringBuilder xml) { // Start tag xml.appendTagOpen("ui:ajaxtrigger"); xml.appendAttribute("triggerId", button.getId()); xml.appendClose(); // Target xml.appendTagOpen("ui:ajaxtargetid"); xml.appendAttribute("targetId", button.getAjaxTarget().getId()); xml.appendEnd(); // End tag xml.appendEndTag("ui:ajaxtrigger"); }
java
private void paintAjax(final WButton button, final XmlStringBuilder xml) { // Start tag xml.appendTagOpen("ui:ajaxtrigger"); xml.appendAttribute("triggerId", button.getId()); xml.appendClose(); // Target xml.appendTagOpen("ui:ajaxtargetid"); xml.appendAttribute("targetId", button.getAjaxTarget().getId()); xml.appendEnd(); // End tag xml.appendEndTag("ui:ajaxtrigger"); }
[ "private", "void", "paintAjax", "(", "final", "WButton", "button", ",", "final", "XmlStringBuilder", "xml", ")", "{", "// Start tag", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxtrigger\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"triggerId\"", ",", "button", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Target", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxtargetid\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"targetId\"", ",", "button", ".", "getAjaxTarget", "(", ")", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "// End tag", "xml", ".", "appendEndTag", "(", "\"ui:ajaxtrigger\"", ")", ";", "}" ]
Paints the AJAX information for the given WButton. @param button the WButton to paint. @param xml the XmlStringBuilder to paint to.
[ "Paints", "the", "AJAX", "information", "for", "the", "given", "WButton", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WButtonRenderer.java#L134-L147
139,046
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDialogRenderer.java
WDialogRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WDialog dialog = (WDialog) component; int state = dialog.getState(); if (state == WDialog.ACTIVE_STATE || dialog.getTrigger() != null) { int width = dialog.getWidth(); int height = dialog.getHeight(); String title = dialog.getTitle(); XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:dialog"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("width", width > 0, width); xml.appendOptionalAttribute("height", height > 0, height); xml.appendOptionalAttribute("modal", dialog.getMode() == WDialog.MODAL, "true"); xml.appendOptionalAttribute("open", dialog.getState() == WDialog.ACTIVE_STATE, "true"); xml.appendOptionalAttribute("title", title); DialogOpenTrigger trigger = dialog.getTrigger(); if (trigger != null) { xml.appendOptionalAttribute("triggerid", trigger.getId()); if (dialog.hasLegacyTriggerButton()) { xml.appendClose(); trigger.paint(renderContext); xml.appendEndTag("ui:dialog"); } else { xml.appendEnd(); } } else { xml.appendEnd(); } } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WDialog dialog = (WDialog) component; int state = dialog.getState(); if (state == WDialog.ACTIVE_STATE || dialog.getTrigger() != null) { int width = dialog.getWidth(); int height = dialog.getHeight(); String title = dialog.getTitle(); XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:dialog"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("width", width > 0, width); xml.appendOptionalAttribute("height", height > 0, height); xml.appendOptionalAttribute("modal", dialog.getMode() == WDialog.MODAL, "true"); xml.appendOptionalAttribute("open", dialog.getState() == WDialog.ACTIVE_STATE, "true"); xml.appendOptionalAttribute("title", title); DialogOpenTrigger trigger = dialog.getTrigger(); if (trigger != null) { xml.appendOptionalAttribute("triggerid", trigger.getId()); if (dialog.hasLegacyTriggerButton()) { xml.appendClose(); trigger.paint(renderContext); xml.appendEndTag("ui:dialog"); } else { xml.appendEnd(); } } else { xml.appendEnd(); } } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WDialog", "dialog", "=", "(", "WDialog", ")", "component", ";", "int", "state", "=", "dialog", ".", "getState", "(", ")", ";", "if", "(", "state", "==", "WDialog", ".", "ACTIVE_STATE", "||", "dialog", ".", "getTrigger", "(", ")", "!=", "null", ")", "{", "int", "width", "=", "dialog", ".", "getWidth", "(", ")", ";", "int", "height", "=", "dialog", ".", "getHeight", "(", ")", ";", "String", "title", "=", "dialog", ".", "getTitle", "(", ")", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:dialog\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"width\"", ",", "width", ">", "0", ",", "width", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"height\"", ",", "height", ">", "0", ",", "height", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"modal\"", ",", "dialog", ".", "getMode", "(", ")", "==", "WDialog", ".", "MODAL", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"open\"", ",", "dialog", ".", "getState", "(", ")", "==", "WDialog", ".", "ACTIVE_STATE", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"title\"", ",", "title", ")", ";", "DialogOpenTrigger", "trigger", "=", "dialog", ".", "getTrigger", "(", ")", ";", "if", "(", "trigger", "!=", "null", ")", "{", "xml", ".", "appendOptionalAttribute", "(", "\"triggerid\"", ",", "trigger", ".", "getId", "(", ")", ")", ";", "if", "(", "dialog", ".", "hasLegacyTriggerButton", "(", ")", ")", "{", "xml", ".", "appendClose", "(", ")", ";", "trigger", ".", "paint", "(", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:dialog\"", ")", ";", "}", "else", "{", "xml", ".", "appendEnd", "(", ")", ";", "}", "}", "else", "{", "xml", ".", "appendEnd", "(", ")", ";", "}", "}", "}" ]
Paints the given WDialog. @param component the WDialog to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WDialog", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDialogRenderer.java#L24-L59
139,047
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxDebugStructureInterceptor.java
AjaxDebugStructureInterceptor.paint
@Override public void paint(final RenderContext renderContext) { if (!DebugUtil.isDebugFeaturesEnabled() || !(renderContext instanceof WebXmlRenderContext)) { getBackingComponent().paint(renderContext); return; } AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation == null) { getBackingComponent().paint(renderContext); return; } getBackingComponent().paint(renderContext); XmlStringBuilder xml = ((WebXmlRenderContext) renderContext).getWriter(); xml.appendTag("ui:debug"); for (String targetId : operation.getTargets()) { ComponentWithContext target = WebUtilities.getComponentById(targetId, true); if (target != null) { writeDebugInfo(target.getComponent(), xml); } } xml.appendEndTag("ui:debug"); }
java
@Override public void paint(final RenderContext renderContext) { if (!DebugUtil.isDebugFeaturesEnabled() || !(renderContext instanceof WebXmlRenderContext)) { getBackingComponent().paint(renderContext); return; } AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation == null) { getBackingComponent().paint(renderContext); return; } getBackingComponent().paint(renderContext); XmlStringBuilder xml = ((WebXmlRenderContext) renderContext).getWriter(); xml.appendTag("ui:debug"); for (String targetId : operation.getTargets()) { ComponentWithContext target = WebUtilities.getComponentById(targetId, true); if (target != null) { writeDebugInfo(target.getComponent(), xml); } } xml.appendEndTag("ui:debug"); }
[ "@", "Override", "public", "void", "paint", "(", "final", "RenderContext", "renderContext", ")", "{", "if", "(", "!", "DebugUtil", ".", "isDebugFeaturesEnabled", "(", ")", "||", "!", "(", "renderContext", "instanceof", "WebXmlRenderContext", ")", ")", "{", "getBackingComponent", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "return", ";", "}", "AjaxOperation", "operation", "=", "AjaxHelper", ".", "getCurrentOperation", "(", ")", ";", "if", "(", "operation", "==", "null", ")", "{", "getBackingComponent", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "return", ";", "}", "getBackingComponent", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "XmlStringBuilder", "xml", "=", "(", "(", "WebXmlRenderContext", ")", "renderContext", ")", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTag", "(", "\"ui:debug\"", ")", ";", "for", "(", "String", "targetId", ":", "operation", ".", "getTargets", "(", ")", ")", "{", "ComponentWithContext", "target", "=", "WebUtilities", ".", "getComponentById", "(", "targetId", ",", "true", ")", ";", "if", "(", "target", "!=", "null", ")", "{", "writeDebugInfo", "(", "target", ".", "getComponent", "(", ")", ",", "xml", ")", ";", "}", "}", "xml", ".", "appendEndTag", "(", "\"ui:debug\"", ")", ";", "}" ]
Override paint to only output the debugging info for the current targets. @param renderContext the renderContext to send the output to.
[ "Override", "paint", "to", "only", "output", "the", "debugging", "info", "for", "the", "current", "targets", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxDebugStructureInterceptor.java#L26-L53
139,048
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/MockRequest.java
MockRequest.setParameter
public void setParameter(final String key, final String value) { parameters.put(key, new String[]{value}); }
java
public void setParameter(final String key, final String value) { parameters.put(key, new String[]{value}); }
[ "public", "void", "setParameter", "(", "final", "String", "key", ",", "final", "String", "value", ")", "{", "parameters", ".", "put", "(", "key", ",", "new", "String", "[", "]", "{", "value", "}", ")", ";", "}" ]
Sets a parameter. @param key the parameter key. @param value the parameter value.
[ "Sets", "a", "parameter", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/MockRequest.java#L70-L72
139,049
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/MockRequest.java
MockRequest.addParameterForButton
public void addParameterForButton(final UIContext uic, final WButton button) { UIContextHolder.pushContext(uic); try { setParameter(button.getId(), "x"); } finally { UIContextHolder.popContext(); } }
java
public void addParameterForButton(final UIContext uic, final WButton button) { UIContextHolder.pushContext(uic); try { setParameter(button.getId(), "x"); } finally { UIContextHolder.popContext(); } }
[ "public", "void", "addParameterForButton", "(", "final", "UIContext", "uic", ",", "final", "WButton", "button", ")", "{", "UIContextHolder", ".", "pushContext", "(", "uic", ")", ";", "try", "{", "setParameter", "(", "button", ".", "getId", "(", ")", ",", "\"x\"", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}" ]
Convenience method that adds a parameter emulating a button press. @param uic the current user's UIContext @param button the button to add a parameter for.
[ "Convenience", "method", "that", "adds", "a", "parameter", "emulating", "a", "button", "press", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/MockRequest.java#L90-L97
139,050
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/MockRequest.java
MockRequest.setFileContents
public void setFileContents(final String key, final byte[] contents) { MockFileItem fileItem = new MockFileItem(); fileItem.set(contents); files.put(key, new FileItem[]{fileItem}); }
java
public void setFileContents(final String key, final byte[] contents) { MockFileItem fileItem = new MockFileItem(); fileItem.set(contents); files.put(key, new FileItem[]{fileItem}); }
[ "public", "void", "setFileContents", "(", "final", "String", "key", ",", "final", "byte", "[", "]", "contents", ")", "{", "MockFileItem", "fileItem", "=", "new", "MockFileItem", "(", ")", ";", "fileItem", ".", "set", "(", "contents", ")", ";", "files", ".", "put", "(", "key", ",", "new", "FileItem", "[", "]", "{", "fileItem", "}", ")", ";", "}" ]
Sets mock file upload contents. @param key the parameter key. @param contents the file binary data.
[ "Sets", "mock", "file", "upload", "contents", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/MockRequest.java#L105-L109
139,051
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessages.java
WMessages.addMessage
private void addMessage(final WMessageBox box, final Message message, final boolean encode) { String code = message.getMessage(); if (!Util.empty(code)) { box.addMessage(encode, code, message.getArgs()); } }
java
private void addMessage(final WMessageBox box, final Message message, final boolean encode) { String code = message.getMessage(); if (!Util.empty(code)) { box.addMessage(encode, code, message.getArgs()); } }
[ "private", "void", "addMessage", "(", "final", "WMessageBox", "box", ",", "final", "Message", "message", ",", "final", "boolean", "encode", ")", "{", "String", "code", "=", "message", ".", "getMessage", "(", ")", ";", "if", "(", "!", "Util", ".", "empty", "(", "code", ")", ")", "{", "box", ".", "addMessage", "(", "encode", ",", "code", ",", "message", ".", "getArgs", "(", ")", ")", ";", "}", "}" ]
Convenience method to add a message to a message box. @param box the message box to add the message to @param message the message to add @param encode true to encode the message, false otherwise.
[ "Convenience", "method", "to", "add", "a", "message", "to", "a", "message", "box", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessages.java#L398-L404
139,052
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessages.java
WMessages.getMessageContainer
protected static MessageContainer getMessageContainer(final WComponent component) { for (WComponent c = component; c != null; c = c.getParent()) { if (c instanceof MessageContainer) { return (MessageContainer) c; } } return null; }
java
protected static MessageContainer getMessageContainer(final WComponent component) { for (WComponent c = component; c != null; c = c.getParent()) { if (c instanceof MessageContainer) { return (MessageContainer) c; } } return null; }
[ "protected", "static", "MessageContainer", "getMessageContainer", "(", "final", "WComponent", "component", ")", "{", "for", "(", "WComponent", "c", "=", "component", ";", "c", "!=", "null", ";", "c", "=", "c", ".", "getParent", "(", ")", ")", "{", "if", "(", "c", "instanceof", "MessageContainer", ")", "{", "return", "(", "MessageContainer", ")", "c", ";", "}", "}", "return", "null", ";", "}" ]
Searches the WComponent tree of the given component for an ancestor that implements the MessageContainer interface. @param component the component to return the Container for @return the nearest MessageContainer if found, null otherwise
[ "Searches", "the", "WComponent", "tree", "of", "the", "given", "component", "for", "an", "ancestor", "that", "implements", "the", "MessageContainer", "interface", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessages.java#L495-L503
139,053
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.addItem
public int addItem(int appId, ItemCreate create, boolean silent) { return getResourceFactory().getApiResource("/item/app/" + appId + "/") .queryParam("silent", silent ? "1" : "0") .entity(create, MediaType.APPLICATION_JSON_TYPE) .post(ItemCreateResponse.class).getId(); }
java
public int addItem(int appId, ItemCreate create, boolean silent) { return getResourceFactory().getApiResource("/item/app/" + appId + "/") .queryParam("silent", silent ? "1" : "0") .entity(create, MediaType.APPLICATION_JSON_TYPE) .post(ItemCreateResponse.class).getId(); }
[ "public", "int", "addItem", "(", "int", "appId", ",", "ItemCreate", "create", ",", "boolean", "silent", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/app/\"", "+", "appId", "+", "\"/\"", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "create", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", "ItemCreateResponse", ".", "class", ")", ".", "getId", "(", ")", ";", "}" ]
Adds a new item to the given app. @param appId The id of the app the item should be added to @param create The data for the new item @param silent True if the create should be silten, false otherwise @return The id of the newly created item
[ "Adds", "a", "new", "item", "to", "the", "given", "app", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L45-L50
139,054
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.updateItem
public void updateItem(int itemId, ItemUpdate update, boolean silent, boolean hook) { getResourceFactory().getApiResource("/item/" + itemId) .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); }
java
public void updateItem(int itemId, ItemUpdate update, boolean silent, boolean hook) { getResourceFactory().getApiResource("/item/" + itemId) .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); }
[ "public", "void", "updateItem", "(", "int", "itemId", ",", "ItemUpdate", "update", ",", "boolean", "silent", ",", "boolean", "hook", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "queryParam", "(", "\"hook\"", ",", "hook", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "update", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Updates the entire item. Only fields which have values specified will be updated. To delete the contents of a field, pass an empty array for the value. @param itemId The id of the item to update @param update The data for the update @param silent True if the update should be silent, false otherwise @param hook True if hooks should be executed for the change, false otherwise
[ "Updates", "the", "entire", "item", ".", "Only", "fields", "which", "have", "values", "specified", "will", "be", "updated", ".", "To", "delete", "the", "contents", "of", "a", "field", "pass", "an", "empty", "array", "for", "the", "value", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L78-L83
139,055
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.updateItemValues
public void updateItemValues(int itemId, List<FieldValuesUpdate> values, boolean silent, boolean hook) { getResourceFactory().getApiResource("/item/" + itemId + "/value/") .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); }
java
public void updateItemValues(int itemId, List<FieldValuesUpdate> values, boolean silent, boolean hook) { getResourceFactory().getApiResource("/item/" + itemId + "/value/") .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); }
[ "public", "void", "updateItemValues", "(", "int", "itemId", ",", "List", "<", "FieldValuesUpdate", ">", "values", ",", "boolean", "silent", ",", "boolean", "hook", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/value/\"", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "queryParam", "(", "\"hook\"", ",", "hook", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "values", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Updates all the values for an item @param itemId The id of the item @param values The values for the fields @param silent True if the update should be silent, false otherwise @param hook True if hooks should be executed for the change, false otherwise
[ "Updates", "all", "the", "values", "for", "an", "item" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L97-L103
139,056
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.updateItemFieldValues
public void updateItemFieldValues(int itemId, int fieldId, List<Map<String, Object>> values, boolean silent, boolean hook) { getResourceFactory() .getApiResource("/item/" + itemId + "/value/" + fieldId) .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); }
java
public void updateItemFieldValues(int itemId, int fieldId, List<Map<String, Object>> values, boolean silent, boolean hook) { getResourceFactory() .getApiResource("/item/" + itemId + "/value/" + fieldId) .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); }
[ "public", "void", "updateItemFieldValues", "(", "int", "itemId", ",", "int", "fieldId", ",", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "values", ",", "boolean", "silent", ",", "boolean", "hook", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/value/\"", "+", "fieldId", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "queryParam", "(", "\"hook\"", ",", "hook", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "values", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Update the item values for a specific field. @param itemId The id of the item @param fieldId The id of the field @param values The new values for the field @param silent True if the update should be silent, false otherwise @param hook True if hooks should be executed for the change, false otherwise
[ "Update", "the", "item", "values", "for", "a", "specific", "field", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L119-L126
139,057
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemFieldValues
public List<Map<String, Object>> getItemFieldValues(int itemId, int fieldId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/value/" + fieldId).get( new GenericType<List<Map<String, Object>>>() { }); }
java
public List<Map<String, Object>> getItemFieldValues(int itemId, int fieldId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/value/" + fieldId).get( new GenericType<List<Map<String, Object>>>() { }); }
[ "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "getItemFieldValues", "(", "int", "itemId", ",", "int", "fieldId", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/value/\"", "+", "fieldId", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Returns the values for a specified field on an item @param itemId The id of the item @param fieldId The id of the field @return The values on the field on the item
[ "Returns", "the", "values", "for", "a", "specified", "field", "on", "an", "item" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L151-L156
139,058
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemValues
public List<FieldValuesView> getItemValues(int itemId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/value/").get( new GenericType<List<FieldValuesView>>() { }); }
java
public List<FieldValuesView> getItemValues(int itemId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/value/").get( new GenericType<List<FieldValuesView>>() { }); }
[ "public", "List", "<", "FieldValuesView", ">", "getItemValues", "(", "int", "itemId", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/value/\"", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "FieldValuesView", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Returns all the values for an item, with the additional data provided by the get item operation. @param itemId The id of the item @return The values on the item
[ "Returns", "all", "the", "values", "for", "an", "item", "with", "the", "additional", "data", "provided", "by", "the", "get", "item", "operation", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L166-L171
139,059
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemsByFieldAndTitle
public List<ItemMini> getItemsByFieldAndTitle(int fieldId, String text, List<Integer> notItemIds, Integer limit) { WebResource resource = getResourceFactory().getApiResource( "/item/field/" + fieldId + "/find"); if (limit != null) { resource = resource.queryParam("limit", limit.toString()); } if (notItemIds != null && notItemIds.size() > 0) { resource = resource.queryParam( "not_item_id", ToStringUtil.toString(notItemIds, ",")); } resource = resource.queryParam("text", text); return resource.get(new GenericType<List<ItemMini>>() {}); }
java
public List<ItemMini> getItemsByFieldAndTitle(int fieldId, String text, List<Integer> notItemIds, Integer limit) { WebResource resource = getResourceFactory().getApiResource( "/item/field/" + fieldId + "/find"); if (limit != null) { resource = resource.queryParam("limit", limit.toString()); } if (notItemIds != null && notItemIds.size() > 0) { resource = resource.queryParam( "not_item_id", ToStringUtil.toString(notItemIds, ",")); } resource = resource.queryParam("text", text); return resource.get(new GenericType<List<ItemMini>>() {}); }
[ "public", "List", "<", "ItemMini", ">", "getItemsByFieldAndTitle", "(", "int", "fieldId", ",", "String", "text", ",", "List", "<", "Integer", ">", "notItemIds", ",", "Integer", "limit", ")", "{", "WebResource", "resource", "=", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/field/\"", "+", "fieldId", "+", "\"/find\"", ")", ";", "if", "(", "limit", "!=", "null", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "\"limit\"", ",", "limit", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "notItemIds", "!=", "null", "&&", "notItemIds", ".", "size", "(", ")", ">", "0", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "\"not_item_id\"", ",", "ToStringUtil", ".", "toString", "(", "notItemIds", ",", "\",\"", ")", ")", ";", "}", "resource", "=", "resource", ".", "queryParam", "(", "\"text\"", ",", "text", ")", ";", "return", "resource", ".", "get", "(", "new", "GenericType", "<", "List", "<", "ItemMini", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Used to find possible items for a given application field. It searches the relevant items for the title given. @param fieldId The id of app reference field to search for @param text The text to search for in the items title @param notItemIds If supplied the items with these ids will not be returned @param limit The maximum number of results to return. Default value: 13 @return The items that were valid for the field and with text matching
[ "Used", "to", "find", "possible", "items", "for", "a", "given", "application", "field", ".", "It", "searches", "the", "relevant", "items", "for", "the", "title", "given", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L187-L203
139,060
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemReference
public List<ItemReference> getItemReference(int itemId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/reference/").get( new GenericType<List<ItemReference>>() { }); }
java
public List<ItemReference> getItemReference(int itemId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/reference/").get( new GenericType<List<ItemReference>>() { }); }
[ "public", "List", "<", "ItemReference", ">", "getItemReference", "(", "int", "itemId", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/reference/\"", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "ItemReference", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Returns the items that have a reference to the given item. The references are grouped by app. Both the apps and the items are sorted by title. @param itemId The id of the item @return The references to the given item
[ "Returns", "the", "items", "that", "have", "a", "reference", "to", "the", "given", "item", ".", "The", "references", "are", "grouped", "by", "app", ".", "Both", "the", "apps", "and", "the", "items", "are", "sorted", "by", "title", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L213-L218
139,061
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemRevision
public ItemRevision getItemRevision(int itemId, int revisionId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/revision/" + revisionId).get( ItemRevision.class); }
java
public ItemRevision getItemRevision(int itemId, int revisionId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/revision/" + revisionId).get( ItemRevision.class); }
[ "public", "ItemRevision", "getItemRevision", "(", "int", "itemId", ",", "int", "revisionId", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/revision/\"", "+", "revisionId", ")", ".", "get", "(", "ItemRevision", ".", "class", ")", ";", "}" ]
Returns the data about the specific revision on an item @param itemId The id of the item @param revisionId The running revision number, starts at 0 for the initial revision @return The revision
[ "Returns", "the", "data", "about", "the", "specific", "revision", "on", "an", "item" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L230-L234
139,062
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemRevisionDifference
public List<ItemFieldDifference> getItemRevisionDifference(int itemId, int revisionFrom, int revisionTo) { return getResourceFactory().getApiResource( "/item/" + itemId + "/revision/" + revisionFrom + "/" + revisionTo).get( new GenericType<List<ItemFieldDifference>>() { }); }
java
public List<ItemFieldDifference> getItemRevisionDifference(int itemId, int revisionFrom, int revisionTo) { return getResourceFactory().getApiResource( "/item/" + itemId + "/revision/" + revisionFrom + "/" + revisionTo).get( new GenericType<List<ItemFieldDifference>>() { }); }
[ "public", "List", "<", "ItemFieldDifference", ">", "getItemRevisionDifference", "(", "int", "itemId", ",", "int", "revisionFrom", ",", "int", "revisionTo", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/revision/\"", "+", "revisionFrom", "+", "\"/\"", "+", "revisionTo", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "ItemFieldDifference", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Returns the difference in fields values between the two revisions. @param itemId The id of the item @param revisionFrom The from revision @param revisionTo The to revision @return The difference between the two revision
[ "Returns", "the", "difference", "in", "fields", "values", "between", "the", "two", "revisions", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L247-L254
139,063
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemRevisions
public List<ItemRevision> getItemRevisions(int itemId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/revision/").get( new GenericType<List<ItemRevision>>() { }); }
java
public List<ItemRevision> getItemRevisions(int itemId) { return getResourceFactory().getApiResource( "/item/" + itemId + "/revision/").get( new GenericType<List<ItemRevision>>() { }); }
[ "public", "List", "<", "ItemRevision", ">", "getItemRevisions", "(", "int", "itemId", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/\"", "+", "itemId", "+", "\"/revision/\"", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "ItemRevision", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Returns all the revisions that have been made to an item @param itemId The id of the item @return All the revisions
[ "Returns", "all", "the", "revisions", "that", "have", "been", "made", "to", "an", "item" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L263-L268
139,064
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItems
public ItemsResponse getItems(int appId, Integer limit, Integer offset, SortBy sortBy, Boolean sortDesc, FilterByValue<?>... filters) { WebResource resource = getResourceFactory().getApiResource( "/item/app/" + appId + "/v2/"); if (limit != null) { resource = resource.queryParam("limit", limit.toString()); } if (offset != null) { resource = resource.queryParam("offset", offset.toString()); } if (sortBy != null) { resource = resource.queryParam("sort_by", sortBy.getKey()); } if (sortDesc != null) { resource = resource.queryParam("sort_desc", sortDesc ? "1" : "0"); } for (FilterByValue<?> filter : filters) { resource = resource.queryParam(filter.getBy().getKey(), filter.getFormattedValue()); } return resource.get(ItemsResponse.class); }
java
public ItemsResponse getItems(int appId, Integer limit, Integer offset, SortBy sortBy, Boolean sortDesc, FilterByValue<?>... filters) { WebResource resource = getResourceFactory().getApiResource( "/item/app/" + appId + "/v2/"); if (limit != null) { resource = resource.queryParam("limit", limit.toString()); } if (offset != null) { resource = resource.queryParam("offset", offset.toString()); } if (sortBy != null) { resource = resource.queryParam("sort_by", sortBy.getKey()); } if (sortDesc != null) { resource = resource.queryParam("sort_desc", sortDesc ? "1" : "0"); } for (FilterByValue<?> filter : filters) { resource = resource.queryParam(filter.getBy().getKey(), filter.getFormattedValue()); } return resource.get(ItemsResponse.class); }
[ "public", "ItemsResponse", "getItems", "(", "int", "appId", ",", "Integer", "limit", ",", "Integer", "offset", ",", "SortBy", "sortBy", ",", "Boolean", "sortDesc", ",", "FilterByValue", "<", "?", ">", "...", "filters", ")", "{", "WebResource", "resource", "=", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/item/app/\"", "+", "appId", "+", "\"/v2/\"", ")", ";", "if", "(", "limit", "!=", "null", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "\"limit\"", ",", "limit", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "offset", "!=", "null", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "\"offset\"", ",", "offset", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "sortBy", "!=", "null", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "\"sort_by\"", ",", "sortBy", ".", "getKey", "(", ")", ")", ";", "}", "if", "(", "sortDesc", "!=", "null", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "\"sort_desc\"", ",", "sortDesc", "?", "\"1\"", ":", "\"0\"", ")", ";", "}", "for", "(", "FilterByValue", "<", "?", ">", "filter", ":", "filters", ")", "{", "resource", "=", "resource", ".", "queryParam", "(", "filter", ".", "getBy", "(", ")", ".", "getKey", "(", ")", ",", "filter", ".", "getFormattedValue", "(", ")", ")", ";", "}", "return", "resource", ".", "get", "(", "ItemsResponse", ".", "class", ")", ";", "}" ]
Returns the items on app matching the given filters. @param appId The id of the app @param limit The maximum number of items to receive, defaults to 20 @param offset The offset from the start of the items returned, defaults to 0 @param sortBy How the items should be sorted. For the possible options, see the filter area. @param sortDesc <code>true</code> or leave out to sort descending, use <code>false</code> to sort ascending @param filters The filters to apply @return The items matching the filters
[ "Returns", "the", "items", "on", "app", "matching", "the", "given", "filters", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L294-L316
139,065
podio/podio-java
src/main/java/com/podio/item/ItemAPI.java
ItemAPI.getItemsByExternalId
public ItemsResponse getItemsByExternalId(int appId, String externalId) { return getItems(appId, null, null, null, null, new FilterByValue<String>(new ExternalIdFilterBy(), externalId)); }
java
public ItemsResponse getItemsByExternalId(int appId, String externalId) { return getItems(appId, null, null, null, null, new FilterByValue<String>(new ExternalIdFilterBy(), externalId)); }
[ "public", "ItemsResponse", "getItemsByExternalId", "(", "int", "appId", ",", "String", "externalId", ")", "{", "return", "getItems", "(", "appId", ",", "null", ",", "null", ",", "null", ",", "null", ",", "new", "FilterByValue", "<", "String", ">", "(", "new", "ExternalIdFilterBy", "(", ")", ",", "externalId", ")", ")", ";", "}" ]
Utility method to get items matching an external id @param appId The id of the app @param externalId The external id @return The items matching the app and external id
[ "Utility", "method", "to", "get", "items", "matching", "an", "external", "id" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L327-L330
139,066
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WAjaxControlRenderer.java
WAjaxControlRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WAjaxControl ajaxControl = (WAjaxControl) component; XmlStringBuilder xml = renderContext.getWriter(); WComponent trigger = ajaxControl.getTrigger() == null ? ajaxControl : ajaxControl. getTrigger(); int delay = ajaxControl.getDelay(); if (ajaxControl.getTargets() == null || ajaxControl.getTargets().isEmpty()) { return; } // Start tag xml.appendTagOpen("ui:ajaxtrigger"); xml.appendAttribute("triggerId", trigger.getId()); xml.appendOptionalAttribute("loadOnce", ajaxControl.isLoadOnce(), "true"); xml.appendOptionalAttribute("delay", delay > 0, delay); xml.appendClose(); // Targets for (AjaxTarget target : ajaxControl.getTargets()) { xml.appendTagOpen("ui:ajaxtargetid"); xml.appendAttribute("targetId", target.getId()); xml.appendEnd(); } // End tag xml.appendEndTag("ui:ajaxtrigger"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WAjaxControl ajaxControl = (WAjaxControl) component; XmlStringBuilder xml = renderContext.getWriter(); WComponent trigger = ajaxControl.getTrigger() == null ? ajaxControl : ajaxControl. getTrigger(); int delay = ajaxControl.getDelay(); if (ajaxControl.getTargets() == null || ajaxControl.getTargets().isEmpty()) { return; } // Start tag xml.appendTagOpen("ui:ajaxtrigger"); xml.appendAttribute("triggerId", trigger.getId()); xml.appendOptionalAttribute("loadOnce", ajaxControl.isLoadOnce(), "true"); xml.appendOptionalAttribute("delay", delay > 0, delay); xml.appendClose(); // Targets for (AjaxTarget target : ajaxControl.getTargets()) { xml.appendTagOpen("ui:ajaxtargetid"); xml.appendAttribute("targetId", target.getId()); xml.appendEnd(); } // End tag xml.appendEndTag("ui:ajaxtrigger"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WAjaxControl", "ajaxControl", "=", "(", "WAjaxControl", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "WComponent", "trigger", "=", "ajaxControl", ".", "getTrigger", "(", ")", "==", "null", "?", "ajaxControl", ":", "ajaxControl", ".", "getTrigger", "(", ")", ";", "int", "delay", "=", "ajaxControl", ".", "getDelay", "(", ")", ";", "if", "(", "ajaxControl", ".", "getTargets", "(", ")", "==", "null", "||", "ajaxControl", ".", "getTargets", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "// Start tag", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxtrigger\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"triggerId\"", ",", "trigger", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"loadOnce\"", ",", "ajaxControl", ".", "isLoadOnce", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"delay\"", ",", "delay", ">", "0", ",", "delay", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Targets", "for", "(", "AjaxTarget", "target", ":", "ajaxControl", ".", "getTargets", "(", ")", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxtargetid\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"targetId\"", ",", "target", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}", "// End tag", "xml", ".", "appendEndTag", "(", "\"ui:ajaxtrigger\"", ")", ";", "}" ]
Paints the given AjaxControl. @param component the AjaxControl to paint @param renderContext the RenderContext to paint to
[ "Paints", "the", "given", "AjaxControl", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WAjaxControlRenderer.java#L24-L52
139,067
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterLinkComponent.java
RepeaterLinkComponent.setNameAction
public void setNameAction(final Action action) { LinkComponent linkComponent = new LinkComponent(); linkComponent.setNameAction(action); repeater.setRepeatedComponent(linkComponent); }
java
public void setNameAction(final Action action) { LinkComponent linkComponent = new LinkComponent(); linkComponent.setNameAction(action); repeater.setRepeatedComponent(linkComponent); }
[ "public", "void", "setNameAction", "(", "final", "Action", "action", ")", "{", "LinkComponent", "linkComponent", "=", "new", "LinkComponent", "(", ")", ";", "linkComponent", ".", "setNameAction", "(", "action", ")", ";", "repeater", ".", "setRepeatedComponent", "(", "linkComponent", ")", ";", "}" ]
Sets the action to execute when the "name" link is invoked. @param action the action for the name link.
[ "Sets", "the", "action", "to", "execute", "when", "the", "name", "link", "is", "invoked", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterLinkComponent.java#L37-L41
139,068
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSingleSelectList.java
AbstractWSingleSelectList.getNewSelection
protected Object getNewSelection(final Request request) { String paramValue = request.getParameter(getId()); if (paramValue == null) { return null; } // Figure out which option has been selected. List<?> options = getOptions(); if (options == null || options.isEmpty()) { if (!isEditable()) { // User could not have made a selection. return null; } options = Collections.EMPTY_LIST; } int optionIndex = 0; for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null) { for (Object nestedOption : groupOptions) { if (paramValue.equals(optionToCode(nestedOption, optionIndex++))) { return nestedOption; } } } } else if (paramValue.equals(optionToCode(option, optionIndex++))) { return option; } } // Option not found, but if editable, user entered text if (isEditable()) { return paramValue; } // Invalid option. Ignore and use the current selection LOG.warn( "Option \"" + paramValue + "\" on the request is not a valid option. Will be ignored."); Object currentOption = getValue(); return currentOption; }
java
protected Object getNewSelection(final Request request) { String paramValue = request.getParameter(getId()); if (paramValue == null) { return null; } // Figure out which option has been selected. List<?> options = getOptions(); if (options == null || options.isEmpty()) { if (!isEditable()) { // User could not have made a selection. return null; } options = Collections.EMPTY_LIST; } int optionIndex = 0; for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null) { for (Object nestedOption : groupOptions) { if (paramValue.equals(optionToCode(nestedOption, optionIndex++))) { return nestedOption; } } } } else if (paramValue.equals(optionToCode(option, optionIndex++))) { return option; } } // Option not found, but if editable, user entered text if (isEditable()) { return paramValue; } // Invalid option. Ignore and use the current selection LOG.warn( "Option \"" + paramValue + "\" on the request is not a valid option. Will be ignored."); Object currentOption = getValue(); return currentOption; }
[ "protected", "Object", "getNewSelection", "(", "final", "Request", "request", ")", "{", "String", "paramValue", "=", "request", ".", "getParameter", "(", "getId", "(", ")", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "return", "null", ";", "}", "// Figure out which option has been selected.", "List", "<", "?", ">", "options", "=", "getOptions", "(", ")", ";", "if", "(", "options", "==", "null", "||", "options", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "!", "isEditable", "(", ")", ")", "{", "// User could not have made a selection.", "return", "null", ";", "}", "options", "=", "Collections", ".", "EMPTY_LIST", ";", "}", "int", "optionIndex", "=", "0", ";", "for", "(", "Object", "option", ":", "options", ")", "{", "if", "(", "option", "instanceof", "OptionGroup", ")", "{", "List", "<", "?", ">", "groupOptions", "=", "(", "(", "OptionGroup", ")", "option", ")", ".", "getOptions", "(", ")", ";", "if", "(", "groupOptions", "!=", "null", ")", "{", "for", "(", "Object", "nestedOption", ":", "groupOptions", ")", "{", "if", "(", "paramValue", ".", "equals", "(", "optionToCode", "(", "nestedOption", ",", "optionIndex", "++", ")", ")", ")", "{", "return", "nestedOption", ";", "}", "}", "}", "}", "else", "if", "(", "paramValue", ".", "equals", "(", "optionToCode", "(", "option", ",", "optionIndex", "++", ")", ")", ")", "{", "return", "option", ";", "}", "}", "// Option not found, but if editable, user entered text", "if", "(", "isEditable", "(", ")", ")", "{", "return", "paramValue", ";", "}", "// Invalid option. Ignore and use the current selection", "LOG", ".", "warn", "(", "\"Option \\\"\"", "+", "paramValue", "+", "\"\\\" on the request is not a valid option. Will be ignored.\"", ")", ";", "Object", "currentOption", "=", "getValue", "(", ")", ";", "return", "currentOption", ";", "}" ]
Determines which selection has been included in the given request. @param request the current request @return the selected option in the given request
[ "Determines", "which", "selection", "has", "been", "included", "in", "the", "given", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSingleSelectList.java#L250-L296
139,069
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/SerializationUtil.java
SerializationUtil.pipe
public static Object pipe(final Object in) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); os.writeObject(in); os.close(); byte[] bytes = bos.toByteArray(); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream is = new ObjectInputStream(bis); Object out = is.readObject(); return out; } catch (Exception ex) { throw new SystemException("Failed to pipe " + in, ex); } }
java
public static Object pipe(final Object in) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); os.writeObject(in); os.close(); byte[] bytes = bos.toByteArray(); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream is = new ObjectInputStream(bis); Object out = is.readObject(); return out; } catch (Exception ex) { throw new SystemException("Failed to pipe " + in, ex); } }
[ "public", "static", "Object", "pipe", "(", "final", "Object", "in", ")", "{", "try", "{", "ByteArrayOutputStream", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "os", "=", "new", "ObjectOutputStream", "(", "bos", ")", ";", "os", ".", "writeObject", "(", "in", ")", ";", "os", ".", "close", "(", ")", ";", "byte", "[", "]", "bytes", "=", "bos", ".", "toByteArray", "(", ")", ";", "ByteArrayInputStream", "bis", "=", "new", "ByteArrayInputStream", "(", "bytes", ")", ";", "ObjectInputStream", "is", "=", "new", "ObjectInputStream", "(", "bis", ")", ";", "Object", "out", "=", "is", ".", "readObject", "(", ")", ";", "return", "out", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "SystemException", "(", "\"Failed to pipe \"", "+", "in", ",", "ex", ")", ";", "}", "}" ]
Takes a copy of an input object via serialization. @param in the object to copy @return the copied object
[ "Takes", "a", "copy", "of", "an", "input", "object", "via", "serialization", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/SerializationUtil.java#L27-L42
139,070
podio/podio-java
src/main/java/com/podio/notification/NotificationAPI.java
NotificationAPI.markAsViewed
public void markAsViewed(int notificationId) { getResourceFactory() .getApiResource("/notification/" + notificationId + "/viewed") .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); }
java
public void markAsViewed(int notificationId) { getResourceFactory() .getApiResource("/notification/" + notificationId + "/viewed") .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); }
[ "public", "void", "markAsViewed", "(", "int", "notificationId", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/notification/\"", "+", "notificationId", "+", "\"/viewed\"", ")", ".", "entity", "(", "new", "Empty", "(", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", ")", ";", "}" ]
Mark the notification as viewed. This will move the notification from the inbox to the viewed archive. @param notificationId The id of the notification
[ "Mark", "the", "notification", "as", "viewed", ".", "This", "will", "move", "the", "notification", "from", "the", "inbox", "to", "the", "viewed", "archive", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/notification/NotificationAPI.java#L49-L53
139,071
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ErrorComponent.java
ErrorComponent.afterPaint
@Override protected void afterPaint(final RenderContext renderContext) { if (renderContext instanceof WebXmlRenderContext) { PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter(); writer.println(WebUtilities.encode(message)); if (error != null) { writer.println("\n<br/>\n<pre>\n"); StringWriter buf = new StringWriter(); error.printStackTrace(new PrintWriter(buf)); writer.println(WebUtilities.encode(buf.toString())); writer.println("\n</pre>"); } } }
java
@Override protected void afterPaint(final RenderContext renderContext) { if (renderContext instanceof WebXmlRenderContext) { PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter(); writer.println(WebUtilities.encode(message)); if (error != null) { writer.println("\n<br/>\n<pre>\n"); StringWriter buf = new StringWriter(); error.printStackTrace(new PrintWriter(buf)); writer.println(WebUtilities.encode(buf.toString())); writer.println("\n</pre>"); } } }
[ "@", "Override", "protected", "void", "afterPaint", "(", "final", "RenderContext", "renderContext", ")", "{", "if", "(", "renderContext", "instanceof", "WebXmlRenderContext", ")", "{", "PrintWriter", "writer", "=", "(", "(", "WebXmlRenderContext", ")", "renderContext", ")", ".", "getWriter", "(", ")", ";", "writer", ".", "println", "(", "WebUtilities", ".", "encode", "(", "message", ")", ")", ";", "if", "(", "error", "!=", "null", ")", "{", "writer", ".", "println", "(", "\"\\n<br/>\\n<pre>\\n\"", ")", ";", "StringWriter", "buf", "=", "new", "StringWriter", "(", ")", ";", "error", ".", "printStackTrace", "(", "new", "PrintWriter", "(", "buf", ")", ")", ";", "writer", ".", "println", "(", "WebUtilities", ".", "encode", "(", "buf", ".", "toString", "(", ")", ")", ")", ";", "writer", ".", "println", "(", "\"\\n</pre>\"", ")", ";", "}", "}", "}" ]
Override in order to paint the component. Real applications should not emit HTML directly. @param renderContext the renderContext to send output to.
[ "Override", "in", "order", "to", "paint", "the", "component", ".", "Real", "applications", "should", "not", "emit", "HTML", "directly", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ErrorComponent.java#L55-L71
139,072
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/WServlet.java
WServlet.serviceInt
protected void serviceInt(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { // Check for resource request boolean continueProcess = ServletUtil.checkResourceRequest(request, response); if (!continueProcess) { return; } // Create a support class to coordinate the web request. WServletHelper helper = createServletHelper(request, response); // Get the interceptors that will be used to plug in features. InterceptorComponent interceptorChain = createInterceptorChain(request); // Get the WComponent that represents the application we are serving. WComponent ui = getUI(request); ServletUtil.processRequest(helper, ui, interceptorChain); }
java
protected void serviceInt(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { // Check for resource request boolean continueProcess = ServletUtil.checkResourceRequest(request, response); if (!continueProcess) { return; } // Create a support class to coordinate the web request. WServletHelper helper = createServletHelper(request, response); // Get the interceptors that will be used to plug in features. InterceptorComponent interceptorChain = createInterceptorChain(request); // Get the WComponent that represents the application we are serving. WComponent ui = getUI(request); ServletUtil.processRequest(helper, ui, interceptorChain); }
[ "protected", "void", "serviceInt", "(", "final", "HttpServletRequest", "request", ",", "final", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "IOException", "{", "// Check for resource request", "boolean", "continueProcess", "=", "ServletUtil", ".", "checkResourceRequest", "(", "request", ",", "response", ")", ";", "if", "(", "!", "continueProcess", ")", "{", "return", ";", "}", "// Create a support class to coordinate the web request.", "WServletHelper", "helper", "=", "createServletHelper", "(", "request", ",", "response", ")", ";", "// Get the interceptors that will be used to plug in features.", "InterceptorComponent", "interceptorChain", "=", "createInterceptorChain", "(", "request", ")", ";", "// Get the WComponent that represents the application we are serving.", "WComponent", "ui", "=", "getUI", "(", "request", ")", ";", "ServletUtil", ".", "processRequest", "(", "helper", ",", "ui", ",", "interceptorChain", ")", ";", "}" ]
Service internal. This method does the real work in servicing the http request. It integrates wcomponents into a servlet environment via a servlet specific helper class. @param request the http servlet request. @param response the http servlet response. @throws IOException an IO exception @throws ServletException a servlet exception
[ "Service", "internal", ".", "This", "method", "does", "the", "real", "work", "in", "servicing", "the", "http", "request", ".", "It", "integrates", "wcomponents", "into", "a", "servlet", "environment", "via", "a", "servlet", "specific", "helper", "class", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/WServlet.java#L130-L148
139,073
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/WServlet.java
WServlet.createServletHelper
protected WServletHelper createServletHelper(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { LOG.debug("Creating a new WServletHelper instance"); WServletHelper helper = new WServletHelper(this, httpServletRequest, httpServletResponse); return helper; }
java
protected WServletHelper createServletHelper(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { LOG.debug("Creating a new WServletHelper instance"); WServletHelper helper = new WServletHelper(this, httpServletRequest, httpServletResponse); return helper; }
[ "protected", "WServletHelper", "createServletHelper", "(", "final", "HttpServletRequest", "httpServletRequest", ",", "final", "HttpServletResponse", "httpServletResponse", ")", "{", "LOG", ".", "debug", "(", "\"Creating a new WServletHelper instance\"", ")", ";", "WServletHelper", "helper", "=", "new", "WServletHelper", "(", "this", ",", "httpServletRequest", ",", "httpServletResponse", ")", ";", "return", "helper", ";", "}" ]
Create a support class to coordinate the web request. @param httpServletRequest the request being processed @param httpServletResponse the servlet response @return the servlet helper
[ "Create", "a", "support", "class", "to", "coordinate", "the", "web", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/WServlet.java#L189-L194
139,074
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPanelRenderer.java
WPanelRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WPanel panel = (WPanel) component; XmlStringBuilder xml = renderContext.getWriter(); WButton submitButton = panel.getDefaultSubmitButton(); String submitId = submitButton == null ? null : submitButton.getId(); String titleText = panel.getTitleText(); boolean renderChildren = isRenderContent(panel); xml.appendTagOpen("ui:panel"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); if (PanelMode.LAZY.equals(panel.getMode())) { xml.appendOptionalAttribute("hidden", !renderChildren, "true"); } else { xml.appendOptionalAttribute("hidden", component.isHidden(), "true"); } xml.appendOptionalAttribute("buttonId", submitId); xml.appendOptionalAttribute("title", titleText); xml.appendOptionalAttribute("accessKey", Util.upperCase(panel.getAccessKeyAsString())); xml.appendOptionalAttribute("type", getPanelType(panel)); xml.appendOptionalAttribute("mode", getPanelMode(panel)); xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(panel, renderContext); if (renderChildren) { renderChildren(panel, renderContext); } else { // Content will be loaded via AJAX xml.append("<ui:content/>"); } xml.appendEndTag("ui:panel"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WPanel panel = (WPanel) component; XmlStringBuilder xml = renderContext.getWriter(); WButton submitButton = panel.getDefaultSubmitButton(); String submitId = submitButton == null ? null : submitButton.getId(); String titleText = panel.getTitleText(); boolean renderChildren = isRenderContent(panel); xml.appendTagOpen("ui:panel"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); if (PanelMode.LAZY.equals(panel.getMode())) { xml.appendOptionalAttribute("hidden", !renderChildren, "true"); } else { xml.appendOptionalAttribute("hidden", component.isHidden(), "true"); } xml.appendOptionalAttribute("buttonId", submitId); xml.appendOptionalAttribute("title", titleText); xml.appendOptionalAttribute("accessKey", Util.upperCase(panel.getAccessKeyAsString())); xml.appendOptionalAttribute("type", getPanelType(panel)); xml.appendOptionalAttribute("mode", getPanelMode(panel)); xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(panel, renderContext); if (renderChildren) { renderChildren(panel, renderContext); } else { // Content will be loaded via AJAX xml.append("<ui:content/>"); } xml.appendEndTag("ui:panel"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WPanel", "panel", "=", "(", "WPanel", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "WButton", "submitButton", "=", "panel", ".", "getDefaultSubmitButton", "(", ")", ";", "String", "submitId", "=", "submitButton", "==", "null", "?", "null", ":", "submitButton", ".", "getId", "(", ")", ";", "String", "titleText", "=", "panel", ".", "getTitleText", "(", ")", ";", "boolean", "renderChildren", "=", "isRenderContent", "(", "panel", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:panel\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "PanelMode", ".", "LAZY", ".", "equals", "(", "panel", ".", "getMode", "(", ")", ")", ")", "{", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "!", "renderChildren", ",", "\"true\"", ")", ";", "}", "else", "{", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "component", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"buttonId\"", ",", "submitId", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"title\"", ",", "titleText", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessKey\"", ",", "Util", ".", "upperCase", "(", "panel", ".", "getAccessKeyAsString", "(", ")", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "getPanelType", "(", "panel", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"mode\"", ",", "getPanelMode", "(", "panel", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Render margin", "MarginRendererUtil", ".", "renderMargin", "(", "panel", ",", "renderContext", ")", ";", "if", "(", "renderChildren", ")", "{", "renderChildren", "(", "panel", ",", "renderContext", ")", ";", "}", "else", "{", "// Content will be loaded via AJAX", "xml", ".", "append", "(", "\"<ui:content/>\"", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:panel\"", ")", ";", "}" ]
Paints the given container. @param component the container to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "container", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPanelRenderer.java#L28-L66
139,075
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WSubordinateControl subordinate = (WSubordinateControl) component; XmlStringBuilder xml = renderContext.getWriter(); if (!subordinate.getRules().isEmpty()) { int seq = 0; for (Rule rule : subordinate.getRules()) { xml.appendTagOpen("ui:subordinate"); xml.appendAttribute("id", subordinate.getId() + "-c" + seq++); xml.appendClose(); paintRule(rule, xml); xml.appendEndTag("ui:subordinate"); } } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WSubordinateControl subordinate = (WSubordinateControl) component; XmlStringBuilder xml = renderContext.getWriter(); if (!subordinate.getRules().isEmpty()) { int seq = 0; for (Rule rule : subordinate.getRules()) { xml.appendTagOpen("ui:subordinate"); xml.appendAttribute("id", subordinate.getId() + "-c" + seq++); xml.appendClose(); paintRule(rule, xml); xml.appendEndTag("ui:subordinate"); } } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WSubordinateControl", "subordinate", "=", "(", "WSubordinateControl", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "if", "(", "!", "subordinate", ".", "getRules", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "int", "seq", "=", "0", ";", "for", "(", "Rule", "rule", ":", "subordinate", ".", "getRules", "(", ")", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:subordinate\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "subordinate", ".", "getId", "(", ")", "+", "\"-c\"", "+", "seq", "++", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "paintRule", "(", "rule", ",", "xml", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:subordinate\"", ")", ";", "}", "}", "}" ]
Paints the given SubordinateControl. @param component the SubordinateControl to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "SubordinateControl", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L35-L51
139,076
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.paintRule
private void paintRule(final Rule rule, final XmlStringBuilder xml) { if (rule.getCondition() == null) { throw new SystemException("Rule cannot be painted as it has no condition"); } paintCondition(rule.getCondition(), xml); for (Action action : rule.getOnTrue()) { paintAction(action, "ui:onTrue", xml); } for (Action action : rule.getOnFalse()) { paintAction(action, "ui:onFalse", xml); } }
java
private void paintRule(final Rule rule, final XmlStringBuilder xml) { if (rule.getCondition() == null) { throw new SystemException("Rule cannot be painted as it has no condition"); } paintCondition(rule.getCondition(), xml); for (Action action : rule.getOnTrue()) { paintAction(action, "ui:onTrue", xml); } for (Action action : rule.getOnFalse()) { paintAction(action, "ui:onFalse", xml); } }
[ "private", "void", "paintRule", "(", "final", "Rule", "rule", ",", "final", "XmlStringBuilder", "xml", ")", "{", "if", "(", "rule", ".", "getCondition", "(", ")", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"Rule cannot be painted as it has no condition\"", ")", ";", "}", "paintCondition", "(", "rule", ".", "getCondition", "(", ")", ",", "xml", ")", ";", "for", "(", "Action", "action", ":", "rule", ".", "getOnTrue", "(", ")", ")", "{", "paintAction", "(", "action", ",", "\"ui:onTrue\"", ",", "xml", ")", ";", "}", "for", "(", "Action", "action", ":", "rule", ".", "getOnFalse", "(", ")", ")", "{", "paintAction", "(", "action", ",", "\"ui:onFalse\"", ",", "xml", ")", ";", "}", "}" ]
Paints a single rule. @param rule the rule to paint. @param xml the writer to send the output to
[ "Paints", "a", "single", "rule", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L59-L73
139,077
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.paintCondition
private void paintCondition(final Condition condition, final XmlStringBuilder xml) { if (condition instanceof And) { xml.appendTag("ui:and"); for (Condition operand : ((And) condition).getConditions()) { paintCondition(operand, xml); } xml.appendEndTag("ui:and"); } else if (condition instanceof Or) { xml.appendTag("ui:or"); for (Condition operand : ((Or) condition).getConditions()) { paintCondition(operand, xml); } xml.appendEndTag("ui:or"); } else if (condition instanceof Not) { xml.appendTag("ui:not"); paintCondition(((Not) condition).getCondition(), xml); xml.appendEndTag("ui:not"); } else if (condition instanceof AbstractCompare) { AbstractCompare compare = (AbstractCompare) condition; xml.appendTagOpen("ui:condition"); xml.appendAttribute("controller", compare.getTrigger().getId()); xml.appendAttribute("value", compare.getComparePaintValue()); xml.appendOptionalAttribute("operator", getCompareTypeName(compare.getCompareType())); xml.appendEnd(); } else { throw new SystemException("Unknown condition: " + condition); } }
java
private void paintCondition(final Condition condition, final XmlStringBuilder xml) { if (condition instanceof And) { xml.appendTag("ui:and"); for (Condition operand : ((And) condition).getConditions()) { paintCondition(operand, xml); } xml.appendEndTag("ui:and"); } else if (condition instanceof Or) { xml.appendTag("ui:or"); for (Condition operand : ((Or) condition).getConditions()) { paintCondition(operand, xml); } xml.appendEndTag("ui:or"); } else if (condition instanceof Not) { xml.appendTag("ui:not"); paintCondition(((Not) condition).getCondition(), xml); xml.appendEndTag("ui:not"); } else if (condition instanceof AbstractCompare) { AbstractCompare compare = (AbstractCompare) condition; xml.appendTagOpen("ui:condition"); xml.appendAttribute("controller", compare.getTrigger().getId()); xml.appendAttribute("value", compare.getComparePaintValue()); xml.appendOptionalAttribute("operator", getCompareTypeName(compare.getCompareType())); xml.appendEnd(); } else { throw new SystemException("Unknown condition: " + condition); } }
[ "private", "void", "paintCondition", "(", "final", "Condition", "condition", ",", "final", "XmlStringBuilder", "xml", ")", "{", "if", "(", "condition", "instanceof", "And", ")", "{", "xml", ".", "appendTag", "(", "\"ui:and\"", ")", ";", "for", "(", "Condition", "operand", ":", "(", "(", "And", ")", "condition", ")", ".", "getConditions", "(", ")", ")", "{", "paintCondition", "(", "operand", ",", "xml", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:and\"", ")", ";", "}", "else", "if", "(", "condition", "instanceof", "Or", ")", "{", "xml", ".", "appendTag", "(", "\"ui:or\"", ")", ";", "for", "(", "Condition", "operand", ":", "(", "(", "Or", ")", "condition", ")", ".", "getConditions", "(", ")", ")", "{", "paintCondition", "(", "operand", ",", "xml", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:or\"", ")", ";", "}", "else", "if", "(", "condition", "instanceof", "Not", ")", "{", "xml", ".", "appendTag", "(", "\"ui:not\"", ")", ";", "paintCondition", "(", "(", "(", "Not", ")", "condition", ")", ".", "getCondition", "(", ")", ",", "xml", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:not\"", ")", ";", "}", "else", "if", "(", "condition", "instanceof", "AbstractCompare", ")", "{", "AbstractCompare", "compare", "=", "(", "AbstractCompare", ")", "condition", ";", "xml", ".", "appendTagOpen", "(", "\"ui:condition\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"controller\"", ",", "compare", ".", "getTrigger", "(", ")", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"value\"", ",", "compare", ".", "getComparePaintValue", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"operator\"", ",", "getCompareTypeName", "(", "compare", ".", "getCompareType", "(", ")", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}", "else", "{", "throw", "new", "SystemException", "(", "\"Unknown condition: \"", "+", "condition", ")", ";", "}", "}" ]
Paints a condition. @param condition the condition to paint. @param xml the writer to send the output to
[ "Paints", "a", "condition", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L81-L112
139,078
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.paintAction
private void paintAction(final Action action, final String elementName, final XmlStringBuilder xml) { switch (action.getActionType()) { case SHOW: case HIDE: case ENABLE: case DISABLE: case OPTIONAL: case MANDATORY: paintStandardAction(action, elementName, xml); break; case SHOWIN: case HIDEIN: case ENABLEIN: case DISABLEIN: paintInGroupAction(action, elementName, xml); break; default: break; } }
java
private void paintAction(final Action action, final String elementName, final XmlStringBuilder xml) { switch (action.getActionType()) { case SHOW: case HIDE: case ENABLE: case DISABLE: case OPTIONAL: case MANDATORY: paintStandardAction(action, elementName, xml); break; case SHOWIN: case HIDEIN: case ENABLEIN: case DISABLEIN: paintInGroupAction(action, elementName, xml); break; default: break; } }
[ "private", "void", "paintAction", "(", "final", "Action", "action", ",", "final", "String", "elementName", ",", "final", "XmlStringBuilder", "xml", ")", "{", "switch", "(", "action", ".", "getActionType", "(", ")", ")", "{", "case", "SHOW", ":", "case", "HIDE", ":", "case", "ENABLE", ":", "case", "DISABLE", ":", "case", "OPTIONAL", ":", "case", "MANDATORY", ":", "paintStandardAction", "(", "action", ",", "elementName", ",", "xml", ")", ";", "break", ";", "case", "SHOWIN", ":", "case", "HIDEIN", ":", "case", "ENABLEIN", ":", "case", "DISABLEIN", ":", "paintInGroupAction", "(", "action", ",", "elementName", ",", "xml", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}" ]
Paints an action. @param action the action to paint @param elementName the enclosing element name ("ui:onFalse" or "ui:onTrue"). @param xml the writer to send the output to
[ "Paints", "an", "action", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L121-L143
139,079
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.paintStandardAction
private void paintStandardAction(final Action action, final String elementName, final XmlStringBuilder xml) { xml.appendTagOpen(elementName); xml.appendAttribute("action", getActionTypeName(action.getActionType())); xml.appendClose(); xml.appendTagOpen("ui:target"); SubordinateTarget target = action.getTarget(); if (target instanceof WComponentGroup<?>) { xml.appendAttribute("groupId", target.getId()); } else { xml.appendAttribute("id", target.getId()); } xml.appendEnd(); xml.appendEndTag(elementName); }
java
private void paintStandardAction(final Action action, final String elementName, final XmlStringBuilder xml) { xml.appendTagOpen(elementName); xml.appendAttribute("action", getActionTypeName(action.getActionType())); xml.appendClose(); xml.appendTagOpen("ui:target"); SubordinateTarget target = action.getTarget(); if (target instanceof WComponentGroup<?>) { xml.appendAttribute("groupId", target.getId()); } else { xml.appendAttribute("id", target.getId()); } xml.appendEnd(); xml.appendEndTag(elementName); }
[ "private", "void", "paintStandardAction", "(", "final", "Action", "action", ",", "final", "String", "elementName", ",", "final", "XmlStringBuilder", "xml", ")", "{", "xml", ".", "appendTagOpen", "(", "elementName", ")", ";", "xml", ".", "appendAttribute", "(", "\"action\"", ",", "getActionTypeName", "(", "action", ".", "getActionType", "(", ")", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:target\"", ")", ";", "SubordinateTarget", "target", "=", "action", ".", "getTarget", "(", ")", ";", "if", "(", "target", "instanceof", "WComponentGroup", "<", "?", ">", ")", "{", "xml", ".", "appendAttribute", "(", "\"groupId\"", ",", "target", ".", "getId", "(", ")", ")", ";", "}", "else", "{", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "target", ".", "getId", "(", ")", ")", ";", "}", "xml", ".", "appendEnd", "(", ")", ";", "xml", ".", "appendEndTag", "(", "elementName", ")", ";", "}" ]
Paint a standard action - where a single item or single group is targeted. @param action the action to paint @param elementName the enclosing element name ("ui:onFalse" or "ui:onTrue"). @param xml the output response
[ "Paint", "a", "standard", "action", "-", "where", "a", "single", "item", "or", "single", "group", "is", "targeted", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L152-L168
139,080
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.paintInGroupAction
private void paintInGroupAction(final Action action, final String elementName, final XmlStringBuilder xml) { xml.appendTagOpen(elementName); xml.appendAttribute("action", getActionTypeName(action.getActionType())); xml.appendClose(); xml.appendTagOpen("ui:target"); xml.appendAttribute("groupId", action.getTarget().getId()); xml.appendAttribute("id", ((AbstractAction) action).getTargetInGroup().getId()); xml.appendEnd(); xml.appendEndTag(elementName); }
java
private void paintInGroupAction(final Action action, final String elementName, final XmlStringBuilder xml) { xml.appendTagOpen(elementName); xml.appendAttribute("action", getActionTypeName(action.getActionType())); xml.appendClose(); xml.appendTagOpen("ui:target"); xml.appendAttribute("groupId", action.getTarget().getId()); xml.appendAttribute("id", ((AbstractAction) action).getTargetInGroup().getId()); xml.appendEnd(); xml.appendEndTag(elementName); }
[ "private", "void", "paintInGroupAction", "(", "final", "Action", "action", ",", "final", "String", "elementName", ",", "final", "XmlStringBuilder", "xml", ")", "{", "xml", ".", "appendTagOpen", "(", "elementName", ")", ";", "xml", ".", "appendAttribute", "(", "\"action\"", ",", "getActionTypeName", "(", "action", ".", "getActionType", "(", ")", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:target\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"groupId\"", ",", "action", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "(", "(", "AbstractAction", ")", "action", ")", ".", "getTargetInGroup", "(", ")", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "xml", ".", "appendEndTag", "(", "elementName", ")", ";", "}" ]
Paint an inGroup action - where a single item is being targeted out of a group of items. @param action the action to paint @param elementName the enclosing element name ("ui:onFalse" or "ui:onTrue"). @param xml the output response
[ "Paint", "an", "inGroup", "action", "-", "where", "a", "single", "item", "is", "being", "targeted", "out", "of", "a", "group", "of", "items", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L177-L187
139,081
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.getCompareTypeName
private String getCompareTypeName(final CompareType type) { String compare = null; switch (type) { case EQUAL: break; case NOT_EQUAL: compare = "ne"; break; case LESS_THAN: compare = "lt"; break; case LESS_THAN_OR_EQUAL: compare = "le"; break; case GREATER_THAN: compare = "gt"; break; case GREATER_THAN_OR_EQUAL: compare = "ge"; break; case MATCH: compare = "rx"; break; default: throw new SystemException("Invalid compare type: " + type); } return compare; }
java
private String getCompareTypeName(final CompareType type) { String compare = null; switch (type) { case EQUAL: break; case NOT_EQUAL: compare = "ne"; break; case LESS_THAN: compare = "lt"; break; case LESS_THAN_OR_EQUAL: compare = "le"; break; case GREATER_THAN: compare = "gt"; break; case GREATER_THAN_OR_EQUAL: compare = "ge"; break; case MATCH: compare = "rx"; break; default: throw new SystemException("Invalid compare type: " + type); } return compare; }
[ "private", "String", "getCompareTypeName", "(", "final", "CompareType", "type", ")", "{", "String", "compare", "=", "null", ";", "switch", "(", "type", ")", "{", "case", "EQUAL", ":", "break", ";", "case", "NOT_EQUAL", ":", "compare", "=", "\"ne\"", ";", "break", ";", "case", "LESS_THAN", ":", "compare", "=", "\"lt\"", ";", "break", ";", "case", "LESS_THAN_OR_EQUAL", ":", "compare", "=", "\"le\"", ";", "break", ";", "case", "GREATER_THAN", ":", "compare", "=", "\"gt\"", ";", "break", ";", "case", "GREATER_THAN_OR_EQUAL", ":", "compare", "=", "\"ge\"", ";", "break", ";", "case", "MATCH", ":", "compare", "=", "\"rx\"", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Invalid compare type: \"", "+", "type", ")", ";", "}", "return", "compare", ";", "}" ]
Helper method to determine the compare type name. @param type the enumerated CompareType @return the name of the CompareType
[ "Helper", "method", "to", "determine", "the", "compare", "type", "name", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L195-L224
139,082
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
WSubordinateControlRenderer.getActionTypeName
private String getActionTypeName(final ActionType type) { String action = null; switch (type) { case SHOW: action = "show"; break; case SHOWIN: action = "showIn"; break; case HIDE: action = "hide"; break; case HIDEIN: action = "hideIn"; break; case ENABLE: action = "enable"; break; case ENABLEIN: action = "enableIn"; break; case DISABLE: action = "disable"; break; case DISABLEIN: action = "disableIn"; break; case OPTIONAL: action = "optional"; break; case MANDATORY: action = "mandatory"; break; default: break; } return action; }
java
private String getActionTypeName(final ActionType type) { String action = null; switch (type) { case SHOW: action = "show"; break; case SHOWIN: action = "showIn"; break; case HIDE: action = "hide"; break; case HIDEIN: action = "hideIn"; break; case ENABLE: action = "enable"; break; case ENABLEIN: action = "enableIn"; break; case DISABLE: action = "disable"; break; case DISABLEIN: action = "disableIn"; break; case OPTIONAL: action = "optional"; break; case MANDATORY: action = "mandatory"; break; default: break; } return action; }
[ "private", "String", "getActionTypeName", "(", "final", "ActionType", "type", ")", "{", "String", "action", "=", "null", ";", "switch", "(", "type", ")", "{", "case", "SHOW", ":", "action", "=", "\"show\"", ";", "break", ";", "case", "SHOWIN", ":", "action", "=", "\"showIn\"", ";", "break", ";", "case", "HIDE", ":", "action", "=", "\"hide\"", ";", "break", ";", "case", "HIDEIN", ":", "action", "=", "\"hideIn\"", ";", "break", ";", "case", "ENABLE", ":", "action", "=", "\"enable\"", ";", "break", ";", "case", "ENABLEIN", ":", "action", "=", "\"enableIn\"", ";", "break", ";", "case", "DISABLE", ":", "action", "=", "\"disable\"", ";", "break", ";", "case", "DISABLEIN", ":", "action", "=", "\"disableIn\"", ";", "break", ";", "case", "OPTIONAL", ":", "action", "=", "\"optional\"", ";", "break", ";", "case", "MANDATORY", ":", "action", "=", "\"mandatory\"", ";", "break", ";", "default", ":", "break", ";", "}", "return", "action", ";", "}" ]
Helper method to determine the action name. @param type the enumerated ActionType @return the name of the action
[ "Helper", "method", "to", "determine", "the", "action", "name", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L232-L271
139,083
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java
ExampleSection.buildUI
private void buildUI() { add(messages); add(tabset); // add(new AccessibilityWarningContainer()); container.add(new WText("Select an example from the menu")); // Set a static ID on container and it becomes a de-facto naming context. container.setIdName("eg"); tabset.addTab(container, "(no selection)", WTabSet.TAB_MODE_CLIENT); WImage srcImage = new WImage(new ImageResource("/image/text-x-source.png", "View Source")); srcImage.setCacheKey("srcTabImage"); tabset.addTab(source, new WDecoratedLabel(srcImage), WTabSet.TAB_MODE_LAZY).setToolTip("View Source"); // The refresh current view button. WButton refreshButton = new WButton("\u200b"); refreshButton.setToolTip("Refresh"); refreshButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-refresh")); //refreshButton.setImage("/image/refresh-w.png"); refreshButton.setRenderAsLink(true); refreshButton.setAction(new ValidatingAction(messages.getValidationErrors(), refreshButton) { @Override public void executeOnValid(final ActionEvent event) { // Do Nothing } }); // The reset example button. final WButton resetButton = new WButton("\u200b"); resetButton.setToolTip("Reset"); resetButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-times-circle")); //resetButton.setImage("/image/cancel-w.png"); resetButton.setRenderAsLink(true); resetButton.setAction(new ValidatingAction(messages.getValidationErrors(), resetButton) { @Override public void executeOnValid(final ActionEvent event) { resetExample(); } }); addToTail(refreshButton); addToTail(new WText("\u2002")); addToTail(resetButton); }
java
private void buildUI() { add(messages); add(tabset); // add(new AccessibilityWarningContainer()); container.add(new WText("Select an example from the menu")); // Set a static ID on container and it becomes a de-facto naming context. container.setIdName("eg"); tabset.addTab(container, "(no selection)", WTabSet.TAB_MODE_CLIENT); WImage srcImage = new WImage(new ImageResource("/image/text-x-source.png", "View Source")); srcImage.setCacheKey("srcTabImage"); tabset.addTab(source, new WDecoratedLabel(srcImage), WTabSet.TAB_MODE_LAZY).setToolTip("View Source"); // The refresh current view button. WButton refreshButton = new WButton("\u200b"); refreshButton.setToolTip("Refresh"); refreshButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-refresh")); //refreshButton.setImage("/image/refresh-w.png"); refreshButton.setRenderAsLink(true); refreshButton.setAction(new ValidatingAction(messages.getValidationErrors(), refreshButton) { @Override public void executeOnValid(final ActionEvent event) { // Do Nothing } }); // The reset example button. final WButton resetButton = new WButton("\u200b"); resetButton.setToolTip("Reset"); resetButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-times-circle")); //resetButton.setImage("/image/cancel-w.png"); resetButton.setRenderAsLink(true); resetButton.setAction(new ValidatingAction(messages.getValidationErrors(), resetButton) { @Override public void executeOnValid(final ActionEvent event) { resetExample(); } }); addToTail(refreshButton); addToTail(new WText("\u2002")); addToTail(resetButton); }
[ "private", "void", "buildUI", "(", ")", "{", "add", "(", "messages", ")", ";", "add", "(", "tabset", ")", ";", "// add(new AccessibilityWarningContainer());", "container", ".", "add", "(", "new", "WText", "(", "\"Select an example from the menu\"", ")", ")", ";", "// Set a static ID on container and it becomes a de-facto naming context.", "container", ".", "setIdName", "(", "\"eg\"", ")", ";", "tabset", ".", "addTab", "(", "container", ",", "\"(no selection)\"", ",", "WTabSet", ".", "TAB_MODE_CLIENT", ")", ";", "WImage", "srcImage", "=", "new", "WImage", "(", "new", "ImageResource", "(", "\"/image/text-x-source.png\"", ",", "\"View Source\"", ")", ")", ";", "srcImage", ".", "setCacheKey", "(", "\"srcTabImage\"", ")", ";", "tabset", ".", "addTab", "(", "source", ",", "new", "WDecoratedLabel", "(", "srcImage", ")", ",", "WTabSet", ".", "TAB_MODE_LAZY", ")", ".", "setToolTip", "(", "\"View Source\"", ")", ";", "// The refresh current view button.", "WButton", "refreshButton", "=", "new", "WButton", "(", "\"\\u200b\"", ")", ";", "refreshButton", ".", "setToolTip", "(", "\"Refresh\"", ")", ";", "refreshButton", ".", "setHtmlClass", "(", "HtmlIconUtil", ".", "getIconClasses", "(", "\"fa-refresh\"", ")", ")", ";", "//refreshButton.setImage(\"/image/refresh-w.png\");", "refreshButton", ".", "setRenderAsLink", "(", "true", ")", ";", "refreshButton", ".", "setAction", "(", "new", "ValidatingAction", "(", "messages", ".", "getValidationErrors", "(", ")", ",", "refreshButton", ")", "{", "@", "Override", "public", "void", "executeOnValid", "(", "final", "ActionEvent", "event", ")", "{", "// Do Nothing", "}", "}", ")", ";", "// The reset example button.", "final", "WButton", "resetButton", "=", "new", "WButton", "(", "\"\\u200b\"", ")", ";", "resetButton", ".", "setToolTip", "(", "\"Reset\"", ")", ";", "resetButton", ".", "setHtmlClass", "(", "HtmlIconUtil", ".", "getIconClasses", "(", "\"fa-times-circle\"", ")", ")", ";", "//resetButton.setImage(\"/image/cancel-w.png\");", "resetButton", ".", "setRenderAsLink", "(", "true", ")", ";", "resetButton", ".", "setAction", "(", "new", "ValidatingAction", "(", "messages", ".", "getValidationErrors", "(", ")", ",", "resetButton", ")", "{", "@", "Override", "public", "void", "executeOnValid", "(", "final", "ActionEvent", "event", ")", "{", "resetExample", "(", ")", ";", "}", "}", ")", ";", "addToTail", "(", "refreshButton", ")", ";", "addToTail", "(", "new", "WText", "(", "\"\\u2002\"", ")", ")", ";", "addToTail", "(", "resetButton", ")", ";", "}" ]
Add the controls to the section in the right order.
[ "Add", "the", "controls", "to", "the", "section", "in", "the", "right", "order", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java#L77-L120
139,084
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java
ExampleSection.addToTail
private void addToTail(final WComponent component) { WContainer tail = (WContainer) getDecoratedLabel().getTail(); if (null != tail) { // bloody well better not be... tail.add(component); } }
java
private void addToTail(final WComponent component) { WContainer tail = (WContainer) getDecoratedLabel().getTail(); if (null != tail) { // bloody well better not be... tail.add(component); } }
[ "private", "void", "addToTail", "(", "final", "WComponent", "component", ")", "{", "WContainer", "tail", "=", "(", "WContainer", ")", "getDecoratedLabel", "(", ")", ".", "getTail", "(", ")", ";", "if", "(", "null", "!=", "tail", ")", "{", "// bloody well better not be...", "tail", ".", "add", "(", "component", ")", ";", "}", "}" ]
Add a component to the WDecoratedLabel's tail container. @param component The component to add.
[ "Add", "a", "component", "to", "the", "WDecoratedLabel", "s", "tail", "container", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java#L136-L141
139,085
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java
ExampleSection.selectExample
public void selectExample(final WComponent example, final String exampleName) { WComponent currentExample = container.getChildAt(0).getParent(); if (currentExample != null && currentExample.getClass().equals(example.getClass())) { // Same example selected, do nothing return; } resetExample(); container.removeAll(); this.getDecoratedLabel().setBody(new WText(exampleName)); WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this); if (app != null) { app.setTitle(exampleName); } if (example instanceof ErrorComponent) { tabset.getTab(0).setText("Error"); source.setSource(null); } else { String className = example.getClass().getName(); WDefinitionList list = new WDefinitionList(WDefinitionList.Type.COLUMN); container.add(list); list.addTerm("Example path", new WText(className.replaceAll("\\.", " / "))); list.addTerm("Example JavaDoc", new JavaDocText(getSource(className))); container.add(new WHorizontalRule()); tabset.getTab(0).setText(example.getClass().getSimpleName()); source.setSource(getSource(className)); } container.add(example); example.setLocked(true); }
java
public void selectExample(final WComponent example, final String exampleName) { WComponent currentExample = container.getChildAt(0).getParent(); if (currentExample != null && currentExample.getClass().equals(example.getClass())) { // Same example selected, do nothing return; } resetExample(); container.removeAll(); this.getDecoratedLabel().setBody(new WText(exampleName)); WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this); if (app != null) { app.setTitle(exampleName); } if (example instanceof ErrorComponent) { tabset.getTab(0).setText("Error"); source.setSource(null); } else { String className = example.getClass().getName(); WDefinitionList list = new WDefinitionList(WDefinitionList.Type.COLUMN); container.add(list); list.addTerm("Example path", new WText(className.replaceAll("\\.", " / "))); list.addTerm("Example JavaDoc", new JavaDocText(getSource(className))); container.add(new WHorizontalRule()); tabset.getTab(0).setText(example.getClass().getSimpleName()); source.setSource(getSource(className)); } container.add(example); example.setLocked(true); }
[ "public", "void", "selectExample", "(", "final", "WComponent", "example", ",", "final", "String", "exampleName", ")", "{", "WComponent", "currentExample", "=", "container", ".", "getChildAt", "(", "0", ")", ".", "getParent", "(", ")", ";", "if", "(", "currentExample", "!=", "null", "&&", "currentExample", ".", "getClass", "(", ")", ".", "equals", "(", "example", ".", "getClass", "(", ")", ")", ")", "{", "// Same example selected, do nothing", "return", ";", "}", "resetExample", "(", ")", ";", "container", ".", "removeAll", "(", ")", ";", "this", ".", "getDecoratedLabel", "(", ")", ".", "setBody", "(", "new", "WText", "(", "exampleName", ")", ")", ";", "WApplication", "app", "=", "WebUtilities", ".", "getAncestorOfClass", "(", "WApplication", ".", "class", ",", "this", ")", ";", "if", "(", "app", "!=", "null", ")", "{", "app", ".", "setTitle", "(", "exampleName", ")", ";", "}", "if", "(", "example", "instanceof", "ErrorComponent", ")", "{", "tabset", ".", "getTab", "(", "0", ")", ".", "setText", "(", "\"Error\"", ")", ";", "source", ".", "setSource", "(", "null", ")", ";", "}", "else", "{", "String", "className", "=", "example", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "WDefinitionList", "list", "=", "new", "WDefinitionList", "(", "WDefinitionList", ".", "Type", ".", "COLUMN", ")", ";", "container", ".", "add", "(", "list", ")", ";", "list", ".", "addTerm", "(", "\"Example path\"", ",", "new", "WText", "(", "className", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\" / \"", ")", ")", ")", ";", "list", ".", "addTerm", "(", "\"Example JavaDoc\"", ",", "new", "JavaDocText", "(", "getSource", "(", "className", ")", ")", ")", ";", "container", ".", "add", "(", "new", "WHorizontalRule", "(", ")", ")", ";", "tabset", ".", "getTab", "(", "0", ")", ".", "setText", "(", "example", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "source", ".", "setSource", "(", "getSource", "(", "className", ")", ")", ";", "}", "container", ".", "add", "(", "example", ")", ";", "example", ".", "setLocked", "(", "true", ")", ";", "}" ]
Selects an example. @param example the example to select. @param exampleName the name of the example being selected.
[ "Selects", "an", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java#L149-L183
139,086
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java
ExampleSection.selectExample
public void selectExample(final ExampleData example) { try { StringBuilder exampleName = new StringBuilder(); if (example.getExampleGroupName() != null && !example.getExampleGroupName().equals("")) { exampleName.append(example.getExampleGroupName()).append(" - "); } exampleName.append(example.getExampleName()); selectExample(example.getExampleClass().newInstance(), exampleName.toString()); } catch (Exception e) { WMessages.getInstance(this).error("Error selecting example \"" + example. getExampleName() + '"'); selectExample(new ErrorComponent(e.getMessage(), e), "Error"); } }
java
public void selectExample(final ExampleData example) { try { StringBuilder exampleName = new StringBuilder(); if (example.getExampleGroupName() != null && !example.getExampleGroupName().equals("")) { exampleName.append(example.getExampleGroupName()).append(" - "); } exampleName.append(example.getExampleName()); selectExample(example.getExampleClass().newInstance(), exampleName.toString()); } catch (Exception e) { WMessages.getInstance(this).error("Error selecting example \"" + example. getExampleName() + '"'); selectExample(new ErrorComponent(e.getMessage(), e), "Error"); } }
[ "public", "void", "selectExample", "(", "final", "ExampleData", "example", ")", "{", "try", "{", "StringBuilder", "exampleName", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "example", ".", "getExampleGroupName", "(", ")", "!=", "null", "&&", "!", "example", ".", "getExampleGroupName", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "exampleName", ".", "append", "(", "example", ".", "getExampleGroupName", "(", ")", ")", ".", "append", "(", "\" - \"", ")", ";", "}", "exampleName", ".", "append", "(", "example", ".", "getExampleName", "(", ")", ")", ";", "selectExample", "(", "example", ".", "getExampleClass", "(", ")", ".", "newInstance", "(", ")", ",", "exampleName", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "WMessages", ".", "getInstance", "(", "this", ")", ".", "error", "(", "\"Error selecting example \\\"\"", "+", "example", ".", "getExampleName", "(", ")", "+", "'", "'", ")", ";", "selectExample", "(", "new", "ErrorComponent", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ",", "\"Error\"", ")", ";", "}", "}" ]
Selects an example. If there is an error instantiating the component, an error message will be displayed. @param example the ExampleData of the example to select.
[ "Selects", "an", "example", ".", "If", "there", "is", "an", "error", "instantiating", "the", "component", "an", "error", "message", "will", "be", "displayed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java#L190-L203
139,087
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java
ExampleSection.getSource
private static String getSource(final String className) { String sourceName = '/' + className.replace('.', '/') + ".java"; InputStream stream = null; try { stream = ExampleSection.class.getResourceAsStream(sourceName); if (stream != null) { byte[] sourceBytes = StreamUtil.getBytes(stream); // we need to do some basic formatting of the source now. return new String(sourceBytes, "UTF-8"); } } catch (IOException e) { LOG.warn("Unable to read source code for class " + className, e); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { LOG.error("Error closing stream", e); } } } return null; }
java
private static String getSource(final String className) { String sourceName = '/' + className.replace('.', '/') + ".java"; InputStream stream = null; try { stream = ExampleSection.class.getResourceAsStream(sourceName); if (stream != null) { byte[] sourceBytes = StreamUtil.getBytes(stream); // we need to do some basic formatting of the source now. return new String(sourceBytes, "UTF-8"); } } catch (IOException e) { LOG.warn("Unable to read source code for class " + className, e); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { LOG.error("Error closing stream", e); } } } return null; }
[ "private", "static", "String", "getSource", "(", "final", "String", "className", ")", "{", "String", "sourceName", "=", "'", "'", "+", "className", ".", "replace", "(", "'", "'", ",", "'", "'", ")", "+", "\".java\"", ";", "InputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "ExampleSection", ".", "class", ".", "getResourceAsStream", "(", "sourceName", ")", ";", "if", "(", "stream", "!=", "null", ")", "{", "byte", "[", "]", "sourceBytes", "=", "StreamUtil", ".", "getBytes", "(", "stream", ")", ";", "// we need to do some basic formatting of the source now.", "return", "new", "String", "(", "sourceBytes", ",", "\"UTF-8\"", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Unable to read source code for class \"", "+", "className", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "stream", "!=", "null", ")", "{", "try", "{", "stream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOG", ".", "error", "(", "\"Error closing stream\"", ",", "e", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Tries to obtain the source file for the given class. @param className the name of the class to find the source for. @return the source file for the given class, or null on error.
[ "Tries", "to", "obtain", "the", "source", "file", "for", "the", "given", "class", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java#L218-L245
139,088
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.optionToCode
protected String optionToCode(final Object option, final int index) { if (index < 0) { List<?> options = getOptions(); if (options == null || options.isEmpty()) { Integrity.issue(this, "No options available, so cannot convert the option \"" + option + "\" to a code."); } else { StringBuffer message = new StringBuffer(); message.append("The option \"").append(option).append( "\" is not one of the available options."); Object firstOption = SelectListUtil.getFirstOption(options); if (firstOption != null && option != null && firstOption.getClass() != option. getClass()) { message.append(" The options in this list component are of type \""); message.append(firstOption.getClass().getName()) .append("\", the selection you supplied is of type \""); message.append(option.getClass().getName()).append("\"."); } Integrity.issue(this, message.toString()); } return null; } else if (option instanceof Option) { Option opt = (Option) option; return opt.getCode() == null ? "" : opt.getCode(); } else { String code = APPLICATION_LOOKUP_TABLE.getCode(getLookupTable(), option); if (code == null) { return String.valueOf(index + 1); } else { return code; } } }
java
protected String optionToCode(final Object option, final int index) { if (index < 0) { List<?> options = getOptions(); if (options == null || options.isEmpty()) { Integrity.issue(this, "No options available, so cannot convert the option \"" + option + "\" to a code."); } else { StringBuffer message = new StringBuffer(); message.append("The option \"").append(option).append( "\" is not one of the available options."); Object firstOption = SelectListUtil.getFirstOption(options); if (firstOption != null && option != null && firstOption.getClass() != option. getClass()) { message.append(" The options in this list component are of type \""); message.append(firstOption.getClass().getName()) .append("\", the selection you supplied is of type \""); message.append(option.getClass().getName()).append("\"."); } Integrity.issue(this, message.toString()); } return null; } else if (option instanceof Option) { Option opt = (Option) option; return opt.getCode() == null ? "" : opt.getCode(); } else { String code = APPLICATION_LOOKUP_TABLE.getCode(getLookupTable(), option); if (code == null) { return String.valueOf(index + 1); } else { return code; } } }
[ "protected", "String", "optionToCode", "(", "final", "Object", "option", ",", "final", "int", "index", ")", "{", "if", "(", "index", "<", "0", ")", "{", "List", "<", "?", ">", "options", "=", "getOptions", "(", ")", ";", "if", "(", "options", "==", "null", "||", "options", ".", "isEmpty", "(", ")", ")", "{", "Integrity", ".", "issue", "(", "this", ",", "\"No options available, so cannot convert the option \\\"\"", "+", "option", "+", "\"\\\" to a code.\"", ")", ";", "}", "else", "{", "StringBuffer", "message", "=", "new", "StringBuffer", "(", ")", ";", "message", ".", "append", "(", "\"The option \\\"\"", ")", ".", "append", "(", "option", ")", ".", "append", "(", "\"\\\" is not one of the available options.\"", ")", ";", "Object", "firstOption", "=", "SelectListUtil", ".", "getFirstOption", "(", "options", ")", ";", "if", "(", "firstOption", "!=", "null", "&&", "option", "!=", "null", "&&", "firstOption", ".", "getClass", "(", ")", "!=", "option", ".", "getClass", "(", ")", ")", "{", "message", ".", "append", "(", "\" The options in this list component are of type \\\"\"", ")", ";", "message", ".", "append", "(", "firstOption", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ".", "append", "(", "\"\\\", the selection you supplied is of type \\\"\"", ")", ";", "message", ".", "append", "(", "option", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ".", "append", "(", "\"\\\".\"", ")", ";", "}", "Integrity", ".", "issue", "(", "this", ",", "message", ".", "toString", "(", ")", ")", ";", "}", "return", "null", ";", "}", "else", "if", "(", "option", "instanceof", "Option", ")", "{", "Option", "opt", "=", "(", "Option", ")", "option", ";", "return", "opt", ".", "getCode", "(", ")", "==", "null", "?", "\"\"", ":", "opt", ".", "getCode", "(", ")", ";", "}", "else", "{", "String", "code", "=", "APPLICATION_LOOKUP_TABLE", ".", "getCode", "(", "getLookupTable", "(", ")", ",", "option", ")", ";", "if", "(", "code", "==", "null", ")", "{", "return", "String", ".", "valueOf", "(", "index", "+", "1", ")", ";", "}", "else", "{", "return", "code", ";", "}", "}", "}" ]
Retrieves the code for the given option. Will return null if there is no matching option. @param option the option @param index the index of the option in the list. @return the code for the given option, or null if there is no matching option.
[ "Retrieves", "the", "code", "for", "the", "given", "option", ".", "Will", "return", "null", "if", "there", "is", "no", "matching", "option", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L126-L163
139,089
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.getOptionIndex
protected int getOptionIndex(final Object option) { int optionCount = 0; List<?> options = getOptions(); if (options != null) { for (Object obj : getOptions()) { if (obj instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) obj).getOptions(); int groupIndex = groupOptions.indexOf(option); if (groupIndex != -1) { return optionCount + groupIndex; } optionCount += groupOptions.size(); } else if (Util.equals(option, obj)) { return optionCount; } else { optionCount++; } } } return -1; }
java
protected int getOptionIndex(final Object option) { int optionCount = 0; List<?> options = getOptions(); if (options != null) { for (Object obj : getOptions()) { if (obj instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) obj).getOptions(); int groupIndex = groupOptions.indexOf(option); if (groupIndex != -1) { return optionCount + groupIndex; } optionCount += groupOptions.size(); } else if (Util.equals(option, obj)) { return optionCount; } else { optionCount++; } } } return -1; }
[ "protected", "int", "getOptionIndex", "(", "final", "Object", "option", ")", "{", "int", "optionCount", "=", "0", ";", "List", "<", "?", ">", "options", "=", "getOptions", "(", ")", ";", "if", "(", "options", "!=", "null", ")", "{", "for", "(", "Object", "obj", ":", "getOptions", "(", ")", ")", "{", "if", "(", "obj", "instanceof", "OptionGroup", ")", "{", "List", "<", "?", ">", "groupOptions", "=", "(", "(", "OptionGroup", ")", "obj", ")", ".", "getOptions", "(", ")", ";", "int", "groupIndex", "=", "groupOptions", ".", "indexOf", "(", "option", ")", ";", "if", "(", "groupIndex", "!=", "-", "1", ")", "{", "return", "optionCount", "+", "groupIndex", ";", "}", "optionCount", "+=", "groupOptions", ".", "size", "(", ")", ";", "}", "else", "if", "(", "Util", ".", "equals", "(", "option", ",", "obj", ")", ")", "{", "return", "optionCount", ";", "}", "else", "{", "optionCount", "++", ";", "}", "}", "}", "return", "-", "1", ";", "}" ]
Retrieves the index of the given option. The index is not necessarily the index of the option in the options list, as there may be options nested in OptionGroups. @param option the option @return the index of the given option, or -1 if there is no matching option.
[ "Retrieves", "the", "index", "of", "the", "given", "option", ".", "The", "index", "is", "not", "necessarily", "the", "index", "of", "the", "option", "in", "the", "options", "list", "as", "there", "may", "be", "options", "nested", "in", "OptionGroups", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L172-L197
139,090
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.getListCacheKey
public String getListCacheKey() { Object table = getLookupTable(); if (table != null && ConfigurationProperties.getDatalistCaching()) { String key = APPLICATION_LOOKUP_TABLE.getCacheKeyForTable(table); return key; } return null; }
java
public String getListCacheKey() { Object table = getLookupTable(); if (table != null && ConfigurationProperties.getDatalistCaching()) { String key = APPLICATION_LOOKUP_TABLE.getCacheKeyForTable(table); return key; } return null; }
[ "public", "String", "getListCacheKey", "(", ")", "{", "Object", "table", "=", "getLookupTable", "(", ")", ";", "if", "(", "table", "!=", "null", "&&", "ConfigurationProperties", ".", "getDatalistCaching", "(", ")", ")", "{", "String", "key", "=", "APPLICATION_LOOKUP_TABLE", ".", "getCacheKeyForTable", "(", "table", ")", ";", "return", "key", ";", "}", "return", "null", ";", "}" ]
Retrieves the data list cache key for this component. @return the cache key if client-side caching is enabled, null otherwise.
[ "Retrieves", "the", "data", "list", "cache", "key", "for", "this", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L204-L213
139,091
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.getOptions
public List<?> getOptions() { if (getLookupTable() == null) { SelectionModel model = getComponentModel(); return model.getOptions(); } else { return APPLICATION_LOOKUP_TABLE.getTable(getLookupTable()); } }
java
public List<?> getOptions() { if (getLookupTable() == null) { SelectionModel model = getComponentModel(); return model.getOptions(); } else { return APPLICATION_LOOKUP_TABLE.getTable(getLookupTable()); } }
[ "public", "List", "<", "?", ">", "getOptions", "(", ")", "{", "if", "(", "getLookupTable", "(", ")", "==", "null", ")", "{", "SelectionModel", "model", "=", "getComponentModel", "(", ")", ";", "return", "model", ".", "getOptions", "(", ")", ";", "}", "else", "{", "return", "APPLICATION_LOOKUP_TABLE", ".", "getTable", "(", "getLookupTable", "(", ")", ")", ";", "}", "}" ]
Returns the complete list of options available for selection for this user's session. @return the list of options available for the given user's session.
[ "Returns", "the", "complete", "list", "of", "options", "available", "for", "selection", "for", "this", "user", "s", "session", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L234-L241
139,092
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.setOptions
public void setOptions(final Object[] aArray) { setOptions(aArray == null ? null : Arrays.asList(aArray)); }
java
public void setOptions(final Object[] aArray) { setOptions(aArray == null ? null : Arrays.asList(aArray)); }
[ "public", "void", "setOptions", "(", "final", "Object", "[", "]", "aArray", ")", "{", "setOptions", "(", "aArray", "==", "null", "?", "null", ":", "Arrays", ".", "asList", "(", "aArray", ")", ")", ";", "}" ]
Set the complete list of options available for selection for this users session. @param aArray the list of options available to the user.
[ "Set", "the", "complete", "list", "of", "options", "available", "for", "selection", "for", "this", "users", "session", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L258-L260
139,093
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); if (isAjax() && UIContextHolder.getCurrent().getUI() != null) { AjaxTarget target = getAjaxTarget(); AjaxHelper.registerComponent(target.getId(), getId()); } String cacheKey = getListCacheKey(); if (cacheKey != null) { LookupTableHelper.registerList(cacheKey, request); } }
java
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); if (isAjax() && UIContextHolder.getCurrent().getUI() != null) { AjaxTarget target = getAjaxTarget(); AjaxHelper.registerComponent(target.getId(), getId()); } String cacheKey = getListCacheKey(); if (cacheKey != null) { LookupTableHelper.registerList(cacheKey, request); } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "if", "(", "isAjax", "(", ")", "&&", "UIContextHolder", ".", "getCurrent", "(", ")", ".", "getUI", "(", ")", "!=", "null", ")", "{", "AjaxTarget", "target", "=", "getAjaxTarget", "(", ")", ";", "AjaxHelper", ".", "registerComponent", "(", "target", ".", "getId", "(", ")", ",", "getId", "(", ")", ")", ";", "}", "String", "cacheKey", "=", "getListCacheKey", "(", ")", ";", "if", "(", "cacheKey", "!=", "null", ")", "{", "LookupTableHelper", ".", "registerList", "(", "cacheKey", ",", "request", ")", ";", "}", "}" ]
Override preparePaintComponent to register an AJAX operation if this list is AJAX enabled. @param request the request being responded to.
[ "Override", "preparePaintComponent", "to", "register", "an", "AJAX", "operation", "if", "this", "list", "is", "AJAX", "enabled", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L372-L386
139,094
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java
AbstractWSelectList.getDesc
public String getDesc(final Object option, final int index) { String desc = ""; if (option instanceof Option) { String optDesc = ((Option) option).getDesc(); if (optDesc != null) { desc = optDesc; } } else { String tableDesc = APPLICATION_LOOKUP_TABLE.getDescription(getLookupTable(), option); if (tableDesc != null) { desc = tableDesc; } else if (option != null) { desc = option.toString(); } } return I18nUtilities.format(null, desc); }
java
public String getDesc(final Object option, final int index) { String desc = ""; if (option instanceof Option) { String optDesc = ((Option) option).getDesc(); if (optDesc != null) { desc = optDesc; } } else { String tableDesc = APPLICATION_LOOKUP_TABLE.getDescription(getLookupTable(), option); if (tableDesc != null) { desc = tableDesc; } else if (option != null) { desc = option.toString(); } } return I18nUtilities.format(null, desc); }
[ "public", "String", "getDesc", "(", "final", "Object", "option", ",", "final", "int", "index", ")", "{", "String", "desc", "=", "\"\"", ";", "if", "(", "option", "instanceof", "Option", ")", "{", "String", "optDesc", "=", "(", "(", "Option", ")", "option", ")", ".", "getDesc", "(", ")", ";", "if", "(", "optDesc", "!=", "null", ")", "{", "desc", "=", "optDesc", ";", "}", "}", "else", "{", "String", "tableDesc", "=", "APPLICATION_LOOKUP_TABLE", ".", "getDescription", "(", "getLookupTable", "(", ")", ",", "option", ")", ";", "if", "(", "tableDesc", "!=", "null", ")", "{", "desc", "=", "tableDesc", ";", "}", "else", "if", "(", "option", "!=", "null", ")", "{", "desc", "=", "option", ".", "toString", "(", ")", ";", "}", "}", "return", "I18nUtilities", ".", "format", "(", "null", ",", "desc", ")", ";", "}" ]
Retrieves the description for the given option. Intended for use by Renderers. @param option the option to retrieve the description for. @param index the option index. @return the description for the given option.
[ "Retrieves", "the", "description", "for", "the", "given", "option", ".", "Intended", "for", "use", "by", "Renderers", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWSelectList.java#L432-L452
139,095
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSingleSelectRenderer.java
WSingleSelectRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WSingleSelect listBox = (WSingleSelect) component; XmlStringBuilder xml = renderContext.getWriter(); String dataKey = listBox.getListCacheKey(); boolean readOnly = listBox.isReadOnly(); int rows = listBox.getRows(); xml.appendTagOpen("ui:listbox"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", listBox.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { xml.appendOptionalAttribute("data", dataKey != null, dataKey); xml.appendOptionalAttribute("disabled", listBox.isDisabled(), "true"); xml.appendOptionalAttribute("required", listBox.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", listBox.isSubmitOnChange(), "true"); xml.appendOptionalAttribute("toolTip", component.getToolTip()); xml.appendOptionalAttribute("accessibleText", component.getAccessibleText()); xml.appendOptionalAttribute("rows", rows >= 2, rows); String autocomplete = listBox.getAutocomplete(); xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete); } xml.appendAttribute("single", "true"); xml.appendClose(); // Options List<?> options = listBox.getOptions(); boolean renderSelectionsOnly = readOnly || dataKey != null; if (options != null) { int optionIndex = 0; Object selectedOption = listBox.getSelected(); for (Object option : options) { if (option instanceof OptionGroup) { xml.appendTagOpen("ui:optgroup"); xml.appendAttribute("label", ((OptionGroup) option).getDesc()); xml.appendClose(); for (Object nestedOption : ((OptionGroup) option).getOptions()) { renderOption(listBox, nestedOption, optionIndex++, xml, selectedOption, renderSelectionsOnly); } xml.appendEndTag("ui:optgroup"); } else { renderOption(listBox, option, optionIndex++, xml, selectedOption, renderSelectionsOnly); } } } if (!readOnly) { DiagnosticRenderUtil.renderDiagnostics(listBox, renderContext); } xml.appendEndTag("ui:listbox"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WSingleSelect listBox = (WSingleSelect) component; XmlStringBuilder xml = renderContext.getWriter(); String dataKey = listBox.getListCacheKey(); boolean readOnly = listBox.isReadOnly(); int rows = listBox.getRows(); xml.appendTagOpen("ui:listbox"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", listBox.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { xml.appendOptionalAttribute("data", dataKey != null, dataKey); xml.appendOptionalAttribute("disabled", listBox.isDisabled(), "true"); xml.appendOptionalAttribute("required", listBox.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", listBox.isSubmitOnChange(), "true"); xml.appendOptionalAttribute("toolTip", component.getToolTip()); xml.appendOptionalAttribute("accessibleText", component.getAccessibleText()); xml.appendOptionalAttribute("rows", rows >= 2, rows); String autocomplete = listBox.getAutocomplete(); xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete); } xml.appendAttribute("single", "true"); xml.appendClose(); // Options List<?> options = listBox.getOptions(); boolean renderSelectionsOnly = readOnly || dataKey != null; if (options != null) { int optionIndex = 0; Object selectedOption = listBox.getSelected(); for (Object option : options) { if (option instanceof OptionGroup) { xml.appendTagOpen("ui:optgroup"); xml.appendAttribute("label", ((OptionGroup) option).getDesc()); xml.appendClose(); for (Object nestedOption : ((OptionGroup) option).getOptions()) { renderOption(listBox, nestedOption, optionIndex++, xml, selectedOption, renderSelectionsOnly); } xml.appendEndTag("ui:optgroup"); } else { renderOption(listBox, option, optionIndex++, xml, selectedOption, renderSelectionsOnly); } } } if (!readOnly) { DiagnosticRenderUtil.renderDiagnostics(listBox, renderContext); } xml.appendEndTag("ui:listbox"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WSingleSelect", "listBox", "=", "(", "WSingleSelect", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "String", "dataKey", "=", "listBox", ".", "getListCacheKey", "(", ")", ";", "boolean", "readOnly", "=", "listBox", ".", "isReadOnly", "(", ")", ";", "int", "rows", "=", "listBox", ".", "getRows", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:listbox\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "listBox", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "readOnly", ")", "{", "xml", ".", "appendAttribute", "(", "\"readOnly\"", ",", "\"true\"", ")", ";", "}", "else", "{", "xml", ".", "appendOptionalAttribute", "(", "\"data\"", ",", "dataKey", "!=", "null", ",", "dataKey", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "listBox", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"required\"", ",", "listBox", ".", "isMandatory", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"submitOnChange\"", ",", "listBox", ".", "isSubmitOnChange", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "component", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessibleText\"", ",", "component", ".", "getAccessibleText", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"rows\"", ",", "rows", ">=", "2", ",", "rows", ")", ";", "String", "autocomplete", "=", "listBox", ".", "getAutocomplete", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"autocomplete\"", ",", "!", "Util", ".", "empty", "(", "autocomplete", ")", ",", "autocomplete", ")", ";", "}", "xml", ".", "appendAttribute", "(", "\"single\"", ",", "\"true\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Options", "List", "<", "?", ">", "options", "=", "listBox", ".", "getOptions", "(", ")", ";", "boolean", "renderSelectionsOnly", "=", "readOnly", "||", "dataKey", "!=", "null", ";", "if", "(", "options", "!=", "null", ")", "{", "int", "optionIndex", "=", "0", ";", "Object", "selectedOption", "=", "listBox", ".", "getSelected", "(", ")", ";", "for", "(", "Object", "option", ":", "options", ")", "{", "if", "(", "option", "instanceof", "OptionGroup", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:optgroup\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"label\"", ",", "(", "(", "OptionGroup", ")", "option", ")", ".", "getDesc", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "for", "(", "Object", "nestedOption", ":", "(", "(", "OptionGroup", ")", "option", ")", ".", "getOptions", "(", ")", ")", "{", "renderOption", "(", "listBox", ",", "nestedOption", ",", "optionIndex", "++", ",", "xml", ",", "selectedOption", ",", "renderSelectionsOnly", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:optgroup\"", ")", ";", "}", "else", "{", "renderOption", "(", "listBox", ",", "option", ",", "optionIndex", "++", ",", "xml", ",", "selectedOption", ",", "renderSelectionsOnly", ")", ";", "}", "}", "}", "if", "(", "!", "readOnly", ")", "{", "DiagnosticRenderUtil", ".", "renderDiagnostics", "(", "listBox", ",", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:listbox\"", ")", ";", "}" ]
Paints the given WSingleSelect. @param component the WSingleSelect to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WSingleSelect", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSingleSelectRenderer.java#L25-L84
139,096
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.initialiseInstanceVariables
private void initialiseInstanceVariables() { backing = new HashMap<>(); booleanBacking = new HashSet<>(); locations = new HashMap<>(); // subContextCache is updated on the fly so ensure no concurrent modification. subcontextCache = Collections.synchronizedMap(new HashMap()); runtimeProperties = new IncludeProperties("Runtime: added at runtime"); }
java
private void initialiseInstanceVariables() { backing = new HashMap<>(); booleanBacking = new HashSet<>(); locations = new HashMap<>(); // subContextCache is updated on the fly so ensure no concurrent modification. subcontextCache = Collections.synchronizedMap(new HashMap()); runtimeProperties = new IncludeProperties("Runtime: added at runtime"); }
[ "private", "void", "initialiseInstanceVariables", "(", ")", "{", "backing", "=", "new", "HashMap", "<>", "(", ")", ";", "booleanBacking", "=", "new", "HashSet", "<>", "(", ")", ";", "locations", "=", "new", "HashMap", "<>", "(", ")", ";", "// subContextCache is updated on the fly so ensure no concurrent modification.", "subcontextCache", "=", "Collections", ".", "synchronizedMap", "(", "new", "HashMap", "(", ")", ")", ";", "runtimeProperties", "=", "new", "IncludeProperties", "(", "\"Runtime: added at runtime\"", ")", ";", "}" ]
This method initialises most of the instance variables.
[ "This", "method", "initialises", "most", "of", "the", "instance", "variables", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L230-L238
139,097
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.load
@SuppressWarnings("checkstyle:emptyblock") private void load() { recordMessage("Loading parameters"); File cwd = new File("."); String workingDir; try { workingDir = cwd.getCanonicalPath(); } catch (IOException ex) { workingDir = "UNKNOWN"; } recordMessage("Working directory is " + workingDir); for (String resourceName : PARAMETER_LOAD_ORDER) { loadTop(resourceName); } if (getBoolean(USE_SYSTEM_PROPERTIES)) { recordMessage("Loading from system properties"); load(System.getProperties(), "System Properties", true); } // Now perform variable substitution. do { // Do nothing while loop } while (substitute()); if (getBoolean(DUMP)) { // Can't use logging infrastructure here, so dump to console log(getDebuggingInfo()); log(getMessages()); } // We don't want the StringBuffer hanging around after 'DUMP'. clearMessages(); // Now move any parameters with the system parameters prefix into the real system parameters. Properties systemProperties = getSubProperties(SYSTEM_PARAMETERS_PREFIX, true); System.getProperties().putAll(systemProperties); }
java
@SuppressWarnings("checkstyle:emptyblock") private void load() { recordMessage("Loading parameters"); File cwd = new File("."); String workingDir; try { workingDir = cwd.getCanonicalPath(); } catch (IOException ex) { workingDir = "UNKNOWN"; } recordMessage("Working directory is " + workingDir); for (String resourceName : PARAMETER_LOAD_ORDER) { loadTop(resourceName); } if (getBoolean(USE_SYSTEM_PROPERTIES)) { recordMessage("Loading from system properties"); load(System.getProperties(), "System Properties", true); } // Now perform variable substitution. do { // Do nothing while loop } while (substitute()); if (getBoolean(DUMP)) { // Can't use logging infrastructure here, so dump to console log(getDebuggingInfo()); log(getMessages()); } // We don't want the StringBuffer hanging around after 'DUMP'. clearMessages(); // Now move any parameters with the system parameters prefix into the real system parameters. Properties systemProperties = getSubProperties(SYSTEM_PARAMETERS_PREFIX, true); System.getProperties().putAll(systemProperties); }
[ "@", "SuppressWarnings", "(", "\"checkstyle:emptyblock\"", ")", "private", "void", "load", "(", ")", "{", "recordMessage", "(", "\"Loading parameters\"", ")", ";", "File", "cwd", "=", "new", "File", "(", "\".\"", ")", ";", "String", "workingDir", ";", "try", "{", "workingDir", "=", "cwd", ".", "getCanonicalPath", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "workingDir", "=", "\"UNKNOWN\"", ";", "}", "recordMessage", "(", "\"Working directory is \"", "+", "workingDir", ")", ";", "for", "(", "String", "resourceName", ":", "PARAMETER_LOAD_ORDER", ")", "{", "loadTop", "(", "resourceName", ")", ";", "}", "if", "(", "getBoolean", "(", "USE_SYSTEM_PROPERTIES", ")", ")", "{", "recordMessage", "(", "\"Loading from system properties\"", ")", ";", "load", "(", "System", ".", "getProperties", "(", ")", ",", "\"System Properties\"", ",", "true", ")", ";", "}", "// Now perform variable substitution.", "do", "{", "// Do nothing while loop", "}", "while", "(", "substitute", "(", ")", ")", ";", "if", "(", "getBoolean", "(", "DUMP", ")", ")", "{", "// Can't use logging infrastructure here, so dump to console", "log", "(", "getDebuggingInfo", "(", ")", ")", ";", "log", "(", "getMessages", "(", ")", ")", ";", "}", "// We don't want the StringBuffer hanging around after 'DUMP'.", "clearMessages", "(", ")", ";", "// Now move any parameters with the system parameters prefix into the real system parameters.", "Properties", "systemProperties", "=", "getSubProperties", "(", "SYSTEM_PARAMETERS_PREFIX", ",", "true", ")", ";", "System", ".", "getProperties", "(", ")", ".", "putAll", "(", "systemProperties", ")", ";", "}" ]
Load the backing from the properties file visible to our classloader, plus the filesystem.
[ "Load", "the", "backing", "from", "the", "properties", "file", "visible", "to", "our", "classloader", "plus", "the", "filesystem", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L243-L283
139,098
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.loadTop
@SuppressWarnings("checkstyle:emptyblock") private void loadTop(final String resourceName) { try { resources.push(resourceName); load(resourceName); // Now check for INCLUDE_AFTER resources String includes = get(INCLUDE_AFTER); if (includes != null) { // First, do substitution on the INCLUDE_AFTER do { } while (substitute(INCLUDE_AFTER)); // Now split and process String[] includeAfter = getString(INCLUDE_AFTER).split(","); backing.remove(INCLUDE_AFTER); for (String after : includeAfter) { loadTop(after); } } } finally { resources.pop(); } }
java
@SuppressWarnings("checkstyle:emptyblock") private void loadTop(final String resourceName) { try { resources.push(resourceName); load(resourceName); // Now check for INCLUDE_AFTER resources String includes = get(INCLUDE_AFTER); if (includes != null) { // First, do substitution on the INCLUDE_AFTER do { } while (substitute(INCLUDE_AFTER)); // Now split and process String[] includeAfter = getString(INCLUDE_AFTER).split(","); backing.remove(INCLUDE_AFTER); for (String after : includeAfter) { loadTop(after); } } } finally { resources.pop(); } }
[ "@", "SuppressWarnings", "(", "\"checkstyle:emptyblock\"", ")", "private", "void", "loadTop", "(", "final", "String", "resourceName", ")", "{", "try", "{", "resources", ".", "push", "(", "resourceName", ")", ";", "load", "(", "resourceName", ")", ";", "// Now check for INCLUDE_AFTER resources", "String", "includes", "=", "get", "(", "INCLUDE_AFTER", ")", ";", "if", "(", "includes", "!=", "null", ")", "{", "// First, do substitution on the INCLUDE_AFTER", "do", "{", "}", "while", "(", "substitute", "(", "INCLUDE_AFTER", ")", ")", ";", "// Now split and process", "String", "[", "]", "includeAfter", "=", "getString", "(", "INCLUDE_AFTER", ")", ".", "split", "(", "\",\"", ")", ";", "backing", ".", "remove", "(", "INCLUDE_AFTER", ")", ";", "for", "(", "String", "after", ":", "includeAfter", ")", "{", "loadTop", "(", "after", ")", ";", "}", "}", "}", "finally", "{", "resources", ".", "pop", "(", ")", ";", "}", "}" ]
Loading of "top level" resources is different to the general recursive case, since it is only at the top level that we check for the includeAfter parameter. @param resourceName the path of the resource to load from.
[ "Loading", "of", "top", "level", "resources", "is", "different", "to", "the", "general", "recursive", "case", "since", "it", "is", "only", "at", "the", "top", "level", "that", "we", "check", "for", "the", "includeAfter", "parameter", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L341-L366
139,099
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.load
private void load(final String resourceName) { boolean found = false; try { resources.push(resourceName); // Try classloader - load the resources in reverse order of the enumeration. Since later-loaded resources // override earlier-loaded ones, this better corresponds to the usual classpath behaviour. ClassLoader classloader = getParamsClassLoader(); List<URL> urls = new ArrayList<>(); for (Enumeration<URL> res = classloader.getResources(resourceName); res. hasMoreElements();) { urls.add(res.nextElement()); } recordMessage("Resource " + resourceName + " was found " + urls.size() + " times"); // Sometimes the same URL will crop up several times (because of redundant entries in classpaths). Also, // sometimes the same file appears under several URLS (because it's packaged into a jar and also a classes // directory, perhaps). In these circumstances we really only want to load the resource once - we load the // first one and then ignore later ones. Map<String, String> loadedFiles = new HashMap<>(); // Build up a list of the byte arrays from the files that we then process. List<byte[]> contentsList = new ArrayList<>(); List<URL> urlList = new ArrayList<>(); // This processes from the front-of-classpath to end-of-classpath since end-of-classpath ones appear last in // the enumeration for (int i = 0; i < urls.size(); i++) { URL url = urls.get(i); found = true; // Load the contents of the resource, for comparison with existing resources. InputStream urlContentStream = url.openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamUtil.copy(urlContentStream, baos); urlContentStream.close(); byte[] urlContentBytes = baos.toByteArray(); String urlContent = new String(urlContentBytes, "UTF-8"); // Check if we have already loaded this file. if (loadedFiles.keySet().contains(urlContent)) { recordMessage("Skipped url " + url + " - duplicate of " + loadedFiles.get(urlContent)); continue; } loadedFiles.put(urlContent, url.toString()); contentsList.add(urlContentBytes); urlList.add(url); } for (int i = contentsList.size() - 1; i >= 0; i--) { byte[] buff = contentsList.get(i); URL url = urlList.get(i); recordMessage("Loading from url " + url + "..."); ByteArrayInputStream in = new ByteArrayInputStream(buff); // Use the "IncludeProperties" to load properties into us one at a time.... IncludeProperties properties = new IncludeProperties(url.toString()); properties.load(in); } File file = new File(resourceName); // Don't reload the file in the working directory if we are in the home directory. if (file.exists()) { recordMessage("Loading from file " + filename(file) + "..."); found = true; // Use the "IncludeProperties" to load properties into us, one at a time.... IncludeProperties properties = new IncludeProperties("file:" + filename(file)); properties.load(new BufferedInputStream(new FileInputStream(file))); } if (!found) { recordMessage("Did not find resource " + resourceName); } } catch (IOException ex) { // This is bad. recordException(ex); } catch (IllegalArgumentException ex) { // Most likely a "Malformed uxxxx encoding." error, which is // usually caused by a developer forgetting to escape backslashes recordException(ex); } finally { resources.pop(); } }
java
private void load(final String resourceName) { boolean found = false; try { resources.push(resourceName); // Try classloader - load the resources in reverse order of the enumeration. Since later-loaded resources // override earlier-loaded ones, this better corresponds to the usual classpath behaviour. ClassLoader classloader = getParamsClassLoader(); List<URL> urls = new ArrayList<>(); for (Enumeration<URL> res = classloader.getResources(resourceName); res. hasMoreElements();) { urls.add(res.nextElement()); } recordMessage("Resource " + resourceName + " was found " + urls.size() + " times"); // Sometimes the same URL will crop up several times (because of redundant entries in classpaths). Also, // sometimes the same file appears under several URLS (because it's packaged into a jar and also a classes // directory, perhaps). In these circumstances we really only want to load the resource once - we load the // first one and then ignore later ones. Map<String, String> loadedFiles = new HashMap<>(); // Build up a list of the byte arrays from the files that we then process. List<byte[]> contentsList = new ArrayList<>(); List<URL> urlList = new ArrayList<>(); // This processes from the front-of-classpath to end-of-classpath since end-of-classpath ones appear last in // the enumeration for (int i = 0; i < urls.size(); i++) { URL url = urls.get(i); found = true; // Load the contents of the resource, for comparison with existing resources. InputStream urlContentStream = url.openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamUtil.copy(urlContentStream, baos); urlContentStream.close(); byte[] urlContentBytes = baos.toByteArray(); String urlContent = new String(urlContentBytes, "UTF-8"); // Check if we have already loaded this file. if (loadedFiles.keySet().contains(urlContent)) { recordMessage("Skipped url " + url + " - duplicate of " + loadedFiles.get(urlContent)); continue; } loadedFiles.put(urlContent, url.toString()); contentsList.add(urlContentBytes); urlList.add(url); } for (int i = contentsList.size() - 1; i >= 0; i--) { byte[] buff = contentsList.get(i); URL url = urlList.get(i); recordMessage("Loading from url " + url + "..."); ByteArrayInputStream in = new ByteArrayInputStream(buff); // Use the "IncludeProperties" to load properties into us one at a time.... IncludeProperties properties = new IncludeProperties(url.toString()); properties.load(in); } File file = new File(resourceName); // Don't reload the file in the working directory if we are in the home directory. if (file.exists()) { recordMessage("Loading from file " + filename(file) + "..."); found = true; // Use the "IncludeProperties" to load properties into us, one at a time.... IncludeProperties properties = new IncludeProperties("file:" + filename(file)); properties.load(new BufferedInputStream(new FileInputStream(file))); } if (!found) { recordMessage("Did not find resource " + resourceName); } } catch (IOException ex) { // This is bad. recordException(ex); } catch (IllegalArgumentException ex) { // Most likely a "Malformed uxxxx encoding." error, which is // usually caused by a developer forgetting to escape backslashes recordException(ex); } finally { resources.pop(); } }
[ "private", "void", "load", "(", "final", "String", "resourceName", ")", "{", "boolean", "found", "=", "false", ";", "try", "{", "resources", ".", "push", "(", "resourceName", ")", ";", "// Try classloader - load the resources in reverse order of the enumeration. Since later-loaded resources", "// override earlier-loaded ones, this better corresponds to the usual classpath behaviour.", "ClassLoader", "classloader", "=", "getParamsClassLoader", "(", ")", ";", "List", "<", "URL", ">", "urls", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Enumeration", "<", "URL", ">", "res", "=", "classloader", ".", "getResources", "(", "resourceName", ")", ";", "res", ".", "hasMoreElements", "(", ")", ";", ")", "{", "urls", ".", "add", "(", "res", ".", "nextElement", "(", ")", ")", ";", "}", "recordMessage", "(", "\"Resource \"", "+", "resourceName", "+", "\" was found \"", "+", "urls", ".", "size", "(", ")", "+", "\" times\"", ")", ";", "// Sometimes the same URL will crop up several times (because of redundant entries in classpaths). Also,", "// sometimes the same file appears under several URLS (because it's packaged into a jar and also a classes", "// directory, perhaps). In these circumstances we really only want to load the resource once - we load the", "// first one and then ignore later ones.", "Map", "<", "String", ",", "String", ">", "loadedFiles", "=", "new", "HashMap", "<>", "(", ")", ";", "// Build up a list of the byte arrays from the files that we then process.", "List", "<", "byte", "[", "]", ">", "contentsList", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "URL", ">", "urlList", "=", "new", "ArrayList", "<>", "(", ")", ";", "// This processes from the front-of-classpath to end-of-classpath since end-of-classpath ones appear last in", "// the enumeration", "for", "(", "int", "i", "=", "0", ";", "i", "<", "urls", ".", "size", "(", ")", ";", "i", "++", ")", "{", "URL", "url", "=", "urls", ".", "get", "(", "i", ")", ";", "found", "=", "true", ";", "// Load the contents of the resource, for comparison with existing resources.", "InputStream", "urlContentStream", "=", "url", ".", "openStream", "(", ")", ";", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "StreamUtil", ".", "copy", "(", "urlContentStream", ",", "baos", ")", ";", "urlContentStream", ".", "close", "(", ")", ";", "byte", "[", "]", "urlContentBytes", "=", "baos", ".", "toByteArray", "(", ")", ";", "String", "urlContent", "=", "new", "String", "(", "urlContentBytes", ",", "\"UTF-8\"", ")", ";", "// Check if we have already loaded this file.", "if", "(", "loadedFiles", ".", "keySet", "(", ")", ".", "contains", "(", "urlContent", ")", ")", "{", "recordMessage", "(", "\"Skipped url \"", "+", "url", "+", "\" - duplicate of \"", "+", "loadedFiles", ".", "get", "(", "urlContent", ")", ")", ";", "continue", ";", "}", "loadedFiles", ".", "put", "(", "urlContent", ",", "url", ".", "toString", "(", ")", ")", ";", "contentsList", ".", "add", "(", "urlContentBytes", ")", ";", "urlList", ".", "add", "(", "url", ")", ";", "}", "for", "(", "int", "i", "=", "contentsList", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "byte", "[", "]", "buff", "=", "contentsList", ".", "get", "(", "i", ")", ";", "URL", "url", "=", "urlList", ".", "get", "(", "i", ")", ";", "recordMessage", "(", "\"Loading from url \"", "+", "url", "+", "\"...\"", ")", ";", "ByteArrayInputStream", "in", "=", "new", "ByteArrayInputStream", "(", "buff", ")", ";", "// Use the \"IncludeProperties\" to load properties into us one at a time....", "IncludeProperties", "properties", "=", "new", "IncludeProperties", "(", "url", ".", "toString", "(", ")", ")", ";", "properties", ".", "load", "(", "in", ")", ";", "}", "File", "file", "=", "new", "File", "(", "resourceName", ")", ";", "// Don't reload the file in the working directory if we are in the home directory.", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "recordMessage", "(", "\"Loading from file \"", "+", "filename", "(", "file", ")", "+", "\"...\"", ")", ";", "found", "=", "true", ";", "// Use the \"IncludeProperties\" to load properties into us, one at a time....", "IncludeProperties", "properties", "=", "new", "IncludeProperties", "(", "\"file:\"", "+", "filename", "(", "file", ")", ")", ";", "properties", ".", "load", "(", "new", "BufferedInputStream", "(", "new", "FileInputStream", "(", "file", ")", ")", ")", ";", "}", "if", "(", "!", "found", ")", "{", "recordMessage", "(", "\"Did not find resource \"", "+", "resourceName", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "// This is bad.", "recordException", "(", "ex", ")", ";", "}", "catch", "(", "IllegalArgumentException", "ex", ")", "{", "// Most likely a \"Malformed uxxxx encoding.\" error, which is", "// usually caused by a developer forgetting to escape backslashes", "recordException", "(", "ex", ")", ";", "}", "finally", "{", "resources", ".", "pop", "(", ")", ";", "}", "}" ]
Try loading the given resource name. There may be several resources corresponding to that name... @param resourceName the path of the resource to load from.
[ "Try", "loading", "the", "given", "resource", "name", ".", "There", "may", "be", "several", "resources", "corresponding", "to", "that", "name", "..." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L373-L462