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,300
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/WrongStepAjaxInterceptor.java
WrongStepAjaxInterceptor.buildApplicationUrl
private String buildApplicationUrl(final UIContext uic) { Environment env = uic.getEnvironment(); return env.getPostPath(); }
java
private String buildApplicationUrl(final UIContext uic) { Environment env = uic.getEnvironment(); return env.getPostPath(); }
[ "private", "String", "buildApplicationUrl", "(", "final", "UIContext", "uic", ")", "{", "Environment", "env", "=", "uic", ".", "getEnvironment", "(", ")", ";", "return", "env", ".", "getPostPath", "(", ")", ";", "}" ]
Build the url to refresh the application. @param uic the current user's context @return the application url
[ "Build", "the", "url", "to", "refresh", "the", "application", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/WrongStepAjaxInterceptor.java#L188-L191
139,301
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java
I18nUtilities.asMessage
public static Serializable asMessage(final String text, final Serializable... args) { if (text == null) { return null; } else if (args == null || args.length == 0) { return text; } else { return new Message(text, args); } }
java
public static Serializable asMessage(final String text, final Serializable... args) { if (text == null) { return null; } else if (args == null || args.length == 0) { return text; } else { return new Message(text, args); } }
[ "public", "static", "Serializable", "asMessage", "(", "final", "String", "text", ",", "final", "Serializable", "...", "args", ")", "{", "if", "(", "text", "==", "null", ")", "{", "return", "null", ";", "}", "else", "if", "(", "args", "==", "null", "||", "args", ".", "length", "==", "0", ")", "{", "return", "text", ";", "}", "else", "{", "return", "new", "Message", "(", "text", ",", "args", ")", ";", "}", "}" ]
Converts a message String and optional message arguments to a an appropriate format for internationalisation. @param text the message text. @param args the message arguments. @return a message in an appropriate format for internationalisation, may be null.
[ "Converts", "a", "message", "String", "and", "optional", "message", "arguments", "to", "a", "an", "appropriate", "format", "for", "internationalisation", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java#L56-L64
139,302
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java
I18nUtilities.format
public static String format(final Locale locale, final String text, final Object... args) { if (text == null) { return null; } String localisedText = getLocalisedText(locale, text); String message = localisedText == null ? text : localisedText; if (args != null) { try { return MessageFormat.format(message, args); } catch (IllegalArgumentException e) { LOG.error("Invalid message format for message " + message, e); } } return message; }
java
public static String format(final Locale locale, final String text, final Object... args) { if (text == null) { return null; } String localisedText = getLocalisedText(locale, text); String message = localisedText == null ? text : localisedText; if (args != null) { try { return MessageFormat.format(message, args); } catch (IllegalArgumentException e) { LOG.error("Invalid message format for message " + message, e); } } return message; }
[ "public", "static", "String", "format", "(", "final", "Locale", "locale", ",", "final", "String", "text", ",", "final", "Object", "...", "args", ")", "{", "if", "(", "text", "==", "null", ")", "{", "return", "null", ";", "}", "String", "localisedText", "=", "getLocalisedText", "(", "locale", ",", "text", ")", ";", "String", "message", "=", "localisedText", "==", "null", "?", "text", ":", "localisedText", ";", "if", "(", "args", "!=", "null", ")", "{", "try", "{", "return", "MessageFormat", ".", "format", "(", "message", ",", "args", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "LOG", ".", "error", "(", "\"Invalid message format for message \"", "+", "message", ",", "e", ")", ";", "}", "}", "return", "message", ";", "}" ]
Formats the given text, optionally using locale-specific text. @param locale The locale to use to look up a message, may be null. @param text the text / resource bundle key to use. @param args the message arguments, may be null. @return the formatted text.
[ "Formats", "the", "given", "text", "optionally", "using", "locale", "-", "specific", "text", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java#L104-L121
139,303
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java
I18nUtilities.getEffectiveLocale
public static Locale getEffectiveLocale() { Locale effectiveLocale = null; UIContext uic = UIContextHolder.getCurrent(); if (uic != null) { effectiveLocale = uic.getLocale(); } if (effectiveLocale == null) { String defaultLocale = ConfigurationProperties.getDefaultLocale(); effectiveLocale = new Locale(defaultLocale); } // Don't use Locale.getDefault() because it is too nebulous (depends on host environment) return effectiveLocale; }
java
public static Locale getEffectiveLocale() { Locale effectiveLocale = null; UIContext uic = UIContextHolder.getCurrent(); if (uic != null) { effectiveLocale = uic.getLocale(); } if (effectiveLocale == null) { String defaultLocale = ConfigurationProperties.getDefaultLocale(); effectiveLocale = new Locale(defaultLocale); } // Don't use Locale.getDefault() because it is too nebulous (depends on host environment) return effectiveLocale; }
[ "public", "static", "Locale", "getEffectiveLocale", "(", ")", "{", "Locale", "effectiveLocale", "=", "null", ";", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "if", "(", "uic", "!=", "null", ")", "{", "effectiveLocale", "=", "uic", ".", "getLocale", "(", ")", ";", "}", "if", "(", "effectiveLocale", "==", "null", ")", "{", "String", "defaultLocale", "=", "ConfigurationProperties", ".", "getDefaultLocale", "(", ")", ";", "effectiveLocale", "=", "new", "Locale", "(", "defaultLocale", ")", ";", "}", "// Don't use Locale.getDefault() because it is too nebulous (depends on host environment)", "return", "effectiveLocale", ";", "}" ]
Get the locale currently in use. @return The currently active locale.
[ "Get", "the", "locale", "currently", "in", "use", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java#L127-L143
139,304
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java
I18nUtilities.getLocalisedText
public static String getLocalisedText(final Locale locale, final String text) { String message = null; String resourceBundleBaseName = getResourceBundleBaseName(); if (!Util.empty(resourceBundleBaseName)) { Locale effectiveLocale = locale; if (effectiveLocale == null) { effectiveLocale = getEffectiveLocale(); } try { // TODO: This is slow ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleBaseName, effectiveLocale); message = bundle.getString(text); } catch (MissingResourceException e) { // Fall back to the Configuration mechanism for the default internal messages if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) { message = ConfigurationProperties.getInternalMessage(text); } if (message == null && !MISSING_RESOURCES.contains(locale)) { LOG.error("Missing resource mapping for locale: " + locale + ", text: " + text); MISSING_RESOURCES.add(locale); } } } else if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) { // Fall back to the Configuration mechanism for the default internal messages message = ConfigurationProperties.getInternalMessage(text); } return message; }
java
public static String getLocalisedText(final Locale locale, final String text) { String message = null; String resourceBundleBaseName = getResourceBundleBaseName(); if (!Util.empty(resourceBundleBaseName)) { Locale effectiveLocale = locale; if (effectiveLocale == null) { effectiveLocale = getEffectiveLocale(); } try { // TODO: This is slow ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleBaseName, effectiveLocale); message = bundle.getString(text); } catch (MissingResourceException e) { // Fall back to the Configuration mechanism for the default internal messages if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) { message = ConfigurationProperties.getInternalMessage(text); } if (message == null && !MISSING_RESOURCES.contains(locale)) { LOG.error("Missing resource mapping for locale: " + locale + ", text: " + text); MISSING_RESOURCES.add(locale); } } } else if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) { // Fall back to the Configuration mechanism for the default internal messages message = ConfigurationProperties.getInternalMessage(text); } return message; }
[ "public", "static", "String", "getLocalisedText", "(", "final", "Locale", "locale", ",", "final", "String", "text", ")", "{", "String", "message", "=", "null", ";", "String", "resourceBundleBaseName", "=", "getResourceBundleBaseName", "(", ")", ";", "if", "(", "!", "Util", ".", "empty", "(", "resourceBundleBaseName", ")", ")", "{", "Locale", "effectiveLocale", "=", "locale", ";", "if", "(", "effectiveLocale", "==", "null", ")", "{", "effectiveLocale", "=", "getEffectiveLocale", "(", ")", ";", "}", "try", "{", "// TODO: This is slow", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "resourceBundleBaseName", ",", "effectiveLocale", ")", ";", "message", "=", "bundle", ".", "getString", "(", "text", ")", ";", "}", "catch", "(", "MissingResourceException", "e", ")", "{", "// Fall back to the Configuration mechanism for the default internal messages", "if", "(", "text", "!=", "null", "&&", "text", ".", "startsWith", "(", "ConfigurationProperties", ".", "INTERNAL_MESSAGE_PREFIX", ")", ")", "{", "message", "=", "ConfigurationProperties", ".", "getInternalMessage", "(", "text", ")", ";", "}", "if", "(", "message", "==", "null", "&&", "!", "MISSING_RESOURCES", ".", "contains", "(", "locale", ")", ")", "{", "LOG", ".", "error", "(", "\"Missing resource mapping for locale: \"", "+", "locale", "+", "\", text: \"", "+", "text", ")", ";", "MISSING_RESOURCES", ".", "add", "(", "locale", ")", ";", "}", "}", "}", "else", "if", "(", "text", "!=", "null", "&&", "text", ".", "startsWith", "(", "ConfigurationProperties", ".", "INTERNAL_MESSAGE_PREFIX", ")", ")", "{", "// Fall back to the Configuration mechanism for the default internal messages", "message", "=", "ConfigurationProperties", ".", "getInternalMessage", "(", "text", ")", ";", "}", "return", "message", ";", "}" ]
Attempts to retrieve the localized message for the given text. @param locale the locale to retrieve the message for, or null for the default locale. @param text the text message or id to look up. @return the localised text if found, otherwise null.
[ "Attempts", "to", "retrieve", "the", "localized", "message", "for", "the", "given", "text", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/I18nUtilities.java#L152-L184
139,305
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java
FileUtil.validateFileType
public static boolean validateFileType(final FileItemWrap newFile, final List<String> fileTypes) { // The newFile is null, then return false if (newFile == null) { return false; } // If fileTypes to validate is null or empty, then assume newFile is valid if (fileTypes == null || fileTypes.isEmpty()) { return true; } final List<String> fileExts = fileTypes.stream() .filter(fileType -> fileType.startsWith(".")) .collect(Collectors.toList()); // filter mime types from fileTypes. final List<String> fileMimes = fileTypes.stream() .filter(fileType -> !fileExts.contains(fileType)) .collect(Collectors.toList()); // First validate newFile against fileExts list // If extensions are supplied, then check if newFile has a name if (fileExts.size() > 0 && newFile.getName() != null) { // Then see if newFile has an extension String[] split = newFile.getName().split(("\\.(?=[^\\.]+$)")); // If it exists, then check if it matches supplied extension(s) if (split.length == 2 && fileExts.stream().anyMatch(fileExt -> fileExt.equals("." + split[1]))) { return true; } } // If extension match is unsucessful, then move to fileMimes list if (fileMimes.size() > 0) { final String mimeType = getFileMimeType(newFile); LOG.debug("File mime-type is: " + mimeType); for (String fileMime : fileMimes) { if (StringUtils.equals(mimeType, fileMime)) { return true; } if (fileMime.indexOf("*") == fileMime.length() - 1) { fileMime = fileMime.substring(0, fileMime.length() - 1); if (mimeType.indexOf(fileMime) == 0) { return true; } } } } return false; }
java
public static boolean validateFileType(final FileItemWrap newFile, final List<String> fileTypes) { // The newFile is null, then return false if (newFile == null) { return false; } // If fileTypes to validate is null or empty, then assume newFile is valid if (fileTypes == null || fileTypes.isEmpty()) { return true; } final List<String> fileExts = fileTypes.stream() .filter(fileType -> fileType.startsWith(".")) .collect(Collectors.toList()); // filter mime types from fileTypes. final List<String> fileMimes = fileTypes.stream() .filter(fileType -> !fileExts.contains(fileType)) .collect(Collectors.toList()); // First validate newFile against fileExts list // If extensions are supplied, then check if newFile has a name if (fileExts.size() > 0 && newFile.getName() != null) { // Then see if newFile has an extension String[] split = newFile.getName().split(("\\.(?=[^\\.]+$)")); // If it exists, then check if it matches supplied extension(s) if (split.length == 2 && fileExts.stream().anyMatch(fileExt -> fileExt.equals("." + split[1]))) { return true; } } // If extension match is unsucessful, then move to fileMimes list if (fileMimes.size() > 0) { final String mimeType = getFileMimeType(newFile); LOG.debug("File mime-type is: " + mimeType); for (String fileMime : fileMimes) { if (StringUtils.equals(mimeType, fileMime)) { return true; } if (fileMime.indexOf("*") == fileMime.length() - 1) { fileMime = fileMime.substring(0, fileMime.length() - 1); if (mimeType.indexOf(fileMime) == 0) { return true; } } } } return false; }
[ "public", "static", "boolean", "validateFileType", "(", "final", "FileItemWrap", "newFile", ",", "final", "List", "<", "String", ">", "fileTypes", ")", "{", "// The newFile is null, then return false", "if", "(", "newFile", "==", "null", ")", "{", "return", "false", ";", "}", "// If fileTypes to validate is null or empty, then assume newFile is valid", "if", "(", "fileTypes", "==", "null", "||", "fileTypes", ".", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "final", "List", "<", "String", ">", "fileExts", "=", "fileTypes", ".", "stream", "(", ")", ".", "filter", "(", "fileType", "->", "fileType", ".", "startsWith", "(", "\".\"", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "// filter mime types from fileTypes.", "final", "List", "<", "String", ">", "fileMimes", "=", "fileTypes", ".", "stream", "(", ")", ".", "filter", "(", "fileType", "->", "!", "fileExts", ".", "contains", "(", "fileType", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "// First validate newFile against fileExts list", "// If extensions are supplied, then check if newFile has a name", "if", "(", "fileExts", ".", "size", "(", ")", ">", "0", "&&", "newFile", ".", "getName", "(", ")", "!=", "null", ")", "{", "// Then see if newFile has an extension", "String", "[", "]", "split", "=", "newFile", ".", "getName", "(", ")", ".", "split", "(", "(", "\"\\\\.(?=[^\\\\.]+$)\"", ")", ")", ";", "// If it exists, then check if it matches supplied extension(s)", "if", "(", "split", ".", "length", "==", "2", "&&", "fileExts", ".", "stream", "(", ")", ".", "anyMatch", "(", "fileExt", "->", "fileExt", ".", "equals", "(", "\".\"", "+", "split", "[", "1", "]", ")", ")", ")", "{", "return", "true", ";", "}", "}", "// If extension match is unsucessful, then move to fileMimes list", "if", "(", "fileMimes", ".", "size", "(", ")", ">", "0", ")", "{", "final", "String", "mimeType", "=", "getFileMimeType", "(", "newFile", ")", ";", "LOG", ".", "debug", "(", "\"File mime-type is: \"", "+", "mimeType", ")", ";", "for", "(", "String", "fileMime", ":", "fileMimes", ")", "{", "if", "(", "StringUtils", ".", "equals", "(", "mimeType", ",", "fileMime", ")", ")", "{", "return", "true", ";", "}", "if", "(", "fileMime", ".", "indexOf", "(", "\"*\"", ")", "==", "fileMime", ".", "length", "(", ")", "-", "1", ")", "{", "fileMime", "=", "fileMime", ".", "substring", "(", "0", ",", "fileMime", ".", "length", "(", ")", "-", "1", ")", ";", "if", "(", "mimeType", ".", "indexOf", "(", "fileMime", ")", "==", "0", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Checks if the file item is one among the supplied file types. This first checks against file extensions, then against file mime types @param newFile the file to be checked, if null then return false otherwise validate @param fileTypes allowed file types, if null or empty return true, otherwise validate @return {@code true} if either extension or mime-type match is successful
[ "Checks", "if", "the", "file", "item", "is", "one", "among", "the", "supplied", "file", "types", ".", "This", "first", "checks", "against", "file", "extensions", "then", "against", "file", "mime", "types" ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java#L43-L89
139,306
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java
FileUtil.getFileMimeType
public static String getFileMimeType(final File file) { if (file != null) { try { final Tika tika = new Tika(); return tika.detect(file.getInputStream()); } catch (IOException ex) { LOG.error("Invalid file, name " + file.getName(), ex); } } return null; }
java
public static String getFileMimeType(final File file) { if (file != null) { try { final Tika tika = new Tika(); return tika.detect(file.getInputStream()); } catch (IOException ex) { LOG.error("Invalid file, name " + file.getName(), ex); } } return null; }
[ "public", "static", "String", "getFileMimeType", "(", "final", "File", "file", ")", "{", "if", "(", "file", "!=", "null", ")", "{", "try", "{", "final", "Tika", "tika", "=", "new", "Tika", "(", ")", ";", "return", "tika", ".", "detect", "(", "file", ".", "getInputStream", "(", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "LOG", ".", "error", "(", "\"Invalid file, name \"", "+", "file", ".", "getName", "(", ")", ",", "ex", ")", ";", "}", "}", "return", "null", ";", "}" ]
Identify the mime type of a file. @param file the File to detect. @return mime type as detected by Apache tika, otherwise null.
[ "Identify", "the", "mime", "type", "of", "a", "file", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java#L97-L107
139,307
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java
FileUtil.validateFileSize
public static boolean validateFileSize(final FileItemWrap newFile, final long maxFileSize) { // If newFile to validate is null, then return false if (newFile == null) { return false; } // If maxFileSize to validate is zero or negative, then assume newFile is valid if (maxFileSize < 1) { return true; } return (newFile.getSize() <= maxFileSize); }
java
public static boolean validateFileSize(final FileItemWrap newFile, final long maxFileSize) { // If newFile to validate is null, then return false if (newFile == null) { return false; } // If maxFileSize to validate is zero or negative, then assume newFile is valid if (maxFileSize < 1) { return true; } return (newFile.getSize() <= maxFileSize); }
[ "public", "static", "boolean", "validateFileSize", "(", "final", "FileItemWrap", "newFile", ",", "final", "long", "maxFileSize", ")", "{", "// If newFile to validate is null, then return false", "if", "(", "newFile", "==", "null", ")", "{", "return", "false", ";", "}", "// If maxFileSize to validate is zero or negative, then assume newFile is valid", "if", "(", "maxFileSize", "<", "1", ")", "{", "return", "true", ";", "}", "return", "(", "newFile", ".", "getSize", "(", ")", "<=", "maxFileSize", ")", ";", "}" ]
Checks if the file item size is within the supplied max file size. @param newFile the file to be checked, if null then return false otherwise validate @param maxFileSize max file size in bytes, if zero or negative return true, otherwise validate @return {@code true} if file size is valid.
[ "Checks", "if", "the", "file", "item", "size", "is", "within", "the", "supplied", "max", "file", "size", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java#L118-L129
139,308
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java
FileUtil.getInvalidFileTypeMessage
public static String getInvalidFileTypeMessage(final List<String> fileTypes) { if (fileTypes == null) { return null; } return String.format(I18nUtilities.format(null, InternalMessages.DEFAULT_VALIDATION_ERROR_FILE_WRONG_TYPE), StringUtils.join(fileTypes.toArray(new Object[fileTypes.size()]), ",")); }
java
public static String getInvalidFileTypeMessage(final List<String> fileTypes) { if (fileTypes == null) { return null; } return String.format(I18nUtilities.format(null, InternalMessages.DEFAULT_VALIDATION_ERROR_FILE_WRONG_TYPE), StringUtils.join(fileTypes.toArray(new Object[fileTypes.size()]), ",")); }
[ "public", "static", "String", "getInvalidFileTypeMessage", "(", "final", "List", "<", "String", ">", "fileTypes", ")", "{", "if", "(", "fileTypes", "==", "null", ")", "{", "return", "null", ";", "}", "return", "String", ".", "format", "(", "I18nUtilities", ".", "format", "(", "null", ",", "InternalMessages", ".", "DEFAULT_VALIDATION_ERROR_FILE_WRONG_TYPE", ")", ",", "StringUtils", ".", "join", "(", "fileTypes", ".", "toArray", "(", "new", "Object", "[", "fileTypes", ".", "size", "(", ")", "]", ")", ",", "\",\"", ")", ")", ";", "}" ]
Returns invalid fileTypes error message. @param fileTypes allowed fileTypes @return human readable message
[ "Returns", "invalid", "fileTypes", "error", "message", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java#L152-L159
139,309
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java
FileUtil.getInvalidFileSizeMessage
public static String getInvalidFileSizeMessage(final long maxFileSize) { return String.format(I18nUtilities.format(null, InternalMessages.DEFAULT_VALIDATION_ERROR_FILE_WRONG_SIZE), FileUtil.readableFileSize(maxFileSize)); }
java
public static String getInvalidFileSizeMessage(final long maxFileSize) { return String.format(I18nUtilities.format(null, InternalMessages.DEFAULT_VALIDATION_ERROR_FILE_WRONG_SIZE), FileUtil.readableFileSize(maxFileSize)); }
[ "public", "static", "String", "getInvalidFileSizeMessage", "(", "final", "long", "maxFileSize", ")", "{", "return", "String", ".", "format", "(", "I18nUtilities", ".", "format", "(", "null", ",", "InternalMessages", ".", "DEFAULT_VALIDATION_ERROR_FILE_WRONG_SIZE", ")", ",", "FileUtil", ".", "readableFileSize", "(", "maxFileSize", ")", ")", ";", "}" ]
Returns invalid fileSize error message. @param maxFileSize allowed fileSize @return human readable message
[ "Returns", "invalid", "fileSize", "error", "message", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java#L167-L170
139,310
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/validation/AbstractWFieldIndicator.java
AbstractWFieldIndicator.getDiagnostics
public List<Diagnostic> getDiagnostics() { FieldIndicatorModel model = getComponentModel(); return Collections.unmodifiableList(model.diagnostics); }
java
public List<Diagnostic> getDiagnostics() { FieldIndicatorModel model = getComponentModel(); return Collections.unmodifiableList(model.diagnostics); }
[ "public", "List", "<", "Diagnostic", ">", "getDiagnostics", "(", ")", "{", "FieldIndicatorModel", "model", "=", "getComponentModel", "(", ")", ";", "return", "Collections", ".", "unmodifiableList", "(", "model", ".", "diagnostics", ")", ";", "}" ]
Return the diagnostics for this indicator. @return A list of diagnostics (may be empty) for this indicator.
[ "Return", "the", "diagnostics", "for", "this", "indicator", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/validation/AbstractWFieldIndicator.java#L110-L113
139,311
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTableColumn.java
WTableColumn.setWidth
public void setWidth(final int width) { if (width > 100) { throw new IllegalArgumentException( "Width (" + width + ") cannot be greater than 100 percent"); } getOrCreateComponentModel().width = Math.max(0, width); }
java
public void setWidth(final int width) { if (width > 100) { throw new IllegalArgumentException( "Width (" + width + ") cannot be greater than 100 percent"); } getOrCreateComponentModel().width = Math.max(0, width); }
[ "public", "void", "setWidth", "(", "final", "int", "width", ")", "{", "if", "(", "width", ">", "100", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Width (\"", "+", "width", "+", "\") cannot be greater than 100 percent\"", ")", ";", "}", "getOrCreateComponentModel", "(", ")", ".", "width", "=", "Math", ".", "max", "(", "0", ",", "width", ")", ";", "}" ]
Sets the column width. @param width the column width as a percentage, or &lt;= 0 for default width.
[ "Sets", "the", "column", "width", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTableColumn.java#L131-L137
139,312
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/ResponseCacheInterceptor.java
ResponseCacheInterceptor.paint
@Override public void paint(final RenderContext renderContext) { // Set headers getResponse().setHeader("Cache-Control", type.getSettings()); // Add extra no cache headers if (!type.isCache()) { getResponse().setHeader("Pragma", "no-cache"); getResponse().setHeader("Expires", "-1"); } super.paint(renderContext); }
java
@Override public void paint(final RenderContext renderContext) { // Set headers getResponse().setHeader("Cache-Control", type.getSettings()); // Add extra no cache headers if (!type.isCache()) { getResponse().setHeader("Pragma", "no-cache"); getResponse().setHeader("Expires", "-1"); } super.paint(renderContext); }
[ "@", "Override", "public", "void", "paint", "(", "final", "RenderContext", "renderContext", ")", "{", "// Set headers", "getResponse", "(", ")", ".", "setHeader", "(", "\"Cache-Control\"", ",", "type", ".", "getSettings", "(", ")", ")", ";", "// Add extra no cache headers", "if", "(", "!", "type", ".", "isCache", "(", ")", ")", "{", "getResponse", "(", ")", ".", "setHeader", "(", "\"Pragma\"", ",", "\"no-cache\"", ")", ";", "getResponse", "(", ")", ".", "setHeader", "(", "\"Expires\"", ",", "\"-1\"", ")", ";", "}", "super", ".", "paint", "(", "renderContext", ")", ";", "}" ]
Set the appropriate response headers for caching or not caching the response. @param renderContext the rendering context
[ "Set", "the", "appropriate", "response", "headers", "for", "caching", "or", "not", "caching", "the", "response", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/ResponseCacheInterceptor.java#L108-L120
139,313
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java
WMessageBox.addMessage
public void addMessage(final boolean encode, final String msg, final Serializable... args) { MessageModel model = getOrCreateComponentModel(); model.messages.add(new Duplet<>(I18nUtilities.asMessage(msg, args), encode)); // Potential for leaking memory here MemoryUtil.checkSize(model.messages.size(), this.getClass().getSimpleName()); }
java
public void addMessage(final boolean encode, final String msg, final Serializable... args) { MessageModel model = getOrCreateComponentModel(); model.messages.add(new Duplet<>(I18nUtilities.asMessage(msg, args), encode)); // Potential for leaking memory here MemoryUtil.checkSize(model.messages.size(), this.getClass().getSimpleName()); }
[ "public", "void", "addMessage", "(", "final", "boolean", "encode", ",", "final", "String", "msg", ",", "final", "Serializable", "...", "args", ")", "{", "MessageModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "messages", ".", "add", "(", "new", "Duplet", "<>", "(", "I18nUtilities", ".", "asMessage", "(", "msg", ",", "args", ")", ",", "encode", ")", ")", ";", "// Potential for leaking memory here", "MemoryUtil", ".", "checkSize", "(", "model", ".", "messages", ".", "size", "(", ")", ",", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}" ]
Adds a message to the message box. @param encode true to encode the message text, false to leave it unencoded. @param msg the text of the message to add, using {@link MessageFormat} syntax. @param args optional arguments for the message format string.
[ "Adds", "a", "message", "to", "the", "message", "box", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java#L203-L208
139,314
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java
WMessageBox.removeMessages
public void removeMessages(final int index) { MessageModel model = getOrCreateComponentModel(); if (model.messages != null) { model.messages.remove(index); } }
java
public void removeMessages(final int index) { MessageModel model = getOrCreateComponentModel(); if (model.messages != null) { model.messages.remove(index); } }
[ "public", "void", "removeMessages", "(", "final", "int", "index", ")", "{", "MessageModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "messages", "!=", "null", ")", "{", "model", ".", "messages", ".", "remove", "(", "index", ")", ";", "}", "}" ]
Removes a message from the message box. @param index the index of the mssage to remove.
[ "Removes", "a", "message", "from", "the", "message", "box", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java#L224-L230
139,315
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java
WMessageBox.clearMessages
public void clearMessages() { MessageModel model = getOrCreateComponentModel(); if (model.messages != null) { model.messages.clear(); } }
java
public void clearMessages() { MessageModel model = getOrCreateComponentModel(); if (model.messages != null) { model.messages.clear(); } }
[ "public", "void", "clearMessages", "(", ")", "{", "MessageModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "messages", "!=", "null", ")", "{", "model", ".", "messages", ".", "clear", "(", ")", ";", "}", "}" ]
Removes all messages from the message box.
[ "Removes", "all", "messages", "from", "the", "message", "box", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java#L235-L241
139,316
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java
WMessageBox.getMessages
public List<String> getMessages() { MessageModel model = getComponentModel(); List<String> messages = new ArrayList<>(model.messages.size()); for (Duplet<Serializable, Boolean> message : model.messages) { String text = I18nUtilities.format(null, message.getFirst()); // If we are outputting unencoded content it must be XML valid. boolean encode = message.getSecond(); messages.add(encode ? WebUtilities.encode(text) : HtmlToXMLUtil.unescapeToXML(text)); } return Collections.unmodifiableList(messages); }
java
public List<String> getMessages() { MessageModel model = getComponentModel(); List<String> messages = new ArrayList<>(model.messages.size()); for (Duplet<Serializable, Boolean> message : model.messages) { String text = I18nUtilities.format(null, message.getFirst()); // If we are outputting unencoded content it must be XML valid. boolean encode = message.getSecond(); messages.add(encode ? WebUtilities.encode(text) : HtmlToXMLUtil.unescapeToXML(text)); } return Collections.unmodifiableList(messages); }
[ "public", "List", "<", "String", ">", "getMessages", "(", ")", "{", "MessageModel", "model", "=", "getComponentModel", "(", ")", ";", "List", "<", "String", ">", "messages", "=", "new", "ArrayList", "<>", "(", "model", ".", "messages", ".", "size", "(", ")", ")", ";", "for", "(", "Duplet", "<", "Serializable", ",", "Boolean", ">", "message", ":", "model", ".", "messages", ")", "{", "String", "text", "=", "I18nUtilities", ".", "format", "(", "null", ",", "message", ".", "getFirst", "(", ")", ")", ";", "// If we are outputting unencoded content it must be XML valid.", "boolean", "encode", "=", "message", ".", "getSecond", "(", ")", ";", "messages", ".", "add", "(", "encode", "?", "WebUtilities", ".", "encode", "(", "text", ")", ":", "HtmlToXMLUtil", ".", "unescapeToXML", "(", "text", ")", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "messages", ")", ";", "}" ]
Retrieves the list of messages. @return the messages for the current context.
[ "Retrieves", "the", "list", "of", "messages", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessageBox.java#L248-L261
139,317
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.setVideo
public void setVideo(final Video[] video) { List<Video> list = video == null ? null : Arrays.asList(video); getOrCreateComponentModel().video = list; }
java
public void setVideo(final Video[] video) { List<Video> list = video == null ? null : Arrays.asList(video); getOrCreateComponentModel().video = list; }
[ "public", "void", "setVideo", "(", "final", "Video", "[", "]", "video", ")", "{", "List", "<", "Video", ">", "list", "=", "video", "==", "null", "?", "null", ":", "Arrays", ".", "asList", "(", "video", ")", ";", "getOrCreateComponentModel", "(", ")", ".", "video", "=", "list", ";", "}" ]
Sets the video clip in multiple formats. The client will try to load the first video clip, and if it fails or isn't supported, it will move on to the next video clip. Only the first clip which can be played on the client will be used. @param video multiple formats for the same the video clip.
[ "Sets", "the", "video", "clip", "in", "multiple", "formats", ".", "The", "client", "will", "try", "to", "load", "the", "first", "video", "clip", "and", "if", "it", "fails", "or", "isn", "t", "supported", "it", "will", "move", "on", "to", "the", "next", "video", "clip", ".", "Only", "the", "first", "clip", "which", "can", "be", "played", "on", "the", "client", "will", "be", "used", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L159-L162
139,318
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.getVideo
public Video[] getVideo() { List<Video> list = getComponentModel().video; return list == null ? null : list.toArray(new Video[]{}); }
java
public Video[] getVideo() { List<Video> list = getComponentModel().video; return list == null ? null : list.toArray(new Video[]{}); }
[ "public", "Video", "[", "]", "getVideo", "(", ")", "{", "List", "<", "Video", ">", "list", "=", "getComponentModel", "(", ")", ".", "video", ";", "return", "list", "==", "null", "?", "null", ":", "list", ".", "toArray", "(", "new", "Video", "[", "]", "{", "}", ")", ";", "}" ]
Retrieves the video clips associated with this WVideo. @return the video clips, may be null.
[ "Retrieves", "the", "video", "clips", "associated", "with", "this", "WVideo", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L169-L172
139,319
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.setMediaGroup
public void setMediaGroup(final String mediaGroup) { String currMediaGroup = getMediaGroup(); if (!Objects.equals(mediaGroup, currMediaGroup)) { getOrCreateComponentModel().mediaGroup = mediaGroup; } }
java
public void setMediaGroup(final String mediaGroup) { String currMediaGroup = getMediaGroup(); if (!Objects.equals(mediaGroup, currMediaGroup)) { getOrCreateComponentModel().mediaGroup = mediaGroup; } }
[ "public", "void", "setMediaGroup", "(", "final", "String", "mediaGroup", ")", "{", "String", "currMediaGroup", "=", "getMediaGroup", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "mediaGroup", ",", "currMediaGroup", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "mediaGroup", "=", "mediaGroup", ";", "}", "}" ]
Sets the media group. @param mediaGroup The media group name.
[ "Sets", "the", "media", "group", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L224-L230
139,320
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.setAltText
public void setAltText(final String altText) { String currAltText = getAltText(); if (!Objects.equals(altText, currAltText)) { getOrCreateComponentModel().altText = altText; } }
java
public void setAltText(final String altText) { String currAltText = getAltText(); if (!Objects.equals(altText, currAltText)) { getOrCreateComponentModel().altText = altText; } }
[ "public", "void", "setAltText", "(", "final", "String", "altText", ")", "{", "String", "currAltText", "=", "getAltText", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "altText", ",", "currAltText", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "altText", "=", "altText", ";", "}", "}" ]
Sets the alternative text to display when the video clip can not be played. @param altText the text to set.
[ "Sets", "the", "alternative", "text", "to", "display", "when", "the", "video", "clip", "can", "not", "be", "played", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L326-L332
139,321
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.setTracks
public void setTracks(final Track[] tracks) { List<Track> list = tracks == null ? null : Arrays.asList(tracks); getOrCreateComponentModel().tracks = list; }
java
public void setTracks(final Track[] tracks) { List<Track> list = tracks == null ? null : Arrays.asList(tracks); getOrCreateComponentModel().tracks = list; }
[ "public", "void", "setTracks", "(", "final", "Track", "[", "]", "tracks", ")", "{", "List", "<", "Track", ">", "list", "=", "tracks", "==", "null", "?", "null", ":", "Arrays", ".", "asList", "(", "tracks", ")", ";", "getOrCreateComponentModel", "(", ")", ".", "tracks", "=", "list", ";", "}" ]
Sets the tracks for the video. The tracks are used to provide additional information relating to the video, for example subtitles. @param tracks additional tracks relating to the video.
[ "Sets", "the", "tracks", "for", "the", "video", ".", "The", "tracks", "are", "used", "to", "provide", "additional", "information", "relating", "to", "the", "video", "for", "example", "subtitles", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L394-L397
139,322
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.getTracks
public Track[] getTracks() { List<Track> list = getComponentModel().tracks; return list == null ? null : list.toArray(new Track[]{}); }
java
public Track[] getTracks() { List<Track> list = getComponentModel().tracks; return list == null ? null : list.toArray(new Track[]{}); }
[ "public", "Track", "[", "]", "getTracks", "(", ")", "{", "List", "<", "Track", ">", "list", "=", "getComponentModel", "(", ")", ".", "tracks", ";", "return", "list", "==", "null", "?", "null", ":", "list", ".", "toArray", "(", "new", "Track", "[", "]", "{", "}", ")", ";", "}" ]
Retrieves additional tracks associated with the video. The tracks provide additional information relating to the video, for example subtitles. @return the video clips, may be null.
[ "Retrieves", "additional", "tracks", "associated", "with", "the", "video", ".", "The", "tracks", "provide", "additional", "information", "relating", "to", "the", "video", "for", "example", "subtitles", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L405-L408
139,323
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.isVisible
@Override public boolean isVisible() { if (!super.isVisible()) { return false; } Video[] video = getVideo(); return video != null && video.length > 0; }
java
@Override public boolean isVisible() { if (!super.isVisible()) { return false; } Video[] video = getVideo(); return video != null && video.length > 0; }
[ "@", "Override", "public", "boolean", "isVisible", "(", ")", "{", "if", "(", "!", "super", ".", "isVisible", "(", ")", ")", "{", "return", "false", ";", "}", "Video", "[", "]", "video", "=", "getVideo", "(", ")", ";", "return", "video", "!=", "null", "&&", "video", ".", "length", ">", "0", ";", "}" ]
Override isVisible to also return false if there are no video clips to play. @return true if this component is visible in the given context, otherwise false.
[ "Override", "isVisible", "to", "also", "return", "false", "if", "there", "are", "no", "video", "clips", "to", "play", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L517-L525
139,324
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.handleRequest
@Override public void handleRequest(final Request request) { super.handleRequest(request); String targ = request.getParameter(Environment.TARGET_ID); boolean contentReqested = (targ != null && targ.equals(getTargetId())); if (contentReqested && request.getParameter(POSTER_REQUEST_PARAM_KEY) != null) { handlePosterRequest(); } if (isDisabled()) { return; } if (contentReqested) { if (request.getParameter(VIDEO_INDEX_REQUEST_PARAM_KEY) != null) { handleVideoRequest(request); } else if (request.getParameter(TRACK_INDEX_REQUEST_PARAM_KEY) != null) { handleTrackRequest(request); } } }
java
@Override public void handleRequest(final Request request) { super.handleRequest(request); String targ = request.getParameter(Environment.TARGET_ID); boolean contentReqested = (targ != null && targ.equals(getTargetId())); if (contentReqested && request.getParameter(POSTER_REQUEST_PARAM_KEY) != null) { handlePosterRequest(); } if (isDisabled()) { return; } if (contentReqested) { if (request.getParameter(VIDEO_INDEX_REQUEST_PARAM_KEY) != null) { handleVideoRequest(request); } else if (request.getParameter(TRACK_INDEX_REQUEST_PARAM_KEY) != null) { handleTrackRequest(request); } } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "super", ".", "handleRequest", "(", "request", ")", ";", "String", "targ", "=", "request", ".", "getParameter", "(", "Environment", ".", "TARGET_ID", ")", ";", "boolean", "contentReqested", "=", "(", "targ", "!=", "null", "&&", "targ", ".", "equals", "(", "getTargetId", "(", ")", ")", ")", ";", "if", "(", "contentReqested", "&&", "request", ".", "getParameter", "(", "POSTER_REQUEST_PARAM_KEY", ")", "!=", "null", ")", "{", "handlePosterRequest", "(", ")", ";", "}", "if", "(", "isDisabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "contentReqested", ")", "{", "if", "(", "request", ".", "getParameter", "(", "VIDEO_INDEX_REQUEST_PARAM_KEY", ")", "!=", "null", ")", "{", "handleVideoRequest", "(", "request", ")", ";", "}", "else", "if", "(", "request", ".", "getParameter", "(", "TRACK_INDEX_REQUEST_PARAM_KEY", ")", "!=", "null", ")", "{", "handleTrackRequest", "(", "request", ")", ";", "}", "}", "}" ]
When an video element is rendered to the client, the browser will make a second request to get the video content. The handleRequest method has been overridden to detect whether the request is the "content fetch" request by looking for the parameter that we encode in the content url. @param request the request being responded to.
[ "When", "an", "video", "element", "is", "rendered", "to", "the", "client", "the", "browser", "will", "make", "a", "second", "request", "to", "get", "the", "video", "content", ".", "The", "handleRequest", "method", "has", "been", "overridden", "to", "detect", "whether", "the", "request", "is", "the", "content", "fetch", "request", "by", "looking", "for", "the", "parameter", "that", "we", "encode", "in", "the", "content", "url", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L534-L557
139,325
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.handlePosterRequest
private void handlePosterRequest() { Image poster = getComponentModel().poster; if (poster != null) { ContentEscape escape = new ContentEscape(poster); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.warn("Client requested non-existant poster"); } }
java
private void handlePosterRequest() { Image poster = getComponentModel().poster; if (poster != null) { ContentEscape escape = new ContentEscape(poster); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.warn("Client requested non-existant poster"); } }
[ "private", "void", "handlePosterRequest", "(", ")", "{", "Image", "poster", "=", "getComponentModel", "(", ")", ".", "poster", ";", "if", "(", "poster", "!=", "null", ")", "{", "ContentEscape", "escape", "=", "new", "ContentEscape", "(", "poster", ")", ";", "escape", ".", "setCacheable", "(", "!", "Util", ".", "empty", "(", "getCacheKey", "(", ")", ")", ")", ";", "throw", "escape", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"Client requested non-existant poster\"", ")", ";", "}", "}" ]
Handles a request for the poster.
[ "Handles", "a", "request", "for", "the", "poster", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L562-L572
139,326
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.handleVideoRequest
private void handleVideoRequest(final Request request) { String videoRequested = request.getParameter(VIDEO_INDEX_REQUEST_PARAM_KEY); int videoFileIndex = 0; try { videoFileIndex = Integer.parseInt(videoRequested); } catch (NumberFormatException e) { LOG.error("Failed to parse video index: " + videoFileIndex); } Video[] video = getVideo(); if (video != null && videoFileIndex >= 0 && videoFileIndex < video.length) { ContentEscape escape = new ContentEscape(video[videoFileIndex]); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.warn("Client requested invalid video clip: " + videoFileIndex); } }
java
private void handleVideoRequest(final Request request) { String videoRequested = request.getParameter(VIDEO_INDEX_REQUEST_PARAM_KEY); int videoFileIndex = 0; try { videoFileIndex = Integer.parseInt(videoRequested); } catch (NumberFormatException e) { LOG.error("Failed to parse video index: " + videoFileIndex); } Video[] video = getVideo(); if (video != null && videoFileIndex >= 0 && videoFileIndex < video.length) { ContentEscape escape = new ContentEscape(video[videoFileIndex]); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.warn("Client requested invalid video clip: " + videoFileIndex); } }
[ "private", "void", "handleVideoRequest", "(", "final", "Request", "request", ")", "{", "String", "videoRequested", "=", "request", ".", "getParameter", "(", "VIDEO_INDEX_REQUEST_PARAM_KEY", ")", ";", "int", "videoFileIndex", "=", "0", ";", "try", "{", "videoFileIndex", "=", "Integer", ".", "parseInt", "(", "videoRequested", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to parse video index: \"", "+", "videoFileIndex", ")", ";", "}", "Video", "[", "]", "video", "=", "getVideo", "(", ")", ";", "if", "(", "video", "!=", "null", "&&", "videoFileIndex", ">=", "0", "&&", "videoFileIndex", "<", "video", ".", "length", ")", "{", "ContentEscape", "escape", "=", "new", "ContentEscape", "(", "video", "[", "videoFileIndex", "]", ")", ";", "escape", ".", "setCacheable", "(", "!", "Util", ".", "empty", "(", "getCacheKey", "(", ")", ")", ")", ";", "throw", "escape", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"Client requested invalid video clip: \"", "+", "videoFileIndex", ")", ";", "}", "}" ]
Handles a request for a video. @param request the request being responded to.
[ "Handles", "a", "request", "for", "a", "video", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L579-L598
139,327
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java
WVideo.handleTrackRequest
private void handleTrackRequest(final Request request) { String trackRequested = request.getParameter(TRACK_INDEX_REQUEST_PARAM_KEY); int trackIndex = 0; try { trackIndex = Integer.parseInt(trackRequested); } catch (NumberFormatException e) { LOG.error("Failed to parse track index: " + trackIndex); } Track[] tracks = getTracks(); if (tracks != null && trackIndex >= 0 && trackIndex < tracks.length) { ContentEscape escape = new ContentEscape(tracks[trackIndex]); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.warn("Client requested invalid track: " + trackIndex); } }
java
private void handleTrackRequest(final Request request) { String trackRequested = request.getParameter(TRACK_INDEX_REQUEST_PARAM_KEY); int trackIndex = 0; try { trackIndex = Integer.parseInt(trackRequested); } catch (NumberFormatException e) { LOG.error("Failed to parse track index: " + trackIndex); } Track[] tracks = getTracks(); if (tracks != null && trackIndex >= 0 && trackIndex < tracks.length) { ContentEscape escape = new ContentEscape(tracks[trackIndex]); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.warn("Client requested invalid track: " + trackIndex); } }
[ "private", "void", "handleTrackRequest", "(", "final", "Request", "request", ")", "{", "String", "trackRequested", "=", "request", ".", "getParameter", "(", "TRACK_INDEX_REQUEST_PARAM_KEY", ")", ";", "int", "trackIndex", "=", "0", ";", "try", "{", "trackIndex", "=", "Integer", ".", "parseInt", "(", "trackRequested", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to parse track index: \"", "+", "trackIndex", ")", ";", "}", "Track", "[", "]", "tracks", "=", "getTracks", "(", ")", ";", "if", "(", "tracks", "!=", "null", "&&", "trackIndex", ">=", "0", "&&", "trackIndex", "<", "tracks", ".", "length", ")", "{", "ContentEscape", "escape", "=", "new", "ContentEscape", "(", "tracks", "[", "trackIndex", "]", ")", ";", "escape", ".", "setCacheable", "(", "!", "Util", ".", "empty", "(", "getCacheKey", "(", ")", ")", ")", ";", "throw", "escape", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"Client requested invalid track: \"", "+", "trackIndex", ")", ";", "}", "}" ]
Handles a request for an auxillary track. @param request the request being responded to.
[ "Handles", "a", "request", "for", "an", "auxillary", "track", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WVideo.java#L605-L624
139,328
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java
WAudio.setAudio
public void setAudio(final Audio[] audio) { List<Audio> list = audio == null ? null : Arrays.asList(audio); getOrCreateComponentModel().audio = list; }
java
public void setAudio(final Audio[] audio) { List<Audio> list = audio == null ? null : Arrays.asList(audio); getOrCreateComponentModel().audio = list; }
[ "public", "void", "setAudio", "(", "final", "Audio", "[", "]", "audio", ")", "{", "List", "<", "Audio", ">", "list", "=", "audio", "==", "null", "?", "null", ":", "Arrays", ".", "asList", "(", "audio", ")", ";", "getOrCreateComponentModel", "(", ")", ".", "audio", "=", "list", ";", "}" ]
Sets the audio clip in multiple formats for all users. The client will try to load the first audio clip, and if it fails or isn't supported, it will move on to the next audio clip. Only the first clip which can be played on the client will be used. @param audio multiple formats for the same the audio clip
[ "Sets", "the", "audio", "clip", "in", "multiple", "formats", "for", "all", "users", ".", "The", "client", "will", "try", "to", "load", "the", "first", "audio", "clip", "and", "if", "it", "fails", "or", "isn", "t", "supported", "it", "will", "move", "on", "to", "the", "next", "audio", "clip", ".", "Only", "the", "first", "clip", "which", "can", "be", "played", "on", "the", "client", "will", "be", "used", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java#L167-L170
139,329
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java
WAudio.getAudio
public Audio[] getAudio() { List<Audio> list = getComponentModel().audio; return list == null ? null : list.toArray(new Audio[]{}); }
java
public Audio[] getAudio() { List<Audio> list = getComponentModel().audio; return list == null ? null : list.toArray(new Audio[]{}); }
[ "public", "Audio", "[", "]", "getAudio", "(", ")", "{", "List", "<", "Audio", ">", "list", "=", "getComponentModel", "(", ")", ".", "audio", ";", "return", "list", "==", "null", "?", "null", ":", "list", ".", "toArray", "(", "new", "Audio", "[", "]", "{", "}", ")", ";", "}" ]
Retrieves the audio clips associated with this WAudio. @return the audio clips, may be null
[ "Retrieves", "the", "audio", "clips", "associated", "with", "this", "WAudio", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java#L177-L180
139,330
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java
WAudio.isVisible
@Override public boolean isVisible() { if (!super.isVisible()) { return false; } Audio[] audio = getAudio(); return audio != null && audio.length > 0; }
java
@Override public boolean isVisible() { if (!super.isVisible()) { return false; } Audio[] audio = getAudio(); return audio != null && audio.length > 0; }
[ "@", "Override", "public", "boolean", "isVisible", "(", ")", "{", "if", "(", "!", "super", ".", "isVisible", "(", ")", ")", "{", "return", "false", ";", "}", "Audio", "[", "]", "audio", "=", "getAudio", "(", ")", ";", "return", "audio", "!=", "null", "&&", "audio", ".", "length", ">", "0", ";", "}" ]
Override isVisible to also return false if there are no audio clips to play. @return true if this component is visible in the given context, otherwise false
[ "Override", "isVisible", "to", "also", "return", "false", "if", "there", "are", "no", "audio", "clips", "to", "play", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java#L343-L351
139,331
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java
WAudio.handleRequest
@Override public void handleRequest(final Request request) { super.handleRequest(request); if (isDisabled()) { return; } String targ = request.getParameter(Environment.TARGET_ID); String audioFileRequested = request.getParameter(AUDIO_INDEX_REQUEST_PARAM_KEY); boolean contentReqested = targ != null && targ.equals(getTargetId()); if (contentReqested) { int audioFileIndex = 0; try { audioFileIndex = Integer.parseInt(audioFileRequested); } catch (NumberFormatException e) { LOG.error("Failed to parse audio index: " + audioFileIndex); } Audio[] audio = getAudio(); if (audio != null && audioFileIndex >= 0 && audioFileIndex < audio.length) { ContentEscape escape = new ContentEscape(audio[audioFileIndex]); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.error("Requested invalid audio clip: " + audioFileIndex); } } }
java
@Override public void handleRequest(final Request request) { super.handleRequest(request); if (isDisabled()) { return; } String targ = request.getParameter(Environment.TARGET_ID); String audioFileRequested = request.getParameter(AUDIO_INDEX_REQUEST_PARAM_KEY); boolean contentReqested = targ != null && targ.equals(getTargetId()); if (contentReqested) { int audioFileIndex = 0; try { audioFileIndex = Integer.parseInt(audioFileRequested); } catch (NumberFormatException e) { LOG.error("Failed to parse audio index: " + audioFileIndex); } Audio[] audio = getAudio(); if (audio != null && audioFileIndex >= 0 && audioFileIndex < audio.length) { ContentEscape escape = new ContentEscape(audio[audioFileIndex]); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } else { LOG.error("Requested invalid audio clip: " + audioFileIndex); } } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "super", ".", "handleRequest", "(", "request", ")", ";", "if", "(", "isDisabled", "(", ")", ")", "{", "return", ";", "}", "String", "targ", "=", "request", ".", "getParameter", "(", "Environment", ".", "TARGET_ID", ")", ";", "String", "audioFileRequested", "=", "request", ".", "getParameter", "(", "AUDIO_INDEX_REQUEST_PARAM_KEY", ")", ";", "boolean", "contentReqested", "=", "targ", "!=", "null", "&&", "targ", ".", "equals", "(", "getTargetId", "(", ")", ")", ";", "if", "(", "contentReqested", ")", "{", "int", "audioFileIndex", "=", "0", ";", "try", "{", "audioFileIndex", "=", "Integer", ".", "parseInt", "(", "audioFileRequested", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to parse audio index: \"", "+", "audioFileIndex", ")", ";", "}", "Audio", "[", "]", "audio", "=", "getAudio", "(", ")", ";", "if", "(", "audio", "!=", "null", "&&", "audioFileIndex", ">=", "0", "&&", "audioFileIndex", "<", "audio", ".", "length", ")", "{", "ContentEscape", "escape", "=", "new", "ContentEscape", "(", "audio", "[", "audioFileIndex", "]", ")", ";", "escape", ".", "setCacheable", "(", "!", "Util", ".", "empty", "(", "getCacheKey", "(", ")", ")", ")", ";", "throw", "escape", ";", "}", "else", "{", "LOG", ".", "error", "(", "\"Requested invalid audio clip: \"", "+", "audioFileIndex", ")", ";", "}", "}", "}" ]
When an audio element is rendered to the client, the browser will make a second request to get the audio content. The handleRequest method has been overridden to detect whether the request is the "content fetch" request by looking for the parameter that we encode in the content url. @param request the request being responded to
[ "When", "an", "audio", "element", "is", "rendered", "to", "the", "client", "the", "browser", "will", "make", "a", "second", "request", "to", "get", "the", "audio", "content", ".", "The", "handleRequest", "method", "has", "been", "overridden", "to", "detect", "whether", "the", "request", "is", "the", "content", "fetch", "request", "by", "looking", "for", "the", "parameter", "that", "we", "encode", "in", "the", "content", "url", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WAudio.java#L360-L391
139,332
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WFieldLayoutExample.java
WFieldLayoutExample.recursiveFieldLayout
private WFieldLayout recursiveFieldLayout(final int curr, final int startAt) { WFieldLayout innerLayout = new WFieldLayout(); innerLayout.setLabelWidth(20); if (curr == 0 && startAt == 0) { innerLayout.setMargin(new Margin(Size.LARGE, null, null, null)); } innerLayout.setOrdered(true); if (startAt > 1) { innerLayout.setOrderedOffset(startAt); } innerLayout.addField("Test " + String.valueOf(startAt > 1 ? startAt : 1), new WTextField()); innerLayout.addField("Test " + String.valueOf(startAt > 1 ? startAt + 1 : 2), new WTextField()); innerLayout.addField("Test " + String.valueOf(startAt > 1 ? startAt + 2 : 2), new WTextField()); if (curr < 4) { int next = curr + 1; innerLayout.addField("indent level " + String.valueOf(next), recursiveFieldLayout(next, 0)); } innerLayout.addField("Test after nest", new WTextField()); return innerLayout; }
java
private WFieldLayout recursiveFieldLayout(final int curr, final int startAt) { WFieldLayout innerLayout = new WFieldLayout(); innerLayout.setLabelWidth(20); if (curr == 0 && startAt == 0) { innerLayout.setMargin(new Margin(Size.LARGE, null, null, null)); } innerLayout.setOrdered(true); if (startAt > 1) { innerLayout.setOrderedOffset(startAt); } innerLayout.addField("Test " + String.valueOf(startAt > 1 ? startAt : 1), new WTextField()); innerLayout.addField("Test " + String.valueOf(startAt > 1 ? startAt + 1 : 2), new WTextField()); innerLayout.addField("Test " + String.valueOf(startAt > 1 ? startAt + 2 : 2), new WTextField()); if (curr < 4) { int next = curr + 1; innerLayout.addField("indent level " + String.valueOf(next), recursiveFieldLayout(next, 0)); } innerLayout.addField("Test after nest", new WTextField()); return innerLayout; }
[ "private", "WFieldLayout", "recursiveFieldLayout", "(", "final", "int", "curr", ",", "final", "int", "startAt", ")", "{", "WFieldLayout", "innerLayout", "=", "new", "WFieldLayout", "(", ")", ";", "innerLayout", ".", "setLabelWidth", "(", "20", ")", ";", "if", "(", "curr", "==", "0", "&&", "startAt", "==", "0", ")", "{", "innerLayout", ".", "setMargin", "(", "new", "Margin", "(", "Size", ".", "LARGE", ",", "null", ",", "null", ",", "null", ")", ")", ";", "}", "innerLayout", ".", "setOrdered", "(", "true", ")", ";", "if", "(", "startAt", ">", "1", ")", "{", "innerLayout", ".", "setOrderedOffset", "(", "startAt", ")", ";", "}", "innerLayout", ".", "addField", "(", "\"Test \"", "+", "String", ".", "valueOf", "(", "startAt", ">", "1", "?", "startAt", ":", "1", ")", ",", "new", "WTextField", "(", ")", ")", ";", "innerLayout", ".", "addField", "(", "\"Test \"", "+", "String", ".", "valueOf", "(", "startAt", ">", "1", "?", "startAt", "+", "1", ":", "2", ")", ",", "new", "WTextField", "(", ")", ")", ";", "innerLayout", ".", "addField", "(", "\"Test \"", "+", "String", ".", "valueOf", "(", "startAt", ">", "1", "?", "startAt", "+", "2", ":", "2", ")", ",", "new", "WTextField", "(", ")", ")", ";", "if", "(", "curr", "<", "4", ")", "{", "int", "next", "=", "curr", "+", "1", ";", "innerLayout", ".", "addField", "(", "\"indent level \"", "+", "String", ".", "valueOf", "(", "next", ")", ",", "recursiveFieldLayout", "(", "next", ",", "0", ")", ")", ";", "}", "innerLayout", ".", "addField", "(", "\"Test after nest\"", ",", "new", "WTextField", "(", ")", ")", ";", "return", "innerLayout", ";", "}" ]
Create a recursive field layout. @param curr recursion index @param startAt the ordered offset @return the recursive field layout.
[ "Create", "a", "recursive", "field", "layout", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WFieldLayoutExample.java#L194-L217
139,333
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiFileWidgetRenderer.java
WMultiFileWidgetRenderer.handleFileUploadRequest
protected void handleFileUploadRequest(final WMultiFileWidget widget, final XmlStringBuilder xml, final String uploadId) { FileWidgetUpload file = widget.getFile(uploadId); if (file == null) { throw new SystemException("Invalid file id [" + uploadId + "] to render uploaded response."); } int idx = widget.getFiles().indexOf(file); FileWidgetRendererUtil.renderFileElement(widget, xml, file, idx); }
java
protected void handleFileUploadRequest(final WMultiFileWidget widget, final XmlStringBuilder xml, final String uploadId) { FileWidgetUpload file = widget.getFile(uploadId); if (file == null) { throw new SystemException("Invalid file id [" + uploadId + "] to render uploaded response."); } int idx = widget.getFiles().indexOf(file); FileWidgetRendererUtil.renderFileElement(widget, xml, file, idx); }
[ "protected", "void", "handleFileUploadRequest", "(", "final", "WMultiFileWidget", "widget", ",", "final", "XmlStringBuilder", "xml", ",", "final", "String", "uploadId", ")", "{", "FileWidgetUpload", "file", "=", "widget", ".", "getFile", "(", "uploadId", ")", ";", "if", "(", "file", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"Invalid file id [\"", "+", "uploadId", "+", "\"] to render uploaded response.\"", ")", ";", "}", "int", "idx", "=", "widget", ".", "getFiles", "(", ")", ".", "indexOf", "(", "file", ")", ";", "FileWidgetRendererUtil", ".", "renderFileElement", "(", "widget", ",", "xml", ",", "file", ",", "idx", ")", ";", "}" ]
Paint the response for the file uploaded in this request. @param widget the file widget to render @param xml the XML string builder @param uploadId the file id uploaded in this request
[ "Paint", "the", "response", "for", "the", "file", "uploaded", "in", "this", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiFileWidgetRenderer.java#L112-L120
139,334
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiFileWidgetRenderer.java
WMultiFileWidgetRenderer.typesToString
private String typesToString(final List<String> types) { if (types == null || types.isEmpty()) { return null; } StringBuffer typesString = new StringBuffer(); for (Iterator<String> iter = types.iterator(); iter.hasNext();) { typesString.append(iter.next()); if (iter.hasNext()) { typesString.append(','); } } return typesString.toString(); }
java
private String typesToString(final List<String> types) { if (types == null || types.isEmpty()) { return null; } StringBuffer typesString = new StringBuffer(); for (Iterator<String> iter = types.iterator(); iter.hasNext();) { typesString.append(iter.next()); if (iter.hasNext()) { typesString.append(','); } } return typesString.toString(); }
[ "private", "String", "typesToString", "(", "final", "List", "<", "String", ">", "types", ")", "{", "if", "(", "types", "==", "null", "||", "types", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "StringBuffer", "typesString", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "iter", "=", "types", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "typesString", ".", "append", "(", "iter", ".", "next", "(", ")", ")", ";", "if", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "typesString", ".", "append", "(", "'", "'", ")", ";", "}", "}", "return", "typesString", ".", "toString", "(", ")", ";", "}" ]
Flattens the list of accepted mime types into a format suitable for rendering. @param types the list of accepted mime types @return the list of accepted mime types in a format suitable for rendering
[ "Flattens", "the", "list", "of", "accepted", "mime", "types", "into", "a", "format", "suitable", "for", "rendering", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiFileWidgetRenderer.java#L128-L144
139,335
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UicProfileButton.java
UicProfileButton.afterPaint
@Override protected void afterPaint(final RenderContext renderContext) { super.afterPaint(renderContext); if (this.isPressed() && renderContext instanceof WebXmlRenderContext) { PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter(); StringBuffer temp = dumpAll(); writer.println("<br/><br/>"); writer.println(temp); } }
java
@Override protected void afterPaint(final RenderContext renderContext) { super.afterPaint(renderContext); if (this.isPressed() && renderContext instanceof WebXmlRenderContext) { PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter(); StringBuffer temp = dumpAll(); writer.println("<br/><br/>"); writer.println(temp); } }
[ "@", "Override", "protected", "void", "afterPaint", "(", "final", "RenderContext", "renderContext", ")", "{", "super", ".", "afterPaint", "(", "renderContext", ")", ";", "if", "(", "this", ".", "isPressed", "(", ")", "&&", "renderContext", "instanceof", "WebXmlRenderContext", ")", "{", "PrintWriter", "writer", "=", "(", "(", "WebXmlRenderContext", ")", "renderContext", ")", ".", "getWriter", "(", ")", ";", "StringBuffer", "temp", "=", "dumpAll", "(", ")", ";", "writer", ".", "println", "(", "\"<br/><br/>\"", ")", ";", "writer", ".", "println", "(", "temp", ")", ";", "}", "}" ]
Override afterPaint to paint the profile information if the button has been pressed. @param renderContext the renderContext to send output to.
[ "Override", "afterPaint", "to", "paint", "the", "profile", "information", "if", "the", "button", "has", "been", "pressed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UicProfileButton.java#L44-L55
139,336
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UicProfileButton.java
UicProfileButton.dumpAll
public StringBuffer dumpAll() { WComponent root = WebUtilities.getTop(this); Map<String, GroupData> compTallyByClass = new TreeMap<>(); GroupData compDataOverall = new GroupData(); StringBuffer out = new StringBuffer(); String className = root.getClass().getName(); out.append("<strong>The root of the WComponent tree is:</strong><br/>").append(className).append( "<br/>"); tally(root, compTallyByClass, compDataOverall, out); out.append("<strong>WComponent usage overall:</strong><br/> "); out.append(compDataOverall.total).append(" WComponent(s) in the WComponent tree.<br/>"); if (compDataOverall.total > 0) { out.append("<strong>WComponent usage by class:</strong><br/>"); for (Map.Entry<String, GroupData> entry : compTallyByClass.entrySet()) { className = entry.getKey(); GroupData dataForClass = entry.getValue(); out.append(' ').append(dataForClass.total).append(" ").append(className).append( "<br/>"); } out.append("<br/><hr/>"); } processUic(out); return out; }
java
public StringBuffer dumpAll() { WComponent root = WebUtilities.getTop(this); Map<String, GroupData> compTallyByClass = new TreeMap<>(); GroupData compDataOverall = new GroupData(); StringBuffer out = new StringBuffer(); String className = root.getClass().getName(); out.append("<strong>The root of the WComponent tree is:</strong><br/>").append(className).append( "<br/>"); tally(root, compTallyByClass, compDataOverall, out); out.append("<strong>WComponent usage overall:</strong><br/> "); out.append(compDataOverall.total).append(" WComponent(s) in the WComponent tree.<br/>"); if (compDataOverall.total > 0) { out.append("<strong>WComponent usage by class:</strong><br/>"); for (Map.Entry<String, GroupData> entry : compTallyByClass.entrySet()) { className = entry.getKey(); GroupData dataForClass = entry.getValue(); out.append(' ').append(dataForClass.total).append(" ").append(className).append( "<br/>"); } out.append("<br/><hr/>"); } processUic(out); return out; }
[ "public", "StringBuffer", "dumpAll", "(", ")", "{", "WComponent", "root", "=", "WebUtilities", ".", "getTop", "(", "this", ")", ";", "Map", "<", "String", ",", "GroupData", ">", "compTallyByClass", "=", "new", "TreeMap", "<>", "(", ")", ";", "GroupData", "compDataOverall", "=", "new", "GroupData", "(", ")", ";", "StringBuffer", "out", "=", "new", "StringBuffer", "(", ")", ";", "String", "className", "=", "root", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "out", ".", "append", "(", "\"<strong>The root of the WComponent tree is:</strong><br/>\"", ")", ".", "append", "(", "className", ")", ".", "append", "(", "\"<br/>\"", ")", ";", "tally", "(", "root", ",", "compTallyByClass", ",", "compDataOverall", ",", "out", ")", ";", "out", ".", "append", "(", "\"<strong>WComponent usage overall:</strong><br/> \"", ")", ";", "out", ".", "append", "(", "compDataOverall", ".", "total", ")", ".", "append", "(", "\" WComponent(s) in the WComponent tree.<br/>\"", ")", ";", "if", "(", "compDataOverall", ".", "total", ">", "0", ")", "{", "out", ".", "append", "(", "\"<strong>WComponent usage by class:</strong><br/>\"", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "GroupData", ">", "entry", ":", "compTallyByClass", ".", "entrySet", "(", ")", ")", "{", "className", "=", "entry", ".", "getKey", "(", ")", ";", "GroupData", "dataForClass", "=", "entry", ".", "getValue", "(", ")", ";", "out", ".", "append", "(", "'", "'", ")", ".", "append", "(", "dataForClass", ".", "total", ")", ".", "append", "(", "\" \"", ")", ".", "append", "(", "className", ")", ".", "append", "(", "\"<br/>\"", ")", ";", "}", "out", ".", "append", "(", "\"<br/><hr/>\"", ")", ";", "}", "processUic", "(", "out", ")", ";", "return", "out", ";", "}" ]
Dumps all the profiling information in textual format to a StringBuffer. @return the profiling information in textual format.
[ "Dumps", "all", "the", "profiling", "information", "in", "textual", "format", "to", "a", "StringBuffer", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UicProfileButton.java#L62-L97
139,337
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/PBaseCompareable.java
PBaseCompareable.inRangeWith
public final R inRangeWith(TQProperty<R> highProperty, T value) { expr().inRangeWith(_name, highProperty._name, value); return _root; }
java
public final R inRangeWith(TQProperty<R> highProperty, T value) { expr().inRangeWith(_name, highProperty._name, value); return _root; }
[ "public", "final", "R", "inRangeWith", "(", "TQProperty", "<", "R", ">", "highProperty", ",", "T", "value", ")", "{", "expr", "(", ")", ".", "inRangeWith", "(", "_name", ",", "highProperty", ".", "_name", ",", "value", ")", ";", "return", "_root", ";", "}" ]
Value in Range between 2 properties. <pre>{@code .startDate.inRangeWith(endDate, now) // which equates to startDate <= now and (endDate > now or endDate is null) }</pre> <p> This is a convenience expression combining a number of simple expressions. The most common use of this could be called "effective dating" where 2 date or timestamp columns represent the date range in which
[ "Value", "in", "Range", "between", "2", "properties", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/PBaseCompareable.java#L111-L114
139,338
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/ProfileContainer.java
ProfileContainer.afterPaint
@Override protected void afterPaint(final RenderContext renderContext) { super.afterPaint(renderContext); // UIC serialization stats UicStats stats = new UicStats(UIContextHolder.getCurrent()); stats.analyseWC(this); if (renderContext instanceof WebXmlRenderContext) { PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter(); writer.println("<h2>Serialization Profile of UIC</h2>"); UicStatsAsHtml.write(writer, stats); // ObjectProfiler writer.println("<h2>ObjectProfiler - " + getClass().getName() + "</h2>"); writer.println("<pre>"); try { writer.println(ObjectGraphDump.dump(this).toFlatSummary()); } catch (Exception e) { LOG.error("Failed to dump component", e); } writer.println("</pre>"); } }
java
@Override protected void afterPaint(final RenderContext renderContext) { super.afterPaint(renderContext); // UIC serialization stats UicStats stats = new UicStats(UIContextHolder.getCurrent()); stats.analyseWC(this); if (renderContext instanceof WebXmlRenderContext) { PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter(); writer.println("<h2>Serialization Profile of UIC</h2>"); UicStatsAsHtml.write(writer, stats); // ObjectProfiler writer.println("<h2>ObjectProfiler - " + getClass().getName() + "</h2>"); writer.println("<pre>"); try { writer.println(ObjectGraphDump.dump(this).toFlatSummary()); } catch (Exception e) { LOG.error("Failed to dump component", e); } writer.println("</pre>"); } }
[ "@", "Override", "protected", "void", "afterPaint", "(", "final", "RenderContext", "renderContext", ")", "{", "super", ".", "afterPaint", "(", "renderContext", ")", ";", "// UIC serialization stats", "UicStats", "stats", "=", "new", "UicStats", "(", "UIContextHolder", ".", "getCurrent", "(", ")", ")", ";", "stats", ".", "analyseWC", "(", "this", ")", ";", "if", "(", "renderContext", "instanceof", "WebXmlRenderContext", ")", "{", "PrintWriter", "writer", "=", "(", "(", "WebXmlRenderContext", ")", "renderContext", ")", ".", "getWriter", "(", ")", ";", "writer", ".", "println", "(", "\"<h2>Serialization Profile of UIC</h2>\"", ")", ";", "UicStatsAsHtml", ".", "write", "(", "writer", ",", "stats", ")", ";", "// ObjectProfiler", "writer", ".", "println", "(", "\"<h2>ObjectProfiler - \"", "+", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"</h2>\"", ")", ";", "writer", ".", "println", "(", "\"<pre>\"", ")", ";", "try", "{", "writer", ".", "println", "(", "ObjectGraphDump", ".", "dump", "(", "this", ")", ".", "toFlatSummary", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to dump component\"", ",", "e", ")", ";", "}", "writer", ".", "println", "(", "\"</pre>\"", ")", ";", "}", "}" ]
Override afterPaint to write the statistics after the component is painted. @param renderContext the renderContext to send output to.
[ "Override", "afterPaint", "to", "write", "the", "statistics", "after", "the", "component", "is", "painted", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/ProfileContainer.java#L32-L59
139,339
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.setTreeModel
public void setTreeModel(final TreeItemModel treeModel) { getOrCreateComponentModel().treeModel = treeModel; clearItemIdMaps(); setSelectedRows(null); setExpandedRows(null); setCustomTree((TreeItemIdNode) null); }
java
public void setTreeModel(final TreeItemModel treeModel) { getOrCreateComponentModel().treeModel = treeModel; clearItemIdMaps(); setSelectedRows(null); setExpandedRows(null); setCustomTree((TreeItemIdNode) null); }
[ "public", "void", "setTreeModel", "(", "final", "TreeItemModel", "treeModel", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "treeModel", "=", "treeModel", ";", "clearItemIdMaps", "(", ")", ";", "setSelectedRows", "(", "null", ")", ";", "setExpandedRows", "(", "null", ")", ";", "setCustomTree", "(", "(", "TreeItemIdNode", ")", "null", ")", ";", "}" ]
Sets the tree model which provides row data. @param treeModel the tree model.
[ "Sets", "the", "tree", "model", "which", "provides", "row", "data", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L226-L232
139,340
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.clearItemIdMaps
protected void clearItemIdMaps() { if (getScratchMap() != null) { getScratchMap().remove(CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY); getScratchMap().remove(ALL_IDS_TO_INDEX_SCRATCH_MAP_KEY); getScratchMap().remove(EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY); } }
java
protected void clearItemIdMaps() { if (getScratchMap() != null) { getScratchMap().remove(CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY); getScratchMap().remove(ALL_IDS_TO_INDEX_SCRATCH_MAP_KEY); getScratchMap().remove(EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY); } }
[ "protected", "void", "clearItemIdMaps", "(", ")", "{", "if", "(", "getScratchMap", "(", ")", "!=", "null", ")", "{", "getScratchMap", "(", ")", ".", "remove", "(", "CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY", ")", ";", "getScratchMap", "(", ")", ".", "remove", "(", "ALL_IDS_TO_INDEX_SCRATCH_MAP_KEY", ")", ";", "getScratchMap", "(", ")", ".", "remove", "(", "EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY", ")", ";", "}", "}" ]
Clear the item id maps from, the scratch map.
[ "Clear", "the", "item", "id", "maps", "from", "the", "scratch", "map", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L496-L502
139,341
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.getCustomIdNodeMap
public Map<String, TreeItemIdNode> getCustomIdNodeMap() { // No user context present if (getScratchMap() == null) { return createCustomIdNodeMapping(); } Map<String, TreeItemIdNode> map = (Map<String, TreeItemIdNode>) getScratchMap().get(CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY); if (map == null) { map = createCustomIdNodeMapping(); getScratchMap().put(CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY, map); } return map; }
java
public Map<String, TreeItemIdNode> getCustomIdNodeMap() { // No user context present if (getScratchMap() == null) { return createCustomIdNodeMapping(); } Map<String, TreeItemIdNode> map = (Map<String, TreeItemIdNode>) getScratchMap().get(CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY); if (map == null) { map = createCustomIdNodeMapping(); getScratchMap().put(CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY, map); } return map; }
[ "public", "Map", "<", "String", ",", "TreeItemIdNode", ">", "getCustomIdNodeMap", "(", ")", "{", "// No user context present", "if", "(", "getScratchMap", "(", ")", "==", "null", ")", "{", "return", "createCustomIdNodeMapping", "(", ")", ";", "}", "Map", "<", "String", ",", "TreeItemIdNode", ">", "map", "=", "(", "Map", "<", "String", ",", "TreeItemIdNode", ">", ")", "getScratchMap", "(", ")", ".", "get", "(", "CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY", ")", ";", "if", "(", "map", "==", "null", ")", "{", "map", "=", "createCustomIdNodeMapping", "(", ")", ";", "getScratchMap", "(", ")", ".", "put", "(", "CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY", ",", "map", ")", ";", "}", "return", "map", ";", "}" ]
Map an item id to its node in the custom tree. As this can be expensive save the map onto the scratch pad. @return the map between the custom item ids and their node item.
[ "Map", "an", "item", "id", "to", "its", "node", "in", "the", "custom", "tree", ".", "As", "this", "can", "be", "expensive", "save", "the", "map", "onto", "the", "scratch", "pad", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L509-L520
139,342
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.getExpandedItemIdIndexMap
public Map<String, List<Integer>> getExpandedItemIdIndexMap() { // CLIENT MODE is include ALL boolean expandedOnly = getExpandMode() != ExpandMode.CLIENT; if (getScratchMap() == null) { if (getCustomTree() == null) { return createItemIdIndexMap(expandedOnly); } else { return createExpandedCustomIdIndexMapping(expandedOnly); } } Map<String, List<Integer>> map = (Map<String, List<Integer>>) getScratchMap().get(EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY); if (map == null) { if (getCustomTree() == null) { map = createItemIdIndexMap(expandedOnly); } else { map = createExpandedCustomIdIndexMapping(expandedOnly); } getScratchMap().put(EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY, map); } return map; }
java
public Map<String, List<Integer>> getExpandedItemIdIndexMap() { // CLIENT MODE is include ALL boolean expandedOnly = getExpandMode() != ExpandMode.CLIENT; if (getScratchMap() == null) { if (getCustomTree() == null) { return createItemIdIndexMap(expandedOnly); } else { return createExpandedCustomIdIndexMapping(expandedOnly); } } Map<String, List<Integer>> map = (Map<String, List<Integer>>) getScratchMap().get(EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY); if (map == null) { if (getCustomTree() == null) { map = createItemIdIndexMap(expandedOnly); } else { map = createExpandedCustomIdIndexMapping(expandedOnly); } getScratchMap().put(EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY, map); } return map; }
[ "public", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "getExpandedItemIdIndexMap", "(", ")", "{", "// CLIENT MODE is include ALL", "boolean", "expandedOnly", "=", "getExpandMode", "(", ")", "!=", "ExpandMode", ".", "CLIENT", ";", "if", "(", "getScratchMap", "(", ")", "==", "null", ")", "{", "if", "(", "getCustomTree", "(", ")", "==", "null", ")", "{", "return", "createItemIdIndexMap", "(", "expandedOnly", ")", ";", "}", "else", "{", "return", "createExpandedCustomIdIndexMapping", "(", "expandedOnly", ")", ";", "}", "}", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "map", "=", "(", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", ")", "getScratchMap", "(", ")", ".", "get", "(", "EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY", ")", ";", "if", "(", "map", "==", "null", ")", "{", "if", "(", "getCustomTree", "(", ")", "==", "null", ")", "{", "map", "=", "createItemIdIndexMap", "(", "expandedOnly", ")", ";", "}", "else", "{", "map", "=", "createExpandedCustomIdIndexMapping", "(", "expandedOnly", ")", ";", "}", "getScratchMap", "(", ")", ".", "put", "(", "EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY", ",", "map", ")", ";", "}", "return", "map", ";", "}" ]
Map expanded item ids to their row index. As this can be expensive save the map onto the scratch pad. @return the mapping between an item id and its row index. Only expanded items.
[ "Map", "expanded", "item", "ids", "to", "their", "row", "index", ".", "As", "this", "can", "be", "expensive", "save", "the", "map", "onto", "the", "scratch", "pad", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L549-L569
139,343
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); // If is an internal AJAX action, set the action type. if (isCurrentAjaxTrigger()) { AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation.isInternalAjaxRequest()) { // Want to replace children in the target (Internal defaults to REPLACE target) operation.setAction(AjaxOperation.AjaxAction.IN); } } // Check if a custom tree needs the expanded rows checked TreeItemIdNode custom = getCustomTree(); if (custom != null) { checkExpandedCustomNodes(); } // Make sure the ID maps are up to date clearItemIdMaps(); if (getExpandMode() == ExpandMode.LAZY) { if (AjaxHelper.getCurrentOperation() == null) { clearPrevExpandedRows(); } else { addPrevExpandedCurrent(); } } }
java
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); // If is an internal AJAX action, set the action type. if (isCurrentAjaxTrigger()) { AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation.isInternalAjaxRequest()) { // Want to replace children in the target (Internal defaults to REPLACE target) operation.setAction(AjaxOperation.AjaxAction.IN); } } // Check if a custom tree needs the expanded rows checked TreeItemIdNode custom = getCustomTree(); if (custom != null) { checkExpandedCustomNodes(); } // Make sure the ID maps are up to date clearItemIdMaps(); if (getExpandMode() == ExpandMode.LAZY) { if (AjaxHelper.getCurrentOperation() == null) { clearPrevExpandedRows(); } else { addPrevExpandedCurrent(); } } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "// If is an internal AJAX action, set the action type.", "if", "(", "isCurrentAjaxTrigger", "(", ")", ")", "{", "AjaxOperation", "operation", "=", "AjaxHelper", ".", "getCurrentOperation", "(", ")", ";", "if", "(", "operation", ".", "isInternalAjaxRequest", "(", ")", ")", "{", "// Want to replace children in the target (Internal defaults to REPLACE target)", "operation", ".", "setAction", "(", "AjaxOperation", ".", "AjaxAction", ".", "IN", ")", ";", "}", "}", "// Check if a custom tree needs the expanded rows checked", "TreeItemIdNode", "custom", "=", "getCustomTree", "(", ")", ";", "if", "(", "custom", "!=", "null", ")", "{", "checkExpandedCustomNodes", "(", ")", ";", "}", "// Make sure the ID maps are up to date", "clearItemIdMaps", "(", ")", ";", "if", "(", "getExpandMode", "(", ")", "==", "ExpandMode", ".", "LAZY", ")", "{", "if", "(", "AjaxHelper", ".", "getCurrentOperation", "(", ")", "==", "null", ")", "{", "clearPrevExpandedRows", "(", ")", ";", "}", "else", "{", "addPrevExpandedCurrent", "(", ")", ";", "}", "}", "}" ]
Override preparePaint to register an AJAX operation. @param request the request being responded to.
[ "Override", "preparePaint", "to", "register", "an", "AJAX", "operation", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L608-L635
139,344
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.checkExpandedCustomNodes
protected void checkExpandedCustomNodes() { TreeItemIdNode custom = getCustomTree(); if (custom == null) { return; } // Get the expanded rows Set<String> expanded = getExpandedRows(); // Process Top Level for (TreeItemIdNode node : custom.getChildren()) { processCheckExpandedCustomNodes(node, expanded); } }
java
protected void checkExpandedCustomNodes() { TreeItemIdNode custom = getCustomTree(); if (custom == null) { return; } // Get the expanded rows Set<String> expanded = getExpandedRows(); // Process Top Level for (TreeItemIdNode node : custom.getChildren()) { processCheckExpandedCustomNodes(node, expanded); } }
[ "protected", "void", "checkExpandedCustomNodes", "(", ")", "{", "TreeItemIdNode", "custom", "=", "getCustomTree", "(", ")", ";", "if", "(", "custom", "==", "null", ")", "{", "return", ";", "}", "// Get the expanded rows", "Set", "<", "String", ">", "expanded", "=", "getExpandedRows", "(", ")", ";", "// Process Top Level", "for", "(", "TreeItemIdNode", "node", ":", "custom", ".", "getChildren", "(", ")", ")", "{", "processCheckExpandedCustomNodes", "(", "node", ",", "expanded", ")", ";", "}", "}" ]
Check if custom nodes that are expanded need their child nodes added from the model.
[ "Check", "if", "custom", "nodes", "that", "are", "expanded", "need", "their", "child", "nodes", "added", "from", "the", "model", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L640-L654
139,345
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.handleItemImageRequest
private void handleItemImageRequest(final Request request) { // Check for tree item id String itemId = request.getParameter(ITEM_REQUEST_KEY); if (itemId == null) { throw new SystemException("No tree item id provided for image request."); } // Check valid item id if (!isValidTreeItem(itemId)) { throw new SystemException("Tree item id for an image request [" + itemId + "] is not valid."); } List<Integer> index = getExpandedItemIdIndexMap().get(itemId); TreeItemImage image = getTreeModel().getItemImage(index); if (image == null) { throw new SystemException("Tree item id [" + itemId + "] does not have an image."); } ContentEscape escape = new ContentEscape(image.getImage()); throw escape; }
java
private void handleItemImageRequest(final Request request) { // Check for tree item id String itemId = request.getParameter(ITEM_REQUEST_KEY); if (itemId == null) { throw new SystemException("No tree item id provided for image request."); } // Check valid item id if (!isValidTreeItem(itemId)) { throw new SystemException("Tree item id for an image request [" + itemId + "] is not valid."); } List<Integer> index = getExpandedItemIdIndexMap().get(itemId); TreeItemImage image = getTreeModel().getItemImage(index); if (image == null) { throw new SystemException("Tree item id [" + itemId + "] does not have an image."); } ContentEscape escape = new ContentEscape(image.getImage()); throw escape; }
[ "private", "void", "handleItemImageRequest", "(", "final", "Request", "request", ")", "{", "// Check for tree item id", "String", "itemId", "=", "request", ".", "getParameter", "(", "ITEM_REQUEST_KEY", ")", ";", "if", "(", "itemId", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"No tree item id provided for image request.\"", ")", ";", "}", "// Check valid item id", "if", "(", "!", "isValidTreeItem", "(", "itemId", ")", ")", "{", "throw", "new", "SystemException", "(", "\"Tree item id for an image request [\"", "+", "itemId", "+", "\"] is not valid.\"", ")", ";", "}", "List", "<", "Integer", ">", "index", "=", "getExpandedItemIdIndexMap", "(", ")", ".", "get", "(", "itemId", ")", ";", "TreeItemImage", "image", "=", "getTreeModel", "(", ")", ".", "getItemImage", "(", "index", ")", ";", "if", "(", "image", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"Tree item id [\"", "+", "itemId", "+", "\"] does not have an image.\"", ")", ";", "}", "ContentEscape", "escape", "=", "new", "ContentEscape", "(", "image", ".", "getImage", "(", ")", ")", ";", "throw", "escape", ";", "}" ]
Handle a targeted request to retrieve the tree item image. @param request the request being processed
[ "Handle", "a", "targeted", "request", "to", "retrieve", "the", "tree", "item", "image", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L867-L888
139,346
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.handleOpenItemRequest
private void handleOpenItemRequest(final Request request) { // Check for tree item id String param = request.getParameter(ITEM_REQUEST_KEY); if (param == null) { throw new SystemException("No tree item id provided for open request."); } // Remove the prefix to get the item id int offset = getItemIdPrefix().length(); if (param.length() <= offset) { throw new SystemException("Tree item id [" + param + "] does not have the correct prefix value."); } String itemId = param.substring(offset); // Check is a valid item id if (!isValidTreeItem(itemId)) { throw new SystemException("Tree item id [" + itemId + "] is not valid."); } // Check expandable TreeItemIdNode custom = getCustomTree(); if (custom == null) { List<Integer> rowIndex = getExpandedItemIdIndexMap().get(itemId); if (!getTreeModel().isExpandable(rowIndex)) { throw new SystemException("Tree item id [" + itemId + "] is not expandable."); } } else { TreeItemIdNode node = getCustomIdNodeMap().get(itemId); if (!node.hasChildren()) { throw new SystemException("Tree item id [" + itemId + "] is not expandable in custom tree."); } } // Save the open id setOpenRequestItemId(itemId); // Run the open action (if set) final Action action = getOpenAction(); if (action != null) { final ActionEvent event = new ActionEvent(this, "openItem"); Runnable later = new Runnable() { @Override public void run() { action.execute(event); } }; invokeLater(later); } }
java
private void handleOpenItemRequest(final Request request) { // Check for tree item id String param = request.getParameter(ITEM_REQUEST_KEY); if (param == null) { throw new SystemException("No tree item id provided for open request."); } // Remove the prefix to get the item id int offset = getItemIdPrefix().length(); if (param.length() <= offset) { throw new SystemException("Tree item id [" + param + "] does not have the correct prefix value."); } String itemId = param.substring(offset); // Check is a valid item id if (!isValidTreeItem(itemId)) { throw new SystemException("Tree item id [" + itemId + "] is not valid."); } // Check expandable TreeItemIdNode custom = getCustomTree(); if (custom == null) { List<Integer> rowIndex = getExpandedItemIdIndexMap().get(itemId); if (!getTreeModel().isExpandable(rowIndex)) { throw new SystemException("Tree item id [" + itemId + "] is not expandable."); } } else { TreeItemIdNode node = getCustomIdNodeMap().get(itemId); if (!node.hasChildren()) { throw new SystemException("Tree item id [" + itemId + "] is not expandable in custom tree."); } } // Save the open id setOpenRequestItemId(itemId); // Run the open action (if set) final Action action = getOpenAction(); if (action != null) { final ActionEvent event = new ActionEvent(this, "openItem"); Runnable later = new Runnable() { @Override public void run() { action.execute(event); } }; invokeLater(later); } }
[ "private", "void", "handleOpenItemRequest", "(", "final", "Request", "request", ")", "{", "// Check for tree item id", "String", "param", "=", "request", ".", "getParameter", "(", "ITEM_REQUEST_KEY", ")", ";", "if", "(", "param", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"No tree item id provided for open request.\"", ")", ";", "}", "// Remove the prefix to get the item id", "int", "offset", "=", "getItemIdPrefix", "(", ")", ".", "length", "(", ")", ";", "if", "(", "param", ".", "length", "(", ")", "<=", "offset", ")", "{", "throw", "new", "SystemException", "(", "\"Tree item id [\"", "+", "param", "+", "\"] does not have the correct prefix value.\"", ")", ";", "}", "String", "itemId", "=", "param", ".", "substring", "(", "offset", ")", ";", "// Check is a valid item id", "if", "(", "!", "isValidTreeItem", "(", "itemId", ")", ")", "{", "throw", "new", "SystemException", "(", "\"Tree item id [\"", "+", "itemId", "+", "\"] is not valid.\"", ")", ";", "}", "// Check expandable", "TreeItemIdNode", "custom", "=", "getCustomTree", "(", ")", ";", "if", "(", "custom", "==", "null", ")", "{", "List", "<", "Integer", ">", "rowIndex", "=", "getExpandedItemIdIndexMap", "(", ")", ".", "get", "(", "itemId", ")", ";", "if", "(", "!", "getTreeModel", "(", ")", ".", "isExpandable", "(", "rowIndex", ")", ")", "{", "throw", "new", "SystemException", "(", "\"Tree item id [\"", "+", "itemId", "+", "\"] is not expandable.\"", ")", ";", "}", "}", "else", "{", "TreeItemIdNode", "node", "=", "getCustomIdNodeMap", "(", ")", ".", "get", "(", "itemId", ")", ";", "if", "(", "!", "node", ".", "hasChildren", "(", ")", ")", "{", "throw", "new", "SystemException", "(", "\"Tree item id [\"", "+", "itemId", "+", "\"] is not expandable in custom tree.\"", ")", ";", "}", "}", "// Save the open id", "setOpenRequestItemId", "(", "itemId", ")", ";", "// Run the open action (if set)", "final", "Action", "action", "=", "getOpenAction", "(", ")", ";", "if", "(", "action", "!=", "null", ")", "{", "final", "ActionEvent", "event", "=", "new", "ActionEvent", "(", "this", ",", "\"openItem\"", ")", ";", "Runnable", "later", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "action", ".", "execute", "(", "event", ")", ";", "}", "}", ";", "invokeLater", "(", "later", ")", ";", "}", "}" ]
Handles a request containing an open request. @param request the request containing row open request.
[ "Handles", "a", "request", "containing", "an", "open", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L895-L945
139,347
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.handleShuffleState
private void handleShuffleState(final Request request) { String json = request.getParameter(SHUFFLE_REQUEST_KEY); if (Util.empty(json)) { return; } // New TreeItemIdNode newTree; try { newTree = TreeItemUtil.convertJsonToTree(json); } catch (Exception e) { LOG.warn("Could not parse JSON for shuffle tree items. " + e.getMessage()); return; } // Current TreeItemIdNode currentTree = getCustomTree(); boolean changed = !TreeItemUtil.isTreeSame(newTree, currentTree); if (changed) { setCustomTree(newTree); // Run the shuffle action (if set) final Action action = getShuffleAction(); if (action != null) { final ActionEvent event = new ActionEvent(this, "shuffle"); Runnable later = new Runnable() { @Override public void run() { action.execute(event); } }; invokeLater(later); } } }
java
private void handleShuffleState(final Request request) { String json = request.getParameter(SHUFFLE_REQUEST_KEY); if (Util.empty(json)) { return; } // New TreeItemIdNode newTree; try { newTree = TreeItemUtil.convertJsonToTree(json); } catch (Exception e) { LOG.warn("Could not parse JSON for shuffle tree items. " + e.getMessage()); return; } // Current TreeItemIdNode currentTree = getCustomTree(); boolean changed = !TreeItemUtil.isTreeSame(newTree, currentTree); if (changed) { setCustomTree(newTree); // Run the shuffle action (if set) final Action action = getShuffleAction(); if (action != null) { final ActionEvent event = new ActionEvent(this, "shuffle"); Runnable later = new Runnable() { @Override public void run() { action.execute(event); } }; invokeLater(later); } } }
[ "private", "void", "handleShuffleState", "(", "final", "Request", "request", ")", "{", "String", "json", "=", "request", ".", "getParameter", "(", "SHUFFLE_REQUEST_KEY", ")", ";", "if", "(", "Util", ".", "empty", "(", "json", ")", ")", "{", "return", ";", "}", "// New", "TreeItemIdNode", "newTree", ";", "try", "{", "newTree", "=", "TreeItemUtil", ".", "convertJsonToTree", "(", "json", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "warn", "(", "\"Could not parse JSON for shuffle tree items. \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "return", ";", "}", "// Current", "TreeItemIdNode", "currentTree", "=", "getCustomTree", "(", ")", ";", "boolean", "changed", "=", "!", "TreeItemUtil", ".", "isTreeSame", "(", "newTree", ",", "currentTree", ")", ";", "if", "(", "changed", ")", "{", "setCustomTree", "(", "newTree", ")", ";", "// Run the shuffle action (if set)", "final", "Action", "action", "=", "getShuffleAction", "(", ")", ";", "if", "(", "action", "!=", "null", ")", "{", "final", "ActionEvent", "event", "=", "new", "ActionEvent", "(", "this", ",", "\"shuffle\"", ")", ";", "Runnable", "later", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "action", ".", "execute", "(", "event", ")", ";", "}", "}", ";", "invokeLater", "(", "later", ")", ";", "}", "}", "}" ]
Handle the tree items that have been shuffled by the client. @param request the request being processed
[ "Handle", "the", "tree", "items", "that", "have", "been", "shuffled", "by", "the", "client", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L952-L988
139,348
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.handleExpandedState
private void handleExpandedState(final Request request) { String[] paramValue = request.getParameterValues(getId() + OPEN_REQUEST_KEY); if (paramValue == null) { paramValue = new String[0]; } String[] expandedRowIds = removeEmptyStrings(paramValue); Set<String> newExpansionIds = new HashSet<>(); if (expandedRowIds != null) { int offset = getItemIdPrefix().length(); for (String expandedRowId : expandedRowIds) { if (expandedRowId.length() <= offset) { LOG.warn("Expanded row id [" + expandedRowId + "] does not have a valid prefix and will be ignored."); continue; } // Remove prefix to get item id String itemId = expandedRowId.substring(offset); // Assume the item id is valid newExpansionIds.add(itemId); } } setExpandedRows(newExpansionIds); }
java
private void handleExpandedState(final Request request) { String[] paramValue = request.getParameterValues(getId() + OPEN_REQUEST_KEY); if (paramValue == null) { paramValue = new String[0]; } String[] expandedRowIds = removeEmptyStrings(paramValue); Set<String> newExpansionIds = new HashSet<>(); if (expandedRowIds != null) { int offset = getItemIdPrefix().length(); for (String expandedRowId : expandedRowIds) { if (expandedRowId.length() <= offset) { LOG.warn("Expanded row id [" + expandedRowId + "] does not have a valid prefix and will be ignored."); continue; } // Remove prefix to get item id String itemId = expandedRowId.substring(offset); // Assume the item id is valid newExpansionIds.add(itemId); } } setExpandedRows(newExpansionIds); }
[ "private", "void", "handleExpandedState", "(", "final", "Request", "request", ")", "{", "String", "[", "]", "paramValue", "=", "request", ".", "getParameterValues", "(", "getId", "(", ")", "+", "OPEN_REQUEST_KEY", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "paramValue", "=", "new", "String", "[", "0", "]", ";", "}", "String", "[", "]", "expandedRowIds", "=", "removeEmptyStrings", "(", "paramValue", ")", ";", "Set", "<", "String", ">", "newExpansionIds", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "expandedRowIds", "!=", "null", ")", "{", "int", "offset", "=", "getItemIdPrefix", "(", ")", ".", "length", "(", ")", ";", "for", "(", "String", "expandedRowId", ":", "expandedRowIds", ")", "{", "if", "(", "expandedRowId", ".", "length", "(", ")", "<=", "offset", ")", "{", "LOG", ".", "warn", "(", "\"Expanded row id [\"", "+", "expandedRowId", "+", "\"] does not have a valid prefix and will be ignored.\"", ")", ";", "continue", ";", "}", "// Remove prefix to get item id", "String", "itemId", "=", "expandedRowId", ".", "substring", "(", "offset", ")", ";", "// Assume the item id is valid", "newExpansionIds", ".", "add", "(", "itemId", ")", ";", "}", "}", "setExpandedRows", "(", "newExpansionIds", ")", ";", "}" ]
Handle the current expanded state. @param request the request containing row expansion data.
[ "Handle", "the", "current", "expanded", "state", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L995-L1019
139,349
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.createItemIdIndexMap
private Map<String, List<Integer>> createItemIdIndexMap(final boolean expandedOnly) { Map<String, List<Integer>> map = new HashMap<>(); TreeItemModel treeModel = getTreeModel(); int rows = treeModel.getRowCount(); Set<String> expanded = null; WTree.ExpandMode mode = getExpandMode(); if (expandedOnly) { expanded = getExpandedRows(); if (mode == WTree.ExpandMode.LAZY) { expanded = new HashSet<>(expanded); expanded.addAll(getPrevExpandedRows()); } } for (int i = 0; i < rows; i++) { List<Integer> index = new ArrayList<>(); index.add(i); processItemIdIndexMapping(map, index, treeModel, expanded); } return Collections.unmodifiableMap(map); }
java
private Map<String, List<Integer>> createItemIdIndexMap(final boolean expandedOnly) { Map<String, List<Integer>> map = new HashMap<>(); TreeItemModel treeModel = getTreeModel(); int rows = treeModel.getRowCount(); Set<String> expanded = null; WTree.ExpandMode mode = getExpandMode(); if (expandedOnly) { expanded = getExpandedRows(); if (mode == WTree.ExpandMode.LAZY) { expanded = new HashSet<>(expanded); expanded.addAll(getPrevExpandedRows()); } } for (int i = 0; i < rows; i++) { List<Integer> index = new ArrayList<>(); index.add(i); processItemIdIndexMapping(map, index, treeModel, expanded); } return Collections.unmodifiableMap(map); }
[ "private", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "createItemIdIndexMap", "(", "final", "boolean", "expandedOnly", ")", "{", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "TreeItemModel", "treeModel", "=", "getTreeModel", "(", ")", ";", "int", "rows", "=", "treeModel", ".", "getRowCount", "(", ")", ";", "Set", "<", "String", ">", "expanded", "=", "null", ";", "WTree", ".", "ExpandMode", "mode", "=", "getExpandMode", "(", ")", ";", "if", "(", "expandedOnly", ")", "{", "expanded", "=", "getExpandedRows", "(", ")", ";", "if", "(", "mode", "==", "WTree", ".", "ExpandMode", ".", "LAZY", ")", "{", "expanded", "=", "new", "HashSet", "<>", "(", "expanded", ")", ";", "expanded", ".", "addAll", "(", "getPrevExpandedRows", "(", ")", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "i", "++", ")", "{", "List", "<", "Integer", ">", "index", "=", "new", "ArrayList", "<>", "(", ")", ";", "index", ".", "add", "(", "i", ")", ";", "processItemIdIndexMapping", "(", "map", ",", "index", ",", "treeModel", ",", "expanded", ")", ";", "}", "return", "Collections", ".", "unmodifiableMap", "(", "map", ")", ";", "}" ]
Map item ids to the row index. @param expandedOnly include expanded only @return the map of item ids to their row index.
[ "Map", "item", "ids", "to", "the", "row", "index", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L1081-L1102
139,350
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.processItemIdIndexMapping
private void processItemIdIndexMapping(final Map<String, List<Integer>> map, final List<Integer> rowIndex, final TreeItemModel treeModel, final Set<String> expandedRows) { // Add current item String id = treeModel.getItemId(rowIndex); if (id == null) { return; } map.put(id, rowIndex); // Check row is expandable if (!treeModel.isExpandable(rowIndex)) { return; } // Check has children if (!treeModel.hasChildren(rowIndex)) { return; } // Add children if expanded ROWS null or contains ID boolean addChildren = expandedRows == null || expandedRows.contains(id); if (!addChildren) { return; } // Get actual child count int children = treeModel.getChildCount(rowIndex); if (children == 0) { // Could be there are no children even though hasChildren returned true return; } // Add children by processing each child row for (int i = 0; i < children; i++) { // Add next level List<Integer> nextRow = new ArrayList<>(rowIndex); nextRow.add(i); processItemIdIndexMapping(map, nextRow, treeModel, expandedRows); } }
java
private void processItemIdIndexMapping(final Map<String, List<Integer>> map, final List<Integer> rowIndex, final TreeItemModel treeModel, final Set<String> expandedRows) { // Add current item String id = treeModel.getItemId(rowIndex); if (id == null) { return; } map.put(id, rowIndex); // Check row is expandable if (!treeModel.isExpandable(rowIndex)) { return; } // Check has children if (!treeModel.hasChildren(rowIndex)) { return; } // Add children if expanded ROWS null or contains ID boolean addChildren = expandedRows == null || expandedRows.contains(id); if (!addChildren) { return; } // Get actual child count int children = treeModel.getChildCount(rowIndex); if (children == 0) { // Could be there are no children even though hasChildren returned true return; } // Add children by processing each child row for (int i = 0; i < children; i++) { // Add next level List<Integer> nextRow = new ArrayList<>(rowIndex); nextRow.add(i); processItemIdIndexMapping(map, nextRow, treeModel, expandedRows); } }
[ "private", "void", "processItemIdIndexMapping", "(", "final", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "map", ",", "final", "List", "<", "Integer", ">", "rowIndex", ",", "final", "TreeItemModel", "treeModel", ",", "final", "Set", "<", "String", ">", "expandedRows", ")", "{", "// Add current item", "String", "id", "=", "treeModel", ".", "getItemId", "(", "rowIndex", ")", ";", "if", "(", "id", "==", "null", ")", "{", "return", ";", "}", "map", ".", "put", "(", "id", ",", "rowIndex", ")", ";", "// Check row is expandable", "if", "(", "!", "treeModel", ".", "isExpandable", "(", "rowIndex", ")", ")", "{", "return", ";", "}", "// Check has children", "if", "(", "!", "treeModel", ".", "hasChildren", "(", "rowIndex", ")", ")", "{", "return", ";", "}", "// Add children if expanded ROWS null or contains ID", "boolean", "addChildren", "=", "expandedRows", "==", "null", "||", "expandedRows", ".", "contains", "(", "id", ")", ";", "if", "(", "!", "addChildren", ")", "{", "return", ";", "}", "// Get actual child count", "int", "children", "=", "treeModel", ".", "getChildCount", "(", "rowIndex", ")", ";", "if", "(", "children", "==", "0", ")", "{", "// Could be there are no children even though hasChildren returned true", "return", ";", "}", "// Add children by processing each child row", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ";", "i", "++", ")", "{", "// Add next level", "List", "<", "Integer", ">", "nextRow", "=", "new", "ArrayList", "<>", "(", "rowIndex", ")", ";", "nextRow", ".", "add", "(", "i", ")", ";", "processItemIdIndexMapping", "(", "map", ",", "nextRow", ",", "treeModel", ",", "expandedRows", ")", ";", "}", "}" ]
Iterate through the table model to add the item ids and their row index. @param map the map of item ids @param rowIndex the current row index @param treeModel the tree model @param expandedRows the set of expanded rows, null if include all
[ "Iterate", "through", "the", "table", "model", "to", "add", "the", "item", "ids", "and", "their", "row", "index", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L1112-L1152
139,351
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.createCustomIdNodeMapping
private Map<String, TreeItemIdNode> createCustomIdNodeMapping() { TreeItemIdNode custom = getCustomTree(); if (custom == null) { return Collections.EMPTY_MAP; } Map<String, TreeItemIdNode> map = new HashMap<>(); processCustomIdNodeMapping(map, custom); return Collections.unmodifiableMap(map); }
java
private Map<String, TreeItemIdNode> createCustomIdNodeMapping() { TreeItemIdNode custom = getCustomTree(); if (custom == null) { return Collections.EMPTY_MAP; } Map<String, TreeItemIdNode> map = new HashMap<>(); processCustomIdNodeMapping(map, custom); return Collections.unmodifiableMap(map); }
[ "private", "Map", "<", "String", ",", "TreeItemIdNode", ">", "createCustomIdNodeMapping", "(", ")", "{", "TreeItemIdNode", "custom", "=", "getCustomTree", "(", ")", ";", "if", "(", "custom", "==", "null", ")", "{", "return", "Collections", ".", "EMPTY_MAP", ";", "}", "Map", "<", "String", ",", "TreeItemIdNode", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "processCustomIdNodeMapping", "(", "map", ",", "custom", ")", ";", "return", "Collections", ".", "unmodifiableMap", "(", "map", ")", ";", "}" ]
Create the map between the custom item id and its node. @return the map between an item id ands its custom node
[ "Create", "the", "map", "between", "the", "custom", "item", "id", "and", "its", "node", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L1159-L1168
139,352
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.processCustomIdNodeMapping
private void processCustomIdNodeMapping(final Map<String, TreeItemIdNode> map, final TreeItemIdNode node) { String itemId = node.getItemId(); if (!Util.empty(itemId)) { map.put(itemId, node); } for (TreeItemIdNode childItem : node.getChildren()) { processCustomIdNodeMapping(map, childItem); } }
java
private void processCustomIdNodeMapping(final Map<String, TreeItemIdNode> map, final TreeItemIdNode node) { String itemId = node.getItemId(); if (!Util.empty(itemId)) { map.put(itemId, node); } for (TreeItemIdNode childItem : node.getChildren()) { processCustomIdNodeMapping(map, childItem); } }
[ "private", "void", "processCustomIdNodeMapping", "(", "final", "Map", "<", "String", ",", "TreeItemIdNode", ">", "map", ",", "final", "TreeItemIdNode", "node", ")", "{", "String", "itemId", "=", "node", ".", "getItemId", "(", ")", ";", "if", "(", "!", "Util", ".", "empty", "(", "itemId", ")", ")", "{", "map", ".", "put", "(", "itemId", ",", "node", ")", ";", "}", "for", "(", "TreeItemIdNode", "childItem", ":", "node", ".", "getChildren", "(", ")", ")", "{", "processCustomIdNodeMapping", "(", "map", ",", "childItem", ")", ";", "}", "}" ]
Iterate over the custom tree structure to add entries to the map. @param map the map of custom items and their node @param node the current node being processed
[ "Iterate", "over", "the", "custom", "tree", "structure", "to", "add", "entries", "to", "the", "map", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L1176-L1185
139,353
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.createExpandedCustomIdIndexMapping
private Map<String, List<Integer>> createExpandedCustomIdIndexMapping(final boolean expandedOnly) { TreeItemIdNode custom = getCustomTree(); if (custom == null) { return Collections.EMPTY_MAP; } Set<String> expanded = null; if (expandedOnly) { expanded = getExpandedRows(); } Map<String, List<Integer>> map = new HashMap<>(); processExpandedCustomIdIndexMapping(custom, expanded, map); return Collections.unmodifiableMap(map); }
java
private Map<String, List<Integer>> createExpandedCustomIdIndexMapping(final boolean expandedOnly) { TreeItemIdNode custom = getCustomTree(); if (custom == null) { return Collections.EMPTY_MAP; } Set<String> expanded = null; if (expandedOnly) { expanded = getExpandedRows(); } Map<String, List<Integer>> map = new HashMap<>(); processExpandedCustomIdIndexMapping(custom, expanded, map); return Collections.unmodifiableMap(map); }
[ "private", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "createExpandedCustomIdIndexMapping", "(", "final", "boolean", "expandedOnly", ")", "{", "TreeItemIdNode", "custom", "=", "getCustomTree", "(", ")", ";", "if", "(", "custom", "==", "null", ")", "{", "return", "Collections", ".", "EMPTY_MAP", ";", "}", "Set", "<", "String", ">", "expanded", "=", "null", ";", "if", "(", "expandedOnly", ")", "{", "expanded", "=", "getExpandedRows", "(", ")", ";", "}", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "processExpandedCustomIdIndexMapping", "(", "custom", ",", "expanded", ",", "map", ")", ";", "return", "Collections", ".", "unmodifiableMap", "(", "map", ")", ";", "}" ]
Crate a map of the expanded custom item ids and their row index. @param expandedOnly true if expanded only @return the map between a custom item id ands its row index
[ "Crate", "a", "map", "of", "the", "expanded", "custom", "item", "ids", "and", "their", "row", "index", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L1193-L1207
139,354
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java
WTree.loadCustomNodeChildren
private void loadCustomNodeChildren(final TreeItemIdNode node) { // Check node was flagged as having children or already has children if (!node.hasChildren() || !node.getChildren().isEmpty()) { return; } // Get the row index for the node String itemId = node.getItemId(); List<Integer> rowIndex = getRowIndexForCustomItemId(itemId); // Get the tree item model TreeItemModel model = getTreeModel(); // Check tree item is expandable and has children if (!model.isExpandable(rowIndex) || !model.hasChildren(rowIndex)) { node.setHasChildren(false); return; } // Check actual child count (could have no children even though hasChildren returned true) int count = model.getChildCount(rowIndex); if (count <= 0) { node.setHasChildren(false); return; } // Get the map of item ids already in the custom tree Map<String, TreeItemIdNode> mapIds = getCustomIdNodeMap(); // Add children of item to the node tree boolean childAdded = false; for (int i = 0; i < count; i++) { List<Integer> childIdx = new ArrayList<>(rowIndex); childIdx.add(i); String childItemId = model.getItemId(childIdx); // Check the child item is not already in the custom tree if (mapIds.containsKey(childItemId)) { continue; } TreeItemIdNode childNode = new TreeItemIdNode(childItemId); childNode.setHasChildren(model.hasChildren(childIdx)); node.addChild(childNode); childAdded = true; // For client mode we have to drill down all the children if (childNode.hasChildren() && getExpandMode() == WTree.ExpandMode.CLIENT) { loadCustomNodeChildren(childNode); } } // This could happen if all the children have been used in the custom map if (!childAdded) { node.setHasChildren(false); } }
java
private void loadCustomNodeChildren(final TreeItemIdNode node) { // Check node was flagged as having children or already has children if (!node.hasChildren() || !node.getChildren().isEmpty()) { return; } // Get the row index for the node String itemId = node.getItemId(); List<Integer> rowIndex = getRowIndexForCustomItemId(itemId); // Get the tree item model TreeItemModel model = getTreeModel(); // Check tree item is expandable and has children if (!model.isExpandable(rowIndex) || !model.hasChildren(rowIndex)) { node.setHasChildren(false); return; } // Check actual child count (could have no children even though hasChildren returned true) int count = model.getChildCount(rowIndex); if (count <= 0) { node.setHasChildren(false); return; } // Get the map of item ids already in the custom tree Map<String, TreeItemIdNode> mapIds = getCustomIdNodeMap(); // Add children of item to the node tree boolean childAdded = false; for (int i = 0; i < count; i++) { List<Integer> childIdx = new ArrayList<>(rowIndex); childIdx.add(i); String childItemId = model.getItemId(childIdx); // Check the child item is not already in the custom tree if (mapIds.containsKey(childItemId)) { continue; } TreeItemIdNode childNode = new TreeItemIdNode(childItemId); childNode.setHasChildren(model.hasChildren(childIdx)); node.addChild(childNode); childAdded = true; // For client mode we have to drill down all the children if (childNode.hasChildren() && getExpandMode() == WTree.ExpandMode.CLIENT) { loadCustomNodeChildren(childNode); } } // This could happen if all the children have been used in the custom map if (!childAdded) { node.setHasChildren(false); } }
[ "private", "void", "loadCustomNodeChildren", "(", "final", "TreeItemIdNode", "node", ")", "{", "// Check node was flagged as having children or already has children", "if", "(", "!", "node", ".", "hasChildren", "(", ")", "||", "!", "node", ".", "getChildren", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "// Get the row index for the node", "String", "itemId", "=", "node", ".", "getItemId", "(", ")", ";", "List", "<", "Integer", ">", "rowIndex", "=", "getRowIndexForCustomItemId", "(", "itemId", ")", ";", "// Get the tree item model", "TreeItemModel", "model", "=", "getTreeModel", "(", ")", ";", "// Check tree item is expandable and has children", "if", "(", "!", "model", ".", "isExpandable", "(", "rowIndex", ")", "||", "!", "model", ".", "hasChildren", "(", "rowIndex", ")", ")", "{", "node", ".", "setHasChildren", "(", "false", ")", ";", "return", ";", "}", "// Check actual child count (could have no children even though hasChildren returned true)", "int", "count", "=", "model", ".", "getChildCount", "(", "rowIndex", ")", ";", "if", "(", "count", "<=", "0", ")", "{", "node", ".", "setHasChildren", "(", "false", ")", ";", "return", ";", "}", "// Get the map of item ids already in the custom tree", "Map", "<", "String", ",", "TreeItemIdNode", ">", "mapIds", "=", "getCustomIdNodeMap", "(", ")", ";", "// Add children of item to the node tree", "boolean", "childAdded", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "List", "<", "Integer", ">", "childIdx", "=", "new", "ArrayList", "<>", "(", "rowIndex", ")", ";", "childIdx", ".", "add", "(", "i", ")", ";", "String", "childItemId", "=", "model", ".", "getItemId", "(", "childIdx", ")", ";", "// Check the child item is not already in the custom tree", "if", "(", "mapIds", ".", "containsKey", "(", "childItemId", ")", ")", "{", "continue", ";", "}", "TreeItemIdNode", "childNode", "=", "new", "TreeItemIdNode", "(", "childItemId", ")", ";", "childNode", ".", "setHasChildren", "(", "model", ".", "hasChildren", "(", "childIdx", ")", ")", ";", "node", ".", "addChild", "(", "childNode", ")", ";", "childAdded", "=", "true", ";", "// For client mode we have to drill down all the children", "if", "(", "childNode", ".", "hasChildren", "(", ")", "&&", "getExpandMode", "(", ")", "==", "WTree", ".", "ExpandMode", ".", "CLIENT", ")", "{", "loadCustomNodeChildren", "(", "childNode", ")", ";", "}", "}", "// This could happen if all the children have been used in the custom map", "if", "(", "!", "childAdded", ")", "{", "node", ".", "setHasChildren", "(", "false", ")", ";", "}", "}" ]
Load the children of a custom node that was flagged as having children. @param node the node to process
[ "Load", "the", "children", "of", "a", "custom", "node", "that", "was", "flagged", "as", "having", "children", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTree.java#L1282-L1336
139,355
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMenuItemRenderer.java
WMenuItemRenderer.getRole
private String getRole(final WMenuItem item) { if (!item.isSelectAllowed()) { return null; } MenuSelectContainer selectContainer = WebUtilities.getAncestorOfClass(MenuSelectContainer.class, item); if (selectContainer == null) { return CHECKBOX_ROLE; } return MenuSelectContainer.SelectionMode.MULTIPLE.equals(selectContainer.getSelectionMode()) ? CHECKBOX_ROLE : RADIO_ROLE; }
java
private String getRole(final WMenuItem item) { if (!item.isSelectAllowed()) { return null; } MenuSelectContainer selectContainer = WebUtilities.getAncestorOfClass(MenuSelectContainer.class, item); if (selectContainer == null) { return CHECKBOX_ROLE; } return MenuSelectContainer.SelectionMode.MULTIPLE.equals(selectContainer.getSelectionMode()) ? CHECKBOX_ROLE : RADIO_ROLE; }
[ "private", "String", "getRole", "(", "final", "WMenuItem", "item", ")", "{", "if", "(", "!", "item", ".", "isSelectAllowed", "(", ")", ")", "{", "return", "null", ";", "}", "MenuSelectContainer", "selectContainer", "=", "WebUtilities", ".", "getAncestorOfClass", "(", "MenuSelectContainer", ".", "class", ",", "item", ")", ";", "if", "(", "selectContainer", "==", "null", ")", "{", "return", "CHECKBOX_ROLE", ";", "}", "return", "MenuSelectContainer", ".", "SelectionMode", ".", "MULTIPLE", ".", "equals", "(", "selectContainer", ".", "getSelectionMode", "(", ")", ")", "?", "CHECKBOX_ROLE", ":", "RADIO_ROLE", ";", "}" ]
The selection mode of the menu item. @param item the WMenuItem to test @return the selection mode if any
[ "The", "selection", "mode", "of", "the", "menu", "item", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMenuItemRenderer.java#L33-L42
139,356
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMenuItemRenderer.java
WMenuItemRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WMenuItem item = (WMenuItem) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:menuitem"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); if (item.isSubmit()) { xml.appendAttribute("submit", "true"); } else { xml.appendOptionalUrlAttribute("url", item.getUrl()); xml.appendOptionalAttribute("targetWindow", item.getTargetWindow()); } xml.appendOptionalAttribute("disabled", item.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", item.isHidden(), "true"); xml.appendOptionalAttribute("selected", item.isSelected(), "true"); xml.appendOptionalAttribute("role", getRole(item)); xml.appendOptionalAttribute("cancel", item.isCancel(), "true"); xml.appendOptionalAttribute("msg", item.getMessage()); xml.appendOptionalAttribute("toolTip", item.getToolTip()); if (item.isTopLevelItem()) { xml.appendOptionalAttribute("accessKey", item.getAccessKeyAsString()); } xml.appendClose(); item.getDecoratedLabel().paint(renderContext); xml.appendEndTag("ui:menuitem"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WMenuItem item = (WMenuItem) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:menuitem"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); if (item.isSubmit()) { xml.appendAttribute("submit", "true"); } else { xml.appendOptionalUrlAttribute("url", item.getUrl()); xml.appendOptionalAttribute("targetWindow", item.getTargetWindow()); } xml.appendOptionalAttribute("disabled", item.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", item.isHidden(), "true"); xml.appendOptionalAttribute("selected", item.isSelected(), "true"); xml.appendOptionalAttribute("role", getRole(item)); xml.appendOptionalAttribute("cancel", item.isCancel(), "true"); xml.appendOptionalAttribute("msg", item.getMessage()); xml.appendOptionalAttribute("toolTip", item.getToolTip()); if (item.isTopLevelItem()) { xml.appendOptionalAttribute("accessKey", item.getAccessKeyAsString()); } xml.appendClose(); item.getDecoratedLabel().paint(renderContext); xml.appendEndTag("ui:menuitem"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WMenuItem", "item", "=", "(", "WMenuItem", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:menuitem\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "item", ".", "isSubmit", "(", ")", ")", "{", "xml", ".", "appendAttribute", "(", "\"submit\"", ",", "\"true\"", ")", ";", "}", "else", "{", "xml", ".", "appendOptionalUrlAttribute", "(", "\"url\"", ",", "item", ".", "getUrl", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"targetWindow\"", ",", "item", ".", "getTargetWindow", "(", ")", ")", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "item", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "item", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"selected\"", ",", "item", ".", "isSelected", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"role\"", ",", "getRole", "(", "item", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"cancel\"", ",", "item", ".", "isCancel", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"msg\"", ",", "item", ".", "getMessage", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "item", ".", "getToolTip", "(", ")", ")", ";", "if", "(", "item", ".", "isTopLevelItem", "(", ")", ")", "{", "xml", ".", "appendOptionalAttribute", "(", "\"accessKey\"", ",", "item", ".", "getAccessKeyAsString", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "item", ".", "getDecoratedLabel", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:menuitem\"", ")", ";", "}" ]
Paints the given WMenuItem. @param component the WMenuItem to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WMenuItem", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMenuItemRenderer.java#L50-L84
139,357
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterComponent.java
RepeaterComponent.show
public void show() { StringBuffer out = new StringBuffer(); for (Iterator iter = repeater.getBeanList().iterator(); iter.hasNext();) { MyData data = (MyData) iter.next(); out.append(data.getName()).append(" : ").append(data.getCount()).append('\n'); } selectorText.setText(out.toString()); }
java
public void show() { StringBuffer out = new StringBuffer(); for (Iterator iter = repeater.getBeanList().iterator(); iter.hasNext();) { MyData data = (MyData) iter.next(); out.append(data.getName()).append(" : ").append(data.getCount()).append('\n'); } selectorText.setText(out.toString()); }
[ "public", "void", "show", "(", ")", "{", "StringBuffer", "out", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "repeater", ".", "getBeanList", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "MyData", "data", "=", "(", "MyData", ")", "iter", ".", "next", "(", ")", ";", "out", ".", "append", "(", "data", ".", "getName", "(", ")", ")", ".", "append", "(", "\" : \"", ")", ".", "append", "(", "data", ".", "getCount", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "selectorText", ".", "setText", "(", "out", ".", "toString", "(", ")", ")", ";", "}" ]
Show the current list of beans used by the repeater.
[ "Show", "the", "current", "list", "of", "beans", "used", "by", "the", "repeater", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterComponent.java#L62-L71
139,358
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMessageBoxRenderer.java
WMessageBoxRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WMessageBox messageBox = (WMessageBox) component; XmlStringBuilder xml = renderContext.getWriter(); if (messageBox.hasMessages()) { xml.appendTagOpen("ui:messagebox"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); switch (messageBox.getType()) { case SUCCESS: xml.appendOptionalAttribute("type", "success"); break; case INFO: xml.appendOptionalAttribute("type", "info"); break; case WARN: xml.appendOptionalAttribute("type", "warn"); break; case ERROR: default: xml.appendOptionalAttribute("type", "error"); break; } xml.appendOptionalAttribute("title", messageBox.getTitleText()); xml.appendClose(); for (String message : messageBox.getMessages()) { xml.appendTag("ui:message"); xml.print(message); xml.appendEndTag("ui:message"); } xml.appendEndTag("ui:messagebox"); } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WMessageBox messageBox = (WMessageBox) component; XmlStringBuilder xml = renderContext.getWriter(); if (messageBox.hasMessages()) { xml.appendTagOpen("ui:messagebox"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); switch (messageBox.getType()) { case SUCCESS: xml.appendOptionalAttribute("type", "success"); break; case INFO: xml.appendOptionalAttribute("type", "info"); break; case WARN: xml.appendOptionalAttribute("type", "warn"); break; case ERROR: default: xml.appendOptionalAttribute("type", "error"); break; } xml.appendOptionalAttribute("title", messageBox.getTitleText()); xml.appendClose(); for (String message : messageBox.getMessages()) { xml.appendTag("ui:message"); xml.print(message); xml.appendEndTag("ui:message"); } xml.appendEndTag("ui:messagebox"); } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WMessageBox", "messageBox", "=", "(", "WMessageBox", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "if", "(", "messageBox", ".", "hasMessages", "(", ")", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:messagebox\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "switch", "(", "messageBox", ".", "getType", "(", ")", ")", "{", "case", "SUCCESS", ":", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "\"success\"", ")", ";", "break", ";", "case", "INFO", ":", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "\"info\"", ")", ";", "break", ";", "case", "WARN", ":", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "\"warn\"", ")", ";", "break", ";", "case", "ERROR", ":", "default", ":", "xml", ".", "appendOptionalAttribute", "(", "\"type\"", ",", "\"error\"", ")", ";", "break", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"title\"", ",", "messageBox", ".", "getTitleText", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "for", "(", "String", "message", ":", "messageBox", ".", "getMessages", "(", ")", ")", "{", "xml", ".", "appendTag", "(", "\"ui:message\"", ")", ";", "xml", ".", "print", "(", "message", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:message\"", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:messagebox\"", ")", ";", "}", "}" ]
Paints the given WMessageBox. @param component the WMessageBox to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WMessageBox", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMessageBoxRenderer.java#L24-L66
139,359
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/validation/repeater/RepeaterExample.java
RepeaterExample.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { MyDataBean myBean = new MyDataBean(); myBean.setName("My Bean"); myBean.addBean(new SomeDataBean("blah", "more blah")); myBean.addBean(new SomeDataBean()); repeaterFields.setData(myBean); setInitialised(true); } }
java
@Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { MyDataBean myBean = new MyDataBean(); myBean.setName("My Bean"); myBean.addBean(new SomeDataBean("blah", "more blah")); myBean.addBean(new SomeDataBean()); repeaterFields.setData(myBean); setInitialised(true); } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "if", "(", "!", "isInitialised", "(", ")", ")", "{", "MyDataBean", "myBean", "=", "new", "MyDataBean", "(", ")", ";", "myBean", ".", "setName", "(", "\"My Bean\"", ")", ";", "myBean", ".", "addBean", "(", "new", "SomeDataBean", "(", "\"blah\"", ",", "\"more blah\"", ")", ")", ";", "myBean", ".", "addBean", "(", "new", "SomeDataBean", "(", ")", ")", ";", "repeaterFields", ".", "setData", "(", "myBean", ")", ";", "setInitialised", "(", "true", ")", ";", "}", "}" ]
Override preparepaint to initialise the data on first acecss by a user. @param request the request being responded to.
[ "Override", "preparepaint", "to", "initialise", "the", "data", "on", "first", "acecss", "by", "a", "user", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/validation/repeater/RepeaterExample.java#L90-L103
139,360
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/SubordinateControlInterceptor.java
SubordinateControlInterceptor.serviceRequest
@Override public void serviceRequest(final Request request) { // Only apply for POST if ("POST".equals(request.getMethod())) { // Apply Controls (Use values on request) SubordinateControlHelper.applyRegisteredControls(request, true); } // Service Request super.serviceRequest(request); }
java
@Override public void serviceRequest(final Request request) { // Only apply for POST if ("POST".equals(request.getMethod())) { // Apply Controls (Use values on request) SubordinateControlHelper.applyRegisteredControls(request, true); } // Service Request super.serviceRequest(request); }
[ "@", "Override", "public", "void", "serviceRequest", "(", "final", "Request", "request", ")", "{", "// Only apply for POST", "if", "(", "\"POST\"", ".", "equals", "(", "request", ".", "getMethod", "(", ")", ")", ")", "{", "// Apply Controls (Use values on request)", "SubordinateControlHelper", ".", "applyRegisteredControls", "(", "request", ",", "true", ")", ";", "}", "// Service Request", "super", ".", "serviceRequest", "(", "request", ")", ";", "}" ]
Before servicing the request, apply the registered subordinate controls to make sure any state changes that have occurred on the client are applied. @param request the request being serviced
[ "Before", "servicing", "the", "request", "apply", "the", "registered", "subordinate", "controls", "to", "make", "sure", "any", "state", "changes", "that", "have", "occurred", "on", "the", "client", "are", "applied", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/SubordinateControlInterceptor.java#L28-L38
139,361
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/SubordinateControlInterceptor.java
SubordinateControlInterceptor.preparePaint
@Override public void preparePaint(final Request request) { // Clear all registered controls on Session SubordinateControlHelper.clearAllRegisteredControls(); super.preparePaint(request); // Apply Controls (Use values from the component models) SubordinateControlHelper.applyRegisteredControls(request, false); }
java
@Override public void preparePaint(final Request request) { // Clear all registered controls on Session SubordinateControlHelper.clearAllRegisteredControls(); super.preparePaint(request); // Apply Controls (Use values from the component models) SubordinateControlHelper.applyRegisteredControls(request, false); }
[ "@", "Override", "public", "void", "preparePaint", "(", "final", "Request", "request", ")", "{", "// Clear all registered controls on Session", "SubordinateControlHelper", ".", "clearAllRegisteredControls", "(", ")", ";", "super", ".", "preparePaint", "(", "request", ")", ";", "// Apply Controls (Use values from the component models)", "SubordinateControlHelper", ".", "applyRegisteredControls", "(", "request", ",", "false", ")", ";", "}" ]
After the prepare paint phase, apply the registered subordinate controls to make sure all the components are in the correct state before being rendered to the client. @param request the request being serviced
[ "After", "the", "prepare", "paint", "phase", "apply", "the", "registered", "subordinate", "controls", "to", "make", "sure", "all", "the", "components", "are", "in", "the", "correct", "state", "before", "being", "rendered", "to", "the", "client", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/SubordinateControlInterceptor.java#L46-L55
139,362
BorderTech/wcomponents
wcomponents-lde/src/main/java/com/github/bordertech/wcomponents/lde/PlainLauncher.java
PlainLauncher.getUI
@Override public synchronized WComponent getUI(final Object httpServletRequest) { String configuredUIClassName = getComponentToLaunchClassName(); if (sharedUI == null || !Util.equals(configuredUIClassName, uiClassName)) { uiClassName = configuredUIClassName; WComponent ui = createUI(); if (ui instanceof WApplication) { sharedUI = (WApplication) ui; } else { LOG.warn( "Top-level component should be a WApplication." + " Creating WApplication wrapper..."); sharedUI = new WApplication(); ui.setLocked(false); sharedUI.add(ui); sharedUI.setLocked(true); } if (ConfigurationProperties.getLdeServerShowMemoryProfile()) { ProfileContainer profiler = new ProfileContainer(); sharedUI.setLocked(false); sharedUI.add(profiler); sharedUI.setLocked(true); } } return sharedUI; }
java
@Override public synchronized WComponent getUI(final Object httpServletRequest) { String configuredUIClassName = getComponentToLaunchClassName(); if (sharedUI == null || !Util.equals(configuredUIClassName, uiClassName)) { uiClassName = configuredUIClassName; WComponent ui = createUI(); if (ui instanceof WApplication) { sharedUI = (WApplication) ui; } else { LOG.warn( "Top-level component should be a WApplication." + " Creating WApplication wrapper..."); sharedUI = new WApplication(); ui.setLocked(false); sharedUI.add(ui); sharedUI.setLocked(true); } if (ConfigurationProperties.getLdeServerShowMemoryProfile()) { ProfileContainer profiler = new ProfileContainer(); sharedUI.setLocked(false); sharedUI.add(profiler); sharedUI.setLocked(true); } } return sharedUI; }
[ "@", "Override", "public", "synchronized", "WComponent", "getUI", "(", "final", "Object", "httpServletRequest", ")", "{", "String", "configuredUIClassName", "=", "getComponentToLaunchClassName", "(", ")", ";", "if", "(", "sharedUI", "==", "null", "||", "!", "Util", ".", "equals", "(", "configuredUIClassName", ",", "uiClassName", ")", ")", "{", "uiClassName", "=", "configuredUIClassName", ";", "WComponent", "ui", "=", "createUI", "(", ")", ";", "if", "(", "ui", "instanceof", "WApplication", ")", "{", "sharedUI", "=", "(", "WApplication", ")", "ui", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"Top-level component should be a WApplication.\"", "+", "\" Creating WApplication wrapper...\"", ")", ";", "sharedUI", "=", "new", "WApplication", "(", ")", ";", "ui", ".", "setLocked", "(", "false", ")", ";", "sharedUI", ".", "add", "(", "ui", ")", ";", "sharedUI", ".", "setLocked", "(", "true", ")", ";", "}", "if", "(", "ConfigurationProperties", ".", "getLdeServerShowMemoryProfile", "(", ")", ")", "{", "ProfileContainer", "profiler", "=", "new", "ProfileContainer", "(", ")", ";", "sharedUI", ".", "setLocked", "(", "false", ")", ";", "sharedUI", ".", "add", "(", "profiler", ")", ";", "sharedUI", ".", "setLocked", "(", "true", ")", ";", "}", "}", "return", "sharedUI", ";", "}" ]
This method has been overridden to load a WComponent from parameters. @param httpServletRequest the servlet request being handled. @return the top-level WComponent for this servlet.
[ "This", "method", "has", "been", "overridden", "to", "load", "a", "WComponent", "from", "parameters", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-lde/src/main/java/com/github/bordertech/wcomponents/lde/PlainLauncher.java#L61-L92
139,363
BorderTech/wcomponents
wcomponents-lde/src/main/java/com/github/bordertech/wcomponents/lde/PlainLauncher.java
PlainLauncher.createUI
protected WComponent createUI() { // Check if the parameter COMPONENT_TO_LAUNCH_PARAM_KEY has been // configured with the name of a component to launch. WComponent sharedApp; uiClassName = getComponentToLaunchClassName(); if (uiClassName == null) { sharedApp = new WText( "You need to set the class name of the WComponent you want to run.<br />" + "Do this by setting the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" in your \"local_app.properties\" file.<br />" + "Eg. <code>" + COMPONENT_TO_LAUNCH_PARAM_KEY + "=com.github.bordertech.wcomponents.examples.picker.ExamplePicker</code>"); ((WText) sharedApp).setEncodeText(false); } else { UIRegistry registry = UIRegistry.getInstance(); sharedApp = registry.getUI(uiClassName); if (sharedApp == null) { sharedApp = new WText( "Unable to load the component \"" + uiClassName + "\".<br />" + "Either the component does not exist as a resource in the classpath," + " or is not a WComponent.<br />" + "Check that the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" is set correctly."); ((WText) sharedApp).setEncodeText(false); } } return sharedApp; }
java
protected WComponent createUI() { // Check if the parameter COMPONENT_TO_LAUNCH_PARAM_KEY has been // configured with the name of a component to launch. WComponent sharedApp; uiClassName = getComponentToLaunchClassName(); if (uiClassName == null) { sharedApp = new WText( "You need to set the class name of the WComponent you want to run.<br />" + "Do this by setting the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" in your \"local_app.properties\" file.<br />" + "Eg. <code>" + COMPONENT_TO_LAUNCH_PARAM_KEY + "=com.github.bordertech.wcomponents.examples.picker.ExamplePicker</code>"); ((WText) sharedApp).setEncodeText(false); } else { UIRegistry registry = UIRegistry.getInstance(); sharedApp = registry.getUI(uiClassName); if (sharedApp == null) { sharedApp = new WText( "Unable to load the component \"" + uiClassName + "\".<br />" + "Either the component does not exist as a resource in the classpath," + " or is not a WComponent.<br />" + "Check that the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" is set correctly."); ((WText) sharedApp).setEncodeText(false); } } return sharedApp; }
[ "protected", "WComponent", "createUI", "(", ")", "{", "// Check if the parameter COMPONENT_TO_LAUNCH_PARAM_KEY has been", "// configured with the name of a component to launch.", "WComponent", "sharedApp", ";", "uiClassName", "=", "getComponentToLaunchClassName", "(", ")", ";", "if", "(", "uiClassName", "==", "null", ")", "{", "sharedApp", "=", "new", "WText", "(", "\"You need to set the class name of the WComponent you want to run.<br />\"", "+", "\"Do this by setting the parameter \\\"\"", "+", "COMPONENT_TO_LAUNCH_PARAM_KEY", "+", "\"\\\" in your \\\"local_app.properties\\\" file.<br />\"", "+", "\"Eg. <code>\"", "+", "COMPONENT_TO_LAUNCH_PARAM_KEY", "+", "\"=com.github.bordertech.wcomponents.examples.picker.ExamplePicker</code>\"", ")", ";", "(", "(", "WText", ")", "sharedApp", ")", ".", "setEncodeText", "(", "false", ")", ";", "}", "else", "{", "UIRegistry", "registry", "=", "UIRegistry", ".", "getInstance", "(", ")", ";", "sharedApp", "=", "registry", ".", "getUI", "(", "uiClassName", ")", ";", "if", "(", "sharedApp", "==", "null", ")", "{", "sharedApp", "=", "new", "WText", "(", "\"Unable to load the component \\\"\"", "+", "uiClassName", "+", "\"\\\".<br />\"", "+", "\"Either the component does not exist as a resource in the classpath,\"", "+", "\" or is not a WComponent.<br />\"", "+", "\"Check that the parameter \\\"\"", "+", "COMPONENT_TO_LAUNCH_PARAM_KEY", "+", "\"\\\" is set correctly.\"", ")", ";", "(", "(", "WText", ")", "sharedApp", ")", ".", "setEncodeText", "(", "false", ")", ";", "}", "}", "return", "sharedApp", ";", "}" ]
Creates the UI which the launcher displays. If there is misconfiguration or error, a UI containing an error message is returned. @return the UI which the launcher displays.
[ "Creates", "the", "UI", "which", "the", "launcher", "displays", ".", "If", "there", "is", "misconfiguration", "or", "error", "a", "UI", "containing", "an", "error", "message", "is", "returned", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-lde/src/main/java/com/github/bordertech/wcomponents/lde/PlainLauncher.java#L100-L138
139,364
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithEditableRows.java
RepeaterExampleWithEditableRows.createExampleUi
private void createExampleUi() { add(new WHeading(HeadingLevel.H2, "Contacts")); add(repeater); WButton addBtn = new WButton("Add"); addBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { addNewContact(); } }); newNameField.setDefaultSubmitButton(addBtn); WButton printBtn = new WButton("Print"); printBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { printEditedDetails(); } }); WFieldLayout layout = new WFieldLayout(); add(layout); layout.addField("New contact name", newNameField); layout.addField((WLabel) null, addBtn); layout.addField("Print output", console); layout.addField((WLabel) null, printBtn); // Ajax controls to make things zippier add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField})); add(new WAjaxControl(printBtn, console)); }
java
private void createExampleUi() { add(new WHeading(HeadingLevel.H2, "Contacts")); add(repeater); WButton addBtn = new WButton("Add"); addBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { addNewContact(); } }); newNameField.setDefaultSubmitButton(addBtn); WButton printBtn = new WButton("Print"); printBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { printEditedDetails(); } }); WFieldLayout layout = new WFieldLayout(); add(layout); layout.addField("New contact name", newNameField); layout.addField((WLabel) null, addBtn); layout.addField("Print output", console); layout.addField((WLabel) null, printBtn); // Ajax controls to make things zippier add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField})); add(new WAjaxControl(printBtn, console)); }
[ "private", "void", "createExampleUi", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"Contacts\"", ")", ")", ";", "add", "(", "repeater", ")", ";", "WButton", "addBtn", "=", "new", "WButton", "(", "\"Add\"", ")", ";", "addBtn", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "addNewContact", "(", ")", ";", "}", "}", ")", ";", "newNameField", ".", "setDefaultSubmitButton", "(", "addBtn", ")", ";", "WButton", "printBtn", "=", "new", "WButton", "(", "\"Print\"", ")", ";", "printBtn", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "printEditedDetails", "(", ")", ";", "}", "}", ")", ";", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "add", "(", "layout", ")", ";", "layout", ".", "addField", "(", "\"New contact name\"", ",", "newNameField", ")", ";", "layout", ".", "addField", "(", "(", "WLabel", ")", "null", ",", "addBtn", ")", ";", "layout", ".", "addField", "(", "\"Print output\"", ",", "console", ")", ";", "layout", ".", "addField", "(", "(", "WLabel", ")", "null", ",", "printBtn", ")", ";", "// Ajax controls to make things zippier", "add", "(", "new", "WAjaxControl", "(", "addBtn", ",", "new", "AjaxTarget", "[", "]", "{", "repeater", ",", "newNameField", "}", ")", ")", ";", "add", "(", "new", "WAjaxControl", "(", "printBtn", ",", "console", ")", ")", ";", "}" ]
Add all the required UI artefacts for this example.
[ "Add", "all", "the", "required", "UI", "artefacts", "for", "this", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithEditableRows.java#L64-L95
139,365
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithEditableRows.java
RepeaterExampleWithEditableRows.printEditedDetails
private void printEditedDetails() { StringBuilder buf = new StringBuilder(); for (Object contact : repeater.getBeanList()) { buf.append(contact).append('\n'); } console.setText(buf.toString()); }
java
private void printEditedDetails() { StringBuilder buf = new StringBuilder(); for (Object contact : repeater.getBeanList()) { buf.append(contact).append('\n'); } console.setText(buf.toString()); }
[ "private", "void", "printEditedDetails", "(", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Object", "contact", ":", "repeater", ".", "getBeanList", "(", ")", ")", "{", "buf", ".", "append", "(", "contact", ")", ".", "append", "(", "'", "'", ")", ";", "}", "console", ".", "setText", "(", "buf", ".", "toString", "(", ")", ")", ";", "}" ]
Write the list of contacts into the textarea console. Any modified phone numbers should be printed out.
[ "Write", "the", "list", "of", "contacts", "into", "the", "textarea", "console", ".", "Any", "modified", "phone", "numbers", "should", "be", "printed", "out", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithEditableRows.java#L110-L118
139,366
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList.java
AbstractWMultiSelectList.getNotSelected
public List<?> getNotSelected() { List options = getOptions(); if (options == null || options.isEmpty()) { return Collections.EMPTY_LIST; } List notSelected = new ArrayList(options); notSelected.removeAll(getSelected()); return Collections.unmodifiableList(notSelected); }
java
public List<?> getNotSelected() { List options = getOptions(); if (options == null || options.isEmpty()) { return Collections.EMPTY_LIST; } List notSelected = new ArrayList(options); notSelected.removeAll(getSelected()); return Collections.unmodifiableList(notSelected); }
[ "public", "List", "<", "?", ">", "getNotSelected", "(", ")", "{", "List", "options", "=", "getOptions", "(", ")", ";", "if", "(", "options", "==", "null", "||", "options", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "EMPTY_LIST", ";", "}", "List", "notSelected", "=", "new", "ArrayList", "(", "options", ")", ";", "notSelected", ".", "removeAll", "(", "getSelected", "(", ")", ")", ";", "return", "Collections", ".", "unmodifiableList", "(", "notSelected", ")", ";", "}" ]
Returns the options which are not selected. @return The unselected options(s).
[ "Returns", "the", "options", "which", "are", "not", "selected", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList.java#L148-L157
139,367
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList.java
AbstractWMultiSelectList.getNewSelections
protected List<?> getNewSelections(final Request request) { String[] paramValues = request.getParameterValues(getId()); if (paramValues == null || paramValues.length == 0) { return NO_SELECTION; } List<String> values = Arrays.asList(paramValues); List<Object> newSelections = new ArrayList<>(values.size()); // Figure out which options have been selected. List<?> options = getOptions(); if (options == null || options.isEmpty()) { if (!isEditable()) { // User could not have made a selection. return NO_SELECTION; } options = Collections.EMPTY_LIST; } for (Object value : values) { boolean found = false; int optionIndex = 0; for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null) { for (Object nestedOption : groupOptions) { if (value.equals(optionToCode(nestedOption, optionIndex++))) { newSelections.add(nestedOption); found = true; break; } } } } else if (value.equals(optionToCode(option, optionIndex++))) { newSelections.add(option); found = true; break; } } if (!found) { if (isEditable()) { newSelections.add(value); } else { LOG.warn( "Option \"" + value + "\" on the request is not a valid option. Will be ignored."); } } } // If no valid options found, then return the current settings if (newSelections.isEmpty()) { LOG.warn("No options on the request are valid. Will be ignored."); return getValue(); } // If must have selection and more than 1 option selected, remove the "null" entry if it was selected. if (!isAllowNoSelection() && newSelections.size() > 1) { List<Object> filtered = new ArrayList<>(); Object nullOption = null; for (Object option : newSelections) { // Check option is null or empty boolean isNull = option == null ? true : option.toString().length() == 0; if (isNull) { // Hold the option as it could be "null" or "empty" nullOption = option; } else { filtered.add(option); } } // In the case where only null options were selected, then add one nullOption if (filtered.isEmpty()) { filtered.add(nullOption); } return filtered; } else { return newSelections; } }
java
protected List<?> getNewSelections(final Request request) { String[] paramValues = request.getParameterValues(getId()); if (paramValues == null || paramValues.length == 0) { return NO_SELECTION; } List<String> values = Arrays.asList(paramValues); List<Object> newSelections = new ArrayList<>(values.size()); // Figure out which options have been selected. List<?> options = getOptions(); if (options == null || options.isEmpty()) { if (!isEditable()) { // User could not have made a selection. return NO_SELECTION; } options = Collections.EMPTY_LIST; } for (Object value : values) { boolean found = false; int optionIndex = 0; for (Object option : options) { if (option instanceof OptionGroup) { List<?> groupOptions = ((OptionGroup) option).getOptions(); if (groupOptions != null) { for (Object nestedOption : groupOptions) { if (value.equals(optionToCode(nestedOption, optionIndex++))) { newSelections.add(nestedOption); found = true; break; } } } } else if (value.equals(optionToCode(option, optionIndex++))) { newSelections.add(option); found = true; break; } } if (!found) { if (isEditable()) { newSelections.add(value); } else { LOG.warn( "Option \"" + value + "\" on the request is not a valid option. Will be ignored."); } } } // If no valid options found, then return the current settings if (newSelections.isEmpty()) { LOG.warn("No options on the request are valid. Will be ignored."); return getValue(); } // If must have selection and more than 1 option selected, remove the "null" entry if it was selected. if (!isAllowNoSelection() && newSelections.size() > 1) { List<Object> filtered = new ArrayList<>(); Object nullOption = null; for (Object option : newSelections) { // Check option is null or empty boolean isNull = option == null ? true : option.toString().length() == 0; if (isNull) { // Hold the option as it could be "null" or "empty" nullOption = option; } else { filtered.add(option); } } // In the case where only null options were selected, then add one nullOption if (filtered.isEmpty()) { filtered.add(nullOption); } return filtered; } else { return newSelections; } }
[ "protected", "List", "<", "?", ">", "getNewSelections", "(", "final", "Request", "request", ")", "{", "String", "[", "]", "paramValues", "=", "request", ".", "getParameterValues", "(", "getId", "(", ")", ")", ";", "if", "(", "paramValues", "==", "null", "||", "paramValues", ".", "length", "==", "0", ")", "{", "return", "NO_SELECTION", ";", "}", "List", "<", "String", ">", "values", "=", "Arrays", ".", "asList", "(", "paramValues", ")", ";", "List", "<", "Object", ">", "newSelections", "=", "new", "ArrayList", "<>", "(", "values", ".", "size", "(", ")", ")", ";", "// Figure out which options have been selected.", "List", "<", "?", ">", "options", "=", "getOptions", "(", ")", ";", "if", "(", "options", "==", "null", "||", "options", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "!", "isEditable", "(", ")", ")", "{", "// User could not have made a selection.", "return", "NO_SELECTION", ";", "}", "options", "=", "Collections", ".", "EMPTY_LIST", ";", "}", "for", "(", "Object", "value", ":", "values", ")", "{", "boolean", "found", "=", "false", ";", "int", "optionIndex", "=", "0", ";", "for", "(", "Object", "option", ":", "options", ")", "{", "if", "(", "option", "instanceof", "OptionGroup", ")", "{", "List", "<", "?", ">", "groupOptions", "=", "(", "(", "OptionGroup", ")", "option", ")", ".", "getOptions", "(", ")", ";", "if", "(", "groupOptions", "!=", "null", ")", "{", "for", "(", "Object", "nestedOption", ":", "groupOptions", ")", "{", "if", "(", "value", ".", "equals", "(", "optionToCode", "(", "nestedOption", ",", "optionIndex", "++", ")", ")", ")", "{", "newSelections", ".", "add", "(", "nestedOption", ")", ";", "found", "=", "true", ";", "break", ";", "}", "}", "}", "}", "else", "if", "(", "value", ".", "equals", "(", "optionToCode", "(", "option", ",", "optionIndex", "++", ")", ")", ")", "{", "newSelections", ".", "add", "(", "option", ")", ";", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "if", "(", "isEditable", "(", ")", ")", "{", "newSelections", ".", "add", "(", "value", ")", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"Option \\\"\"", "+", "value", "+", "\"\\\" on the request is not a valid option. Will be ignored.\"", ")", ";", "}", "}", "}", "// If no valid options found, then return the current settings", "if", "(", "newSelections", ".", "isEmpty", "(", ")", ")", "{", "LOG", ".", "warn", "(", "\"No options on the request are valid. Will be ignored.\"", ")", ";", "return", "getValue", "(", ")", ";", "}", "// If must have selection and more than 1 option selected, remove the \"null\" entry if it was selected.", "if", "(", "!", "isAllowNoSelection", "(", ")", "&&", "newSelections", ".", "size", "(", ")", ">", "1", ")", "{", "List", "<", "Object", ">", "filtered", "=", "new", "ArrayList", "<>", "(", ")", ";", "Object", "nullOption", "=", "null", ";", "for", "(", "Object", "option", ":", "newSelections", ")", "{", "// Check option is null or empty", "boolean", "isNull", "=", "option", "==", "null", "?", "true", ":", "option", ".", "toString", "(", ")", ".", "length", "(", ")", "==", "0", ";", "if", "(", "isNull", ")", "{", "// Hold the option as it could be \"null\" or \"empty\"", "nullOption", "=", "option", ";", "}", "else", "{", "filtered", ".", "add", "(", "option", ")", ";", "}", "}", "// In the case where only null options were selected, then add one nullOption", "if", "(", "filtered", ".", "isEmpty", "(", ")", ")", "{", "filtered", ".", "add", "(", "nullOption", ")", ";", "}", "return", "filtered", ";", "}", "else", "{", "return", "newSelections", ";", "}", "}" ]
Determines which selections have been added in the given request. @param request the current request @return a list of selections that have been added in the given request.
[ "Determines", "which", "selections", "have", "been", "added", "in", "the", "given", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList.java#L424-L504
139,368
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList.java
AbstractWMultiSelectList.validateComponent
@Override protected void validateComponent(final List<Diagnostic> diags) { super.validateComponent(diags); List<?> selected = getValue(); // Only validate max and min if options have been selected if (!selected.isEmpty()) { int value = selected.size(); int min = getMinSelect(); int max = getMaxSelect(); if (min > 0 && value < min) { diags.add( createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_MIN_SELECT, this, min)); } if (max > 0 && value > max) { diags.add( createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_MAX_SELECT, this, max)); } } }
java
@Override protected void validateComponent(final List<Diagnostic> diags) { super.validateComponent(diags); List<?> selected = getValue(); // Only validate max and min if options have been selected if (!selected.isEmpty()) { int value = selected.size(); int min = getMinSelect(); int max = getMaxSelect(); if (min > 0 && value < min) { diags.add( createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_MIN_SELECT, this, min)); } if (max > 0 && value > max) { diags.add( createErrorDiagnostic(InternalMessages.DEFAULT_VALIDATION_ERROR_MAX_SELECT, this, max)); } } }
[ "@", "Override", "protected", "void", "validateComponent", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "super", ".", "validateComponent", "(", "diags", ")", ";", "List", "<", "?", ">", "selected", "=", "getValue", "(", ")", ";", "// Only validate max and min if options have been selected", "if", "(", "!", "selected", ".", "isEmpty", "(", ")", ")", "{", "int", "value", "=", "selected", ".", "size", "(", ")", ";", "int", "min", "=", "getMinSelect", "(", ")", ";", "int", "max", "=", "getMaxSelect", "(", ")", ";", "if", "(", "min", ">", "0", "&&", "value", "<", "min", ")", "{", "diags", ".", "add", "(", "createErrorDiagnostic", "(", "InternalMessages", ".", "DEFAULT_VALIDATION_ERROR_MIN_SELECT", ",", "this", ",", "min", ")", ")", ";", "}", "if", "(", "max", ">", "0", "&&", "value", ">", "max", ")", "{", "diags", ".", "add", "(", "createErrorDiagnostic", "(", "InternalMessages", ".", "DEFAULT_VALIDATION_ERROR_MAX_SELECT", ",", "this", ",", "max", ")", ")", ";", "}", "}", "}" ]
Override WInput's validateComponent to perform further validation on the options selected. @param diags the list into which any validation diagnostics are added.
[ "Override", "WInput", "s", "validateComponent", "to", "perform", "further", "validation", "on", "the", "options", "selected", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList.java#L534-L558
139,369
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WCollapsible.java
WCollapsible.handleRequest
@Override public void handleRequest(final Request request) { String clientState = request.getParameter(getId()); if (clientState != null) { setCollapsed(clientState.equalsIgnoreCase("closed")); } }
java
@Override public void handleRequest(final Request request) { String clientState = request.getParameter(getId()); if (clientState != null) { setCollapsed(clientState.equalsIgnoreCase("closed")); } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "String", "clientState", "=", "request", ".", "getParameter", "(", "getId", "(", ")", ")", ";", "if", "(", "clientState", "!=", "null", ")", "{", "setCollapsed", "(", "clientState", ".", "equalsIgnoreCase", "(", "\"closed\"", ")", ")", ";", "}", "}" ]
Override handleRequest to perform processing necessary for this component. This is used to handle the server-side collapsible mode and to synchronise with the client-side state for the other modes. @param request the request being responded to.
[ "Override", "handleRequest", "to", "perform", "processing", "necessary", "for", "this", "component", ".", "This", "is", "used", "to", "handle", "the", "server", "-", "side", "collapsible", "mode", "and", "to", "synchronise", "with", "the", "client", "-", "side", "state", "for", "the", "other", "modes", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WCollapsible.java#L276-L283
139,370
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WCollapsible.java
WCollapsible.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); if (content != null) { switch (getMode()) { case EAGER: { // Always visible content.setVisible(true); AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId()); break; } case LAZY: content.setVisible(!isCollapsed()); if (isCollapsed()) { AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId()); } break; case DYNAMIC: { content.setVisible(!isCollapsed()); AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId()); break; } case SERVER: { content.setVisible(!isCollapsed()); break; } case CLIENT: { // Will always be visible content.setVisible(true); break; } default: { throw new SystemException("Unknown mode: " + getMode()); } } } }
java
@Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); if (content != null) { switch (getMode()) { case EAGER: { // Always visible content.setVisible(true); AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId()); break; } case LAZY: content.setVisible(!isCollapsed()); if (isCollapsed()) { AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId()); } break; case DYNAMIC: { content.setVisible(!isCollapsed()); AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId()); break; } case SERVER: { content.setVisible(!isCollapsed()); break; } case CLIENT: { // Will always be visible content.setVisible(true); break; } default: { throw new SystemException("Unknown mode: " + getMode()); } } } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "if", "(", "content", "!=", "null", ")", "{", "switch", "(", "getMode", "(", ")", ")", "{", "case", "EAGER", ":", "{", "// Always visible", "content", ".", "setVisible", "(", "true", ")", ";", "AjaxHelper", ".", "registerContainer", "(", "getId", "(", ")", ",", "getId", "(", ")", "+", "\"-content\"", ",", "content", ".", "getId", "(", ")", ")", ";", "break", ";", "}", "case", "LAZY", ":", "content", ".", "setVisible", "(", "!", "isCollapsed", "(", ")", ")", ";", "if", "(", "isCollapsed", "(", ")", ")", "{", "AjaxHelper", ".", "registerContainer", "(", "getId", "(", ")", ",", "getId", "(", ")", "+", "\"-content\"", ",", "content", ".", "getId", "(", ")", ")", ";", "}", "break", ";", "case", "DYNAMIC", ":", "{", "content", ".", "setVisible", "(", "!", "isCollapsed", "(", ")", ")", ";", "AjaxHelper", ".", "registerContainer", "(", "getId", "(", ")", ",", "getId", "(", ")", "+", "\"-content\"", ",", "content", ".", "getId", "(", ")", ")", ";", "break", ";", "}", "case", "SERVER", ":", "{", "content", ".", "setVisible", "(", "!", "isCollapsed", "(", ")", ")", ";", "break", ";", "}", "case", "CLIENT", ":", "{", "// Will always be visible", "content", ".", "setVisible", "(", "true", ")", ";", "break", ";", "}", "default", ":", "{", "throw", "new", "SystemException", "(", "\"Unknown mode: \"", "+", "getMode", "(", ")", ")", ";", "}", "}", "}", "}" ]
Override preparePaintComponent in order to toggle the visibility of the content, or to register the appropriate ajax operation. @param request the request being responded to
[ "Override", "preparePaintComponent", "in", "order", "to", "toggle", "the", "visibility", "of", "the", "content", "or", "to", "register", "the", "appropriate", "ajax", "operation", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WCollapsible.java#L291-L331
139,371
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WProgressBar.java
WProgressBar.setMax
public final void setMax(final int max) { if (max < 0) { throw new IllegalArgumentException(ILLEGAL_MAX); } if (max != getMax()) { getOrCreateComponentModel().max = max; } }
java
public final void setMax(final int max) { if (max < 0) { throw new IllegalArgumentException(ILLEGAL_MAX); } if (max != getMax()) { getOrCreateComponentModel().max = max; } }
[ "public", "final", "void", "setMax", "(", "final", "int", "max", ")", "{", "if", "(", "max", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "ILLEGAL_MAX", ")", ";", "}", "if", "(", "max", "!=", "getMax", "(", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "max", "=", "max", ";", "}", "}" ]
Sets the maximum value of the progress bar. @param max the maximum allowable value.
[ "Sets", "the", "maximum", "value", "of", "the", "progress", "bar", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WProgressBar.java#L147-L154
139,372
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WProgressBar.java
WProgressBar.getValue
public int getValue() { int max = getMax(); Integer data = (Integer) getData(); return data == null ? 0 : Math.max(0, Math.min(max, data)); }
java
public int getValue() { int max = getMax(); Integer data = (Integer) getData(); return data == null ? 0 : Math.max(0, Math.min(max, data)); }
[ "public", "int", "getValue", "(", ")", "{", "int", "max", "=", "getMax", "(", ")", ";", "Integer", "data", "=", "(", "Integer", ")", "getData", "(", ")", ";", "return", "data", "==", "null", "?", "0", ":", "Math", ".", "max", "(", "0", ",", "Math", ".", "min", "(", "max", ",", "data", ")", ")", ";", "}" ]
Retrieves the value of the progress bar. @return the progress bar's value for the context.
[ "Retrieves", "the", "value", "of", "the", "progress", "bar", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WProgressBar.java#L173-L177
139,373
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WProgressBar.java
WProgressBar.setProgressBarType
public final void setProgressBarType(final ProgressBarType type) { ProgressBarType currentType = getProgressBarType(); ProgressBarType typeToSet = type == null ? DEFAULT_TYPE : type; if (typeToSet != currentType) { getOrCreateComponentModel().barType = typeToSet; } }
java
public final void setProgressBarType(final ProgressBarType type) { ProgressBarType currentType = getProgressBarType(); ProgressBarType typeToSet = type == null ? DEFAULT_TYPE : type; if (typeToSet != currentType) { getOrCreateComponentModel().barType = typeToSet; } }
[ "public", "final", "void", "setProgressBarType", "(", "final", "ProgressBarType", "type", ")", "{", "ProgressBarType", "currentType", "=", "getProgressBarType", "(", ")", ";", "ProgressBarType", "typeToSet", "=", "type", "==", "null", "?", "DEFAULT_TYPE", ":", "type", ";", "if", "(", "typeToSet", "!=", "currentType", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "barType", "=", "typeToSet", ";", "}", "}" ]
Sets the progress bar type. @param type the progress bar type.
[ "Sets", "the", "progress", "bar", "type", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WProgressBar.java#L191-L197
139,374
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/subordinate/SubordinateControlOptionsExample.java
SubordinateControlOptionsExample.buildControl
private void buildControl() { buildControlPanel.reset(); buildTargetPanel.reset(); // Setup Trigger setupTrigger(); // Create target SubordinateTarget target = setupTarget(); // Create Actions com.github.bordertech.wcomponents.subordinate.Action trueAction; com.github.bordertech.wcomponents.subordinate.Action falseAction; switch ((ControlActionType) drpActionType.getSelected()) { case ENABLE_DISABLE: trueAction = new Enable(target); falseAction = new Disable(target); break; case SHOW_HIDE: trueAction = new Show(target); falseAction = new Hide(target); break; case MAN_OPT: trueAction = new Mandatory(target); falseAction = new Optional(target); break; case SHOWIN_HIDEIN: trueAction = new ShowInGroup(target, targetGroup); falseAction = new HideInGroup(target, targetGroup); break; case ENABLEIN_DISABLEIN: trueAction = new EnableInGroup(target, targetGroup); falseAction = new DisableInGroup(target, targetGroup); break; default: throw new SystemException("ControlAction type not valid"); } // Create Condition Condition condition = createCondition(); if (cbNot.isSelected()) { condition = new Not(condition); } // Create Rule Rule rule = new Rule(condition, trueAction, falseAction); // Create Subordinate WSubordinateControl control = new WSubordinateControl(); control.addRule(rule); buildControlPanel.add(control); if (targetCollapsible.getDecoratedLabel() != null) { targetCollapsible.getDecoratedLabel().setTail(new WText(control.toString())); } control = new WSubordinateControl(); rule = new Rule(new Equal(cbClientDisableTrigger, true), new Disable((SubordinateTarget) trigger), new Enable((SubordinateTarget) trigger)); control.addRule(rule); buildControlPanel.add(control); }
java
private void buildControl() { buildControlPanel.reset(); buildTargetPanel.reset(); // Setup Trigger setupTrigger(); // Create target SubordinateTarget target = setupTarget(); // Create Actions com.github.bordertech.wcomponents.subordinate.Action trueAction; com.github.bordertech.wcomponents.subordinate.Action falseAction; switch ((ControlActionType) drpActionType.getSelected()) { case ENABLE_DISABLE: trueAction = new Enable(target); falseAction = new Disable(target); break; case SHOW_HIDE: trueAction = new Show(target); falseAction = new Hide(target); break; case MAN_OPT: trueAction = new Mandatory(target); falseAction = new Optional(target); break; case SHOWIN_HIDEIN: trueAction = new ShowInGroup(target, targetGroup); falseAction = new HideInGroup(target, targetGroup); break; case ENABLEIN_DISABLEIN: trueAction = new EnableInGroup(target, targetGroup); falseAction = new DisableInGroup(target, targetGroup); break; default: throw new SystemException("ControlAction type not valid"); } // Create Condition Condition condition = createCondition(); if (cbNot.isSelected()) { condition = new Not(condition); } // Create Rule Rule rule = new Rule(condition, trueAction, falseAction); // Create Subordinate WSubordinateControl control = new WSubordinateControl(); control.addRule(rule); buildControlPanel.add(control); if (targetCollapsible.getDecoratedLabel() != null) { targetCollapsible.getDecoratedLabel().setTail(new WText(control.toString())); } control = new WSubordinateControl(); rule = new Rule(new Equal(cbClientDisableTrigger, true), new Disable((SubordinateTarget) trigger), new Enable((SubordinateTarget) trigger)); control.addRule(rule); buildControlPanel.add(control); }
[ "private", "void", "buildControl", "(", ")", "{", "buildControlPanel", ".", "reset", "(", ")", ";", "buildTargetPanel", ".", "reset", "(", ")", ";", "// Setup Trigger", "setupTrigger", "(", ")", ";", "// Create target", "SubordinateTarget", "target", "=", "setupTarget", "(", ")", ";", "// Create Actions", "com", ".", "github", ".", "bordertech", ".", "wcomponents", ".", "subordinate", ".", "Action", "trueAction", ";", "com", ".", "github", ".", "bordertech", ".", "wcomponents", ".", "subordinate", ".", "Action", "falseAction", ";", "switch", "(", "(", "ControlActionType", ")", "drpActionType", ".", "getSelected", "(", ")", ")", "{", "case", "ENABLE_DISABLE", ":", "trueAction", "=", "new", "Enable", "(", "target", ")", ";", "falseAction", "=", "new", "Disable", "(", "target", ")", ";", "break", ";", "case", "SHOW_HIDE", ":", "trueAction", "=", "new", "Show", "(", "target", ")", ";", "falseAction", "=", "new", "Hide", "(", "target", ")", ";", "break", ";", "case", "MAN_OPT", ":", "trueAction", "=", "new", "Mandatory", "(", "target", ")", ";", "falseAction", "=", "new", "Optional", "(", "target", ")", ";", "break", ";", "case", "SHOWIN_HIDEIN", ":", "trueAction", "=", "new", "ShowInGroup", "(", "target", ",", "targetGroup", ")", ";", "falseAction", "=", "new", "HideInGroup", "(", "target", ",", "targetGroup", ")", ";", "break", ";", "case", "ENABLEIN_DISABLEIN", ":", "trueAction", "=", "new", "EnableInGroup", "(", "target", ",", "targetGroup", ")", ";", "falseAction", "=", "new", "DisableInGroup", "(", "target", ",", "targetGroup", ")", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"ControlAction type not valid\"", ")", ";", "}", "// Create Condition", "Condition", "condition", "=", "createCondition", "(", ")", ";", "if", "(", "cbNot", ".", "isSelected", "(", ")", ")", "{", "condition", "=", "new", "Not", "(", "condition", ")", ";", "}", "// Create Rule", "Rule", "rule", "=", "new", "Rule", "(", "condition", ",", "trueAction", ",", "falseAction", ")", ";", "// Create Subordinate", "WSubordinateControl", "control", "=", "new", "WSubordinateControl", "(", ")", ";", "control", ".", "addRule", "(", "rule", ")", ";", "buildControlPanel", ".", "add", "(", "control", ")", ";", "if", "(", "targetCollapsible", ".", "getDecoratedLabel", "(", ")", "!=", "null", ")", "{", "targetCollapsible", ".", "getDecoratedLabel", "(", ")", ".", "setTail", "(", "new", "WText", "(", "control", ".", "toString", "(", ")", ")", ")", ";", "}", "control", "=", "new", "WSubordinateControl", "(", ")", ";", "rule", "=", "new", "Rule", "(", "new", "Equal", "(", "cbClientDisableTrigger", ",", "true", ")", ",", "new", "Disable", "(", "(", "SubordinateTarget", ")", "trigger", ")", ",", "new", "Enable", "(", "(", "SubordinateTarget", ")", "trigger", ")", ")", ";", "control", ".", "addRule", "(", "rule", ")", ";", "buildControlPanel", ".", "add", "(", "control", ")", ";", "}" ]
Build the subordinate control.
[ "Build", "the", "subordinate", "control", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/subordinate/SubordinateControlOptionsExample.java#L603-L671
139,375
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/subordinate/SubordinateControlOptionsExample.java
SubordinateControlOptionsExample.setupTrigger
private void setupTrigger() { String label = drpTriggerType.getSelected() + " Trigger"; WFieldLayout layout = new WFieldLayout(); layout.setLabelWidth(LABEL_WIDTH); buildControlPanel.add(layout); switch ((TriggerType) drpTriggerType.getSelected()) { case RadioButtonGroup: trigger = new RadioButtonGroup(); WFieldSet rbSet = new WFieldSet("Select an option"); RadioButtonGroup group = (RadioButtonGroup) trigger; WRadioButton rb1 = group.addRadioButton("A"); WRadioButton rb2 = group.addRadioButton("B"); WRadioButton rb3 = group.addRadioButton("C"); rbSet.add(group); rbSet.add(rb1); rbSet.add(new WLabel("A", rb1)); rbSet.add(new WText("\u00a0")); rbSet.add(rb2); rbSet.add(new WLabel("B", rb2)); rbSet.add(new WText("\u00a0")); rbSet.add(rb3); rbSet.add(new WLabel("C", rb3)); layout.addField(label, rbSet); return; case CheckBox: trigger = new WCheckBox(); break; case CheckBoxSelect: trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME); break; case DateField: trigger = new WDateField(); break; case Dropdown: trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME)); break; case EmailField: trigger = new WEmailField(); break; case MultiSelect: trigger = new WMultiSelect(LOOKUP_TABLE_NAME); break; case MultiSelectPair: trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME); break; case NumberField: trigger = new WNumberField(); break; case PartialDateField: trigger = new WPartialDateField(); break; case PasswordField: trigger = new WPasswordField(); break; case PhoneNumberField: trigger = new WPhoneNumberField(); break; case RadioButtonSelect: trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME); break; case SingleSelect: trigger = new WSingleSelect(LOOKUP_TABLE_NAME); break; case TextArea: trigger = new WTextArea(); ((WTextArea) trigger).setMaxLength(1000); break; case TextField: trigger = new WTextField(); break; default: throw new SystemException("Trigger type not valid"); } layout.addField(label, trigger); }
java
private void setupTrigger() { String label = drpTriggerType.getSelected() + " Trigger"; WFieldLayout layout = new WFieldLayout(); layout.setLabelWidth(LABEL_WIDTH); buildControlPanel.add(layout); switch ((TriggerType) drpTriggerType.getSelected()) { case RadioButtonGroup: trigger = new RadioButtonGroup(); WFieldSet rbSet = new WFieldSet("Select an option"); RadioButtonGroup group = (RadioButtonGroup) trigger; WRadioButton rb1 = group.addRadioButton("A"); WRadioButton rb2 = group.addRadioButton("B"); WRadioButton rb3 = group.addRadioButton("C"); rbSet.add(group); rbSet.add(rb1); rbSet.add(new WLabel("A", rb1)); rbSet.add(new WText("\u00a0")); rbSet.add(rb2); rbSet.add(new WLabel("B", rb2)); rbSet.add(new WText("\u00a0")); rbSet.add(rb3); rbSet.add(new WLabel("C", rb3)); layout.addField(label, rbSet); return; case CheckBox: trigger = new WCheckBox(); break; case CheckBoxSelect: trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME); break; case DateField: trigger = new WDateField(); break; case Dropdown: trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME)); break; case EmailField: trigger = new WEmailField(); break; case MultiSelect: trigger = new WMultiSelect(LOOKUP_TABLE_NAME); break; case MultiSelectPair: trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME); break; case NumberField: trigger = new WNumberField(); break; case PartialDateField: trigger = new WPartialDateField(); break; case PasswordField: trigger = new WPasswordField(); break; case PhoneNumberField: trigger = new WPhoneNumberField(); break; case RadioButtonSelect: trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME); break; case SingleSelect: trigger = new WSingleSelect(LOOKUP_TABLE_NAME); break; case TextArea: trigger = new WTextArea(); ((WTextArea) trigger).setMaxLength(1000); break; case TextField: trigger = new WTextField(); break; default: throw new SystemException("Trigger type not valid"); } layout.addField(label, trigger); }
[ "private", "void", "setupTrigger", "(", ")", "{", "String", "label", "=", "drpTriggerType", ".", "getSelected", "(", ")", "+", "\" Trigger\"", ";", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "layout", ".", "setLabelWidth", "(", "LABEL_WIDTH", ")", ";", "buildControlPanel", ".", "add", "(", "layout", ")", ";", "switch", "(", "(", "TriggerType", ")", "drpTriggerType", ".", "getSelected", "(", ")", ")", "{", "case", "RadioButtonGroup", ":", "trigger", "=", "new", "RadioButtonGroup", "(", ")", ";", "WFieldSet", "rbSet", "=", "new", "WFieldSet", "(", "\"Select an option\"", ")", ";", "RadioButtonGroup", "group", "=", "(", "RadioButtonGroup", ")", "trigger", ";", "WRadioButton", "rb1", "=", "group", ".", "addRadioButton", "(", "\"A\"", ")", ";", "WRadioButton", "rb2", "=", "group", ".", "addRadioButton", "(", "\"B\"", ")", ";", "WRadioButton", "rb3", "=", "group", ".", "addRadioButton", "(", "\"C\"", ")", ";", "rbSet", ".", "add", "(", "group", ")", ";", "rbSet", ".", "add", "(", "rb1", ")", ";", "rbSet", ".", "add", "(", "new", "WLabel", "(", "\"A\"", ",", "rb1", ")", ")", ";", "rbSet", ".", "add", "(", "new", "WText", "(", "\"\\u00a0\"", ")", ")", ";", "rbSet", ".", "add", "(", "rb2", ")", ";", "rbSet", ".", "add", "(", "new", "WLabel", "(", "\"B\"", ",", "rb2", ")", ")", ";", "rbSet", ".", "add", "(", "new", "WText", "(", "\"\\u00a0\"", ")", ")", ";", "rbSet", ".", "add", "(", "rb3", ")", ";", "rbSet", ".", "add", "(", "new", "WLabel", "(", "\"C\"", ",", "rb3", ")", ")", ";", "layout", ".", "addField", "(", "label", ",", "rbSet", ")", ";", "return", ";", "case", "CheckBox", ":", "trigger", "=", "new", "WCheckBox", "(", ")", ";", "break", ";", "case", "CheckBoxSelect", ":", "trigger", "=", "new", "WCheckBoxSelect", "(", "LOOKUP_TABLE_NAME", ")", ";", "break", ";", "case", "DateField", ":", "trigger", "=", "new", "WDateField", "(", ")", ";", "break", ";", "case", "Dropdown", ":", "trigger", "=", "new", "WDropdown", "(", "new", "TableWithNullOption", "(", "LOOKUP_TABLE_NAME", ")", ")", ";", "break", ";", "case", "EmailField", ":", "trigger", "=", "new", "WEmailField", "(", ")", ";", "break", ";", "case", "MultiSelect", ":", "trigger", "=", "new", "WMultiSelect", "(", "LOOKUP_TABLE_NAME", ")", ";", "break", ";", "case", "MultiSelectPair", ":", "trigger", "=", "new", "WMultiSelectPair", "(", "LOOKUP_TABLE_NAME", ")", ";", "break", ";", "case", "NumberField", ":", "trigger", "=", "new", "WNumberField", "(", ")", ";", "break", ";", "case", "PartialDateField", ":", "trigger", "=", "new", "WPartialDateField", "(", ")", ";", "break", ";", "case", "PasswordField", ":", "trigger", "=", "new", "WPasswordField", "(", ")", ";", "break", ";", "case", "PhoneNumberField", ":", "trigger", "=", "new", "WPhoneNumberField", "(", ")", ";", "break", ";", "case", "RadioButtonSelect", ":", "trigger", "=", "new", "WRadioButtonSelect", "(", "LOOKUP_TABLE_NAME", ")", ";", "break", ";", "case", "SingleSelect", ":", "trigger", "=", "new", "WSingleSelect", "(", "LOOKUP_TABLE_NAME", ")", ";", "break", ";", "case", "TextArea", ":", "trigger", "=", "new", "WTextArea", "(", ")", ";", "(", "(", "WTextArea", ")", "trigger", ")", ".", "setMaxLength", "(", "1000", ")", ";", "break", ";", "case", "TextField", ":", "trigger", "=", "new", "WTextField", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Trigger type not valid\"", ")", ";", "}", "layout", ".", "addField", "(", "label", ",", "trigger", ")", ";", "}" ]
Setup the trigger for the subordinate control.
[ "Setup", "the", "trigger", "for", "the", "subordinate", "control", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/subordinate/SubordinateControlOptionsExample.java#L676-L771
139,376
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/subordinate/SubordinateControlOptionsExample.java
SubordinateControlOptionsExample.setPresets
private void setPresets() { TriggerType selectedTrigger = (TriggerType) drpTriggerType.getSelected(); comboField.setVisible( selectedTrigger != TriggerType.DateField && selectedTrigger != TriggerType.NumberField); dateField.setVisible(selectedTrigger == TriggerType.DateField); numberField.setVisible(selectedTrigger == TriggerType.NumberField); // If a group action selected, then target can only be the field (as it is defined in a group) switch ((ControlActionType) drpActionType.getSelected()) { case ENABLEIN_DISABLEIN: case SHOWIN_HIDEIN: drpTargetType.setSelected(TargetType.WFIELD); drpTargetType.setDisabled(true); break; default: drpTargetType.setDisabled(false); } }
java
private void setPresets() { TriggerType selectedTrigger = (TriggerType) drpTriggerType.getSelected(); comboField.setVisible( selectedTrigger != TriggerType.DateField && selectedTrigger != TriggerType.NumberField); dateField.setVisible(selectedTrigger == TriggerType.DateField); numberField.setVisible(selectedTrigger == TriggerType.NumberField); // If a group action selected, then target can only be the field (as it is defined in a group) switch ((ControlActionType) drpActionType.getSelected()) { case ENABLEIN_DISABLEIN: case SHOWIN_HIDEIN: drpTargetType.setSelected(TargetType.WFIELD); drpTargetType.setDisabled(true); break; default: drpTargetType.setDisabled(false); } }
[ "private", "void", "setPresets", "(", ")", "{", "TriggerType", "selectedTrigger", "=", "(", "TriggerType", ")", "drpTriggerType", ".", "getSelected", "(", ")", ";", "comboField", ".", "setVisible", "(", "selectedTrigger", "!=", "TriggerType", ".", "DateField", "&&", "selectedTrigger", "!=", "TriggerType", ".", "NumberField", ")", ";", "dateField", ".", "setVisible", "(", "selectedTrigger", "==", "TriggerType", ".", "DateField", ")", ";", "numberField", ".", "setVisible", "(", "selectedTrigger", "==", "TriggerType", ".", "NumberField", ")", ";", "// If a group action selected, then target can only be the field (as it is defined in a group)", "switch", "(", "(", "ControlActionType", ")", "drpActionType", ".", "getSelected", "(", ")", ")", "{", "case", "ENABLEIN_DISABLEIN", ":", "case", "SHOWIN_HIDEIN", ":", "drpTargetType", ".", "setSelected", "(", "TargetType", ".", "WFIELD", ")", ";", "drpTargetType", ".", "setDisabled", "(", "true", ")", ";", "break", ";", "default", ":", "drpTargetType", ".", "setDisabled", "(", "false", ")", ";", "}", "}" ]
Setup the default values for the configuration options.
[ "Setup", "the", "default", "values", "for", "the", "configuration", "options", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/subordinate/SubordinateControlOptionsExample.java#L890-L908
139,377
ebean-orm/ebean-querybean
src/main/java/io/ebean/typequery/PJson.java
PJson.jsonEqualTo
public R jsonEqualTo(String path, Object value) { expr().jsonEqualTo(_name, path, value); return _root; }
java
public R jsonEqualTo(String path, Object value) { expr().jsonEqualTo(_name, path, value); return _root; }
[ "public", "R", "jsonEqualTo", "(", "String", "path", ",", "Object", "value", ")", "{", "expr", "(", ")", ".", "jsonEqualTo", "(", "_name", ",", "path", ",", "value", ")", ";", "return", "_root", ";", "}" ]
Value at the given JSON path is equal to the given value. <pre>{@code new QSimpleDoc() .content.jsonEqualTo("title", "Rob JSON in the DB") .findList(); }</pre> <pre>{@code new QSimpleDoc() .content.jsonEqualTo("path.other", 34) .findList(); }</pre> @param path the dot notation path in the JSON document @param value the equal to bind value
[ "Value", "at", "the", "given", "JSON", "path", "is", "equal", "to", "the", "given", "value", "." ]
821650cb817c9c0fdcc97f93408dc79170b12423
https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/PJson.java#L98-L101
139,378
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WProgressBarRenderer.java
WProgressBarRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WProgressBar progressBar = (WProgressBar) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("html:progress"); xml.appendAttribute("id", component.getId()); xml.appendAttribute("class", getHtmlClass(progressBar)); xml.appendOptionalAttribute("hidden", progressBar.isHidden(), "hidden"); xml.appendOptionalAttribute("title", progressBar.getToolTip()); xml.appendOptionalAttribute("aria-label", progressBar.getAccessibleText()); xml.appendAttribute("value", progressBar.getValue()); xml.appendOptionalAttribute("max", progressBar.getMax() > 0, progressBar.getMax()); xml.appendClose(); xml.appendEndTag("html:progress"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WProgressBar progressBar = (WProgressBar) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("html:progress"); xml.appendAttribute("id", component.getId()); xml.appendAttribute("class", getHtmlClass(progressBar)); xml.appendOptionalAttribute("hidden", progressBar.isHidden(), "hidden"); xml.appendOptionalAttribute("title", progressBar.getToolTip()); xml.appendOptionalAttribute("aria-label", progressBar.getAccessibleText()); xml.appendAttribute("value", progressBar.getValue()); xml.appendOptionalAttribute("max", progressBar.getMax() > 0, progressBar.getMax()); xml.appendClose(); xml.appendEndTag("html:progress"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WProgressBar", "progressBar", "=", "(", "WProgressBar", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"html:progress\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"class\"", ",", "getHtmlClass", "(", "progressBar", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "progressBar", ".", "isHidden", "(", ")", ",", "\"hidden\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"title\"", ",", "progressBar", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"aria-label\"", ",", "progressBar", ".", "getAccessibleText", "(", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"value\"", ",", "progressBar", ".", "getValue", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"max\"", ",", "progressBar", ".", "getMax", "(", ")", ">", "0", ",", "progressBar", ".", "getMax", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "xml", ".", "appendEndTag", "(", "\"html:progress\"", ")", ";", "}" ]
Paints the given WProgressBar. @param component the WProgressBar to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WProgressBar", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WProgressBarRenderer.java#L23-L38
139,379
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/ButtonOptionsExample.java
ButtonOptionsExample.applySettings
private void applySettings() { buttonContainer.reset(); WButton exampleButton = new WButton(tfButtonLabel.getText()); exampleButton.setRenderAsLink(cbRenderAsLink.isSelected()); exampleButton.setText(tfButtonLabel.getText()); if (cbSetImage.isSelected()) { exampleButton.setImage("/image/pencil.png"); exampleButton.setImagePosition((ImagePosition) ddImagePosition.getSelected()); } exampleButton.setDisabled(cbDisabled.isSelected()); if (tfAccesskey.getText() != null && tfAccesskey.getText().length() > 0) { exampleButton.setAccessKey(tfAccesskey.getText().toCharArray()[0]); } buttonContainer.add(exampleButton); }
java
private void applySettings() { buttonContainer.reset(); WButton exampleButton = new WButton(tfButtonLabel.getText()); exampleButton.setRenderAsLink(cbRenderAsLink.isSelected()); exampleButton.setText(tfButtonLabel.getText()); if (cbSetImage.isSelected()) { exampleButton.setImage("/image/pencil.png"); exampleButton.setImagePosition((ImagePosition) ddImagePosition.getSelected()); } exampleButton.setDisabled(cbDisabled.isSelected()); if (tfAccesskey.getText() != null && tfAccesskey.getText().length() > 0) { exampleButton.setAccessKey(tfAccesskey.getText().toCharArray()[0]); } buttonContainer.add(exampleButton); }
[ "private", "void", "applySettings", "(", ")", "{", "buttonContainer", ".", "reset", "(", ")", ";", "WButton", "exampleButton", "=", "new", "WButton", "(", "tfButtonLabel", ".", "getText", "(", ")", ")", ";", "exampleButton", ".", "setRenderAsLink", "(", "cbRenderAsLink", ".", "isSelected", "(", ")", ")", ";", "exampleButton", ".", "setText", "(", "tfButtonLabel", ".", "getText", "(", ")", ")", ";", "if", "(", "cbSetImage", ".", "isSelected", "(", ")", ")", "{", "exampleButton", ".", "setImage", "(", "\"/image/pencil.png\"", ")", ";", "exampleButton", ".", "setImagePosition", "(", "(", "ImagePosition", ")", "ddImagePosition", ".", "getSelected", "(", ")", ")", ";", "}", "exampleButton", ".", "setDisabled", "(", "cbDisabled", ".", "isSelected", "(", ")", ")", ";", "if", "(", "tfAccesskey", ".", "getText", "(", ")", "!=", "null", "&&", "tfAccesskey", ".", "getText", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "exampleButton", ".", "setAccessKey", "(", "tfAccesskey", ".", "getText", "(", ")", ".", "toCharArray", "(", ")", "[", "0", "]", ")", ";", "}", "buttonContainer", ".", "add", "(", "exampleButton", ")", ";", "}" ]
this is were the majority of the work is done for building the button. Note that it is in a container that is reset, effectively creating a new button. this is only done to enable to dynamically change the button to a link and back.
[ "this", "is", "were", "the", "majority", "of", "the", "work", "is", "done", "for", "building", "the", "button", ".", "Note", "that", "it", "is", "in", "a", "container", "that", "is", "reset", "effectively", "creating", "a", "new", "button", ".", "this", "is", "only", "done", "to", "enable", "to", "dynamically", "change", "the", "button", "to", "a", "link", "and", "back", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/ButtonOptionsExample.java#L132-L152
139,380
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java
WColumnLayout.setLeftColumn
public void setLeftColumn(final String heading, final WComponent content) { setLeftColumn(new WHeading(WHeading.MINOR, heading), content); }
java
public void setLeftColumn(final String heading, final WComponent content) { setLeftColumn(new WHeading(WHeading.MINOR, heading), content); }
[ "public", "void", "setLeftColumn", "(", "final", "String", "heading", ",", "final", "WComponent", "content", ")", "{", "setLeftColumn", "(", "new", "WHeading", "(", "WHeading", ".", "MINOR", ",", "heading", ")", ",", "content", ")", ";", "}" ]
Sets the left column content. @param heading the column heading text. @param content the content.
[ "Sets", "the", "left", "column", "content", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java#L82-L84
139,381
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java
WColumnLayout.setRightColumn
public void setRightColumn(final String heading, final WComponent content) { setRightColumn(new WHeading(WHeading.MINOR, heading), content); }
java
public void setRightColumn(final String heading, final WComponent content) { setRightColumn(new WHeading(WHeading.MINOR, heading), content); }
[ "public", "void", "setRightColumn", "(", "final", "String", "heading", ",", "final", "WComponent", "content", ")", "{", "setRightColumn", "(", "new", "WHeading", "(", "WHeading", ".", "MINOR", ",", "heading", ")", ",", "content", ")", ";", "}" ]
Sets the right column content. @param heading the column heading text. @param content the content.
[ "Sets", "the", "right", "column", "content", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java#L111-L113
139,382
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java
WColumnLayout.setContent
private void setContent(final WColumn column, final WHeading heading, final WComponent content) { column.removeAll(); if (heading != null) { column.add(heading); } if (content != null) { column.add(content); } // Update column widths & visibility if (hasLeftContent() && hasRightContent()) { // Set columns 50% leftColumn.setWidth(50); rightColumn.setWidth(50); // Set both visible leftColumn.setVisible(true); rightColumn.setVisible(true); } else { // Set columns 100% (only one visible) leftColumn.setWidth(100); rightColumn.setWidth(100); // Set visibility leftColumn.setVisible(hasLeftContent()); rightColumn.setVisible(hasRightContent()); } }
java
private void setContent(final WColumn column, final WHeading heading, final WComponent content) { column.removeAll(); if (heading != null) { column.add(heading); } if (content != null) { column.add(content); } // Update column widths & visibility if (hasLeftContent() && hasRightContent()) { // Set columns 50% leftColumn.setWidth(50); rightColumn.setWidth(50); // Set both visible leftColumn.setVisible(true); rightColumn.setVisible(true); } else { // Set columns 100% (only one visible) leftColumn.setWidth(100); rightColumn.setWidth(100); // Set visibility leftColumn.setVisible(hasLeftContent()); rightColumn.setVisible(hasRightContent()); } }
[ "private", "void", "setContent", "(", "final", "WColumn", "column", ",", "final", "WHeading", "heading", ",", "final", "WComponent", "content", ")", "{", "column", ".", "removeAll", "(", ")", ";", "if", "(", "heading", "!=", "null", ")", "{", "column", ".", "add", "(", "heading", ")", ";", "}", "if", "(", "content", "!=", "null", ")", "{", "column", ".", "add", "(", "content", ")", ";", "}", "// Update column widths & visibility", "if", "(", "hasLeftContent", "(", ")", "&&", "hasRightContent", "(", ")", ")", "{", "// Set columns 50%", "leftColumn", ".", "setWidth", "(", "50", ")", ";", "rightColumn", ".", "setWidth", "(", "50", ")", ";", "// Set both visible", "leftColumn", ".", "setVisible", "(", "true", ")", ";", "rightColumn", ".", "setVisible", "(", "true", ")", ";", "}", "else", "{", "// Set columns 100% (only one visible)", "leftColumn", ".", "setWidth", "(", "100", ")", ";", "rightColumn", ".", "setWidth", "(", "100", ")", ";", "// Set visibility", "leftColumn", ".", "setVisible", "(", "hasLeftContent", "(", ")", ")", ";", "rightColumn", ".", "setVisible", "(", "hasRightContent", "(", ")", ")", ";", "}", "}" ]
Sets the content of the given column and updates the column widths and visibilities. @param column the column being updated. @param heading the column heading. @param content the content.
[ "Sets", "the", "content", "of", "the", "given", "column", "and", "updates", "the", "column", "widths", "and", "visibilities", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java#L132-L159
139,383
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTabRenderer.java
WTabRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTab tab = (WTab) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:tab"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("open", tab.isOpen(), "true"); xml.appendOptionalAttribute("disabled", tab.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", tab.isHidden(), "true"); xml.appendOptionalAttribute("toolTip", tab.getToolTip()); switch (tab.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 tab mode: " + tab.getMode()); } if (tab.getAccessKey() != 0) { xml.appendAttribute("accessKey", String.valueOf(Character. toUpperCase(tab.getAccessKey()))); } xml.appendClose(); // Paint label tab.getTabLabel().paint(renderContext); // Paint content WComponent content = tab.getContent(); xml.appendTagOpen("ui:tabcontent"); xml.appendAttribute("id", tab.getId() + "-content"); xml.appendClose(); // Render content if not EAGER Mode or is EAGER and is the current AJAX trigger if (content != null && (TabMode.EAGER != tab.getMode() || AjaxHelper.isCurrentAjaxTrigger( tab))) { // Visibility of content set in prepare paint content.paint(renderContext); } xml.appendEndTag("ui:tabcontent"); xml.appendEndTag("ui:tab"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTab tab = (WTab) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:tab"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("open", tab.isOpen(), "true"); xml.appendOptionalAttribute("disabled", tab.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", tab.isHidden(), "true"); xml.appendOptionalAttribute("toolTip", tab.getToolTip()); switch (tab.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 tab mode: " + tab.getMode()); } if (tab.getAccessKey() != 0) { xml.appendAttribute("accessKey", String.valueOf(Character. toUpperCase(tab.getAccessKey()))); } xml.appendClose(); // Paint label tab.getTabLabel().paint(renderContext); // Paint content WComponent content = tab.getContent(); xml.appendTagOpen("ui:tabcontent"); xml.appendAttribute("id", tab.getId() + "-content"); xml.appendClose(); // Render content if not EAGER Mode or is EAGER and is the current AJAX trigger if (content != null && (TabMode.EAGER != tab.getMode() || AjaxHelper.isCurrentAjaxTrigger( tab))) { // Visibility of content set in prepare paint content.paint(renderContext); } xml.appendEndTag("ui:tabcontent"); xml.appendEndTag("ui:tab"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTab", "tab", "=", "(", "WTab", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:tab\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"open\"", ",", "tab", ".", "isOpen", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "tab", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "tab", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "tab", ".", "getToolTip", "(", ")", ")", ";", "switch", "(", "tab", ".", "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 tab mode: \"", "+", "tab", ".", "getMode", "(", ")", ")", ";", "}", "if", "(", "tab", ".", "getAccessKey", "(", ")", "!=", "0", ")", "{", "xml", ".", "appendAttribute", "(", "\"accessKey\"", ",", "String", ".", "valueOf", "(", "Character", ".", "toUpperCase", "(", "tab", ".", "getAccessKey", "(", ")", ")", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "// Paint label", "tab", ".", "getTabLabel", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "// Paint content", "WComponent", "content", "=", "tab", ".", "getContent", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:tabcontent\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "tab", ".", "getId", "(", ")", "+", "\"-content\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Render content if not EAGER Mode or is EAGER and is the current AJAX trigger", "if", "(", "content", "!=", "null", "&&", "(", "TabMode", ".", "EAGER", "!=", "tab", ".", "getMode", "(", ")", "||", "AjaxHelper", ".", "isCurrentAjaxTrigger", "(", "tab", ")", ")", ")", "{", "// Visibility of content set in prepare paint", "content", ".", "paint", "(", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:tabcontent\"", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:tab\"", ")", ";", "}" ]
Paints the given WTab. @param component the WTab to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTab", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTabRenderer.java#L26-L87
139,384
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFilterText.java
WFilterText.getText
@Override public String getText() { String text = super.getText(); FilterTextModel model = getComponentModel(); if (text != null && model.search != null && model.replace != null) { text = text.replaceAll(model.search, model.replace); } return text; }
java
@Override public String getText() { String text = super.getText(); FilterTextModel model = getComponentModel(); if (text != null && model.search != null && model.replace != null) { text = text.replaceAll(model.search, model.replace); } return text; }
[ "@", "Override", "public", "String", "getText", "(", ")", "{", "String", "text", "=", "super", ".", "getText", "(", ")", ";", "FilterTextModel", "model", "=", "getComponentModel", "(", ")", ";", "if", "(", "text", "!=", "null", "&&", "model", ".", "search", "!=", "null", "&&", "model", ".", "replace", "!=", "null", ")", "{", "text", "=", "text", ".", "replaceAll", "(", "model", ".", "search", ",", "model", ".", "replace", ")", ";", "}", "return", "text", ";", "}" ]
Override in order to filter the encoded text. @return the filtered encoded text
[ "Override", "in", "order", "to", "filter", "the", "encoded", "text", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFilterText.java#L52-L62
139,385
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java
WTreeRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTree tree = (WTree) component; XmlStringBuilder xml = renderContext.getWriter(); // Check if rendering an open item request String openId = tree.getOpenRequestItemId(); if (openId != null) { handleOpenItemRequest(tree, xml, openId); return; } // Check the tree has tree items (WCAG requirement) TreeItemModel model = tree.getTreeModel(); if (model == null || model.getRowCount() <= 0) { LOG.warn("Tree not rendered as it has no items."); return; } xml.appendTagOpen("ui:tree"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("htree", WTree.Type.HORIZONTAL == tree.getType(), "true"); xml.appendOptionalAttribute("multiple", WTree.SelectMode.MULTIPLE == tree.getSelectMode(), "true"); xml.appendOptionalAttribute("disabled", tree.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", tree.isHidden(), "true"); xml.appendOptionalAttribute("required", tree.isMandatory(), "true"); switch (tree.getExpandMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case DYNAMIC: xml.appendAttribute("mode", "dynamic"); break; case LAZY: xml.appendAttribute("mode", "lazy"); break; default: throw new IllegalStateException("Invalid expand mode: " + tree.getType()); } xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(tree, renderContext); if (tree.getCustomTree() == null) { handlePaintItems(tree, xml); } else { handlePaintCustom(tree, xml); } DiagnosticRenderUtil.renderDiagnostics(tree, renderContext); xml.appendEndTag("ui:tree"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTree tree = (WTree) component; XmlStringBuilder xml = renderContext.getWriter(); // Check if rendering an open item request String openId = tree.getOpenRequestItemId(); if (openId != null) { handleOpenItemRequest(tree, xml, openId); return; } // Check the tree has tree items (WCAG requirement) TreeItemModel model = tree.getTreeModel(); if (model == null || model.getRowCount() <= 0) { LOG.warn("Tree not rendered as it has no items."); return; } xml.appendTagOpen("ui:tree"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("htree", WTree.Type.HORIZONTAL == tree.getType(), "true"); xml.appendOptionalAttribute("multiple", WTree.SelectMode.MULTIPLE == tree.getSelectMode(), "true"); xml.appendOptionalAttribute("disabled", tree.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", tree.isHidden(), "true"); xml.appendOptionalAttribute("required", tree.isMandatory(), "true"); switch (tree.getExpandMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case DYNAMIC: xml.appendAttribute("mode", "dynamic"); break; case LAZY: xml.appendAttribute("mode", "lazy"); break; default: throw new IllegalStateException("Invalid expand mode: " + tree.getType()); } xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(tree, renderContext); if (tree.getCustomTree() == null) { handlePaintItems(tree, xml); } else { handlePaintCustom(tree, xml); } DiagnosticRenderUtil.renderDiagnostics(tree, renderContext); xml.appendEndTag("ui:tree"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTree", "tree", "=", "(", "WTree", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "// Check if rendering an open item request", "String", "openId", "=", "tree", ".", "getOpenRequestItemId", "(", ")", ";", "if", "(", "openId", "!=", "null", ")", "{", "handleOpenItemRequest", "(", "tree", ",", "xml", ",", "openId", ")", ";", "return", ";", "}", "// Check the tree has tree items (WCAG requirement)", "TreeItemModel", "model", "=", "tree", ".", "getTreeModel", "(", ")", ";", "if", "(", "model", "==", "null", "||", "model", ".", "getRowCount", "(", ")", "<=", "0", ")", "{", "LOG", ".", "warn", "(", "\"Tree not rendered as it has no items.\"", ")", ";", "return", ";", "}", "xml", ".", "appendTagOpen", "(", "\"ui:tree\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"htree\"", ",", "WTree", ".", "Type", ".", "HORIZONTAL", "==", "tree", ".", "getType", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"multiple\"", ",", "WTree", ".", "SelectMode", ".", "MULTIPLE", "==", "tree", ".", "getSelectMode", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "tree", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "tree", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"required\"", ",", "tree", ".", "isMandatory", "(", ")", ",", "\"true\"", ")", ";", "switch", "(", "tree", ".", "getExpandMode", "(", ")", ")", "{", "case", "CLIENT", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"client\"", ")", ";", "break", ";", "case", "DYNAMIC", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"dynamic\"", ")", ";", "break", ";", "case", "LAZY", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"lazy\"", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "\"Invalid expand mode: \"", "+", "tree", ".", "getType", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "// Render margin", "MarginRendererUtil", ".", "renderMargin", "(", "tree", ",", "renderContext", ")", ";", "if", "(", "tree", ".", "getCustomTree", "(", ")", "==", "null", ")", "{", "handlePaintItems", "(", "tree", ",", "xml", ")", ";", "}", "else", "{", "handlePaintCustom", "(", "tree", ",", "xml", ")", ";", "}", "DiagnosticRenderUtil", ".", "renderDiagnostics", "(", "tree", ",", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:tree\"", ")", ";", "}" ]
Paints the given WTree. @param component the WTree to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTree", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L36-L95
139,386
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java
WTreeRenderer.handleOpenItemRequest
protected void handleOpenItemRequest(final WTree tree, final XmlStringBuilder xml, final String itemId) { TreeItemModel model = tree.getTreeModel(); Set<String> selectedRows = new HashSet(tree.getSelectedRows()); WTree.ExpandMode mode = tree.getExpandMode(); // Only want to render the children of the "open item" so only include the open item id in the expanded rows Set<String> expandedRows = new HashSet(); expandedRows.add(itemId); if (tree.getCustomTree() == null) { List<Integer> rowIndex = tree.getExpandedItemIdIndexMap().get(itemId); paintItem(tree, mode, model, rowIndex, xml, selectedRows, expandedRows); } else { TreeItemIdNode node = tree.getCustomIdNodeMap().get(itemId); paintCustomItem(tree, mode, model, node, xml, selectedRows, expandedRows); } }
java
protected void handleOpenItemRequest(final WTree tree, final XmlStringBuilder xml, final String itemId) { TreeItemModel model = tree.getTreeModel(); Set<String> selectedRows = new HashSet(tree.getSelectedRows()); WTree.ExpandMode mode = tree.getExpandMode(); // Only want to render the children of the "open item" so only include the open item id in the expanded rows Set<String> expandedRows = new HashSet(); expandedRows.add(itemId); if (tree.getCustomTree() == null) { List<Integer> rowIndex = tree.getExpandedItemIdIndexMap().get(itemId); paintItem(tree, mode, model, rowIndex, xml, selectedRows, expandedRows); } else { TreeItemIdNode node = tree.getCustomIdNodeMap().get(itemId); paintCustomItem(tree, mode, model, node, xml, selectedRows, expandedRows); } }
[ "protected", "void", "handleOpenItemRequest", "(", "final", "WTree", "tree", ",", "final", "XmlStringBuilder", "xml", ",", "final", "String", "itemId", ")", "{", "TreeItemModel", "model", "=", "tree", ".", "getTreeModel", "(", ")", ";", "Set", "<", "String", ">", "selectedRows", "=", "new", "HashSet", "(", "tree", ".", "getSelectedRows", "(", ")", ")", ";", "WTree", ".", "ExpandMode", "mode", "=", "tree", ".", "getExpandMode", "(", ")", ";", "// Only want to render the children of the \"open item\" so only include the open item id in the expanded rows", "Set", "<", "String", ">", "expandedRows", "=", "new", "HashSet", "(", ")", ";", "expandedRows", ".", "add", "(", "itemId", ")", ";", "if", "(", "tree", ".", "getCustomTree", "(", ")", "==", "null", ")", "{", "List", "<", "Integer", ">", "rowIndex", "=", "tree", ".", "getExpandedItemIdIndexMap", "(", ")", ".", "get", "(", "itemId", ")", ";", "paintItem", "(", "tree", ",", "mode", ",", "model", ",", "rowIndex", ",", "xml", ",", "selectedRows", ",", "expandedRows", ")", ";", "}", "else", "{", "TreeItemIdNode", "node", "=", "tree", ".", "getCustomIdNodeMap", "(", ")", ".", "get", "(", "itemId", ")", ";", "paintCustomItem", "(", "tree", ",", "mode", ",", "model", ",", "node", ",", "xml", ",", "selectedRows", ",", "expandedRows", ")", ";", "}", "}" ]
Paint the item that was on the open request. @param tree the WTree to render @param xml the XML string builder @param itemId the item id to open
[ "Paint", "the", "item", "that", "was", "on", "the", "open", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L104-L120
139,387
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java
WTreeRenderer.handlePaintItems
protected void handlePaintItems(final WTree tree, final XmlStringBuilder xml) { TreeItemModel model = tree.getTreeModel(); int rows = model.getRowCount(); if (rows > 0) { Set<String> selectedRows = new HashSet(tree.getSelectedRows()); Set<String> expandedRows = new HashSet(tree.getExpandedRows()); WTree.ExpandMode mode = tree.getExpandMode(); for (int i = 0; i < rows; i++) { List<Integer> rowIndex = new ArrayList<>(); rowIndex.add(i); paintItem(tree, mode, model, rowIndex, xml, selectedRows, expandedRows); } } }
java
protected void handlePaintItems(final WTree tree, final XmlStringBuilder xml) { TreeItemModel model = tree.getTreeModel(); int rows = model.getRowCount(); if (rows > 0) { Set<String> selectedRows = new HashSet(tree.getSelectedRows()); Set<String> expandedRows = new HashSet(tree.getExpandedRows()); WTree.ExpandMode mode = tree.getExpandMode(); for (int i = 0; i < rows; i++) { List<Integer> rowIndex = new ArrayList<>(); rowIndex.add(i); paintItem(tree, mode, model, rowIndex, xml, selectedRows, expandedRows); } } }
[ "protected", "void", "handlePaintItems", "(", "final", "WTree", "tree", ",", "final", "XmlStringBuilder", "xml", ")", "{", "TreeItemModel", "model", "=", "tree", ".", "getTreeModel", "(", ")", ";", "int", "rows", "=", "model", ".", "getRowCount", "(", ")", ";", "if", "(", "rows", ">", "0", ")", "{", "Set", "<", "String", ">", "selectedRows", "=", "new", "HashSet", "(", "tree", ".", "getSelectedRows", "(", ")", ")", ";", "Set", "<", "String", ">", "expandedRows", "=", "new", "HashSet", "(", "tree", ".", "getExpandedRows", "(", ")", ")", ";", "WTree", ".", "ExpandMode", "mode", "=", "tree", ".", "getExpandMode", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "i", "++", ")", "{", "List", "<", "Integer", ">", "rowIndex", "=", "new", "ArrayList", "<>", "(", ")", ";", "rowIndex", ".", "add", "(", "i", ")", ";", "paintItem", "(", "tree", ",", "mode", ",", "model", ",", "rowIndex", ",", "xml", ",", "selectedRows", ",", "expandedRows", ")", ";", "}", "}", "}" ]
Paint the tree items. @param tree the WTree to render @param xml the XML string builder
[ "Paint", "the", "tree", "items", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L128-L143
139,388
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java
WTreeRenderer.paintItem
protected void paintItem(final WTree tree, final WTree.ExpandMode mode, final TreeItemModel model, final List<Integer> rowIndex, final XmlStringBuilder xml, final Set<String> selectedRows, final Set<String> expandedRows) { String itemId = model.getItemId(rowIndex); boolean selected = selectedRows.remove(itemId); boolean expandable = model.isExpandable(rowIndex) && model.hasChildren(rowIndex); boolean expanded = expandedRows.remove(itemId); TreeItemImage image = model.getItemImage(rowIndex); String url = null; if (image != null) { url = tree.getItemImageUrl(image, itemId); } xml.appendTagOpen("ui:treeitem"); xml.appendAttribute("id", tree.getItemIdPrefix() + itemId); xml.appendAttribute("label", model.getItemLabel(rowIndex)); xml.appendOptionalUrlAttribute("imageUrl", url); xml.appendOptionalAttribute("selected", selected, "true"); xml.appendOptionalAttribute("expandable", expandable, "true"); xml.appendOptionalAttribute("open", expandable && expanded, "true"); xml.appendClose(); if (expandable && (mode == WTree.ExpandMode.CLIENT || expanded)) { // Get actual child count int children = model.getChildCount(rowIndex); if (children > 0) { for (int i = 0; i < children; i++) { // Add next level List<Integer> nextRow = new ArrayList<>(rowIndex); nextRow.add(i); paintItem(tree, mode, model, nextRow, xml, selectedRows, expandedRows); } } } xml.appendEndTag("ui:treeitem"); }
java
protected void paintItem(final WTree tree, final WTree.ExpandMode mode, final TreeItemModel model, final List<Integer> rowIndex, final XmlStringBuilder xml, final Set<String> selectedRows, final Set<String> expandedRows) { String itemId = model.getItemId(rowIndex); boolean selected = selectedRows.remove(itemId); boolean expandable = model.isExpandable(rowIndex) && model.hasChildren(rowIndex); boolean expanded = expandedRows.remove(itemId); TreeItemImage image = model.getItemImage(rowIndex); String url = null; if (image != null) { url = tree.getItemImageUrl(image, itemId); } xml.appendTagOpen("ui:treeitem"); xml.appendAttribute("id", tree.getItemIdPrefix() + itemId); xml.appendAttribute("label", model.getItemLabel(rowIndex)); xml.appendOptionalUrlAttribute("imageUrl", url); xml.appendOptionalAttribute("selected", selected, "true"); xml.appendOptionalAttribute("expandable", expandable, "true"); xml.appendOptionalAttribute("open", expandable && expanded, "true"); xml.appendClose(); if (expandable && (mode == WTree.ExpandMode.CLIENT || expanded)) { // Get actual child count int children = model.getChildCount(rowIndex); if (children > 0) { for (int i = 0; i < children; i++) { // Add next level List<Integer> nextRow = new ArrayList<>(rowIndex); nextRow.add(i); paintItem(tree, mode, model, nextRow, xml, selectedRows, expandedRows); } } } xml.appendEndTag("ui:treeitem"); }
[ "protected", "void", "paintItem", "(", "final", "WTree", "tree", ",", "final", "WTree", ".", "ExpandMode", "mode", ",", "final", "TreeItemModel", "model", ",", "final", "List", "<", "Integer", ">", "rowIndex", ",", "final", "XmlStringBuilder", "xml", ",", "final", "Set", "<", "String", ">", "selectedRows", ",", "final", "Set", "<", "String", ">", "expandedRows", ")", "{", "String", "itemId", "=", "model", ".", "getItemId", "(", "rowIndex", ")", ";", "boolean", "selected", "=", "selectedRows", ".", "remove", "(", "itemId", ")", ";", "boolean", "expandable", "=", "model", ".", "isExpandable", "(", "rowIndex", ")", "&&", "model", ".", "hasChildren", "(", "rowIndex", ")", ";", "boolean", "expanded", "=", "expandedRows", ".", "remove", "(", "itemId", ")", ";", "TreeItemImage", "image", "=", "model", ".", "getItemImage", "(", "rowIndex", ")", ";", "String", "url", "=", "null", ";", "if", "(", "image", "!=", "null", ")", "{", "url", "=", "tree", ".", "getItemImageUrl", "(", "image", ",", "itemId", ")", ";", "}", "xml", ".", "appendTagOpen", "(", "\"ui:treeitem\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "tree", ".", "getItemIdPrefix", "(", ")", "+", "itemId", ")", ";", "xml", ".", "appendAttribute", "(", "\"label\"", ",", "model", ".", "getItemLabel", "(", "rowIndex", ")", ")", ";", "xml", ".", "appendOptionalUrlAttribute", "(", "\"imageUrl\"", ",", "url", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"selected\"", ",", "selected", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"expandable\"", ",", "expandable", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"open\"", ",", "expandable", "&&", "expanded", ",", "\"true\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "if", "(", "expandable", "&&", "(", "mode", "==", "WTree", ".", "ExpandMode", ".", "CLIENT", "||", "expanded", ")", ")", "{", "// Get actual child count", "int", "children", "=", "model", ".", "getChildCount", "(", "rowIndex", ")", ";", "if", "(", "children", ">", "0", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ";", "i", "++", ")", "{", "// Add next level", "List", "<", "Integer", ">", "nextRow", "=", "new", "ArrayList", "<>", "(", "rowIndex", ")", ";", "nextRow", ".", "add", "(", "i", ")", ";", "paintItem", "(", "tree", ",", "mode", ",", "model", ",", "nextRow", ",", "xml", ",", "selectedRows", ",", "expandedRows", ")", ";", "}", "}", "}", "xml", ".", "appendEndTag", "(", "\"ui:treeitem\"", ")", ";", "}" ]
Iterate of over the rows to render the tree items. @param tree the WTree to render @param mode the expand mode @param model the tree model @param rowIndex the current row index @param xml the XML string builder @param selectedRows the set of selected rows @param expandedRows the set of expanded rows
[ "Iterate", "of", "over", "the", "rows", "to", "render", "the", "tree", "items", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L156-L197
139,389
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java
WTreeRenderer.handlePaintCustom
protected void handlePaintCustom(final WTree tree, final XmlStringBuilder xml) { TreeItemModel model = tree.getTreeModel(); TreeItemIdNode root = tree.getCustomTree(); Set<String> selectedRows = new HashSet(tree.getSelectedRows()); Set<String> expandedRows = new HashSet(tree.getExpandedRows()); WTree.ExpandMode mode = tree.getExpandMode(); // Process root nodes for (TreeItemIdNode node : root.getChildren()) { paintCustomItem(tree, mode, model, node, xml, selectedRows, expandedRows); } }
java
protected void handlePaintCustom(final WTree tree, final XmlStringBuilder xml) { TreeItemModel model = tree.getTreeModel(); TreeItemIdNode root = tree.getCustomTree(); Set<String> selectedRows = new HashSet(tree.getSelectedRows()); Set<String> expandedRows = new HashSet(tree.getExpandedRows()); WTree.ExpandMode mode = tree.getExpandMode(); // Process root nodes for (TreeItemIdNode node : root.getChildren()) { paintCustomItem(tree, mode, model, node, xml, selectedRows, expandedRows); } }
[ "protected", "void", "handlePaintCustom", "(", "final", "WTree", "tree", ",", "final", "XmlStringBuilder", "xml", ")", "{", "TreeItemModel", "model", "=", "tree", ".", "getTreeModel", "(", ")", ";", "TreeItemIdNode", "root", "=", "tree", ".", "getCustomTree", "(", ")", ";", "Set", "<", "String", ">", "selectedRows", "=", "new", "HashSet", "(", "tree", ".", "getSelectedRows", "(", ")", ")", ";", "Set", "<", "String", ">", "expandedRows", "=", "new", "HashSet", "(", "tree", ".", "getExpandedRows", "(", ")", ")", ";", "WTree", ".", "ExpandMode", "mode", "=", "tree", ".", "getExpandMode", "(", ")", ";", "// Process root nodes", "for", "(", "TreeItemIdNode", "node", ":", "root", ".", "getChildren", "(", ")", ")", "{", "paintCustomItem", "(", "tree", ",", "mode", ",", "model", ",", "node", ",", "xml", ",", "selectedRows", ",", "expandedRows", ")", ";", "}", "}" ]
Paint the custom tree layout. @param tree the WTree to render @param xml the XML string builder
[ "Paint", "the", "custom", "tree", "layout", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L205-L217
139,390
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java
WTreeRenderer.paintCustomItem
protected void paintCustomItem(final WTree tree, final WTree.ExpandMode mode, final TreeItemModel model, final TreeItemIdNode node, final XmlStringBuilder xml, final Set<String> selectedRows, final Set<String> expandedRows) { String itemId = node.getItemId(); List<Integer> rowIndex = tree.getRowIndexForCustomItemId(itemId); boolean selected = selectedRows.remove(itemId); boolean expandable = node.hasChildren(); boolean expanded = expandedRows.remove(itemId); TreeItemImage image = model.getItemImage(rowIndex); String url = null; if (image != null) { url = tree.getItemImageUrl(image, itemId); } xml.appendTagOpen("ui:treeitem"); xml.appendAttribute("id", tree.getItemIdPrefix() + itemId); xml.appendAttribute("label", model.getItemLabel(rowIndex)); xml.appendOptionalUrlAttribute("imageUrl", url); xml.appendOptionalAttribute("selected", selected, "true"); xml.appendOptionalAttribute("expandable", expandable, "true"); xml.appendOptionalAttribute("open", expandable && expanded, "true"); xml.appendClose(); // Paint child items if (expandable && (mode == WTree.ExpandMode.CLIENT || expanded)) { for (TreeItemIdNode childNode : node.getChildren()) { paintCustomItem(tree, mode, model, childNode, xml, selectedRows, expandedRows); } } xml.appendEndTag("ui:treeitem"); }
java
protected void paintCustomItem(final WTree tree, final WTree.ExpandMode mode, final TreeItemModel model, final TreeItemIdNode node, final XmlStringBuilder xml, final Set<String> selectedRows, final Set<String> expandedRows) { String itemId = node.getItemId(); List<Integer> rowIndex = tree.getRowIndexForCustomItemId(itemId); boolean selected = selectedRows.remove(itemId); boolean expandable = node.hasChildren(); boolean expanded = expandedRows.remove(itemId); TreeItemImage image = model.getItemImage(rowIndex); String url = null; if (image != null) { url = tree.getItemImageUrl(image, itemId); } xml.appendTagOpen("ui:treeitem"); xml.appendAttribute("id", tree.getItemIdPrefix() + itemId); xml.appendAttribute("label", model.getItemLabel(rowIndex)); xml.appendOptionalUrlAttribute("imageUrl", url); xml.appendOptionalAttribute("selected", selected, "true"); xml.appendOptionalAttribute("expandable", expandable, "true"); xml.appendOptionalAttribute("open", expandable && expanded, "true"); xml.appendClose(); // Paint child items if (expandable && (mode == WTree.ExpandMode.CLIENT || expanded)) { for (TreeItemIdNode childNode : node.getChildren()) { paintCustomItem(tree, mode, model, childNode, xml, selectedRows, expandedRows); } } xml.appendEndTag("ui:treeitem"); }
[ "protected", "void", "paintCustomItem", "(", "final", "WTree", "tree", ",", "final", "WTree", ".", "ExpandMode", "mode", ",", "final", "TreeItemModel", "model", ",", "final", "TreeItemIdNode", "node", ",", "final", "XmlStringBuilder", "xml", ",", "final", "Set", "<", "String", ">", "selectedRows", ",", "final", "Set", "<", "String", ">", "expandedRows", ")", "{", "String", "itemId", "=", "node", ".", "getItemId", "(", ")", ";", "List", "<", "Integer", ">", "rowIndex", "=", "tree", ".", "getRowIndexForCustomItemId", "(", "itemId", ")", ";", "boolean", "selected", "=", "selectedRows", ".", "remove", "(", "itemId", ")", ";", "boolean", "expandable", "=", "node", ".", "hasChildren", "(", ")", ";", "boolean", "expanded", "=", "expandedRows", ".", "remove", "(", "itemId", ")", ";", "TreeItemImage", "image", "=", "model", ".", "getItemImage", "(", "rowIndex", ")", ";", "String", "url", "=", "null", ";", "if", "(", "image", "!=", "null", ")", "{", "url", "=", "tree", ".", "getItemImageUrl", "(", "image", ",", "itemId", ")", ";", "}", "xml", ".", "appendTagOpen", "(", "\"ui:treeitem\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "tree", ".", "getItemIdPrefix", "(", ")", "+", "itemId", ")", ";", "xml", ".", "appendAttribute", "(", "\"label\"", ",", "model", ".", "getItemLabel", "(", "rowIndex", ")", ")", ";", "xml", ".", "appendOptionalUrlAttribute", "(", "\"imageUrl\"", ",", "url", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"selected\"", ",", "selected", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"expandable\"", ",", "expandable", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"open\"", ",", "expandable", "&&", "expanded", ",", "\"true\"", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Paint child items", "if", "(", "expandable", "&&", "(", "mode", "==", "WTree", ".", "ExpandMode", ".", "CLIENT", "||", "expanded", ")", ")", "{", "for", "(", "TreeItemIdNode", "childNode", ":", "node", ".", "getChildren", "(", ")", ")", "{", "paintCustomItem", "(", "tree", ",", "mode", ",", "model", ",", "childNode", ",", "xml", ",", "selectedRows", ",", "expandedRows", ")", ";", "}", "}", "xml", ".", "appendEndTag", "(", "\"ui:treeitem\"", ")", ";", "}" ]
Iterate of over the nodes to render the custom layout of the tree items. @param tree the WTree to render @param mode the expand mode @param model the tree model @param node the current node in the custom tree layout @param xml the XML string builder @param selectedRows the set of selected rows @param expandedRows the set of expanded rows
[ "Iterate", "of", "over", "the", "nodes", "to", "render", "the", "custom", "layout", "of", "the", "tree", "items", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTreeRenderer.java#L230-L265
139,391
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/SimplePaginationTableWithSelectablesExample.java
SimplePaginationTableWithSelectablesExample.buttonAction
private Action buttonAction(final String preface) { return new Action() { @Override public void execute(final ActionEvent event) { StringBuffer buf = new StringBuffer(preface); buf.append("\n"); for (Object selected : wTable.getSelectedRows()) { // The Model uses the "bean" as the key PersonBean person = (PersonBean) selected; buf.append(person.toString()).append("\n"); } selectionText.setText(buf.toString()); } }; }
java
private Action buttonAction(final String preface) { return new Action() { @Override public void execute(final ActionEvent event) { StringBuffer buf = new StringBuffer(preface); buf.append("\n"); for (Object selected : wTable.getSelectedRows()) { // The Model uses the "bean" as the key PersonBean person = (PersonBean) selected; buf.append(person.toString()).append("\n"); } selectionText.setText(buf.toString()); } }; }
[ "private", "Action", "buttonAction", "(", "final", "String", "preface", ")", "{", "return", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "preface", ")", ";", "buf", ".", "append", "(", "\"\\n\"", ")", ";", "for", "(", "Object", "selected", ":", "wTable", ".", "getSelectedRows", "(", ")", ")", "{", "// The Model uses the \"bean\" as the key", "PersonBean", "person", "=", "(", "PersonBean", ")", "selected", ";", "buf", ".", "append", "(", "person", ".", "toString", "(", ")", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "selectionText", ".", "setText", "(", "buf", ".", "toString", "(", ")", ")", ";", "}", "}", ";", "}" ]
Common action for the table buttons. @param preface the initial content for the text output. @return an Action instance
[ "Common", "action", "for", "the", "table", "buttons", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/SimplePaginationTableWithSelectablesExample.java#L81-L98
139,392
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/template/TemplateUtil.java
TemplateUtil.mapTaggedComponents
public static Map<String, WComponent> mapTaggedComponents(final Map<String, Object> context, final Map<String, WComponent> taggedComponents) { Map<String, WComponent> componentsByKey = new HashMap<>(); // Replace each component tag with the key so it can be used in the replace writer for (Map.Entry<String, WComponent> tagged : taggedComponents.entrySet()) { String tag = tagged.getKey(); WComponent comp = tagged.getValue(); // The key needs to be something which would never be output by a Template. String key = "[WC-TemplateLayout-" + tag + "]"; componentsByKey.put(key, comp); // Map the tag to the key in the context context.put(tag, key); } return componentsByKey; }
java
public static Map<String, WComponent> mapTaggedComponents(final Map<String, Object> context, final Map<String, WComponent> taggedComponents) { Map<String, WComponent> componentsByKey = new HashMap<>(); // Replace each component tag with the key so it can be used in the replace writer for (Map.Entry<String, WComponent> tagged : taggedComponents.entrySet()) { String tag = tagged.getKey(); WComponent comp = tagged.getValue(); // The key needs to be something which would never be output by a Template. String key = "[WC-TemplateLayout-" + tag + "]"; componentsByKey.put(key, comp); // Map the tag to the key in the context context.put(tag, key); } return componentsByKey; }
[ "public", "static", "Map", "<", "String", ",", "WComponent", ">", "mapTaggedComponents", "(", "final", "Map", "<", "String", ",", "Object", ">", "context", ",", "final", "Map", "<", "String", ",", "WComponent", ">", "taggedComponents", ")", "{", "Map", "<", "String", ",", "WComponent", ">", "componentsByKey", "=", "new", "HashMap", "<>", "(", ")", ";", "// Replace each component tag with the key so it can be used in the replace writer", "for", "(", "Map", ".", "Entry", "<", "String", ",", "WComponent", ">", "tagged", ":", "taggedComponents", ".", "entrySet", "(", ")", ")", "{", "String", "tag", "=", "tagged", ".", "getKey", "(", ")", ";", "WComponent", "comp", "=", "tagged", ".", "getValue", "(", ")", ";", "// The key needs to be something which would never be output by a Template.", "String", "key", "=", "\"[WC-TemplateLayout-\"", "+", "tag", "+", "\"]\"", ";", "componentsByKey", ".", "put", "(", "key", ",", "comp", ")", ";", "// Map the tag to the key in the context", "context", ".", "put", "(", "tag", ",", "key", ")", ";", "}", "return", "componentsByKey", ";", "}" ]
Replace each component tag with the key so it can be used in the replace writer. @param context the context to modify. @param taggedComponents the tagged components @return the keyed components
[ "Replace", "each", "component", "tag", "with", "the", "key", "so", "it", "can", "be", "used", "in", "the", "replace", "writer", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/template/TemplateUtil.java#L29-L47
139,393
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDecoratedLabel.java
WDecoratedLabel.setHead
public void setHead(final WComponent head) { DecoratedLabelModel model = getOrCreateComponentModel(); if (model.head != null) { remove(model.head); } model.head = head; if (head != null) { add(head); } }
java
public void setHead(final WComponent head) { DecoratedLabelModel model = getOrCreateComponentModel(); if (model.head != null) { remove(model.head); } model.head = head; if (head != null) { add(head); } }
[ "public", "void", "setHead", "(", "final", "WComponent", "head", ")", "{", "DecoratedLabelModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "head", "!=", "null", ")", "{", "remove", "(", "model", ".", "head", ")", ";", "}", "model", ".", "head", "=", "head", ";", "if", "(", "head", "!=", "null", ")", "{", "add", "(", "head", ")", ";", "}", "}" ]
Sets the label head content. @param head the head content, or null for no content.
[ "Sets", "the", "label", "head", "content", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDecoratedLabel.java#L71-L83
139,394
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDecoratedLabel.java
WDecoratedLabel.setBody
public void setBody(final WComponent body) { DecoratedLabelModel model = getOrCreateComponentModel(); if (body == null) { throw new IllegalArgumentException("Body content must not be null"); } if (model.body != null) { remove(model.body); } model.body = body; add(body); }
java
public void setBody(final WComponent body) { DecoratedLabelModel model = getOrCreateComponentModel(); if (body == null) { throw new IllegalArgumentException("Body content must not be null"); } if (model.body != null) { remove(model.body); } model.body = body; add(body); }
[ "public", "void", "setBody", "(", "final", "WComponent", "body", ")", "{", "DecoratedLabelModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "body", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Body content must not be null\"", ")", ";", "}", "if", "(", "model", ".", "body", "!=", "null", ")", "{", "remove", "(", "model", ".", "body", ")", ";", "}", "model", ".", "body", "=", "body", ";", "add", "(", "body", ")", ";", "}" ]
Sets the label body content. @param body the body content, must not be null.
[ "Sets", "the", "label", "body", "content", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDecoratedLabel.java#L99-L112
139,395
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDecoratedLabel.java
WDecoratedLabel.setTail
public void setTail(final WComponent tail) { DecoratedLabelModel model = getOrCreateComponentModel(); if (model.tail != null) { remove(model.tail); } model.tail = tail; if (tail != null) { add(tail); } }
java
public void setTail(final WComponent tail) { DecoratedLabelModel model = getOrCreateComponentModel(); if (model.tail != null) { remove(model.tail); } model.tail = tail; if (tail != null) { add(tail); } }
[ "public", "void", "setTail", "(", "final", "WComponent", "tail", ")", "{", "DecoratedLabelModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "tail", "!=", "null", ")", "{", "remove", "(", "model", ".", "tail", ")", ";", "}", "model", ".", "tail", "=", "tail", ";", "if", "(", "tail", "!=", "null", ")", "{", "add", "(", "tail", ")", ";", "}", "}" ]
Sets the label tail content. @param tail the tail content, or null for no content.
[ "Sets", "the", "label", "tail", "content", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDecoratedLabel.java#L128-L140
139,396
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTimeoutWarningRenderer.java
WTimeoutWarningRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTimeoutWarning warning = (WTimeoutWarning) component; XmlStringBuilder xml = renderContext.getWriter(); final int timoutPeriod = warning.getTimeoutPeriod(); if (timoutPeriod > 0) { xml.appendTagOpen("ui:session"); xml.appendAttribute("timeout", String.valueOf(timoutPeriod)); int warningPeriod = warning.getWarningPeriod(); xml.appendOptionalAttribute("warn", warningPeriod > 0, warningPeriod); xml.appendEnd(); } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTimeoutWarning warning = (WTimeoutWarning) component; XmlStringBuilder xml = renderContext.getWriter(); final int timoutPeriod = warning.getTimeoutPeriod(); if (timoutPeriod > 0) { xml.appendTagOpen("ui:session"); xml.appendAttribute("timeout", String.valueOf(timoutPeriod)); int warningPeriod = warning.getWarningPeriod(); xml.appendOptionalAttribute("warn", warningPeriod > 0, warningPeriod); xml.appendEnd(); } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTimeoutWarning", "warning", "=", "(", "WTimeoutWarning", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "final", "int", "timoutPeriod", "=", "warning", ".", "getTimeoutPeriod", "(", ")", ";", "if", "(", "timoutPeriod", ">", "0", ")", "{", "xml", ".", "appendTagOpen", "(", "\"ui:session\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"timeout\"", ",", "String", ".", "valueOf", "(", "timoutPeriod", ")", ")", ";", "int", "warningPeriod", "=", "warning", ".", "getWarningPeriod", "(", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"warn\"", ",", "warningPeriod", ">", "0", ",", "warningPeriod", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}", "}" ]
Paints the given WTimeoutWarning if the component's timeout period is greater than 0. @param component the WTimeoutWarning to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTimeoutWarning", "if", "the", "component", "s", "timeout", "period", "is", "greater", "than", "0", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTimeoutWarningRenderer.java#L22-L36
139,397
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/AbstractWebXmlRenderer.java
AbstractWebXmlRenderer.render
@Override public void render(final WComponent component, final RenderContext renderContext) { if (renderContext instanceof WebXmlRenderContext) { doRender(component, (WebXmlRenderContext) renderContext); } else { throw new SystemException("Unable to render web xml output to " + renderContext); } }
java
@Override public void render(final WComponent component, final RenderContext renderContext) { if (renderContext instanceof WebXmlRenderContext) { doRender(component, (WebXmlRenderContext) renderContext); } else { throw new SystemException("Unable to render web xml output to " + renderContext); } }
[ "@", "Override", "public", "void", "render", "(", "final", "WComponent", "component", ",", "final", "RenderContext", "renderContext", ")", "{", "if", "(", "renderContext", "instanceof", "WebXmlRenderContext", ")", "{", "doRender", "(", "component", ",", "(", "WebXmlRenderContext", ")", "renderContext", ")", ";", "}", "else", "{", "throw", "new", "SystemException", "(", "\"Unable to render web xml output to \"", "+", "renderContext", ")", ";", "}", "}" ]
Renders the component. @param component the component to paint @param renderContext the context for rendering.
[ "Renders", "the", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/AbstractWebXmlRenderer.java#L28-L35
139,398
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/AbstractWebXmlRenderer.java
AbstractWebXmlRenderer.paintChildren
protected final void paintChildren(final Container container, final WebXmlRenderContext renderContext) { final int size = container.getChildCount(); for (int i = 0; i < size; i++) { WComponent child = container.getChildAt(i); child.paint(renderContext); } }
java
protected final void paintChildren(final Container container, final WebXmlRenderContext renderContext) { final int size = container.getChildCount(); for (int i = 0; i < size; i++) { WComponent child = container.getChildAt(i); child.paint(renderContext); } }
[ "protected", "final", "void", "paintChildren", "(", "final", "Container", "container", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "final", "int", "size", "=", "container", ".", "getChildCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "WComponent", "child", "=", "container", ".", "getChildAt", "(", "i", ")", ";", "child", ".", "paint", "(", "renderContext", ")", ";", "}", "}" ]
Paints the children of the given component. @param container the component whose children will be painted. @param renderContext the context for rendering.
[ "Paints", "the", "children", "of", "the", "given", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/AbstractWebXmlRenderer.java#L43-L51
139,399
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/velocity/VelocityLogger.java
VelocityLogger.logVelocityMessage
@Override public void logVelocityMessage(final int level, final String message) { switch (level) { case LogSystem.WARN_ID: LOG.warn(message); break; case LogSystem.INFO_ID: LOG.info(message); break; case LogSystem.DEBUG_ID: LOG.debug(message); break; case LogSystem.ERROR_ID: LOG.error(message); break; default: LOG.debug(message); break; } }
java
@Override public void logVelocityMessage(final int level, final String message) { switch (level) { case LogSystem.WARN_ID: LOG.warn(message); break; case LogSystem.INFO_ID: LOG.info(message); break; case LogSystem.DEBUG_ID: LOG.debug(message); break; case LogSystem.ERROR_ID: LOG.error(message); break; default: LOG.debug(message); break; } }
[ "@", "Override", "public", "void", "logVelocityMessage", "(", "final", "int", "level", ",", "final", "String", "message", ")", "{", "switch", "(", "level", ")", "{", "case", "LogSystem", ".", "WARN_ID", ":", "LOG", ".", "warn", "(", "message", ")", ";", "break", ";", "case", "LogSystem", ".", "INFO_ID", ":", "LOG", ".", "info", "(", "message", ")", ";", "break", ";", "case", "LogSystem", ".", "DEBUG_ID", ":", "LOG", ".", "debug", "(", "message", ")", ";", "break", ";", "case", "LogSystem", ".", "ERROR_ID", ":", "LOG", ".", "error", "(", "message", ")", ";", "break", ";", "default", ":", "LOG", ".", "debug", "(", "message", ")", ";", "break", ";", "}", "}" ]
Log velocity engine messages. @param level severity level @param message complete error message
[ "Log", "velocity", "engine", "messages", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/velocity/VelocityLogger.java#L36-L55