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
138,800
hmsonline/dropwizard-spring
src/main/java/com/hmsonline/dropwizard/spring/SpringService.java
SpringService.loadWebConfigs
private void loadWebConfigs(Environment environment, SpringConfiguration config, ApplicationContext appCtx) throws ClassNotFoundException { // Load filters. loadFilters(config.getFilters(), environment); // Load servlet listener. environment.servlets().addServletListeners(new RestContextLoaderListener((XmlRestWebApplicationContext) appCtx)); // Load servlets. loadServlets(config.getServlets(), environment); }
java
private void loadWebConfigs(Environment environment, SpringConfiguration config, ApplicationContext appCtx) throws ClassNotFoundException { // Load filters. loadFilters(config.getFilters(), environment); // Load servlet listener. environment.servlets().addServletListeners(new RestContextLoaderListener((XmlRestWebApplicationContext) appCtx)); // Load servlets. loadServlets(config.getServlets(), environment); }
[ "private", "void", "loadWebConfigs", "(", "Environment", "environment", ",", "SpringConfiguration", "config", ",", "ApplicationContext", "appCtx", ")", "throws", "ClassNotFoundException", "{", "// Load filters.", "loadFilters", "(", "config", ".", "getFilters", "(", ")", ",", "environment", ")", ";", "// Load servlet listener.", "environment", ".", "servlets", "(", ")", ".", "addServletListeners", "(", "new", "RestContextLoaderListener", "(", "(", "XmlRestWebApplicationContext", ")", "appCtx", ")", ")", ";", "// Load servlets.", "loadServlets", "(", "config", ".", "getServlets", "(", ")", ",", "environment", ")", ";", "}" ]
Load filter, servlets or listeners for WebApplicationContext.
[ "Load", "filter", "servlets", "or", "listeners", "for", "WebApplicationContext", "." ]
b0b3ac7b1da3e411cdcc236d352a8b89762fbec1
https://github.com/hmsonline/dropwizard-spring/blob/b0b3ac7b1da3e411cdcc236d352a8b89762fbec1/src/main/java/com/hmsonline/dropwizard/spring/SpringService.java#L81-L90
138,801
hmsonline/dropwizard-spring
src/main/java/com/hmsonline/dropwizard/spring/SpringService.java
SpringService.loadFilters
@SuppressWarnings("unchecked") private void loadFilters(Map<String, FilterConfiguration> filters, Environment environment) throws ClassNotFoundException { if (filters != null) { for (Map.Entry<String, FilterConfiguration> filterEntry : filters.entrySet()) { FilterConfiguration filter = filterEntry.getValue(); // Create filter holder FilterHolder filterHolder = new FilterHolder((Class<? extends Filter>) Class.forName(filter.getClazz())); // Set name of filter filterHolder.setName(filterEntry.getKey()); // Set params if (filter.getParam() != null) { for (Map.Entry<String, String> entry : filter.getParam().entrySet()) { filterHolder.setInitParameter(entry.getKey(), entry.getValue()); } } // Add filter environment.getApplicationContext().addFilter(filterHolder, filter.getUrl(), EnumSet.of(DispatcherType.REQUEST)); } } }
java
@SuppressWarnings("unchecked") private void loadFilters(Map<String, FilterConfiguration> filters, Environment environment) throws ClassNotFoundException { if (filters != null) { for (Map.Entry<String, FilterConfiguration> filterEntry : filters.entrySet()) { FilterConfiguration filter = filterEntry.getValue(); // Create filter holder FilterHolder filterHolder = new FilterHolder((Class<? extends Filter>) Class.forName(filter.getClazz())); // Set name of filter filterHolder.setName(filterEntry.getKey()); // Set params if (filter.getParam() != null) { for (Map.Entry<String, String> entry : filter.getParam().entrySet()) { filterHolder.setInitParameter(entry.getKey(), entry.getValue()); } } // Add filter environment.getApplicationContext().addFilter(filterHolder, filter.getUrl(), EnumSet.of(DispatcherType.REQUEST)); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "loadFilters", "(", "Map", "<", "String", ",", "FilterConfiguration", ">", "filters", ",", "Environment", "environment", ")", "throws", "ClassNotFoundException", "{", "if", "(", "filters", "!=", "null", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "FilterConfiguration", ">", "filterEntry", ":", "filters", ".", "entrySet", "(", ")", ")", "{", "FilterConfiguration", "filter", "=", "filterEntry", ".", "getValue", "(", ")", ";", "// Create filter holder", "FilterHolder", "filterHolder", "=", "new", "FilterHolder", "(", "(", "Class", "<", "?", "extends", "Filter", ">", ")", "Class", ".", "forName", "(", "filter", ".", "getClazz", "(", ")", ")", ")", ";", "// Set name of filter", "filterHolder", ".", "setName", "(", "filterEntry", ".", "getKey", "(", ")", ")", ";", "// Set params", "if", "(", "filter", ".", "getParam", "(", ")", "!=", "null", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "filter", ".", "getParam", "(", ")", ".", "entrySet", "(", ")", ")", "{", "filterHolder", ".", "setInitParameter", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "// Add filter", "environment", ".", "getApplicationContext", "(", ")", ".", "addFilter", "(", "filterHolder", ",", "filter", ".", "getUrl", "(", ")", ",", "EnumSet", ".", "of", "(", "DispatcherType", ".", "REQUEST", ")", ")", ";", "}", "}", "}" ]
Load all filters.
[ "Load", "all", "filters", "." ]
b0b3ac7b1da3e411cdcc236d352a8b89762fbec1
https://github.com/hmsonline/dropwizard-spring/blob/b0b3ac7b1da3e411cdcc236d352a8b89762fbec1/src/main/java/com/hmsonline/dropwizard/spring/SpringService.java#L95-L118
138,802
hmsonline/dropwizard-spring
src/main/java/com/hmsonline/dropwizard/spring/SpringService.java
SpringService.loadServlets
@SuppressWarnings("unchecked") private void loadServlets(Map<String, ServletConfiguration> servlets, Environment environment) throws ClassNotFoundException { if (servlets != null) { for (Map.Entry<String, ServletConfiguration> servletEntry : servlets.entrySet()) { ServletConfiguration servlet = servletEntry.getValue(); // Create servlet holder ServletHolder servletHolder = new ServletHolder((Class<? extends Servlet>) Class.forName(servlet.getClazz())); // Set name of servlet servletHolder.setName(servletEntry.getKey()); // Set params if (servlet.getParam() != null) { for (Map.Entry<String, String> entry : servlet.getParam().entrySet()) { servletHolder.setInitParameter(entry.getKey(), entry.getValue()); } } // Add servlet environment.getApplicationContext().addServlet(servletHolder, servlet.getUrl()); } } }
java
@SuppressWarnings("unchecked") private void loadServlets(Map<String, ServletConfiguration> servlets, Environment environment) throws ClassNotFoundException { if (servlets != null) { for (Map.Entry<String, ServletConfiguration> servletEntry : servlets.entrySet()) { ServletConfiguration servlet = servletEntry.getValue(); // Create servlet holder ServletHolder servletHolder = new ServletHolder((Class<? extends Servlet>) Class.forName(servlet.getClazz())); // Set name of servlet servletHolder.setName(servletEntry.getKey()); // Set params if (servlet.getParam() != null) { for (Map.Entry<String, String> entry : servlet.getParam().entrySet()) { servletHolder.setInitParameter(entry.getKey(), entry.getValue()); } } // Add servlet environment.getApplicationContext().addServlet(servletHolder, servlet.getUrl()); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "loadServlets", "(", "Map", "<", "String", ",", "ServletConfiguration", ">", "servlets", ",", "Environment", "environment", ")", "throws", "ClassNotFoundException", "{", "if", "(", "servlets", "!=", "null", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "ServletConfiguration", ">", "servletEntry", ":", "servlets", ".", "entrySet", "(", ")", ")", "{", "ServletConfiguration", "servlet", "=", "servletEntry", ".", "getValue", "(", ")", ";", "// Create servlet holder", "ServletHolder", "servletHolder", "=", "new", "ServletHolder", "(", "(", "Class", "<", "?", "extends", "Servlet", ">", ")", "Class", ".", "forName", "(", "servlet", ".", "getClazz", "(", ")", ")", ")", ";", "// Set name of servlet", "servletHolder", ".", "setName", "(", "servletEntry", ".", "getKey", "(", ")", ")", ";", "// Set params", "if", "(", "servlet", ".", "getParam", "(", ")", "!=", "null", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "servlet", ".", "getParam", "(", ")", ".", "entrySet", "(", ")", ")", "{", "servletHolder", ".", "setInitParameter", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "// Add servlet", "environment", ".", "getApplicationContext", "(", ")", ".", "addServlet", "(", "servletHolder", ",", "servlet", ".", "getUrl", "(", ")", ")", ";", "}", "}", "}" ]
Load all servlets.
[ "Load", "all", "servlets", "." ]
b0b3ac7b1da3e411cdcc236d352a8b89762fbec1
https://github.com/hmsonline/dropwizard-spring/blob/b0b3ac7b1da3e411cdcc236d352a8b89762fbec1/src/main/java/com/hmsonline/dropwizard/spring/SpringService.java#L123-L146
138,803
litsec/eidas-opensaml
opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/impl/PersonIdentifierTypeImpl.java
PersonIdentifierTypeImpl.getPart
private String getPart(int pos) { String value = this.getValue(); if (value == null) { return null; } String[] parts = value.split("/"); return parts.length >= pos + 1 ? parts[pos] : null; }
java
private String getPart(int pos) { String value = this.getValue(); if (value == null) { return null; } String[] parts = value.split("/"); return parts.length >= pos + 1 ? parts[pos] : null; }
[ "private", "String", "getPart", "(", "int", "pos", ")", "{", "String", "value", "=", "this", ".", "getValue", "(", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "String", "[", "]", "parts", "=", "value", ".", "split", "(", "\"/\"", ")", ";", "return", "parts", ".", "length", ">=", "pos", "+", "1", "?", "parts", "[", "pos", "]", ":", "null", ";", "}" ]
Extracts the given part from the unique identifier. @param pos position @return the part or {@code null}
[ "Extracts", "the", "given", "part", "from", "the", "unique", "identifier", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/impl/PersonIdentifierTypeImpl.java#L68-L75
138,804
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/junit/NeedleRule.java
NeedleRule.withOuter
public NeedleRule withOuter(final MethodRule rule) { if (rule instanceof InjectionProvider) { addInjectionProvider((InjectionProvider<?>) rule); } methodRuleChain.add(0, rule); return this; }
java
public NeedleRule withOuter(final MethodRule rule) { if (rule instanceof InjectionProvider) { addInjectionProvider((InjectionProvider<?>) rule); } methodRuleChain.add(0, rule); return this; }
[ "public", "NeedleRule", "withOuter", "(", "final", "MethodRule", "rule", ")", "{", "if", "(", "rule", "instanceof", "InjectionProvider", ")", "{", "addInjectionProvider", "(", "(", "InjectionProvider", "<", "?", ">", ")", "rule", ")", ";", "}", "methodRuleChain", ".", "add", "(", "0", ",", "rule", ")", ";", "return", "this", ";", "}" ]
Encloses the added rule. @param rule - outer method rule @return {@link NeedleRule}
[ "Encloses", "the", "added", "rule", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/junit/NeedleRule.java#L93-L99
138,805
WASdev/ci.ant
src/main/java/net/wasdev/wlp/ant/SpringBootUtilTask.java
SpringBootUtilTask.buildCommand
private List<String> buildCommand() { List<String> command = new ArrayList<String>(); command.add(cmd); command.add("thin"); command.add("--sourceAppPath=" + getSourceAppPath()); command.add("--targetLibCachePath=" + getTargetLibCachePath()); command.add("--targetThinAppPath=" + getTargetThinAppPath()); if (getParentLibCachePath() != null) { command.add("--parentLibCachePath=" + getParentLibCachePath()); } return command; }
java
private List<String> buildCommand() { List<String> command = new ArrayList<String>(); command.add(cmd); command.add("thin"); command.add("--sourceAppPath=" + getSourceAppPath()); command.add("--targetLibCachePath=" + getTargetLibCachePath()); command.add("--targetThinAppPath=" + getTargetThinAppPath()); if (getParentLibCachePath() != null) { command.add("--parentLibCachePath=" + getParentLibCachePath()); } return command; }
[ "private", "List", "<", "String", ">", "buildCommand", "(", ")", "{", "List", "<", "String", ">", "command", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "command", ".", "add", "(", "cmd", ")", ";", "command", ".", "add", "(", "\"thin\"", ")", ";", "command", ".", "add", "(", "\"--sourceAppPath=\"", "+", "getSourceAppPath", "(", ")", ")", ";", "command", ".", "add", "(", "\"--targetLibCachePath=\"", "+", "getTargetLibCachePath", "(", ")", ")", ";", "command", ".", "add", "(", "\"--targetThinAppPath=\"", "+", "getTargetThinAppPath", "(", ")", ")", ";", "if", "(", "getParentLibCachePath", "(", ")", "!=", "null", ")", "{", "command", ".", "add", "(", "\"--parentLibCachePath=\"", "+", "getParentLibCachePath", "(", ")", ")", ";", "}", "return", "command", ";", "}" ]
Build up a command string to launch in new process
[ "Build", "up", "a", "command", "string", "to", "launch", "in", "new", "process" ]
13edd5c9111b98e12f74c0be83f9180285e6e40c
https://github.com/WASdev/ci.ant/blob/13edd5c9111b98e12f74c0be83f9180285e6e40c/src/main/java/net/wasdev/wlp/ant/SpringBootUtilTask.java#L90-L101
138,806
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/mock/EasyMockProvider.java
EasyMockProvider.resetToNice
@SuppressWarnings("unchecked") public <X> X resetToNice(final Object mock) { EasyMock.resetToNice(mock); return (X) mock; }
java
@SuppressWarnings("unchecked") public <X> X resetToNice(final Object mock) { EasyMock.resetToNice(mock); return (X) mock; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "X", ">", "X", "resetToNice", "(", "final", "Object", "mock", ")", "{", "EasyMock", ".", "resetToNice", "(", "mock", ")", ";", "return", "(", "X", ")", "mock", ";", "}" ]
Resets the given mock object and turns them to a mock with nice behavior. For details, see the EasyMock documentation. @param mock the mock object @return the mock object
[ "Resets", "the", "given", "mock", "object", "and", "turns", "them", "to", "a", "mock", "with", "nice", "behavior", ".", "For", "details", "see", "the", "EasyMock", "documentation", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/mock/EasyMockProvider.java#L79-L83
138,807
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/mock/EasyMockProvider.java
EasyMockProvider.resetToStrict
@SuppressWarnings("unchecked") public <X> X resetToStrict(final Object mock) { EasyMock.resetToStrict(mock); return (X) mock; }
java
@SuppressWarnings("unchecked") public <X> X resetToStrict(final Object mock) { EasyMock.resetToStrict(mock); return (X) mock; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "X", ">", "X", "resetToStrict", "(", "final", "Object", "mock", ")", "{", "EasyMock", ".", "resetToStrict", "(", "mock", ")", ";", "return", "(", "X", ")", "mock", ";", "}" ]
Resets the given mock object and turns them to a mock with strict behavior. For details, see the EasyMock documentation. @param mock the mock objects @return the mock object
[ "Resets", "the", "given", "mock", "object", "and", "turns", "them", "to", "a", "mock", "with", "strict", "behavior", ".", "For", "details", "see", "the", "EasyMock", "documentation", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/mock/EasyMockProvider.java#L105-L109
138,808
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/mock/EasyMockProvider.java
EasyMockProvider.resetToDefault
@SuppressWarnings("unchecked") public <X> X resetToDefault(final Object mock) { EasyMock.resetToDefault(mock); return (X) mock; }
java
@SuppressWarnings("unchecked") public <X> X resetToDefault(final Object mock) { EasyMock.resetToDefault(mock); return (X) mock; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "X", ">", "X", "resetToDefault", "(", "final", "Object", "mock", ")", "{", "EasyMock", ".", "resetToDefault", "(", "mock", ")", ";", "return", "(", "X", ")", "mock", ";", "}" ]
Resets the given mock object and turns them to a mock with default behavior. For details, see the EasyMock documentation. @param mock the mock object @return the mock object
[ "Resets", "the", "given", "mock", "object", "and", "turns", "them", "to", "a", "mock", "with", "default", "behavior", ".", "For", "details", "see", "the", "EasyMock", "documentation", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/mock/EasyMockProvider.java#L131-L135
138,809
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/db/operation/hsql/HSQLDeleteOperation.java
HSQLDeleteOperation.deleteContent
protected void deleteContent(final List<String> tables, final Statement statement) throws SQLException { final ArrayList<String> tempTables = new ArrayList<String>(tables); // Loop until all data is deleted: we don't know the correct DROP // order, so we have to retry upon failure while (!tempTables.isEmpty()) { final int sizeBefore = tempTables.size(); for (final ListIterator<String> iterator = tempTables.listIterator(); iterator.hasNext();) { final String table = iterator.next(); try { statement.executeUpdate("DELETE FROM " + table); iterator.remove(); } catch (final SQLException exc) { LOG.warn("Ignored exception: " + exc.getMessage() + ". WILL RETRY."); } } if (tempTables.size() == sizeBefore) { throw new AssertionError("unable to clean tables " + tempTables); } } }
java
protected void deleteContent(final List<String> tables, final Statement statement) throws SQLException { final ArrayList<String> tempTables = new ArrayList<String>(tables); // Loop until all data is deleted: we don't know the correct DROP // order, so we have to retry upon failure while (!tempTables.isEmpty()) { final int sizeBefore = tempTables.size(); for (final ListIterator<String> iterator = tempTables.listIterator(); iterator.hasNext();) { final String table = iterator.next(); try { statement.executeUpdate("DELETE FROM " + table); iterator.remove(); } catch (final SQLException exc) { LOG.warn("Ignored exception: " + exc.getMessage() + ". WILL RETRY."); } } if (tempTables.size() == sizeBefore) { throw new AssertionError("unable to clean tables " + tempTables); } } }
[ "protected", "void", "deleteContent", "(", "final", "List", "<", "String", ">", "tables", ",", "final", "Statement", "statement", ")", "throws", "SQLException", "{", "final", "ArrayList", "<", "String", ">", "tempTables", "=", "new", "ArrayList", "<", "String", ">", "(", "tables", ")", ";", "// Loop until all data is deleted: we don't know the correct DROP", "// order, so we have to retry upon failure", "while", "(", "!", "tempTables", ".", "isEmpty", "(", ")", ")", "{", "final", "int", "sizeBefore", "=", "tempTables", ".", "size", "(", ")", ";", "for", "(", "final", "ListIterator", "<", "String", ">", "iterator", "=", "tempTables", ".", "listIterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "final", "String", "table", "=", "iterator", ".", "next", "(", ")", ";", "try", "{", "statement", ".", "executeUpdate", "(", "\"DELETE FROM \"", "+", "table", ")", ";", "iterator", ".", "remove", "(", ")", ";", "}", "catch", "(", "final", "SQLException", "exc", ")", "{", "LOG", ".", "warn", "(", "\"Ignored exception: \"", "+", "exc", ".", "getMessage", "(", ")", "+", "\". WILL RETRY.\"", ")", ";", "}", "}", "if", "(", "tempTables", ".", "size", "(", ")", "==", "sizeBefore", ")", "{", "throw", "new", "AssertionError", "(", "\"unable to clean tables \"", "+", "tempTables", ")", ";", "}", "}", "}" ]
Deletes all contents from the given tables. @param tables a {@link List} of table names who are to be deleted. @param statement the {@link Statement} to be used for executing a SQL statement. @throws SQLException - if a database access error occurs
[ "Deletes", "all", "contents", "from", "the", "given", "tables", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/db/operation/hsql/HSQLDeleteOperation.java#L123-L147
138,810
WASdev/ci.ant
src/main/java/net/wasdev/wlp/ant/InstallFeatureTask.java
InstallFeatureTask.initCommand
private List<String> initCommand(){ List<String> command = new ArrayList<String>(); command.add(cmd); command.add("install"); if (acceptLicense) { command.add("--acceptLicense"); } else { command.add("--viewLicenseAgreement"); } if (to != null) { command.add("--to=" + to); } if (from != null) { command.add("--from=" + from); } return command; }
java
private List<String> initCommand(){ List<String> command = new ArrayList<String>(); command.add(cmd); command.add("install"); if (acceptLicense) { command.add("--acceptLicense"); } else { command.add("--viewLicenseAgreement"); } if (to != null) { command.add("--to=" + to); } if (from != null) { command.add("--from=" + from); } return command; }
[ "private", "List", "<", "String", ">", "initCommand", "(", ")", "{", "List", "<", "String", ">", "command", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "command", ".", "add", "(", "cmd", ")", ";", "command", ".", "add", "(", "\"install\"", ")", ";", "if", "(", "acceptLicense", ")", "{", "command", ".", "add", "(", "\"--acceptLicense\"", ")", ";", "}", "else", "{", "command", ".", "add", "(", "\"--viewLicenseAgreement\"", ")", ";", "}", "if", "(", "to", "!=", "null", ")", "{", "command", ".", "add", "(", "\"--to=\"", "+", "to", ")", ";", "}", "if", "(", "from", "!=", "null", ")", "{", "command", ".", "add", "(", "\"--from=\"", "+", "from", ")", ";", "}", "return", "command", ";", "}" ]
Generate a String list containing all the parameter for the command. @returns A List<String> containing the command to be executed.
[ "Generate", "a", "String", "list", "containing", "all", "the", "parameter", "for", "the", "command", "." ]
13edd5c9111b98e12f74c0be83f9180285e6e40c
https://github.com/WASdev/ci.ant/blob/13edd5c9111b98e12f74c0be83f9180285e6e40c/src/main/java/net/wasdev/wlp/ant/InstallFeatureTask.java#L90-L107
138,811
litsec/eidas-opensaml
opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/impl/CurrentAddressStructuredTypeImpl.java
CurrentAddressStructuredTypeImpl.createXSString
private <T extends XSString> T createXSString(Class<T> clazz, String value) { if (value == null) { return null; } QName elementName = null; String localName = null; try { elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null); localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null); } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) { throw new RuntimeException(e); } XMLObjectBuilder<? extends XMLObject> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName); Object object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix())); T xsstring = clazz.cast(object); xsstring.setValue(value); return xsstring; }
java
private <T extends XSString> T createXSString(Class<T> clazz, String value) { if (value == null) { return null; } QName elementName = null; String localName = null; try { elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null); localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null); } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) { throw new RuntimeException(e); } XMLObjectBuilder<? extends XMLObject> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName); Object object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix())); T xsstring = clazz.cast(object); xsstring.setValue(value); return xsstring; }
[ "private", "<", "T", "extends", "XSString", ">", "T", "createXSString", "(", "Class", "<", "T", ">", "clazz", ",", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "QName", "elementName", "=", "null", ";", "String", "localName", "=", "null", ";", "try", "{", "elementName", "=", "(", "QName", ")", "clazz", ".", "getDeclaredField", "(", "\"DEFAULT_ELEMENT_NAME\"", ")", ".", "get", "(", "null", ")", ";", "localName", "=", "(", "String", ")", "clazz", ".", "getDeclaredField", "(", "\"DEFAULT_ELEMENT_LOCAL_NAME\"", ")", ".", "get", "(", "null", ")", ";", "}", "catch", "(", "NoSuchFieldException", "|", "IllegalArgumentException", "|", "IllegalAccessException", "|", "SecurityException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "XMLObjectBuilder", "<", "?", "extends", "XMLObject", ">", "builder", "=", "XMLObjectProviderRegistrySupport", ".", "getBuilderFactory", "(", ")", ".", "getBuilder", "(", "elementName", ")", ";", "Object", "object", "=", "builder", ".", "buildObject", "(", "new", "QName", "(", "this", ".", "getElementQName", "(", ")", ".", "getNamespaceURI", "(", ")", ",", "localName", ",", "this", ".", "getElementQName", "(", ")", ".", "getPrefix", "(", ")", ")", ")", ";", "T", "xsstring", "=", "clazz", ".", "cast", "(", "object", ")", ";", "xsstring", ".", "setValue", "(", "value", ")", ";", "return", "xsstring", ";", "}" ]
Utility method for creating an OpenSAML object given its type and assigns the value. @param clazz the class to create @param value the string value to assign @return the XML object or {@code null} if value is {@code null}
[ "Utility", "method", "for", "creating", "an", "OpenSAML", "object", "given", "its", "type", "and", "assigns", "the", "value", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/impl/CurrentAddressStructuredTypeImpl.java#L248-L266
138,812
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/injection/InjectionTargetInformation.java
InjectionTargetInformation.getAnnotations
public Annotation[] getAnnotations() { final Annotation[] accessibleObjectAnnotations = accessibleObject.getAnnotations(); final Annotation[] annotations = new Annotation[accessibleObjectAnnotations.length + parameterAnnotations.length]; System.arraycopy(accessibleObjectAnnotations, 0, annotations, 0, accessibleObjectAnnotations.length); System.arraycopy(parameterAnnotations, 0, annotations, accessibleObjectAnnotations.length, parameterAnnotations.length); return annotations; }
java
public Annotation[] getAnnotations() { final Annotation[] accessibleObjectAnnotations = accessibleObject.getAnnotations(); final Annotation[] annotations = new Annotation[accessibleObjectAnnotations.length + parameterAnnotations.length]; System.arraycopy(accessibleObjectAnnotations, 0, annotations, 0, accessibleObjectAnnotations.length); System.arraycopy(parameterAnnotations, 0, annotations, accessibleObjectAnnotations.length, parameterAnnotations.length); return annotations; }
[ "public", "Annotation", "[", "]", "getAnnotations", "(", ")", "{", "final", "Annotation", "[", "]", "accessibleObjectAnnotations", "=", "accessibleObject", ".", "getAnnotations", "(", ")", ";", "final", "Annotation", "[", "]", "annotations", "=", "new", "Annotation", "[", "accessibleObjectAnnotations", ".", "length", "+", "parameterAnnotations", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "accessibleObjectAnnotations", ",", "0", ",", "annotations", ",", "0", ",", "accessibleObjectAnnotations", ".", "length", ")", ";", "System", ".", "arraycopy", "(", "parameterAnnotations", ",", "0", ",", "annotations", ",", "accessibleObjectAnnotations", ".", "length", ",", "parameterAnnotations", ".", "length", ")", ";", "return", "annotations", ";", "}" ]
Returns an array of all annotations present on the injection target. If the {@link AccessibleObject} of the injection target is of type {@link Method} or {@link Constructor}, then the {@link Annotation} of the {@link AccessibleObject} and the corresponding parameter are returned. @return Array of all annotations present on the injection target
[ "Returns", "an", "array", "of", "all", "annotations", "present", "on", "the", "injection", "target", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/injection/InjectionTargetInformation.java#L95-L105
138,813
litsec/eidas-opensaml
opensaml3/src/main/java/se/litsec/eidas/opensaml/metadata/MetadataServiceListVersion.java
MetadataServiceListVersion.valueOf
public static final MetadataServiceListVersion valueOf(final int majorVersion, final int minorVersion) { if (majorVersion == 1 && minorVersion == 0) { return MetadataServiceListVersion.VERSION_10; } return new MetadataServiceListVersion(majorVersion, minorVersion); }
java
public static final MetadataServiceListVersion valueOf(final int majorVersion, final int minorVersion) { if (majorVersion == 1 && minorVersion == 0) { return MetadataServiceListVersion.VERSION_10; } return new MetadataServiceListVersion(majorVersion, minorVersion); }
[ "public", "static", "final", "MetadataServiceListVersion", "valueOf", "(", "final", "int", "majorVersion", ",", "final", "int", "minorVersion", ")", "{", "if", "(", "majorVersion", "==", "1", "&&", "minorVersion", "==", "0", ")", "{", "return", "MetadataServiceListVersion", ".", "VERSION_10", ";", "}", "return", "new", "MetadataServiceListVersion", "(", "majorVersion", ",", "minorVersion", ")", ";", "}" ]
Gets the version given the major and minor version number. @param majorVersion major version number @param minorVersion minor version number @return the version
[ "Gets", "the", "version", "given", "the", "major", "and", "minor", "version", "number", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/metadata/MetadataServiceListVersion.java#L59-L65
138,814
litsec/eidas-opensaml
opensaml3/src/main/java/se/litsec/eidas/opensaml/metadata/MetadataServiceListVersion.java
MetadataServiceListVersion.valueOf
public static final MetadataServiceListVersion valueOf(String version) { String[] components = version.split("\\."); return valueOf(Integer.valueOf(components[0]), Integer.valueOf(components[1])); }
java
public static final MetadataServiceListVersion valueOf(String version) { String[] components = version.split("\\."); return valueOf(Integer.valueOf(components[0]), Integer.valueOf(components[1])); }
[ "public", "static", "final", "MetadataServiceListVersion", "valueOf", "(", "String", "version", ")", "{", "String", "[", "]", "components", "=", "version", ".", "split", "(", "\"\\\\.\"", ")", ";", "return", "valueOf", "(", "Integer", ".", "valueOf", "(", "components", "[", "0", "]", ")", ",", "Integer", ".", "valueOf", "(", "components", "[", "1", "]", ")", ")", ";", "}" ]
Gets the version for a given version string, such as "1.0". @param version version string @return version for the given string
[ "Gets", "the", "version", "for", "a", "given", "version", "string", "such", "as", "1", ".", "0", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/metadata/MetadataServiceListVersion.java#L75-L78
138,815
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java
InjectionProviders.providerForQualifiedInstance
public static <T> InjectionProvider<T> providerForQualifiedInstance(final Class<? extends Annotation> qualifier, final T instance) { return new QualifiedInstanceInjectionProvider<T>(qualifier, instance); }
java
public static <T> InjectionProvider<T> providerForQualifiedInstance(final Class<? extends Annotation> qualifier, final T instance) { return new QualifiedInstanceInjectionProvider<T>(qualifier, instance); }
[ "public", "static", "<", "T", ">", "InjectionProvider", "<", "T", ">", "providerForQualifiedInstance", "(", "final", "Class", "<", "?", "extends", "Annotation", ">", "qualifier", ",", "final", "T", "instance", ")", "{", "return", "new", "QualifiedInstanceInjectionProvider", "<", "T", ">", "(", "qualifier", ",", "instance", ")", ";", "}" ]
InjectionProvider that provides a singleton instance of type T for every injection point that is annotated with the given qualifier. @param qualifier qualifying annotation of injection point @param instance the instance to return whenever needed @return InjectionProvider for instance
[ "InjectionProvider", "that", "provides", "a", "singleton", "instance", "of", "type", "T", "for", "every", "injection", "point", "that", "is", "annotated", "with", "the", "given", "qualifier", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java#L67-L69
138,816
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java
InjectionProviders.newProviderSet
private static Set<InjectionProvider<?>> newProviderSet(final InjectionProvider<?>... providers) { final Set<InjectionProvider<?>> result = new LinkedHashSet<InjectionProvider<?>>(); if (providers != null && providers.length > 0) { for (final InjectionProvider<?> provider : providers) { result.add(provider); } } return result; }
java
private static Set<InjectionProvider<?>> newProviderSet(final InjectionProvider<?>... providers) { final Set<InjectionProvider<?>> result = new LinkedHashSet<InjectionProvider<?>>(); if (providers != null && providers.length > 0) { for (final InjectionProvider<?> provider : providers) { result.add(provider); } } return result; }
[ "private", "static", "Set", "<", "InjectionProvider", "<", "?", ">", ">", "newProviderSet", "(", "final", "InjectionProvider", "<", "?", ">", "...", "providers", ")", "{", "final", "Set", "<", "InjectionProvider", "<", "?", ">", ">", "result", "=", "new", "LinkedHashSet", "<", "InjectionProvider", "<", "?", ">", ">", "(", ")", ";", "if", "(", "providers", "!=", "null", "&&", "providers", ".", "length", ">", "0", ")", "{", "for", "(", "final", "InjectionProvider", "<", "?", ">", "provider", ":", "providers", ")", "{", "result", ".", "add", "(", "provider", ")", ";", "}", "}", "return", "result", ";", "}" ]
Creates a new Set. @param providers vararg array of providers @return set containing providers
[ "Creates", "a", "new", "Set", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java#L78-L89
138,817
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java
InjectionProviders.mergeSuppliers
private static InjectionProviderInstancesSupplier mergeSuppliers(final InjectionProviderInstancesSupplier... suppliers) { final Set<InjectionProvider<?>> result = new LinkedHashSet<InjectionProvider<?>>(); if (suppliers != null && suppliers.length > 0) { for (final InjectionProviderInstancesSupplier supplier : suppliers) { result.addAll(supplier.get()); } } return new InjectionProviderInstancesSupplier() { @Override public Set<InjectionProvider<?>> get() { return result; } }; }
java
private static InjectionProviderInstancesSupplier mergeSuppliers(final InjectionProviderInstancesSupplier... suppliers) { final Set<InjectionProvider<?>> result = new LinkedHashSet<InjectionProvider<?>>(); if (suppliers != null && suppliers.length > 0) { for (final InjectionProviderInstancesSupplier supplier : suppliers) { result.addAll(supplier.get()); } } return new InjectionProviderInstancesSupplier() { @Override public Set<InjectionProvider<?>> get() { return result; } }; }
[ "private", "static", "InjectionProviderInstancesSupplier", "mergeSuppliers", "(", "final", "InjectionProviderInstancesSupplier", "...", "suppliers", ")", "{", "final", "Set", "<", "InjectionProvider", "<", "?", ">", ">", "result", "=", "new", "LinkedHashSet", "<", "InjectionProvider", "<", "?", ">", ">", "(", ")", ";", "if", "(", "suppliers", "!=", "null", "&&", "suppliers", ".", "length", ">", "0", ")", "{", "for", "(", "final", "InjectionProviderInstancesSupplier", "supplier", ":", "suppliers", ")", "{", "result", ".", "addAll", "(", "supplier", ".", "get", "(", ")", ")", ";", "}", "}", "return", "new", "InjectionProviderInstancesSupplier", "(", ")", "{", "@", "Override", "public", "Set", "<", "InjectionProvider", "<", "?", ">", ">", "get", "(", ")", "{", "return", "result", ";", "}", "}", ";", "}" ]
Creates new supplier containing all providers in a new set. @param suppliers vararg array of existing suppliers @return new instance containing all providers
[ "Creates", "new", "supplier", "containing", "all", "providers", "in", "a", "new", "set", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java#L115-L133
138,818
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java
InjectionProviders.providersForInstancesSuppliers
public static InjectionProvider<?>[] providersForInstancesSuppliers(final InjectionProviderInstancesSupplier... suppliers) { final InjectionProviderInstancesSupplier supplier = mergeSuppliers(suppliers); return supplier.get().toArray(new InjectionProvider<?>[supplier.get().size()]); }
java
public static InjectionProvider<?>[] providersForInstancesSuppliers(final InjectionProviderInstancesSupplier... suppliers) { final InjectionProviderInstancesSupplier supplier = mergeSuppliers(suppliers); return supplier.get().toArray(new InjectionProvider<?>[supplier.get().size()]); }
[ "public", "static", "InjectionProvider", "<", "?", ">", "[", "]", "providersForInstancesSuppliers", "(", "final", "InjectionProviderInstancesSupplier", "...", "suppliers", ")", "{", "final", "InjectionProviderInstancesSupplier", "supplier", "=", "mergeSuppliers", "(", "suppliers", ")", ";", "return", "supplier", ".", "get", "(", ")", ".", "toArray", "(", "new", "InjectionProvider", "<", "?", ">", "[", "supplier", ".", "get", "(", ")", ".", "size", "(", ")", "]", ")", ";", "}" ]
Create array of providers from given suppliers. @param suppliers vararg array of suppliers @return array of providers for use with vararg method
[ "Create", "array", "of", "providers", "from", "given", "suppliers", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java#L142-L145
138,819
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java
InjectionProviders.providersToArray
public static InjectionProvider<?>[] providersToArray(final Collection<InjectionProvider<?>> providers) { return providers == null ? new InjectionProvider<?>[0] : providers .toArray(new InjectionProvider<?>[providers.size()]); }
java
public static InjectionProvider<?>[] providersToArray(final Collection<InjectionProvider<?>> providers) { return providers == null ? new InjectionProvider<?>[0] : providers .toArray(new InjectionProvider<?>[providers.size()]); }
[ "public", "static", "InjectionProvider", "<", "?", ">", "[", "]", "providersToArray", "(", "final", "Collection", "<", "InjectionProvider", "<", "?", ">", ">", "providers", ")", "{", "return", "providers", "==", "null", "?", "new", "InjectionProvider", "<", "?", ">", "[", "0", "]", ":", "providers", ".", "toArray", "(", "new", "InjectionProvider", "<", "?", ">", "[", "providers", ".", "size", "(", ")", "]", ")", ";", "}" ]
Create array of InjectionProviders for given collection. @param providers providers to be contained @return array of given providers
[ "Create", "array", "of", "InjectionProviders", "for", "given", "collection", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/injection/InjectionProviders.java#L166-L169
138,820
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/db/transaction/TransactionHelper.java
TransactionHelper.saveObject
public final <T> T saveObject(final T obj) throws Exception { return executeInTransaction(new Runnable<T>() { @Override public T run(final EntityManager entityManager) { return persist(obj, entityManager); } }); }
java
public final <T> T saveObject(final T obj) throws Exception { return executeInTransaction(new Runnable<T>() { @Override public T run(final EntityManager entityManager) { return persist(obj, entityManager); } }); }
[ "public", "final", "<", "T", ">", "T", "saveObject", "(", "final", "T", "obj", ")", "throws", "Exception", "{", "return", "executeInTransaction", "(", "new", "Runnable", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "run", "(", "final", "EntityManager", "entityManager", ")", "{", "return", "persist", "(", "obj", ",", "entityManager", ")", ";", "}", "}", ")", ";", "}" ]
Saves the given object in the database. @param <T> type of given object obj @param obj object to save @return saved object @throws Exception save objects failed
[ "Saves", "the", "given", "object", "in", "the", "database", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/db/transaction/TransactionHelper.java#L29-L36
138,821
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/db/transaction/TransactionHelper.java
TransactionHelper.loadObject
public final <T> T loadObject(final Class<T> clazz, final Object id) throws Exception { return executeInTransaction(new Runnable<T>() { @Override public T run(final EntityManager entityManager) { return loadObject(entityManager, clazz, id); } }); }
java
public final <T> T loadObject(final Class<T> clazz, final Object id) throws Exception { return executeInTransaction(new Runnable<T>() { @Override public T run(final EntityManager entityManager) { return loadObject(entityManager, clazz, id); } }); }
[ "public", "final", "<", "T", ">", "T", "loadObject", "(", "final", "Class", "<", "T", ">", "clazz", ",", "final", "Object", "id", ")", "throws", "Exception", "{", "return", "executeInTransaction", "(", "new", "Runnable", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "run", "(", "final", "EntityManager", "entityManager", ")", "{", "return", "loadObject", "(", "entityManager", ",", "clazz", ",", "id", ")", ";", "}", "}", ")", ";", "}" ]
Finds and returns the object of the given id in the persistence context. @param <T> type of searched object @param clazz type of searched object @param id technical id of searched object @return found object @throws Exception finding object failed
[ "Finds", "and", "returns", "the", "object", "of", "the", "given", "id", "in", "the", "persistence", "context", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/db/transaction/TransactionHelper.java#L51-L58
138,822
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/db/transaction/TransactionHelper.java
TransactionHelper.loadAllObjects
public final <T> List<T> loadAllObjects(final Class<T> clazz) throws Exception { final Entity entityAnnotation = clazz.getAnnotation(Entity.class); if(entityAnnotation == null){ throw new IllegalArgumentException("Unknown entity: " + clazz.getName()); } return executeInTransaction(new Runnable<List<T>>() { @Override @SuppressWarnings("unchecked") public List<T> run(final EntityManager entityManager) { final String fromEntity = entityAnnotation.name().isEmpty() ? clazz.getSimpleName() : entityAnnotation.name(); final String alias = fromEntity.toLowerCase(); return entityManager.createQuery("SELECT " + alias + " FROM " + fromEntity + " " + alias) .getResultList(); } }); }
java
public final <T> List<T> loadAllObjects(final Class<T> clazz) throws Exception { final Entity entityAnnotation = clazz.getAnnotation(Entity.class); if(entityAnnotation == null){ throw new IllegalArgumentException("Unknown entity: " + clazz.getName()); } return executeInTransaction(new Runnable<List<T>>() { @Override @SuppressWarnings("unchecked") public List<T> run(final EntityManager entityManager) { final String fromEntity = entityAnnotation.name().isEmpty() ? clazz.getSimpleName() : entityAnnotation.name(); final String alias = fromEntity.toLowerCase(); return entityManager.createQuery("SELECT " + alias + " FROM " + fromEntity + " " + alias) .getResultList(); } }); }
[ "public", "final", "<", "T", ">", "List", "<", "T", ">", "loadAllObjects", "(", "final", "Class", "<", "T", ">", "clazz", ")", "throws", "Exception", "{", "final", "Entity", "entityAnnotation", "=", "clazz", ".", "getAnnotation", "(", "Entity", ".", "class", ")", ";", "if", "(", "entityAnnotation", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown entity: \"", "+", "clazz", ".", "getName", "(", ")", ")", ";", "}", "return", "executeInTransaction", "(", "new", "Runnable", "<", "List", "<", "T", ">", ">", "(", ")", "{", "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "T", ">", "run", "(", "final", "EntityManager", "entityManager", ")", "{", "final", "String", "fromEntity", "=", "entityAnnotation", ".", "name", "(", ")", ".", "isEmpty", "(", ")", "?", "clazz", ".", "getSimpleName", "(", ")", ":", "entityAnnotation", ".", "name", "(", ")", ";", "final", "String", "alias", "=", "fromEntity", ".", "toLowerCase", "(", ")", ";", "return", "entityManager", ".", "createQuery", "(", "\"SELECT \"", "+", "alias", "+", "\" FROM \"", "+", "fromEntity", "+", "\" \"", "+", "alias", ")", ".", "getResultList", "(", ")", ";", "}", "}", ")", ";", "}" ]
Returns all objects of the given class in persistence context. @param <T> type of searched objects @param clazz type of searched objects @return list of found objects @throws IllegalArgumentException if the instance is not an entity @throws Exception selecting objects failed
[ "Returns", "all", "objects", "of", "the", "given", "class", "in", "persistence", "context", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/db/transaction/TransactionHelper.java#L73-L91
138,823
litsec/eidas-opensaml
opensaml2/src/main/java/se/litsec/eidas/opensaml2/ext/attributes/impl/CurrentAddressTypeUnmarshaller.java
CurrentAddressTypeUnmarshaller.unmarshall
@Override public XMLObject unmarshall(Element domElement) throws UnmarshallingException { Document newDocument = null; Node childNode = domElement.getFirstChild(); while (childNode != null) { if (childNode.getNodeType() != Node.TEXT_NODE) { // We skip everything except for a text node. log.info("Ignoring node {} - it is not a text node", childNode.getNodeName()); } else { newDocument = parseContents((Text) childNode, domElement); if (newDocument != null) { break; } } childNode = childNode.getNextSibling(); } return super.unmarshall(newDocument != null ? newDocument.getDocumentElement() : domElement); }
java
@Override public XMLObject unmarshall(Element domElement) throws UnmarshallingException { Document newDocument = null; Node childNode = domElement.getFirstChild(); while (childNode != null) { if (childNode.getNodeType() != Node.TEXT_NODE) { // We skip everything except for a text node. log.info("Ignoring node {} - it is not a text node", childNode.getNodeName()); } else { newDocument = parseContents((Text) childNode, domElement); if (newDocument != null) { break; } } childNode = childNode.getNextSibling(); } return super.unmarshall(newDocument != null ? newDocument.getDocumentElement() : domElement); }
[ "@", "Override", "public", "XMLObject", "unmarshall", "(", "Element", "domElement", ")", "throws", "UnmarshallingException", "{", "Document", "newDocument", "=", "null", ";", "Node", "childNode", "=", "domElement", ".", "getFirstChild", "(", ")", ";", "while", "(", "childNode", "!=", "null", ")", "{", "if", "(", "childNode", ".", "getNodeType", "(", ")", "!=", "Node", ".", "TEXT_NODE", ")", "{", "// We skip everything except for a text node.", "log", ".", "info", "(", "\"Ignoring node {} - it is not a text node\"", ",", "childNode", ".", "getNodeName", "(", ")", ")", ";", "}", "else", "{", "newDocument", "=", "parseContents", "(", "(", "Text", ")", "childNode", ",", "domElement", ")", ";", "if", "(", "newDocument", "!=", "null", ")", "{", "break", ";", "}", "}", "childNode", "=", "childNode", ".", "getNextSibling", "(", ")", ";", "}", "return", "super", ".", "unmarshall", "(", "newDocument", "!=", "null", "?", "newDocument", ".", "getDocumentElement", "(", ")", ":", "domElement", ")", ";", "}" ]
Special handling of the Base64 encoded value that represents the address elements.
[ "Special", "handling", "of", "the", "Base64", "encoded", "value", "that", "represents", "the", "address", "elements", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml2/src/main/java/se/litsec/eidas/opensaml2/ext/attributes/impl/CurrentAddressTypeUnmarshaller.java#L53-L74
138,824
litsec/eidas-opensaml
opensaml2/src/main/java/se/litsec/eidas/opensaml2/ext/attributes/impl/CurrentAddressTypeUnmarshaller.java
CurrentAddressTypeUnmarshaller.getNamespaceBindings
private static Map<String, String> getNamespaceBindings(Element element) { Map<String, String> namespaceMap = new HashMap<String, String>(); getNamespaceBindings(element, namespaceMap); return namespaceMap; }
java
private static Map<String, String> getNamespaceBindings(Element element) { Map<String, String> namespaceMap = new HashMap<String, String>(); getNamespaceBindings(element, namespaceMap); return namespaceMap; }
[ "private", "static", "Map", "<", "String", ",", "String", ">", "getNamespaceBindings", "(", "Element", "element", ")", "{", "Map", "<", "String", ",", "String", ">", "namespaceMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "getNamespaceBindings", "(", "element", ",", "namespaceMap", ")", ";", "return", "namespaceMap", ";", "}" ]
Returns a map holding all registered namespace bindings, where the key is the qualified name of the namespace and the value part is the URI. @param element the element to start from @return a namespace map
[ "Returns", "a", "map", "holding", "all", "registered", "namespace", "bindings", "where", "the", "key", "is", "the", "qualified", "name", "of", "the", "namespace", "and", "the", "value", "part", "is", "the", "URI", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml2/src/main/java/se/litsec/eidas/opensaml2/ext/attributes/impl/CurrentAddressTypeUnmarshaller.java#L158-L162
138,825
WASdev/ci.ant
src/main/java/net/wasdev/wlp/ant/AbstractTask.java
AbstractTask.waitForStringInLog
public String waitForStringInLog(String regexp, long timeout, File outputFile) { int waited = 0; final int waitIncrement = 500; log(MessageFormat.format(messages.getString("info.search.string"), regexp, outputFile.getAbsolutePath(), timeout / 1000)); try { while (waited <= timeout) { String string = findStringInFile(regexp, outputFile); if (string == null) { try { Thread.sleep(waitIncrement); } catch (InterruptedException e) { // Ignore and carry on } waited += waitIncrement; } else { return string; } } log(MessageFormat.format(messages.getString("error.serch.string.timeout"), regexp, outputFile.getAbsolutePath())); } catch (Exception e) { // I think we can assume if we can't read the file it doesn't // contain our string throw new BuildException(e); } return null; }
java
public String waitForStringInLog(String regexp, long timeout, File outputFile) { int waited = 0; final int waitIncrement = 500; log(MessageFormat.format(messages.getString("info.search.string"), regexp, outputFile.getAbsolutePath(), timeout / 1000)); try { while (waited <= timeout) { String string = findStringInFile(regexp, outputFile); if (string == null) { try { Thread.sleep(waitIncrement); } catch (InterruptedException e) { // Ignore and carry on } waited += waitIncrement; } else { return string; } } log(MessageFormat.format(messages.getString("error.serch.string.timeout"), regexp, outputFile.getAbsolutePath())); } catch (Exception e) { // I think we can assume if we can't read the file it doesn't // contain our string throw new BuildException(e); } return null; }
[ "public", "String", "waitForStringInLog", "(", "String", "regexp", ",", "long", "timeout", ",", "File", "outputFile", ")", "{", "int", "waited", "=", "0", ";", "final", "int", "waitIncrement", "=", "500", ";", "log", "(", "MessageFormat", ".", "format", "(", "messages", ".", "getString", "(", "\"info.search.string\"", ")", ",", "regexp", ",", "outputFile", ".", "getAbsolutePath", "(", ")", ",", "timeout", "/", "1000", ")", ")", ";", "try", "{", "while", "(", "waited", "<=", "timeout", ")", "{", "String", "string", "=", "findStringInFile", "(", "regexp", ",", "outputFile", ")", ";", "if", "(", "string", "==", "null", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "waitIncrement", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "// Ignore and carry on", "}", "waited", "+=", "waitIncrement", ";", "}", "else", "{", "return", "string", ";", "}", "}", "log", "(", "MessageFormat", ".", "format", "(", "messages", ".", "getString", "(", "\"error.serch.string.timeout\"", ")", ",", "regexp", ",", "outputFile", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// I think we can assume if we can't read the file it doesn't", "// contain our string", "throw", "new", "BuildException", "(", "e", ")", ";", "}", "return", "null", ";", "}" ]
Check for a number of strings in a potentially remote file @param regexp a regular expression to search for @param timeout a timeout, in milliseconds @param outputFile file to check @return line that matched the regexp
[ "Check", "for", "a", "number", "of", "strings", "in", "a", "potentially", "remote", "file" ]
13edd5c9111b98e12f74c0be83f9180285e6e40c
https://github.com/WASdev/ci.ant/blob/13edd5c9111b98e12f74c0be83f9180285e6e40c/src/main/java/net/wasdev/wlp/ant/AbstractTask.java#L294-L323
138,826
litsec/eidas-opensaml
opensaml2/src/main/java/se/litsec/eidas/opensaml2/config/EidasBootstrap.java
EidasBootstrap.bootstrap
public void bootstrap() throws ConfigurationException { XMLConfigurator configurator = new XMLConfigurator(); for (String config : configs) { log.debug("Loading XMLTooling configuration " + config); configurator.load(Configuration.class.getResourceAsStream(config)); } }
java
public void bootstrap() throws ConfigurationException { XMLConfigurator configurator = new XMLConfigurator(); for (String config : configs) { log.debug("Loading XMLTooling configuration " + config); configurator.load(Configuration.class.getResourceAsStream(config)); } }
[ "public", "void", "bootstrap", "(", ")", "throws", "ConfigurationException", "{", "XMLConfigurator", "configurator", "=", "new", "XMLConfigurator", "(", ")", ";", "for", "(", "String", "config", ":", "configs", ")", "{", "log", ".", "debug", "(", "\"Loading XMLTooling configuration \"", "+", "config", ")", ";", "configurator", ".", "load", "(", "Configuration", ".", "class", ".", "getResourceAsStream", "(", "config", ")", ")", ";", "}", "}" ]
Bootstrap method for this library. @throws ConfigurationException for config errors
[ "Bootstrap", "method", "for", "this", "library", "." ]
522ba6dba433a9524cb8a02464cc3b087b47a2b7
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml2/src/main/java/se/litsec/eidas/opensaml2/config/EidasBootstrap.java#L62-L70
138,827
akquinet/needle
src/main/java/de/akquinet/jbosscc/needle/configuration/ConfigurationLoader.java
ConfigurationLoader.loadResource
public static InputStream loadResource(final String resource) throws FileNotFoundException { final boolean hasLeadingSlash = resource.startsWith("/"); final String stripped = hasLeadingSlash ? resource.substring(1) : resource; InputStream stream = null; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader != null) { stream = classLoader.getResourceAsStream(resource); if (stream == null && hasLeadingSlash) { stream = classLoader.getResourceAsStream(stripped); } } if (stream == null) { throw new FileNotFoundException("resource " + resource + " not found"); } return stream; }
java
public static InputStream loadResource(final String resource) throws FileNotFoundException { final boolean hasLeadingSlash = resource.startsWith("/"); final String stripped = hasLeadingSlash ? resource.substring(1) : resource; InputStream stream = null; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader != null) { stream = classLoader.getResourceAsStream(resource); if (stream == null && hasLeadingSlash) { stream = classLoader.getResourceAsStream(stripped); } } if (stream == null) { throw new FileNotFoundException("resource " + resource + " not found"); } return stream; }
[ "public", "static", "InputStream", "loadResource", "(", "final", "String", "resource", ")", "throws", "FileNotFoundException", "{", "final", "boolean", "hasLeadingSlash", "=", "resource", ".", "startsWith", "(", "\"/\"", ")", ";", "final", "String", "stripped", "=", "hasLeadingSlash", "?", "resource", ".", "substring", "(", "1", ")", ":", "resource", ";", "InputStream", "stream", "=", "null", ";", "final", "ClassLoader", "classLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "classLoader", "!=", "null", ")", "{", "stream", "=", "classLoader", ".", "getResourceAsStream", "(", "resource", ")", ";", "if", "(", "stream", "==", "null", "&&", "hasLeadingSlash", ")", "{", "stream", "=", "classLoader", ".", "getResourceAsStream", "(", "stripped", ")", ";", "}", "}", "if", "(", "stream", "==", "null", ")", "{", "throw", "new", "FileNotFoundException", "(", "\"resource \"", "+", "resource", "+", "\" not found\"", ")", ";", "}", "return", "stream", ";", "}" ]
Returns an input stream for reading the specified resource. @param resource the resource name @return an input stream for reading the resource. @throws FileNotFoundException if the resource could not be found
[ "Returns", "an", "input", "stream", "for", "reading", "the", "specified", "resource", "." ]
8b411c521246b8212882485edc01644f9aac7e24
https://github.com/akquinet/needle/blob/8b411c521246b8212882485edc01644f9aac7e24/src/main/java/de/akquinet/jbosscc/needle/configuration/ConfigurationLoader.java#L116-L135
138,828
sitoolkit/sit-wt-all
sit-wt-runtime/src/main/java/io/sitoolkit/wt/domain/operation/IncludeOperation.java
IncludeOperation.operate
@Override public OperationResult operate(TestStep testStep) { String testStepName = testStep.getLocator().getValue(); LogRecord log = LogRecord.info(LOG, testStep, "script.execute", testStepName); current.backup(); TestScript testScript = dao.load(new File(pm.getPageScriptDir(), testStepName), sheetName, false); current.setTestScript(testScript); current.reset(); current.setCurrentIndex(current.getCurrentIndex() - 1); String caseNo = testStep.getValue(); if (testScript.containsCaseNo(caseNo)) { current.setCaseNo(caseNo); } else { String msg = MessageManager.getMessage("case.number.error", caseNo) + testScript.getCaseNoMap().keySet(); throw new TestException(msg); } current.setTestContextListener(this); return new OperationResult(log); }
java
@Override public OperationResult operate(TestStep testStep) { String testStepName = testStep.getLocator().getValue(); LogRecord log = LogRecord.info(LOG, testStep, "script.execute", testStepName); current.backup(); TestScript testScript = dao.load(new File(pm.getPageScriptDir(), testStepName), sheetName, false); current.setTestScript(testScript); current.reset(); current.setCurrentIndex(current.getCurrentIndex() - 1); String caseNo = testStep.getValue(); if (testScript.containsCaseNo(caseNo)) { current.setCaseNo(caseNo); } else { String msg = MessageManager.getMessage("case.number.error", caseNo) + testScript.getCaseNoMap().keySet(); throw new TestException(msg); } current.setTestContextListener(this); return new OperationResult(log); }
[ "@", "Override", "public", "OperationResult", "operate", "(", "TestStep", "testStep", ")", "{", "String", "testStepName", "=", "testStep", ".", "getLocator", "(", ")", ".", "getValue", "(", ")", ";", "LogRecord", "log", "=", "LogRecord", ".", "info", "(", "LOG", ",", "testStep", ",", "\"script.execute\"", ",", "testStepName", ")", ";", "current", ".", "backup", "(", ")", ";", "TestScript", "testScript", "=", "dao", ".", "load", "(", "new", "File", "(", "pm", ".", "getPageScriptDir", "(", ")", ",", "testStepName", ")", ",", "sheetName", ",", "false", ")", ";", "current", ".", "setTestScript", "(", "testScript", ")", ";", "current", ".", "reset", "(", ")", ";", "current", ".", "setCurrentIndex", "(", "current", ".", "getCurrentIndex", "(", ")", "-", "1", ")", ";", "String", "caseNo", "=", "testStep", ".", "getValue", "(", ")", ";", "if", "(", "testScript", ".", "containsCaseNo", "(", "caseNo", ")", ")", "{", "current", ".", "setCaseNo", "(", "caseNo", ")", ";", "}", "else", "{", "String", "msg", "=", "MessageManager", ".", "getMessage", "(", "\"case.number.error\"", ",", "caseNo", ")", "+", "testScript", ".", "getCaseNoMap", "(", ")", ".", "keySet", "(", ")", ";", "throw", "new", "TestException", "(", "msg", ")", ";", "}", "current", ".", "setTestContextListener", "(", "this", ")", ";", "return", "new", "OperationResult", "(", "log", ")", ";", "}" ]
OperationLog opelog;
[ "OperationLog", "opelog", ";" ]
efabde27aa731a5602d2041e137721a22f4fd27a
https://github.com/sitoolkit/sit-wt-all/blob/efabde27aa731a5602d2041e137721a22f4fd27a/sit-wt-runtime/src/main/java/io/sitoolkit/wt/domain/operation/IncludeOperation.java#L63-L88
138,829
sitoolkit/sit-wt-all
sit-wt-runtime/src/main/java/io/sitoolkit/wt/domain/operation/GotoOperation.java
GotoOperation.operate
@Override public OperationResult operate(TestStep testStep) { String value = testStep.getValue(); LogRecord record = LogRecord.info(log, testStep, "test.step.execute", value); TestScript testScript = current.getTestScript(); int nextIndex = testScript.getIndexByScriptNo(value) - 1; current.setCurrentIndex(nextIndex); return new OperationResult(record); }
java
@Override public OperationResult operate(TestStep testStep) { String value = testStep.getValue(); LogRecord record = LogRecord.info(log, testStep, "test.step.execute", value); TestScript testScript = current.getTestScript(); int nextIndex = testScript.getIndexByScriptNo(value) - 1; current.setCurrentIndex(nextIndex); return new OperationResult(record); }
[ "@", "Override", "public", "OperationResult", "operate", "(", "TestStep", "testStep", ")", "{", "String", "value", "=", "testStep", ".", "getValue", "(", ")", ";", "LogRecord", "record", "=", "LogRecord", ".", "info", "(", "log", ",", "testStep", ",", "\"test.step.execute\"", ",", "value", ")", ";", "TestScript", "testScript", "=", "current", ".", "getTestScript", "(", ")", ";", "int", "nextIndex", "=", "testScript", ".", "getIndexByScriptNo", "(", "value", ")", "-", "1", ";", "current", ".", "setCurrentIndex", "(", "nextIndex", ")", ";", "return", "new", "OperationResult", "(", "record", ")", ";", "}" ]
protected OperationLog opelog;
[ "protected", "OperationLog", "opelog", ";" ]
efabde27aa731a5602d2041e137721a22f4fd27a
https://github.com/sitoolkit/sit-wt-all/blob/efabde27aa731a5602d2041e137721a22f4fd27a/sit-wt-runtime/src/main/java/io/sitoolkit/wt/domain/operation/GotoOperation.java#L42-L53
138,830
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/TreeMenuExample.java
TreeMenuExample.buildTreeMenu
private WMenu buildTreeMenu(final WText selectedMenuText) { WMenu menu = new WMenu(WMenu.MenuType.TREE); menu.setSelectMode(SelectMode.SINGLE); mapTreeHierarchy(menu, createExampleHierarchy(), selectedMenuText); return menu; }
java
private WMenu buildTreeMenu(final WText selectedMenuText) { WMenu menu = new WMenu(WMenu.MenuType.TREE); menu.setSelectMode(SelectMode.SINGLE); mapTreeHierarchy(menu, createExampleHierarchy(), selectedMenuText); return menu; }
[ "private", "WMenu", "buildTreeMenu", "(", "final", "WText", "selectedMenuText", ")", "{", "WMenu", "menu", "=", "new", "WMenu", "(", "WMenu", ".", "MenuType", ".", "TREE", ")", ";", "menu", ".", "setSelectMode", "(", "SelectMode", ".", "SINGLE", ")", ";", "mapTreeHierarchy", "(", "menu", ",", "createExampleHierarchy", "(", ")", ",", "selectedMenuText", ")", ";", "return", "menu", ";", "}" ]
Builds up a tree menu for inclusion in the example. @param selectedMenuText the WText to display the selected menu item. @return a tree menu for the example.
[ "Builds", "up", "a", "tree", "menu", "for", "inclusion", "in", "the", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/TreeMenuExample.java#L55-L62
138,831
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/TreeMenuExample.java
TreeMenuExample.mapTreeHierarchy
private void mapTreeHierarchy(final WComponent currentComponent, final StringTreeNode currentNode, final WText selectedMenuText) { if (currentNode.isLeaf()) { WMenuItem menuItem = new WMenuItem(currentNode.getData(), new ExampleMenuAction( selectedMenuText)); menuItem.setActionObject(currentNode.getData()); if (currentComponent instanceof WMenu) { ((WMenu) currentComponent).add(menuItem); } else { ((WSubMenu) currentComponent).add(menuItem); } } else { WSubMenu subMenu = new WSubMenu(currentNode.getData()); subMenu.setSelectMode(SelectMode.SINGLE); if (currentComponent instanceof WMenu) { ((WMenu) currentComponent).add(subMenu); } else { ((WSubMenu) currentComponent).add(subMenu); } // Expand the first couple of levels in the tree by default. if (currentNode.getLevel() < 2) { subMenu.setOpen(true); } for (Iterator<TreeNode> i = currentNode.children(); i.hasNext();) { mapTreeHierarchy(subMenu, (StringTreeNode) i.next(), selectedMenuText); } } }
java
private void mapTreeHierarchy(final WComponent currentComponent, final StringTreeNode currentNode, final WText selectedMenuText) { if (currentNode.isLeaf()) { WMenuItem menuItem = new WMenuItem(currentNode.getData(), new ExampleMenuAction( selectedMenuText)); menuItem.setActionObject(currentNode.getData()); if (currentComponent instanceof WMenu) { ((WMenu) currentComponent).add(menuItem); } else { ((WSubMenu) currentComponent).add(menuItem); } } else { WSubMenu subMenu = new WSubMenu(currentNode.getData()); subMenu.setSelectMode(SelectMode.SINGLE); if (currentComponent instanceof WMenu) { ((WMenu) currentComponent).add(subMenu); } else { ((WSubMenu) currentComponent).add(subMenu); } // Expand the first couple of levels in the tree by default. if (currentNode.getLevel() < 2) { subMenu.setOpen(true); } for (Iterator<TreeNode> i = currentNode.children(); i.hasNext();) { mapTreeHierarchy(subMenu, (StringTreeNode) i.next(), selectedMenuText); } } }
[ "private", "void", "mapTreeHierarchy", "(", "final", "WComponent", "currentComponent", ",", "final", "StringTreeNode", "currentNode", ",", "final", "WText", "selectedMenuText", ")", "{", "if", "(", "currentNode", ".", "isLeaf", "(", ")", ")", "{", "WMenuItem", "menuItem", "=", "new", "WMenuItem", "(", "currentNode", ".", "getData", "(", ")", ",", "new", "ExampleMenuAction", "(", "selectedMenuText", ")", ")", ";", "menuItem", ".", "setActionObject", "(", "currentNode", ".", "getData", "(", ")", ")", ";", "if", "(", "currentComponent", "instanceof", "WMenu", ")", "{", "(", "(", "WMenu", ")", "currentComponent", ")", ".", "add", "(", "menuItem", ")", ";", "}", "else", "{", "(", "(", "WSubMenu", ")", "currentComponent", ")", ".", "add", "(", "menuItem", ")", ";", "}", "}", "else", "{", "WSubMenu", "subMenu", "=", "new", "WSubMenu", "(", "currentNode", ".", "getData", "(", ")", ")", ";", "subMenu", ".", "setSelectMode", "(", "SelectMode", ".", "SINGLE", ")", ";", "if", "(", "currentComponent", "instanceof", "WMenu", ")", "{", "(", "(", "WMenu", ")", "currentComponent", ")", ".", "add", "(", "subMenu", ")", ";", "}", "else", "{", "(", "(", "WSubMenu", ")", "currentComponent", ")", ".", "add", "(", "subMenu", ")", ";", "}", "// Expand the first couple of levels in the tree by default.", "if", "(", "currentNode", ".", "getLevel", "(", ")", "<", "2", ")", "{", "subMenu", ".", "setOpen", "(", "true", ")", ";", "}", "for", "(", "Iterator", "<", "TreeNode", ">", "i", "=", "currentNode", ".", "children", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "mapTreeHierarchy", "(", "subMenu", ",", "(", "StringTreeNode", ")", "i", ".", "next", "(", ")", ",", "selectedMenuText", ")", ";", "}", "}", "}" ]
Recursively maps a tree hierarchy to a hierarchical menu. @param currentComponent the current component in the menu. @param currentNode the current node in the tree. @param selectedMenuText the WText to display the selected menu item.
[ "Recursively", "maps", "a", "tree", "hierarchy", "to", "a", "hierarchical", "menu", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/TreeMenuExample.java#L71-L101
138,832
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/TreeMenuExample.java
TreeMenuExample.createExampleHierarchy
private static StringTreeNode createExampleHierarchy() { StringTreeNode root = new StringTreeNode(Object.class.getName()); Map<String, StringTreeNode> nodeMap = new HashMap<>(); nodeMap.put(root.getData(), root); // The classes to show in the hierarchy Class<?>[] classes = new Class[]{ WMenu.class, WMenuItem.class, WSubMenu.class, WMenuItemGroup.class, WText.class, WText.class }; for (Class<?> clazz : classes) { StringTreeNode childNode = new StringTreeNode(clazz.getName()); nodeMap.put(childNode.getData(), childNode); for (Class<?> parentClass = clazz.getSuperclass(); parentClass != null; parentClass = parentClass. getSuperclass()) { StringTreeNode parentNode = nodeMap.get(parentClass.getName()); if (parentNode == null) { parentNode = new StringTreeNode(parentClass.getName()); nodeMap.put(parentNode.getData(), parentNode); parentNode.add(childNode); childNode = parentNode; } else { parentNode.add(childNode); // already have this node hierarchy break; } } } return root; }
java
private static StringTreeNode createExampleHierarchy() { StringTreeNode root = new StringTreeNode(Object.class.getName()); Map<String, StringTreeNode> nodeMap = new HashMap<>(); nodeMap.put(root.getData(), root); // The classes to show in the hierarchy Class<?>[] classes = new Class[]{ WMenu.class, WMenuItem.class, WSubMenu.class, WMenuItemGroup.class, WText.class, WText.class }; for (Class<?> clazz : classes) { StringTreeNode childNode = new StringTreeNode(clazz.getName()); nodeMap.put(childNode.getData(), childNode); for (Class<?> parentClass = clazz.getSuperclass(); parentClass != null; parentClass = parentClass. getSuperclass()) { StringTreeNode parentNode = nodeMap.get(parentClass.getName()); if (parentNode == null) { parentNode = new StringTreeNode(parentClass.getName()); nodeMap.put(parentNode.getData(), parentNode); parentNode.add(childNode); childNode = parentNode; } else { parentNode.add(childNode); // already have this node hierarchy break; } } } return root; }
[ "private", "static", "StringTreeNode", "createExampleHierarchy", "(", ")", "{", "StringTreeNode", "root", "=", "new", "StringTreeNode", "(", "Object", ".", "class", ".", "getName", "(", ")", ")", ";", "Map", "<", "String", ",", "StringTreeNode", ">", "nodeMap", "=", "new", "HashMap", "<>", "(", ")", ";", "nodeMap", ".", "put", "(", "root", ".", "getData", "(", ")", ",", "root", ")", ";", "// The classes to show in the hierarchy", "Class", "<", "?", ">", "[", "]", "classes", "=", "new", "Class", "[", "]", "{", "WMenu", ".", "class", ",", "WMenuItem", ".", "class", ",", "WSubMenu", ".", "class", ",", "WMenuItemGroup", ".", "class", ",", "WText", ".", "class", ",", "WText", ".", "class", "}", ";", "for", "(", "Class", "<", "?", ">", "clazz", ":", "classes", ")", "{", "StringTreeNode", "childNode", "=", "new", "StringTreeNode", "(", "clazz", ".", "getName", "(", ")", ")", ";", "nodeMap", ".", "put", "(", "childNode", ".", "getData", "(", ")", ",", "childNode", ")", ";", "for", "(", "Class", "<", "?", ">", "parentClass", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "parentClass", "!=", "null", ";", "parentClass", "=", "parentClass", ".", "getSuperclass", "(", ")", ")", "{", "StringTreeNode", "parentNode", "=", "nodeMap", ".", "get", "(", "parentClass", ".", "getName", "(", ")", ")", ";", "if", "(", "parentNode", "==", "null", ")", "{", "parentNode", "=", "new", "StringTreeNode", "(", "parentClass", ".", "getName", "(", ")", ")", ";", "nodeMap", ".", "put", "(", "parentNode", ".", "getData", "(", ")", ",", "parentNode", ")", ";", "parentNode", ".", "add", "(", "childNode", ")", ";", "childNode", "=", "parentNode", ";", "}", "else", "{", "parentNode", ".", "add", "(", "childNode", ")", ";", "// already have this node hierarchy", "break", ";", "}", "}", "}", "return", "root", ";", "}" ]
Creates an example hierarchy, showing the WMenu API. @return the root of the tree.
[ "Creates", "an", "example", "hierarchy", "showing", "the", "WMenu", "API", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/TreeMenuExample.java#L108-L144
138,833
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDefinitionList.java
WDefinitionList.addTerm
public void addTerm(final String term, final WComponent... data) { for (WComponent component : data) { if (component != null) { content.add(component, term); } } // If the term doesn't exist, we may need to add a dummy component if (getComponentsForTerm(term).isEmpty()) { content.add(new DefaultWComponent(), term); } }
java
public void addTerm(final String term, final WComponent... data) { for (WComponent component : data) { if (component != null) { content.add(component, term); } } // If the term doesn't exist, we may need to add a dummy component if (getComponentsForTerm(term).isEmpty()) { content.add(new DefaultWComponent(), term); } }
[ "public", "void", "addTerm", "(", "final", "String", "term", ",", "final", "WComponent", "...", "data", ")", "{", "for", "(", "WComponent", "component", ":", "data", ")", "{", "if", "(", "component", "!=", "null", ")", "{", "content", ".", "add", "(", "component", ",", "term", ")", ";", "}", "}", "// If the term doesn't exist, we may need to add a dummy component", "if", "(", "getComponentsForTerm", "(", "term", ")", ".", "isEmpty", "(", ")", ")", "{", "content", ".", "add", "(", "new", "DefaultWComponent", "(", ")", ",", "term", ")", ";", "}", "}" ]
Adds a term to this definition list. If there is an existing term, the component is added to the list of data for the term. @param term the term to add. @param data the term data.
[ "Adds", "a", "term", "to", "this", "definition", "list", ".", "If", "there", "is", "an", "existing", "term", "the", "component", "is", "added", "to", "the", "list", "of", "data", "for", "the", "term", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDefinitionList.java#L102-L113
138,834
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDefinitionList.java
WDefinitionList.getTerms
public List<Duplet<String, ArrayList<WComponent>>> getTerms() { Map<String, Duplet<String, ArrayList<WComponent>>> componentsByTerm = new HashMap<>(); List<Duplet<String, ArrayList<WComponent>>> result = new ArrayList<>(); List<WComponent> childList = content.getComponentModel().getChildren(); if (childList != null) { for (int i = 0; i < childList.size(); i++) { WComponent child = childList.get(i); String term = child.getTag(); Duplet<String, ArrayList<WComponent>> termComponents = componentsByTerm.get(term); if (termComponents == null) { termComponents = new Duplet<>(term, new ArrayList<WComponent>()); componentsByTerm.put(term, termComponents); result.add(termComponents); } termComponents.getSecond().add(child); } } return result; }
java
public List<Duplet<String, ArrayList<WComponent>>> getTerms() { Map<String, Duplet<String, ArrayList<WComponent>>> componentsByTerm = new HashMap<>(); List<Duplet<String, ArrayList<WComponent>>> result = new ArrayList<>(); List<WComponent> childList = content.getComponentModel().getChildren(); if (childList != null) { for (int i = 0; i < childList.size(); i++) { WComponent child = childList.get(i); String term = child.getTag(); Duplet<String, ArrayList<WComponent>> termComponents = componentsByTerm.get(term); if (termComponents == null) { termComponents = new Duplet<>(term, new ArrayList<WComponent>()); componentsByTerm.put(term, termComponents); result.add(termComponents); } termComponents.getSecond().add(child); } } return result; }
[ "public", "List", "<", "Duplet", "<", "String", ",", "ArrayList", "<", "WComponent", ">", ">", ">", "getTerms", "(", ")", "{", "Map", "<", "String", ",", "Duplet", "<", "String", ",", "ArrayList", "<", "WComponent", ">", ">", ">", "componentsByTerm", "=", "new", "HashMap", "<>", "(", ")", ";", "List", "<", "Duplet", "<", "String", ",", "ArrayList", "<", "WComponent", ">", ">", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "WComponent", ">", "childList", "=", "content", ".", "getComponentModel", "(", ")", ".", "getChildren", "(", ")", ";", "if", "(", "childList", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "WComponent", "child", "=", "childList", ".", "get", "(", "i", ")", ";", "String", "term", "=", "child", ".", "getTag", "(", ")", ";", "Duplet", "<", "String", ",", "ArrayList", "<", "WComponent", ">", ">", "termComponents", "=", "componentsByTerm", ".", "get", "(", "term", ")", ";", "if", "(", "termComponents", "==", "null", ")", "{", "termComponents", "=", "new", "Duplet", "<>", "(", "term", ",", "new", "ArrayList", "<", "WComponent", ">", "(", ")", ")", ";", "componentsByTerm", ".", "put", "(", "term", ",", "termComponents", ")", ";", "result", ".", "add", "(", "termComponents", ")", ";", "}", "termComponents", ".", "getSecond", "(", ")", ".", "add", "(", "child", ")", ";", "}", "}", "return", "result", ";", "}" ]
Groups a definition list's child components by their term for rendering. @return a list of this definition list's children grouped by their terms.
[ "Groups", "a", "definition", "list", "s", "child", "components", "by", "their", "term", "for", "rendering", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDefinitionList.java#L139-L164
138,835
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDefinitionList.java
WDefinitionList.getComponentsForTerm
private List<WComponent> getComponentsForTerm(final String term) { List<WComponent> childList = content.getComponentModel().getChildren(); List<WComponent> result = new ArrayList<>(); if (childList != null) { for (int i = 0; i < childList.size(); i++) { WComponent child = childList.get(i); if (term.equals(child.getTag())) { result.add(child); } } } return result; }
java
private List<WComponent> getComponentsForTerm(final String term) { List<WComponent> childList = content.getComponentModel().getChildren(); List<WComponent> result = new ArrayList<>(); if (childList != null) { for (int i = 0; i < childList.size(); i++) { WComponent child = childList.get(i); if (term.equals(child.getTag())) { result.add(child); } } } return result; }
[ "private", "List", "<", "WComponent", ">", "getComponentsForTerm", "(", "final", "String", "term", ")", "{", "List", "<", "WComponent", ">", "childList", "=", "content", ".", "getComponentModel", "(", ")", ".", "getChildren", "(", ")", ";", "List", "<", "WComponent", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "childList", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "WComponent", "child", "=", "childList", ".", "get", "(", "i", ")", ";", "if", "(", "term", ".", "equals", "(", "child", ".", "getTag", "(", ")", ")", ")", "{", "result", ".", "add", "(", "child", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Retrieves the components for the given term. @param term the term of the children to be retrieved. @return the child components for the given term, may be empty.
[ "Retrieves", "the", "components", "for", "the", "given", "term", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDefinitionList.java#L172-L187
138,836
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/Message.java
Message.setArgs
public void setArgs(final Serializable... args) { this.args = args == null || args.length == 0 ? null : args; }
java
public void setArgs(final Serializable... args) { this.args = args == null || args.length == 0 ? null : args; }
[ "public", "void", "setArgs", "(", "final", "Serializable", "...", "args", ")", "{", "this", ".", "args", "=", "args", "==", "null", "||", "args", ".", "length", "==", "0", "?", "null", ":", "args", ";", "}" ]
Sets the message format arguments. @param args the message arguments.
[ "Sets", "the", "message", "format", "arguments", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/Message.java#L88-L90
138,837
podio/podio-java
src/main/java/com/podio/contact/ContactAPI.java
ContactAPI.addSpaceContact
public int addSpaceContact(int spaceId, ContactCreate create, boolean silent) { return getResourceFactory().getApiResource("/contact/space/" + spaceId + "/") .queryParam("silent", silent ? "1" : "0") .entity(create, MediaType.APPLICATION_JSON_TYPE) .post(ContactCreateResponse.class).getId(); }
java
public int addSpaceContact(int spaceId, ContactCreate create, boolean silent) { return getResourceFactory().getApiResource("/contact/space/" + spaceId + "/") .queryParam("silent", silent ? "1" : "0") .entity(create, MediaType.APPLICATION_JSON_TYPE) .post(ContactCreateResponse.class).getId(); }
[ "public", "int", "addSpaceContact", "(", "int", "spaceId", ",", "ContactCreate", "create", ",", "boolean", "silent", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/contact/space/\"", "+", "spaceId", "+", "\"/\"", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "create", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", "ContactCreateResponse", ".", "class", ")", ".", "getId", "(", ")", ";", "}" ]
Adds a new contact to the given space. @param spaceId The id of the space the contact should be added to @param create The data for the new contact @param silent True if the create should be silent, false otherwise @return The id of the newly created contact
[ "Adds", "a", "new", "contact", "to", "the", "given", "space", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/contact/ContactAPI.java#L40-L45
138,838
podio/podio-java
src/main/java/com/podio/contact/ContactAPI.java
ContactAPI.updateSpaceContact
public void updateSpaceContact(int profileId, ContactUpdate update, boolean silent, boolean hook) { getResourceFactory().getApiResource("/contact/" + profileId) .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); }
java
public void updateSpaceContact(int profileId, ContactUpdate update, boolean silent, boolean hook) { getResourceFactory().getApiResource("/contact/" + profileId) .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); }
[ "public", "void", "updateSpaceContact", "(", "int", "profileId", ",", "ContactUpdate", "update", ",", "boolean", "silent", ",", "boolean", "hook", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/contact/\"", "+", "profileId", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "queryParam", "(", "\"hook\"", ",", "hook", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "update", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Updates the entire space contact. Only fields which have values specified will be updated. To delete the contents of a field, pass an empty array for the value. @param profileId The id of the space contact to be updated @param update The data for the update @param silent True if the update should be silent, false otherwise @param hook True if hooks should be executed for the change, false otherwise
[ "Updates", "the", "entire", "space", "contact", ".", "Only", "fields", "which", "have", "values", "specified", "will", "be", "updated", ".", "To", "delete", "the", "contents", "of", "a", "field", "pass", "an", "empty", "array", "for", "the", "value", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/contact/ContactAPI.java#L61-L66
138,839
podio/podio-java
src/main/java/com/podio/contact/ContactAPI.java
ContactAPI.getContacts
public <T, F, R> List<T> getContacts(ProfileField<F, R> key, F value, Integer limit, Integer offset, ProfileType<T> type, ContactOrder order, ContactType contactType) { WebResource resource = getResourceFactory().getApiResource("/contact/"); return getContactsCommon(resource, key, value, limit, offset, type, order, contactType); }
java
public <T, F, R> List<T> getContacts(ProfileField<F, R> key, F value, Integer limit, Integer offset, ProfileType<T> type, ContactOrder order, ContactType contactType) { WebResource resource = getResourceFactory().getApiResource("/contact/"); return getContactsCommon(resource, key, value, limit, offset, type, order, contactType); }
[ "public", "<", "T", ",", "F", ",", "R", ">", "List", "<", "T", ">", "getContacts", "(", "ProfileField", "<", "F", ",", "R", ">", "key", ",", "F", "value", ",", "Integer", "limit", ",", "Integer", "offset", ",", "ProfileType", "<", "T", ">", "type", ",", "ContactOrder", "order", ",", "ContactType", "contactType", ")", "{", "WebResource", "resource", "=", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/contact/\"", ")", ";", "return", "getContactsCommon", "(", "resource", ",", "key", ",", "value", ",", "limit", ",", "offset", ",", "type", ",", "order", ",", "contactType", ")", ";", "}" ]
Used to get a list of contacts for the user. @param key The profile field if the contacts should be filtered @param value The value for the field if the contacts should be filtered @param limit The maximum number of contacts to return @param offset The offset into the list of contacts @param type The format in which the contacts should be returned @param order How the contacts should be ordered @param contactType The type of contacts to be returned @return The list of contacts
[ "Used", "to", "get", "a", "list", "of", "contacts", "for", "the", "user", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/contact/ContactAPI.java#L147-L154
138,840
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImage.java
WImage.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) { ContentEscape escape = new ContentEscape(getImage()); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } }
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) { ContentEscape escape = new ContentEscape(getImage()); escape.setCacheable(!Util.empty(getCacheKey())); throw escape; } }
[ "@", "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", ")", "{", "ContentEscape", "escape", "=", "new", "ContentEscape", "(", "getImage", "(", ")", ")", ";", "escape", ".", "setCacheable", "(", "!", "Util", ".", "empty", "(", "getCacheKey", "(", ")", ")", ")", ";", "throw", "escape", ";", "}", "}" ]
When an img element is included in the html output of a page, the browser will make a second request to get the image contents. The handleRequest method has been overridden to detect whether the request is the "image content fetch" request by looking for the parameter that we encode in the image url. @param request the request being responded to.
[ "When", "an", "img", "element", "is", "included", "in", "the", "html", "output", "of", "a", "page", "the", "browser", "will", "make", "a", "second", "request", "to", "get", "the", "image", "contents", ".", "The", "handleRequest", "method", "has", "been", "overridden", "to", "detect", "whether", "the", "request", "is", "the", "image", "content", "fetch", "request", "by", "looking", "for", "the", "parameter", "that", "we", "encode", "in", "the", "image", "url", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImage.java#L131-L143
138,841
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImage.java
WImage.setImage
public void setImage(final Image image) { ImageModel model = getOrCreateComponentModel(); model.image = image; model.imageUrl = null; }
java
public void setImage(final Image image) { ImageModel model = getOrCreateComponentModel(); model.image = image; model.imageUrl = null; }
[ "public", "void", "setImage", "(", "final", "Image", "image", ")", "{", "ImageModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "image", "=", "image", ";", "model", ".", "imageUrl", "=", "null", ";", "}" ]
Sets the image. @param image the image to set.
[ "Sets", "the", "image", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImage.java#L150-L154
138,842
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImage.java
WImage.setImageUrl
public void setImageUrl(final String imageUrl) { ImageModel model = getOrCreateComponentModel(); model.imageUrl = imageUrl; model.image = null; }
java
public void setImageUrl(final String imageUrl) { ImageModel model = getOrCreateComponentModel(); model.imageUrl = imageUrl; model.image = null; }
[ "public", "void", "setImageUrl", "(", "final", "String", "imageUrl", ")", "{", "ImageModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "imageUrl", "=", "imageUrl", ";", "model", ".", "image", "=", "null", ";", "}" ]
Sets the image to an external URL. @param imageUrl the image URL.
[ "Sets", "the", "image", "to", "an", "external", "URL", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImage.java#L161-L165
138,843
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WRadioButtonSelectRenderer.java
WRadioButtonSelectRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WRadioButtonSelect rbSelect = (WRadioButtonSelect) component; XmlStringBuilder xml = renderContext.getWriter(); int cols = rbSelect.getButtonColumns(); boolean readOnly = rbSelect.isReadOnly(); xml.appendTagOpen("ui:radiobuttonselect"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", rbSelect.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { xml.appendOptionalAttribute("disabled", rbSelect.isDisabled(), "true"); xml.appendOptionalAttribute("required", rbSelect.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", rbSelect.isSubmitOnChange(), "true"); xml.appendOptionalAttribute("toolTip", component.getToolTip()); xml.appendOptionalAttribute("accessibleText", component.getAccessibleText()); } xml.appendOptionalAttribute("frameless", rbSelect.isFrameless(), "true"); switch (rbSelect.getButtonLayout()) { case COLUMNS: xml.appendAttribute("layout", "column"); xml.appendOptionalAttribute("layoutColumnCount", cols > 0, String.valueOf(cols)); break; case FLAT: xml.appendAttribute("layout", "flat"); break; case STACKED: xml.appendAttribute("layout", "stacked"); break; default: throw new SystemException("Unknown radio button layout: " + rbSelect.getButtonLayout()); } xml.appendClose(); // Options List<?> options = rbSelect.getOptions(); boolean renderSelectionsOnly = readOnly; if (options != null) { int optionIndex = 0; Object selectedOption = rbSelect.getSelected(); for (Object option : options) { if (option instanceof OptionGroup) { throw new SystemException("Option groups not supported in WRadioButtonSelect."); } else { renderOption(rbSelect, option, optionIndex++, xml, selectedOption, renderSelectionsOnly); } } } if (!readOnly) { DiagnosticRenderUtil.renderDiagnostics(rbSelect, renderContext); } xml.appendEndTag("ui:radiobuttonselect"); if (rbSelect.isAjax()) { paintAjax(rbSelect, xml); } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WRadioButtonSelect rbSelect = (WRadioButtonSelect) component; XmlStringBuilder xml = renderContext.getWriter(); int cols = rbSelect.getButtonColumns(); boolean readOnly = rbSelect.isReadOnly(); xml.appendTagOpen("ui:radiobuttonselect"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", rbSelect.isHidden(), "true"); if (readOnly) { xml.appendAttribute("readOnly", "true"); } else { xml.appendOptionalAttribute("disabled", rbSelect.isDisabled(), "true"); xml.appendOptionalAttribute("required", rbSelect.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", rbSelect.isSubmitOnChange(), "true"); xml.appendOptionalAttribute("toolTip", component.getToolTip()); xml.appendOptionalAttribute("accessibleText", component.getAccessibleText()); } xml.appendOptionalAttribute("frameless", rbSelect.isFrameless(), "true"); switch (rbSelect.getButtonLayout()) { case COLUMNS: xml.appendAttribute("layout", "column"); xml.appendOptionalAttribute("layoutColumnCount", cols > 0, String.valueOf(cols)); break; case FLAT: xml.appendAttribute("layout", "flat"); break; case STACKED: xml.appendAttribute("layout", "stacked"); break; default: throw new SystemException("Unknown radio button layout: " + rbSelect.getButtonLayout()); } xml.appendClose(); // Options List<?> options = rbSelect.getOptions(); boolean renderSelectionsOnly = readOnly; if (options != null) { int optionIndex = 0; Object selectedOption = rbSelect.getSelected(); for (Object option : options) { if (option instanceof OptionGroup) { throw new SystemException("Option groups not supported in WRadioButtonSelect."); } else { renderOption(rbSelect, option, optionIndex++, xml, selectedOption, renderSelectionsOnly); } } } if (!readOnly) { DiagnosticRenderUtil.renderDiagnostics(rbSelect, renderContext); } xml.appendEndTag("ui:radiobuttonselect"); if (rbSelect.isAjax()) { paintAjax(rbSelect, xml); } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WRadioButtonSelect", "rbSelect", "=", "(", "WRadioButtonSelect", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "int", "cols", "=", "rbSelect", ".", "getButtonColumns", "(", ")", ";", "boolean", "readOnly", "=", "rbSelect", ".", "isReadOnly", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:radiobuttonselect\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "rbSelect", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "readOnly", ")", "{", "xml", ".", "appendAttribute", "(", "\"readOnly\"", ",", "\"true\"", ")", ";", "}", "else", "{", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "rbSelect", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"required\"", ",", "rbSelect", ".", "isMandatory", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"submitOnChange\"", ",", "rbSelect", ".", "isSubmitOnChange", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"toolTip\"", ",", "component", ".", "getToolTip", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessibleText\"", ",", "component", ".", "getAccessibleText", "(", ")", ")", ";", "}", "xml", ".", "appendOptionalAttribute", "(", "\"frameless\"", ",", "rbSelect", ".", "isFrameless", "(", ")", ",", "\"true\"", ")", ";", "switch", "(", "rbSelect", ".", "getButtonLayout", "(", ")", ")", "{", "case", "COLUMNS", ":", "xml", ".", "appendAttribute", "(", "\"layout\"", ",", "\"column\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"layoutColumnCount\"", ",", "cols", ">", "0", ",", "String", ".", "valueOf", "(", "cols", ")", ")", ";", "break", ";", "case", "FLAT", ":", "xml", ".", "appendAttribute", "(", "\"layout\"", ",", "\"flat\"", ")", ";", "break", ";", "case", "STACKED", ":", "xml", ".", "appendAttribute", "(", "\"layout\"", ",", "\"stacked\"", ")", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown radio button layout: \"", "+", "rbSelect", ".", "getButtonLayout", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "// Options", "List", "<", "?", ">", "options", "=", "rbSelect", ".", "getOptions", "(", ")", ";", "boolean", "renderSelectionsOnly", "=", "readOnly", ";", "if", "(", "options", "!=", "null", ")", "{", "int", "optionIndex", "=", "0", ";", "Object", "selectedOption", "=", "rbSelect", ".", "getSelected", "(", ")", ";", "for", "(", "Object", "option", ":", "options", ")", "{", "if", "(", "option", "instanceof", "OptionGroup", ")", "{", "throw", "new", "SystemException", "(", "\"Option groups not supported in WRadioButtonSelect.\"", ")", ";", "}", "else", "{", "renderOption", "(", "rbSelect", ",", "option", ",", "optionIndex", "++", ",", "xml", ",", "selectedOption", ",", "renderSelectionsOnly", ")", ";", "}", "}", "}", "if", "(", "!", "readOnly", ")", "{", "DiagnosticRenderUtil", ".", "renderDiagnostics", "(", "rbSelect", ",", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:radiobuttonselect\"", ")", ";", "if", "(", "rbSelect", ".", "isAjax", "(", ")", ")", "{", "paintAjax", "(", "rbSelect", ",", "xml", ")", ";", "}", "}" ]
Paints the given WRadioButtonSelect. @param component the WRadioButtonSelect to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WRadioButtonSelect", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WRadioButtonSelectRenderer.java#L26-L91
138,844
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WRadioButtonSelectRenderer.java
WRadioButtonSelectRenderer.paintAjax
private void paintAjax(final WRadioButtonSelect rbSelect, final XmlStringBuilder xml) { // Start tag xml.appendTagOpen("ui:ajaxtrigger"); xml.appendAttribute("triggerId", rbSelect.getId()); xml.appendClose(); // Target xml.appendTagOpen("ui:ajaxtargetid"); xml.appendAttribute("targetId", rbSelect.getAjaxTarget().getId()); xml.appendEnd(); // End tag xml.appendEndTag("ui:ajaxtrigger"); }
java
private void paintAjax(final WRadioButtonSelect rbSelect, final XmlStringBuilder xml) { // Start tag xml.appendTagOpen("ui:ajaxtrigger"); xml.appendAttribute("triggerId", rbSelect.getId()); xml.appendClose(); // Target xml.appendTagOpen("ui:ajaxtargetid"); xml.appendAttribute("targetId", rbSelect.getAjaxTarget().getId()); xml.appendEnd(); // End tag xml.appendEndTag("ui:ajaxtrigger"); }
[ "private", "void", "paintAjax", "(", "final", "WRadioButtonSelect", "rbSelect", ",", "final", "XmlStringBuilder", "xml", ")", "{", "// Start tag", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxtrigger\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"triggerId\"", ",", "rbSelect", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Target", "xml", ".", "appendTagOpen", "(", "\"ui:ajaxtargetid\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"targetId\"", ",", "rbSelect", ".", "getAjaxTarget", "(", ")", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "// End tag", "xml", ".", "appendEndTag", "(", "\"ui:ajaxtrigger\"", ")", ";", "}" ]
Paints the AJAX information for the given WRadioButtonSelect. @param rbSelect the WRadioButtonSelect to paint. @param xml the XmlStringBuilder to paint to.
[ "Paints", "the", "AJAX", "information", "for", "the", "given", "WRadioButtonSelect", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WRadioButtonSelectRenderer.java#L133-L146
138,845
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java
WBeanComponent.setBean
@Override public void setBean(final Object bean) { BeanAndProviderBoundComponentModel model = getOrCreateComponentModel(); model.setBean(bean); if (getBeanProperty() == null) { setBeanProperty("."); } // Remove values in scratch map removeBeanFromScratchMap(); }
java
@Override public void setBean(final Object bean) { BeanAndProviderBoundComponentModel model = getOrCreateComponentModel(); model.setBean(bean); if (getBeanProperty() == null) { setBeanProperty("."); } // Remove values in scratch map removeBeanFromScratchMap(); }
[ "@", "Override", "public", "void", "setBean", "(", "final", "Object", "bean", ")", "{", "BeanAndProviderBoundComponentModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "setBean", "(", "bean", ")", ";", "if", "(", "getBeanProperty", "(", ")", "==", "null", ")", "{", "setBeanProperty", "(", "\".\"", ")", ";", "}", "// Remove values in scratch map", "removeBeanFromScratchMap", "(", ")", ";", "}" ]
Sets the bean associated with this WBeanComponent. This method of bean association is discouraged, as the bean will be stored in the user's session. A better alternative is to provide a BeanProvider and a Bean Id. @param bean the bean to associate
[ "Sets", "the", "bean", "associated", "with", "this", "WBeanComponent", ".", "This", "method", "of", "bean", "association", "is", "discouraged", "as", "the", "bean", "will", "be", "stored", "in", "the", "user", "s", "session", ".", "A", "better", "alternative", "is", "to", "provide", "a", "BeanProvider", "and", "a", "Bean", "Id", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java#L122-L132
138,846
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java
WBeanComponent.setBeanId
@Override public void setBeanId(final Object beanId) { BeanAndProviderBoundComponentModel model = getOrCreateComponentModel(); model.setBeanId(beanId); // Remove values in scratch map removeBeanFromScratchMap(); }
java
@Override public void setBeanId(final Object beanId) { BeanAndProviderBoundComponentModel model = getOrCreateComponentModel(); model.setBeanId(beanId); // Remove values in scratch map removeBeanFromScratchMap(); }
[ "@", "Override", "public", "void", "setBeanId", "(", "final", "Object", "beanId", ")", "{", "BeanAndProviderBoundComponentModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "setBeanId", "(", "beanId", ")", ";", "// Remove values in scratch map", "removeBeanFromScratchMap", "(", ")", ";", "}" ]
Sets the bean id associated with this WBeanComponent. This bean id will be used to obtain the bean from the associated {@link BeanProvider} whenever the bean data is required. @see BeanProviderBound @param beanId the bean id to associate
[ "Sets", "the", "bean", "id", "associated", "with", "this", "WBeanComponent", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java#L144-L150
138,847
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java
WBeanComponent.setBeanProperty
@Override public void setBeanProperty(final String propertyName) { String currBeanProperty = getBeanProperty(); if (!Objects.equals(propertyName, currBeanProperty)) { getOrCreateComponentModel().setBeanProperty(propertyName); } }
java
@Override public void setBeanProperty(final String propertyName) { String currBeanProperty = getBeanProperty(); if (!Objects.equals(propertyName, currBeanProperty)) { getOrCreateComponentModel().setBeanProperty(propertyName); } }
[ "@", "Override", "public", "void", "setBeanProperty", "(", "final", "String", "propertyName", ")", "{", "String", "currBeanProperty", "=", "getBeanProperty", "(", ")", ";", "if", "(", "!", "Objects", ".", "equals", "(", "propertyName", ",", "currBeanProperty", ")", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "setBeanProperty", "(", "propertyName", ")", ";", "}", "}" ]
Sets the bean property that this component is interested in. The bean property is expressed in Jakarta PropertyUtils bean notation, with an extension of "." to indicate that the bean itself should be used. @param propertyName the bean property, in Jakarta PropertyUtils bean notation
[ "Sets", "the", "bean", "property", "that", "this", "component", "is", "interested", "in", ".", "The", "bean", "property", "is", "expressed", "in", "Jakarta", "PropertyUtils", "bean", "notation", "with", "an", "extension", "of", ".", "to", "indicate", "that", "the", "bean", "itself", "should", "be", "used", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java#L170-L177
138,848
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java
WBeanComponent.doUpdateBeanValue
protected void doUpdateBeanValue(final Object value) { String beanProperty = getBeanProperty(); if (beanProperty != null && beanProperty.length() > 0 && !".".equals(beanProperty)) { Object bean = getBean(); if (bean != null) { try { Object beanValue = getBeanValue(); if (!Util.equals(beanValue, value)) { PropertyUtils.setProperty(bean, beanProperty, value); } } catch (Exception e) { LOG.error("Failed to set bean property " + beanProperty + " on " + bean); } } } }
java
protected void doUpdateBeanValue(final Object value) { String beanProperty = getBeanProperty(); if (beanProperty != null && beanProperty.length() > 0 && !".".equals(beanProperty)) { Object bean = getBean(); if (bean != null) { try { Object beanValue = getBeanValue(); if (!Util.equals(beanValue, value)) { PropertyUtils.setProperty(bean, beanProperty, value); } } catch (Exception e) { LOG.error("Failed to set bean property " + beanProperty + " on " + bean); } } } }
[ "protected", "void", "doUpdateBeanValue", "(", "final", "Object", "value", ")", "{", "String", "beanProperty", "=", "getBeanProperty", "(", ")", ";", "if", "(", "beanProperty", "!=", "null", "&&", "beanProperty", ".", "length", "(", ")", ">", "0", "&&", "!", "\".\"", ".", "equals", "(", "beanProperty", ")", ")", "{", "Object", "bean", "=", "getBean", "(", ")", ";", "if", "(", "bean", "!=", "null", ")", "{", "try", "{", "Object", "beanValue", "=", "getBeanValue", "(", ")", ";", "if", "(", "!", "Util", ".", "equals", "(", "beanValue", ",", "value", ")", ")", "{", "PropertyUtils", ".", "setProperty", "(", "bean", ",", "beanProperty", ",", "value", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to set bean property \"", "+", "beanProperty", "+", "\" on \"", "+", "bean", ")", ";", "}", "}", "}", "}" ]
Updates the bean value with the new value. @param value the new value with which to update the bean
[ "Updates", "the", "bean", "value", "with", "the", "new", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java#L331-L346
138,849
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java
WBeanComponent.removeBeanFromScratchMap
protected void removeBeanFromScratchMap() { Map<Object, Object> scratchMap = getBeanScratchMap(); if (scratchMap == null) { return; } scratchMap.remove(SCRATCHMAP_BEAN_ID_KEY); scratchMap.remove(SCRATCHMAP_BEAN_OBJECT_KEY); }
java
protected void removeBeanFromScratchMap() { Map<Object, Object> scratchMap = getBeanScratchMap(); if (scratchMap == null) { return; } scratchMap.remove(SCRATCHMAP_BEAN_ID_KEY); scratchMap.remove(SCRATCHMAP_BEAN_OBJECT_KEY); }
[ "protected", "void", "removeBeanFromScratchMap", "(", ")", "{", "Map", "<", "Object", ",", "Object", ">", "scratchMap", "=", "getBeanScratchMap", "(", ")", ";", "if", "(", "scratchMap", "==", "null", ")", "{", "return", ";", "}", "scratchMap", ".", "remove", "(", "SCRATCHMAP_BEAN_ID_KEY", ")", ";", "scratchMap", ".", "remove", "(", "SCRATCHMAP_BEAN_OBJECT_KEY", ")", ";", "}" ]
Remove the bean from the scratch maps.
[ "Remove", "the", "bean", "from", "the", "scratch", "maps", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java#L359-L366
138,850
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java
WBeanComponent.isChanged
public boolean isChanged() { Object currentValue = getData(); Object sharedValue = ((BeanAndProviderBoundComponentModel) getDefaultModel()).getData(); if (getBeanProperty() != null) { sharedValue = getBeanValue(); } return !Util.equals(currentValue, sharedValue); }
java
public boolean isChanged() { Object currentValue = getData(); Object sharedValue = ((BeanAndProviderBoundComponentModel) getDefaultModel()).getData(); if (getBeanProperty() != null) { sharedValue = getBeanValue(); } return !Util.equals(currentValue, sharedValue); }
[ "public", "boolean", "isChanged", "(", ")", "{", "Object", "currentValue", "=", "getData", "(", ")", ";", "Object", "sharedValue", "=", "(", "(", "BeanAndProviderBoundComponentModel", ")", "getDefaultModel", "(", ")", ")", ".", "getData", "(", ")", ";", "if", "(", "getBeanProperty", "(", ")", "!=", "null", ")", "{", "sharedValue", "=", "getBeanValue", "(", ")", ";", "}", "return", "!", "Util", ".", "equals", "(", "currentValue", ",", "sharedValue", ")", ";", "}" ]
Indicates whether this component's data has changed from the default value. TODO: This needs to be added to the databound interface after the bulk of the components have been converted. @return true if this component's current value differs from the default value for the given context.
[ "Indicates", "whether", "this", "component", "s", "data", "has", "changed", "from", "the", "default", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java#L431-L440
138,851
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTabSetRenderer.java
WTabSetRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTabSet tabSet = (WTabSet) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:tabset"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("type", getTypeAsString(tabSet.getType())); xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true"); xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight()); xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true"); xml.appendOptionalAttribute("single", TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(), "true"); if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) { xml.appendOptionalAttribute("groupName", tabSet.getGroupName()); } xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(tabSet, renderContext); paintChildren(tabSet, renderContext); xml.appendEndTag("ui:tabset"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WTabSet tabSet = (WTabSet) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:tabset"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("type", getTypeAsString(tabSet.getType())); xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true"); xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true"); xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight()); xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true"); xml.appendOptionalAttribute("single", TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(), "true"); if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) { xml.appendOptionalAttribute("groupName", tabSet.getGroupName()); } xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(tabSet, renderContext); paintChildren(tabSet, renderContext); xml.appendEndTag("ui:tabset"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WTabSet", "tabSet", "=", "(", "WTabSet", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:tabset\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"type\"", ",", "getTypeAsString", "(", "tabSet", ".", "getType", "(", ")", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"disabled\"", ",", "tabSet", ".", "isDisabled", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "tabSet", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"contentHeight\"", ",", "tabSet", ".", "getContentHeight", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"showHeadOnly\"", ",", "tabSet", ".", "isShowHeadOnly", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"single\"", ",", "TabSetType", ".", "ACCORDION", ".", "equals", "(", "tabSet", ".", "getType", "(", ")", ")", "&&", "tabSet", ".", "isSingle", "(", ")", ",", "\"true\"", ")", ";", "if", "(", "WTabSet", ".", "TabSetType", ".", "ACCORDION", ".", "equals", "(", "tabSet", ".", "getType", "(", ")", ")", ")", "{", "xml", ".", "appendOptionalAttribute", "(", "\"groupName\"", ",", "tabSet", ".", "getGroupName", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "// Render margin", "MarginRendererUtil", ".", "renderMargin", "(", "tabSet", ",", "renderContext", ")", ";", "paintChildren", "(", "tabSet", ",", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:tabset\"", ")", ";", "}" ]
Paints the given WTabSet. @param component the WTabSet to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WTabSet", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTabSetRenderer.java#L24-L52
138,852
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java
RepeaterExampleWithStaticIDs.createUI
private void createUI() { add(new WHeading(HeadingLevel.H2, "Contacts")); add(repeater); createButtonBar(); createAddContactSubForm(); createPrintContactsSubForm(); }
java
private void createUI() { add(new WHeading(HeadingLevel.H2, "Contacts")); add(repeater); createButtonBar(); createAddContactSubForm(); createPrintContactsSubForm(); }
[ "private", "void", "createUI", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"Contacts\"", ")", ")", ";", "add", "(", "repeater", ")", ";", "createButtonBar", "(", ")", ";", "createAddContactSubForm", "(", ")", ";", "createPrintContactsSubForm", "(", ")", ";", "}" ]
Creates the example UI.
[ "Creates", "the", "example", "UI", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java#L108-L114
138,853
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java
RepeaterExampleWithStaticIDs.createButtonBar
private void createButtonBar() { // Update and reset controls for the repeater. WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE); buttonPanel.setMargin(new Margin(Size.MEDIUM, null , Size.LARGE, null)); buttonPanel.setLayout(new BorderLayout()); WButton updateButton = new WButton("Update"); updateButton.setImage("/image/document-save-5.png"); updateButton.setImagePosition(WButton.ImagePosition.EAST); buttonPanel.add(updateButton, BorderLayout.EAST); WButton resetButton = new WButton("Reset"); resetButton.setImage("/image/edit-undo-8.png"); resetButton.setImagePosition(WButton.ImagePosition.WEST); resetButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { repeater.setData(fetchDataList()); } }); buttonPanel.add(resetButton, BorderLayout.WEST); add(buttonPanel); add(new WAjaxControl(updateButton, repeater)); add(new WAjaxControl(resetButton, repeater)); }
java
private void createButtonBar() { // Update and reset controls for the repeater. WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE); buttonPanel.setMargin(new Margin(Size.MEDIUM, null , Size.LARGE, null)); buttonPanel.setLayout(new BorderLayout()); WButton updateButton = new WButton("Update"); updateButton.setImage("/image/document-save-5.png"); updateButton.setImagePosition(WButton.ImagePosition.EAST); buttonPanel.add(updateButton, BorderLayout.EAST); WButton resetButton = new WButton("Reset"); resetButton.setImage("/image/edit-undo-8.png"); resetButton.setImagePosition(WButton.ImagePosition.WEST); resetButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { repeater.setData(fetchDataList()); } }); buttonPanel.add(resetButton, BorderLayout.WEST); add(buttonPanel); add(new WAjaxControl(updateButton, repeater)); add(new WAjaxControl(resetButton, repeater)); }
[ "private", "void", "createButtonBar", "(", ")", "{", "// Update and reset controls for the repeater.", "WPanel", "buttonPanel", "=", "new", "WPanel", "(", "WPanel", ".", "Type", ".", "FEATURE", ")", ";", "buttonPanel", ".", "setMargin", "(", "new", "Margin", "(", "Size", ".", "MEDIUM", ",", "null", ",", "Size", ".", "LARGE", ",", "null", ")", ")", ";", "buttonPanel", ".", "setLayout", "(", "new", "BorderLayout", "(", ")", ")", ";", "WButton", "updateButton", "=", "new", "WButton", "(", "\"Update\"", ")", ";", "updateButton", ".", "setImage", "(", "\"/image/document-save-5.png\"", ")", ";", "updateButton", ".", "setImagePosition", "(", "WButton", ".", "ImagePosition", ".", "EAST", ")", ";", "buttonPanel", ".", "add", "(", "updateButton", ",", "BorderLayout", ".", "EAST", ")", ";", "WButton", "resetButton", "=", "new", "WButton", "(", "\"Reset\"", ")", ";", "resetButton", ".", "setImage", "(", "\"/image/edit-undo-8.png\"", ")", ";", "resetButton", ".", "setImagePosition", "(", "WButton", ".", "ImagePosition", ".", "WEST", ")", ";", "resetButton", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "repeater", ".", "setData", "(", "fetchDataList", "(", ")", ")", ";", "}", "}", ")", ";", "buttonPanel", ".", "add", "(", "resetButton", ",", "BorderLayout", ".", "WEST", ")", ";", "add", "(", "buttonPanel", ")", ";", "add", "(", "new", "WAjaxControl", "(", "updateButton", ",", "repeater", ")", ")", ";", "add", "(", "new", "WAjaxControl", "(", "resetButton", ",", "repeater", ")", ")", ";", "}" ]
Create the UI artefacts for the update and reset buttons.
[ "Create", "the", "UI", "artefacts", "for", "the", "update", "and", "reset", "buttons", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java#L119-L143
138,854
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java
RepeaterExampleWithStaticIDs.createAddContactSubForm
private void createAddContactSubForm() { add(new WHeading(HeadingLevel.H3, "Add a new contact")); WButton addBtn = new WButton("Add"); addBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { addNewContact(); } }); addBtn.setImage("/image/address-book-new.png"); newNameField.setDefaultSubmitButton(addBtn); WContainer container = new WContainer(); container.add(newNameField); container.add(addBtn); WFieldLayout layout = new WFieldLayout(); add(layout); layout.addField("New contact name", container); add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField})); }
java
private void createAddContactSubForm() { add(new WHeading(HeadingLevel.H3, "Add a new contact")); WButton addBtn = new WButton("Add"); addBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { addNewContact(); } }); addBtn.setImage("/image/address-book-new.png"); newNameField.setDefaultSubmitButton(addBtn); WContainer container = new WContainer(); container.add(newNameField); container.add(addBtn); WFieldLayout layout = new WFieldLayout(); add(layout); layout.addField("New contact name", container); add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField})); }
[ "private", "void", "createAddContactSubForm", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Add a new contact\"", ")", ")", ";", "WButton", "addBtn", "=", "new", "WButton", "(", "\"Add\"", ")", ";", "addBtn", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "addNewContact", "(", ")", ";", "}", "}", ")", ";", "addBtn", ".", "setImage", "(", "\"/image/address-book-new.png\"", ")", ";", "newNameField", ".", "setDefaultSubmitButton", "(", "addBtn", ")", ";", "WContainer", "container", "=", "new", "WContainer", "(", ")", ";", "container", ".", "add", "(", "newNameField", ")", ";", "container", ".", "add", "(", "addBtn", ")", ";", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "add", "(", "layout", ")", ";", "layout", ".", "addField", "(", "\"New contact name\"", ",", "container", ")", ";", "add", "(", "new", "WAjaxControl", "(", "addBtn", ",", "new", "AjaxTarget", "[", "]", "{", "repeater", ",", "newNameField", "}", ")", ")", ";", "}" ]
Create the UI artefacts for the "Add contact" sub form.
[ "Create", "the", "UI", "artefacts", "for", "the", "Add", "contact", "sub", "form", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java#L148-L169
138,855
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java
RepeaterExampleWithStaticIDs.createPrintContactsSubForm
private void createPrintContactsSubForm() { add(new WHeading(HeadingLevel.H3, "Print to CSV")); WButton printBtn = new WButton("Print"); printBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { printDetails(); } }); printBtn.setImage("/image/document-print.png"); printBtn.setImagePosition(WButton.ImagePosition.EAST); WFieldLayout layout = new WFieldLayout(); add(layout); layout.setMargin(new Margin(Size.LARGE, null, null, null)); layout.addField("Print output", printOutput); layout.addField((WLabel) null, printBtn); add(new WAjaxControl(printBtn, printOutput)); }
java
private void createPrintContactsSubForm() { add(new WHeading(HeadingLevel.H3, "Print to CSV")); WButton printBtn = new WButton("Print"); printBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { printDetails(); } }); printBtn.setImage("/image/document-print.png"); printBtn.setImagePosition(WButton.ImagePosition.EAST); WFieldLayout layout = new WFieldLayout(); add(layout); layout.setMargin(new Margin(Size.LARGE, null, null, null)); layout.addField("Print output", printOutput); layout.addField((WLabel) null, printBtn); add(new WAjaxControl(printBtn, printOutput)); }
[ "private", "void", "createPrintContactsSubForm", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Print to CSV\"", ")", ")", ";", "WButton", "printBtn", "=", "new", "WButton", "(", "\"Print\"", ")", ";", "printBtn", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "printDetails", "(", ")", ";", "}", "}", ")", ";", "printBtn", ".", "setImage", "(", "\"/image/document-print.png\"", ")", ";", "printBtn", ".", "setImagePosition", "(", "WButton", ".", "ImagePosition", ".", "EAST", ")", ";", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "add", "(", "layout", ")", ";", "layout", ".", "setMargin", "(", "new", "Margin", "(", "Size", ".", "LARGE", ",", "null", ",", "null", ",", "null", ")", ")", ";", "layout", ".", "addField", "(", "\"Print output\"", ",", "printOutput", ")", ";", "layout", ".", "addField", "(", "(", "WLabel", ")", "null", ",", "printBtn", ")", ";", "add", "(", "new", "WAjaxControl", "(", "printBtn", ",", "printOutput", ")", ")", ";", "}" ]
Create the UI artefacts for the "Print contacts" sub form.
[ "Create", "the", "UI", "artefacts", "for", "the", "Print", "contacts", "sub", "form", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java#L174-L193
138,856
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java
RepeaterExampleWithStaticIDs.printDetails
private void printDetails() { StringBuilder builder = new StringBuilder("\"Name\",\"Phone\",\"Roles\",\"Identifier\"\n"); for (Object contact : repeater.getBeanList()) { builder.append(contact).append('\n'); } printOutput.setText(builder.toString()); }
java
private void printDetails() { StringBuilder builder = new StringBuilder("\"Name\",\"Phone\",\"Roles\",\"Identifier\"\n"); for (Object contact : repeater.getBeanList()) { builder.append(contact).append('\n'); } printOutput.setText(builder.toString()); }
[ "private", "void", "printDetails", "(", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "\"\\\"Name\\\",\\\"Phone\\\",\\\"Roles\\\",\\\"Identifier\\\"\\n\"", ")", ";", "for", "(", "Object", "contact", ":", "repeater", ".", "getBeanList", "(", ")", ")", "{", "builder", ".", "append", "(", "contact", ")", ".", "append", "(", "'", "'", ")", ";", "}", "printOutput", ".", "setText", "(", "builder", ".", "toString", "(", ")", ")", ";", "}" ]
Write the list of contacts into the WTextArea printOutput.
[ "Write", "the", "list", "of", "contacts", "into", "the", "WTextArea", "printOutput", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java#L211-L217
138,857
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java
RepeaterExampleWithStaticIDs.fetchDataList
private static List<ContactDetails> fetchDataList() { List<ContactDetails> list = new ArrayList<>(); list.add(new ContactDetails("David", "1234", new String[]{"a", "b"})); list.add(new ContactDetails("Jun", "1111", new String[]{"c"})); list.add(new ContactDetails("Martin", null, new String[]{"b"})); return list; }
java
private static List<ContactDetails> fetchDataList() { List<ContactDetails> list = new ArrayList<>(); list.add(new ContactDetails("David", "1234", new String[]{"a", "b"})); list.add(new ContactDetails("Jun", "1111", new String[]{"c"})); list.add(new ContactDetails("Martin", null, new String[]{"b"})); return list; }
[ "private", "static", "List", "<", "ContactDetails", ">", "fetchDataList", "(", ")", "{", "List", "<", "ContactDetails", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "list", ".", "add", "(", "new", "ContactDetails", "(", "\"David\"", ",", "\"1234\"", ",", "new", "String", "[", "]", "{", "\"a\"", ",", "\"b\"", "}", ")", ")", ";", "list", ".", "add", "(", "new", "ContactDetails", "(", "\"Jun\"", ",", "\"1111\"", ",", "new", "String", "[", "]", "{", "\"c\"", "}", ")", ")", ";", "list", ".", "add", "(", "new", "ContactDetails", "(", "\"Martin\"", ",", "null", ",", "new", "String", "[", "]", "{", "\"b\"", "}", ")", ")", ";", "return", "list", ";", "}" ]
Retrieves dummy data used by this example. @return the list of data for this example.
[ "Retrieves", "dummy", "data", "used", "by", "this", "example", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/RepeaterExampleWithStaticIDs.java#L360-L366
138,858
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WFieldSetExample.java
WFieldSetExample.addFieldSet
private WFieldSet addFieldSet(final String title, final WFieldSet.FrameType type) { final WFieldSet fieldset = new WFieldSet(title); fieldset.setFrameType(type); fieldset.setMargin(new Margin(null, null, Size.LARGE, null)); final WFieldLayout layout = new WFieldLayout(); fieldset.add(layout); layout.setLabelWidth(25); layout.addField("Street address", new WTextField()); final WField add2Field = layout.addField("Street address line 2", new WTextField()); add2Field.getLabel().setHidden(true); layout.addField("Suburb", new WTextField()); layout.addField("State/Territory", new WDropdown( new String[]{"", "ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA"})); //NOTE: this is an Australia-specific post code field. An Australian post code is not a number as they may contain a leading zero. final WTextField postcode = new WTextField(); postcode.setMaxLength(4); postcode.setColumns(4); postcode.setMinLength(3); layout.addField("Postcode", postcode); add(fieldset); return fieldset; }
java
private WFieldSet addFieldSet(final String title, final WFieldSet.FrameType type) { final WFieldSet fieldset = new WFieldSet(title); fieldset.setFrameType(type); fieldset.setMargin(new Margin(null, null, Size.LARGE, null)); final WFieldLayout layout = new WFieldLayout(); fieldset.add(layout); layout.setLabelWidth(25); layout.addField("Street address", new WTextField()); final WField add2Field = layout.addField("Street address line 2", new WTextField()); add2Field.getLabel().setHidden(true); layout.addField("Suburb", new WTextField()); layout.addField("State/Territory", new WDropdown( new String[]{"", "ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA"})); //NOTE: this is an Australia-specific post code field. An Australian post code is not a number as they may contain a leading zero. final WTextField postcode = new WTextField(); postcode.setMaxLength(4); postcode.setColumns(4); postcode.setMinLength(3); layout.addField("Postcode", postcode); add(fieldset); return fieldset; }
[ "private", "WFieldSet", "addFieldSet", "(", "final", "String", "title", ",", "final", "WFieldSet", ".", "FrameType", "type", ")", "{", "final", "WFieldSet", "fieldset", "=", "new", "WFieldSet", "(", "title", ")", ";", "fieldset", ".", "setFrameType", "(", "type", ")", ";", "fieldset", ".", "setMargin", "(", "new", "Margin", "(", "null", ",", "null", ",", "Size", ".", "LARGE", ",", "null", ")", ")", ";", "final", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "fieldset", ".", "add", "(", "layout", ")", ";", "layout", ".", "setLabelWidth", "(", "25", ")", ";", "layout", ".", "addField", "(", "\"Street address\"", ",", "new", "WTextField", "(", ")", ")", ";", "final", "WField", "add2Field", "=", "layout", ".", "addField", "(", "\"Street address line 2\"", ",", "new", "WTextField", "(", ")", ")", ";", "add2Field", ".", "getLabel", "(", ")", ".", "setHidden", "(", "true", ")", ";", "layout", ".", "addField", "(", "\"Suburb\"", ",", "new", "WTextField", "(", ")", ")", ";", "layout", ".", "addField", "(", "\"State/Territory\"", ",", "new", "WDropdown", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"ACT\"", ",", "\"NSW\"", ",", "\"NT\"", ",", "\"QLD\"", ",", "\"SA\"", ",", "\"TAS\"", ",", "\"VIC\"", ",", "\"WA\"", "}", ")", ")", ";", "//NOTE: this is an Australia-specific post code field. An Australian post code is not a number as they may contain a leading zero.", "final", "WTextField", "postcode", "=", "new", "WTextField", "(", ")", ";", "postcode", ".", "setMaxLength", "(", "4", ")", ";", "postcode", ".", "setColumns", "(", "4", ")", ";", "postcode", ".", "setMinLength", "(", "3", ")", ";", "layout", ".", "addField", "(", "\"Postcode\"", ",", "postcode", ")", ";", "add", "(", "fieldset", ")", ";", "return", "fieldset", ";", "}" ]
Creates a WFieldSet with content and a given FrameType. @param title The title to give to the WFieldSet. @param type The decorative model of the WFieldSet @return a WFieldSet with form control content.
[ "Creates", "a", "WFieldSet", "with", "content", "and", "a", "given", "FrameType", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WFieldSetExample.java#L88-L109
138,859
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java
WRadioButtonSelectExample.makeSimpleExample
private void makeSimpleExample() { add(new WHeading(HeadingLevel.H3, "Simple WRadioButtonSelect")); WPanel examplePanel = new WPanel(); examplePanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.MEDIUM)); add(examplePanel); /** * The radio button select. */ final WRadioButtonSelect rbSelect = new WRadioButtonSelect("australian_state"); final WTextField text = new WTextField(); text.setReadOnly(true); text.setText(NO_SELECTION); WButton update = new WButton("Update"); update.setAction(new Action() { @Override public void execute(final ActionEvent event) { text.setText("The selected item is: " + rbSelect.getSelected()); } }); //setting the default submit button improves usability. It can be set on a WPanel or the WRadioButtonSelect directly examplePanel.setDefaultSubmitButton(update); examplePanel.add(new WLabel("Select a state or territory", rbSelect)); examplePanel.add(rbSelect); examplePanel.add(text); examplePanel.add(update); add(new WAjaxControl(update, text)); }
java
private void makeSimpleExample() { add(new WHeading(HeadingLevel.H3, "Simple WRadioButtonSelect")); WPanel examplePanel = new WPanel(); examplePanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.MEDIUM)); add(examplePanel); /** * The radio button select. */ final WRadioButtonSelect rbSelect = new WRadioButtonSelect("australian_state"); final WTextField text = new WTextField(); text.setReadOnly(true); text.setText(NO_SELECTION); WButton update = new WButton("Update"); update.setAction(new Action() { @Override public void execute(final ActionEvent event) { text.setText("The selected item is: " + rbSelect.getSelected()); } }); //setting the default submit button improves usability. It can be set on a WPanel or the WRadioButtonSelect directly examplePanel.setDefaultSubmitButton(update); examplePanel.add(new WLabel("Select a state or territory", rbSelect)); examplePanel.add(rbSelect); examplePanel.add(text); examplePanel.add(update); add(new WAjaxControl(update, text)); }
[ "private", "void", "makeSimpleExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Simple WRadioButtonSelect\"", ")", ")", ";", "WPanel", "examplePanel", "=", "new", "WPanel", "(", ")", ";", "examplePanel", ".", "setLayout", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "VERTICAL", ",", "Size", ".", "MEDIUM", ")", ")", ";", "add", "(", "examplePanel", ")", ";", "/**\n\t\t * The radio button select.\n\t\t */", "final", "WRadioButtonSelect", "rbSelect", "=", "new", "WRadioButtonSelect", "(", "\"australian_state\"", ")", ";", "final", "WTextField", "text", "=", "new", "WTextField", "(", ")", ";", "text", ".", "setReadOnly", "(", "true", ")", ";", "text", ".", "setText", "(", "NO_SELECTION", ")", ";", "WButton", "update", "=", "new", "WButton", "(", "\"Update\"", ")", ";", "update", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "text", ".", "setText", "(", "\"The selected item is: \"", "+", "rbSelect", ".", "getSelected", "(", ")", ")", ";", "}", "}", ")", ";", "//setting the default submit button improves usability. It can be set on a WPanel or the WRadioButtonSelect directly", "examplePanel", ".", "setDefaultSubmitButton", "(", "update", ")", ";", "examplePanel", ".", "add", "(", "new", "WLabel", "(", "\"Select a state or territory\"", ",", "rbSelect", ")", ")", ";", "examplePanel", ".", "add", "(", "rbSelect", ")", ";", "examplePanel", ".", "add", "(", "text", ")", ";", "examplePanel", ".", "add", "(", "update", ")", ";", "add", "(", "new", "WAjaxControl", "(", "update", ",", "text", ")", ")", ";", "}" ]
Make a simple editable example. The label for this example is used to get the example for use in the unit tests.
[ "Make", "a", "simple", "editable", "example", ".", "The", "label", "for", "this", "example", "is", "used", "to", "get", "the", "example", "for", "use", "in", "the", "unit", "tests", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java#L71-L102
138,860
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java
WRadioButtonSelectExample.makeFramelessExample
private void makeFramelessExample() { add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect without its frame")); add(new ExplanatoryText("When a WRadioButtonSelect is frameless it loses some of its coherence, especially when its WLabel is hidden or " + "replaced by a toolTip. Using a frameless WRadioButtonSelect is useful within an existing WFieldLayout as it can provide a more " + "consistent user interface but only if it has a relatively small number of options.")); final WRadioButtonSelect select = new SelectWithSelection("australian_state"); select.setFrameless(true); add(new WLabel("Frameless with default selection", select)); add(select); }
java
private void makeFramelessExample() { add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect without its frame")); add(new ExplanatoryText("When a WRadioButtonSelect is frameless it loses some of its coherence, especially when its WLabel is hidden or " + "replaced by a toolTip. Using a frameless WRadioButtonSelect is useful within an existing WFieldLayout as it can provide a more " + "consistent user interface but only if it has a relatively small number of options.")); final WRadioButtonSelect select = new SelectWithSelection("australian_state"); select.setFrameless(true); add(new WLabel("Frameless with default selection", select)); add(select); }
[ "private", "void", "makeFramelessExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"WRadioButtonSelect without its frame\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"When a WRadioButtonSelect is frameless it loses some of its coherence, especially when its WLabel is hidden or \"", "+", "\"replaced by a toolTip. Using a frameless WRadioButtonSelect is useful within an existing WFieldLayout as it can provide a more \"", "+", "\"consistent user interface but only if it has a relatively small number of options.\"", ")", ")", ";", "final", "WRadioButtonSelect", "select", "=", "new", "SelectWithSelection", "(", "\"australian_state\"", ")", ";", "select", ".", "setFrameless", "(", "true", ")", ";", "add", "(", "new", "WLabel", "(", "\"Frameless with default selection\"", ",", "select", ")", ")", ";", "add", "(", "select", ")", ";", "}" ]
Make a simple editable example without a frame.
[ "Make", "a", "simple", "editable", "example", "without", "a", "frame", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java#L107-L116
138,861
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java
WRadioButtonSelectExample.addInsideAFieldLayoutExample
private void addInsideAFieldLayoutExample() { add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect inside a WFieldLayout")); add(new ExplanatoryText( "When a WRadioButtonSelect is inside a WField its label is exposed in a way which appears and behaves like a regular HTML label." + " This allows WRadioButtonSelects to be used in a layout with simple form controls (such as WTextField) and produce a consistent" + " and predicatable interface.\n" + "The third example in this set uses a null label and a toolTip to hide the labelling element. This can lead to user confusion and" + " is not recommended.")); // Note: the wrapper WPanel here is to work around a bug in validation. See https://github.com/BorderTech/wcomponents/issues/1370 final WPanel wrapper = new WPanel(); add(wrapper); final WMessages messages = new WMessages(); wrapper.add(messages); WFieldLayout layout = new WFieldLayout(); layout.setLabelWidth(25); wrapper.add(layout); WButton resetThisBit = new WButton("Reset this bit"); resetThisBit.setCancel(true); resetThisBit.setAjaxTarget(wrapper); resetThisBit.setAction(new Action() { @Override public void execute(final ActionEvent event) { wrapper.reset(); } }); layout.addField(resetThisBit); String[] options = new String[]{"Dog", "Cat", "Bird", "Turtle"}; WRadioButtonSelect select = new WRadioButtonSelect(options); layout.addField("Select an animal", select); String[] options2 = new String[]{"Parrot", "Galah", "Cockatoo", "Lyre"}; select = new WRadioButtonSelect(options2); select.setMandatory(true); layout.addField("You must select a bird", select); select.setFrameless(true); //a tooltip can be used as a label stand-in even in a WField String[] options3 = new String[]{"Carrot", "Beet", "Brocolli", "Bacon - the perfect vegetable"}; select = new WRadioButtonSelect(options3); //if you absolutely do not want a WLabel in a WField then it has to be added using null cast to a WLabel. layout.addField((WLabel) null, select); select.setToolTip("Veggies"); WButton btnValidate = new WButton("validate"); btnValidate.setAction(new ValidatingAction(messages.getValidationErrors(), layout) { @Override public void executeOnValid(final ActionEvent event) { // do nothing } }); layout.addField(btnValidate); wrapper.add(new WAjaxControl(btnValidate, wrapper)); }
java
private void addInsideAFieldLayoutExample() { add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect inside a WFieldLayout")); add(new ExplanatoryText( "When a WRadioButtonSelect is inside a WField its label is exposed in a way which appears and behaves like a regular HTML label." + " This allows WRadioButtonSelects to be used in a layout with simple form controls (such as WTextField) and produce a consistent" + " and predicatable interface.\n" + "The third example in this set uses a null label and a toolTip to hide the labelling element. This can lead to user confusion and" + " is not recommended.")); // Note: the wrapper WPanel here is to work around a bug in validation. See https://github.com/BorderTech/wcomponents/issues/1370 final WPanel wrapper = new WPanel(); add(wrapper); final WMessages messages = new WMessages(); wrapper.add(messages); WFieldLayout layout = new WFieldLayout(); layout.setLabelWidth(25); wrapper.add(layout); WButton resetThisBit = new WButton("Reset this bit"); resetThisBit.setCancel(true); resetThisBit.setAjaxTarget(wrapper); resetThisBit.setAction(new Action() { @Override public void execute(final ActionEvent event) { wrapper.reset(); } }); layout.addField(resetThisBit); String[] options = new String[]{"Dog", "Cat", "Bird", "Turtle"}; WRadioButtonSelect select = new WRadioButtonSelect(options); layout.addField("Select an animal", select); String[] options2 = new String[]{"Parrot", "Galah", "Cockatoo", "Lyre"}; select = new WRadioButtonSelect(options2); select.setMandatory(true); layout.addField("You must select a bird", select); select.setFrameless(true); //a tooltip can be used as a label stand-in even in a WField String[] options3 = new String[]{"Carrot", "Beet", "Brocolli", "Bacon - the perfect vegetable"}; select = new WRadioButtonSelect(options3); //if you absolutely do not want a WLabel in a WField then it has to be added using null cast to a WLabel. layout.addField((WLabel) null, select); select.setToolTip("Veggies"); WButton btnValidate = new WButton("validate"); btnValidate.setAction(new ValidatingAction(messages.getValidationErrors(), layout) { @Override public void executeOnValid(final ActionEvent event) { // do nothing } }); layout.addField(btnValidate); wrapper.add(new WAjaxControl(btnValidate, wrapper)); }
[ "private", "void", "addInsideAFieldLayoutExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"WRadioButtonSelect inside a WFieldLayout\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"When a WRadioButtonSelect is inside a WField its label is exposed in a way which appears and behaves like a regular HTML label.\"", "+", "\" This allows WRadioButtonSelects to be used in a layout with simple form controls (such as WTextField) and produce a consistent\"", "+", "\" and predicatable interface.\\n\"", "+", "\"The third example in this set uses a null label and a toolTip to hide the labelling element. This can lead to user confusion and\"", "+", "\" is not recommended.\"", ")", ")", ";", "// Note: the wrapper WPanel here is to work around a bug in validation. See https://github.com/BorderTech/wcomponents/issues/1370", "final", "WPanel", "wrapper", "=", "new", "WPanel", "(", ")", ";", "add", "(", "wrapper", ")", ";", "final", "WMessages", "messages", "=", "new", "WMessages", "(", ")", ";", "wrapper", ".", "add", "(", "messages", ")", ";", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "layout", ".", "setLabelWidth", "(", "25", ")", ";", "wrapper", ".", "add", "(", "layout", ")", ";", "WButton", "resetThisBit", "=", "new", "WButton", "(", "\"Reset this bit\"", ")", ";", "resetThisBit", ".", "setCancel", "(", "true", ")", ";", "resetThisBit", ".", "setAjaxTarget", "(", "wrapper", ")", ";", "resetThisBit", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "wrapper", ".", "reset", "(", ")", ";", "}", "}", ")", ";", "layout", ".", "addField", "(", "resetThisBit", ")", ";", "String", "[", "]", "options", "=", "new", "String", "[", "]", "{", "\"Dog\"", ",", "\"Cat\"", ",", "\"Bird\"", ",", "\"Turtle\"", "}", ";", "WRadioButtonSelect", "select", "=", "new", "WRadioButtonSelect", "(", "options", ")", ";", "layout", ".", "addField", "(", "\"Select an animal\"", ",", "select", ")", ";", "String", "[", "]", "options2", "=", "new", "String", "[", "]", "{", "\"Parrot\"", ",", "\"Galah\"", ",", "\"Cockatoo\"", ",", "\"Lyre\"", "}", ";", "select", "=", "new", "WRadioButtonSelect", "(", "options2", ")", ";", "select", ".", "setMandatory", "(", "true", ")", ";", "layout", ".", "addField", "(", "\"You must select a bird\"", ",", "select", ")", ";", "select", ".", "setFrameless", "(", "true", ")", ";", "//a tooltip can be used as a label stand-in even in a WField", "String", "[", "]", "options3", "=", "new", "String", "[", "]", "{", "\"Carrot\"", ",", "\"Beet\"", ",", "\"Brocolli\"", ",", "\"Bacon - the perfect vegetable\"", "}", ";", "select", "=", "new", "WRadioButtonSelect", "(", "options3", ")", ";", "//if you absolutely do not want a WLabel in a WField then it has to be added using null cast to a WLabel.", "layout", ".", "addField", "(", "(", "WLabel", ")", "null", ",", "select", ")", ";", "select", ".", "setToolTip", "(", "\"Veggies\"", ")", ";", "WButton", "btnValidate", "=", "new", "WButton", "(", "\"validate\"", ")", ";", "btnValidate", ".", "setAction", "(", "new", "ValidatingAction", "(", "messages", ".", "getValidationErrors", "(", ")", ",", "layout", ")", "{", "@", "Override", "public", "void", "executeOnValid", "(", "final", "ActionEvent", "event", ")", "{", "// do nothing", "}", "}", ")", ";", "layout", ".", "addField", "(", "btnValidate", ")", ";", "wrapper", ".", "add", "(", "new", "WAjaxControl", "(", "btnValidate", ",", "wrapper", ")", ")", ";", "}" ]
When a WRadioButtonSelect is added to a WFieldLayout the legend is moved. The first CheckBoxSelect has a frame, the second doesn't
[ "When", "a", "WRadioButtonSelect", "is", "added", "to", "a", "WFieldLayout", "the", "legend", "is", "moved", ".", "The", "first", "CheckBoxSelect", "has", "a", "frame", "the", "second", "doesn", "t" ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java#L123-L173
138,862
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java
WRadioButtonSelectExample.addFlatSelectExample
private void addFlatSelectExample() { add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect with flat layout")); add(new ExplanatoryText("Setting the layout to FLAT will make the radio buttons be rendered in a horizontal line. They will wrap when they" + " reach the edge of the parent container.")); final WRadioButtonSelect select = new WRadioButtonSelect("australian_state"); select.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT); add(new WLabel("Flat selection", select)); add(select); }
java
private void addFlatSelectExample() { add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect with flat layout")); add(new ExplanatoryText("Setting the layout to FLAT will make the radio buttons be rendered in a horizontal line. They will wrap when they" + " reach the edge of the parent container.")); final WRadioButtonSelect select = new WRadioButtonSelect("australian_state"); select.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT); add(new WLabel("Flat selection", select)); add(select); }
[ "private", "void", "addFlatSelectExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"WRadioButtonSelect with flat layout\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"Setting the layout to FLAT will make the radio buttons be rendered in a horizontal line. They will wrap when they\"", "+", "\" reach the edge of the parent container.\"", ")", ")", ";", "final", "WRadioButtonSelect", "select", "=", "new", "WRadioButtonSelect", "(", "\"australian_state\"", ")", ";", "select", ".", "setButtonLayout", "(", "WRadioButtonSelect", ".", "LAYOUT_FLAT", ")", ";", "add", "(", "new", "WLabel", "(", "\"Flat selection\"", ",", "select", ")", ")", ";", "add", "(", "select", ")", ";", "}" ]
adds a WRadioButtonSelect with LAYOUT_FLAT.
[ "adds", "a", "WRadioButtonSelect", "with", "LAYOUT_FLAT", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java#L183-L191
138,863
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java
WRadioButtonSelectExample.addReadOnlyExamples
private void addReadOnlyExamples() { add(new WHeading(HeadingLevel.H3, "Read-only WRadioButtonSelect examples")); add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above. " + "When the readOnly state is specified only that option which is selected is output.\n" + "Since no more than one option is able to be selected the layout and frame settings are ignored in the read only state.")); WFieldLayout layout = new WFieldLayout(); add(layout); WRadioButtonSelect select = new WRadioButtonSelect("australian_state"); select.setReadOnly(true); layout.addField("Read only with no selection", select); select = new SelectWithSelection("australian_state"); select.setReadOnly(true); layout.addField("Read only with selection", select); }
java
private void addReadOnlyExamples() { add(new WHeading(HeadingLevel.H3, "Read-only WRadioButtonSelect examples")); add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above. " + "When the readOnly state is specified only that option which is selected is output.\n" + "Since no more than one option is able to be selected the layout and frame settings are ignored in the read only state.")); WFieldLayout layout = new WFieldLayout(); add(layout); WRadioButtonSelect select = new WRadioButtonSelect("australian_state"); select.setReadOnly(true); layout.addField("Read only with no selection", select); select = new SelectWithSelection("australian_state"); select.setReadOnly(true); layout.addField("Read only with selection", select); }
[ "private", "void", "addReadOnlyExamples", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H3", ",", "\"Read-only WRadioButtonSelect examples\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"These examples all use the same list of options: the states and territories list from the editable examples above. \"", "+", "\"When the readOnly state is specified only that option which is selected is output.\\n\"", "+", "\"Since no more than one option is able to be selected the layout and frame settings are ignored in the read only state.\"", ")", ")", ";", "WFieldLayout", "layout", "=", "new", "WFieldLayout", "(", ")", ";", "add", "(", "layout", ")", ";", "WRadioButtonSelect", "select", "=", "new", "WRadioButtonSelect", "(", "\"australian_state\"", ")", ";", "select", ".", "setReadOnly", "(", "true", ")", ";", "layout", ".", "addField", "(", "\"Read only with no selection\"", ",", "select", ")", ";", "select", "=", "new", "SelectWithSelection", "(", "\"australian_state\"", ")", ";", "select", ".", "setReadOnly", "(", "true", ")", ";", "layout", ".", "addField", "(", "\"Read only with selection\"", ",", "select", ")", ";", "}" ]
Examples of readonly states. When in a read only state only the selected option is output. Since a WRadioButtonSeelct can only have 0 or 1 selected option the LAYOUT and FRAME are ignored.
[ "Examples", "of", "readonly", "states", ".", "When", "in", "a", "read", "only", "state", "only", "the", "selected", "option", "is", "output", ".", "Since", "a", "WRadioButtonSeelct", "can", "only", "have", "0", "or", "1", "selected", "option", "the", "LAYOUT", "and", "FRAME", "are", "ignored", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample.java#L279-L295
138,864
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WContentExample.java
WContentExample.addContentRow
private void addContentRow(final String contentDesc, final ContentAccess contentAccess, final MutableContainer target) { // Demonstrate WButton + WContent, round trip WButton button = new WButton(contentDesc); final WContent buttonContent = new WContent(); button.setAction(new Action() { @Override public void execute(final ActionEvent event) { buttonContent.setContentAccess(contentAccess); buttonContent.display(); } }); WContainer buttonCell = new WContainer(); buttonCell.add(buttonContent); buttonCell.add(button); target.add(buttonCell); // Demonstrate WButton + WContent, using AJAX WButton ajaxButton = new WButton(contentDesc); final WContent ajaxContent = new WContent(); ajaxButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { ajaxContent.setContentAccess(contentAccess); ajaxContent.display(); } }); WContainer ajaxCell = new WContainer(); // The WContent must be wrapped in an AJAX targetable container WPanel ajaxContentPanel = new WPanel(); ajaxContentPanel.add(ajaxContent); ajaxCell.add(ajaxButton); ajaxCell.add(ajaxContentPanel); ajaxButton.setAjaxTarget(ajaxContentPanel); target.add(ajaxCell); // Demonstrate WContentLink - new window WContentLink contentLinkNewWindow = new WContentLink(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); setContentAccess(contentAccess); } }; target.add(contentLinkNewWindow); // Demonstrate WContentLink - prompt to save WContentLink contentLinkPromptToSave = new WContentLink(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); setContentAccess(contentAccess); } }; contentLinkPromptToSave.setDisplayMode(DisplayMode.PROMPT_TO_SAVE); target.add(contentLinkPromptToSave); // Demonstrate WContentLink - inline WContentLink contentLinkInline = new WContentLink(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); setContentAccess(contentAccess); } }; contentLinkInline.setDisplayMode(DisplayMode.DISPLAY_INLINE); target.add(contentLinkInline); // Demonstrate targeting of content via a URL WMenu menu = new WMenu(WMenu.MenuType.FLYOUT); final WContent menuContent = new WContent(); menuContent.setDisplayMode(DisplayMode.PROMPT_TO_SAVE); WMenuItem menuItem = new WMenuItem(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); menuContent.setContentAccess(contentAccess); setUrl(menuContent.getUrl()); } }; menu.add(menuItem); WContainer menuCell = new WContainer(); menuCell.add(menuContent); menuCell.add(menu); target.add(menuCell); }
java
private void addContentRow(final String contentDesc, final ContentAccess contentAccess, final MutableContainer target) { // Demonstrate WButton + WContent, round trip WButton button = new WButton(contentDesc); final WContent buttonContent = new WContent(); button.setAction(new Action() { @Override public void execute(final ActionEvent event) { buttonContent.setContentAccess(contentAccess); buttonContent.display(); } }); WContainer buttonCell = new WContainer(); buttonCell.add(buttonContent); buttonCell.add(button); target.add(buttonCell); // Demonstrate WButton + WContent, using AJAX WButton ajaxButton = new WButton(contentDesc); final WContent ajaxContent = new WContent(); ajaxButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { ajaxContent.setContentAccess(contentAccess); ajaxContent.display(); } }); WContainer ajaxCell = new WContainer(); // The WContent must be wrapped in an AJAX targetable container WPanel ajaxContentPanel = new WPanel(); ajaxContentPanel.add(ajaxContent); ajaxCell.add(ajaxButton); ajaxCell.add(ajaxContentPanel); ajaxButton.setAjaxTarget(ajaxContentPanel); target.add(ajaxCell); // Demonstrate WContentLink - new window WContentLink contentLinkNewWindow = new WContentLink(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); setContentAccess(contentAccess); } }; target.add(contentLinkNewWindow); // Demonstrate WContentLink - prompt to save WContentLink contentLinkPromptToSave = new WContentLink(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); setContentAccess(contentAccess); } }; contentLinkPromptToSave.setDisplayMode(DisplayMode.PROMPT_TO_SAVE); target.add(contentLinkPromptToSave); // Demonstrate WContentLink - inline WContentLink contentLinkInline = new WContentLink(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); setContentAccess(contentAccess); } }; contentLinkInline.setDisplayMode(DisplayMode.DISPLAY_INLINE); target.add(contentLinkInline); // Demonstrate targeting of content via a URL WMenu menu = new WMenu(WMenu.MenuType.FLYOUT); final WContent menuContent = new WContent(); menuContent.setDisplayMode(DisplayMode.PROMPT_TO_SAVE); WMenuItem menuItem = new WMenuItem(contentDesc) { @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); menuContent.setContentAccess(contentAccess); setUrl(menuContent.getUrl()); } }; menu.add(menuItem); WContainer menuCell = new WContainer(); menuCell.add(menuContent); menuCell.add(menu); target.add(menuCell); }
[ "private", "void", "addContentRow", "(", "final", "String", "contentDesc", ",", "final", "ContentAccess", "contentAccess", ",", "final", "MutableContainer", "target", ")", "{", "// Demonstrate WButton + WContent, round trip", "WButton", "button", "=", "new", "WButton", "(", "contentDesc", ")", ";", "final", "WContent", "buttonContent", "=", "new", "WContent", "(", ")", ";", "button", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "buttonContent", ".", "setContentAccess", "(", "contentAccess", ")", ";", "buttonContent", ".", "display", "(", ")", ";", "}", "}", ")", ";", "WContainer", "buttonCell", "=", "new", "WContainer", "(", ")", ";", "buttonCell", ".", "add", "(", "buttonContent", ")", ";", "buttonCell", ".", "add", "(", "button", ")", ";", "target", ".", "add", "(", "buttonCell", ")", ";", "// Demonstrate WButton + WContent, using AJAX", "WButton", "ajaxButton", "=", "new", "WButton", "(", "contentDesc", ")", ";", "final", "WContent", "ajaxContent", "=", "new", "WContent", "(", ")", ";", "ajaxButton", ".", "setAction", "(", "new", "Action", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", "final", "ActionEvent", "event", ")", "{", "ajaxContent", ".", "setContentAccess", "(", "contentAccess", ")", ";", "ajaxContent", ".", "display", "(", ")", ";", "}", "}", ")", ";", "WContainer", "ajaxCell", "=", "new", "WContainer", "(", ")", ";", "// The WContent must be wrapped in an AJAX targetable container", "WPanel", "ajaxContentPanel", "=", "new", "WPanel", "(", ")", ";", "ajaxContentPanel", ".", "add", "(", "ajaxContent", ")", ";", "ajaxCell", ".", "add", "(", "ajaxButton", ")", ";", "ajaxCell", ".", "add", "(", "ajaxContentPanel", ")", ";", "ajaxButton", ".", "setAjaxTarget", "(", "ajaxContentPanel", ")", ";", "target", ".", "add", "(", "ajaxCell", ")", ";", "// Demonstrate WContentLink - new window", "WContentLink", "contentLinkNewWindow", "=", "new", "WContentLink", "(", "contentDesc", ")", "{", "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "setContentAccess", "(", "contentAccess", ")", ";", "}", "}", ";", "target", ".", "add", "(", "contentLinkNewWindow", ")", ";", "// Demonstrate WContentLink - prompt to save", "WContentLink", "contentLinkPromptToSave", "=", "new", "WContentLink", "(", "contentDesc", ")", "{", "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "setContentAccess", "(", "contentAccess", ")", ";", "}", "}", ";", "contentLinkPromptToSave", ".", "setDisplayMode", "(", "DisplayMode", ".", "PROMPT_TO_SAVE", ")", ";", "target", ".", "add", "(", "contentLinkPromptToSave", ")", ";", "// Demonstrate WContentLink - inline", "WContentLink", "contentLinkInline", "=", "new", "WContentLink", "(", "contentDesc", ")", "{", "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "setContentAccess", "(", "contentAccess", ")", ";", "}", "}", ";", "contentLinkInline", ".", "setDisplayMode", "(", "DisplayMode", ".", "DISPLAY_INLINE", ")", ";", "target", ".", "add", "(", "contentLinkInline", ")", ";", "// Demonstrate targeting of content via a URL", "WMenu", "menu", "=", "new", "WMenu", "(", "WMenu", ".", "MenuType", ".", "FLYOUT", ")", ";", "final", "WContent", "menuContent", "=", "new", "WContent", "(", ")", ";", "menuContent", ".", "setDisplayMode", "(", "DisplayMode", ".", "PROMPT_TO_SAVE", ")", ";", "WMenuItem", "menuItem", "=", "new", "WMenuItem", "(", "contentDesc", ")", "{", "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "super", ".", "preparePaintComponent", "(", "request", ")", ";", "menuContent", ".", "setContentAccess", "(", "contentAccess", ")", ";", "setUrl", "(", "menuContent", ".", "getUrl", "(", ")", ")", ";", "}", "}", ";", "menu", ".", "add", "(", "menuItem", ")", ";", "WContainer", "menuCell", "=", "new", "WContainer", "(", ")", ";", "menuCell", ".", "add", "(", "menuContent", ")", ";", "menuCell", ".", "add", "(", "menu", ")", ";", "target", ".", "add", "(", "menuCell", ")", ";", "}" ]
Adds components to the given container which demonstrate various ways of acessing the given content. @param contentDesc the description of the content, used to label the controls. @param contentAccess the content which will be displayed. @param target the container to add the UI controls to.
[ "Adds", "components", "to", "the", "given", "container", "which", "demonstrate", "various", "ways", "of", "acessing", "the", "given", "content", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WContentExample.java#L64-L158
138,865
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/LinkOptionsExample.java
LinkOptionsExample.applySettings
private void applySettings() { linkContainer.reset(); WLink exampleLink = new WLink(); exampleLink.setText(tfLinkLabel.getText()); final String url = tfUrlField.getValue(); if ("".equals(url) || !isValidUrl(url)) { tfUrlField.setText(URL); exampleLink.setUrl(URL); } else { exampleLink.setUrl(url); } exampleLink.setRenderAsButton(cbRenderAsButton.isSelected()); exampleLink.setText(tfLinkLabel.getText()); if (cbSetImage.isSelected()) { WImage linkImage = new WImage("/image/attachment.png", "Add attachment"); exampleLink.setImage(linkImage.getImage()); exampleLink.setImagePosition((ImagePosition) ddImagePosition.getSelected()); } exampleLink.setDisabled(cbDisabled.isSelected()); if (tfAccesskey.getText() != null && tfAccesskey.getText().length() > 0) { exampleLink.setAccessKey(tfAccesskey.getText().toCharArray()[0]); } if (cbOpenNew.isSelected()) { exampleLink.setOpenNewWindow(true); exampleLink.setTargetWindowName("_blank"); } else { exampleLink.setOpenNewWindow(false); } linkContainer.add(exampleLink); }
java
private void applySettings() { linkContainer.reset(); WLink exampleLink = new WLink(); exampleLink.setText(tfLinkLabel.getText()); final String url = tfUrlField.getValue(); if ("".equals(url) || !isValidUrl(url)) { tfUrlField.setText(URL); exampleLink.setUrl(URL); } else { exampleLink.setUrl(url); } exampleLink.setRenderAsButton(cbRenderAsButton.isSelected()); exampleLink.setText(tfLinkLabel.getText()); if (cbSetImage.isSelected()) { WImage linkImage = new WImage("/image/attachment.png", "Add attachment"); exampleLink.setImage(linkImage.getImage()); exampleLink.setImagePosition((ImagePosition) ddImagePosition.getSelected()); } exampleLink.setDisabled(cbDisabled.isSelected()); if (tfAccesskey.getText() != null && tfAccesskey.getText().length() > 0) { exampleLink.setAccessKey(tfAccesskey.getText().toCharArray()[0]); } if (cbOpenNew.isSelected()) { exampleLink.setOpenNewWindow(true); exampleLink.setTargetWindowName("_blank"); } else { exampleLink.setOpenNewWindow(false); } linkContainer.add(exampleLink); }
[ "private", "void", "applySettings", "(", ")", "{", "linkContainer", ".", "reset", "(", ")", ";", "WLink", "exampleLink", "=", "new", "WLink", "(", ")", ";", "exampleLink", ".", "setText", "(", "tfLinkLabel", ".", "getText", "(", ")", ")", ";", "final", "String", "url", "=", "tfUrlField", ".", "getValue", "(", ")", ";", "if", "(", "\"\"", ".", "equals", "(", "url", ")", "||", "!", "isValidUrl", "(", "url", ")", ")", "{", "tfUrlField", ".", "setText", "(", "URL", ")", ";", "exampleLink", ".", "setUrl", "(", "URL", ")", ";", "}", "else", "{", "exampleLink", ".", "setUrl", "(", "url", ")", ";", "}", "exampleLink", ".", "setRenderAsButton", "(", "cbRenderAsButton", ".", "isSelected", "(", ")", ")", ";", "exampleLink", ".", "setText", "(", "tfLinkLabel", ".", "getText", "(", ")", ")", ";", "if", "(", "cbSetImage", ".", "isSelected", "(", ")", ")", "{", "WImage", "linkImage", "=", "new", "WImage", "(", "\"/image/attachment.png\"", ",", "\"Add attachment\"", ")", ";", "exampleLink", ".", "setImage", "(", "linkImage", ".", "getImage", "(", ")", ")", ";", "exampleLink", ".", "setImagePosition", "(", "(", "ImagePosition", ")", "ddImagePosition", ".", "getSelected", "(", ")", ")", ";", "}", "exampleLink", ".", "setDisabled", "(", "cbDisabled", ".", "isSelected", "(", ")", ")", ";", "if", "(", "tfAccesskey", ".", "getText", "(", ")", "!=", "null", "&&", "tfAccesskey", ".", "getText", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "exampleLink", ".", "setAccessKey", "(", "tfAccesskey", ".", "getText", "(", ")", ".", "toCharArray", "(", ")", "[", "0", "]", ")", ";", "}", "if", "(", "cbOpenNew", ".", "isSelected", "(", ")", ")", "{", "exampleLink", ".", "setOpenNewWindow", "(", "true", ")", ";", "exampleLink", ".", "setTargetWindowName", "(", "\"_blank\"", ")", ";", "}", "else", "{", "exampleLink", ".", "setOpenNewWindow", "(", "false", ")", ";", "}", "linkContainer", ".", "add", "(", "exampleLink", ")", ";", "}" ]
this is were the majority of the work is done for building the link. Note that it is in a container that is reset, effectively creating a new link. this is only done to enable to dynamically change the link to a button and back.
[ "this", "is", "were", "the", "majority", "of", "the", "work", "is", "done", "for", "building", "the", "link", ".", "Note", "that", "it", "is", "in", "a", "container", "that", "is", "reset", "effectively", "creating", "a", "new", "link", ".", "this", "is", "only", "done", "to", "enable", "to", "dynamically", "change", "the", "link", "to", "a", "button", "and", "back", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/LinkOptionsExample.java#L162-L198
138,866
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterLinkTab.java
RepeaterLinkTab.showDetails
public void showDetails(final ActionEvent event) { // Track down the data associated with this event. MyData data = (MyData) event.getActionObject(); displayDialog.setData(data); dialog.display(); }
java
public void showDetails(final ActionEvent event) { // Track down the data associated with this event. MyData data = (MyData) event.getActionObject(); displayDialog.setData(data); dialog.display(); }
[ "public", "void", "showDetails", "(", "final", "ActionEvent", "event", ")", "{", "// Track down the data associated with this event.", "MyData", "data", "=", "(", "MyData", ")", "event", ".", "getActionObject", "(", ")", ";", "displayDialog", ".", "setData", "(", "data", ")", ";", "dialog", ".", "display", "(", ")", ";", "}" ]
Handle show details. @param event the action event
[ "Handle", "show", "details", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/repeater/link/RepeaterLinkTab.java#L60-L66
138,867
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessagesProxy.java
WMessagesProxy.getWMessageInstance
private WMessages getWMessageInstance() { MessageContainer container = getMessageContainer(component); WMessages result = null; if (container == null) { LOG.warn("No MessageContainer as ancestor of " + component + ". Messages will not be added"); } else { result = container.getMessages(); if (result == null) { LOG.warn("No messages in container of " + component + ". Messages will not be added"); } } return result; }
java
private WMessages getWMessageInstance() { MessageContainer container = getMessageContainer(component); WMessages result = null; if (container == null) { LOG.warn("No MessageContainer as ancestor of " + component + ". Messages will not be added"); } else { result = container.getMessages(); if (result == null) { LOG.warn("No messages in container of " + component + ". Messages will not be added"); } } return result; }
[ "private", "WMessages", "getWMessageInstance", "(", ")", "{", "MessageContainer", "container", "=", "getMessageContainer", "(", "component", ")", ";", "WMessages", "result", "=", "null", ";", "if", "(", "container", "==", "null", ")", "{", "LOG", ".", "warn", "(", "\"No MessageContainer as ancestor of \"", "+", "component", "+", "\". Messages will not be added\"", ")", ";", "}", "else", "{", "result", "=", "container", ".", "getMessages", "(", ")", ";", "if", "(", "result", "==", "null", ")", "{", "LOG", ".", "warn", "(", "\"No messages in container of \"", "+", "component", "+", "\". Messages will not be added\"", ")", ";", "}", "}", "return", "result", ";", "}" ]
Utility method that searches for the WMessages instance for the given component. If not found, a warning will be logged and null returned. @return the WMessages instance for the given component, or null if not found.
[ "Utility", "method", "that", "searches", "for", "the", "WMessages", "instance", "for", "the", "given", "component", ".", "If", "not", "found", "a", "warning", "will", "be", "logged", "and", "null", "returned", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessagesProxy.java#L52-L69
138,868
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessagesProxy.java
WMessagesProxy.error
@Override public void error(final String code) { WMessages instance = getWMessageInstance(); if (instance != null) { instance.error(code); } }
java
@Override public void error(final String code) { WMessages instance = getWMessageInstance(); if (instance != null) { instance.error(code); } }
[ "@", "Override", "public", "void", "error", "(", "final", "String", "code", ")", "{", "WMessages", "instance", "=", "getWMessageInstance", "(", ")", ";", "if", "(", "instance", "!=", "null", ")", "{", "instance", ".", "error", "(", "code", ")", ";", "}", "}" ]
Adds an error message. @param code the message code.
[ "Adds", "an", "error", "message", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMessagesProxy.java#L76-L83
138,869
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.setBeanList
public void setBeanList(final List beanList) { RepeaterModel model = getOrCreateComponentModel(); model.setData(beanList); // Clean up any stale data. HashSet rowIds = new HashSet(beanList.size()); for (Object bean : beanList) { rowIds.add(getRowId(bean)); } cleanupStaleContexts(rowIds); // Clean up cached component IDs UIContext uic = UIContextHolder.getCurrent(); if (uic != null && getRepeatRoot() != null) { clearScratchMaps(this); } }
java
public void setBeanList(final List beanList) { RepeaterModel model = getOrCreateComponentModel(); model.setData(beanList); // Clean up any stale data. HashSet rowIds = new HashSet(beanList.size()); for (Object bean : beanList) { rowIds.add(getRowId(bean)); } cleanupStaleContexts(rowIds); // Clean up cached component IDs UIContext uic = UIContextHolder.getCurrent(); if (uic != null && getRepeatRoot() != null) { clearScratchMaps(this); } }
[ "public", "void", "setBeanList", "(", "final", "List", "beanList", ")", "{", "RepeaterModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "setData", "(", "beanList", ")", ";", "// Clean up any stale data.", "HashSet", "rowIds", "=", "new", "HashSet", "(", "beanList", ".", "size", "(", ")", ")", ";", "for", "(", "Object", "bean", ":", "beanList", ")", "{", "rowIds", ".", "add", "(", "getRowId", "(", "bean", ")", ")", ";", "}", "cleanupStaleContexts", "(", "rowIds", ")", ";", "// Clean up cached component IDs", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "if", "(", "uic", "!=", "null", "&&", "getRepeatRoot", "(", ")", "!=", "null", ")", "{", "clearScratchMaps", "(", "this", ")", ";", "}", "}" ]
Remember the list of beans that hold the data object for each row. @param beanList the list of data objects for each row.
[ "Remember", "the", "list", "of", "beans", "that", "hold", "the", "data", "object", "for", "each", "row", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L90-L109
138,870
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.clearScratchMaps
protected void clearScratchMaps(final WComponent node) { UIContext uic = UIContextHolder.getCurrent(); uic.clearRequestScratchMap(node); uic.clearScratchMap(node); if (node instanceof WRepeater) { WRepeater repeater = (WRepeater) node; List<UIContext> rowContextList = repeater.getRowContexts(); WComponent repeatedComponent = repeater.getRepeatedComponent(); for (UIContext rowContext : rowContextList) { UIContextHolder.pushContext(rowContext); try { clearScratchMaps(repeatedComponent); } finally { UIContextHolder.popContext(); } } // Make sure the repeater's scratch map has not been repopulated by processing its children uic.clearRequestScratchMap(node); uic.clearScratchMap(node); } else if (node instanceof Container) { Container container = (Container) node; for (int i = 0; i < container.getChildCount(); i++) { clearScratchMaps(container.getChildAt(i)); } } }
java
protected void clearScratchMaps(final WComponent node) { UIContext uic = UIContextHolder.getCurrent(); uic.clearRequestScratchMap(node); uic.clearScratchMap(node); if (node instanceof WRepeater) { WRepeater repeater = (WRepeater) node; List<UIContext> rowContextList = repeater.getRowContexts(); WComponent repeatedComponent = repeater.getRepeatedComponent(); for (UIContext rowContext : rowContextList) { UIContextHolder.pushContext(rowContext); try { clearScratchMaps(repeatedComponent); } finally { UIContextHolder.popContext(); } } // Make sure the repeater's scratch map has not been repopulated by processing its children uic.clearRequestScratchMap(node); uic.clearScratchMap(node); } else if (node instanceof Container) { Container container = (Container) node; for (int i = 0; i < container.getChildCount(); i++) { clearScratchMaps(container.getChildAt(i)); } } }
[ "protected", "void", "clearScratchMaps", "(", "final", "WComponent", "node", ")", "{", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "uic", ".", "clearRequestScratchMap", "(", "node", ")", ";", "uic", ".", "clearScratchMap", "(", "node", ")", ";", "if", "(", "node", "instanceof", "WRepeater", ")", "{", "WRepeater", "repeater", "=", "(", "WRepeater", ")", "node", ";", "List", "<", "UIContext", ">", "rowContextList", "=", "repeater", ".", "getRowContexts", "(", ")", ";", "WComponent", "repeatedComponent", "=", "repeater", ".", "getRepeatedComponent", "(", ")", ";", "for", "(", "UIContext", "rowContext", ":", "rowContextList", ")", "{", "UIContextHolder", ".", "pushContext", "(", "rowContext", ")", ";", "try", "{", "clearScratchMaps", "(", "repeatedComponent", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "// Make sure the repeater's scratch map has not been repopulated by processing its children", "uic", ".", "clearRequestScratchMap", "(", "node", ")", ";", "uic", ".", "clearScratchMap", "(", "node", ")", ";", "}", "else", "if", "(", "node", "instanceof", "Container", ")", "{", "Container", "container", "=", "(", "Container", ")", "node", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "container", ".", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "clearScratchMaps", "(", "container", ".", "getChildAt", "(", "i", ")", ")", ";", "}", "}", "}" ]
Recursively clears cached component scratch maps. This is called when the bean list changes, as the beans may have changed. @param node the component branch to clear cached data in.
[ "Recursively", "clears", "cached", "component", "scratch", "maps", ".", "This", "is", "called", "when", "the", "bean", "list", "changes", "as", "the", "beans", "may", "have", "changed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L117-L148
138,871
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.getBeanList
public List getBeanList() { List beanList = (List) getData(); if (beanList == null) { return Collections.emptyList(); } return Collections.unmodifiableList(beanList); }
java
public List getBeanList() { List beanList = (List) getData(); if (beanList == null) { return Collections.emptyList(); } return Collections.unmodifiableList(beanList); }
[ "public", "List", "getBeanList", "(", ")", "{", "List", "beanList", "=", "(", "List", ")", "getData", "(", ")", ";", "if", "(", "beanList", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "beanList", ")", ";", "}" ]
Retrieves the list of dataBeans that holds the data object for each row. The list returned will be the same instance as the one supplied via the setBeanList method. Will never return null, but it can return an empty list. @return the list of dataBeans that holds the data object for each row
[ "Retrieves", "the", "list", "of", "dataBeans", "that", "holds", "the", "data", "object", "for", "each", "row", ".", "The", "list", "returned", "will", "be", "the", "same", "instance", "as", "the", "one", "supplied", "via", "the", "setBeanList", "method", ".", "Will", "never", "return", "null", "but", "it", "can", "return", "an", "empty", "list", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L156-L164
138,872
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.validate
@Override public void validate(final List<Diagnostic> diags) { // Validate each row. List beanList = this.getBeanList(); WComponent row = getRepeatedComponent(); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); UIContext rowContext = getRowContext(rowData, i); UIContextHolder.pushContext(rowContext); try { row.validate(diags); } finally { UIContextHolder.popContext(); } } }
java
@Override public void validate(final List<Diagnostic> diags) { // Validate each row. List beanList = this.getBeanList(); WComponent row = getRepeatedComponent(); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); UIContext rowContext = getRowContext(rowData, i); UIContextHolder.pushContext(rowContext); try { row.validate(diags); } finally { UIContextHolder.popContext(); } } }
[ "@", "Override", "public", "void", "validate", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "// Validate each row.", "List", "beanList", "=", "this", ".", "getBeanList", "(", ")", ";", "WComponent", "row", "=", "getRepeatedComponent", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "beanList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Object", "rowData", "=", "beanList", ".", "get", "(", "i", ")", ";", "UIContext", "rowContext", "=", "getRowContext", "(", "rowData", ",", "i", ")", ";", "UIContextHolder", ".", "pushContext", "(", "rowContext", ")", ";", "try", "{", "row", ".", "validate", "(", "diags", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "}" ]
Validates each row. @param diags the list of SfpDiagnostics to add to.
[ "Validates", "each", "row", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L209-L227
138,873
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.handleRequest
@Override public void handleRequest(final Request request) { assertConfigured(); // // Service the request for each row. // List beanList = getBeanList(); HashSet rowIds = new HashSet(beanList.size()); WComponent row = getRepeatedComponent(); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); rowIds.add(getRowId(rowData)); // Each row has its own context. This is why we can reuse the same // WComponent instance for each row. UIContext rowContext = getRowContext(rowData, i); try { UIContextHolder.pushContext(rowContext); row.serviceRequest(request); } finally { UIContextHolder.popContext(); } } cleanupStaleContexts(rowIds); }
java
@Override public void handleRequest(final Request request) { assertConfigured(); // // Service the request for each row. // List beanList = getBeanList(); HashSet rowIds = new HashSet(beanList.size()); WComponent row = getRepeatedComponent(); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); rowIds.add(getRowId(rowData)); // Each row has its own context. This is why we can reuse the same // WComponent instance for each row. UIContext rowContext = getRowContext(rowData, i); try { UIContextHolder.pushContext(rowContext); row.serviceRequest(request); } finally { UIContextHolder.popContext(); } } cleanupStaleContexts(rowIds); }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "assertConfigured", "(", ")", ";", "//", "// Service the request for each row.", "//", "List", "beanList", "=", "getBeanList", "(", ")", ";", "HashSet", "rowIds", "=", "new", "HashSet", "(", "beanList", ".", "size", "(", ")", ")", ";", "WComponent", "row", "=", "getRepeatedComponent", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "beanList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Object", "rowData", "=", "beanList", ".", "get", "(", "i", ")", ";", "rowIds", ".", "add", "(", "getRowId", "(", "rowData", ")", ")", ";", "// Each row has its own context. This is why we can reuse the same", "// WComponent instance for each row.", "UIContext", "rowContext", "=", "getRowContext", "(", "rowData", ",", "i", ")", ";", "try", "{", "UIContextHolder", ".", "pushContext", "(", "rowContext", ")", ";", "row", ".", "serviceRequest", "(", "request", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "cleanupStaleContexts", "(", "rowIds", ")", ";", "}" ]
Override handleRequest to process the request for each row. @param request the request being responded to.
[ "Override", "handleRequest", "to", "process", "the", "request", "for", "each", "row", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L262-L290
138,874
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.cleanupStaleContexts
protected void cleanupStaleContexts(final Set<?> rowIds) { RepeaterModel model = getOrCreateComponentModel(); if (model.rowContextMap != null) { for (Iterator<Map.Entry<Object, SubUIContext>> i = model.rowContextMap.entrySet(). iterator(); i.hasNext();) { Map.Entry<Object, SubUIContext> entry = i.next(); Object rowId = entry.getKey(); if (!rowIds.contains(rowId)) { i.remove(); } } if (model.rowContextMap.isEmpty()) { model.rowContextMap = null; } } }
java
protected void cleanupStaleContexts(final Set<?> rowIds) { RepeaterModel model = getOrCreateComponentModel(); if (model.rowContextMap != null) { for (Iterator<Map.Entry<Object, SubUIContext>> i = model.rowContextMap.entrySet(). iterator(); i.hasNext();) { Map.Entry<Object, SubUIContext> entry = i.next(); Object rowId = entry.getKey(); if (!rowIds.contains(rowId)) { i.remove(); } } if (model.rowContextMap.isEmpty()) { model.rowContextMap = null; } } }
[ "protected", "void", "cleanupStaleContexts", "(", "final", "Set", "<", "?", ">", "rowIds", ")", "{", "RepeaterModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "if", "(", "model", ".", "rowContextMap", "!=", "null", ")", "{", "for", "(", "Iterator", "<", "Map", ".", "Entry", "<", "Object", ",", "SubUIContext", ">", ">", "i", "=", "model", ".", "rowContextMap", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "Map", ".", "Entry", "<", "Object", ",", "SubUIContext", ">", "entry", "=", "i", ".", "next", "(", ")", ";", "Object", "rowId", "=", "entry", ".", "getKey", "(", ")", ";", "if", "(", "!", "rowIds", ".", "contains", "(", "rowId", ")", ")", "{", "i", ".", "remove", "(", ")", ";", "}", "}", "if", "(", "model", ".", "rowContextMap", ".", "isEmpty", "(", ")", ")", "{", "model", ".", "rowContextMap", "=", "null", ";", "}", "}", "}" ]
Removes any stale contexts from the row context map. @param rowIds the current set of row Ids.
[ "Removes", "any", "stale", "contexts", "from", "the", "row", "context", "map", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L297-L314
138,875
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.preparePaintComponent
@Override protected void preparePaintComponent(final Request request) { assertConfigured(); List beanList = getBeanList(); List<Integer> used = new ArrayList<>(); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); // Each row has its own context. This is why we can reuse the same // WComponent instance for each row. UIContext rowContext = getRowContext(rowData, i); // Check the context has not been used for another row Integer subId = ((SubUIContext) rowContext).getContextId(); if (used.contains(subId)) { Object rowId = ((SubUIContext) rowContext).getRowId(); String msg = "The row context for row id [" + rowId + "] has already been used for another row. " + "Either the row ID is not unique or the row bean has not implemented equals/hashcode " + "or no rowIdBeanProperty set on the repeater that uniquely identifies the row."; throw new SystemException(msg); } used.add(subId); UIContextHolder.pushContext(rowContext); try { prepareRow(request, i); } finally { UIContextHolder.popContext(); } } }
java
@Override protected void preparePaintComponent(final Request request) { assertConfigured(); List beanList = getBeanList(); List<Integer> used = new ArrayList<>(); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); // Each row has its own context. This is why we can reuse the same // WComponent instance for each row. UIContext rowContext = getRowContext(rowData, i); // Check the context has not been used for another row Integer subId = ((SubUIContext) rowContext).getContextId(); if (used.contains(subId)) { Object rowId = ((SubUIContext) rowContext).getRowId(); String msg = "The row context for row id [" + rowId + "] has already been used for another row. " + "Either the row ID is not unique or the row bean has not implemented equals/hashcode " + "or no rowIdBeanProperty set on the repeater that uniquely identifies the row."; throw new SystemException(msg); } used.add(subId); UIContextHolder.pushContext(rowContext); try { prepareRow(request, i); } finally { UIContextHolder.popContext(); } } }
[ "@", "Override", "protected", "void", "preparePaintComponent", "(", "final", "Request", "request", ")", "{", "assertConfigured", "(", ")", ";", "List", "beanList", "=", "getBeanList", "(", ")", ";", "List", "<", "Integer", ">", "used", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "beanList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Object", "rowData", "=", "beanList", ".", "get", "(", "i", ")", ";", "// Each row has its own context. This is why we can reuse the same", "// WComponent instance for each row.", "UIContext", "rowContext", "=", "getRowContext", "(", "rowData", ",", "i", ")", ";", "// Check the context has not been used for another row", "Integer", "subId", "=", "(", "(", "SubUIContext", ")", "rowContext", ")", ".", "getContextId", "(", ")", ";", "if", "(", "used", ".", "contains", "(", "subId", ")", ")", "{", "Object", "rowId", "=", "(", "(", "SubUIContext", ")", "rowContext", ")", ".", "getRowId", "(", ")", ";", "String", "msg", "=", "\"The row context for row id [\"", "+", "rowId", "+", "\"] has already been used for another row. \"", "+", "\"Either the row ID is not unique or the row bean has not implemented equals/hashcode \"", "+", "\"or no rowIdBeanProperty set on the repeater that uniquely identifies the row.\"", ";", "throw", "new", "SystemException", "(", "msg", ")", ";", "}", "used", ".", "add", "(", "subId", ")", ";", "UIContextHolder", ".", "pushContext", "(", "rowContext", ")", ";", "try", "{", "prepareRow", "(", "request", ",", "i", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "}" ]
Override preparePaintComponent to prepare each row for painting. @param request the request being responded to.
[ "Override", "preparePaintComponent", "to", "prepare", "each", "row", "for", "painting", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L351-L387
138,876
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.prepareRow
protected void prepareRow(final Request request, final int rowIndex) { WComponent row = getRepeatedComponent(); row.preparePaint(request); }
java
protected void prepareRow(final Request request, final int rowIndex) { WComponent row = getRepeatedComponent(); row.preparePaint(request); }
[ "protected", "void", "prepareRow", "(", "final", "Request", "request", ",", "final", "int", "rowIndex", ")", "{", "WComponent", "row", "=", "getRepeatedComponent", "(", ")", ";", "row", ".", "preparePaint", "(", "request", ")", ";", "}" ]
Prepares a single row for painting. @param request the request being responded to. @param rowIndex the row index.
[ "Prepares", "a", "single", "row", "for", "painting", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L395-L398
138,877
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.getRowContext
public UIContext getRowContext(final Object rowBean, final int rowIndex) { RepeaterModel model = getOrCreateComponentModel(); Object rowId = getRowId(rowBean); if (model.rowContextMap == null) { model.rowContextMap = new HashMap<>(); } SubUIContext rowContext = model.rowContextMap.get(rowId); if (rowContext == null) { int seq = model.rowContextIdSequence++; // Just for the first row, check rowId has implemented equals/hashcode. Assumes each row will use the same // row id class. if (seq == 0) { try { if (rowId.getClass() != rowId.getClass().getMethod("equals", Object.class). getDeclaringClass() || rowId.getClass() != rowId.getClass().getMethod("hashCode"). getDeclaringClass()) { LOG.warn("Row id class [" + rowId.getClass().getName() + "] has not implemented equals or hashcode. This can cause errors when matching a row context. " + "Implement equals/hashcode on the row bean or refer to setRowIdBeanProperty method on WRepeater."); } } catch (Exception e) { LOG.info( "Error checking equals and hashcode implementation on the row id. " + e. getMessage(), e); } } // Get the row render id name (used in naming context for each row) String renderId = getRowIdName(rowBean, rowId); if (renderId == null) { // Just use the context id as the row naming context rowContext = new SubUIContext(this, seq); } else { // Check ID is properly formed // Must only contain letters, digits and or underscores Matcher matcher = ROW_ID_CONTEXT_NAME_PATTERN.matcher(renderId); if (!matcher.matches()) { throw new IllegalArgumentException( "Row idName [" + renderId + "] must start with a letter and followed by letters, digits and or underscores."); } rowContext = new SubUIContext(this, seq, renderId); } rowContext.setRowId(rowId); model.rowContextMap.put(rowId, rowContext); } rowContext.setRowIndex(rowIndex); // just incase it has changed return rowContext; }
java
public UIContext getRowContext(final Object rowBean, final int rowIndex) { RepeaterModel model = getOrCreateComponentModel(); Object rowId = getRowId(rowBean); if (model.rowContextMap == null) { model.rowContextMap = new HashMap<>(); } SubUIContext rowContext = model.rowContextMap.get(rowId); if (rowContext == null) { int seq = model.rowContextIdSequence++; // Just for the first row, check rowId has implemented equals/hashcode. Assumes each row will use the same // row id class. if (seq == 0) { try { if (rowId.getClass() != rowId.getClass().getMethod("equals", Object.class). getDeclaringClass() || rowId.getClass() != rowId.getClass().getMethod("hashCode"). getDeclaringClass()) { LOG.warn("Row id class [" + rowId.getClass().getName() + "] has not implemented equals or hashcode. This can cause errors when matching a row context. " + "Implement equals/hashcode on the row bean or refer to setRowIdBeanProperty method on WRepeater."); } } catch (Exception e) { LOG.info( "Error checking equals and hashcode implementation on the row id. " + e. getMessage(), e); } } // Get the row render id name (used in naming context for each row) String renderId = getRowIdName(rowBean, rowId); if (renderId == null) { // Just use the context id as the row naming context rowContext = new SubUIContext(this, seq); } else { // Check ID is properly formed // Must only contain letters, digits and or underscores Matcher matcher = ROW_ID_CONTEXT_NAME_PATTERN.matcher(renderId); if (!matcher.matches()) { throw new IllegalArgumentException( "Row idName [" + renderId + "] must start with a letter and followed by letters, digits and or underscores."); } rowContext = new SubUIContext(this, seq, renderId); } rowContext.setRowId(rowId); model.rowContextMap.put(rowId, rowContext); } rowContext.setRowIndex(rowIndex); // just incase it has changed return rowContext; }
[ "public", "UIContext", "getRowContext", "(", "final", "Object", "rowBean", ",", "final", "int", "rowIndex", ")", "{", "RepeaterModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "Object", "rowId", "=", "getRowId", "(", "rowBean", ")", ";", "if", "(", "model", ".", "rowContextMap", "==", "null", ")", "{", "model", ".", "rowContextMap", "=", "new", "HashMap", "<>", "(", ")", ";", "}", "SubUIContext", "rowContext", "=", "model", ".", "rowContextMap", ".", "get", "(", "rowId", ")", ";", "if", "(", "rowContext", "==", "null", ")", "{", "int", "seq", "=", "model", ".", "rowContextIdSequence", "++", ";", "// Just for the first row, check rowId has implemented equals/hashcode. Assumes each row will use the same", "// row id class.", "if", "(", "seq", "==", "0", ")", "{", "try", "{", "if", "(", "rowId", ".", "getClass", "(", ")", "!=", "rowId", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"equals\"", ",", "Object", ".", "class", ")", ".", "getDeclaringClass", "(", ")", "||", "rowId", ".", "getClass", "(", ")", "!=", "rowId", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"hashCode\"", ")", ".", "getDeclaringClass", "(", ")", ")", "{", "LOG", ".", "warn", "(", "\"Row id class [\"", "+", "rowId", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"] has not implemented equals or hashcode. This can cause errors when matching a row context. \"", "+", "\"Implement equals/hashcode on the row bean or refer to setRowIdBeanProperty method on WRepeater.\"", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "info", "(", "\"Error checking equals and hashcode implementation on the row id. \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "// Get the row render id name (used in naming context for each row)", "String", "renderId", "=", "getRowIdName", "(", "rowBean", ",", "rowId", ")", ";", "if", "(", "renderId", "==", "null", ")", "{", "// Just use the context id as the row naming context", "rowContext", "=", "new", "SubUIContext", "(", "this", ",", "seq", ")", ";", "}", "else", "{", "// Check ID is properly formed", "// Must only contain letters, digits and or underscores", "Matcher", "matcher", "=", "ROW_ID_CONTEXT_NAME_PATTERN", ".", "matcher", "(", "renderId", ")", ";", "if", "(", "!", "matcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Row idName [\"", "+", "renderId", "+", "\"] must start with a letter and followed by letters, digits and or underscores.\"", ")", ";", "}", "rowContext", "=", "new", "SubUIContext", "(", "this", ",", "seq", ",", "renderId", ")", ";", "}", "rowContext", ".", "setRowId", "(", "rowId", ")", ";", "model", ".", "rowContextMap", ".", "put", "(", "rowId", ",", "rowContext", ")", ";", "}", "rowContext", ".", "setRowIndex", "(", "rowIndex", ")", ";", "// just incase it has changed", "return", "rowContext", ";", "}" ]
Retrieves the UIContext for a row. @param rowBean the row's bean. @param rowIndex the row index. @return The context for the given row.
[ "Retrieves", "the", "UIContext", "for", "a", "row", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L499-L555
138,878
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.getRowBeanForSubcontext
public Object getRowBeanForSubcontext(final SubUIContext subContext) { if (subContext.repeatRoot != getRepeatRoot()) { // TODO: Is this still necessary? throw new IllegalArgumentException("SubUIContext is not for this WRepeater instance."); } // We need to get the list using the parent context // so that e.g. caching in the scratch map works properly. UIContextHolder.pushContext(subContext.getParentContext()); try { return getRowData(subContext.getRowId()); } finally { UIContextHolder.popContext(); } }
java
public Object getRowBeanForSubcontext(final SubUIContext subContext) { if (subContext.repeatRoot != getRepeatRoot()) { // TODO: Is this still necessary? throw new IllegalArgumentException("SubUIContext is not for this WRepeater instance."); } // We need to get the list using the parent context // so that e.g. caching in the scratch map works properly. UIContextHolder.pushContext(subContext.getParentContext()); try { return getRowData(subContext.getRowId()); } finally { UIContextHolder.popContext(); } }
[ "public", "Object", "getRowBeanForSubcontext", "(", "final", "SubUIContext", "subContext", ")", "{", "if", "(", "subContext", ".", "repeatRoot", "!=", "getRepeatRoot", "(", ")", ")", "{", "// TODO: Is this still necessary?", "throw", "new", "IllegalArgumentException", "(", "\"SubUIContext is not for this WRepeater instance.\"", ")", ";", "}", "// We need to get the list using the parent context", "// so that e.g. caching in the scratch map works properly.", "UIContextHolder", ".", "pushContext", "(", "subContext", ".", "getParentContext", "(", ")", ")", ";", "try", "{", "return", "getRowData", "(", "subContext", ".", "getRowId", "(", ")", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}" ]
Returns the row data for the given row context. @param subContext the row context. @return the data bean for the given row context.
[ "Returns", "the", "row", "data", "for", "the", "given", "row", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L563-L578
138,879
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.getRowData
private Object getRowData(final Object rowId) { // We cache row id --> row bean mapping per request for performance (to avoid nested loops) Map dataByRowId = (Map) getScratchMap().get(SCRATCHMAP_DATA_BY_ROW_ID_KEY); if (dataByRowId == null) { dataByRowId = createRowIdCache(); } Object data = dataByRowId.get(rowId); if (data == null && !dataByRowId.containsKey(rowId)) { // Ok, new data has probably been added. We need to cache the new data. dataByRowId = createRowIdCache(); data = dataByRowId.get(rowId); } return data; }
java
private Object getRowData(final Object rowId) { // We cache row id --> row bean mapping per request for performance (to avoid nested loops) Map dataByRowId = (Map) getScratchMap().get(SCRATCHMAP_DATA_BY_ROW_ID_KEY); if (dataByRowId == null) { dataByRowId = createRowIdCache(); } Object data = dataByRowId.get(rowId); if (data == null && !dataByRowId.containsKey(rowId)) { // Ok, new data has probably been added. We need to cache the new data. dataByRowId = createRowIdCache(); data = dataByRowId.get(rowId); } return data; }
[ "private", "Object", "getRowData", "(", "final", "Object", "rowId", ")", "{", "// We cache row id --> row bean mapping per request for performance (to avoid nested loops)", "Map", "dataByRowId", "=", "(", "Map", ")", "getScratchMap", "(", ")", ".", "get", "(", "SCRATCHMAP_DATA_BY_ROW_ID_KEY", ")", ";", "if", "(", "dataByRowId", "==", "null", ")", "{", "dataByRowId", "=", "createRowIdCache", "(", ")", ";", "}", "Object", "data", "=", "dataByRowId", ".", "get", "(", "rowId", ")", ";", "if", "(", "data", "==", "null", "&&", "!", "dataByRowId", ".", "containsKey", "(", "rowId", ")", ")", "{", "// Ok, new data has probably been added. We need to cache the new data.", "dataByRowId", "=", "createRowIdCache", "(", ")", ";", "data", "=", "dataByRowId", ".", "get", "(", "rowId", ")", ";", "}", "return", "data", ";", "}" ]
Returns the row data corresponding to the given id. @param rowId the row id @return the row data with the given id, or null if not found.
[ "Returns", "the", "row", "data", "corresponding", "to", "the", "given", "id", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L586-L603
138,880
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.getRowId
protected Object getRowId(final Object rowBean) { String rowIdProperty = getComponentModel().rowIdProperty; if (rowIdProperty == null || rowBean == null) { return rowBean; } try { return PropertyUtils.getProperty(rowBean, rowIdProperty); } catch (Exception e) { LOG.error("Failed to read row property \"" + rowIdProperty + "\" on " + rowBean, e); return rowBean; } }
java
protected Object getRowId(final Object rowBean) { String rowIdProperty = getComponentModel().rowIdProperty; if (rowIdProperty == null || rowBean == null) { return rowBean; } try { return PropertyUtils.getProperty(rowBean, rowIdProperty); } catch (Exception e) { LOG.error("Failed to read row property \"" + rowIdProperty + "\" on " + rowBean, e); return rowBean; } }
[ "protected", "Object", "getRowId", "(", "final", "Object", "rowBean", ")", "{", "String", "rowIdProperty", "=", "getComponentModel", "(", ")", ".", "rowIdProperty", ";", "if", "(", "rowIdProperty", "==", "null", "||", "rowBean", "==", "null", ")", "{", "return", "rowBean", ";", "}", "try", "{", "return", "PropertyUtils", ".", "getProperty", "(", "rowBean", ",", "rowIdProperty", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to read row property \\\"\"", "+", "rowIdProperty", "+", "\"\\\" on \"", "+", "rowBean", ",", "e", ")", ";", "return", "rowBean", ";", "}", "}" ]
Retrieves the row id for the given row. @param rowBean the row's data. @return the id for the given row. Defaults to the row data.
[ "Retrieves", "the", "row", "id", "for", "the", "given", "row", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L635-L648
138,881
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java
WRepeater.getRowContexts
public List<UIContext> getRowContexts() { List<?> beanList = this.getBeanList(); List<UIContext> contexts = new ArrayList<>(beanList.size()); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); contexts.add(this.getRowContext(rowData, i)); } return Collections.unmodifiableList(contexts); }
java
public List<UIContext> getRowContexts() { List<?> beanList = this.getBeanList(); List<UIContext> contexts = new ArrayList<>(beanList.size()); for (int i = 0; i < beanList.size(); i++) { Object rowData = beanList.get(i); contexts.add(this.getRowContext(rowData, i)); } return Collections.unmodifiableList(contexts); }
[ "public", "List", "<", "UIContext", ">", "getRowContexts", "(", ")", "{", "List", "<", "?", ">", "beanList", "=", "this", ".", "getBeanList", "(", ")", ";", "List", "<", "UIContext", ">", "contexts", "=", "new", "ArrayList", "<>", "(", "beanList", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "beanList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Object", "rowData", "=", "beanList", ".", "get", "(", "i", ")", ";", "contexts", ".", "add", "(", "this", ".", "getRowContext", "(", "rowData", ",", "i", ")", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "contexts", ")", ";", "}" ]
Retrieves the row contexts for all rows. @return A list containing a UIContext for each row. Will never return null, but it can return an empty list.
[ "Retrieves", "the", "row", "contexts", "for", "all", "rows", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java#L655-L665
138,882
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.assignTask
public void assignTask(int taskId, int responsible) { getResourceFactory() .getApiResource("/task/" + taskId + "/assign") .entity(new AssignValue(responsible), MediaType.APPLICATION_JSON_TYPE).post(); }
java
public void assignTask(int taskId, int responsible) { getResourceFactory() .getApiResource("/task/" + taskId + "/assign") .entity(new AssignValue(responsible), MediaType.APPLICATION_JSON_TYPE).post(); }
[ "public", "void", "assignTask", "(", "int", "taskId", ",", "int", "responsible", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", "+", "taskId", "+", "\"/assign\"", ")", ".", "entity", "(", "new", "AssignValue", "(", "responsible", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", ")", ";", "}" ]
Assigns the task to another user. This makes the user responsible for the task and its completion. @param taskId The id of the task to assign @param responsible The id of the user the task should be assigned to
[ "Assigns", "the", "task", "to", "another", "user", ".", "This", "makes", "the", "user", "responsible", "for", "the", "task", "and", "its", "completion", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L77-L82
138,883
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.completeTask
public void completeTask(int taskId) { getResourceFactory().getApiResource("/task/" + taskId + "/complete") .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); }
java
public void completeTask(int taskId) { getResourceFactory().getApiResource("/task/" + taskId + "/complete") .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); }
[ "public", "void", "completeTask", "(", "int", "taskId", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", "+", "taskId", "+", "\"/complete\"", ")", ".", "entity", "(", "new", "Empty", "(", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", ")", ";", "}" ]
Mark the given task as completed. @param taskId The id of the task to nark as complete
[ "Mark", "the", "given", "task", "as", "completed", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L90-L93
138,884
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.updateDueDate
public void updateDueDate(int taskId, LocalDate dueDate) { getResourceFactory() .getApiResource("/task/" + taskId + "/due_date") .entity(new TaskDueDate(dueDate), MediaType.APPLICATION_JSON_TYPE).put(); }
java
public void updateDueDate(int taskId, LocalDate dueDate) { getResourceFactory() .getApiResource("/task/" + taskId + "/due_date") .entity(new TaskDueDate(dueDate), MediaType.APPLICATION_JSON_TYPE).put(); }
[ "public", "void", "updateDueDate", "(", "int", "taskId", ",", "LocalDate", "dueDate", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", "+", "taskId", "+", "\"/due_date\"", ")", ".", "entity", "(", "new", "TaskDueDate", "(", "dueDate", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Updates the due date of the task to the given value @param taskId The id of the task @param dueDate The new due date of the task
[ "Updates", "the", "due", "date", "of", "the", "task", "to", "the", "given", "value" ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L114-L119
138,885
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.updatePrivate
public void updatePrivate(int taskId, boolean priv) { getResourceFactory().getApiResource("/task/" + taskId + "/private") .entity(new TaskPrivate(priv), MediaType.APPLICATION_JSON_TYPE) .put(); }
java
public void updatePrivate(int taskId, boolean priv) { getResourceFactory().getApiResource("/task/" + taskId + "/private") .entity(new TaskPrivate(priv), MediaType.APPLICATION_JSON_TYPE) .put(); }
[ "public", "void", "updatePrivate", "(", "int", "taskId", ",", "boolean", "priv", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", "+", "taskId", "+", "\"/private\"", ")", ".", "entity", "(", "new", "TaskPrivate", "(", "priv", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Update the private flag on the given task. @param taskId The id of the task @param priv <code>true</code> if the task should be private, <code>false</code> otherwise
[ "Update", "the", "private", "flag", "on", "the", "given", "task", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L130-L134
138,886
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.updateText
public void updateText(int taskId, String text) { getResourceFactory().getApiResource("/task/" + taskId + "/text") .entity(new TaskText(text), MediaType.APPLICATION_JSON_TYPE) .put(); }
java
public void updateText(int taskId, String text) { getResourceFactory().getApiResource("/task/" + taskId + "/text") .entity(new TaskText(text), MediaType.APPLICATION_JSON_TYPE) .put(); }
[ "public", "void", "updateText", "(", "int", "taskId", ",", "String", "text", ")", "{", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", "+", "taskId", "+", "\"/text\"", ")", ".", "entity", "(", "new", "TaskText", "(", "text", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "put", "(", ")", ";", "}" ]
Updates the text of the task. @param taskId The id of the task @param text The new text of the task
[ "Updates", "the", "text", "of", "the", "task", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L144-L148
138,887
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.createTask
public int createTask(TaskCreate task, boolean silent, boolean hook) { TaskCreateResponse response = getResourceFactory() .getApiResource("/task/") .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(task, MediaType.APPLICATION_JSON_TYPE) .post(TaskCreateResponse.class); return response.getId(); }
java
public int createTask(TaskCreate task, boolean silent, boolean hook) { TaskCreateResponse response = getResourceFactory() .getApiResource("/task/") .queryParam("silent", silent ? "1" : "0") .queryParam("hook", hook ? "1" : "0") .entity(task, MediaType.APPLICATION_JSON_TYPE) .post(TaskCreateResponse.class); return response.getId(); }
[ "public", "int", "createTask", "(", "TaskCreate", "task", ",", "boolean", "silent", ",", "boolean", "hook", ")", "{", "TaskCreateResponse", "response", "=", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", ")", ".", "queryParam", "(", "\"silent\"", ",", "silent", "?", "\"1\"", ":", "\"0\"", ")", ".", "queryParam", "(", "\"hook\"", ",", "hook", "?", "\"1\"", ":", "\"0\"", ")", ".", "entity", "(", "task", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", "TaskCreateResponse", ".", "class", ")", ";", "return", "response", ".", "getId", "(", ")", ";", "}" ]
Creates a new task with no reference to other objects. @param task The data of the task to be created @param silent Disable notifications @param hook Execute hooks for the change @return The id of the newly created task
[ "Creates", "a", "new", "task", "with", "no", "reference", "to", "other", "objects", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L174-L183
138,888
podio/podio-java
src/main/java/com/podio/task/TaskAPI.java
TaskAPI.getTasksWithReference
public List<Task> getTasksWithReference(Reference reference) { return getResourceFactory().getApiResource( "/task/" + reference.getType().name().toLowerCase() + "/" + reference.getId() + "/").get( new GenericType<List<Task>>() { }); }
java
public List<Task> getTasksWithReference(Reference reference) { return getResourceFactory().getApiResource( "/task/" + reference.getType().name().toLowerCase() + "/" + reference.getId() + "/").get( new GenericType<List<Task>>() { }); }
[ "public", "List", "<", "Task", ">", "getTasksWithReference", "(", "Reference", "reference", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/task/\"", "+", "reference", ".", "getType", "(", ")", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", "+", "\"/\"", "+", "reference", ".", "getId", "(", ")", "+", "\"/\"", ")", ".", "get", "(", "new", "GenericType", "<", "List", "<", "Task", ">", ">", "(", ")", "{", "}", ")", ";", "}" ]
Gets a list of tasks with a reference to the given object. This will return both active and completed tasks. The reference will not be set on the individual tasks. @param reference The object on which to return tasks @return The list of tasks
[ "Gets", "a", "list", "of", "tasks", "with", "a", "reference", "to", "the", "given", "object", ".", "This", "will", "return", "both", "active", "and", "completed", "tasks", ".", "The", "reference", "will", "not", "be", "set", "on", "the", "individual", "tasks", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/task/TaskAPI.java#L235-L241
138,889
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDateField.java
WDateField.convertDate
private Date convertDate(final Object data) { if (data == null) { return null; } else if (data instanceof Date) { return (Date) data; } else if (data instanceof Long) { return new Date((Long) data); } else if (data instanceof Calendar) { return ((Calendar) data).getTime(); } else if (data instanceof String) { try { SimpleDateFormat sdf = new SimpleDateFormat(INTERNAL_DATE_FORMAT); sdf.setLenient(lenient); return sdf.parse((String) data); } catch (ParseException e) { throw new SystemException("Could not convert String data [" + data + "] to a date."); } } throw new SystemException("Cannot convert data type " + data.getClass() + " to a date."); }
java
private Date convertDate(final Object data) { if (data == null) { return null; } else if (data instanceof Date) { return (Date) data; } else if (data instanceof Long) { return new Date((Long) data); } else if (data instanceof Calendar) { return ((Calendar) data).getTime(); } else if (data instanceof String) { try { SimpleDateFormat sdf = new SimpleDateFormat(INTERNAL_DATE_FORMAT); sdf.setLenient(lenient); return sdf.parse((String) data); } catch (ParseException e) { throw new SystemException("Could not convert String data [" + data + "] to a date."); } } throw new SystemException("Cannot convert data type " + data.getClass() + " to a date."); }
[ "private", "Date", "convertDate", "(", "final", "Object", "data", ")", "{", "if", "(", "data", "==", "null", ")", "{", "return", "null", ";", "}", "else", "if", "(", "data", "instanceof", "Date", ")", "{", "return", "(", "Date", ")", "data", ";", "}", "else", "if", "(", "data", "instanceof", "Long", ")", "{", "return", "new", "Date", "(", "(", "Long", ")", "data", ")", ";", "}", "else", "if", "(", "data", "instanceof", "Calendar", ")", "{", "return", "(", "(", "Calendar", ")", "data", ")", ".", "getTime", "(", ")", ";", "}", "else", "if", "(", "data", "instanceof", "String", ")", "{", "try", "{", "SimpleDateFormat", "sdf", "=", "new", "SimpleDateFormat", "(", "INTERNAL_DATE_FORMAT", ")", ";", "sdf", ".", "setLenient", "(", "lenient", ")", ";", "return", "sdf", ".", "parse", "(", "(", "String", ")", "data", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "throw", "new", "SystemException", "(", "\"Could not convert String data [\"", "+", "data", "+", "\"] to a date.\"", ")", ";", "}", "}", "throw", "new", "SystemException", "(", "\"Cannot convert data type \"", "+", "data", ".", "getClass", "(", ")", "+", "\" to a date.\"", ")", ";", "}" ]
Attempts to convert the given object to a date. Throws a SystemException on error. @param data the data to convert. @return the converted date, or null if <code>data</code> was null/empty.
[ "Attempts", "to", "convert", "the", "given", "object", "to", "a", "date", ".", "Throws", "a", "SystemException", "on", "error", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDateField.java#L114-L134
138,890
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDateField.java
WDateField.validateComponent
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isParseable()) { super.validateComponent(diags); validateDate(diags); } else { diags.add(createErrorDiagnostic(getComponentModel().errorMessage, this)); } }
java
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isParseable()) { super.validateComponent(diags); validateDate(diags); } else { diags.add(createErrorDiagnostic(getComponentModel().errorMessage, this)); } }
[ "@", "Override", "protected", "void", "validateComponent", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "if", "(", "isParseable", "(", ")", ")", "{", "super", ".", "validateComponent", "(", "diags", ")", ";", "validateDate", "(", "diags", ")", ";", "}", "else", "{", "diags", ".", "add", "(", "createErrorDiagnostic", "(", "getComponentModel", "(", ")", ".", "errorMessage", ",", "this", ")", ")", ";", "}", "}" ]
Override WInput's validateComponent to perform further validation on the date. @param diags the list into which any validation diagnostics are added.
[ "Override", "WInput", "s", "validateComponent", "to", "perform", "further", "validation", "on", "the", "date", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDateField.java#L267-L275
138,891
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java
UIContextImpl.setModel
@Override public void setModel(final WebComponent component, final WebModel model) { map.put(component, model); }
java
@Override public void setModel(final WebComponent component, final WebModel model) { map.put(component, model); }
[ "@", "Override", "public", "void", "setModel", "(", "final", "WebComponent", "component", ",", "final", "WebModel", "model", ")", "{", "map", ".", "put", "(", "component", ",", "model", ")", ";", "}" ]
Stores the extrinsic state information for the given component. @param component the component to set the model for. @param model the model to set.
[ "Stores", "the", "extrinsic", "state", "information", "for", "the", "given", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L123-L126
138,892
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java
UIContextImpl.invokeLater
@Override public void invokeLater(final UIContext uic, final Runnable runnable) { if (invokeLaterRunnables == null) { invokeLaterRunnables = new ArrayList<>(); } invokeLaterRunnables.add(new UIContextImplRunnable(uic, runnable)); }
java
@Override public void invokeLater(final UIContext uic, final Runnable runnable) { if (invokeLaterRunnables == null) { invokeLaterRunnables = new ArrayList<>(); } invokeLaterRunnables.add(new UIContextImplRunnable(uic, runnable)); }
[ "@", "Override", "public", "void", "invokeLater", "(", "final", "UIContext", "uic", ",", "final", "Runnable", "runnable", ")", "{", "if", "(", "invokeLaterRunnables", "==", "null", ")", "{", "invokeLaterRunnables", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "invokeLaterRunnables", ".", "add", "(", "new", "UIContextImplRunnable", "(", "uic", ",", "runnable", ")", ")", ";", "}" ]
Adds a runnable to the list of runnables to be invoked later. @param uic the UIContext to invoke the runnable in. @param runnable the runnable to add
[ "Adds", "a", "runnable", "to", "the", "list", "of", "runnables", "to", "be", "invoked", "later", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L195-L202
138,893
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java
UIContextImpl.setFocussed
@Override public void setFocussed(final WComponent component, final UIContext uic) { this.focussed = component; this.focussedUIC = uic; }
java
@Override public void setFocussed(final WComponent component, final UIContext uic) { this.focussed = component; this.focussedUIC = uic; }
[ "@", "Override", "public", "void", "setFocussed", "(", "final", "WComponent", "component", ",", "final", "UIContext", "uic", ")", "{", "this", ".", "focussed", "=", "component", ";", "this", ".", "focussedUIC", "=", "uic", ";", "}" ]
Sets the component in this UIC which is to be the focus of the client browser cursor. The id of the component is used to find the focussed element in the rendered html. Since id could be different in different contexts the context of the component is also needed. @param component - the component that sould be the cursor focus in the rendered UI. @param uic - the context that the component exists in.
[ "Sets", "the", "component", "in", "this", "UIC", "which", "is", "to", "be", "the", "focus", "of", "the", "client", "browser", "cursor", ".", "The", "id", "of", "the", "component", "is", "used", "to", "find", "the", "focussed", "element", "in", "the", "rendered", "html", ".", "Since", "id", "could", "be", "different", "in", "different", "contexts", "the", "context", "of", "the", "component", "is", "also", "needed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L260-L264
138,894
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java
UIContextImpl.getFwkAttribute
@Override public Object getFwkAttribute(final String name) { if (attribMap == null) { return null; } return attribMap.get(name); }
java
@Override public Object getFwkAttribute(final String name) { if (attribMap == null) { return null; } return attribMap.get(name); }
[ "@", "Override", "public", "Object", "getFwkAttribute", "(", "final", "String", "name", ")", "{", "if", "(", "attribMap", "==", "null", ")", "{", "return", "null", ";", "}", "return", "attribMap", ".", "get", "(", "name", ")", ";", "}" ]
Reserved for internal framework use. Retrieves a framework attribute. @param name the attribute name. @return the framework attribute with the given name.
[ "Reserved", "for", "internal", "framework", "use", ".", "Retrieves", "a", "framework", "attribute", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L346-L352
138,895
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java
UIContextImpl.setFwkAttribute
@Override public void setFwkAttribute(final String name, final Object value) { if (attribMap == null) { attribMap = new HashMap<>(); } attribMap.put(name, value); }
java
@Override public void setFwkAttribute(final String name, final Object value) { if (attribMap == null) { attribMap = new HashMap<>(); } attribMap.put(name, value); }
[ "@", "Override", "public", "void", "setFwkAttribute", "(", "final", "String", "name", ",", "final", "Object", "value", ")", "{", "if", "(", "attribMap", "==", "null", ")", "{", "attribMap", "=", "new", "HashMap", "<>", "(", ")", ";", "}", "attribMap", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Reserved for internal framework use. Sets a framework attribute. @param name the attribute name. @param value the attribute value.
[ "Reserved", "for", "internal", "framework", "use", ".", "Sets", "a", "framework", "attribute", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L360-L367
138,896
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java
UIContextImpl.getScratchMap
@Override public Map<Object, Object> getScratchMap(final WComponent component) { if (scratchMaps == null) { scratchMaps = new HashMap<>(); } Map<Object, Object> componentScratchMap = scratchMaps.get(component); if (componentScratchMap == null) { componentScratchMap = new HashMap<>(2); scratchMaps.put(component, componentScratchMap); } return componentScratchMap; }
java
@Override public Map<Object, Object> getScratchMap(final WComponent component) { if (scratchMaps == null) { scratchMaps = new HashMap<>(); } Map<Object, Object> componentScratchMap = scratchMaps.get(component); if (componentScratchMap == null) { componentScratchMap = new HashMap<>(2); scratchMaps.put(component, componentScratchMap); } return componentScratchMap; }
[ "@", "Override", "public", "Map", "<", "Object", ",", "Object", ">", "getScratchMap", "(", "final", "WComponent", "component", ")", "{", "if", "(", "scratchMaps", "==", "null", ")", "{", "scratchMaps", "=", "new", "HashMap", "<>", "(", ")", ";", "}", "Map", "<", "Object", ",", "Object", ">", "componentScratchMap", "=", "scratchMaps", ".", "get", "(", "component", ")", ";", "if", "(", "componentScratchMap", "==", "null", ")", "{", "componentScratchMap", "=", "new", "HashMap", "<>", "(", "2", ")", ";", "scratchMaps", ".", "put", "(", "component", ",", "componentScratchMap", ")", ";", "}", "return", "componentScratchMap", ";", "}" ]
Reserved for internal framework use. Retrieves a scratch area, where data can be temporarily stored. WComponents must not rely on data being available in the scratch area after each phase. @param component the component to retrieve the scratch map for. @return the scratch map for the given component.
[ "Reserved", "for", "internal", "framework", "use", ".", "Retrieves", "a", "scratch", "area", "where", "data", "can", "be", "temporarily", "stored", ".", "WComponents", "must", "not", "rely", "on", "data", "being", "available", "in", "the", "scratch", "area", "after", "each", "phase", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L402-L416
138,897
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WHeading.java
WHeading.setupLabel
private void setupLabel() { // To retain compatibility with the WText API, create a WText for this component, // which gets added to the label body. WText textBody = new WText() { @Override public boolean isEncodeText() { return WHeading.this.isEncodeText(); } @Override public String getText() { return WHeading.this.getText(); } }; if (label.getBody() == null) { label.setBody(textBody); } else { WComponent oldBody = label.getBody(); WContainer newBody = new WContainer(); label.setBody(newBody); newBody.add(textBody); newBody.add(oldBody); } }
java
private void setupLabel() { // To retain compatibility with the WText API, create a WText for this component, // which gets added to the label body. WText textBody = new WText() { @Override public boolean isEncodeText() { return WHeading.this.isEncodeText(); } @Override public String getText() { return WHeading.this.getText(); } }; if (label.getBody() == null) { label.setBody(textBody); } else { WComponent oldBody = label.getBody(); WContainer newBody = new WContainer(); label.setBody(newBody); newBody.add(textBody); newBody.add(oldBody); } }
[ "private", "void", "setupLabel", "(", ")", "{", "// To retain compatibility with the WText API, create a WText for this component,", "// which gets added to the label body.", "WText", "textBody", "=", "new", "WText", "(", ")", "{", "@", "Override", "public", "boolean", "isEncodeText", "(", ")", "{", "return", "WHeading", ".", "this", ".", "isEncodeText", "(", ")", ";", "}", "@", "Override", "public", "String", "getText", "(", ")", "{", "return", "WHeading", ".", "this", ".", "getText", "(", ")", ";", "}", "}", ";", "if", "(", "label", ".", "getBody", "(", ")", "==", "null", ")", "{", "label", ".", "setBody", "(", "textBody", ")", ";", "}", "else", "{", "WComponent", "oldBody", "=", "label", ".", "getBody", "(", ")", ";", "WContainer", "newBody", "=", "new", "WContainer", "(", ")", ";", "label", ".", "setBody", "(", "newBody", ")", ";", "newBody", ".", "add", "(", "textBody", ")", ";", "newBody", ".", "add", "(", "oldBody", ")", ";", "}", "}" ]
Setup the label.
[ "Setup", "the", "label", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WHeading.java#L134-L160
138,898
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WLabelExample.java
WLabelExample.addNullLabelExample
private void addNullLabelExample() { add(new WHeading(HeadingLevel.H2, "How to use accessible null WLabels")); add(new ExplanatoryText("These examples shows how sometime a null WLabel is the right thing to do." + "\n This example uses a WFieldSet as the labelled component and it has its own \"label\".")); // We want to add a WFieldSet to a WFieldLayout but without an extra label. WFieldLayout fieldsFlat = new WFieldLayout(); fieldsFlat.setMargin(new Margin(null, null, Size.XL, null)); add(fieldsFlat); WFieldSet fs = new WFieldSet("Do you like Bananas?"); fieldsFlat.addField((WLabel) null, fs); // now add the WRadioButtons to the WFieldSet using an inner WFieldLayout WFieldLayout innerLayout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED); // The content will be a group of WRadioButtons RadioButtonGroup group1 = new RadioButtonGroup(); WRadioButton rb1 = group1.addRadioButton(1); WRadioButton rb2 = group1.addRadioButton(2); //make the labels for the radio buttons WLabel rb1Label = new WLabel("", rb1); WImage labelImage = new WImage("/image/success.png", "I still like bananas"); labelImage.setHtmlClass("wc-valign-bottom"); rb1Label.add(labelImage); WLabel rb2Label = new WLabel("", rb2); labelImage = new WImage("/image/error.png", "I still dislike bananas"); labelImage.setHtmlClass("wc-valign-bottom"); rb2Label.add(labelImage); innerLayout.addField(rb1Label, rb1); innerLayout.addField(rb2Label, rb2); // add the content to the WFieldLayout - the order really doesn't matter. fs.add(group1); fs.add(innerLayout); }
java
private void addNullLabelExample() { add(new WHeading(HeadingLevel.H2, "How to use accessible null WLabels")); add(new ExplanatoryText("These examples shows how sometime a null WLabel is the right thing to do." + "\n This example uses a WFieldSet as the labelled component and it has its own \"label\".")); // We want to add a WFieldSet to a WFieldLayout but without an extra label. WFieldLayout fieldsFlat = new WFieldLayout(); fieldsFlat.setMargin(new Margin(null, null, Size.XL, null)); add(fieldsFlat); WFieldSet fs = new WFieldSet("Do you like Bananas?"); fieldsFlat.addField((WLabel) null, fs); // now add the WRadioButtons to the WFieldSet using an inner WFieldLayout WFieldLayout innerLayout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED); // The content will be a group of WRadioButtons RadioButtonGroup group1 = new RadioButtonGroup(); WRadioButton rb1 = group1.addRadioButton(1); WRadioButton rb2 = group1.addRadioButton(2); //make the labels for the radio buttons WLabel rb1Label = new WLabel("", rb1); WImage labelImage = new WImage("/image/success.png", "I still like bananas"); labelImage.setHtmlClass("wc-valign-bottom"); rb1Label.add(labelImage); WLabel rb2Label = new WLabel("", rb2); labelImage = new WImage("/image/error.png", "I still dislike bananas"); labelImage.setHtmlClass("wc-valign-bottom"); rb2Label.add(labelImage); innerLayout.addField(rb1Label, rb1); innerLayout.addField(rb2Label, rb2); // add the content to the WFieldLayout - the order really doesn't matter. fs.add(group1); fs.add(innerLayout); }
[ "private", "void", "addNullLabelExample", "(", ")", "{", "add", "(", "new", "WHeading", "(", "HeadingLevel", ".", "H2", ",", "\"How to use accessible null WLabels\"", ")", ")", ";", "add", "(", "new", "ExplanatoryText", "(", "\"These examples shows how sometime a null WLabel is the right thing to do.\"", "+", "\"\\n This example uses a WFieldSet as the labelled component and it has its own \\\"label\\\".\"", ")", ")", ";", "// We want to add a WFieldSet to a WFieldLayout but without an extra label.", "WFieldLayout", "fieldsFlat", "=", "new", "WFieldLayout", "(", ")", ";", "fieldsFlat", ".", "setMargin", "(", "new", "Margin", "(", "null", ",", "null", ",", "Size", ".", "XL", ",", "null", ")", ")", ";", "add", "(", "fieldsFlat", ")", ";", "WFieldSet", "fs", "=", "new", "WFieldSet", "(", "\"Do you like Bananas?\"", ")", ";", "fieldsFlat", ".", "addField", "(", "(", "WLabel", ")", "null", ",", "fs", ")", ";", "// now add the WRadioButtons to the WFieldSet using an inner WFieldLayout", "WFieldLayout", "innerLayout", "=", "new", "WFieldLayout", "(", "WFieldLayout", ".", "LAYOUT_STACKED", ")", ";", "// The content will be a group of WRadioButtons", "RadioButtonGroup", "group1", "=", "new", "RadioButtonGroup", "(", ")", ";", "WRadioButton", "rb1", "=", "group1", ".", "addRadioButton", "(", "1", ")", ";", "WRadioButton", "rb2", "=", "group1", ".", "addRadioButton", "(", "2", ")", ";", "//make the labels for the radio buttons", "WLabel", "rb1Label", "=", "new", "WLabel", "(", "\"\"", ",", "rb1", ")", ";", "WImage", "labelImage", "=", "new", "WImage", "(", "\"/image/success.png\"", ",", "\"I still like bananas\"", ")", ";", "labelImage", ".", "setHtmlClass", "(", "\"wc-valign-bottom\"", ")", ";", "rb1Label", ".", "add", "(", "labelImage", ")", ";", "WLabel", "rb2Label", "=", "new", "WLabel", "(", "\"\"", ",", "rb2", ")", ";", "labelImage", "=", "new", "WImage", "(", "\"/image/error.png\"", ",", "\"I still dislike bananas\"", ")", ";", "labelImage", ".", "setHtmlClass", "(", "\"wc-valign-bottom\"", ")", ";", "rb2Label", ".", "add", "(", "labelImage", ")", ";", "innerLayout", ".", "addField", "(", "rb1Label", ",", "rb1", ")", ";", "innerLayout", ".", "addField", "(", "rb2Label", ",", "rb2", ")", ";", "// add the content to the WFieldLayout - the order really doesn't matter.", "fs", ".", "add", "(", "group1", ")", ";", "fs", ".", "add", "(", "innerLayout", ")", ";", "}" ]
Example of when and how to use a null WLabel.
[ "Example", "of", "when", "and", "how", "to", "use", "a", "null", "WLabel", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WLabelExample.java#L142-L174
138,899
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WHeadingRenderer.java
WHeadingRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WHeading heading = (WHeading) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:heading"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("level", heading.getHeadingLevel().getLevel()); xml.appendOptionalAttribute("accessibleText", heading.getAccessibleText()); xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(heading, renderContext); if (heading.getDecoratedLabel() == null) { // Constructed with a String xml.append(heading.getText(), heading.isEncodeText()); } else { heading.getDecoratedLabel().paint(renderContext); } xml.appendEndTag("ui:heading"); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WHeading heading = (WHeading) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:heading"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendAttribute("level", heading.getHeadingLevel().getLevel()); xml.appendOptionalAttribute("accessibleText", heading.getAccessibleText()); xml.appendClose(); // Render margin MarginRendererUtil.renderMargin(heading, renderContext); if (heading.getDecoratedLabel() == null) { // Constructed with a String xml.append(heading.getText(), heading.isEncodeText()); } else { heading.getDecoratedLabel().paint(renderContext); } xml.appendEndTag("ui:heading"); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WHeading", "heading", "=", "(", "WHeading", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"ui:heading\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"id\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendAttribute", "(", "\"level\"", ",", "heading", ".", "getHeadingLevel", "(", ")", ".", "getLevel", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"accessibleText\"", ",", "heading", ".", "getAccessibleText", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Render margin", "MarginRendererUtil", ".", "renderMargin", "(", "heading", ",", "renderContext", ")", ";", "if", "(", "heading", ".", "getDecoratedLabel", "(", ")", "==", "null", ")", "{", "// Constructed with a String", "xml", ".", "append", "(", "heading", ".", "getText", "(", ")", ",", "heading", ".", "isEncodeText", "(", ")", ")", ";", "}", "else", "{", "heading", ".", "getDecoratedLabel", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:heading\"", ")", ";", "}" ]
Paints the given WHeading. @param component the WHeading to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WHeading", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WHeadingRenderer.java#L23-L47