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,100
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.filename
private String filename(final File aFile) { try { return aFile.getCanonicalPath(); } catch (IOException ex) { recordException(ex); return "UNKNOWN FILE"; } }
java
private String filename(final File aFile) { try { return aFile.getCanonicalPath(); } catch (IOException ex) { recordException(ex); return "UNKNOWN FILE"; } }
[ "private", "String", "filename", "(", "final", "File", "aFile", ")", "{", "try", "{", "return", "aFile", ".", "getCanonicalPath", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "recordException", "(", "ex", ")", ";", "return", "\"UNKNOWN FILE\"", ";", "}", "}" ]
Retrieves the canonical path for a given file. @param aFile the file to get the canonical path for. @return the canonical path to the given file, or <code>"UNKNOWN FILE"</code> on error.
[ "Retrieves", "the", "canonical", "path", "for", "a", "given", "file", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L470-L477
139,101
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.load
private void load(final Properties properties, final String location, final boolean overwriteOnly) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String already = get(key); if (overwriteOnly && already == null && !INCLUDE.equals(key)) { continue; } String value = (String) entry.getValue(); load(key, value, location); } }
java
private void load(final Properties properties, final String location, final boolean overwriteOnly) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String already = get(key); if (overwriteOnly && already == null && !INCLUDE.equals(key)) { continue; } String value = (String) entry.getValue(); load(key, value, location); } }
[ "private", "void", "load", "(", "final", "Properties", "properties", ",", "final", "String", "location", ",", "final", "boolean", "overwriteOnly", ")", "{", "for", "(", "Map", ".", "Entry", "<", "Object", ",", "Object", ">", "entry", ":", "properties", ".", "entrySet", "(", ")", ")", "{", "String", "key", "=", "(", "String", ")", "entry", ".", "getKey", "(", ")", ";", "String", "already", "=", "get", "(", "key", ")", ";", "if", "(", "overwriteOnly", "&&", "already", "==", "null", "&&", "!", "INCLUDE", ".", "equals", "(", "key", ")", ")", "{", "continue", ";", "}", "String", "value", "=", "(", "String", ")", "entry", ".", "getValue", "(", ")", ";", "load", "(", "key", ",", "value", ",", "location", ")", ";", "}", "}" ]
Load the properties from the given Properties object, recording the origin on those properties as being from the given location. @param properties the properties to load from @param location the location where the parameter was defined. @param overwriteOnly if true, only properties that are already defined will be loaded
[ "Load", "the", "properties", "from", "the", "given", "Properties", "object", "recording", "the", "origin", "on", "those", "properties", "as", "being", "from", "the", "given", "location", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L535-L549
139,102
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.load
private void load(final String key, final String value, final String location) { // Recursive bit if (INCLUDE.equals(key)) { load(parseStringArray(value)); } else { backing.put(key, value); if ("yes".equals(value) || "true".equals(value)) { booleanBacking.add(key); } else { booleanBacking.remove(key); } String history = locations.get(key); if (history == null) { history = location; } else { history = location + "; " + history; } locations.put(key, history); } }
java
private void load(final String key, final String value, final String location) { // Recursive bit if (INCLUDE.equals(key)) { load(parseStringArray(value)); } else { backing.put(key, value); if ("yes".equals(value) || "true".equals(value)) { booleanBacking.add(key); } else { booleanBacking.remove(key); } String history = locations.get(key); if (history == null) { history = location; } else { history = location + "; " + history; } locations.put(key, history); } }
[ "private", "void", "load", "(", "final", "String", "key", ",", "final", "String", "value", ",", "final", "String", "location", ")", "{", "// Recursive bit", "if", "(", "INCLUDE", ".", "equals", "(", "key", ")", ")", "{", "load", "(", "parseStringArray", "(", "value", ")", ")", ";", "}", "else", "{", "backing", ".", "put", "(", "key", ",", "value", ")", ";", "if", "(", "\"yes\"", ".", "equals", "(", "value", ")", "||", "\"true\"", ".", "equals", "(", "value", ")", ")", "{", "booleanBacking", ".", "add", "(", "key", ")", ";", "}", "else", "{", "booleanBacking", ".", "remove", "(", "key", ")", ";", "}", "String", "history", "=", "locations", ".", "get", "(", "key", ")", ";", "if", "(", "history", "==", "null", ")", "{", "history", "=", "location", ";", "}", "else", "{", "history", "=", "location", "+", "\"; \"", "+", "history", ";", "}", "locations", ".", "put", "(", "key", ",", "history", ")", ";", "}", "}" ]
Loads a single parameter into the configuration. This handles the special directives such as "include". @param key the parameter key. @param value the parameter value. @param location the location where the parameter was defined.
[ "Loads", "a", "single", "parameter", "into", "the", "configuration", ".", "This", "handles", "the", "special", "directives", "such", "as", "include", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L558-L581
139,103
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.load
private void load(final String[] subFiles) { for (int i = 0; i < subFiles.length; i++) { load(subFiles[i]); } }
java
private void load(final String[] subFiles) { for (int i = 0; i < subFiles.length; i++) { load(subFiles[i]); } }
[ "private", "void", "load", "(", "final", "String", "[", "]", "subFiles", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "subFiles", ".", "length", ";", "i", "++", ")", "{", "load", "(", "subFiles", "[", "i", "]", ")", ";", "}", "}" ]
Loads the configuration from a set of files. @param subFiles the files to load from.
[ "Loads", "the", "configuration", "from", "a", "set", "of", "files", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L588-L592
139,104
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java
DefaultInternalConfiguration.getSubProperties
public Properties getSubProperties(final String prefix, final boolean truncate) { String cacheKey = truncate + prefix; Properties sub = subcontextCache.get(cacheKey); if (sub != null) { // make a copy so users can't change. Properties copy = new Properties(); copy.putAll(sub); return copy; } sub = new Properties(); int length = prefix.length(); for (Map.Entry<String, Object> entry : backing.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { // If we are truncating, remove the prefix String newKey = key; if (truncate) { newKey = key.substring(length); } sub.setProperty(newKey, (String) entry.getValue()); } } subcontextCache.put(cacheKey, sub); // Make a copy so users can't change. Properties copy = new Properties(); copy.putAll(sub); return copy; }
java
public Properties getSubProperties(final String prefix, final boolean truncate) { String cacheKey = truncate + prefix; Properties sub = subcontextCache.get(cacheKey); if (sub != null) { // make a copy so users can't change. Properties copy = new Properties(); copy.putAll(sub); return copy; } sub = new Properties(); int length = prefix.length(); for (Map.Entry<String, Object> entry : backing.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { // If we are truncating, remove the prefix String newKey = key; if (truncate) { newKey = key.substring(length); } sub.setProperty(newKey, (String) entry.getValue()); } } subcontextCache.put(cacheKey, sub); // Make a copy so users can't change. Properties copy = new Properties(); copy.putAll(sub); return copy; }
[ "public", "Properties", "getSubProperties", "(", "final", "String", "prefix", ",", "final", "boolean", "truncate", ")", "{", "String", "cacheKey", "=", "truncate", "+", "prefix", ";", "Properties", "sub", "=", "subcontextCache", ".", "get", "(", "cacheKey", ")", ";", "if", "(", "sub", "!=", "null", ")", "{", "// make a copy so users can't change.", "Properties", "copy", "=", "new", "Properties", "(", ")", ";", "copy", ".", "putAll", "(", "sub", ")", ";", "return", "copy", ";", "}", "sub", "=", "new", "Properties", "(", ")", ";", "int", "length", "=", "prefix", ".", "length", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "backing", ".", "entrySet", "(", ")", ")", "{", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "if", "(", "key", ".", "startsWith", "(", "prefix", ")", ")", "{", "// If we are truncating, remove the prefix", "String", "newKey", "=", "key", ";", "if", "(", "truncate", ")", "{", "newKey", "=", "key", ".", "substring", "(", "length", ")", ";", "}", "sub", ".", "setProperty", "(", "newKey", ",", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "subcontextCache", ".", "put", "(", "cacheKey", ",", "sub", ")", ";", "// Make a copy so users can't change.", "Properties", "copy", "=", "new", "Properties", "(", ")", ";", "copy", ".", "putAll", "(", "sub", ")", ";", "return", "copy", ";", "}" ]
Returns a sub-set of the parameters contained in this configuration. @param prefix the prefix of the parameter keys which should be included. @param truncate if true, the prefix is truncated in the returned properties. @return the properties sub-set, may be empty.
[ "Returns", "a", "sub", "-", "set", "of", "the", "parameters", "contained", "in", "this", "configuration", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L633-L671
139,105
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExample.java
RepeaterExample.preparePaintComponent
@Override public void preparePaintComponent(final Request request) { if (!this.isInitialised()) { // Give the repeater the list of data to display. productRepeater.setData(fetchProductData()); // Remember that we've done the initialisation. this.setInitialised(true); } }
java
@Override public void preparePaintComponent(final Request request) { if (!this.isInitialised()) { // Give the repeater the list of data to display. productRepeater.setData(fetchProductData()); // Remember that we've done the initialisation. this.setInitialised(true); } }
[ "@", "Override", "public", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "if", "(", "!", "this", ".", "isInitialised", "(", ")", ")", "{", "// Give the repeater the list of data to display.", "productRepeater", ".", "setData", "(", "fetchProductData", "(", ")", ")", ";", "// Remember that we've done the initialisation.", "this", ".", "setInitialised", "(", "true", ")", ";", "}", "}" ]
Override to initialise some data. @param request the request being responded to.
[ "Override", "to", "initialise", "some", "data", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExample.java#L38-L47
139,106
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/HtmlToXMLUtil.java
HtmlToXMLUtil.unescapeToXML
public static String unescapeToXML(final String input) { if (Util.empty(input)) { return input; } // Check if input has encoded brackets String encoded = WebUtilities.doubleEncodeBrackets(input); String unescaped = UNESCAPE_HTML_TO_XML.translate(encoded); String decoded = WebUtilities.doubleDecodeBrackets(unescaped); return decoded; }
java
public static String unescapeToXML(final String input) { if (Util.empty(input)) { return input; } // Check if input has encoded brackets String encoded = WebUtilities.doubleEncodeBrackets(input); String unescaped = UNESCAPE_HTML_TO_XML.translate(encoded); String decoded = WebUtilities.doubleDecodeBrackets(unescaped); return decoded; }
[ "public", "static", "String", "unescapeToXML", "(", "final", "String", "input", ")", "{", "if", "(", "Util", ".", "empty", "(", "input", ")", ")", "{", "return", "input", ";", "}", "// Check if input has encoded brackets", "String", "encoded", "=", "WebUtilities", ".", "doubleEncodeBrackets", "(", "input", ")", ";", "String", "unescaped", "=", "UNESCAPE_HTML_TO_XML", ".", "translate", "(", "encoded", ")", ";", "String", "decoded", "=", "WebUtilities", ".", "doubleDecodeBrackets", "(", "unescaped", ")", ";", "return", "decoded", ";", "}" ]
Unescape HTML entities to safe XML. <p> Example</p> <pre> {@code StringEscapeHTMLToXMLUtil.unescapeToXML("&bull;&Dagger}"); // returns "•‡"} {@code StringEscapeHTMLToXMLUtil.unescapeToXML("&lt;p&gt;"); // returns "&lt;p&gt;" not "<p>"} </pre> @param input The String to unescape. @return the input with all HTML4 character entities unescaped except those which are also XML entities.
[ "Unescape", "HTML", "entities", "to", "safe", "XML", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/HtmlToXMLUtil.java#L51-L60
139,107
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/error/impl/DefaultSystemFailureMapper.java
DefaultSystemFailureMapper.toMessage
@Override public Message toMessage(final Throwable throwable) { LOG.error("The system is currently unavailable", throwable); return new Message(Message.ERROR_MESSAGE, InternalMessages.DEFAULT_SYSTEM_ERROR); }
java
@Override public Message toMessage(final Throwable throwable) { LOG.error("The system is currently unavailable", throwable); return new Message(Message.ERROR_MESSAGE, InternalMessages.DEFAULT_SYSTEM_ERROR); }
[ "@", "Override", "public", "Message", "toMessage", "(", "final", "Throwable", "throwable", ")", "{", "LOG", ".", "error", "(", "\"The system is currently unavailable\"", ",", "throwable", ")", ";", "return", "new", "Message", "(", "Message", ".", "ERROR_MESSAGE", ",", "InternalMessages", ".", "DEFAULT_SYSTEM_ERROR", ")", ";", "}" ]
This method converts a java Throwable into a "user friendly" error message. @param throwable the Throwable to convert @return A {@link Message} containing the hard coded description "The system is currently unavailable."
[ "This", "method", "converts", "a", "java", "Throwable", "into", "a", "user", "friendly", "error", "message", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/error/impl/DefaultSystemFailureMapper.java#L27-L31
139,108
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAjaxControl.java
WAjaxControl.addTargets
public void addTargets(final List<? extends AjaxTarget> targets) { if (targets != null) { for (AjaxTarget target : targets) { this.addTarget(target); } } }
java
public void addTargets(final List<? extends AjaxTarget> targets) { if (targets != null) { for (AjaxTarget target : targets) { this.addTarget(target); } } }
[ "public", "void", "addTargets", "(", "final", "List", "<", "?", "extends", "AjaxTarget", ">", "targets", ")", "{", "if", "(", "targets", "!=", "null", ")", "{", "for", "(", "AjaxTarget", "target", ":", "targets", ")", "{", "this", ".", "addTarget", "(", "target", ")", ";", "}", "}", "}" ]
Add a list of target components that should be targets for this AJAX request. @param targets the components that will be repainted for the AJAX request
[ "Add", "a", "list", "of", "target", "components", "that", "should", "be", "targets", "for", "this", "AJAX", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAjaxControl.java#L104-L110
139,109
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAjaxControl.java
WAjaxControl.addTarget
public void addTarget(final AjaxTarget target) { AjaxControlModel model = getOrCreateComponentModel(); if (model.targets == null) { model.targets = new ArrayList<>(); } model.targets.add(target); MemoryUtil.checkSize(model.targets.size(), this.getClass().getSimpleName()); }
java
public void addTarget(final AjaxTarget target) { AjaxControlModel model = getOrCreateComponentModel(); if (model.targets == null) { model.targets = new ArrayList<>(); } model.targets.add(target); MemoryUtil.checkSize(model.targets.size(), this.getClass().getSimpleName()); }
[ "public", "void", "addTarget", "(", "final", "AjaxTarget", "target", ")", "{", "AjaxControlModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "targets", "==", "null", ")", "{", "model", ".", "targets", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "model", ".", "targets", ".", "add", "(", "target", ")", ";", "MemoryUtil", ".", "checkSize", "(", "model", ".", "targets", ".", "size", "(", ")", ",", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}" ]
Add a single target WComponent to this AJAX control. @param target a WComponent to be repainted
[ "Add", "a", "single", "target", "WComponent", "to", "this", "AJAX", "control", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAjaxControl.java#L117-L126
139,110
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAjaxControl.java
WAjaxControl.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); List<AjaxTarget> targets = getTargets(); if (targets != null && !targets.isEmpty()) { WComponent triggerComponent = trigger == null ? this : trigger; // The trigger maybe in a different context UIContext triggerContext = WebUtilities.getContextForComponent(triggerComponent); UIContextHolder.pushContext(triggerContext); // TODO The IDs of the targets are based on the Triggers Context. Not good for targets in repeaters try { List<String> targetIds = new ArrayList<>(); for (AjaxTarget target : getTargets()) { targetIds.add(target.getId()); } AjaxHelper.registerComponents(targetIds, triggerComponent.getId()); } finally { UIContextHolder.popContext(); } } }
java
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); List<AjaxTarget> targets = getTargets(); if (targets != null && !targets.isEmpty()) { WComponent triggerComponent = trigger == null ? this : trigger; // The trigger maybe in a different context UIContext triggerContext = WebUtilities.getContextForComponent(triggerComponent); UIContextHolder.pushContext(triggerContext); // TODO The IDs of the targets are based on the Triggers Context. Not good for targets in repeaters try { List<String> targetIds = new ArrayList<>(); for (AjaxTarget target : getTargets()) { targetIds.add(target.getId()); } AjaxHelper.registerComponents(targetIds, triggerComponent.getId()); } finally { UIContextHolder.popContext(); } } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "List", "<", "AjaxTarget", ">", "targets", "=", "getTargets", "(", ")", ";", "if", "(", "targets", "!=", "null", "&&", "!", "targets", ".", "isEmpty", "(", ")", ")", "{", "WComponent", "triggerComponent", "=", "trigger", "==", "null", "?", "this", ":", "trigger", ";", "// The trigger maybe in a different context", "UIContext", "triggerContext", "=", "WebUtilities", ".", "getContextForComponent", "(", "triggerComponent", ")", ";", "UIContextHolder", ".", "pushContext", "(", "triggerContext", ")", ";", "// TODO The IDs of the targets are based on the Triggers Context. Not good for targets in repeaters", "try", "{", "List", "<", "String", ">", "targetIds", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "AjaxTarget", "target", ":", "getTargets", "(", ")", ")", "{", "targetIds", ".", "add", "(", "target", ".", "getId", "(", ")", ")", ";", "}", "AjaxHelper", ".", "registerComponents", "(", "targetIds", ",", "triggerComponent", ".", "getId", "(", ")", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "}" ]
Override preparePaintComponent in order to register the components for the current request. @param request the request being responded to
[ "Override", "preparePaintComponent", "in", "order", "to", "register", "the", "components", "for", "the", "current", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAjaxControl.java#L245-L268
139,111
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java
FilterableTableExample.setCaseSensitiveMatch
public void setCaseSensitiveMatch(final Boolean caseInsensitive) { FilterableBeanBoundDataModel model = getFilterableTableModel(); if (model != null) { model.setCaseSensitiveMatch(caseInsensitive); } }
java
public void setCaseSensitiveMatch(final Boolean caseInsensitive) { FilterableBeanBoundDataModel model = getFilterableTableModel(); if (model != null) { model.setCaseSensitiveMatch(caseInsensitive); } }
[ "public", "void", "setCaseSensitiveMatch", "(", "final", "Boolean", "caseInsensitive", ")", "{", "FilterableBeanBoundDataModel", "model", "=", "getFilterableTableModel", "(", ")", ";", "if", "(", "model", "!=", "null", ")", "{", "model", ".", "setCaseSensitiveMatch", "(", "caseInsensitive", ")", ";", "}", "}" ]
Set the filter case sensitivity. @param caseInsensitive If true the filter will not be case sensitive so, for example, "Smith" and "smith" will be equivalent.
[ "Set", "the", "filter", "case", "sensitivity", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java#L138-L143
139,112
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java
FilterableTableExample.buildColumnHeader
private WDecoratedLabel buildColumnHeader(final String text, final WMenu menu) { WDecoratedLabel label = new WDecoratedLabel(null, new WText(text), menu); return label; }
java
private WDecoratedLabel buildColumnHeader(final String text, final WMenu menu) { WDecoratedLabel label = new WDecoratedLabel(null, new WText(text), menu); return label; }
[ "private", "WDecoratedLabel", "buildColumnHeader", "(", "final", "String", "text", ",", "final", "WMenu", "menu", ")", "{", "WDecoratedLabel", "label", "=", "new", "WDecoratedLabel", "(", "null", ",", "new", "WText", "(", "text", ")", ",", "menu", ")", ";", "return", "label", ";", "}" ]
Helper to create the table column heading's WDecoratedLabel. @param text The readable text content of the column header @param menu The WMenu we want in this column header. @return WDecoratedLabel used to create a column heading.
[ "Helper", "to", "create", "the", "table", "column", "heading", "s", "WDecoratedLabel", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java#L152-L155
139,113
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java
FilterableTableExample.buildFilterMenus
private void buildFilterMenus() { buildFilterSubMenu(firstNameFilterMenu, FIRST_NAME); if (firstNameFilterMenu.getChildCount() == 0) { firstNameFilterMenu.setVisible(false); } buildFilterSubMenu(lastNameFilterMenu, LAST_NAME); if (lastNameFilterMenu.getChildCount() == 0) { lastNameFilterMenu.setVisible(false); } buildFilterSubMenu(dobFilterMenu, DOB); if (dobFilterMenu.getChildCount() == 0) { dobFilterMenu.setVisible(false); } }
java
private void buildFilterMenus() { buildFilterSubMenu(firstNameFilterMenu, FIRST_NAME); if (firstNameFilterMenu.getChildCount() == 0) { firstNameFilterMenu.setVisible(false); } buildFilterSubMenu(lastNameFilterMenu, LAST_NAME); if (lastNameFilterMenu.getChildCount() == 0) { lastNameFilterMenu.setVisible(false); } buildFilterSubMenu(dobFilterMenu, DOB); if (dobFilterMenu.getChildCount() == 0) { dobFilterMenu.setVisible(false); } }
[ "private", "void", "buildFilterMenus", "(", ")", "{", "buildFilterSubMenu", "(", "firstNameFilterMenu", ",", "FIRST_NAME", ")", ";", "if", "(", "firstNameFilterMenu", ".", "getChildCount", "(", ")", "==", "0", ")", "{", "firstNameFilterMenu", ".", "setVisible", "(", "false", ")", ";", "}", "buildFilterSubMenu", "(", "lastNameFilterMenu", ",", "LAST_NAME", ")", ";", "if", "(", "lastNameFilterMenu", ".", "getChildCount", "(", ")", "==", "0", ")", "{", "lastNameFilterMenu", ".", "setVisible", "(", "false", ")", ";", "}", "buildFilterSubMenu", "(", "dobFilterMenu", ",", "DOB", ")", ";", "if", "(", "dobFilterMenu", ".", "getChildCount", "(", ")", "==", "0", ")", "{", "dobFilterMenu", ".", "setVisible", "(", "false", ")", ";", "}", "}" ]
Builds the menu content for each column heading's filter menu.
[ "Builds", "the", "menu", "content", "for", "each", "column", "heading", "s", "filter", "menu", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java#L160-L175
139,114
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java
FilterableTableExample.setUpClearAllAction
private void setUpClearAllAction() { /* if one or fewer of the filter menus are visible then we don't need the clear all menus button */ int visibleMenus = 0; if (firstNameFilterMenu.isVisible()) { visibleMenus++; } if (lastNameFilterMenu.isVisible()) { visibleMenus++; } if (dobFilterMenu.isVisible()) { visibleMenus++; } clearAllFiltersButton.setVisible(visibleMenus > 1); /* enable/disable the clear all filters action: * if we have not initialised the lists then we do not need the button (though in this case it will not be visible); * otherwise if the size of the full list is the same as the size of the filtered list then we have not filtered the * list so we do not need to clear the filters and the button can be disabled; * otherwise enable the button because we have applied at least one filter. */ if (clearAllFiltersButton.isVisible()) { List<?> fullList = getFilterableTableModel().getFullBeanList(); List<?> filteredList = getFilterableTableModel().getBeanList(); clearAllFiltersButton.setDisabled(fullList == null || filteredList == null || fullList. size() == filteredList.size()); } }
java
private void setUpClearAllAction() { /* if one or fewer of the filter menus are visible then we don't need the clear all menus button */ int visibleMenus = 0; if (firstNameFilterMenu.isVisible()) { visibleMenus++; } if (lastNameFilterMenu.isVisible()) { visibleMenus++; } if (dobFilterMenu.isVisible()) { visibleMenus++; } clearAllFiltersButton.setVisible(visibleMenus > 1); /* enable/disable the clear all filters action: * if we have not initialised the lists then we do not need the button (though in this case it will not be visible); * otherwise if the size of the full list is the same as the size of the filtered list then we have not filtered the * list so we do not need to clear the filters and the button can be disabled; * otherwise enable the button because we have applied at least one filter. */ if (clearAllFiltersButton.isVisible()) { List<?> fullList = getFilterableTableModel().getFullBeanList(); List<?> filteredList = getFilterableTableModel().getBeanList(); clearAllFiltersButton.setDisabled(fullList == null || filteredList == null || fullList. size() == filteredList.size()); } }
[ "private", "void", "setUpClearAllAction", "(", ")", "{", "/* if one or fewer of the filter menus are visible then we don't need the clear all menus button */", "int", "visibleMenus", "=", "0", ";", "if", "(", "firstNameFilterMenu", ".", "isVisible", "(", ")", ")", "{", "visibleMenus", "++", ";", "}", "if", "(", "lastNameFilterMenu", ".", "isVisible", "(", ")", ")", "{", "visibleMenus", "++", ";", "}", "if", "(", "dobFilterMenu", ".", "isVisible", "(", ")", ")", "{", "visibleMenus", "++", ";", "}", "clearAllFiltersButton", ".", "setVisible", "(", "visibleMenus", ">", "1", ")", ";", "/* enable/disable the clear all filters action:\n* if we have not initialised the lists then we do not need the button (though in this case it will not be visible);\n * otherwise if the size of the full list is the same as the size of the filtered list then we have not filtered the\n * list so we do not need to clear the filters and the button can be disabled;\n * otherwise enable the button because we have applied at least one filter.\n\t\t */", "if", "(", "clearAllFiltersButton", ".", "isVisible", "(", ")", ")", "{", "List", "<", "?", ">", "fullList", "=", "getFilterableTableModel", "(", ")", ".", "getFullBeanList", "(", ")", ";", "List", "<", "?", ">", "filteredList", "=", "getFilterableTableModel", "(", ")", ".", "getBeanList", "(", ")", ";", "clearAllFiltersButton", ".", "setDisabled", "(", "fullList", "==", "null", "||", "filteredList", "==", "null", "||", "fullList", ".", "size", "(", ")", "==", "filteredList", ".", "size", "(", ")", ")", ";", "}", "}" ]
Sets the state of the clearAllActions button based on the visibility of the filter menus and if the button is visible sets its disabled state if nothing is filtered. This is usability sugar, it is not necessary for the functionality of the filters.
[ "Sets", "the", "state", "of", "the", "clearAllActions", "button", "based", "on", "the", "visibility", "of", "the", "filter", "menus", "and", "if", "the", "button", "is", "visible", "sets", "its", "disabled", "state", "if", "nothing", "is", "filtered", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java#L213-L239
139,115
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java
FilterableTableExample.buildFilterSubMenu
private void buildFilterSubMenu(final WMenu menu, final int column) { List<?> beanList = getFilterableTableModel().getFullBeanList(); int rows = (beanList == null) ? 0 : beanList.size(); if (rows == 0) { return; } final List<String> found = new ArrayList<>(); final WDecoratedLabel filterSubMenuLabel = new WDecoratedLabel(new WText("\u200b")); filterSubMenuLabel.setToolTip("Filter this column"); filterSubMenuLabel.setHtmlClass(HtmlIconUtil.getIconClasses("fa-filter")); final WSubMenu submenu = new WSubMenu(filterSubMenuLabel); submenu.setSelectionMode(SELECTION_MODE); menu.add(submenu); WMenuItem item = new WMenuItem(CLEAR_ALL, new ClearFilterAction()); submenu.add(item); item.setActionObject(item); item.setSelectability(false); add(new WAjaxControl(item, table)); Object cellObject; String cellContent, cellContentMatch; Object bean; if (beanList != null) { for (int i = 0; i < rows; ++i) { bean = beanList.get(i); if (bean != null) { cellObject = getFilterableTableModel().getBeanPropertyValueFullList(BEAN_PROPERTIES[column], bean); if (cellObject != null) { if (cellObject instanceof Date) { cellContent = new SimpleDateFormat(DATE_FORMAT).format((Date) cellObject); } else { cellContent = cellObject.toString(); } if ("".equals(cellContent)) { cellContent = EMPTY; } cellContentMatch = (getFilterableTableModel().isCaseInsensitiveMatch()) ? cellContent. toLowerCase() : cellContent; if (found.indexOf(cellContentMatch) == -1) { item = new WMenuItem(cellContent, new FilterAction()); submenu.add(item); add(new WAjaxControl(item, table)); found.add(cellContentMatch); } } } } } }
java
private void buildFilterSubMenu(final WMenu menu, final int column) { List<?> beanList = getFilterableTableModel().getFullBeanList(); int rows = (beanList == null) ? 0 : beanList.size(); if (rows == 0) { return; } final List<String> found = new ArrayList<>(); final WDecoratedLabel filterSubMenuLabel = new WDecoratedLabel(new WText("\u200b")); filterSubMenuLabel.setToolTip("Filter this column"); filterSubMenuLabel.setHtmlClass(HtmlIconUtil.getIconClasses("fa-filter")); final WSubMenu submenu = new WSubMenu(filterSubMenuLabel); submenu.setSelectionMode(SELECTION_MODE); menu.add(submenu); WMenuItem item = new WMenuItem(CLEAR_ALL, new ClearFilterAction()); submenu.add(item); item.setActionObject(item); item.setSelectability(false); add(new WAjaxControl(item, table)); Object cellObject; String cellContent, cellContentMatch; Object bean; if (beanList != null) { for (int i = 0; i < rows; ++i) { bean = beanList.get(i); if (bean != null) { cellObject = getFilterableTableModel().getBeanPropertyValueFullList(BEAN_PROPERTIES[column], bean); if (cellObject != null) { if (cellObject instanceof Date) { cellContent = new SimpleDateFormat(DATE_FORMAT).format((Date) cellObject); } else { cellContent = cellObject.toString(); } if ("".equals(cellContent)) { cellContent = EMPTY; } cellContentMatch = (getFilterableTableModel().isCaseInsensitiveMatch()) ? cellContent. toLowerCase() : cellContent; if (found.indexOf(cellContentMatch) == -1) { item = new WMenuItem(cellContent, new FilterAction()); submenu.add(item); add(new WAjaxControl(item, table)); found.add(cellContentMatch); } } } } } }
[ "private", "void", "buildFilterSubMenu", "(", "final", "WMenu", "menu", ",", "final", "int", "column", ")", "{", "List", "<", "?", ">", "beanList", "=", "getFilterableTableModel", "(", ")", ".", "getFullBeanList", "(", ")", ";", "int", "rows", "=", "(", "beanList", "==", "null", ")", "?", "0", ":", "beanList", ".", "size", "(", ")", ";", "if", "(", "rows", "==", "0", ")", "{", "return", ";", "}", "final", "List", "<", "String", ">", "found", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "WDecoratedLabel", "filterSubMenuLabel", "=", "new", "WDecoratedLabel", "(", "new", "WText", "(", "\"\\u200b\"", ")", ")", ";", "filterSubMenuLabel", ".", "setToolTip", "(", "\"Filter this column\"", ")", ";", "filterSubMenuLabel", ".", "setHtmlClass", "(", "HtmlIconUtil", ".", "getIconClasses", "(", "\"fa-filter\"", ")", ")", ";", "final", "WSubMenu", "submenu", "=", "new", "WSubMenu", "(", "filterSubMenuLabel", ")", ";", "submenu", ".", "setSelectionMode", "(", "SELECTION_MODE", ")", ";", "menu", ".", "add", "(", "submenu", ")", ";", "WMenuItem", "item", "=", "new", "WMenuItem", "(", "CLEAR_ALL", ",", "new", "ClearFilterAction", "(", ")", ")", ";", "submenu", ".", "add", "(", "item", ")", ";", "item", ".", "setActionObject", "(", "item", ")", ";", "item", ".", "setSelectability", "(", "false", ")", ";", "add", "(", "new", "WAjaxControl", "(", "item", ",", "table", ")", ")", ";", "Object", "cellObject", ";", "String", "cellContent", ",", "cellContentMatch", ";", "Object", "bean", ";", "if", "(", "beanList", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "++", "i", ")", "{", "bean", "=", "beanList", ".", "get", "(", "i", ")", ";", "if", "(", "bean", "!=", "null", ")", "{", "cellObject", "=", "getFilterableTableModel", "(", ")", ".", "getBeanPropertyValueFullList", "(", "BEAN_PROPERTIES", "[", "column", "]", ",", "bean", ")", ";", "if", "(", "cellObject", "!=", "null", ")", "{", "if", "(", "cellObject", "instanceof", "Date", ")", "{", "cellContent", "=", "new", "SimpleDateFormat", "(", "DATE_FORMAT", ")", ".", "format", "(", "(", "Date", ")", "cellObject", ")", ";", "}", "else", "{", "cellContent", "=", "cellObject", ".", "toString", "(", ")", ";", "}", "if", "(", "\"\"", ".", "equals", "(", "cellContent", ")", ")", "{", "cellContent", "=", "EMPTY", ";", "}", "cellContentMatch", "=", "(", "getFilterableTableModel", "(", ")", ".", "isCaseInsensitiveMatch", "(", ")", ")", "?", "cellContent", ".", "toLowerCase", "(", ")", ":", "cellContent", ";", "if", "(", "found", ".", "indexOf", "(", "cellContentMatch", ")", "==", "-", "1", ")", "{", "item", "=", "new", "WMenuItem", "(", "cellContent", ",", "new", "FilterAction", "(", ")", ")", ";", "submenu", ".", "add", "(", "item", ")", ";", "add", "(", "new", "WAjaxControl", "(", "item", ",", "table", ")", ")", ";", "found", ".", "add", "(", "cellContentMatch", ")", ";", "}", "}", "}", "}", "}", "}" ]
Creates and populates the sub-menu for each filter menu. @param menu The WMenu we are currently populating. @param column The column index of the table column the menu is in. This is used to get the data off the table's Bean to put text content into the menu's items.
[ "Creates", "and", "populates", "the", "sub", "-", "menu", "for", "each", "filter", "menu", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/FilterableTableExample.java#L257-L313
139,116
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPopup.java
WPopup.setUrl
public void setUrl(final String url) { String currUrl = getUrl(); if (!Objects.equals(url, currUrl)) { getOrCreateComponentModel().url = url; } }
java
public void setUrl(final String url) { String currUrl = getUrl(); if (!Objects.equals(url, currUrl)) { getOrCreateComponentModel().url = url; } }
[ "public", "void", "setUrl", "(", "final", "String", "url", ")", "{", "String", "currUrl", "=", "getUrl", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "url", ",", "currUrl", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "url", "=", "url", ";", "}", "}" ]
Sets the URL. @param url the URL to set.
[ "Sets", "the", "URL", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPopup.java#L116-L122
139,117
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPopup.java
WPopup.setTargetWindow
public void setTargetWindow(final String targetWindow) { String currTargWin = getTargetWindow(); if (!Objects.equals(targetWindow, currTargWin)) { getOrCreateComponentModel().targetWindow = targetWindow; } }
java
public void setTargetWindow(final String targetWindow) { String currTargWin = getTargetWindow(); if (!Objects.equals(targetWindow, currTargWin)) { getOrCreateComponentModel().targetWindow = targetWindow; } }
[ "public", "void", "setTargetWindow", "(", "final", "String", "targetWindow", ")", "{", "String", "currTargWin", "=", "getTargetWindow", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "targetWindow", ",", "currTargWin", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "targetWindow", "=", "targetWindow", ";", "}", "}" ]
Sets the target window name. @param targetWindow the target window name.
[ "Sets", "the", "target", "window", "name", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPopup.java#L138-L144
139,118
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/InfoDump.java
InfoDump.dumpWEnvironment
private void dumpWEnvironment() { StringBuffer text = new StringBuffer(); Environment env = getEnvironment(); text.append("\n\nWEnvironment" + "\n------------"); text.append("\nAppId: ").append(env.getAppId()); text.append("\nBaseUrl: ").append(env.getBaseUrl()); text.append("\nHostFreeBaseUrl: ").append(env.getHostFreeBaseUrl()); text.append("\nPostPath: ").append(env.getPostPath()); text.append("\nTargetablePath: ").append(env.getWServletPath()); text.append("\nAppHostPath: ").append(env.getAppHostPath()); text.append("\nThemePath: ").append(env.getThemePath()); text.append("\nStep: ").append(env.getStep()); text.append("\nSession Token: ").append(env.getSessionToken()); text.append("\nFormEncType: ").append(env.getFormEncType()); text.append('\n'); appendToConsole(text.toString()); }
java
private void dumpWEnvironment() { StringBuffer text = new StringBuffer(); Environment env = getEnvironment(); text.append("\n\nWEnvironment" + "\n------------"); text.append("\nAppId: ").append(env.getAppId()); text.append("\nBaseUrl: ").append(env.getBaseUrl()); text.append("\nHostFreeBaseUrl: ").append(env.getHostFreeBaseUrl()); text.append("\nPostPath: ").append(env.getPostPath()); text.append("\nTargetablePath: ").append(env.getWServletPath()); text.append("\nAppHostPath: ").append(env.getAppHostPath()); text.append("\nThemePath: ").append(env.getThemePath()); text.append("\nStep: ").append(env.getStep()); text.append("\nSession Token: ").append(env.getSessionToken()); text.append("\nFormEncType: ").append(env.getFormEncType()); text.append('\n'); appendToConsole(text.toString()); }
[ "private", "void", "dumpWEnvironment", "(", ")", "{", "StringBuffer", "text", "=", "new", "StringBuffer", "(", ")", ";", "Environment", "env", "=", "getEnvironment", "(", ")", ";", "text", ".", "append", "(", "\"\\n\\nWEnvironment\"", "+", "\"\\n------------\"", ")", ";", "text", ".", "append", "(", "\"\\nAppId: \"", ")", ".", "append", "(", "env", ".", "getAppId", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nBaseUrl: \"", ")", ".", "append", "(", "env", ".", "getBaseUrl", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nHostFreeBaseUrl: \"", ")", ".", "append", "(", "env", ".", "getHostFreeBaseUrl", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nPostPath: \"", ")", ".", "append", "(", "env", ".", "getPostPath", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nTargetablePath: \"", ")", ".", "append", "(", "env", ".", "getWServletPath", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nAppHostPath: \"", ")", ".", "append", "(", "env", ".", "getAppHostPath", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nThemePath: \"", ")", ".", "append", "(", "env", ".", "getThemePath", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nStep: \"", ")", ".", "append", "(", "env", ".", "getStep", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nSession Token: \"", ")", ".", "append", "(", "env", ".", "getSessionToken", "(", ")", ")", ";", "text", ".", "append", "(", "\"\\nFormEncType: \"", ")", ".", "append", "(", "env", ".", "getFormEncType", "(", ")", ")", ";", "text", ".", "append", "(", "'", "'", ")", ";", "appendToConsole", "(", "text", ".", "toString", "(", ")", ")", ";", "}" ]
Appends the current environment to the console.
[ "Appends", "the", "current", "environment", "to", "the", "console", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/InfoDump.java#L87-L108
139,119
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Config.java
Config.copyConfiguration
public static Configuration copyConfiguration(final Configuration original) { Configuration copy = new MapConfiguration(new HashMap<String, Object>()); for (Iterator<?> i = original.getKeys(); i.hasNext();) { String key = (String) i.next(); Object value = original.getProperty(key); if (value instanceof List) { value = new ArrayList((List) value); } copy.setProperty(key, value); } return copy; }
java
public static Configuration copyConfiguration(final Configuration original) { Configuration copy = new MapConfiguration(new HashMap<String, Object>()); for (Iterator<?> i = original.getKeys(); i.hasNext();) { String key = (String) i.next(); Object value = original.getProperty(key); if (value instanceof List) { value = new ArrayList((List) value); } copy.setProperty(key, value); } return copy; }
[ "public", "static", "Configuration", "copyConfiguration", "(", "final", "Configuration", "original", ")", "{", "Configuration", "copy", "=", "new", "MapConfiguration", "(", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ")", ";", "for", "(", "Iterator", "<", "?", ">", "i", "=", "original", ".", "getKeys", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "String", "key", "=", "(", "String", ")", "i", ".", "next", "(", ")", ";", "Object", "value", "=", "original", ".", "getProperty", "(", "key", ")", ";", "if", "(", "value", "instanceof", "List", ")", "{", "value", "=", "new", "ArrayList", "(", "(", "List", ")", "value", ")", ";", "}", "copy", ".", "setProperty", "(", "key", ",", "value", ")", ";", "}", "return", "copy", ";", "}" ]
Creates a deep-copy of the given configuration. This is useful for unit-testing. @param original the configuration to copy. @return a copy of the given configuration.
[ "Creates", "a", "deep", "-", "copy", "of", "the", "given", "configuration", ".", "This", "is", "useful", "for", "unit", "-", "testing", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Config.java#L98-L113
139,120
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java
WFileWidget.getFileTypes
public List<String> getFileTypes() { List<String> fileTypes = getComponentModel().fileTypes; if (fileTypes == null) { return Collections.emptyList(); } return Collections.unmodifiableList(fileTypes); }
java
public List<String> getFileTypes() { List<String> fileTypes = getComponentModel().fileTypes; if (fileTypes == null) { return Collections.emptyList(); } return Collections.unmodifiableList(fileTypes); }
[ "public", "List", "<", "String", ">", "getFileTypes", "(", ")", "{", "List", "<", "String", ">", "fileTypes", "=", "getComponentModel", "(", ")", ".", "fileTypes", ";", "if", "(", "fileTypes", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "fileTypes", ")", ";", "}" ]
Returns a list of strings that determine the allowable file mime types accepted by the file input. If no types have been added an empty list is returned. An empty list indicates that all file types are accepted. @return The mime types accepted by this file input e.g. "text/plain", "text/html", "application/pdf".
[ "Returns", "a", "list", "of", "strings", "that", "determine", "the", "allowable", "file", "mime", "types", "accepted", "by", "the", "file", "input", ".", "If", "no", "types", "have", "been", "added", "an", "empty", "list", "is", "returned", ".", "An", "empty", "list", "indicates", "that", "all", "file", "types", "are", "accepted", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java#L62-L70
139,121
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java
WFileWidget.setFileTypes
public void setFileTypes(final String[] types) { if (types == null) { setFileTypes((List<String>) null); } else { setFileTypes(Arrays.asList(types)); } }
java
public void setFileTypes(final String[] types) { if (types == null) { setFileTypes((List<String>) null); } else { setFileTypes(Arrays.asList(types)); } }
[ "public", "void", "setFileTypes", "(", "final", "String", "[", "]", "types", ")", "{", "if", "(", "types", "==", "null", ")", "{", "setFileTypes", "(", "(", "List", "<", "String", ">", ")", "null", ")", ";", "}", "else", "{", "setFileTypes", "(", "Arrays", ".", "asList", "(", "types", ")", ")", ";", "}", "}" ]
Set each file type to be accepted by the WFileWidget. @see #setFileTypes(java.util.List) for the file types @param types The file types that will be accepted by the file input.
[ "Set", "each", "file", "type", "to", "be", "accepted", "by", "the", "WFileWidget", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java#L79-L85
139,122
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java
WFileWidget.resetValidationState
private void resetValidationState() { // if User Model exists it will be returned, othewise Shared Model is returned final FileWidgetModel componentModel = getComponentModel(); // If Shared Model is returned then both fileType and fileSize are always valid // If User Model is returned check if any if any is false if (!componentModel.validFileSize || !componentModel.validFileType) { final FileWidgetModel userModel = getOrCreateComponentModel(); userModel.validFileType = true; userModel.validFileSize = true; } }
java
private void resetValidationState() { // if User Model exists it will be returned, othewise Shared Model is returned final FileWidgetModel componentModel = getComponentModel(); // If Shared Model is returned then both fileType and fileSize are always valid // If User Model is returned check if any if any is false if (!componentModel.validFileSize || !componentModel.validFileType) { final FileWidgetModel userModel = getOrCreateComponentModel(); userModel.validFileType = true; userModel.validFileSize = true; } }
[ "private", "void", "resetValidationState", "(", ")", "{", "// if User Model exists it will be returned, othewise Shared Model is returned", "final", "FileWidgetModel", "componentModel", "=", "getComponentModel", "(", ")", ";", "// If Shared Model is returned then both fileType and fileSize are always valid", "// If User Model is returned check if any if any is false", "if", "(", "!", "componentModel", ".", "validFileSize", "||", "!", "componentModel", ".", "validFileType", ")", "{", "final", "FileWidgetModel", "userModel", "=", "getOrCreateComponentModel", "(", ")", ";", "userModel", ".", "validFileType", "=", "true", ";", "userModel", ".", "validFileSize", "=", "true", ";", "}", "}" ]
Reset validation state.
[ "Reset", "validation", "state", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java#L213-L224
139,123
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java
WFileWidget.getInputStream
public InputStream getInputStream() throws IOException { FileItemWrap wrapper = getValue(); if (wrapper != null) { return wrapper.getInputStream(); } return null; }
java
public InputStream getInputStream() throws IOException { FileItemWrap wrapper = getValue(); if (wrapper != null) { return wrapper.getInputStream(); } return null; }
[ "public", "InputStream", "getInputStream", "(", ")", "throws", "IOException", "{", "FileItemWrap", "wrapper", "=", "getValue", "(", ")", ";", "if", "(", "wrapper", "!=", "null", ")", "{", "return", "wrapper", ".", "getInputStream", "(", ")", ";", "}", "return", "null", ";", "}" ]
Retrieves an input stream of the uploaded file's contents. @return an input stream of the file's contents, or null if there was no file uploaded @throws IOException if there is an error obtaining the input stream from the uploaded file.
[ "Retrieves", "an", "input", "stream", "of", "the", "uploaded", "file", "s", "contents", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFileWidget.java#L325-L333
139,124
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTextArea.java
WTextArea.getData
@Override public Object getData() { Object data = super.getData(); if (isRichTextArea() && isSanitizeOnOutput() && data != null) { return sanitizeOutputText(data.toString()); } return data; }
java
@Override public Object getData() { Object data = super.getData(); if (isRichTextArea() && isSanitizeOnOutput() && data != null) { return sanitizeOutputText(data.toString()); } return data; }
[ "@", "Override", "public", "Object", "getData", "(", ")", "{", "Object", "data", "=", "super", ".", "getData", "(", ")", ";", "if", "(", "isRichTextArea", "(", ")", "&&", "isSanitizeOnOutput", "(", ")", "&&", "data", "!=", "null", ")", "{", "return", "sanitizeOutputText", "(", "data", ".", "toString", "(", ")", ")", ";", "}", "return", "data", ";", "}" ]
The data for this WTextArea. If the text area is not rich text its output is XML escaped so we can ignore sanitization. If the text area is a rich text area then we check the sanitizeOnOutput flag as sanitization is rather resource intensive. @return The data for this WTextArea.
[ "The", "data", "for", "this", "WTextArea", ".", "If", "the", "text", "area", "is", "not", "rich", "text", "its", "output", "is", "XML", "escaped", "so", "we", "can", "ignore", "sanitization", ".", "If", "the", "text", "area", "is", "a", "rich", "text", "area", "then", "we", "check", "the", "sanitizeOnOutput", "flag", "as", "sanitization", "is", "rather", "resource", "intensive", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTextArea.java#L31-L38
139,125
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTextArea.java
WTextArea.setData
@Override public void setData(final Object data) { if (isRichTextArea() && data instanceof String) { super.setData(sanitizeInputText((String) data)); } else { super.setData(data); } }
java
@Override public void setData(final Object data) { if (isRichTextArea() && data instanceof String) { super.setData(sanitizeInputText((String) data)); } else { super.setData(data); } }
[ "@", "Override", "public", "void", "setData", "(", "final", "Object", "data", ")", "{", "if", "(", "isRichTextArea", "(", ")", "&&", "data", "instanceof", "String", ")", "{", "super", ".", "setData", "(", "sanitizeInputText", "(", "(", "String", ")", "data", ")", ")", ";", "}", "else", "{", "super", ".", "setData", "(", "data", ")", ";", "}", "}" ]
Set data in this component. If the WTextArea is a rich text input we need to sanitize the input. @param data The input data
[ "Set", "data", "in", "this", "component", ".", "If", "the", "WTextArea", "is", "a", "rich", "text", "input", "we", "need", "to", "sanitize", "the", "input", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTextArea.java#L45-L52
139,126
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/validation/ValidationHelper.java
ValidationHelper.extractDiagnostics
public static List<Diagnostic> extractDiagnostics(final List<Diagnostic> diagnostics, final int severity) { ArrayList<Diagnostic> extract = new ArrayList<>(); for (Diagnostic diagnostic : diagnostics) { if (diagnostic.getSeverity() == severity) { extract.add(diagnostic); } } return extract; }
java
public static List<Diagnostic> extractDiagnostics(final List<Diagnostic> diagnostics, final int severity) { ArrayList<Diagnostic> extract = new ArrayList<>(); for (Diagnostic diagnostic : diagnostics) { if (diagnostic.getSeverity() == severity) { extract.add(diagnostic); } } return extract; }
[ "public", "static", "List", "<", "Diagnostic", ">", "extractDiagnostics", "(", "final", "List", "<", "Diagnostic", ">", "diagnostics", ",", "final", "int", "severity", ")", "{", "ArrayList", "<", "Diagnostic", ">", "extract", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Diagnostic", "diagnostic", ":", "diagnostics", ")", "{", "if", "(", "diagnostic", ".", "getSeverity", "(", ")", "==", "severity", ")", "{", "extract", ".", "add", "(", "diagnostic", ")", ";", "}", "}", "return", "extract", ";", "}" ]
Extract diagnostics with a given severity from a list of Diagnostic objects. This is useful for picking errors out from a list of diagnostics, for example. @param diagnostics the list of diagnostics to look through. @param severity the severity of diagnostics to extract. @return a list of diagnostics with the given severity, may be empty.
[ "Extract", "diagnostics", "with", "a", "given", "severity", "from", "a", "list", "of", "Diagnostic", "objects", ".", "This", "is", "useful", "for", "picking", "errors", "out", "from", "a", "list", "of", "diagnostics", "for", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/validation/ValidationHelper.java#L28-L39
139,127
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WCollapsibleRenderer.java
WCollapsibleRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WCollapsible collapsible = (WCollapsible) component; XmlStringBuilder xml = renderContext.getWriter(); WComponent content = collapsible.getContent(); boolean collapsed = collapsible.isCollapsed(); xml.appendTagOpen("ui:collapsible"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("groupName", collapsible.getGroupName()); xml.appendOptionalAttribute("collapsed", collapsed, "true"); xml.appendOptionalAttribute("hidden", collapsible.isHidden(), "true"); switch (collapsible.getMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case LAZY: xml.appendAttribute("mode", "lazy"); break; case EAGER: xml.appendAttribute("mode", "eager"); break; case DYNAMIC: xml.appendAttribute("mode", "dynamic"); break; case SERVER: xml.appendAttribute("mode", "server"); break; default: throw new SystemException("Unknown collapsible mode: " + collapsible.getMode()); } HeadingLevel level = collapsible.getHeadingLevel(); if (level != null) { xml.appendAttribute("level", level.getLevel()); } xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(collapsible, renderContext); // Label collapsible.getDecoratedLabel().paint(renderContext); // Content 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 trigger if (CollapsibleMode.EAGER != collapsible.getMode() || AjaxHelper.isCurrentAjaxTrigger( collapsible)) { // Visibility of content set in prepare paint content.paint(renderContext); } xml.appendEndTag("ui:content"); xml.appendEndTag("ui:collapsible"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WCollapsible collapsible = (WCollapsible) component; XmlStringBuilder xml = renderContext.getWriter(); WComponent content = collapsible.getContent(); boolean collapsed = collapsible.isCollapsed(); xml.appendTagOpen("ui:collapsible"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("groupName", collapsible.getGroupName()); xml.appendOptionalAttribute("collapsed", collapsed, "true"); xml.appendOptionalAttribute("hidden", collapsible.isHidden(), "true"); switch (collapsible.getMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case LAZY: xml.appendAttribute("mode", "lazy"); break; case EAGER: xml.appendAttribute("mode", "eager"); break; case DYNAMIC: xml.appendAttribute("mode", "dynamic"); break; case SERVER: xml.appendAttribute("mode", "server"); break; default: throw new SystemException("Unknown collapsible mode: " + collapsible.getMode()); } HeadingLevel level = collapsible.getHeadingLevel(); if (level != null) { xml.appendAttribute("level", level.getLevel()); } xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(collapsible, renderContext); // Label collapsible.getDecoratedLabel().paint(renderContext); // Content 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 trigger if (CollapsibleMode.EAGER != collapsible.getMode() || AjaxHelper.isCurrentAjaxTrigger( collapsible)) { // Visibility of content set in prepare paint content.paint(renderContext); } xml.appendEndTag("ui:content"); xml.appendEndTag("ui:collapsible"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WCollapsible", "collapsible", "=", "(", "WCollapsible", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "WComponent", "content", "=", "collapsible", ".", "getContent", "(", ")", ";", "boolean", "collapsed", "=", "collapsible", ".", "isCollapsed", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:collapsible\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"groupName\"", ",", "collapsible", ".", "getGroupName", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"collapsed\"", ",", "collapsed", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "collapsible", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "switch", "(", "collapsible", ".", "getMode", "(", ")", ")", "{", "case", "CLIENT", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"client\"", ")", ";", "break", ";", "case", "LAZY", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"lazy\"", ")", ";", "break", ";", "case", "EAGER", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"eager\"", ")", ";", "break", ";", "case", "DYNAMIC", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"dynamic\"", ")", ";", "break", ";", "case", "SERVER", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"server\"", ")", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown collapsible mode: \"", "+", "collapsible", ".", "getMode", "(", ")", ")", ";", "}", "HeadingLevel", "level", "=", "collapsible", ".", "getHeadingLevel", "(", ")", ";", "if", "(", "level", "!=", "null", ")", "{", "xml", ".", "appendAttribute", "(", "\"level\"", ",", "level", ".", "getLevel", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "// Render margin", "MarginRendererUtil", ".", "renderMargin", "(", "collapsible", ",", "renderContext", ")", ";", "// Label", "collapsible", ".", "getDecoratedLabel", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "// Content", "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 trigger", "if", "(", "CollapsibleMode", ".", "EAGER", "!=", "collapsible", ".", "getMode", "(", ")", "||", "AjaxHelper", ".", "isCurrentAjaxTrigger", "(", "collapsible", ")", ")", "{", "// Visibility of content set in prepare paint", "content", ".", "paint", "(", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:content\"", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:collapsible\"", ")", ";", "}" ]
Paints the given WCollapsible. @param component the WCollapsible to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WCollapsible", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WCollapsibleRenderer.java#L26-L89
139,128
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMultiFileWidgetExample.java
WMultiFileWidgetExample.toggleReadOnly
private void toggleReadOnly() { allFiles.setReadOnly(!allFiles.isReadOnly()); imageFiles.setReadOnly(!imageFiles.isReadOnly()); textFiles.setReadOnly(!textFiles.isReadOnly()); pdfFiles.setReadOnly(!pdfFiles.isReadOnly()); }
java
private void toggleReadOnly() { allFiles.setReadOnly(!allFiles.isReadOnly()); imageFiles.setReadOnly(!imageFiles.isReadOnly()); textFiles.setReadOnly(!textFiles.isReadOnly()); pdfFiles.setReadOnly(!pdfFiles.isReadOnly()); }
[ "private", "void", "toggleReadOnly", "(", ")", "{", "allFiles", ".", "setReadOnly", "(", "!", "allFiles", ".", "isReadOnly", "(", ")", ")", ";", "imageFiles", ".", "setReadOnly", "(", "!", "imageFiles", ".", "isReadOnly", "(", ")", ")", ";", "textFiles", ".", "setReadOnly", "(", "!", "textFiles", ".", "isReadOnly", "(", ")", ")", ";", "pdfFiles", ".", "setReadOnly", "(", "!", "pdfFiles", ".", "isReadOnly", "(", ")", ")", ";", "}" ]
Toggles the readonly state off all file widgets in the example.
[ "Toggles", "the", "readonly", "state", "off", "all", "file", "widgets", "in", "the", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMultiFileWidgetExample.java#L175-L180
139,129
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMultiFileWidgetExample.java
WMultiFileWidgetExample.processFiles
private void processFiles() { StringBuffer buf = new StringBuffer(); appendFileDetails(buf, allFiles); appendFileDetails(buf, textFiles); appendFileDetails(buf, pdfFiles); console.setText(buf.toString()); }
java
private void processFiles() { StringBuffer buf = new StringBuffer(); appendFileDetails(buf, allFiles); appendFileDetails(buf, textFiles); appendFileDetails(buf, pdfFiles); console.setText(buf.toString()); }
[ "private", "void", "processFiles", "(", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "appendFileDetails", "(", "buf", ",", "allFiles", ")", ";", "appendFileDetails", "(", "buf", ",", "textFiles", ")", ";", "appendFileDetails", "(", "buf", ",", "pdfFiles", ")", ";", "console", ".", "setText", "(", "buf", ".", "toString", "(", ")", ")", ";", "}" ]
Outputs information on the uploaded files to the text area.
[ "Outputs", "information", "on", "the", "uploaded", "files", "to", "the", "text", "area", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMultiFileWidgetExample.java#L185-L191
139,130
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMultiFileWidgetExample.java
WMultiFileWidgetExample.appendFileDetails
private void appendFileDetails(final StringBuffer buf, final WMultiFileWidget fileWidget) { List<FileWidgetUpload> files = fileWidget.getFiles(); if (files != null) { for (FileWidgetUpload file : files) { String streamedSize; try { InputStream in = file.getFile().getInputStream(); int size = 0; while (in.read() >= 0) { size++; } streamedSize = String.valueOf(size); } catch (IOException e) { streamedSize = e.getMessage(); } buf.append("Name: ").append(file.getFile().getName()); buf.append("\nSize: ").append(streamedSize).append(" bytes\n\n"); } } }
java
private void appendFileDetails(final StringBuffer buf, final WMultiFileWidget fileWidget) { List<FileWidgetUpload> files = fileWidget.getFiles(); if (files != null) { for (FileWidgetUpload file : files) { String streamedSize; try { InputStream in = file.getFile().getInputStream(); int size = 0; while (in.read() >= 0) { size++; } streamedSize = String.valueOf(size); } catch (IOException e) { streamedSize = e.getMessage(); } buf.append("Name: ").append(file.getFile().getName()); buf.append("\nSize: ").append(streamedSize).append(" bytes\n\n"); } } }
[ "private", "void", "appendFileDetails", "(", "final", "StringBuffer", "buf", ",", "final", "WMultiFileWidget", "fileWidget", ")", "{", "List", "<", "FileWidgetUpload", ">", "files", "=", "fileWidget", ".", "getFiles", "(", ")", ";", "if", "(", "files", "!=", "null", ")", "{", "for", "(", "FileWidgetUpload", "file", ":", "files", ")", "{", "String", "streamedSize", ";", "try", "{", "InputStream", "in", "=", "file", ".", "getFile", "(", ")", ".", "getInputStream", "(", ")", ";", "int", "size", "=", "0", ";", "while", "(", "in", ".", "read", "(", ")", ">=", "0", ")", "{", "size", "++", ";", "}", "streamedSize", "=", "String", ".", "valueOf", "(", "size", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "streamedSize", "=", "e", ".", "getMessage", "(", ")", ";", "}", "buf", ".", "append", "(", "\"Name: \"", ")", ".", "append", "(", "file", ".", "getFile", "(", ")", ".", "getName", "(", ")", ")", ";", "buf", ".", "append", "(", "\"\\nSize: \"", ")", ".", "append", "(", "streamedSize", ")", ".", "append", "(", "\" bytes\\n\\n\"", ")", ";", "}", "}", "}" ]
Appends details of the uploaded files to the given string buffer. @param buf the buffer to append file details to. @param fileWidget the WFieldWidget to obtain the files from.
[ "Appends", "details", "of", "the", "uploaded", "files", "to", "the", "given", "string", "buffer", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMultiFileWidgetExample.java#L199-L223
139,131
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WContent.java
WContent.getUrl
public String getUrl() { ContentAccess content = getContentAccess(); String mode = DisplayMode.PROMPT_TO_SAVE.equals(getDisplayMode()) ? "attach" : "inline"; // Check for a "static" resource if (content instanceof InternalResource) { String url = ((InternalResource) content).getTargetUrl(); // This magic parameter is a work-around to the loading indicator becoming // "stuck" in certain browsers. // It is also used by the static resource handler to set the correct headers url = url + "&" + URL_CONTENT_MODE_PARAMETER_KEY + "=" + mode; return url; } Environment env = getEnvironment(); Map<String, String> parameters = env.getHiddenParameters(); parameters.put(Environment.TARGET_ID, getTargetId()); if (Util.empty(getCacheKey())) { // Add some randomness to the URL to prevent caching String random = WebUtilities.generateRandom(); parameters.put(Environment.UNIQUE_RANDOM_PARAM, random); } else { // Remove step counter as not required for cached content parameters.remove(Environment.STEP_VARIABLE); parameters.remove(Environment.SESSION_TOKEN_VARIABLE); // Add the cache key parameters.put(Environment.CONTENT_CACHE_KEY, getCacheKey()); } // This magic parameter is a work-around to the loading indicator becoming // "stuck" in certain browsers. It is only read by the theme. parameters.put(URL_CONTENT_MODE_PARAMETER_KEY, mode); // The targetable path needs to be configured for the portal environment. String url = env.getWServletPath(); // Note the last parameter. In javascript we don't want to encode "&". return WebUtilities.getPath(url, parameters, true); }
java
public String getUrl() { ContentAccess content = getContentAccess(); String mode = DisplayMode.PROMPT_TO_SAVE.equals(getDisplayMode()) ? "attach" : "inline"; // Check for a "static" resource if (content instanceof InternalResource) { String url = ((InternalResource) content).getTargetUrl(); // This magic parameter is a work-around to the loading indicator becoming // "stuck" in certain browsers. // It is also used by the static resource handler to set the correct headers url = url + "&" + URL_CONTENT_MODE_PARAMETER_KEY + "=" + mode; return url; } Environment env = getEnvironment(); Map<String, String> parameters = env.getHiddenParameters(); parameters.put(Environment.TARGET_ID, getTargetId()); if (Util.empty(getCacheKey())) { // Add some randomness to the URL to prevent caching String random = WebUtilities.generateRandom(); parameters.put(Environment.UNIQUE_RANDOM_PARAM, random); } else { // Remove step counter as not required for cached content parameters.remove(Environment.STEP_VARIABLE); parameters.remove(Environment.SESSION_TOKEN_VARIABLE); // Add the cache key parameters.put(Environment.CONTENT_CACHE_KEY, getCacheKey()); } // This magic parameter is a work-around to the loading indicator becoming // "stuck" in certain browsers. It is only read by the theme. parameters.put(URL_CONTENT_MODE_PARAMETER_KEY, mode); // The targetable path needs to be configured for the portal environment. String url = env.getWServletPath(); // Note the last parameter. In javascript we don't want to encode "&". return WebUtilities.getPath(url, parameters, true); }
[ "public", "String", "getUrl", "(", ")", "{", "ContentAccess", "content", "=", "getContentAccess", "(", ")", ";", "String", "mode", "=", "DisplayMode", ".", "PROMPT_TO_SAVE", ".", "equals", "(", "getDisplayMode", "(", ")", ")", "?", "\"attach\"", ":", "\"inline\"", ";", "// Check for a \"static\" resource", "if", "(", "content", "instanceof", "InternalResource", ")", "{", "String", "url", "=", "(", "(", "InternalResource", ")", "content", ")", ".", "getTargetUrl", "(", ")", ";", "// This magic parameter is a work-around to the loading indicator becoming", "// \"stuck\" in certain browsers.", "// It is also used by the static resource handler to set the correct headers", "url", "=", "url", "+", "\"&\"", "+", "URL_CONTENT_MODE_PARAMETER_KEY", "+", "\"=\"", "+", "mode", ";", "return", "url", ";", "}", "Environment", "env", "=", "getEnvironment", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "parameters", "=", "env", ".", "getHiddenParameters", "(", ")", ";", "parameters", ".", "put", "(", "Environment", ".", "TARGET_ID", ",", "getTargetId", "(", ")", ")", ";", "if", "(", "Util", ".", "empty", "(", "getCacheKey", "(", ")", ")", ")", "{", "// Add some randomness to the URL to prevent caching", "String", "random", "=", "WebUtilities", ".", "generateRandom", "(", ")", ";", "parameters", ".", "put", "(", "Environment", ".", "UNIQUE_RANDOM_PARAM", ",", "random", ")", ";", "}", "else", "{", "// Remove step counter as not required for cached content", "parameters", ".", "remove", "(", "Environment", ".", "STEP_VARIABLE", ")", ";", "parameters", ".", "remove", "(", "Environment", ".", "SESSION_TOKEN_VARIABLE", ")", ";", "// Add the cache key", "parameters", ".", "put", "(", "Environment", ".", "CONTENT_CACHE_KEY", ",", "getCacheKey", "(", ")", ")", ";", "}", "// This magic parameter is a work-around to the loading indicator becoming", "// \"stuck\" in certain browsers. It is only read by the theme.", "parameters", ".", "put", "(", "URL_CONTENT_MODE_PARAMETER_KEY", ",", "mode", ")", ";", "// The targetable path needs to be configured for the portal environment.", "String", "url", "=", "env", ".", "getWServletPath", "(", ")", ";", "// Note the last parameter. In javascript we don't want to encode \"&\".", "return", "WebUtilities", ".", "getPath", "(", "url", ",", "parameters", ",", "true", ")", ";", "}" ]
Retrieves a dynamic URL which this targetable component can be accessed from. @return the URL to access this targetable component.
[ "Retrieves", "a", "dynamic", "URL", "which", "this", "targetable", "component", "can", "be", "accessed", "from", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WContent.java#L174-L214
139,132
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WListOptionsExample.java
WListOptionsExample.applySettings
private void applySettings() { container.reset(); WList list = new WList((com.github.bordertech.wcomponents.WList.Type) ddType.getSelected()); List<String> selected = (List<String>) cgBeanFields.getSelected(); SimpleListRenderer renderer = new SimpleListRenderer(selected, cbRenderUsingFieldLayout. isSelected()); list.setRepeatedComponent(renderer); list.setSeparator((Separator) ddSeparator.getSelected()); list.setRenderBorder(cbRenderBorder.isSelected()); container.add(list); List<SimpleTableBean> items = new ArrayList<>(); items.add(new SimpleTableBean("A", "none", "thing")); items.add(new SimpleTableBean("B", "some", "thing2")); items.add(new SimpleTableBean("C", "little", "thing3")); items.add(new SimpleTableBean("D", "lots", "thing4")); list.setData(items); list.setVisible(cbVisible.isSelected()); }
java
private void applySettings() { container.reset(); WList list = new WList((com.github.bordertech.wcomponents.WList.Type) ddType.getSelected()); List<String> selected = (List<String>) cgBeanFields.getSelected(); SimpleListRenderer renderer = new SimpleListRenderer(selected, cbRenderUsingFieldLayout. isSelected()); list.setRepeatedComponent(renderer); list.setSeparator((Separator) ddSeparator.getSelected()); list.setRenderBorder(cbRenderBorder.isSelected()); container.add(list); List<SimpleTableBean> items = new ArrayList<>(); items.add(new SimpleTableBean("A", "none", "thing")); items.add(new SimpleTableBean("B", "some", "thing2")); items.add(new SimpleTableBean("C", "little", "thing3")); items.add(new SimpleTableBean("D", "lots", "thing4")); list.setData(items); list.setVisible(cbVisible.isSelected()); }
[ "private", "void", "applySettings", "(", ")", "{", "container", ".", "reset", "(", ")", ";", "WList", "list", "=", "new", "WList", "(", "(", "com", ".", "github", ".", "bordertech", ".", "wcomponents", ".", "WList", ".", "Type", ")", "ddType", ".", "getSelected", "(", ")", ")", ";", "List", "<", "String", ">", "selected", "=", "(", "List", "<", "String", ">", ")", "cgBeanFields", ".", "getSelected", "(", ")", ";", "SimpleListRenderer", "renderer", "=", "new", "SimpleListRenderer", "(", "selected", ",", "cbRenderUsingFieldLayout", ".", "isSelected", "(", ")", ")", ";", "list", ".", "setRepeatedComponent", "(", "renderer", ")", ";", "list", ".", "setSeparator", "(", "(", "Separator", ")", "ddSeparator", ".", "getSelected", "(", ")", ")", ";", "list", ".", "setRenderBorder", "(", "cbRenderBorder", ".", "isSelected", "(", ")", ")", ";", "container", ".", "add", "(", "list", ")", ";", "List", "<", "SimpleTableBean", ">", "items", "=", "new", "ArrayList", "<>", "(", ")", ";", "items", ".", "add", "(", "new", "SimpleTableBean", "(", "\"A\"", ",", "\"none\"", ",", "\"thing\"", ")", ")", ";", "items", ".", "add", "(", "new", "SimpleTableBean", "(", "\"B\"", ",", "\"some\"", ",", "\"thing2\"", ")", ")", ";", "items", ".", "add", "(", "new", "SimpleTableBean", "(", "\"C\"", ",", "\"little\"", ",", "\"thing3\"", ")", ")", ";", "items", ".", "add", "(", "new", "SimpleTableBean", "(", "\"D\"", ",", "\"lots\"", ",", "\"thing4\"", ")", ")", ";", "list", ".", "setData", "(", "items", ")", ";", "list", ".", "setVisible", "(", "cbVisible", ".", "isSelected", "(", ")", ")", ";", "}" ]
Apply settings is responsible for building the list to be displayed and adding it to the container.
[ "Apply", "settings", "is", "responsible", "for", "building", "the", "list", "to", "be", "displayed", "and", "adding", "it", "to", "the", "container", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WListOptionsExample.java#L142-L164
139,133
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WNumberFieldRenderer.java
WNumberFieldRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WNumberField field = (WNumberField) component; XmlStringBuilder xml = renderContext.getWriter(); boolean readOnly = field.isReadOnly(); BigDecimal value = field.getValue(); String userText = field.getText(); xml.appendTagOpen("ui:numberfield"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", component.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { WComponent submitControl = field.getDefaultSubmitButton(); String submitControlId = submitControl == null ? null : submitControl.getId(); BigDecimal min = field.getMinValue(); BigDecimal max = field.getMaxValue(); BigDecimal step = field.getStep(); int decimals = field.getDecimalPlaces(); xml.appendOptionalAttribute("disabled", field.isDisabled(), "true"); xml.appendOptionalAttribute("required", field.isMandatory(), "true"); xml.appendOptionalAttribute("toolTip", field.getToolTip()); xml.appendOptionalAttribute("accessibleText", field.getAccessibleText()); xml.appendOptionalAttribute("min", min != null, String.valueOf(min)); xml.appendOptionalAttribute("max", max != null, String.valueOf(max)); xml.appendOptionalAttribute("step", step != null, String.valueOf(step)); xml.appendOptionalAttribute("decimals", decimals > 0, decimals); xml.appendOptionalAttribute("buttonId", submitControlId); String autocomplete = field.getAutocomplete(); xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete); } xml.appendClose(); xml.appendEscaped(value == null ? userText : value.toString()); if (!readOnly) { DiagnosticRenderUtil.renderDiagnostics(field, renderContext); } xml.appendEndTag("ui:numberfield"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WNumberField field = (WNumberField) component; XmlStringBuilder xml = renderContext.getWriter(); boolean readOnly = field.isReadOnly(); BigDecimal value = field.getValue(); String userText = field.getText(); xml.appendTagOpen("ui:numberfield"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", component.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { WComponent submitControl = field.getDefaultSubmitButton(); String submitControlId = submitControl == null ? null : submitControl.getId(); BigDecimal min = field.getMinValue(); BigDecimal max = field.getMaxValue(); BigDecimal step = field.getStep(); int decimals = field.getDecimalPlaces(); xml.appendOptionalAttribute("disabled", field.isDisabled(), "true"); xml.appendOptionalAttribute("required", field.isMandatory(), "true"); xml.appendOptionalAttribute("toolTip", field.getToolTip()); xml.appendOptionalAttribute("accessibleText", field.getAccessibleText()); xml.appendOptionalAttribute("min", min != null, String.valueOf(min)); xml.appendOptionalAttribute("max", max != null, String.valueOf(max)); xml.appendOptionalAttribute("step", step != null, String.valueOf(step)); xml.appendOptionalAttribute("decimals", decimals > 0, decimals); xml.appendOptionalAttribute("buttonId", submitControlId); String autocomplete = field.getAutocomplete(); xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete); } xml.appendClose(); xml.appendEscaped(value == null ? userText : value.toString()); if (!readOnly) { DiagnosticRenderUtil.renderDiagnostics(field, renderContext); } xml.appendEndTag("ui:numberfield"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WNumberField", "field", "=", "(", "WNumberField", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "boolean", "readOnly", "=", "field", ".", "isReadOnly", "(", ")", ";", "BigDecimal", "value", "=", "field", ".", "getValue", "(", ")", ";", "String", "userText", "=", "field", ".", "getText", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:numberfield\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "component", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "readOnly", ")", "{", "xml", ".", "appendAttribute", "(", "\"readOnly\"", ",", "\"true\"", ")", ";", "}", "else", "{", "WComponent", "submitControl", "=", "field", ".", "getDefaultSubmitButton", "(", ")", ";", "String", "submitControlId", "=", "submitControl", "==", "null", "?", "null", ":", "submitControl", ".", "getId", "(", ")", ";", "BigDecimal", "min", "=", "field", ".", "getMinValue", "(", ")", ";", "BigDecimal", "max", "=", "field", ".", "getMaxValue", "(", ")", ";", "BigDecimal", "step", "=", "field", ".", "getStep", "(", ")", ";", "int", "decimals", "=", "field", ".", "getDecimalPlaces", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "field", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"required\"", ",", "field", ".", "isMandatory", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "field", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessibleText\"", ",", "field", ".", "getAccessibleText", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"min\"", ",", "min", "!=", "null", ",", "String", ".", "valueOf", "(", "min", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"max\"", ",", "max", "!=", "null", ",", "String", ".", "valueOf", "(", "max", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"step\"", ",", "step", "!=", "null", ",", "String", ".", "valueOf", "(", "step", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"decimals\"", ",", "decimals", ">", "0", ",", "decimals", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"buttonId\"", ",", "submitControlId", ")", ";", "String", "autocomplete", "=", "field", ".", "getAutocomplete", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"autocomplete\"", ",", "!", "Util", ".", "empty", "(", "autocomplete", ")", ",", "autocomplete", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "xml", ".", "appendEscaped", "(", "value", "==", "null", "?", "userText", ":", "value", ".", "toString", "(", ")", ")", ";", "if", "(", "!", "readOnly", ")", "{", "DiagnosticRenderUtil", ".", "renderDiagnostics", "(", "field", ",", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:numberfield\"", ")", ";", "}" ]
Paints the given WNumberField. @param component the WNumberField to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WNumberField", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WNumberFieldRenderer.java#L25-L69
139,134
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/WhiteSpaceFilterPrintWriter.java
WhiteSpaceFilterPrintWriter.write
@Override public void write(final int c) { WhiteSpaceFilterStateMachine.StateChange change = stateMachine.nextState((char) c); if (change.getOutputBytes() != null) { for (int i = 0; i < change.getOutputBytes().length; i++) { super.write(change.getOutputBytes()[i]); } } if (!change.isSuppressCurrentChar()) { super.write(c); } }
java
@Override public void write(final int c) { WhiteSpaceFilterStateMachine.StateChange change = stateMachine.nextState((char) c); if (change.getOutputBytes() != null) { for (int i = 0; i < change.getOutputBytes().length; i++) { super.write(change.getOutputBytes()[i]); } } if (!change.isSuppressCurrentChar()) { super.write(c); } }
[ "@", "Override", "public", "void", "write", "(", "final", "int", "c", ")", "{", "WhiteSpaceFilterStateMachine", ".", "StateChange", "change", "=", "stateMachine", ".", "nextState", "(", "(", "char", ")", "c", ")", ";", "if", "(", "change", ".", "getOutputBytes", "(", ")", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "change", ".", "getOutputBytes", "(", ")", ".", "length", ";", "i", "++", ")", "{", "super", ".", "write", "(", "change", ".", "getOutputBytes", "(", ")", "[", "i", "]", ")", ";", "}", "}", "if", "(", "!", "change", ".", "isSuppressCurrentChar", "(", ")", ")", "{", "super", ".", "write", "(", "c", ")", ";", "}", "}" ]
Writes the given byte to the underlying output stream if it passes filtering. @param c the byte to write.
[ "Writes", "the", "given", "byte", "to", "the", "underlying", "output", "stream", "if", "it", "passes", "filtering", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/WhiteSpaceFilterPrintWriter.java#L34-L47
139,135
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/WhiteSpaceFilterPrintWriter.java
WhiteSpaceFilterPrintWriter.write
@Override public void write(final String string, final int off, final int len) { for (int i = off; i < off + len; i++) { write(string.charAt(i)); } }
java
@Override public void write(final String string, final int off, final int len) { for (int i = off; i < off + len; i++) { write(string.charAt(i)); } }
[ "@", "Override", "public", "void", "write", "(", "final", "String", "string", ",", "final", "int", "off", ",", "final", "int", "len", ")", "{", "for", "(", "int", "i", "=", "off", ";", "i", "<", "off", "+", "len", ";", "i", "++", ")", "{", "write", "(", "string", ".", "charAt", "(", "i", ")", ")", ";", "}", "}" ]
Writes the given String to the underlying output stream, filtering as necessary. @param string the String to write. @param off the position in the string to start writing data from. @param len the number of characters to write.
[ "Writes", "the", "given", "String", "to", "the", "underlying", "output", "stream", "filtering", "as", "necessary", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/WhiteSpaceFilterPrintWriter.java#L70-L75
139,136
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/Or.java
Or.execute
@Override protected boolean execute(final Request request) { for (Condition condition : conditions) { if (condition.isTrue(request)) { return true; } } return false; }
java
@Override protected boolean execute(final Request request) { for (Condition condition : conditions) { if (condition.isTrue(request)) { return true; } } return false; }
[ "@", "Override", "protected", "boolean", "execute", "(", "final", "Request", "request", ")", "{", "for", "(", "Condition", "condition", ":", "conditions", ")", "{", "if", "(", "condition", ".", "isTrue", "(", "request", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Evaluates the condition using values on the Request. Note that this uses the short-circuit or operator, so condition 'b' will not necessarily be evaluated. @param request the request being processed. @return true if either of the conditions are true, otherwise false
[ "Evaluates", "the", "condition", "using", "values", "on", "the", "Request", ".", "Note", "that", "this", "uses", "the", "short", "-", "circuit", "or", "operator", "so", "condition", "b", "will", "not", "necessarily", "be", "evaluated", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/Or.java#L73-L82
139,137
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/TQAssocBean.java
TQAssocBean.fetch
public R fetch(String properties) { ((TQRootBean) _root).query().fetch(_name, properties); return _root; }
java
public R fetch(String properties) { ((TQRootBean) _root).query().fetch(_name, properties); return _root; }
[ "public", "R", "fetch", "(", "String", "properties", ")", "{", "(", "(", "TQRootBean", ")", "_root", ")", ".", "query", "(", ")", ".", "fetch", "(", "_name", ",", "properties", ")", ";", "return", "_root", ";", "}" ]
Eagerly fetch this association with the properties specified.
[ "Eagerly", "fetch", "this", "association", "with", "the", "properties", "specified", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQAssocBean.java#L58-L61
139,138
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/TQAssocBean.java
TQAssocBean.fetchQuery
public R fetchQuery(String properties) { ((TQRootBean) _root).query().fetchQuery(_name, properties); return _root; }
java
public R fetchQuery(String properties) { ((TQRootBean) _root).query().fetchQuery(_name, properties); return _root; }
[ "public", "R", "fetchQuery", "(", "String", "properties", ")", "{", "(", "(", "TQRootBean", ")", "_root", ")", ".", "query", "(", ")", ".", "fetchQuery", "(", "_name", ",", "properties", ")", ";", "return", "_root", ";", "}" ]
Eagerly fetch this association using a "query join" with the properties specified.
[ "Eagerly", "fetch", "this", "association", "using", "a", "query", "join", "with", "the", "properties", "specified", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQAssocBean.java#L66-L69
139,139
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/TQAssocBean.java
TQAssocBean.fetchProperties
protected R fetchProperties(TQProperty<?>... props) { ((TQRootBean) _root).query().fetch(_name, properties(props)); return _root; }
java
protected R fetchProperties(TQProperty<?>... props) { ((TQRootBean) _root).query().fetch(_name, properties(props)); return _root; }
[ "protected", "R", "fetchProperties", "(", "TQProperty", "<", "?", ">", "...", "props", ")", "{", "(", "(", "TQRootBean", ")", "_root", ")", ".", "query", "(", ")", ".", "fetch", "(", "_name", ",", "properties", "(", "props", ")", ")", ";", "return", "_root", ";", "}" ]
Eagerly fetch this association fetching some of the properties.
[ "Eagerly", "fetch", "this", "association", "fetching", "some", "of", "the", "properties", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQAssocBean.java#L83-L86
139,140
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/TQAssocBean.java
TQAssocBean.properties
protected String properties(TQProperty<?>... props) { StringBuilder selectProps = new StringBuilder(50); for (int i = 0; i < props.length; i++) { if (i > 0) { selectProps.append(","); } selectProps.append(props[i].propertyName()); } return selectProps.toString(); }
java
protected String properties(TQProperty<?>... props) { StringBuilder selectProps = new StringBuilder(50); for (int i = 0; i < props.length; i++) { if (i > 0) { selectProps.append(","); } selectProps.append(props[i].propertyName()); } return selectProps.toString(); }
[ "protected", "String", "properties", "(", "TQProperty", "<", "?", ">", "...", "props", ")", "{", "StringBuilder", "selectProps", "=", "new", "StringBuilder", "(", "50", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "props", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "selectProps", ".", "append", "(", "\",\"", ")", ";", "}", "selectProps", ".", "append", "(", "props", "[", "i", "]", ".", "propertyName", "(", ")", ")", ";", "}", "return", "selectProps", ".", "toString", "(", ")", ";", "}" ]
Append the properties as a comma delimited string.
[ "Append", "the", "properties", "as", "a", "comma", "delimited", "string", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQAssocBean.java#L107-L116
139,141
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/TQAssocBean.java
TQAssocBean.filterMany
public R filterMany(ExpressionList<T> filter) { @SuppressWarnings("unchecked") ExpressionList<T> expressionList = (ExpressionList<T>) expr().filterMany(_name); expressionList.addAll(filter); return _root; }
java
public R filterMany(ExpressionList<T> filter) { @SuppressWarnings("unchecked") ExpressionList<T> expressionList = (ExpressionList<T>) expr().filterMany(_name); expressionList.addAll(filter); return _root; }
[ "public", "R", "filterMany", "(", "ExpressionList", "<", "T", ">", "filter", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "ExpressionList", "<", "T", ">", "expressionList", "=", "(", "ExpressionList", "<", "T", ">", ")", "expr", "(", ")", ".", "filterMany", "(", "_name", ")", ";", "expressionList", ".", "addAll", "(", "filter", ")", ";", "return", "_root", ";", "}" ]
Apply a filter when fetching these beans.
[ "Apply", "a", "filter", "when", "fetching", "these", "beans", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQAssocBean.java#L151-L157
139,142
podio/podio-java
src/main/java/com/podio/calendar/CalendarAPI.java
CalendarAPI.getApp
public List<Event> getApp(int appId, LocalDate dateFrom, LocalDate dateTo, ReferenceType... types) { return getCalendar("app/" + appId, dateFrom, dateTo, null, types); }
java
public List<Event> getApp(int appId, LocalDate dateFrom, LocalDate dateTo, ReferenceType... types) { return getCalendar("app/" + appId, dateFrom, dateTo, null, types); }
[ "public", "List", "<", "Event", ">", "getApp", "(", "int", "appId", ",", "LocalDate", "dateFrom", ",", "LocalDate", "dateTo", ",", "ReferenceType", "...", "types", ")", "{", "return", "getCalendar", "(", "\"app/\"", "+", "appId", ",", "dateFrom", ",", "dateTo", ",", "null", ",", "types", ")", ";", "}" ]
Returns the items and tasks that are related to the given app. @param appId The id of the app @param dateFrom The from date @param dateTo The to date @param types The types of events that should be returned. Leave out to get all types of events. @return The events in the calendar
[ "Returns", "the", "items", "and", "tasks", "that", "are", "related", "to", "the", "given", "app", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/calendar/CalendarAPI.java#L63-L66
139,143
podio/podio-java
src/main/java/com/podio/calendar/CalendarAPI.java
CalendarAPI.getSpace
public List<Event> getSpace(int spaceId, LocalDate dateFrom, LocalDate dateTo, ReferenceType... types) { return getCalendar("space/" + spaceId, dateFrom, dateTo, null, types); }
java
public List<Event> getSpace(int spaceId, LocalDate dateFrom, LocalDate dateTo, ReferenceType... types) { return getCalendar("space/" + spaceId, dateFrom, dateTo, null, types); }
[ "public", "List", "<", "Event", ">", "getSpace", "(", "int", "spaceId", ",", "LocalDate", "dateFrom", ",", "LocalDate", "dateTo", ",", "ReferenceType", "...", "types", ")", "{", "return", "getCalendar", "(", "\"space/\"", "+", "spaceId", ",", "dateFrom", ",", "dateTo", ",", "null", ",", "types", ")", ";", "}" ]
Returns all items and tasks that the user have access to in the given space. Tasks with reference to other spaces are not returned or tasks with no reference. @param spaceId The id of the space @param dateFrom The from date @param dateTo The to date @param types The types of events that should be returned. Leave out to get all types of events. @return The events in the calendar
[ "Returns", "all", "items", "and", "tasks", "that", "the", "user", "have", "access", "to", "in", "the", "given", "space", ".", "Tasks", "with", "reference", "to", "other", "spaces", "are", "not", "returned", "or", "tasks", "with", "no", "reference", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/calendar/CalendarAPI.java#L84-L87
139,144
podio/podio-java
src/main/java/com/podio/calendar/CalendarAPI.java
CalendarAPI.getGlobal
public List<Event> getGlobal(LocalDate dateFrom, LocalDate dateTo, List<Integer> spaceIds, ReferenceType... types) { return getCalendar("", dateFrom, dateTo, spaceIds, types); }
java
public List<Event> getGlobal(LocalDate dateFrom, LocalDate dateTo, List<Integer> spaceIds, ReferenceType... types) { return getCalendar("", dateFrom, dateTo, spaceIds, types); }
[ "public", "List", "<", "Event", ">", "getGlobal", "(", "LocalDate", "dateFrom", ",", "LocalDate", "dateTo", ",", "List", "<", "Integer", ">", "spaceIds", ",", "ReferenceType", "...", "types", ")", "{", "return", "getCalendar", "(", "\"\"", ",", "dateFrom", ",", "dateTo", ",", "spaceIds", ",", "types", ")", ";", "}" ]
Returns all items that the user have access to and all tasks that are assigned to the user. The items and tasks can be filtered by a list of space ids, but tasks without a reference will always be returned. @param dateFrom The from date @param dateTo The to date @param types The types of events that should be returned. Leave out to get all types of events. @return The events in the calendar
[ "Returns", "all", "items", "that", "the", "user", "have", "access", "to", "and", "all", "tasks", "that", "are", "assigned", "to", "the", "user", ".", "The", "items", "and", "tasks", "can", "be", "filtered", "by", "a", "list", "of", "space", "ids", "but", "tasks", "without", "a", "reference", "will", "always", "be", "returned", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/calendar/CalendarAPI.java#L103-L106
139,145
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPasswordFieldRenderer.java
WPasswordFieldRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WPasswordField field = (WPasswordField) component; XmlStringBuilder xml = renderContext.getWriter(); boolean readOnly = field.isReadOnly(); xml.appendTagOpen(TAG_NAME); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", component.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); xml.appendEnd(); return; } int cols = field.getColumns(); int minLength = field.getMinLength(); int maxLength = field.getMaxLength(); WComponent submitControl = field.getDefaultSubmitButton(); String submitControlId = submitControl == null ? null : submitControl.getId(); xml.appendOptionalAttribute("disabled", field.isDisabled(), "true"); xml.appendOptionalAttribute("required", field.isMandatory(), "true"); xml.appendOptionalAttribute("minLength", minLength > 0, minLength); xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength); xml.appendOptionalAttribute("toolTip", field.getToolTip()); xml.appendOptionalAttribute("accessibleText", field.getAccessibleText()); xml.appendOptionalAttribute("size", cols > 0, cols); xml.appendOptionalAttribute("buttonId", submitControlId); String placeholder = field.getPlaceholder(); xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder); String autocomplete = field.getAutocomplete(); xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete); List<Diagnostic> diags = field.getDiagnostics(Diagnostic.ERROR); if (diags == null || diags.isEmpty()) { xml.appendEnd(); return; } xml.appendClose(); DiagnosticRenderUtil.renderDiagnostics(field, renderContext); xml.appendEndTag(TAG_NAME); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WPasswordField field = (WPasswordField) component; XmlStringBuilder xml = renderContext.getWriter(); boolean readOnly = field.isReadOnly(); xml.appendTagOpen(TAG_NAME); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", component.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); xml.appendEnd(); return; } int cols = field.getColumns(); int minLength = field.getMinLength(); int maxLength = field.getMaxLength(); WComponent submitControl = field.getDefaultSubmitButton(); String submitControlId = submitControl == null ? null : submitControl.getId(); xml.appendOptionalAttribute("disabled", field.isDisabled(), "true"); xml.appendOptionalAttribute("required", field.isMandatory(), "true"); xml.appendOptionalAttribute("minLength", minLength > 0, minLength); xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength); xml.appendOptionalAttribute("toolTip", field.getToolTip()); xml.appendOptionalAttribute("accessibleText", field.getAccessibleText()); xml.appendOptionalAttribute("size", cols > 0, cols); xml.appendOptionalAttribute("buttonId", submitControlId); String placeholder = field.getPlaceholder(); xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder); String autocomplete = field.getAutocomplete(); xml.appendOptionalAttribute("autocomplete", !Util.empty(autocomplete), autocomplete); List<Diagnostic> diags = field.getDiagnostics(Diagnostic.ERROR); if (diags == null || diags.isEmpty()) { xml.appendEnd(); return; } xml.appendClose(); DiagnosticRenderUtil.renderDiagnostics(field, renderContext); xml.appendEndTag(TAG_NAME); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WPasswordField", "field", "=", "(", "WPasswordField", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "boolean", "readOnly", "=", "field", ".", "isReadOnly", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "TAG_NAME", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "component", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "readOnly", ")", "{", "xml", ".", "appendAttribute", "(", "\"readOnly\"", ",", "\"true\"", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "return", ";", "}", "int", "cols", "=", "field", ".", "getColumns", "(", ")", ";", "int", "minLength", "=", "field", ".", "getMinLength", "(", ")", ";", "int", "maxLength", "=", "field", ".", "getMaxLength", "(", ")", ";", "WComponent", "submitControl", "=", "field", ".", "getDefaultSubmitButton", "(", ")", ";", "String", "submitControlId", "=", "submitControl", "==", "null", "?", "null", ":", "submitControl", ".", "getId", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "field", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"required\"", ",", "field", ".", "isMandatory", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"minLength\"", ",", "minLength", ">", "0", ",", "minLength", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"maxLength\"", ",", "maxLength", ">", "0", ",", "maxLength", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "field", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessibleText\"", ",", "field", ".", "getAccessibleText", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"size\"", ",", "cols", ">", "0", ",", "cols", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"buttonId\"", ",", "submitControlId", ")", ";", "String", "placeholder", "=", "field", ".", "getPlaceholder", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"placeholder\"", ",", "!", "Util", ".", "empty", "(", "placeholder", ")", ",", "placeholder", ")", ";", "String", "autocomplete", "=", "field", ".", "getAutocomplete", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"autocomplete\"", ",", "!", "Util", ".", "empty", "(", "autocomplete", ")", ",", "autocomplete", ")", ";", "List", "<", "Diagnostic", ">", "diags", "=", "field", ".", "getDiagnostics", "(", "Diagnostic", ".", "ERROR", ")", ";", "if", "(", "diags", "==", "null", "||", "diags", ".", "isEmpty", "(", ")", ")", "{", "xml", ".", "appendEnd", "(", ")", ";", "return", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "DiagnosticRenderUtil", ".", "renderDiagnostics", "(", "field", ",", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "TAG_NAME", ")", ";", "}" ]
Paints the given WPasswordField. @param component the WPasswordField to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WPasswordField", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPasswordFieldRenderer.java#L30-L75
139,146
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/SafetyContainer.java
SafetyContainer.handleRequest
@Override public void handleRequest(final Request request) { if (!isInitialised()) { getOrCreateComponentModel().delegate = new SafetyContainerDelegate(UIContextHolder. getCurrent()); setInitialised(true); } try { UIContext delegate = getComponentModel().delegate; UIContextHolder.pushContext(delegate); try { for (int i = 0; i < shim.getChildCount(); i++) { shim.getChildAt(i).serviceRequest(request); } delegate.doInvokeLaters(); } finally { UIContextHolder.popContext(); } } catch (final ActionEscape e) { // We don't want to catch ActionEscapes (e.g. ForwardExceptions) throw e; } catch (final Exception e) { if (isAjaxOrTargetedRequest(request)) { throw new SystemException(e.getMessage(), e); } else { setAttribute(ERROR_KEY, e); } } }
java
@Override public void handleRequest(final Request request) { if (!isInitialised()) { getOrCreateComponentModel().delegate = new SafetyContainerDelegate(UIContextHolder. getCurrent()); setInitialised(true); } try { UIContext delegate = getComponentModel().delegate; UIContextHolder.pushContext(delegate); try { for (int i = 0; i < shim.getChildCount(); i++) { shim.getChildAt(i).serviceRequest(request); } delegate.doInvokeLaters(); } finally { UIContextHolder.popContext(); } } catch (final ActionEscape e) { // We don't want to catch ActionEscapes (e.g. ForwardExceptions) throw e; } catch (final Exception e) { if (isAjaxOrTargetedRequest(request)) { throw new SystemException(e.getMessage(), e); } else { setAttribute(ERROR_KEY, e); } } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "if", "(", "!", "isInitialised", "(", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "delegate", "=", "new", "SafetyContainerDelegate", "(", "UIContextHolder", ".", "getCurrent", "(", ")", ")", ";", "setInitialised", "(", "true", ")", ";", "}", "try", "{", "UIContext", "delegate", "=", "getComponentModel", "(", ")", ".", "delegate", ";", "UIContextHolder", ".", "pushContext", "(", "delegate", ")", ";", "try", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "shim", ".", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "shim", ".", "getChildAt", "(", "i", ")", ".", "serviceRequest", "(", "request", ")", ";", "}", "delegate", ".", "doInvokeLaters", "(", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "catch", "(", "final", "ActionEscape", "e", ")", "{", "// We don't want to catch ActionEscapes (e.g. ForwardExceptions)", "throw", "e", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "if", "(", "isAjaxOrTargetedRequest", "(", "request", ")", ")", "{", "throw", "new", "SystemException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "else", "{", "setAttribute", "(", "ERROR_KEY", ",", "e", ")", ";", "}", "}", "}" ]
Override handleRequest in order to safely process the example component, which has been excluded from normal WComponent processing. @param request the request being responded to.
[ "Override", "handleRequest", "in", "order", "to", "safely", "process", "the", "example", "component", "which", "has", "been", "excluded", "from", "normal", "WComponent", "processing", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/SafetyContainer.java#L55-L86
139,147
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/SafetyContainer.java
SafetyContainer.resetContent
public void resetContent() { for (int i = 0; i < shim.getChildCount(); i++) { WComponent child = shim.getChildAt(i); child.reset(); } removeAttribute(SafetyContainer.ERROR_KEY); }
java
public void resetContent() { for (int i = 0; i < shim.getChildCount(); i++) { WComponent child = shim.getChildAt(i); child.reset(); } removeAttribute(SafetyContainer.ERROR_KEY); }
[ "public", "void", "resetContent", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "shim", ".", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "WComponent", "child", "=", "shim", ".", "getChildAt", "(", "i", ")", ";", "child", ".", "reset", "(", ")", ";", "}", "removeAttribute", "(", "SafetyContainer", ".", "ERROR_KEY", ")", ";", "}" ]
Resets the contents.
[ "Resets", "the", "contents", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/SafetyContainer.java#L170-L177
139,148
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WRadioButtonRenderer.java
WRadioButtonRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WRadioButton button = (WRadioButton) component; XmlStringBuilder xml = renderContext.getWriter(); boolean readOnly = button.isReadOnly(); String value = button.getValue(); xml.appendTagOpen("ui:radiobutton"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", button.isHidden(), "true"); xml.appendAttribute("groupName", button.getGroupName()); xml.appendAttribute("value", WebUtilities.encode(value)); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { xml.appendOptionalAttribute("disabled", button.isDisabled(), "true"); xml.appendOptionalAttribute("required", button.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", button.isSubmitOnChange(), "true"); xml.appendOptionalAttribute("toolTip", button.getToolTip()); xml.appendOptionalAttribute("accessibleText", button.getAccessibleText()); // Check for null option (ie null or empty). Match isEmpty() logic. boolean isNull = value == null ? true : (value.length() == 0); xml.appendOptionalAttribute("isNull", isNull, "true"); } xml.appendOptionalAttribute("selected", button.isSelected(), "true"); xml.appendEnd(); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WRadioButton button = (WRadioButton) component; XmlStringBuilder xml = renderContext.getWriter(); boolean readOnly = button.isReadOnly(); String value = button.getValue(); xml.appendTagOpen("ui:radiobutton"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", button.isHidden(), "true"); xml.appendAttribute("groupName", button.getGroupName()); xml.appendAttribute("value", WebUtilities.encode(value)); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { xml.appendOptionalAttribute("disabled", button.isDisabled(), "true"); xml.appendOptionalAttribute("required", button.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", button.isSubmitOnChange(), "true"); xml.appendOptionalAttribute("toolTip", button.getToolTip()); xml.appendOptionalAttribute("accessibleText", button.getAccessibleText()); // Check for null option (ie null or empty). Match isEmpty() logic. boolean isNull = value == null ? true : (value.length() == 0); xml.appendOptionalAttribute("isNull", isNull, "true"); } xml.appendOptionalAttribute("selected", button.isSelected(), "true"); xml.appendEnd(); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WRadioButton", "button", "=", "(", "WRadioButton", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "boolean", "readOnly", "=", "button", ".", "isReadOnly", "(", ")", ";", "String", "value", "=", "button", ".", "getValue", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:radiobutton\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "button", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"groupName\"", ",", "button", ".", "getGroupName", "(", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"value\"", ",", "WebUtilities", ".", "encode", "(", "value", ")", ")", ";", "if", "(", "readOnly", ")", "{", "xml", ".", "appendAttribute", "(", "\"readOnly\"", ",", "\"true\"", ")", ";", "}", "else", "{", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "button", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"required\"", ",", "button", ".", "isMandatory", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"submitOnChange\"", ",", "button", ".", "isSubmitOnChange", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "button", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessibleText\"", ",", "button", ".", "getAccessibleText", "(", ")", ")", ";", "// Check for null option (ie null or empty). Match isEmpty() logic.", "boolean", "isNull", "=", "value", "==", "null", "?", "true", ":", "(", "value", ".", "length", "(", ")", "==", "0", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"isNull\"", ",", "isNull", ",", "\"true\"", ")", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"selected\"", ",", "button", ".", "isSelected", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}" ]
Paints the given WRadioButton. @param component the WRadioButton to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WRadioButton", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WRadioButtonRenderer.java#L24-L53
139,149
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTabGroupRenderer.java
WTabGroupRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTabGroup group = (WTabGroup) component; paintChildren(group, renderContext); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTabGroup group = (WTabGroup) component; paintChildren(group, renderContext); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTabGroup", "group", "=", "(", "WTabGroup", ")", "component", ";", "paintChildren", "(", "group", ",", "renderContext", ")", ";", "}" ]
Paints the given WTabGroup. @param component the WTabGroup to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTabGroup", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTabGroupRenderer.java#L23-L27
139,150
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/DefaultPageShell.java
DefaultPageShell.getApplicationTitle
private String getApplicationTitle(final UIContext uic) { WComponent root = uic.getUI(); String title = root instanceof WApplication ? ((WApplication) root).getTitle() : null; Map<String, String> params = uic.getEnvironment().getHiddenParameters(); String target = params.get(WWindow.WWINDOW_REQUEST_PARAM_KEY); if (target != null) { ComponentWithContext targetComp = WebUtilities.getComponentById(target, true); if (targetComp != null && targetComp.getComponent() instanceof WWindow) { try { UIContextHolder.pushContext(targetComp.getContext()); title = ((WWindow) targetComp.getComponent()).getTitle(); } finally { UIContextHolder.popContext(); } } } return title == null ? "" : title; }
java
private String getApplicationTitle(final UIContext uic) { WComponent root = uic.getUI(); String title = root instanceof WApplication ? ((WApplication) root).getTitle() : null; Map<String, String> params = uic.getEnvironment().getHiddenParameters(); String target = params.get(WWindow.WWINDOW_REQUEST_PARAM_KEY); if (target != null) { ComponentWithContext targetComp = WebUtilities.getComponentById(target, true); if (targetComp != null && targetComp.getComponent() instanceof WWindow) { try { UIContextHolder.pushContext(targetComp.getContext()); title = ((WWindow) targetComp.getComponent()).getTitle(); } finally { UIContextHolder.popContext(); } } } return title == null ? "" : title; }
[ "private", "String", "getApplicationTitle", "(", "final", "UIContext", "uic", ")", "{", "WComponent", "root", "=", "uic", ".", "getUI", "(", ")", ";", "String", "title", "=", "root", "instanceof", "WApplication", "?", "(", "(", "WApplication", ")", "root", ")", ".", "getTitle", "(", ")", ":", "null", ";", "Map", "<", "String", ",", "String", ">", "params", "=", "uic", ".", "getEnvironment", "(", ")", ".", "getHiddenParameters", "(", ")", ";", "String", "target", "=", "params", ".", "get", "(", "WWindow", ".", "WWINDOW_REQUEST_PARAM_KEY", ")", ";", "if", "(", "target", "!=", "null", ")", "{", "ComponentWithContext", "targetComp", "=", "WebUtilities", ".", "getComponentById", "(", "target", ",", "true", ")", ";", "if", "(", "targetComp", "!=", "null", "&&", "targetComp", ".", "getComponent", "(", ")", "instanceof", "WWindow", ")", "{", "try", "{", "UIContextHolder", ".", "pushContext", "(", "targetComp", ".", "getContext", "(", ")", ")", ";", "title", "=", "(", "(", "WWindow", ")", "targetComp", ".", "getComponent", "(", ")", ")", ".", "getTitle", "(", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "}", "return", "title", "==", "null", "?", "\"\"", ":", "title", ";", "}" ]
Retrieves the application title for the given context. This mess is required due to WWindow essentially existing as a separate UI root. If WWindow is eventually removed, then we can just retrieve the title from the root WApplication. @param uic the context to check. @return the current application title.
[ "Retrieves", "the", "application", "title", "for", "the", "given", "context", ".", "This", "mess", "is", "required", "due", "to", "WWindow", "essentially", "existing", "as", "a", "separate", "UI", "root", ".", "If", "WWindow", "is", "eventually", "removed", "then", "we", "can", "just", "retrieve", "the", "title", "from", "the", "root", "WApplication", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/DefaultPageShell.java#L70-L91
139,151
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRowRendererRenderer.java
WDataTableRowRendererRenderer.getFilterValues
private String getFilterValues(final TableDataModel dataModel, final int rowIndex) { List<String> filterValues = dataModel.getFilterValues(rowIndex); if (filterValues == null || filterValues.isEmpty()) { return null; } StringBuffer buf = new StringBuffer(filterValues.get(0)); for (int i = 1; i < filterValues.size(); i++) { buf.append(", "); buf.append(filterValues.get(i)); } return buf.toString(); }
java
private String getFilterValues(final TableDataModel dataModel, final int rowIndex) { List<String> filterValues = dataModel.getFilterValues(rowIndex); if (filterValues == null || filterValues.isEmpty()) { return null; } StringBuffer buf = new StringBuffer(filterValues.get(0)); for (int i = 1; i < filterValues.size(); i++) { buf.append(", "); buf.append(filterValues.get(i)); } return buf.toString(); }
[ "private", "String", "getFilterValues", "(", "final", "TableDataModel", "dataModel", ",", "final", "int", "rowIndex", ")", "{", "List", "<", "String", ">", "filterValues", "=", "dataModel", ".", "getFilterValues", "(", "rowIndex", ")", ";", "if", "(", "filterValues", "==", "null", "||", "filterValues", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "filterValues", ".", "get", "(", "0", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "filterValues", ".", "size", "(", ")", ";", "i", "++", ")", "{", "buf", ".", "append", "(", "\", \"", ")", ";", "buf", ".", "append", "(", "filterValues", ".", "get", "(", "i", ")", ")", ";", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Retrieves the filter values for the given row in the data model, as a comma-separated string. @param dataModel the data model. @param rowIndex the row index. @return the filter values string.
[ "Retrieves", "the", "filter", "values", "for", "the", "given", "row", "in", "the", "data", "model", "as", "a", "comma", "-", "separated", "string", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRowRendererRenderer.java#L163-L178
139,152
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.getRenderer
public static Renderer getRenderer(final WComponent component, final RenderContext context) { Class<? extends WComponent> clazz = component.getClass(); Duplet<String, Class<?>> key = new Duplet<String, Class<?>>(context.getRenderPackage(), clazz); Renderer renderer = INSTANCE.renderers.get(key); if (renderer == null) { renderer = INSTANCE.findRenderer(component, key); } else if (renderer == NULL_RENDERER) { return null; } return renderer; }
java
public static Renderer getRenderer(final WComponent component, final RenderContext context) { Class<? extends WComponent> clazz = component.getClass(); Duplet<String, Class<?>> key = new Duplet<String, Class<?>>(context.getRenderPackage(), clazz); Renderer renderer = INSTANCE.renderers.get(key); if (renderer == null) { renderer = INSTANCE.findRenderer(component, key); } else if (renderer == NULL_RENDERER) { return null; } return renderer; }
[ "public", "static", "Renderer", "getRenderer", "(", "final", "WComponent", "component", ",", "final", "RenderContext", "context", ")", "{", "Class", "<", "?", "extends", "WComponent", ">", "clazz", "=", "component", ".", "getClass", "(", ")", ";", "Duplet", "<", "String", ",", "Class", "<", "?", ">", ">", "key", "=", "new", "Duplet", "<", "String", ",", "Class", "<", "?", ">", ">", "(", "context", ".", "getRenderPackage", "(", ")", ",", "clazz", ")", ";", "Renderer", "renderer", "=", "INSTANCE", ".", "renderers", ".", "get", "(", "key", ")", ";", "if", "(", "renderer", "==", "null", ")", "{", "renderer", "=", "INSTANCE", ".", "findRenderer", "(", "component", ",", "key", ")", ";", "}", "else", "if", "(", "renderer", "==", "NULL_RENDERER", ")", "{", "return", "null", ";", "}", "return", "renderer", ";", "}" ]
Retrieves a renderer which can renderer the given component to the context. @param component the component to retrieve the renderer for. @param context the render context. @return an appropriate renderer for the component and context, or null if a suitable renderer could not be found.
[ "Retrieves", "a", "renderer", "which", "can", "renderer", "the", "given", "component", "to", "the", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L120-L134
139,153
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.getTemplateRenderer
@Deprecated public static Renderer getTemplateRenderer(final RenderContext context) { String packageName = context.getRenderPackage(); Renderer renderer = INSTANCE.templateRenderers.get(packageName); if (renderer == null) { renderer = INSTANCE.findTemplateRenderer(packageName); } else if (renderer == NULL_RENDERER) { return null; } return renderer; }
java
@Deprecated public static Renderer getTemplateRenderer(final RenderContext context) { String packageName = context.getRenderPackage(); Renderer renderer = INSTANCE.templateRenderers.get(packageName); if (renderer == null) { renderer = INSTANCE.findTemplateRenderer(packageName); } else if (renderer == NULL_RENDERER) { return null; } return renderer; }
[ "@", "Deprecated", "public", "static", "Renderer", "getTemplateRenderer", "(", "final", "RenderContext", "context", ")", "{", "String", "packageName", "=", "context", ".", "getRenderPackage", "(", ")", ";", "Renderer", "renderer", "=", "INSTANCE", ".", "templateRenderers", ".", "get", "(", "packageName", ")", ";", "if", "(", "renderer", "==", "null", ")", "{", "renderer", "=", "INSTANCE", ".", "findTemplateRenderer", "(", "packageName", ")", ";", "}", "else", "if", "(", "renderer", "==", "NULL_RENDERER", ")", "{", "return", "null", ";", "}", "return", "renderer", ";", "}" ]
Retrieves a renderer which can renderer templates for the given context. @param context the render context. @return an appropriate renderer for the component and context, or null if a suitable renderer could not be found. @deprecated Use {@link WTemplate} instead.
[ "Retrieves", "a", "renderer", "which", "can", "renderer", "templates", "for", "the", "given", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L143-L155
139,154
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.findTemplateRenderer
@Deprecated private synchronized Renderer findTemplateRenderer(final String packageName) { RendererFactory factory = INSTANCE.findRendererFactory(packageName); Renderer renderer = factory.getTemplateRenderer(); if (renderer == null) { templateRenderers.put(packageName, NULL_RENDERER); } else { templateRenderers.put(packageName, renderer); } return renderer; }
java
@Deprecated private synchronized Renderer findTemplateRenderer(final String packageName) { RendererFactory factory = INSTANCE.findRendererFactory(packageName); Renderer renderer = factory.getTemplateRenderer(); if (renderer == null) { templateRenderers.put(packageName, NULL_RENDERER); } else { templateRenderers.put(packageName, renderer); } return renderer; }
[ "@", "Deprecated", "private", "synchronized", "Renderer", "findTemplateRenderer", "(", "final", "String", "packageName", ")", "{", "RendererFactory", "factory", "=", "INSTANCE", ".", "findRendererFactory", "(", "packageName", ")", ";", "Renderer", "renderer", "=", "factory", ".", "getTemplateRenderer", "(", ")", ";", "if", "(", "renderer", "==", "null", ")", "{", "templateRenderers", ".", "put", "(", "packageName", ",", "NULL_RENDERER", ")", ";", "}", "else", "{", "templateRenderers", ".", "put", "(", "packageName", ",", "renderer", ")", ";", "}", "return", "renderer", ";", "}" ]
Retrieves the template renderer for the given package. @param packageName the package to retrieve the template renderer for. @return the template renderer for the given package, or null if the package does not contain a template renderer. @deprecated Use {@link WTemplate} instead.
[ "Retrieves", "the", "template", "renderer", "for", "the", "given", "package", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L164-L176
139,155
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.getDefaultRenderer
@Deprecated public static Renderer getDefaultRenderer(final WComponent component) { LOG.warn("The getDefaultRenderer() method is deprecated. Do not obtain renderers directly."); return getRenderer(component, new WebXmlRenderContext(new PrintWriter(new NullWriter()))); }
java
@Deprecated public static Renderer getDefaultRenderer(final WComponent component) { LOG.warn("The getDefaultRenderer() method is deprecated. Do not obtain renderers directly."); return getRenderer(component, new WebXmlRenderContext(new PrintWriter(new NullWriter()))); }
[ "@", "Deprecated", "public", "static", "Renderer", "getDefaultRenderer", "(", "final", "WComponent", "component", ")", "{", "LOG", ".", "warn", "(", "\"The getDefaultRenderer() method is deprecated. Do not obtain renderers directly.\"", ")", ";", "return", "getRenderer", "(", "component", ",", "new", "WebXmlRenderContext", "(", "new", "PrintWriter", "(", "new", "NullWriter", "(", ")", ")", ")", ")", ";", "}" ]
Retrieves the default LayoutManager for the given component. This method must no longer be used, as it will only ever return a web-xml renderer. @param component the component. @return the LayoutManager for the given component. @deprecated use {@link #getRenderer(WComponent, RenderContext)}.
[ "Retrieves", "the", "default", "LayoutManager", "for", "the", "given", "component", ".", "This", "method", "must", "no", "longer", "be", "used", "as", "it", "will", "only", "ever", "return", "a", "web", "-", "xml", "renderer", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L187-L191
139,156
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.findRenderer
private synchronized Renderer findRenderer(final WComponent component, final Duplet<String, Class<?>> key) { LOG.info("Looking for layout for " + key.getSecond().getName() + " in " + key.getFirst()); Renderer renderer = findConfiguredRenderer(component, key.getFirst()); if (renderer == null) { renderers.put(key, NULL_RENDERER); } else { renderers.put(key, renderer); } return renderer; }
java
private synchronized Renderer findRenderer(final WComponent component, final Duplet<String, Class<?>> key) { LOG.info("Looking for layout for " + key.getSecond().getName() + " in " + key.getFirst()); Renderer renderer = findConfiguredRenderer(component, key.getFirst()); if (renderer == null) { renderers.put(key, NULL_RENDERER); } else { renderers.put(key, renderer); } return renderer; }
[ "private", "synchronized", "Renderer", "findRenderer", "(", "final", "WComponent", "component", ",", "final", "Duplet", "<", "String", ",", "Class", "<", "?", ">", ">", "key", ")", "{", "LOG", ".", "info", "(", "\"Looking for layout for \"", "+", "key", ".", "getSecond", "(", ")", ".", "getName", "(", ")", "+", "\" in \"", "+", "key", ".", "getFirst", "(", ")", ")", ";", "Renderer", "renderer", "=", "findConfiguredRenderer", "(", "component", ",", "key", ".", "getFirst", "(", ")", ")", ";", "if", "(", "renderer", "==", "null", ")", "{", "renderers", ".", "put", "(", "key", ",", "NULL_RENDERER", ")", ";", "}", "else", "{", "renderers", ".", "put", "(", "key", ",", "renderer", ")", ";", "}", "return", "renderer", ";", "}" ]
Finds the layout for the given theme and component. @param component the WComponent class to find a manager for. @param key the component key to use for caching the renderer. @return the LayoutManager for the component.
[ "Finds", "the", "layout", "for", "the", "given", "theme", "and", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L208-L221
139,157
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.findRendererFactory
private synchronized RendererFactory findRendererFactory(final String packageName) { RendererFactory factory = factoriesByPackage.get(packageName); if (factory == null) { try { factory = (RendererFactory) Class.forName(packageName + ".RendererFactoryImpl"). newInstance(); factoriesByPackage.put(packageName, factory); } catch (Exception e) { throw new SystemException( "Failed to create layout manager factory for " + packageName, e); } } return factory; }
java
private synchronized RendererFactory findRendererFactory(final String packageName) { RendererFactory factory = factoriesByPackage.get(packageName); if (factory == null) { try { factory = (RendererFactory) Class.forName(packageName + ".RendererFactoryImpl"). newInstance(); factoriesByPackage.put(packageName, factory); } catch (Exception e) { throw new SystemException( "Failed to create layout manager factory for " + packageName, e); } } return factory; }
[ "private", "synchronized", "RendererFactory", "findRendererFactory", "(", "final", "String", "packageName", ")", "{", "RendererFactory", "factory", "=", "factoriesByPackage", ".", "get", "(", "packageName", ")", ";", "if", "(", "factory", "==", "null", ")", "{", "try", "{", "factory", "=", "(", "RendererFactory", ")", "Class", ".", "forName", "(", "packageName", "+", "\".RendererFactoryImpl\"", ")", ".", "newInstance", "(", ")", ";", "factoriesByPackage", ".", "put", "(", "packageName", ",", "factory", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "SystemException", "(", "\"Failed to create layout manager factory for \"", "+", "packageName", ",", "e", ")", ";", "}", "}", "return", "factory", ";", "}" ]
Finds the renderer factory for the given package. @param packageName the package name to find the renderer factory for. @return the RendererFactory for the given package, or null if not found.
[ "Finds", "the", "renderer", "factory", "for", "the", "given", "package", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L229-L244
139,158
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.findConfiguredRenderer
private Renderer findConfiguredRenderer(final WComponent component, final String rendererPackage) { Renderer renderer = null; // We loop for each WComponent in the class hierarchy, as the // Renderer may have been specified at a higher level. for (Class<?> c = component.getClass(); renderer == null && c != null && !AbstractWComponent.class. equals(c); c = c.getSuperclass()) { String qualifiedClassName = c.getName(); // Is there an override for this class? String rendererName = ConfigurationProperties.getRendererOverride(qualifiedClassName); if (rendererName != null) { renderer = createRenderer(rendererName); if (renderer == null) { LOG.warn( "Layout Manager \"" + rendererName + "\" specified for " + qualifiedClassName + " was not found"); } else { return renderer; } } renderer = findRendererFactory(rendererPackage).getRenderer(c); } return renderer; }
java
private Renderer findConfiguredRenderer(final WComponent component, final String rendererPackage) { Renderer renderer = null; // We loop for each WComponent in the class hierarchy, as the // Renderer may have been specified at a higher level. for (Class<?> c = component.getClass(); renderer == null && c != null && !AbstractWComponent.class. equals(c); c = c.getSuperclass()) { String qualifiedClassName = c.getName(); // Is there an override for this class? String rendererName = ConfigurationProperties.getRendererOverride(qualifiedClassName); if (rendererName != null) { renderer = createRenderer(rendererName); if (renderer == null) { LOG.warn( "Layout Manager \"" + rendererName + "\" specified for " + qualifiedClassName + " was not found"); } else { return renderer; } } renderer = findRendererFactory(rendererPackage).getRenderer(c); } return renderer; }
[ "private", "Renderer", "findConfiguredRenderer", "(", "final", "WComponent", "component", ",", "final", "String", "rendererPackage", ")", "{", "Renderer", "renderer", "=", "null", ";", "// We loop for each WComponent in the class hierarchy, as the", "// Renderer may have been specified at a higher level.", "for", "(", "Class", "<", "?", ">", "c", "=", "component", ".", "getClass", "(", ")", ";", "renderer", "==", "null", "&&", "c", "!=", "null", "&&", "!", "AbstractWComponent", ".", "class", ".", "equals", "(", "c", ")", ";", "c", "=", "c", ".", "getSuperclass", "(", ")", ")", "{", "String", "qualifiedClassName", "=", "c", ".", "getName", "(", ")", ";", "// Is there an override for this class?", "String", "rendererName", "=", "ConfigurationProperties", ".", "getRendererOverride", "(", "qualifiedClassName", ")", ";", "if", "(", "rendererName", "!=", "null", ")", "{", "renderer", "=", "createRenderer", "(", "rendererName", ")", ";", "if", "(", "renderer", "==", "null", ")", "{", "LOG", ".", "warn", "(", "\"Layout Manager \\\"\"", "+", "rendererName", "+", "\"\\\" specified for \"", "+", "qualifiedClassName", "+", "\" was not found\"", ")", ";", "}", "else", "{", "return", "renderer", ";", "}", "}", "renderer", "=", "findRendererFactory", "(", "rendererPackage", ")", ".", "getRenderer", "(", "c", ")", ";", "}", "return", "renderer", ";", "}" ]
Attempts to find the configured renderer for the given output format and component. @param component the component to find a manager for. @param rendererPackage the package containing the renderers. @return the Renderer for the component, or null if there is no renderer defined.
[ "Attempts", "to", "find", "the", "configured", "renderer", "for", "the", "given", "output", "format", "and", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L253-L280
139,159
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java
UIManager.createRenderer
private static Renderer createRenderer(final String rendererName) { if (rendererName.endsWith(".vm")) { // This is a velocity template, so use a VelocityLayout return new VelocityRenderer(rendererName); } try { Class<?> managerClass = Class.forName(rendererName); Object manager = managerClass.newInstance(); if (!(manager instanceof Renderer)) { throw new SystemException(rendererName + " is not a Renderer"); } return (Renderer) manager; } catch (ClassNotFoundException e) { // Legal - there might not a manager implementation in a given theme return null; } catch (InstantiationException e) { throw new SystemException("Failed to instantiate " + rendererName, e); } catch (IllegalAccessException e) { throw new SystemException("Failed to access " + rendererName, e); } }
java
private static Renderer createRenderer(final String rendererName) { if (rendererName.endsWith(".vm")) { // This is a velocity template, so use a VelocityLayout return new VelocityRenderer(rendererName); } try { Class<?> managerClass = Class.forName(rendererName); Object manager = managerClass.newInstance(); if (!(manager instanceof Renderer)) { throw new SystemException(rendererName + " is not a Renderer"); } return (Renderer) manager; } catch (ClassNotFoundException e) { // Legal - there might not a manager implementation in a given theme return null; } catch (InstantiationException e) { throw new SystemException("Failed to instantiate " + rendererName, e); } catch (IllegalAccessException e) { throw new SystemException("Failed to access " + rendererName, e); } }
[ "private", "static", "Renderer", "createRenderer", "(", "final", "String", "rendererName", ")", "{", "if", "(", "rendererName", ".", "endsWith", "(", "\".vm\"", ")", ")", "{", "// This is a velocity template, so use a VelocityLayout", "return", "new", "VelocityRenderer", "(", "rendererName", ")", ";", "}", "try", "{", "Class", "<", "?", ">", "managerClass", "=", "Class", ".", "forName", "(", "rendererName", ")", ";", "Object", "manager", "=", "managerClass", ".", "newInstance", "(", ")", ";", "if", "(", "!", "(", "manager", "instanceof", "Renderer", ")", ")", "{", "throw", "new", "SystemException", "(", "rendererName", "+", "\" is not a Renderer\"", ")", ";", "}", "return", "(", "Renderer", ")", "manager", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "// Legal - there might not a manager implementation in a given theme", "return", "null", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "SystemException", "(", "\"Failed to instantiate \"", "+", "rendererName", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "SystemException", "(", "\"Failed to access \"", "+", "rendererName", ",", "e", ")", ";", "}", "}" ]
Attempts to create a Renderer with the given name. @param rendererName the name of the Renderer @return a Renderer of the given type, or null if the class was not found.
[ "Attempts", "to", "create", "a", "Renderer", "with", "the", "given", "name", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/UIManager.java#L288-L311
139,160
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/ajax/AjaxPollingWButtonExample.java
AjaxPollingWButtonExample.fakeServiceCall
private void fakeServiceCall() { poller.enablePoll(); Cache.getCache().invalidate(DATA_KEY); new Thread() { @Override public void run() { try { Thread.sleep(SERVICE_TIME); Cache.getCache().put(DATA_KEY, "SUCCESS!"); } catch (InterruptedException e) { LOG.error("Timed out calling service", e); Cache.getCache().put(DATA_KEY, "Timed out!"); } } }.start(); }
java
private void fakeServiceCall() { poller.enablePoll(); Cache.getCache().invalidate(DATA_KEY); new Thread() { @Override public void run() { try { Thread.sleep(SERVICE_TIME); Cache.getCache().put(DATA_KEY, "SUCCESS!"); } catch (InterruptedException e) { LOG.error("Timed out calling service", e); Cache.getCache().put(DATA_KEY, "Timed out!"); } } }.start(); }
[ "private", "void", "fakeServiceCall", "(", ")", "{", "poller", ".", "enablePoll", "(", ")", ";", "Cache", ".", "getCache", "(", ")", ".", "invalidate", "(", "DATA_KEY", ")", ";", "new", "Thread", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "SERVICE_TIME", ")", ";", "Cache", ".", "getCache", "(", ")", ".", "put", "(", "DATA_KEY", ",", "\"SUCCESS!\"", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "LOG", ".", "error", "(", "\"Timed out calling service\"", ",", "e", ")", ";", "Cache", ".", "getCache", "(", ")", ".", "put", "(", "DATA_KEY", ",", "\"Timed out!\"", ")", ";", "}", "}", "}", ".", "start", "(", ")", ";", "}" ]
Fakes a service call, using the WorkManager for threading.
[ "Fakes", "a", "service", "call", "using", "the", "WorkManager", "for", "threading", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/ajax/AjaxPollingWButtonExample.java#L107-L123
139,161
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java
UicStats.analyseWC
public void analyseWC(final WComponent comp) { if (comp == null) { return; } statsByWCTree.put(comp, createWCTreeStats(comp)); }
java
public void analyseWC(final WComponent comp) { if (comp == null) { return; } statsByWCTree.put(comp, createWCTreeStats(comp)); }
[ "public", "void", "analyseWC", "(", "final", "WComponent", "comp", ")", "{", "if", "(", "comp", "==", "null", ")", "{", "return", ";", "}", "statsByWCTree", ".", "put", "(", "comp", ",", "createWCTreeStats", "(", "comp", ")", ")", ";", "}" ]
Creates statistics for the given WComponent within the uicontext being analysed. @param comp the component to create stats for.
[ "Creates", "statistics", "for", "the", "given", "WComponent", "within", "the", "uicontext", "being", "analysed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java#L113-L119
139,162
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java
UicStats.addStats
private void addStats(final Map<WComponent, Stat> statsMap, final WComponent comp) { Stat stat = createStat(comp); statsMap.put(comp, stat); if (comp instanceof Container) { Container container = (Container) comp; int childCount = container.getChildCount(); for (int i = 0; i < childCount; i++) { WComponent child = container.getChildAt(i); addStats(statsMap, child); } } }
java
private void addStats(final Map<WComponent, Stat> statsMap, final WComponent comp) { Stat stat = createStat(comp); statsMap.put(comp, stat); if (comp instanceof Container) { Container container = (Container) comp; int childCount = container.getChildCount(); for (int i = 0; i < childCount; i++) { WComponent child = container.getChildAt(i); addStats(statsMap, child); } } }
[ "private", "void", "addStats", "(", "final", "Map", "<", "WComponent", ",", "Stat", ">", "statsMap", ",", "final", "WComponent", "comp", ")", "{", "Stat", "stat", "=", "createStat", "(", "comp", ")", ";", "statsMap", ".", "put", "(", "comp", ",", "stat", ")", ";", "if", "(", "comp", "instanceof", "Container", ")", "{", "Container", "container", "=", "(", "Container", ")", "comp", ";", "int", "childCount", "=", "container", ".", "getChildCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childCount", ";", "i", "++", ")", "{", "WComponent", "child", "=", "container", ".", "getChildAt", "(", "i", ")", ";", "addStats", "(", "statsMap", ",", "child", ")", ";", "}", "}", "}" ]
Recursively adds statistics for a component and its children to the stats map. @param statsMap the stats map to add to. @param comp the component to analyse.
[ "Recursively", "adds", "statistics", "for", "a", "component", "and", "its", "children", "to", "the", "stats", "map", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java#L147-L160
139,163
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java
UicStats.createStat
private Stat createStat(final WComponent comp) { Stat stat = new Stat(); stat.setClassName(comp.getClass().getName()); stat.setName(comp.getId()); if (stat.getName() == null) { stat.setName("Unknown"); } if (comp instanceof AbstractWComponent) { Object obj = AbstractWComponent.replaceWComponent((AbstractWComponent) comp); if (obj instanceof AbstractWComponent.WComponentRef) { stat.setRef(obj.toString()); } } ComponentModel model = (ComponentModel) uic.getModel(comp); stat.setModelState(Stat.MDL_NONE); if (model != null) { if (comp.isDefaultState()) { stat.setModelState(Stat.MDL_DEFAULT); } else { addSerializationStat(model, stat); } } return stat; }
java
private Stat createStat(final WComponent comp) { Stat stat = new Stat(); stat.setClassName(comp.getClass().getName()); stat.setName(comp.getId()); if (stat.getName() == null) { stat.setName("Unknown"); } if (comp instanceof AbstractWComponent) { Object obj = AbstractWComponent.replaceWComponent((AbstractWComponent) comp); if (obj instanceof AbstractWComponent.WComponentRef) { stat.setRef(obj.toString()); } } ComponentModel model = (ComponentModel) uic.getModel(comp); stat.setModelState(Stat.MDL_NONE); if (model != null) { if (comp.isDefaultState()) { stat.setModelState(Stat.MDL_DEFAULT); } else { addSerializationStat(model, stat); } } return stat; }
[ "private", "Stat", "createStat", "(", "final", "WComponent", "comp", ")", "{", "Stat", "stat", "=", "new", "Stat", "(", ")", ";", "stat", ".", "setClassName", "(", "comp", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "stat", ".", "setName", "(", "comp", ".", "getId", "(", ")", ")", ";", "if", "(", "stat", ".", "getName", "(", ")", "==", "null", ")", "{", "stat", ".", "setName", "(", "\"Unknown\"", ")", ";", "}", "if", "(", "comp", "instanceof", "AbstractWComponent", ")", "{", "Object", "obj", "=", "AbstractWComponent", ".", "replaceWComponent", "(", "(", "AbstractWComponent", ")", "comp", ")", ";", "if", "(", "obj", "instanceof", "AbstractWComponent", ".", "WComponentRef", ")", "{", "stat", ".", "setRef", "(", "obj", ".", "toString", "(", ")", ")", ";", "}", "}", "ComponentModel", "model", "=", "(", "ComponentModel", ")", "uic", ".", "getModel", "(", "comp", ")", ";", "stat", ".", "setModelState", "(", "Stat", ".", "MDL_NONE", ")", ";", "if", "(", "model", "!=", "null", ")", "{", "if", "(", "comp", ".", "isDefaultState", "(", ")", ")", "{", "stat", ".", "setModelState", "(", "Stat", ".", "MDL_DEFAULT", ")", ";", "}", "else", "{", "addSerializationStat", "(", "model", ",", "stat", ")", ";", "}", "}", "return", "stat", ";", "}" ]
Creates statistics for a component in the given context. @param comp the component. @return the stats for the given component in the given context.
[ "Creates", "statistics", "for", "a", "component", "in", "the", "given", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java#L168-L199
139,164
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java
UicStats.getSerializationSize
private int getSerializationSize(final Object obj) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.close(); byte[] bytes = bos.toByteArray(); return bytes.length; } catch (IOException ex) { // Unable to serialize so cannot determine size. return -1; } }
java
private int getSerializationSize(final Object obj) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.close(); byte[] bytes = bos.toByteArray(); return bytes.length; } catch (IOException ex) { // Unable to serialize so cannot determine size. return -1; } }
[ "private", "int", "getSerializationSize", "(", "final", "Object", "obj", ")", "{", "try", "{", "ByteArrayOutputStream", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "oos", "=", "new", "ObjectOutputStream", "(", "bos", ")", ";", "oos", ".", "writeObject", "(", "obj", ")", ";", "oos", ".", "close", "(", ")", ";", "byte", "[", "]", "bytes", "=", "bos", ".", "toByteArray", "(", ")", ";", "return", "bytes", ".", "length", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "// Unable to serialize so cannot determine size.", "return", "-", "1", ";", "}", "}" ]
Determines the serialized size of an object by serializng it to a byte array. @param obj the object to find the serialized size of. @return the serialized size of the given object, or -1 on error.
[ "Determines", "the", "serialized", "size", "of", "an", "object", "by", "serializng", "it", "to", "a", "byte", "array", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStats.java#L207-L220
139,165
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableBeanExample.java
DataTableBeanExample.createTable
private WDataTable createTable() { WDataTable tbl = new WDataTable(); tbl.addColumn(new WTableColumn("First name", new WTextField())); tbl.addColumn(new WTableColumn("Last name", new WTextField())); tbl.addColumn(new WTableColumn("DOB", new WDateField())); return tbl; }
java
private WDataTable createTable() { WDataTable tbl = new WDataTable(); tbl.addColumn(new WTableColumn("First name", new WTextField())); tbl.addColumn(new WTableColumn("Last name", new WTextField())); tbl.addColumn(new WTableColumn("DOB", new WDateField())); return tbl; }
[ "private", "WDataTable", "createTable", "(", ")", "{", "WDataTable", "tbl", "=", "new", "WDataTable", "(", ")", ";", "tbl", ".", "addColumn", "(", "new", "WTableColumn", "(", "\"First name\"", ",", "new", "WTextField", "(", ")", ")", ")", ";", "tbl", ".", "addColumn", "(", "new", "WTableColumn", "(", "\"Last name\"", ",", "new", "WTextField", "(", ")", ")", ")", ";", "tbl", ".", "addColumn", "(", "new", "WTableColumn", "(", "\"DOB\"", ",", "new", "WDateField", "(", ")", ")", ")", ";", "return", "tbl", ";", "}" ]
Creates and configures the table to be used by the example. @return a new configured table.
[ "Creates", "and", "configures", "the", "table", "to", "be", "used", "by", "the", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableBeanExample.java#L104-L110
139,166
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterLinkExample.java
RepeaterLinkExample.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { MyData data = new MyData("Homer"); basic.setData(data); List<MyData> dataList = new ArrayList<>(); dataList.add(new MyData("Homer")); dataList.add(new MyData("Marge")); dataList.add(new MyData("Bart")); repeated.setBeanList(dataList); dataList = new ArrayList<>(); dataList.add(new MyData("Greg")); dataList.add(new MyData("Jeff")); dataList.add(new MyData("Anthony")); dataList.add(new MyData("Murray")); repeatedLink.setData(dataList); List<List<MyData>> rootList = new ArrayList<>(); List<MyData> subList = new ArrayList<>(); subList.add(new MyData("Ernie")); subList.add(new MyData("Bert")); rootList.add(subList); subList = new ArrayList<>(); subList.add(new MyData("Starsky")); subList.add(new MyData("Hutch")); rootList.add(subList); nestedRepeaterTab.setData(rootList); setInitialised(true); } }
java
@Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { MyData data = new MyData("Homer"); basic.setData(data); List<MyData> dataList = new ArrayList<>(); dataList.add(new MyData("Homer")); dataList.add(new MyData("Marge")); dataList.add(new MyData("Bart")); repeated.setBeanList(dataList); dataList = new ArrayList<>(); dataList.add(new MyData("Greg")); dataList.add(new MyData("Jeff")); dataList.add(new MyData("Anthony")); dataList.add(new MyData("Murray")); repeatedLink.setData(dataList); List<List<MyData>> rootList = new ArrayList<>(); List<MyData> subList = new ArrayList<>(); subList.add(new MyData("Ernie")); subList.add(new MyData("Bert")); rootList.add(subList); subList = new ArrayList<>(); subList.add(new MyData("Starsky")); subList.add(new MyData("Hutch")); rootList.add(subList); nestedRepeaterTab.setData(rootList); setInitialised(true); } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "if", "(", "!", "isInitialised", "(", ")", ")", "{", "MyData", "data", "=", "new", "MyData", "(", "\"Homer\"", ")", ";", "basic", ".", "setData", "(", "data", ")", ";", "List", "<", "MyData", ">", "dataList", "=", "new", "ArrayList", "<>", "(", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Homer\"", ")", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Marge\"", ")", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Bart\"", ")", ")", ";", "repeated", ".", "setBeanList", "(", "dataList", ")", ";", "dataList", "=", "new", "ArrayList", "<>", "(", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Greg\"", ")", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Jeff\"", ")", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Anthony\"", ")", ")", ";", "dataList", ".", "add", "(", "new", "MyData", "(", "\"Murray\"", ")", ")", ";", "repeatedLink", ".", "setData", "(", "dataList", ")", ";", "List", "<", "List", "<", "MyData", ">", ">", "rootList", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "MyData", ">", "subList", "=", "new", "ArrayList", "<>", "(", ")", ";", "subList", ".", "add", "(", "new", "MyData", "(", "\"Ernie\"", ")", ")", ";", "subList", ".", "add", "(", "new", "MyData", "(", "\"Bert\"", ")", ")", ";", "rootList", ".", "add", "(", "subList", ")", ";", "subList", "=", "new", "ArrayList", "<>", "(", ")", ";", "subList", ".", "add", "(", "new", "MyData", "(", "\"Starsky\"", ")", ")", ";", "subList", ".", "add", "(", "new", "MyData", "(", "\"Hutch\"", ")", ")", ";", "rootList", ".", "add", "(", "subList", ")", ";", "nestedRepeaterTab", ".", "setData", "(", "rootList", ")", ";", "setInitialised", "(", "true", ")", ";", "}", "}" ]
Override preparePaint to initialise the data the first time through. @param request the request being responded to.
[ "Override", "preparePaint", "to", "initialise", "the", "data", "the", "first", "time", "through", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterLinkExample.java#L56-L91
139,167
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphNode.java
ObjectGraphNode.getSize
private int getSize(final String fieldType, final Object fieldValue) { Integer fieldSize = SIMPLE_SIZES.get(fieldType); if (fieldSize != null) { if (PRIMITIVE_TYPES.contains(fieldType)) { return fieldSize; } return OBJREF_SIZE + fieldSize; } else if (fieldValue instanceof String) { return (OBJREF_SIZE + OBJECT_SHELL_SIZE) * 2 // One for the String Object itself, and one for the char[] value + INT_FIELD_SIZE * 3 // offset, count, hash + ((String) fieldValue).length() * CHAR_FIELD_SIZE; } else if (fieldValue != null) { return OBJECT_SHELL_SIZE + OBJREF_SIZE; // plus the size of any nested nodes. } else { // Null return OBJREF_SIZE; } }
java
private int getSize(final String fieldType, final Object fieldValue) { Integer fieldSize = SIMPLE_SIZES.get(fieldType); if (fieldSize != null) { if (PRIMITIVE_TYPES.contains(fieldType)) { return fieldSize; } return OBJREF_SIZE + fieldSize; } else if (fieldValue instanceof String) { return (OBJREF_SIZE + OBJECT_SHELL_SIZE) * 2 // One for the String Object itself, and one for the char[] value + INT_FIELD_SIZE * 3 // offset, count, hash + ((String) fieldValue).length() * CHAR_FIELD_SIZE; } else if (fieldValue != null) { return OBJECT_SHELL_SIZE + OBJREF_SIZE; // plus the size of any nested nodes. } else { // Null return OBJREF_SIZE; } }
[ "private", "int", "getSize", "(", "final", "String", "fieldType", ",", "final", "Object", "fieldValue", ")", "{", "Integer", "fieldSize", "=", "SIMPLE_SIZES", ".", "get", "(", "fieldType", ")", ";", "if", "(", "fieldSize", "!=", "null", ")", "{", "if", "(", "PRIMITIVE_TYPES", ".", "contains", "(", "fieldType", ")", ")", "{", "return", "fieldSize", ";", "}", "return", "OBJREF_SIZE", "+", "fieldSize", ";", "}", "else", "if", "(", "fieldValue", "instanceof", "String", ")", "{", "return", "(", "OBJREF_SIZE", "+", "OBJECT_SHELL_SIZE", ")", "*", "2", "// One for the String Object itself, and one for the char[] value", "+", "INT_FIELD_SIZE", "*", "3", "// offset, count, hash", "+", "(", "(", "String", ")", "fieldValue", ")", ".", "length", "(", ")", "*", "CHAR_FIELD_SIZE", ";", "}", "else", "if", "(", "fieldValue", "!=", "null", ")", "{", "return", "OBJECT_SHELL_SIZE", "+", "OBJREF_SIZE", ";", "// plus the size of any nested nodes.", "}", "else", "{", "// Null", "return", "OBJREF_SIZE", ";", "}", "}" ]
Calculates the size of a field value obtained using the reflection API. @param fieldType the Field's type (class), needed to return the correct values for primitives. @param fieldValue the field's value (primitives are boxed). @return an approximation of amount of memory the field occupies, in bytes.
[ "Calculates", "the", "size", "of", "a", "field", "value", "obtained", "using", "the", "reflection", "API", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphNode.java#L177-L195
139,168
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphNode.java
ObjectGraphNode.toFlatSummary
private void toFlatSummary(final String indent, final StringBuffer buffer) { buffer.append(indent); ObjectGraphNode root = (ObjectGraphNode) getRoot(); double pct = 100.0 * getSize() / root.getSize(); buffer.append(getSize()).append(" ("); buffer.append(new DecimalFormat("0.0").format(pct)); buffer.append("%) - ").append(getFieldName()).append(" - "); if (getRefNode() != null) { buffer.append("ref (").append(getRefNode().getValue().getClass().getName()).append(')'); } else if (getValue() == null) { buffer.append("null (").append(getType()).append(')'); } else { buffer.append(getType()); } buffer.append('\n'); String newIndent = indent + " "; for (int i = 0; i < getChildCount(); i++) { ((ObjectGraphNode) getChildAt(i)).toFlatSummary(newIndent, buffer); } }
java
private void toFlatSummary(final String indent, final StringBuffer buffer) { buffer.append(indent); ObjectGraphNode root = (ObjectGraphNode) getRoot(); double pct = 100.0 * getSize() / root.getSize(); buffer.append(getSize()).append(" ("); buffer.append(new DecimalFormat("0.0").format(pct)); buffer.append("%) - ").append(getFieldName()).append(" - "); if (getRefNode() != null) { buffer.append("ref (").append(getRefNode().getValue().getClass().getName()).append(')'); } else if (getValue() == null) { buffer.append("null (").append(getType()).append(')'); } else { buffer.append(getType()); } buffer.append('\n'); String newIndent = indent + " "; for (int i = 0; i < getChildCount(); i++) { ((ObjectGraphNode) getChildAt(i)).toFlatSummary(newIndent, buffer); } }
[ "private", "void", "toFlatSummary", "(", "final", "String", "indent", ",", "final", "StringBuffer", "buffer", ")", "{", "buffer", ".", "append", "(", "indent", ")", ";", "ObjectGraphNode", "root", "=", "(", "ObjectGraphNode", ")", "getRoot", "(", ")", ";", "double", "pct", "=", "100.0", "*", "getSize", "(", ")", "/", "root", ".", "getSize", "(", ")", ";", "buffer", ".", "append", "(", "getSize", "(", ")", ")", ".", "append", "(", "\" (\"", ")", ";", "buffer", ".", "append", "(", "new", "DecimalFormat", "(", "\"0.0\"", ")", ".", "format", "(", "pct", ")", ")", ";", "buffer", ".", "append", "(", "\"%) - \"", ")", ".", "append", "(", "getFieldName", "(", ")", ")", ".", "append", "(", "\" - \"", ")", ";", "if", "(", "getRefNode", "(", ")", "!=", "null", ")", "{", "buffer", ".", "append", "(", "\"ref (\"", ")", ".", "append", "(", "getRefNode", "(", ")", ".", "getValue", "(", ")", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "else", "if", "(", "getValue", "(", ")", "==", "null", ")", "{", "buffer", ".", "append", "(", "\"null (\"", ")", ".", "append", "(", "getType", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "getType", "(", ")", ")", ";", "}", "buffer", ".", "append", "(", "'", "'", ")", ";", "String", "newIndent", "=", "indent", "+", "\" \"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "(", "(", "ObjectGraphNode", ")", "getChildAt", "(", "i", ")", ")", ".", "toFlatSummary", "(", "newIndent", ",", "buffer", ")", ";", "}", "}" ]
Generates a flat format summary XML representation of this ObjectGraphNode. @param indent the indent, for formatting. @param buffer the StringBuffer to append the summary to.
[ "Generates", "a", "flat", "format", "summary", "XML", "representation", "of", "this", "ObjectGraphNode", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphNode.java#L273-L298
139,169
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphNode.java
ObjectGraphNode.toXml
private void toXml(final String indent, final StringBuffer xml) { String primitiveString = formatSimpleValue(); xml.append(indent); xml.append(isPrimitive() ? "<primitive" : "<object"); if (refNode == null) { xml.append(" id=\"").append(id).append('"'); if (fieldName != null) { xml.append(" field=\"").append(fieldName).append('"'); } if (primitiveString != null) { primitiveString = WebUtilities.encode(primitiveString); xml.append(" value=\"").append(primitiveString).append('"'); } if (type != null) { xml.append(" type=\"").append(type).append('"'); } xml.append(" size=\"").append(getSize()).append('"'); if (getChildCount() == 0) { xml.append("/>\n"); } else { xml.append(">\n"); String newIndent = indent + " "; for (int i = 0; i < getChildCount(); i++) { ((ObjectGraphNode) getChildAt(i)).toXml(newIndent, xml); } xml.append(indent); xml.append(isPrimitive() ? "</primitive>\n" : "</object>\n"); } } else { if (fieldName != null) { xml.append(" field=\"").append(fieldName).append('"'); } xml.append(" refId=\"").append(refNode.id).append('"'); if (refNode.value == null) { xml.append(" type=\"").append(refNode.type).append('"'); } else { xml.append(" type=\"").append(refNode.value.getClass().getName()).append('"'); } xml.append(" size=\"").append(OBJREF_SIZE).append('"'); xml.append("/>\n"); } }
java
private void toXml(final String indent, final StringBuffer xml) { String primitiveString = formatSimpleValue(); xml.append(indent); xml.append(isPrimitive() ? "<primitive" : "<object"); if (refNode == null) { xml.append(" id=\"").append(id).append('"'); if (fieldName != null) { xml.append(" field=\"").append(fieldName).append('"'); } if (primitiveString != null) { primitiveString = WebUtilities.encode(primitiveString); xml.append(" value=\"").append(primitiveString).append('"'); } if (type != null) { xml.append(" type=\"").append(type).append('"'); } xml.append(" size=\"").append(getSize()).append('"'); if (getChildCount() == 0) { xml.append("/>\n"); } else { xml.append(">\n"); String newIndent = indent + " "; for (int i = 0; i < getChildCount(); i++) { ((ObjectGraphNode) getChildAt(i)).toXml(newIndent, xml); } xml.append(indent); xml.append(isPrimitive() ? "</primitive>\n" : "</object>\n"); } } else { if (fieldName != null) { xml.append(" field=\"").append(fieldName).append('"'); } xml.append(" refId=\"").append(refNode.id).append('"'); if (refNode.value == null) { xml.append(" type=\"").append(refNode.type).append('"'); } else { xml.append(" type=\"").append(refNode.value.getClass().getName()).append('"'); } xml.append(" size=\"").append(OBJREF_SIZE).append('"'); xml.append("/>\n"); } }
[ "private", "void", "toXml", "(", "final", "String", "indent", ",", "final", "StringBuffer", "xml", ")", "{", "String", "primitiveString", "=", "formatSimpleValue", "(", ")", ";", "xml", ".", "append", "(", "indent", ")", ";", "xml", ".", "append", "(", "isPrimitive", "(", ")", "?", "\"<primitive\"", ":", "\"<object\"", ")", ";", "if", "(", "refNode", "==", "null", ")", "{", "xml", ".", "append", "(", "\" id=\\\"\"", ")", ".", "append", "(", "id", ")", ".", "append", "(", "'", "'", ")", ";", "if", "(", "fieldName", "!=", "null", ")", "{", "xml", ".", "append", "(", "\" field=\\\"\"", ")", ".", "append", "(", "fieldName", ")", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "primitiveString", "!=", "null", ")", "{", "primitiveString", "=", "WebUtilities", ".", "encode", "(", "primitiveString", ")", ";", "xml", ".", "append", "(", "\" value=\\\"\"", ")", ".", "append", "(", "primitiveString", ")", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "type", "!=", "null", ")", "{", "xml", ".", "append", "(", "\" type=\\\"\"", ")", ".", "append", "(", "type", ")", ".", "append", "(", "'", "'", ")", ";", "}", "xml", ".", "append", "(", "\" size=\\\"\"", ")", ".", "append", "(", "getSize", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "if", "(", "getChildCount", "(", ")", "==", "0", ")", "{", "xml", ".", "append", "(", "\"/>\\n\"", ")", ";", "}", "else", "{", "xml", ".", "append", "(", "\">\\n\"", ")", ";", "String", "newIndent", "=", "indent", "+", "\" \"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "(", "(", "ObjectGraphNode", ")", "getChildAt", "(", "i", ")", ")", ".", "toXml", "(", "newIndent", ",", "xml", ")", ";", "}", "xml", ".", "append", "(", "indent", ")", ";", "xml", ".", "append", "(", "isPrimitive", "(", ")", "?", "\"</primitive>\\n\"", ":", "\"</object>\\n\"", ")", ";", "}", "}", "else", "{", "if", "(", "fieldName", "!=", "null", ")", "{", "xml", ".", "append", "(", "\" field=\\\"\"", ")", ".", "append", "(", "fieldName", ")", ".", "append", "(", "'", "'", ")", ";", "}", "xml", ".", "append", "(", "\" refId=\\\"\"", ")", ".", "append", "(", "refNode", ".", "id", ")", ".", "append", "(", "'", "'", ")", ";", "if", "(", "refNode", ".", "value", "==", "null", ")", "{", "xml", ".", "append", "(", "\" type=\\\"\"", ")", ".", "append", "(", "refNode", ".", "type", ")", ".", "append", "(", "'", "'", ")", ";", "}", "else", "{", "xml", ".", "append", "(", "\" type=\\\"\"", ")", ".", "append", "(", "refNode", ".", "value", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "xml", ".", "append", "(", "\" size=\\\"\"", ")", ".", "append", "(", "OBJREF_SIZE", ")", ".", "append", "(", "'", "'", ")", ";", "xml", ".", "append", "(", "\"/>\\n\"", ")", ";", "}", "}" ]
Emits an XML representation of this ObjectGraphNode. @param indent the indent, for formatting. @param xml the buffer to write XML output to.
[ "Emits", "an", "XML", "representation", "of", "this", "ObjectGraphNode", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphNode.java#L316-L371
139,170
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java
WButtonExample.addClientOnlyExamples
private void addClientOnlyExamples() { // client command button add(new WHeading(HeadingLevel.H2, "Client command buttons")); add(new ExplanatoryText("These examples show buttons which do not submit the form")); //client command buttons witho a command WButton nothingButton = new WButton("Do nothing"); add(nothingButton); nothingButton.setClientCommandOnly(true); nothingButton = new WButton("Do nothing link"); add(nothingButton); nothingButton.setRenderAsLink(true); nothingButton.setClientCommandOnly(true); // client command buttons with command. HelloButton helloButton = new HelloButton("Hello"); add(helloButton); helloButton = new HelloButton("Hello link"); helloButton.setRenderAsLink(true); add(helloButton); }
java
private void addClientOnlyExamples() { // client command button add(new WHeading(HeadingLevel.H2, "Client command buttons")); add(new ExplanatoryText("These examples show buttons which do not submit the form")); //client command buttons witho a command WButton nothingButton = new WButton("Do nothing"); add(nothingButton); nothingButton.setClientCommandOnly(true); nothingButton = new WButton("Do nothing link"); add(nothingButton); nothingButton.setRenderAsLink(true); nothingButton.setClientCommandOnly(true); // client command buttons with command. HelloButton helloButton = new HelloButton("Hello"); add(helloButton); helloButton = new HelloButton("Hello link"); helloButton.setRenderAsLink(true); add(helloButton); }
[ "private", "void", "addClientOnlyExamples", "(", ")", "{", "// client command button", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"Client command buttons\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"These examples show buttons which do not submit the form\"", ")", ")", ";", "//client command buttons witho a command", "WButton", "nothingButton", "=", "new", "WButton", "(", "\"Do nothing\"", ")", ";", "add", "(", "nothingButton", ")", ";", "nothingButton", ".", "setClientCommandOnly", "(", "true", ")", ";", "nothingButton", "=", "new", "WButton", "(", "\"Do nothing link\"", ")", ";", "add", "(", "nothingButton", ")", ";", "nothingButton", ".", "setRenderAsLink", "(", "true", ")", ";", "nothingButton", ".", "setClientCommandOnly", "(", "true", ")", ";", "// client command buttons with command.", "HelloButton", "helloButton", "=", "new", "HelloButton", "(", "\"Hello\"", ")", ";", "add", "(", "helloButton", ")", ";", "helloButton", "=", "new", "HelloButton", "(", "\"Hello link\"", ")", ";", "helloButton", ".", "setRenderAsLink", "(", "true", ")", ";", "add", "(", "helloButton", ")", ";", "}" ]
Examples showing use of client only buttons.
[ "Examples", "showing", "use", "of", "client", "only", "buttons", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java#L208-L229
139,171
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java
WButtonExample.addDefaultSubmitButtonExample
private void addDefaultSubmitButtonExample() { add(new WHeading(HeadingLevel.H3, "Default submit button")); add(new ExplanatoryText( "This example shows how to use an image as the only content of a WButton. " + "In addition this text field submits the entire screen using the image button to the right of the field.")); // We use WFieldLayout to lay out a label:input pair. In this case the input is a //compound control of a WTextField and a WButton. WFieldLayout imageButtonFieldLayout = new WFieldLayout(); imageButtonFieldLayout.setLabelWidth(25); add(imageButtonFieldLayout); // the text field and the button both need to be defined explicitly to be able to add them into a wrapper WTextField textFld = new WTextField(); //and finally we get to the actual button WButton button = new WButton("Flag this record for follow-up"); button.setImage("/image/flag.png"); button.getImageHolder().setCacheKey("eg-button-flag"); button.setActionObject(button); button.setAction(new ExampleButtonAction()); //we can set the image button to be the default submit button for the text field. textFld.setDefaultSubmitButton(button); //There are many way of putting multiple controls in to a WField's input. //We are using a WContainer is the one which is lowest impact in the UI. WContainer imageButtonFieldContainer = new WContainer(); imageButtonFieldContainer.add(textFld); //Use a WText to push the button off of the text field by an appropriate (user-agent determined) amount. imageButtonFieldContainer.add(new WText("\u2002")); //an en space is half an em. a none-breaking space \u00a0 could also be used but will have no effect on inter-node wrapping imageButtonFieldContainer.add(button); //Finally add the input wrapper to the WFieldLayout imageButtonFieldLayout.addField("Enter record ID", imageButtonFieldContainer); }
java
private void addDefaultSubmitButtonExample() { add(new WHeading(HeadingLevel.H3, "Default submit button")); add(new ExplanatoryText( "This example shows how to use an image as the only content of a WButton. " + "In addition this text field submits the entire screen using the image button to the right of the field.")); // We use WFieldLayout to lay out a label:input pair. In this case the input is a //compound control of a WTextField and a WButton. WFieldLayout imageButtonFieldLayout = new WFieldLayout(); imageButtonFieldLayout.setLabelWidth(25); add(imageButtonFieldLayout); // the text field and the button both need to be defined explicitly to be able to add them into a wrapper WTextField textFld = new WTextField(); //and finally we get to the actual button WButton button = new WButton("Flag this record for follow-up"); button.setImage("/image/flag.png"); button.getImageHolder().setCacheKey("eg-button-flag"); button.setActionObject(button); button.setAction(new ExampleButtonAction()); //we can set the image button to be the default submit button for the text field. textFld.setDefaultSubmitButton(button); //There are many way of putting multiple controls in to a WField's input. //We are using a WContainer is the one which is lowest impact in the UI. WContainer imageButtonFieldContainer = new WContainer(); imageButtonFieldContainer.add(textFld); //Use a WText to push the button off of the text field by an appropriate (user-agent determined) amount. imageButtonFieldContainer.add(new WText("\u2002")); //an en space is half an em. a none-breaking space \u00a0 could also be used but will have no effect on inter-node wrapping imageButtonFieldContainer.add(button); //Finally add the input wrapper to the WFieldLayout imageButtonFieldLayout.addField("Enter record ID", imageButtonFieldContainer); }
[ "private", "void", "addDefaultSubmitButtonExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Default submit button\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"This example shows how to use an image as the only content of a WButton. \"", "+", "\"In addition this text field submits the entire screen using the image button to the right of the field.\"", ")", ")", ";", "// We use WFieldLayout to lay out a label:input pair. In this case the input is a", "//compound control of a WTextField and a WButton.", "WFieldLayout", "imageButtonFieldLayout", "=", "new", "WFieldLayout", "(", ")", ";", "imageButtonFieldLayout", ".", "setLabelWidth", "(", "25", ")", ";", "add", "(", "imageButtonFieldLayout", ")", ";", "// the text field and the button both need to be defined explicitly to be able to add them into a wrapper", "WTextField", "textFld", "=", "new", "WTextField", "(", ")", ";", "//and finally we get to the actual button", "WButton", "button", "=", "new", "WButton", "(", "\"Flag this record for follow-up\"", ")", ";", "button", ".", "setImage", "(", "\"/image/flag.png\"", ")", ";", "button", ".", "getImageHolder", "(", ")", ".", "setCacheKey", "(", "\"eg-button-flag\"", ")", ";", "button", ".", "setActionObject", "(", "button", ")", ";", "button", ".", "setAction", "(", "new", "ExampleButtonAction", "(", ")", ")", ";", "//we can set the image button to be the default submit button for the text field.", "textFld", ".", "setDefaultSubmitButton", "(", "button", ")", ";", "//There are many way of putting multiple controls in to a WField's input.", "//We are using a WContainer is the one which is lowest impact in the UI.", "WContainer", "imageButtonFieldContainer", "=", "new", "WContainer", "(", ")", ";", "imageButtonFieldContainer", ".", "add", "(", "textFld", ")", ";", "//Use a WText to push the button off of the text field by an appropriate (user-agent determined) amount.", "imageButtonFieldContainer", ".", "add", "(", "new", "WText", "(", "\"\\u2002\"", ")", ")", ";", "//an en space is half an em. a none-breaking space \\u00a0 could also be used but will have no effect on inter-node wrapping", "imageButtonFieldContainer", ".", "add", "(", "button", ")", ";", "//Finally add the input wrapper to the WFieldLayout", "imageButtonFieldLayout", ".", "addField", "(", "\"Enter record ID\"", ",", "imageButtonFieldContainer", ")", ";", "}" ]
Examples showing how to set a WButton as the default submit button for an input control.
[ "Examples", "showing", "how", "to", "set", "a", "WButton", "as", "the", "default", "submit", "button", "for", "an", "input", "control", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java#L280-L311
139,172
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java
WButtonExample.addDisabledExamples
private void addDisabledExamples() { add(new WHeading(HeadingLevel.H2, "Examples of disabled buttons")); WPanel disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX); disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE)); add(disabledButtonLayoutPanel); WButton button = new WButton("Disabled button"); button.setDisabled(true); disabledButtonLayoutPanel.add(button); button = new WButton("Disabled button as link"); button.setDisabled(true); button.setRenderAsLink(true); disabledButtonLayoutPanel.add(button); add(new WHeading(HeadingLevel.H3, "Examples of disabled buttons displaying only an image")); disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX); disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE)); add(disabledButtonLayoutPanel); button = new WButton("Disabled button"); button.setDisabled(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); disabledButtonLayoutPanel.add(button); button = new WButton("Disabled button as link"); button.setDisabled(true); button.setRenderAsLink(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); disabledButtonLayoutPanel.add(button); add(new WHeading(HeadingLevel.H3, "Examples of disabled buttons displaying an image with imagePosition EAST")); disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX); disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE)); add(disabledButtonLayoutPanel); button = new WButton("Disabled button"); button.setDisabled(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); button.setImagePosition(ImagePosition.EAST); disabledButtonLayoutPanel.add(button); button = new WButton("Disabled button as link"); button.setDisabled(true); button.setRenderAsLink(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); button.setImagePosition(ImagePosition.EAST); disabledButtonLayoutPanel.add(button); }
java
private void addDisabledExamples() { add(new WHeading(HeadingLevel.H2, "Examples of disabled buttons")); WPanel disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX); disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE)); add(disabledButtonLayoutPanel); WButton button = new WButton("Disabled button"); button.setDisabled(true); disabledButtonLayoutPanel.add(button); button = new WButton("Disabled button as link"); button.setDisabled(true); button.setRenderAsLink(true); disabledButtonLayoutPanel.add(button); add(new WHeading(HeadingLevel.H3, "Examples of disabled buttons displaying only an image")); disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX); disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE)); add(disabledButtonLayoutPanel); button = new WButton("Disabled button"); button.setDisabled(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); disabledButtonLayoutPanel.add(button); button = new WButton("Disabled button as link"); button.setDisabled(true); button.setRenderAsLink(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); disabledButtonLayoutPanel.add(button); add(new WHeading(HeadingLevel.H3, "Examples of disabled buttons displaying an image with imagePosition EAST")); disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX); disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE)); add(disabledButtonLayoutPanel); button = new WButton("Disabled button"); button.setDisabled(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); button.setImagePosition(ImagePosition.EAST); disabledButtonLayoutPanel.add(button); button = new WButton("Disabled button as link"); button.setDisabled(true); button.setRenderAsLink(true); button.setImage("/image/tick.png"); button.setToolTip("Checking currently disabled"); button.setImagePosition(ImagePosition.EAST); disabledButtonLayoutPanel.add(button); }
[ "private", "void", "addDisabledExamples", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"Examples of disabled buttons\"", ")", ")", ";", "WPanel", "disabledButtonLayoutPanel", "=", "new", "WPanel", "(", "WPanel", ".", "Type", ".", "BOX", ")", ";", "disabledButtonLayoutPanel", ".", "setLayout", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "LEFT", ",", "6", ",", "0", ",", "FlowLayout", ".", "ContentAlignment", ".", "BASELINE", ")", ")", ";", "add", "(", "disabledButtonLayoutPanel", ")", ";", "WButton", "button", "=", "new", "WButton", "(", "\"Disabled button\"", ")", ";", "button", ".", "setDisabled", "(", "true", ")", ";", "disabledButtonLayoutPanel", ".", "add", "(", "button", ")", ";", "button", "=", "new", "WButton", "(", "\"Disabled button as link\"", ")", ";", "button", ".", "setDisabled", "(", "true", ")", ";", "button", ".", "setRenderAsLink", "(", "true", ")", ";", "disabledButtonLayoutPanel", ".", "add", "(", "button", ")", ";", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Examples of disabled buttons displaying only an image\"", ")", ")", ";", "disabledButtonLayoutPanel", "=", "new", "WPanel", "(", "WPanel", ".", "Type", ".", "BOX", ")", ";", "disabledButtonLayoutPanel", ".", "setLayout", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "LEFT", ",", "6", ",", "0", ",", "FlowLayout", ".", "ContentAlignment", ".", "BASELINE", ")", ")", ";", "add", "(", "disabledButtonLayoutPanel", ")", ";", "button", "=", "new", "WButton", "(", "\"Disabled button\"", ")", ";", "button", ".", "setDisabled", "(", "true", ")", ";", "button", ".", "setImage", "(", "\"/image/tick.png\"", ")", ";", "button", ".", "setToolTip", "(", "\"Checking currently disabled\"", ")", ";", "disabledButtonLayoutPanel", ".", "add", "(", "button", ")", ";", "button", "=", "new", "WButton", "(", "\"Disabled button as link\"", ")", ";", "button", ".", "setDisabled", "(", "true", ")", ";", "button", ".", "setRenderAsLink", "(", "true", ")", ";", "button", ".", "setImage", "(", "\"/image/tick.png\"", ")", ";", "button", ".", "setToolTip", "(", "\"Checking currently disabled\"", ")", ";", "disabledButtonLayoutPanel", ".", "add", "(", "button", ")", ";", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Examples of disabled buttons displaying an image with imagePosition EAST\"", ")", ")", ";", "disabledButtonLayoutPanel", "=", "new", "WPanel", "(", "WPanel", ".", "Type", ".", "BOX", ")", ";", "disabledButtonLayoutPanel", ".", "setLayout", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "LEFT", ",", "6", ",", "0", ",", "FlowLayout", ".", "ContentAlignment", ".", "BASELINE", ")", ")", ";", "add", "(", "disabledButtonLayoutPanel", ")", ";", "button", "=", "new", "WButton", "(", "\"Disabled button\"", ")", ";", "button", ".", "setDisabled", "(", "true", ")", ";", "button", ".", "setImage", "(", "\"/image/tick.png\"", ")", ";", "button", ".", "setToolTip", "(", "\"Checking currently disabled\"", ")", ";", "button", ".", "setImagePosition", "(", "ImagePosition", ".", "EAST", ")", ";", "disabledButtonLayoutPanel", ".", "add", "(", "button", ")", ";", "button", "=", "new", "WButton", "(", "\"Disabled button as link\"", ")", ";", "button", ".", "setDisabled", "(", "true", ")", ";", "button", ".", "setRenderAsLink", "(", "true", ")", ";", "button", ".", "setImage", "(", "\"/image/tick.png\"", ")", ";", "button", ".", "setToolTip", "(", "\"Checking currently disabled\"", ")", ";", "button", ".", "setImagePosition", "(", "ImagePosition", ".", "EAST", ")", ";", "disabledButtonLayoutPanel", ".", "add", "(", "button", ")", ";", "}" ]
Examples of disabled buttons in various guises.
[ "Examples", "of", "disabled", "buttons", "in", "various", "guises", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java#L316-L370
139,173
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java
WButtonExample.addAntiPatternExamples
private void addAntiPatternExamples() { add(new WHeading(HeadingLevel.H2, "WButton anti-pattern examples")); add(new WMessageBox(WMessageBox.WARN, "These examples are purposely bad and should not be used as samples of how to use WComponents but samples of how NOT to use them.")); add(new WHeading(HeadingLevel.H3, "WButton without a good label")); add(new WButton("\u2002")); add(new ExplanatoryText("A button without a text label is very bad")); add(new WHeading(HeadingLevel.H3, "WButton with a WImage but without a good label")); WButton button = new WButton(""); button.setImage("/image/help.png"); add(button); add(new ExplanatoryText( "A button without a text label is very bad, even if you think the image is sufficient. The text label becomes the image alt text.")); }
java
private void addAntiPatternExamples() { add(new WHeading(HeadingLevel.H2, "WButton anti-pattern examples")); add(new WMessageBox(WMessageBox.WARN, "These examples are purposely bad and should not be used as samples of how to use WComponents but samples of how NOT to use them.")); add(new WHeading(HeadingLevel.H3, "WButton without a good label")); add(new WButton("\u2002")); add(new ExplanatoryText("A button without a text label is very bad")); add(new WHeading(HeadingLevel.H3, "WButton with a WImage but without a good label")); WButton button = new WButton(""); button.setImage("/image/help.png"); add(button); add(new ExplanatoryText( "A button without a text label is very bad, even if you think the image is sufficient. The text label becomes the image alt text.")); }
[ "private", "void", "addAntiPatternExamples", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"WButton anti-pattern examples\"", ")", ")", ";", "add", "(", "new", "WMessageBox", "(", "WMessageBox", ".", "WARN", ",", "\"These examples are purposely bad and should not be used as samples of how to use WComponents but samples of how NOT to use them.\"", ")", ")", ";", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"WButton without a good label\"", ")", ")", ";", "add", "(", "new", "WButton", "(", "\"\\u2002\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"A button without a text label is very bad\"", ")", ")", ";", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"WButton with a WImage but without a good label\"", ")", ")", ";", "WButton", "button", "=", "new", "WButton", "(", "\"\"", ")", ";", "button", ".", "setImage", "(", "\"/image/help.png\"", ")", ";", "add", "(", "button", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"A button without a text label is very bad, even if you think the image is sufficient. The text label becomes the image alt text.\"", ")", ")", ";", "}" ]
Examples of what not to do when using WButton.
[ "Examples", "of", "what", "not", "to", "do", "when", "using", "WButton", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java#L375-L391
139,174
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java
WButtonExample.handleRequest
@Override public void handleRequest(final Request request) { if (plainBtn.isPressed()) { WMessages.getInstance(this).info("Plain button pressed."); } if (linkBtn.isPressed()) { WMessages.getInstance(this).info("Link button pressed."); } }
java
@Override public void handleRequest(final Request request) { if (plainBtn.isPressed()) { WMessages.getInstance(this).info("Plain button pressed."); } if (linkBtn.isPressed()) { WMessages.getInstance(this).info("Link button pressed."); } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "if", "(", "plainBtn", ".", "isPressed", "(", ")", ")", "{", "WMessages", ".", "getInstance", "(", "this", ")", ".", "info", "(", "\"Plain button pressed.\"", ")", ";", "}", "if", "(", "linkBtn", ".", "isPressed", "(", ")", ")", "{", "WMessages", ".", "getInstance", "(", "this", ")", ".", "info", "(", "\"Link button pressed.\"", ")", ";", "}", "}" ]
Override handleRequest in order to perform processing specific to this example. Normally, you would attach actions to a button rather than calling "isPressed" on each button. @param request the request being responded to.
[ "Override", "handleRequest", "in", "order", "to", "perform", "processing", "specific", "to", "this", "example", ".", "Normally", "you", "would", "attach", "actions", "to", "a", "button", "rather", "than", "calling", "isPressed", "on", "each", "button", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WButtonExample.java#L407-L416
139,175
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SelectListUtil.java
SelectListUtil.containsOption
public static boolean containsOption(final List<?> options, final Object findOption) { if (options != null) { for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null) { for (Object nestedOption : groupOptions) { if (Util.equals(nestedOption, findOption)) { return true; } } } } else if (Util.equals(option, findOption)) { return true; } } } return false; }
java
public static boolean containsOption(final List<?> options, final Object findOption) { if (options != null) { for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null) { for (Object nestedOption : groupOptions) { if (Util.equals(nestedOption, findOption)) { return true; } } } } else if (Util.equals(option, findOption)) { return true; } } } return false; }
[ "public", "static", "boolean", "containsOption", "(", "final", "List", "<", "?", ">", "options", ",", "final", "Object", "findOption", ")", "{", "if", "(", "options", "!=", "null", ")", "{", "for", "(", "Object", "option", ":", "options", ")", "{", "if", "(", "option", "instanceof", "OptionGroup", ")", "{", "List", "<", "?", ">", "groupOptions", "=", "(", "(", "OptionGroup", ")", "option", ")", ".", "getOptions", "(", ")", ";", "if", "(", "groupOptions", "!=", "null", ")", "{", "for", "(", "Object", "nestedOption", ":", "groupOptions", ")", "{", "if", "(", "Util", ".", "equals", "(", "nestedOption", ",", "findOption", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "else", "if", "(", "Util", ".", "equals", "(", "option", ",", "findOption", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Iterate through the options to determine if an option exists. @param options the list of options @param findOption the option to search for @return true if the list of options contains the option
[ "Iterate", "through", "the", "options", "to", "determine", "if", "an", "option", "exists", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SelectListUtil.java#L28-L46
139,176
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SelectListUtil.java
SelectListUtil.getFirstOption
public static Object getFirstOption(final List<?> options) { if (options != null) { for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null && !groupOptions.isEmpty()) { return groupOptions.get(0); } } else { return option; } } } return null; }
java
public static Object getFirstOption(final List<?> options) { if (options != null) { for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null && !groupOptions.isEmpty()) { return groupOptions.get(0); } } else { return option; } } } return null; }
[ "public", "static", "Object", "getFirstOption", "(", "final", "List", "<", "?", ">", "options", ")", "{", "if", "(", "options", "!=", "null", ")", "{", "for", "(", "Object", "option", ":", "options", ")", "{", "if", "(", "option", "instanceof", "OptionGroup", ")", "{", "List", "<", "?", ">", "groupOptions", "=", "(", "(", "OptionGroup", ")", "option", ")", ".", "getOptions", "(", ")", ";", "if", "(", "groupOptions", "!=", "null", "&&", "!", "groupOptions", ".", "isEmpty", "(", ")", ")", "{", "return", "groupOptions", ".", "get", "(", "0", ")", ";", "}", "}", "else", "{", "return", "option", ";", "}", "}", "}", "return", "null", ";", "}" ]
Retrieve the first option. The first option maybe within an option group. @param options the list of options @return true the first option
[ "Retrieve", "the", "first", "option", ".", "The", "first", "option", "maybe", "within", "an", "option", "group", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SelectListUtil.java#L139-L153
139,177
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SelectListUtil.java
SelectListUtil.isLegacyMatch
@Deprecated private static boolean isLegacyMatch(final Object option, final Object data) { // Support legacy matching, which supported setSelected using String representations... String optionAsString = String.valueOf(option); String matchAsString = String.valueOf(data); boolean equal = Util.equals(optionAsString, matchAsString); return equal; }
java
@Deprecated private static boolean isLegacyMatch(final Object option, final Object data) { // Support legacy matching, which supported setSelected using String representations... String optionAsString = String.valueOf(option); String matchAsString = String.valueOf(data); boolean equal = Util.equals(optionAsString, matchAsString); return equal; }
[ "@", "Deprecated", "private", "static", "boolean", "isLegacyMatch", "(", "final", "Object", "option", ",", "final", "Object", "data", ")", "{", "// Support legacy matching, which supported setSelected using String representations...", "String", "optionAsString", "=", "String", ".", "valueOf", "(", "option", ")", ";", "String", "matchAsString", "=", "String", ".", "valueOf", "(", "data", ")", ";", "boolean", "equal", "=", "Util", ".", "equals", "(", "optionAsString", ",", "matchAsString", ")", ";", "return", "equal", ";", "}" ]
Check for legacy matching, which supported setSelected using String representations. @param option the option to test for a match @param data the test data value @return true if the option is a legacy match @deprecated Support for legacy matching will be removed
[ "Check", "for", "legacy", "matching", "which", "supported", "setSelected", "using", "String", "representations", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SelectListUtil.java#L175-L182
139,178
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTemplateRenderer.java
WTemplateRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTemplate template = (WTemplate) component; // Setup the context Map<String, Object> context = new HashMap<>(); // Make the component available under the "wc" key. context.put("wc", template); // Load the parameters context.putAll(template.getParameters()); // Get template renderer for the engine String engine = template.getEngineName(); if (Util.empty(engine)) { engine = ConfigurationProperties.getDefaultRenderingEngine(); } TemplateRenderer templateRenderer = TemplateRendererFactory.newInstance(engine); // Render if (!Util.empty(template.getTemplateName())) { // Render the template templateRenderer.renderTemplate(template.getTemplateName(), context, template.getTaggedComponents(), renderContext.getWriter(), template.getEngineOptions()); } else if (!Util.empty(template.getInlineTemplate())) { // Render inline templateRenderer.renderInline(template.getInlineTemplate(), context, template.getTaggedComponents(), renderContext.getWriter(), template.getEngineOptions()); } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTemplate template = (WTemplate) component; // Setup the context Map<String, Object> context = new HashMap<>(); // Make the component available under the "wc" key. context.put("wc", template); // Load the parameters context.putAll(template.getParameters()); // Get template renderer for the engine String engine = template.getEngineName(); if (Util.empty(engine)) { engine = ConfigurationProperties.getDefaultRenderingEngine(); } TemplateRenderer templateRenderer = TemplateRendererFactory.newInstance(engine); // Render if (!Util.empty(template.getTemplateName())) { // Render the template templateRenderer.renderTemplate(template.getTemplateName(), context, template.getTaggedComponents(), renderContext.getWriter(), template.getEngineOptions()); } else if (!Util.empty(template.getInlineTemplate())) { // Render inline templateRenderer.renderInline(template.getInlineTemplate(), context, template.getTaggedComponents(), renderContext.getWriter(), template.getEngineOptions()); } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTemplate", "template", "=", "(", "WTemplate", ")", "component", ";", "// Setup the context", "Map", "<", "String", ",", "Object", ">", "context", "=", "new", "HashMap", "<>", "(", ")", ";", "// Make the component available under the \"wc\" key.", "context", ".", "put", "(", "\"wc\"", ",", "template", ")", ";", "// Load the parameters", "context", ".", "putAll", "(", "template", ".", "getParameters", "(", ")", ")", ";", "// Get template renderer for the engine", "String", "engine", "=", "template", ".", "getEngineName", "(", ")", ";", "if", "(", "Util", ".", "empty", "(", "engine", ")", ")", "{", "engine", "=", "ConfigurationProperties", ".", "getDefaultRenderingEngine", "(", ")", ";", "}", "TemplateRenderer", "templateRenderer", "=", "TemplateRendererFactory", ".", "newInstance", "(", "engine", ")", ";", "// Render", "if", "(", "!", "Util", ".", "empty", "(", "template", ".", "getTemplateName", "(", ")", ")", ")", "{", "// Render the template", "templateRenderer", ".", "renderTemplate", "(", "template", ".", "getTemplateName", "(", ")", ",", "context", ",", "template", ".", "getTaggedComponents", "(", ")", ",", "renderContext", ".", "getWriter", "(", ")", ",", "template", ".", "getEngineOptions", "(", ")", ")", ";", "}", "else", "if", "(", "!", "Util", ".", "empty", "(", "template", ".", "getInlineTemplate", "(", ")", ")", ")", "{", "// Render inline", "templateRenderer", ".", "renderInline", "(", "template", ".", "getInlineTemplate", "(", ")", ",", "context", ",", "template", ".", "getTaggedComponents", "(", ")", ",", "renderContext", ".", "getWriter", "(", ")", ",", "template", ".", "getEngineOptions", "(", ")", ")", ";", "}", "}" ]
Paints the given WTemplate. @param component the WTemplate to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTemplate", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTemplateRenderer.java#L28-L56
139,179
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/DisplayComponent.java
DisplayComponent.updateComponent
@Override public void updateComponent(final Object data) { MyData myData = (MyData) data; name.setText("<B>" + myData.getName() + "</B>"); count.setText(String.valueOf(myData.getCount())); }
java
@Override public void updateComponent(final Object data) { MyData myData = (MyData) data; name.setText("<B>" + myData.getName() + "</B>"); count.setText(String.valueOf(myData.getCount())); }
[ "@", "Override", "public", "void", "updateComponent", "(", "final", "Object", "data", ")", "{", "MyData", "myData", "=", "(", "MyData", ")", "data", ";", "name", ".", "setText", "(", "\"<B>\"", "+", "myData", ".", "getName", "(", ")", "+", "\"</B>\"", ")", ";", "count", ".", "setText", "(", "String", ".", "valueOf", "(", "myData", ".", "getCount", "(", ")", ")", ")", ";", "}" ]
Copies data from the Model into the View. @param data the MyData bean to set on the component.
[ "Copies", "data", "from", "the", "Model", "into", "the", "View", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/DisplayComponent.java#L45-L50
139,180
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java
TransformXMLInterceptor.paint
@Override public void paint(final RenderContext renderContext) { if (!doTransform) { super.paint(renderContext); return; } if (!(renderContext instanceof WebXmlRenderContext)) { LOG.warn("Unable to transform a " + renderContext); super.paint(renderContext); return; } LOG.debug("Transform XML Interceptor: Start"); UIContext uic = UIContextHolder.getCurrent(); // Set up a render context to buffer the XML payload. StringWriter xmlBuffer = new StringWriter(); PrintWriter xmlWriter = new PrintWriter(xmlBuffer); WebXmlRenderContext xmlContext = new WebXmlRenderContext(xmlWriter, uic.getLocale()); super.paint(xmlContext); // write the XML to the buffer // Get a handle to the true PrintWriter. WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext; PrintWriter writer = webRenderContext.getWriter(); /* * Switch the response content-type to HTML. * In theory the transformation could be to ANYTHING (not just HTML) so perhaps it would make more sense to * write a new interceptor "ContentTypeInterceptor" which attempts to sniff payloads and choose the correct * content-type. This is exactly the kind of thing IE6 loved to do, so perhaps it's a bad idea. */ Response response = getResponse(); response.setContentType(WebUtilities.CONTENT_TYPE_HTML); String xml = xmlBuffer.toString(); if (isAllowCorruptCharacters() && !Util.empty(xml)) { // Remove illegal HTML characters from the content before transforming it. xml = removeCorruptCharacters(xml); } // Double encode template tokens in the XML xml = WebUtilities.doubleEncodeBrackets(xml); // Setup temp writer StringWriter tempBuffer = new StringWriter(); PrintWriter tempWriter = new PrintWriter(tempBuffer); // Perform the transformation and write the result. transform(xml, uic, tempWriter); // Decode Double Encoded Brackets String tempResp = tempBuffer.toString(); tempResp = WebUtilities.doubleDecodeBrackets(tempResp); // Write response writer.write(tempResp); LOG.debug("Transform XML Interceptor: Finished"); }
java
@Override public void paint(final RenderContext renderContext) { if (!doTransform) { super.paint(renderContext); return; } if (!(renderContext instanceof WebXmlRenderContext)) { LOG.warn("Unable to transform a " + renderContext); super.paint(renderContext); return; } LOG.debug("Transform XML Interceptor: Start"); UIContext uic = UIContextHolder.getCurrent(); // Set up a render context to buffer the XML payload. StringWriter xmlBuffer = new StringWriter(); PrintWriter xmlWriter = new PrintWriter(xmlBuffer); WebXmlRenderContext xmlContext = new WebXmlRenderContext(xmlWriter, uic.getLocale()); super.paint(xmlContext); // write the XML to the buffer // Get a handle to the true PrintWriter. WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext; PrintWriter writer = webRenderContext.getWriter(); /* * Switch the response content-type to HTML. * In theory the transformation could be to ANYTHING (not just HTML) so perhaps it would make more sense to * write a new interceptor "ContentTypeInterceptor" which attempts to sniff payloads and choose the correct * content-type. This is exactly the kind of thing IE6 loved to do, so perhaps it's a bad idea. */ Response response = getResponse(); response.setContentType(WebUtilities.CONTENT_TYPE_HTML); String xml = xmlBuffer.toString(); if (isAllowCorruptCharacters() && !Util.empty(xml)) { // Remove illegal HTML characters from the content before transforming it. xml = removeCorruptCharacters(xml); } // Double encode template tokens in the XML xml = WebUtilities.doubleEncodeBrackets(xml); // Setup temp writer StringWriter tempBuffer = new StringWriter(); PrintWriter tempWriter = new PrintWriter(tempBuffer); // Perform the transformation and write the result. transform(xml, uic, tempWriter); // Decode Double Encoded Brackets String tempResp = tempBuffer.toString(); tempResp = WebUtilities.doubleDecodeBrackets(tempResp); // Write response writer.write(tempResp); LOG.debug("Transform XML Interceptor: Finished"); }
[ "@", "Override", "public", "void", "paint", "(", "final", "RenderContext", "renderContext", ")", "{", "if", "(", "!", "doTransform", ")", "{", "super", ".", "paint", "(", "renderContext", ")", ";", "return", ";", "}", "if", "(", "!", "(", "renderContext", "instanceof", "WebXmlRenderContext", ")", ")", "{", "LOG", ".", "warn", "(", "\"Unable to transform a \"", "+", "renderContext", ")", ";", "super", ".", "paint", "(", "renderContext", ")", ";", "return", ";", "}", "LOG", ".", "debug", "(", "\"Transform XML Interceptor: Start\"", ")", ";", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "// Set up a render context to buffer the XML payload.", "StringWriter", "xmlBuffer", "=", "new", "StringWriter", "(", ")", ";", "PrintWriter", "xmlWriter", "=", "new", "PrintWriter", "(", "xmlBuffer", ")", ";", "WebXmlRenderContext", "xmlContext", "=", "new", "WebXmlRenderContext", "(", "xmlWriter", ",", "uic", ".", "getLocale", "(", ")", ")", ";", "super", ".", "paint", "(", "xmlContext", ")", ";", "// write the XML to the buffer", "// Get a handle to the true PrintWriter.", "WebXmlRenderContext", "webRenderContext", "=", "(", "WebXmlRenderContext", ")", "renderContext", ";", "PrintWriter", "writer", "=", "webRenderContext", ".", "getWriter", "(", ")", ";", "/*\n\t\t * Switch the response content-type to HTML.\n\t\t * In theory the transformation could be to ANYTHING (not just HTML) so perhaps it would make more sense to\n\t\t * write a new interceptor \"ContentTypeInterceptor\" which attempts to sniff payloads and choose the correct\n\t\t * content-type. This is exactly the kind of thing IE6 loved to do, so perhaps it's a bad idea.\n\t\t */", "Response", "response", "=", "getResponse", "(", ")", ";", "response", ".", "setContentType", "(", "WebUtilities", ".", "CONTENT_TYPE_HTML", ")", ";", "String", "xml", "=", "xmlBuffer", ".", "toString", "(", ")", ";", "if", "(", "isAllowCorruptCharacters", "(", ")", "&&", "!", "Util", ".", "empty", "(", "xml", ")", ")", "{", "// Remove illegal HTML characters from the content before transforming it.", "xml", "=", "removeCorruptCharacters", "(", "xml", ")", ";", "}", "// Double encode template tokens in the XML", "xml", "=", "WebUtilities", ".", "doubleEncodeBrackets", "(", "xml", ")", ";", "// Setup temp writer", "StringWriter", "tempBuffer", "=", "new", "StringWriter", "(", ")", ";", "PrintWriter", "tempWriter", "=", "new", "PrintWriter", "(", "tempBuffer", ")", ";", "// Perform the transformation and write the result.", "transform", "(", "xml", ",", "uic", ",", "tempWriter", ")", ";", "// Decode Double Encoded Brackets", "String", "tempResp", "=", "tempBuffer", ".", "toString", "(", ")", ";", "tempResp", "=", "WebUtilities", ".", "doubleDecodeBrackets", "(", "tempResp", ")", ";", "// Write response", "writer", ".", "write", "(", "tempResp", ")", ";", "LOG", ".", "debug", "(", "\"Transform XML Interceptor: Finished\"", ")", ";", "}" ]
Override paint to perform XML to HTML transformation. @param renderContext the renderContext to send the output to.
[ "Override", "paint", "to", "perform", "XML", "to", "HTML", "transformation", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java#L115-L172
139,181
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java
TransformXMLInterceptor.transform
private void transform(final String xml, final UIContext uic, final PrintWriter writer) { Transformer transformer = newTransformer(); Source inputXml; try { inputXml = new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8"))); StreamResult result = new StreamResult(writer); if (debugRequested) { transformer.setParameter("isDebug", 1); } transformer.transform(inputXml, result); } catch (UnsupportedEncodingException | TransformerException ex) { throw new SystemException("Could not transform xml", ex); } }
java
private void transform(final String xml, final UIContext uic, final PrintWriter writer) { Transformer transformer = newTransformer(); Source inputXml; try { inputXml = new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8"))); StreamResult result = new StreamResult(writer); if (debugRequested) { transformer.setParameter("isDebug", 1); } transformer.transform(inputXml, result); } catch (UnsupportedEncodingException | TransformerException ex) { throw new SystemException("Could not transform xml", ex); } }
[ "private", "void", "transform", "(", "final", "String", "xml", ",", "final", "UIContext", "uic", ",", "final", "PrintWriter", "writer", ")", "{", "Transformer", "transformer", "=", "newTransformer", "(", ")", ";", "Source", "inputXml", ";", "try", "{", "inputXml", "=", "new", "StreamSource", "(", "new", "ByteArrayInputStream", "(", "xml", ".", "getBytes", "(", "\"utf-8\"", ")", ")", ")", ";", "StreamResult", "result", "=", "new", "StreamResult", "(", "writer", ")", ";", "if", "(", "debugRequested", ")", "{", "transformer", ".", "setParameter", "(", "\"isDebug\"", ",", "1", ")", ";", "}", "transformer", ".", "transform", "(", "inputXml", ",", "result", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "|", "TransformerException", "ex", ")", "{", "throw", "new", "SystemException", "(", "\"Could not transform xml\"", ",", "ex", ")", ";", "}", "}" ]
Transform the UI XML to HTML using the correct XSLT from the classpath. @param xml The XML to transform. @param uic The UIContext used to determine variables such as locale. @param writer The result of the transformation will be written to this writer.
[ "Transform", "the", "UI", "XML", "to", "HTML", "using", "the", "correct", "XSLT", "from", "the", "classpath", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java#L181-L195
139,182
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java
TransformXMLInterceptor.initTemplates
private static Templates initTemplates() { try { URL xsltURL = ThemeUtil.class.getResource(RESOURCE_NAME); if (xsltURL != null) { Source xsltSource = new StreamSource(xsltURL.openStream(), xsltURL.toExternalForm()); TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl(); Templates templates = factory.newTemplates(xsltSource); LOG.debug("Generated XSLT templates for: " + RESOURCE_NAME); return templates; } else { // Server-side XSLT enabled but theme resource not on classpath. throw new IllegalStateException(RESOURCE_NAME + " not on classpath"); } } catch (IOException | TransformerConfigurationException ex) { throw new SystemException("Could not create transformer for " + RESOURCE_NAME, ex); } }
java
private static Templates initTemplates() { try { URL xsltURL = ThemeUtil.class.getResource(RESOURCE_NAME); if (xsltURL != null) { Source xsltSource = new StreamSource(xsltURL.openStream(), xsltURL.toExternalForm()); TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl(); Templates templates = factory.newTemplates(xsltSource); LOG.debug("Generated XSLT templates for: " + RESOURCE_NAME); return templates; } else { // Server-side XSLT enabled but theme resource not on classpath. throw new IllegalStateException(RESOURCE_NAME + " not on classpath"); } } catch (IOException | TransformerConfigurationException ex) { throw new SystemException("Could not create transformer for " + RESOURCE_NAME, ex); } }
[ "private", "static", "Templates", "initTemplates", "(", ")", "{", "try", "{", "URL", "xsltURL", "=", "ThemeUtil", ".", "class", ".", "getResource", "(", "RESOURCE_NAME", ")", ";", "if", "(", "xsltURL", "!=", "null", ")", "{", "Source", "xsltSource", "=", "new", "StreamSource", "(", "xsltURL", ".", "openStream", "(", ")", ",", "xsltURL", ".", "toExternalForm", "(", ")", ")", ";", "TransformerFactory", "factory", "=", "new", "net", ".", "sf", ".", "saxon", ".", "TransformerFactoryImpl", "(", ")", ";", "Templates", "templates", "=", "factory", ".", "newTemplates", "(", "xsltSource", ")", ";", "LOG", ".", "debug", "(", "\"Generated XSLT templates for: \"", "+", "RESOURCE_NAME", ")", ";", "return", "templates", ";", "}", "else", "{", "// Server-side XSLT enabled but theme resource not on classpath.", "throw", "new", "IllegalStateException", "(", "RESOURCE_NAME", "+", "\" not on classpath\"", ")", ";", "}", "}", "catch", "(", "IOException", "|", "TransformerConfigurationException", "ex", ")", "{", "throw", "new", "SystemException", "(", "\"Could not create transformer for \"", "+", "RESOURCE_NAME", ",", "ex", ")", ";", "}", "}" ]
Statically initialize the XSLT templates that are cached for all future transforms. @return the XSLT Templates.
[ "Statically", "initialize", "the", "XSLT", "templates", "that", "are", "cached", "for", "all", "future", "transforms", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java#L221-L237
139,183
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java
TransformXMLInterceptor.removeCorruptCharacters
private static String removeCorruptCharacters(final String input) { if (Util.empty(input)) { return input; } return ESCAPE_BAD_XML10.translate(input); }
java
private static String removeCorruptCharacters(final String input) { if (Util.empty(input)) { return input; } return ESCAPE_BAD_XML10.translate(input); }
[ "private", "static", "String", "removeCorruptCharacters", "(", "final", "String", "input", ")", "{", "if", "(", "Util", ".", "empty", "(", "input", ")", ")", "{", "return", "input", ";", "}", "return", "ESCAPE_BAD_XML10", ".", "translate", "(", "input", ")", ";", "}" ]
Remove bad characters in XML. @param input The String to escape. @return the clean string
[ "Remove", "bad", "characters", "in", "XML", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/TransformXMLInterceptor.java#L252-L257
139,184
podio/podio-java
src/main/java/com/podio/hook/HookAPI.java
HookAPI.create
public int create(Reference object, HookCreate create) { return getResourceFactory() .getApiResource( "/hook/" + object.getType() + "/" + object.getId() + "/") .entity(create, MediaType.APPLICATION_JSON) .post(HookCreateResponse.class).getId(); }
java
public int create(Reference object, HookCreate create) { return getResourceFactory() .getApiResource( "/hook/" + object.getType() + "/" + object.getId() + "/") .entity(create, MediaType.APPLICATION_JSON) .post(HookCreateResponse.class).getId(); }
[ "public", "int", "create", "(", "Reference", "object", ",", "HookCreate", "create", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/hook/\"", "+", "object", ".", "getType", "(", ")", "+", "\"/\"", "+", "object", ".", "getId", "(", ")", "+", "\"/\"", ")", ".", "entity", "(", "create", ",", "MediaType", ".", "APPLICATION_JSON", ")", ".", "post", "(", "HookCreateResponse", ".", "class", ")", ".", "getId", "(", ")", ";", "}" ]
Create a new hook on the given object. @param object The reference to the object the hook should be created on @param create The details for the new hook @return The id of the newly created hook
[ "Create", "a", "new", "hook", "on", "the", "given", "object", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/hook/HookAPI.java#L28-L35
139,185
podio/podio-java
src/main/java/com/podio/hook/HookAPI.java
HookAPI.get
public List<Hook> get(Reference object) { return getResourceFactory().getApiResource( "/hook/" + object.getType() + "/" + object.getId() + "/").get( new GenericType<List<Hook>>() { }); }
java
public List<Hook> get(Reference object) { return getResourceFactory().getApiResource( "/hook/" + object.getType() + "/" + object.getId() + "/").get( new GenericType<List<Hook>>() { }); }
[ "public", "List", "<", "Hook", ">", "get", "(", "Reference", "object", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/hook/\"", "+", "object", ".", "getType", "(", ")", "+", "\"/\"", "+", "object", ".", "getId", "(", ")", "+", "\"/\"", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "Hook", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Returns the hooks on the object. @param object The reference to the object to get hooks for @return The list of hooks on the object
[ "Returns", "the", "hooks", "on", "the", "object", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/hook/HookAPI.java#L55-L60
139,186
podio/podio-java
src/main/java/com/podio/hook/HookAPI.java
HookAPI.requestVerification
public void requestVerification(int id) { getResourceFactory().getApiResource("/hook/" + id + "/verify/request") .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); }
java
public void requestVerification(int id) { getResourceFactory().getApiResource("/hook/" + id + "/verify/request") .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); }
[ "public", "void", "requestVerification", "(", "int", "id", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/hook/\"", "+", "id", "+", "\"/verify/request\"", ")", ".", "entity", "(", "new", "Empty", "(", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", ")", ";", "}" ]
Request the hook to be validated. This will cause the hook to send a request to the URL with the parameter "type" set to "hook.verify" and "code" set to the verification code. The endpoint must then call the validate method with the code to complete the verification. @param id The id of the hook to be verified
[ "Request", "the", "hook", "to", "be", "validated", ".", "This", "will", "cause", "the", "hook", "to", "send", "a", "request", "to", "the", "URL", "with", "the", "parameter", "type", "set", "to", "hook", ".", "verify", "and", "code", "set", "to", "the", "verification", "code", ".", "The", "endpoint", "must", "then", "call", "the", "validate", "method", "with", "the", "code", "to", "complete", "the", "verification", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/hook/HookAPI.java#L71-L74
139,187
podio/podio-java
src/main/java/com/podio/hook/HookAPI.java
HookAPI.validateVerification
public void validateVerification(int id, String code) { getResourceFactory().getApiResource("/hook/" + id + "/verify/validate") .entity(new HookValidate(code), MediaType.APPLICATION_JSON) .post(); }
java
public void validateVerification(int id, String code) { getResourceFactory().getApiResource("/hook/" + id + "/verify/validate") .entity(new HookValidate(code), MediaType.APPLICATION_JSON) .post(); }
[ "public", "void", "validateVerification", "(", "int", "id", ",", "String", "code", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/hook/\"", "+", "id", "+", "\"/verify/validate\"", ")", ".", "entity", "(", "new", "HookValidate", "(", "code", ")", ",", "MediaType", ".", "APPLICATION_JSON", ")", ".", "post", "(", ")", ";", "}" ]
Validates the hook using the code received from the verify call. On successful validation the hook will become active. @param id The id of the hook to be verified @param code The code received from the call to the endpoint
[ "Validates", "the", "hook", "using", "the", "code", "received", "from", "the", "verify", "call", ".", "On", "successful", "validation", "the", "hook", "will", "become", "active", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/hook/HookAPI.java#L85-L89
139,188
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRadioButton.java
WRadioButton.handleRequest
@Override public void handleRequest(final Request request) { // Protect against client-side tampering of disabled/read-only fields. if (isDisabled() || isReadOnly()) { return; } RadioButtonGroup currentGroup = getGroup(); // Check if the group is not on the request (do nothing) if (!currentGroup.isPresent(request)) { return; } // Check if the group has a null value (will be handled by the group handle request) if (request.getParameter(currentGroup.getId()) == null) { return; } // Get the groups value on the request String requestValue = currentGroup.getRequestValue(request); // Check if this button's value matches the request boolean onRequest = Util.equals(requestValue, getValue()); if (onRequest) { boolean changed = currentGroup.handleButtonOnRequest(request); if (changed && (UIContextHolder.getCurrent() != null) && (UIContextHolder.getCurrent().getFocussed() == null) && currentGroup.isCurrentAjaxTrigger()) { setFocussed(); } } }
java
@Override public void handleRequest(final Request request) { // Protect against client-side tampering of disabled/read-only fields. if (isDisabled() || isReadOnly()) { return; } RadioButtonGroup currentGroup = getGroup(); // Check if the group is not on the request (do nothing) if (!currentGroup.isPresent(request)) { return; } // Check if the group has a null value (will be handled by the group handle request) if (request.getParameter(currentGroup.getId()) == null) { return; } // Get the groups value on the request String requestValue = currentGroup.getRequestValue(request); // Check if this button's value matches the request boolean onRequest = Util.equals(requestValue, getValue()); if (onRequest) { boolean changed = currentGroup.handleButtonOnRequest(request); if (changed && (UIContextHolder.getCurrent() != null) && (UIContextHolder.getCurrent().getFocussed() == null) && currentGroup.isCurrentAjaxTrigger()) { setFocussed(); } } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "// Protect against client-side tampering of disabled/read-only fields.", "if", "(", "isDisabled", "(", ")", "||", "isReadOnly", "(", ")", ")", "{", "return", ";", "}", "RadioButtonGroup", "currentGroup", "=", "getGroup", "(", ")", ";", "// Check if the group is not on the request (do nothing)", "if", "(", "!", "currentGroup", ".", "isPresent", "(", "request", ")", ")", "{", "return", ";", "}", "// Check if the group has a null value (will be handled by the group handle request)", "if", "(", "request", ".", "getParameter", "(", "currentGroup", ".", "getId", "(", ")", ")", "==", "null", ")", "{", "return", ";", "}", "// Get the groups value on the request", "String", "requestValue", "=", "currentGroup", ".", "getRequestValue", "(", "request", ")", ";", "// Check if this button's value matches the request", "boolean", "onRequest", "=", "Util", ".", "equals", "(", "requestValue", ",", "getValue", "(", ")", ")", ";", "if", "(", "onRequest", ")", "{", "boolean", "changed", "=", "currentGroup", ".", "handleButtonOnRequest", "(", "request", ")", ";", "if", "(", "changed", "&&", "(", "UIContextHolder", ".", "getCurrent", "(", ")", "!=", "null", ")", "&&", "(", "UIContextHolder", ".", "getCurrent", "(", ")", ".", "getFocussed", "(", ")", "==", "null", ")", "&&", "currentGroup", ".", "isCurrentAjaxTrigger", "(", ")", ")", "{", "setFocussed", "(", ")", ";", "}", "}", "}" ]
This method will only process the request if the value for the group matches the button's value. @param request the request being processed.
[ "This", "method", "will", "only", "process", "the", "request", "if", "the", "value", "for", "the", "group", "matches", "the", "button", "s", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRadioButton.java#L68-L100
139,189
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRadioButton.java
WRadioButton.setSelected
public void setSelected(final boolean selected) { if (selected) { if (isDisabled()) { throw new IllegalStateException("Cannot select a disabled radio button"); } getGroup().setSelectedValue(getValue()); } else if (isSelected()) { // Clear selection getGroup().setData(null); } }
java
public void setSelected(final boolean selected) { if (selected) { if (isDisabled()) { throw new IllegalStateException("Cannot select a disabled radio button"); } getGroup().setSelectedValue(getValue()); } else if (isSelected()) { // Clear selection getGroup().setData(null); } }
[ "public", "void", "setSelected", "(", "final", "boolean", "selected", ")", "{", "if", "(", "selected", ")", "{", "if", "(", "isDisabled", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot select a disabled radio button\"", ")", ";", "}", "getGroup", "(", ")", ".", "setSelectedValue", "(", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "isSelected", "(", ")", ")", "{", "// Clear selection", "getGroup", "(", ")", ".", "setData", "(", "null", ")", ";", "}", "}" ]
Sets whether the radio button is selected. @param selected true if the button should be selected, false if not
[ "Sets", "whether", "the", "radio", "button", "is", "selected", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRadioButton.java#L126-L136
139,190
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.addJsUrl
public ApplicationResource addJsUrl(final String url) { if (Util.empty(url)) { throw new IllegalArgumentException("A URL must be provided."); } ApplicationResource res = new ApplicationResource(url); addJsResource(res); return res; }
java
public ApplicationResource addJsUrl(final String url) { if (Util.empty(url)) { throw new IllegalArgumentException("A URL must be provided."); } ApplicationResource res = new ApplicationResource(url); addJsResource(res); return res; }
[ "public", "ApplicationResource", "addJsUrl", "(", "final", "String", "url", ")", "{", "if", "(", "Util", ".", "empty", "(", "url", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A URL must be provided.\"", ")", ";", "}", "ApplicationResource", "res", "=", "new", "ApplicationResource", "(", "url", ")", ";", "addJsResource", "(", "res", ")", ";", "return", "res", ";", "}" ]
Add custom javaScript located at the specified URL to be used by the Application. @param url URL to a javaScript resource @return the application resource in which the URL details are held
[ "Add", "custom", "javaScript", "located", "at", "the", "specified", "URL", "to", "be", "used", "by", "the", "Application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L168-L175
139,191
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.addJsFile
public ApplicationResource addJsFile(final String fileName) { if (Util.empty(fileName)) { throw new IllegalArgumentException("A file name must be provided."); } InternalResource resource = new InternalResource(fileName, fileName); ApplicationResource res = new ApplicationResource(resource); addJsResource(res); return res; }
java
public ApplicationResource addJsFile(final String fileName) { if (Util.empty(fileName)) { throw new IllegalArgumentException("A file name must be provided."); } InternalResource resource = new InternalResource(fileName, fileName); ApplicationResource res = new ApplicationResource(resource); addJsResource(res); return res; }
[ "public", "ApplicationResource", "addJsFile", "(", "final", "String", "fileName", ")", "{", "if", "(", "Util", ".", "empty", "(", "fileName", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A file name must be provided.\"", ")", ";", "}", "InternalResource", "resource", "=", "new", "InternalResource", "(", "fileName", ",", "fileName", ")", ";", "ApplicationResource", "res", "=", "new", "ApplicationResource", "(", "resource", ")", ";", "addJsResource", "(", "res", ")", ";", "return", "res", ";", "}" ]
Add custom JavaScript held as an internal resource to be used by the application. @param fileName the JavaScript file name @return the application resource in which the resource details are held
[ "Add", "custom", "JavaScript", "held", "as", "an", "internal", "resource", "to", "be", "used", "by", "the", "application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L183-L191
139,192
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.addJsResource
public void addJsResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.jsResources == null) { model.jsResources = new ArrayList<>(); } else if (model.jsResources.contains(resource)) { return; } model.jsResources.add(resource); MemoryUtil.checkSize(model.jsResources.size(), this.getClass().getSimpleName()); }
java
public void addJsResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.jsResources == null) { model.jsResources = new ArrayList<>(); } else if (model.jsResources.contains(resource)) { return; } model.jsResources.add(resource); MemoryUtil.checkSize(model.jsResources.size(), this.getClass().getSimpleName()); }
[ "public", "void", "addJsResource", "(", "final", "ApplicationResource", "resource", ")", "{", "WApplicationModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "jsResources", "==", "null", ")", "{", "model", ".", "jsResources", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "else", "if", "(", "model", ".", "jsResources", ".", "contains", "(", "resource", ")", ")", "{", "return", ";", "}", "model", ".", "jsResources", ".", "add", "(", "resource", ")", ";", "MemoryUtil", ".", "checkSize", "(", "model", ".", "jsResources", ".", "size", "(", ")", ",", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}" ]
Add a custom javaScript resource that is to be loaded and used by the application. @param resource the JavaScript resource
[ "Add", "a", "custom", "javaScript", "resource", "that", "is", "to", "be", "loaded", "and", "used", "by", "the", "application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L198-L207
139,193
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.removeJsResource
public void removeJsResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.jsResources != null) { model.jsResources.remove(resource); } }
java
public void removeJsResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.jsResources != null) { model.jsResources.remove(resource); } }
[ "public", "void", "removeJsResource", "(", "final", "ApplicationResource", "resource", ")", "{", "WApplicationModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "jsResources", "!=", "null", ")", "{", "model", ".", "jsResources", ".", "remove", "(", "resource", ")", ";", "}", "}" ]
Remove a custom JavaScript resource. @param resource the javaScript resource to remove
[ "Remove", "a", "custom", "JavaScript", "resource", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L221-L226
139,194
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.addCssUrl
public ApplicationResource addCssUrl(final String url) { if (Util.empty(url)) { throw new IllegalArgumentException("A URL must be provided."); } ApplicationResource res = new ApplicationResource(url); addCssResource(res); return res; }
java
public ApplicationResource addCssUrl(final String url) { if (Util.empty(url)) { throw new IllegalArgumentException("A URL must be provided."); } ApplicationResource res = new ApplicationResource(url); addCssResource(res); return res; }
[ "public", "ApplicationResource", "addCssUrl", "(", "final", "String", "url", ")", "{", "if", "(", "Util", ".", "empty", "(", "url", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A URL must be provided.\"", ")", ";", "}", "ApplicationResource", "res", "=", "new", "ApplicationResource", "(", "url", ")", ";", "addCssResource", "(", "res", ")", ";", "return", "res", ";", "}" ]
Add custom CSS located at the specified URL to be used by the Application. @param url URL to a CSS resource @return the application resource in which the URL details are held
[ "Add", "custom", "CSS", "located", "at", "the", "specified", "URL", "to", "be", "used", "by", "the", "Application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L245-L252
139,195
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.addCssFile
public ApplicationResource addCssFile(final String fileName) { if (Util.empty(fileName)) { throw new IllegalArgumentException("A file name must be provided."); } InternalResource resource = new InternalResource(fileName, fileName); ApplicationResource res = new ApplicationResource(resource); addCssResource(res); return res; }
java
public ApplicationResource addCssFile(final String fileName) { if (Util.empty(fileName)) { throw new IllegalArgumentException("A file name must be provided."); } InternalResource resource = new InternalResource(fileName, fileName); ApplicationResource res = new ApplicationResource(resource); addCssResource(res); return res; }
[ "public", "ApplicationResource", "addCssFile", "(", "final", "String", "fileName", ")", "{", "if", "(", "Util", ".", "empty", "(", "fileName", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A file name must be provided.\"", ")", ";", "}", "InternalResource", "resource", "=", "new", "InternalResource", "(", "fileName", ",", "fileName", ")", ";", "ApplicationResource", "res", "=", "new", "ApplicationResource", "(", "resource", ")", ";", "addCssResource", "(", "res", ")", ";", "return", "res", ";", "}" ]
Add custom CSS held as an internal resource to be used by the Application. @param fileName the CSS file name @return the application resource in which the resource details are held
[ "Add", "custom", "CSS", "held", "as", "an", "internal", "resource", "to", "be", "used", "by", "the", "Application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L260-L268
139,196
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.addCssResource
public void addCssResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.cssResources == null) { model.cssResources = new ArrayList<>(); } else if (model.cssResources.contains(resource)) { return; } model.cssResources.add(resource); MemoryUtil.checkSize(model.cssResources.size(), this.getClass().getSimpleName()); }
java
public void addCssResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.cssResources == null) { model.cssResources = new ArrayList<>(); } else if (model.cssResources.contains(resource)) { return; } model.cssResources.add(resource); MemoryUtil.checkSize(model.cssResources.size(), this.getClass().getSimpleName()); }
[ "public", "void", "addCssResource", "(", "final", "ApplicationResource", "resource", ")", "{", "WApplicationModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "cssResources", "==", "null", ")", "{", "model", ".", "cssResources", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "else", "if", "(", "model", ".", "cssResources", ".", "contains", "(", "resource", ")", ")", "{", "return", ";", "}", "model", ".", "cssResources", ".", "add", "(", "resource", ")", ";", "MemoryUtil", ".", "checkSize", "(", "model", ".", "cssResources", ".", "size", "(", ")", ",", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}" ]
Add a custom CSS resource that will be loaded and used by this application. @param resource the CSS resource
[ "Add", "a", "custom", "CSS", "resource", "that", "will", "be", "loaded", "and", "used", "by", "this", "application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L275-L284
139,197
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java
WApplication.removeCssResource
public void removeCssResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.cssResources != null) { model.cssResources.remove(resource); } }
java
public void removeCssResource(final ApplicationResource resource) { WApplicationModel model = getOrCreateComponentModel(); if (model.cssResources != null) { model.cssResources.remove(resource); } }
[ "public", "void", "removeCssResource", "(", "final", "ApplicationResource", "resource", ")", "{", "WApplicationModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "cssResources", "!=", "null", ")", "{", "model", ".", "cssResources", ".", "remove", "(", "resource", ")", ";", "}", "}" ]
Remove a custom CSS resource. @param resource the CSS resource to remove
[ "Remove", "a", "custom", "CSS", "resource", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WApplication.java#L298-L303
139,198
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractInput.java
AbstractInput.validateComponent
@Override protected void validateComponent(final List<Diagnostic> diags) { // Mandatory validation if (isMandatory() && isEmpty()) { diags.add(createMandatoryDiagnostic()); } // Other validations List<FieldValidator> validators = getComponentModel().validators; if (validators != null) { for (FieldValidator validator : validators) { validator.validate(diags); } } }
java
@Override protected void validateComponent(final List<Diagnostic> diags) { // Mandatory validation if (isMandatory() && isEmpty()) { diags.add(createMandatoryDiagnostic()); } // Other validations List<FieldValidator> validators = getComponentModel().validators; if (validators != null) { for (FieldValidator validator : validators) { validator.validate(diags); } } }
[ "@", "Override", "protected", "void", "validateComponent", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "// Mandatory validation", "if", "(", "isMandatory", "(", ")", "&&", "isEmpty", "(", ")", ")", "{", "diags", ".", "add", "(", "createMandatoryDiagnostic", "(", ")", ")", ";", "}", "// Other validations", "List", "<", "FieldValidator", ">", "validators", "=", "getComponentModel", "(", ")", ".", "validators", ";", "if", "(", "validators", "!=", "null", ")", "{", "for", "(", "FieldValidator", "validator", ":", "validators", ")", "{", "validator", ".", "validate", "(", "diags", ")", ";", "}", "}", "}" ]
Override WComponent's validatorComponent in order to use the validators which have been added to this input field. Subclasses may still override this method, but it is suggested to call super.validateComponent to ensure that the validators are still used. @param diags the list into which any validation diagnostics are added.
[ "Override", "WComponent", "s", "validatorComponent", "in", "order", "to", "use", "the", "validators", "which", "have", "been", "added", "to", "this", "input", "field", ".", "Subclasses", "may", "still", "override", "this", "method", "but", "it", "is", "suggested", "to", "call", "super", ".", "validateComponent", "to", "ensure", "that", "the", "validators", "are", "still", "used", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractInput.java#L67-L82
139,199
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractInput.java
AbstractInput.setChangedInLastRequest
protected void setChangedInLastRequest(final boolean changed) { if (isChangedInLastRequest() != changed) { InputModel model = getOrCreateComponentModel(); model.changedInLastRequest = changed; } }
java
protected void setChangedInLastRequest(final boolean changed) { if (isChangedInLastRequest() != changed) { InputModel model = getOrCreateComponentModel(); model.changedInLastRequest = changed; } }
[ "protected", "void", "setChangedInLastRequest", "(", "final", "boolean", "changed", ")", "{", "if", "(", "isChangedInLastRequest", "(", ")", "!=", "changed", ")", "{", "InputModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "changedInLastRequest", "=", "changed", ";", "}", "}" ]
Set the changed flag to indicate if the component changed in the last request. @param changed true if the value changed in the request
[ "Set", "the", "changed", "flag", "to", "indicate", "if", "the", "component", "changed", "in", "the", "last", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractInput.java#L373-L378