id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
139,500 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownTriggerActionExample.java | WDropdownTriggerActionExample.getSuburbs | private static String[] getSuburbs(final String region) {
if ("Tuggeranong".equals(region)) {
return TUGGERANONG_SUBURBS;
} else if ("Woden".equals(region)) {
return WODEN_SUBURBS;
} else if ("Melbourne".equals(region)) {
return MELBOURNE_SUBURBS;
} else if ("Mornington Peninsula".equals(region)) {
return MORNINGTON_SUBURBS;
} else {
return null;
}
} | java | private static String[] getSuburbs(final String region) {
if ("Tuggeranong".equals(region)) {
return TUGGERANONG_SUBURBS;
} else if ("Woden".equals(region)) {
return WODEN_SUBURBS;
} else if ("Melbourne".equals(region)) {
return MELBOURNE_SUBURBS;
} else if ("Mornington Peninsula".equals(region)) {
return MORNINGTON_SUBURBS;
} else {
return null;
}
} | [
"private",
"static",
"String",
"[",
"]",
"getSuburbs",
"(",
"final",
"String",
"region",
")",
"{",
"if",
"(",
"\"Tuggeranong\"",
".",
"equals",
"(",
"region",
")",
")",
"{",
"return",
"TUGGERANONG_SUBURBS",
";",
"}",
"else",
"if",
"(",
"\"Woden\"",
".",
"equals",
"(",
"region",
")",
")",
"{",
"return",
"WODEN_SUBURBS",
";",
"}",
"else",
"if",
"(",
"\"Melbourne\"",
".",
"equals",
"(",
"region",
")",
")",
"{",
"return",
"MELBOURNE_SUBURBS",
";",
"}",
"else",
"if",
"(",
"\"Mornington Peninsula\"",
".",
"equals",
"(",
"region",
")",
")",
"{",
"return",
"MORNINGTON_SUBURBS",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Retrieves the suburbs in a region.
@param region the region.
@return the suburbs in the given region. | [
"Retrieves",
"the",
"suburbs",
"in",
"a",
"region",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownTriggerActionExample.java#L169-L181 |
139,501 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/ajax/WCollapsibleOptionsExample.java | WCollapsibleOptionsExample.applySettings | private void applySettings() {
// reset the container.
container.reset();
// create the new collapsible.
WText component1 = new WText("Here is some text that is collapsible via ajax.");
WCollapsible collapsible1 = new WCollapsible(component1, "Collapsible",
(CollapsibleMode) rbCollapsibleSelect.getSelected());
collapsible1.setCollapsed(cbCollapsed.isSelected());
collapsible1.setVisible(cbVisible.isSelected());
if (collapsible1.getMode() == CollapsibleMode.DYNAMIC) {
component1.setText(component1.getText() + "\u00a0Generated on " + new Date());
}
if (drpHeadingLevels.getSelected() != null) {
collapsible1.setHeadingLevel((HeadingLevel) drpHeadingLevels.getSelected());
}
// add the new collapsible to the container.
container.add(collapsible1);
} | java | private void applySettings() {
// reset the container.
container.reset();
// create the new collapsible.
WText component1 = new WText("Here is some text that is collapsible via ajax.");
WCollapsible collapsible1 = new WCollapsible(component1, "Collapsible",
(CollapsibleMode) rbCollapsibleSelect.getSelected());
collapsible1.setCollapsed(cbCollapsed.isSelected());
collapsible1.setVisible(cbVisible.isSelected());
if (collapsible1.getMode() == CollapsibleMode.DYNAMIC) {
component1.setText(component1.getText() + "\u00a0Generated on " + new Date());
}
if (drpHeadingLevels.getSelected() != null) {
collapsible1.setHeadingLevel((HeadingLevel) drpHeadingLevels.getSelected());
}
// add the new collapsible to the container.
container.add(collapsible1);
} | [
"private",
"void",
"applySettings",
"(",
")",
"{",
"// reset the container.",
"container",
".",
"reset",
"(",
")",
";",
"// create the new collapsible.",
"WText",
"component1",
"=",
"new",
"WText",
"(",
"\"Here is some text that is collapsible via ajax.\"",
")",
";",
"WCollapsible",
"collapsible1",
"=",
"new",
"WCollapsible",
"(",
"component1",
",",
"\"Collapsible\"",
",",
"(",
"CollapsibleMode",
")",
"rbCollapsibleSelect",
".",
"getSelected",
"(",
")",
")",
";",
"collapsible1",
".",
"setCollapsed",
"(",
"cbCollapsed",
".",
"isSelected",
"(",
")",
")",
";",
"collapsible1",
".",
"setVisible",
"(",
"cbVisible",
".",
"isSelected",
"(",
")",
")",
";",
"if",
"(",
"collapsible1",
".",
"getMode",
"(",
")",
"==",
"CollapsibleMode",
".",
"DYNAMIC",
")",
"{",
"component1",
".",
"setText",
"(",
"component1",
".",
"getText",
"(",
")",
"+",
"\"\\u00a0Generated on \"",
"+",
"new",
"Date",
"(",
")",
")",
";",
"}",
"if",
"(",
"drpHeadingLevels",
".",
"getSelected",
"(",
")",
"!=",
"null",
")",
"{",
"collapsible1",
".",
"setHeadingLevel",
"(",
"(",
"HeadingLevel",
")",
"drpHeadingLevels",
".",
"getSelected",
"(",
")",
")",
";",
"}",
"// add the new collapsible to the container.",
"container",
".",
"add",
"(",
"collapsible1",
")",
";",
"}"
] | applySettings creates the WCollapsible, and loads it into the container. | [
"applySettings",
"creates",
"the",
"WCollapsible",
"and",
"loads",
"it",
"into",
"the",
"container",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/ajax/WCollapsibleOptionsExample.java#L97-L119 |
139,502 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMenuItemGroupRenderer.java | WMenuItemGroupRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMenuItemGroup group = (WMenuItemGroup) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:menugroup");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendClose();
paintChildren(group, renderContext);
xml.appendEndTag("ui:menugroup");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMenuItemGroup group = (WMenuItemGroup) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:menugroup");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendClose();
paintChildren(group, renderContext);
xml.appendEndTag("ui:menugroup");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WMenuItemGroup",
"group",
"=",
"(",
"WMenuItemGroup",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:menugroup\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"paintChildren",
"(",
"group",
",",
"renderContext",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:menugroup\"",
")",
";",
"}"
] | Paints the given WMenuItemGroup.
@param component the WMenuItemGroup to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WMenuItemGroup",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMenuItemGroupRenderer.java#L22-L36 |
139,503 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiDropdownRenderer.java | WMultiDropdownRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiDropdown dropdown = (WMultiDropdown) component;
XmlStringBuilder xml = renderContext.getWriter();
String dataKey = dropdown.getListCacheKey();
boolean readOnly = dropdown.isReadOnly();
xml.appendTagOpen("ui:multidropdown");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", dropdown.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendOptionalAttribute("data", dataKey != null && !readOnly, dataKey);
xml.appendOptionalAttribute("disabled", dropdown.isDisabled(), "true");
xml.appendOptionalAttribute("required", dropdown.isMandatory(), "true");
xml.appendOptionalAttribute("submitOnChange", dropdown.isSubmitOnChange(), "true");
xml.appendOptionalAttribute("toolTip", component.getToolTip());
xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
int min = dropdown.getMinSelect();
int max = dropdown.getMaxSelect();
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTIDROPDOWN_TIP));
}
xml.appendClose();
// Options
List<?> options = dropdown.getOptions();
boolean renderSelectionsOnly = dropdown.isReadOnly() || dataKey != null;
if (options != null) {
int optionIndex = 0;
List<?> selections = dropdown.getSelected();
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
for (Object nestedOption : ((OptionGroup) option).getOptions()) {
renderOption(dropdown, nestedOption, optionIndex++, xml, selections,
renderSelectionsOnly);
}
xml.appendEndTag("ui:optgroup");
} else {
renderOption(dropdown, option, optionIndex++, xml, selections,
renderSelectionsOnly);
}
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(dropdown, renderContext);
}
// End tag
xml.appendEndTag("ui:multidropdown");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiDropdown dropdown = (WMultiDropdown) component;
XmlStringBuilder xml = renderContext.getWriter();
String dataKey = dropdown.getListCacheKey();
boolean readOnly = dropdown.isReadOnly();
xml.appendTagOpen("ui:multidropdown");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", dropdown.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendOptionalAttribute("data", dataKey != null && !readOnly, dataKey);
xml.appendOptionalAttribute("disabled", dropdown.isDisabled(), "true");
xml.appendOptionalAttribute("required", dropdown.isMandatory(), "true");
xml.appendOptionalAttribute("submitOnChange", dropdown.isSubmitOnChange(), "true");
xml.appendOptionalAttribute("toolTip", component.getToolTip());
xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
int min = dropdown.getMinSelect();
int max = dropdown.getMaxSelect();
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTIDROPDOWN_TIP));
}
xml.appendClose();
// Options
List<?> options = dropdown.getOptions();
boolean renderSelectionsOnly = dropdown.isReadOnly() || dataKey != null;
if (options != null) {
int optionIndex = 0;
List<?> selections = dropdown.getSelected();
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
for (Object nestedOption : ((OptionGroup) option).getOptions()) {
renderOption(dropdown, nestedOption, optionIndex++, xml, selections,
renderSelectionsOnly);
}
xml.appendEndTag("ui:optgroup");
} else {
renderOption(dropdown, option, optionIndex++, xml, selections,
renderSelectionsOnly);
}
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(dropdown, renderContext);
}
// End tag
xml.appendEndTag("ui:multidropdown");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WMultiDropdown",
"dropdown",
"=",
"(",
"WMultiDropdown",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"String",
"dataKey",
"=",
"dropdown",
".",
"getListCacheKey",
"(",
")",
";",
"boolean",
"readOnly",
"=",
"dropdown",
".",
"isReadOnly",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:multidropdown\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"dropdown",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"readOnly",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"readOnly\"",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"data\"",
",",
"dataKey",
"!=",
"null",
"&&",
"!",
"readOnly",
",",
"dataKey",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"dropdown",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"required\"",
",",
"dropdown",
".",
"isMandatory",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"submitOnChange\"",
",",
"dropdown",
".",
"isSubmitOnChange",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"toolTip\"",
",",
"component",
".",
"getToolTip",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"accessibleText\"",
",",
"component",
".",
"getAccessibleText",
"(",
")",
")",
";",
"int",
"min",
"=",
"dropdown",
".",
"getMinSelect",
"(",
")",
";",
"int",
"max",
"=",
"dropdown",
".",
"getMaxSelect",
"(",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"min\"",
",",
"min",
">",
"0",
",",
"min",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"max\"",
",",
"max",
">",
"0",
",",
"max",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"title\"",
",",
"I18nUtilities",
".",
"format",
"(",
"null",
",",
"InternalMessages",
".",
"DEFAULT_MULTIDROPDOWN_TIP",
")",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Options",
"List",
"<",
"?",
">",
"options",
"=",
"dropdown",
".",
"getOptions",
"(",
")",
";",
"boolean",
"renderSelectionsOnly",
"=",
"dropdown",
".",
"isReadOnly",
"(",
")",
"||",
"dataKey",
"!=",
"null",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"int",
"optionIndex",
"=",
"0",
";",
"List",
"<",
"?",
">",
"selections",
"=",
"dropdown",
".",
"getSelected",
"(",
")",
";",
"for",
"(",
"Object",
"option",
":",
"options",
")",
"{",
"if",
"(",
"option",
"instanceof",
"OptionGroup",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:optgroup\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"label\"",
",",
"(",
"(",
"OptionGroup",
")",
"option",
")",
".",
"getDesc",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"for",
"(",
"Object",
"nestedOption",
":",
"(",
"(",
"OptionGroup",
")",
"option",
")",
".",
"getOptions",
"(",
")",
")",
"{",
"renderOption",
"(",
"dropdown",
",",
"nestedOption",
",",
"optionIndex",
"++",
",",
"xml",
",",
"selections",
",",
"renderSelectionsOnly",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:optgroup\"",
")",
";",
"}",
"else",
"{",
"renderOption",
"(",
"dropdown",
",",
"option",
",",
"optionIndex",
"++",
",",
"xml",
",",
"selections",
",",
"renderSelectionsOnly",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"readOnly",
")",
"{",
"DiagnosticRenderUtil",
".",
"renderDiagnostics",
"(",
"dropdown",
",",
"renderContext",
")",
";",
"}",
"// End tag",
"xml",
".",
"appendEndTag",
"(",
"\"ui:multidropdown\"",
")",
";",
"}"
] | Paints the given WMultiDropdown.
@param component the WMultiDropdown to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WMultiDropdown",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiDropdownRenderer.java#L27-L89 |
139,504 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/transientcontainer/ExampleTablePanel.java | ExampleTablePanel.setData | public void setData(final List data) {
// Bean properties to render
String[] properties = new String[]{"colour", "shape", "animal"};
simpleTable.setDataModel(new SimpleBeanListTableDataModel(properties, data));
} | java | public void setData(final List data) {
// Bean properties to render
String[] properties = new String[]{"colour", "shape", "animal"};
simpleTable.setDataModel(new SimpleBeanListTableDataModel(properties, data));
} | [
"public",
"void",
"setData",
"(",
"final",
"List",
"data",
")",
"{",
"// Bean properties to render",
"String",
"[",
"]",
"properties",
"=",
"new",
"String",
"[",
"]",
"{",
"\"colour\"",
",",
"\"shape\"",
",",
"\"animal\"",
"}",
";",
"simpleTable",
".",
"setDataModel",
"(",
"new",
"SimpleBeanListTableDataModel",
"(",
"properties",
",",
"data",
")",
")",
";",
"}"
] | Sets the table data.
@param data a list of {@link ExampleDataBean}s. | [
"Sets",
"the",
"table",
"data",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/transientcontainer/ExampleTablePanel.java#L46-L51 |
139,505 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldSet.java | WFieldSet.setMandatory | public void setMandatory(final boolean mandatory, final String message) {
setFlag(ComponentModel.MANDATORY_FLAG, mandatory);
getOrCreateComponentModel().errorMessage = message;
} | java | public void setMandatory(final boolean mandatory, final String message) {
setFlag(ComponentModel.MANDATORY_FLAG, mandatory);
getOrCreateComponentModel().errorMessage = message;
} | [
"public",
"void",
"setMandatory",
"(",
"final",
"boolean",
"mandatory",
",",
"final",
"String",
"message",
")",
"{",
"setFlag",
"(",
"ComponentModel",
".",
"MANDATORY_FLAG",
",",
"mandatory",
")",
";",
"getOrCreateComponentModel",
"(",
")",
".",
"errorMessage",
"=",
"message",
";",
"}"
] | Set whether or not this field set is mandatory, and customise the error message that will be displayed.
@param mandatory true for mandatory, false for optional.
@param message the message to display to the user on mandatory validation failure. | [
"Set",
"whether",
"or",
"not",
"this",
"field",
"set",
"is",
"mandatory",
"and",
"customise",
"the",
"error",
"message",
"that",
"will",
"be",
"displayed",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldSet.java#L110-L113 |
139,506 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldSet.java | WFieldSet.hasInputWithValue | private boolean hasInputWithValue() {
// Visit all children of the fieldset of type Input
AbstractVisitorWithResult<Boolean> visitor = new AbstractVisitorWithResult<Boolean>() {
@Override
public WComponentTreeVisitor.VisitorResult visit(final WComponent comp) {
// Check if the component is an Input and has a value
if (comp instanceof Input && !((Input) comp).isEmpty()) {
setResult(true);
return VisitorResult.ABORT;
}
return VisitorResult.CONTINUE;
}
};
visitor.setResult(false);
TreeUtil.traverseVisible(this, visitor);
return visitor.getResult();
} | java | private boolean hasInputWithValue() {
// Visit all children of the fieldset of type Input
AbstractVisitorWithResult<Boolean> visitor = new AbstractVisitorWithResult<Boolean>() {
@Override
public WComponentTreeVisitor.VisitorResult visit(final WComponent comp) {
// Check if the component is an Input and has a value
if (comp instanceof Input && !((Input) comp).isEmpty()) {
setResult(true);
return VisitorResult.ABORT;
}
return VisitorResult.CONTINUE;
}
};
visitor.setResult(false);
TreeUtil.traverseVisible(this, visitor);
return visitor.getResult();
} | [
"private",
"boolean",
"hasInputWithValue",
"(",
")",
"{",
"// Visit all children of the fieldset of type Input",
"AbstractVisitorWithResult",
"<",
"Boolean",
">",
"visitor",
"=",
"new",
"AbstractVisitorWithResult",
"<",
"Boolean",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WComponentTreeVisitor",
".",
"VisitorResult",
"visit",
"(",
"final",
"WComponent",
"comp",
")",
"{",
"// Check if the component is an Input and has a value",
"if",
"(",
"comp",
"instanceof",
"Input",
"&&",
"!",
"(",
"(",
"Input",
")",
"comp",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"setResult",
"(",
"true",
")",
";",
"return",
"VisitorResult",
".",
"ABORT",
";",
"}",
"return",
"VisitorResult",
".",
"CONTINUE",
";",
"}",
"}",
";",
"visitor",
".",
"setResult",
"(",
"false",
")",
";",
"TreeUtil",
".",
"traverseVisible",
"(",
"this",
",",
"visitor",
")",
";",
"return",
"visitor",
".",
"getResult",
"(",
")",
";",
"}"
] | Checks at least one input component has a value.
@return true if the field set contains an input with a value | [
"Checks",
"at",
"least",
"one",
"input",
"component",
"has",
"a",
"value",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldSet.java#L152-L171 |
139,507 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeItemUtil.java | TreeItemUtil.processJsonToTree | private static void processJsonToTree(final TreeItemIdNode parentNode, final JsonObject json) {
String id = json.getAsJsonPrimitive("id").getAsString();
JsonPrimitive expandableJson = json.getAsJsonPrimitive("expandable");
TreeItemIdNode node = new TreeItemIdNode(id);
if (expandableJson != null && expandableJson.getAsBoolean()) {
node.setHasChildren(true);
}
parentNode.addChild(node);
JsonArray children = json.getAsJsonArray("items");
if (children != null) {
for (int i = 0; i < children.size(); i++) {
JsonObject child = children.get(i).getAsJsonObject();
processJsonToTree(node, child);
}
}
} | java | private static void processJsonToTree(final TreeItemIdNode parentNode, final JsonObject json) {
String id = json.getAsJsonPrimitive("id").getAsString();
JsonPrimitive expandableJson = json.getAsJsonPrimitive("expandable");
TreeItemIdNode node = new TreeItemIdNode(id);
if (expandableJson != null && expandableJson.getAsBoolean()) {
node.setHasChildren(true);
}
parentNode.addChild(node);
JsonArray children = json.getAsJsonArray("items");
if (children != null) {
for (int i = 0; i < children.size(); i++) {
JsonObject child = children.get(i).getAsJsonObject();
processJsonToTree(node, child);
}
}
} | [
"private",
"static",
"void",
"processJsonToTree",
"(",
"final",
"TreeItemIdNode",
"parentNode",
",",
"final",
"JsonObject",
"json",
")",
"{",
"String",
"id",
"=",
"json",
".",
"getAsJsonPrimitive",
"(",
"\"id\"",
")",
".",
"getAsString",
"(",
")",
";",
"JsonPrimitive",
"expandableJson",
"=",
"json",
".",
"getAsJsonPrimitive",
"(",
"\"expandable\"",
")",
";",
"TreeItemIdNode",
"node",
"=",
"new",
"TreeItemIdNode",
"(",
"id",
")",
";",
"if",
"(",
"expandableJson",
"!=",
"null",
"&&",
"expandableJson",
".",
"getAsBoolean",
"(",
")",
")",
"{",
"node",
".",
"setHasChildren",
"(",
"true",
")",
";",
"}",
"parentNode",
".",
"addChild",
"(",
"node",
")",
";",
"JsonArray",
"children",
"=",
"json",
".",
"getAsJsonArray",
"(",
"\"items\"",
")",
";",
"if",
"(",
"children",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"JsonObject",
"child",
"=",
"children",
".",
"get",
"(",
"i",
")",
".",
"getAsJsonObject",
"(",
")",
";",
"processJsonToTree",
"(",
"node",
",",
"child",
")",
";",
"}",
"}",
"}"
] | Iterate over the JSON objects to create the tree structure.
@param parentNode the parent node
@param json the current JSON object | [
"Iterate",
"over",
"the",
"JSON",
"objects",
"to",
"create",
"the",
"tree",
"structure",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeItemUtil.java#L247-L265 |
139,508 | ebean-orm/ebean-querybean | src/main/java/io/ebean/typequery/TQRootBean.java | TQRootBean.fetchQuery | public R fetchQuery(String path, String properties) {
query.fetchQuery(path, properties);
return root;
} | java | public R fetchQuery(String path, String properties) {
query.fetchQuery(path, properties);
return root;
} | [
"public",
"R",
"fetchQuery",
"(",
"String",
"path",
",",
"String",
"properties",
")",
"{",
"query",
".",
"fetchQuery",
"(",
"path",
",",
"properties",
")",
";",
"return",
"root",
";",
"}"
] | Specify a path and properties to load using a "query join".
<pre>{@code
List<Customer> customers =
new QCustomer()
// eager fetch contacts using a "query join"
.fetchQuery("contacts", "email, firstName, lastName")
.findList();
}</pre>
@param path the property path of an associated (OneToOne, OneToMany, ManyToOne or ManyToMany) bean. | [
"Specify",
"a",
"path",
"and",
"properties",
"to",
"load",
"using",
"a",
"query",
"join",
"."
] | 821650cb817c9c0fdcc97f93408dc79170b12423 | https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQRootBean.java#L322-L325 |
139,509 | ebean-orm/ebean-querybean | src/main/java/io/ebean/typequery/TQRootBean.java | TQRootBean.pushExprList | private R pushExprList(ExpressionList<T> list) {
if (textMode) {
textStack.push(list);
} else {
whereStack.push(list);
}
return root;
} | java | private R pushExprList(ExpressionList<T> list) {
if (textMode) {
textStack.push(list);
} else {
whereStack.push(list);
}
return root;
} | [
"private",
"R",
"pushExprList",
"(",
"ExpressionList",
"<",
"T",
">",
"list",
")",
"{",
"if",
"(",
"textMode",
")",
"{",
"textStack",
".",
"push",
"(",
"list",
")",
";",
"}",
"else",
"{",
"whereStack",
".",
"push",
"(",
"list",
")",
";",
"}",
"return",
"root",
";",
"}"
] | Push the expression list onto the appropriate stack. | [
"Push",
"the",
"expression",
"list",
"onto",
"the",
"appropriate",
"stack",
"."
] | 821650cb817c9c0fdcc97f93408dc79170b12423 | https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQRootBean.java#L1330-L1337 |
139,510 | ebean-orm/ebean-querybean | src/main/java/io/ebean/typequery/TQRootBean.java | TQRootBean.peekExprList | protected ExpressionList<T> peekExprList() {
if (textMode) {
// return the current text expression list
return _peekText();
}
if (whereStack == null) {
whereStack = new ArrayStack<>();
whereStack.push(query.where());
}
// return the current expression list
return whereStack.peek();
} | java | protected ExpressionList<T> peekExprList() {
if (textMode) {
// return the current text expression list
return _peekText();
}
if (whereStack == null) {
whereStack = new ArrayStack<>();
whereStack.push(query.where());
}
// return the current expression list
return whereStack.peek();
} | [
"protected",
"ExpressionList",
"<",
"T",
">",
"peekExprList",
"(",
")",
"{",
"if",
"(",
"textMode",
")",
"{",
"// return the current text expression list",
"return",
"_peekText",
"(",
")",
";",
"}",
"if",
"(",
"whereStack",
"==",
"null",
")",
"{",
"whereStack",
"=",
"new",
"ArrayStack",
"<>",
"(",
")",
";",
"whereStack",
".",
"push",
"(",
"query",
".",
"where",
"(",
")",
")",
";",
"}",
"// return the current expression list",
"return",
"whereStack",
".",
"peek",
"(",
")",
";",
"}"
] | Return the current expression list that expressions should be added to. | [
"Return",
"the",
"current",
"expression",
"list",
"that",
"expressions",
"should",
"be",
"added",
"to",
"."
] | 821650cb817c9c0fdcc97f93408dc79170b12423 | https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQRootBean.java#L1983-L1996 |
139,511 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.notEquals | public ExpressionBuilder notEquals(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.NOT_EQUAL, trigger, compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder notEquals(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.NOT_EQUAL, trigger, compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"notEquals",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"Object",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"NOT_EQUAL",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a not equals test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"not",
"equals",
"test",
"to",
"the",
"condition",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L77-L82 |
139,512 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.lessThan | public ExpressionBuilder lessThan(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.LESS_THAN, trigger, compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder lessThan(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.LESS_THAN, trigger, compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"lessThan",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"Object",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"LESS_THAN",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a less than test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"less",
"than",
"test",
"to",
"the",
"condition",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L91-L96 |
139,513 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.lessThanOrEquals | public ExpressionBuilder lessThanOrEquals(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.LESS_THAN_OR_EQUAL, trigger,
compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder lessThanOrEquals(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.LESS_THAN_OR_EQUAL, trigger,
compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"lessThanOrEquals",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"Object",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"LESS_THAN_OR_EQUAL",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a less than or equals test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"less",
"than",
"or",
"equals",
"test",
"to",
"the",
"condition",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L105-L111 |
139,514 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.greaterThan | public ExpressionBuilder greaterThan(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.GREATER_THAN, trigger, compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder greaterThan(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.GREATER_THAN, trigger, compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"greaterThan",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"Object",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"GREATER_THAN",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a greater than test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"greater",
"than",
"test",
"to",
"the",
"condition",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L120-L125 |
139,515 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.greaterThanOrEquals | public ExpressionBuilder greaterThanOrEquals(final SubordinateTrigger trigger,
final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.GREATER_THAN_OR_EQUAL, trigger,
compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder greaterThanOrEquals(final SubordinateTrigger trigger,
final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.GREATER_THAN_OR_EQUAL, trigger,
compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"greaterThanOrEquals",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"Object",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"GREATER_THAN_OR_EQUAL",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a greater than or equals test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"greater",
"than",
"or",
"equals",
"test",
"to",
"the",
"condition",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L134-L141 |
139,516 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.matches | public ExpressionBuilder matches(final SubordinateTrigger trigger, final String compare) {
BooleanExpression exp = new CompareExpression(CompareType.MATCH, trigger, compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder matches(final SubordinateTrigger trigger, final String compare) {
BooleanExpression exp = new CompareExpression(CompareType.MATCH, trigger, compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"matches",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"String",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"MATCH",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a matches test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"matches",
"test",
"to",
"the",
"condition",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L150-L155 |
139,517 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.or | public ExpressionBuilder or() {
GroupExpression lastGroupExpression = stack.isEmpty() ? null : stack.peek();
if (lhsExpression == null) {
throw new SyntaxException("Syntax exception: OR missing LHS operand");
} else if (lastGroupExpression == null) {
GroupExpression or = new GroupExpression(GroupExpression.Type.OR);
or.add(lhsExpression);
stack.push(or);
expression.setExpression(or);
lhsExpression = null;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.OR)) {
// Keep using the existing OR
lhsExpression = null;
return this;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.AND)) {
// AND takes precedence over OR, so we wrap the AND
// by removing it from any parent expressions and inserting the OR in its place
GroupExpression and = stack.pop();
GroupExpression or = new GroupExpression(GroupExpression.Type.OR);
if (stack.isEmpty()) {
expression.setExpression(or);
or.add(and);
} else {
// need to get at the parent
GroupExpression parent = stack.pop();
parent.remove(and);
parent.add(or);
or.add(and);
}
stack.push(and);
stack.push(or);
lhsExpression = null;
}
return this;
} | java | public ExpressionBuilder or() {
GroupExpression lastGroupExpression = stack.isEmpty() ? null : stack.peek();
if (lhsExpression == null) {
throw new SyntaxException("Syntax exception: OR missing LHS operand");
} else if (lastGroupExpression == null) {
GroupExpression or = new GroupExpression(GroupExpression.Type.OR);
or.add(lhsExpression);
stack.push(or);
expression.setExpression(or);
lhsExpression = null;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.OR)) {
// Keep using the existing OR
lhsExpression = null;
return this;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.AND)) {
// AND takes precedence over OR, so we wrap the AND
// by removing it from any parent expressions and inserting the OR in its place
GroupExpression and = stack.pop();
GroupExpression or = new GroupExpression(GroupExpression.Type.OR);
if (stack.isEmpty()) {
expression.setExpression(or);
or.add(and);
} else {
// need to get at the parent
GroupExpression parent = stack.pop();
parent.remove(and);
parent.add(or);
or.add(and);
}
stack.push(and);
stack.push(or);
lhsExpression = null;
}
return this;
} | [
"public",
"ExpressionBuilder",
"or",
"(",
")",
"{",
"GroupExpression",
"lastGroupExpression",
"=",
"stack",
".",
"isEmpty",
"(",
")",
"?",
"null",
":",
"stack",
".",
"peek",
"(",
")",
";",
"if",
"(",
"lhsExpression",
"==",
"null",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"\"Syntax exception: OR missing LHS operand\"",
")",
";",
"}",
"else",
"if",
"(",
"lastGroupExpression",
"==",
"null",
")",
"{",
"GroupExpression",
"or",
"=",
"new",
"GroupExpression",
"(",
"GroupExpression",
".",
"Type",
".",
"OR",
")",
";",
"or",
".",
"add",
"(",
"lhsExpression",
")",
";",
"stack",
".",
"push",
"(",
"or",
")",
";",
"expression",
".",
"setExpression",
"(",
"or",
")",
";",
"lhsExpression",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"lastGroupExpression",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"GroupExpression",
".",
"Type",
".",
"OR",
")",
")",
"{",
"// Keep using the existing OR",
"lhsExpression",
"=",
"null",
";",
"return",
"this",
";",
"}",
"else",
"if",
"(",
"lastGroupExpression",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"GroupExpression",
".",
"Type",
".",
"AND",
")",
")",
"{",
"// AND takes precedence over OR, so we wrap the AND",
"// by removing it from any parent expressions and inserting the OR in its place",
"GroupExpression",
"and",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"GroupExpression",
"or",
"=",
"new",
"GroupExpression",
"(",
"GroupExpression",
".",
"Type",
".",
"OR",
")",
";",
"if",
"(",
"stack",
".",
"isEmpty",
"(",
")",
")",
"{",
"expression",
".",
"setExpression",
"(",
"or",
")",
";",
"or",
".",
"add",
"(",
"and",
")",
";",
"}",
"else",
"{",
"// need to get at the parent",
"GroupExpression",
"parent",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"parent",
".",
"remove",
"(",
"and",
")",
";",
"parent",
".",
"add",
"(",
"or",
")",
";",
"or",
".",
"add",
"(",
"and",
")",
";",
"}",
"stack",
".",
"push",
"(",
"and",
")",
";",
"stack",
".",
"push",
"(",
"or",
")",
";",
"lhsExpression",
"=",
"null",
";",
"}",
"return",
"this",
";",
"}"
] | Appends an OR expression to the RHS of the expression. The current RHS of the expression must be an Operand.
@return this ExpressionBuilder. | [
"Appends",
"an",
"OR",
"expression",
"to",
"the",
"RHS",
"of",
"the",
"expression",
".",
"The",
"current",
"RHS",
"of",
"the",
"expression",
"must",
"be",
"an",
"Operand",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L165-L204 |
139,518 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.and | public ExpressionBuilder and() {
GroupExpression lastGroupExpression = stack.isEmpty() ? null : stack.peek();
if (lhsExpression == null) {
throw new SyntaxException("Syntax exception: AND missing LHS operand");
} else if (lastGroupExpression == null) {
GroupExpression and = new GroupExpression(GroupExpression.Type.AND);
and.add(lhsExpression);
stack.push(and);
expression.setExpression(and);
lhsExpression = null;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.AND)) {
// Keep using the existing AND
lhsExpression = null;
return this;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.OR)) {
// AND takes precedence over OR, so we steal the OR's RHS
GroupExpression or = lastGroupExpression;
GroupExpression and = new GroupExpression(GroupExpression.Type.AND);
or.remove(lhsExpression);
and.add(lhsExpression);
or.add(and);
stack.push(and);
lhsExpression = null;
}
return this;
} | java | public ExpressionBuilder and() {
GroupExpression lastGroupExpression = stack.isEmpty() ? null : stack.peek();
if (lhsExpression == null) {
throw new SyntaxException("Syntax exception: AND missing LHS operand");
} else if (lastGroupExpression == null) {
GroupExpression and = new GroupExpression(GroupExpression.Type.AND);
and.add(lhsExpression);
stack.push(and);
expression.setExpression(and);
lhsExpression = null;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.AND)) {
// Keep using the existing AND
lhsExpression = null;
return this;
} else if (lastGroupExpression.getType().equals(GroupExpression.Type.OR)) {
// AND takes precedence over OR, so we steal the OR's RHS
GroupExpression or = lastGroupExpression;
GroupExpression and = new GroupExpression(GroupExpression.Type.AND);
or.remove(lhsExpression);
and.add(lhsExpression);
or.add(and);
stack.push(and);
lhsExpression = null;
}
return this;
} | [
"public",
"ExpressionBuilder",
"and",
"(",
")",
"{",
"GroupExpression",
"lastGroupExpression",
"=",
"stack",
".",
"isEmpty",
"(",
")",
"?",
"null",
":",
"stack",
".",
"peek",
"(",
")",
";",
"if",
"(",
"lhsExpression",
"==",
"null",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"\"Syntax exception: AND missing LHS operand\"",
")",
";",
"}",
"else",
"if",
"(",
"lastGroupExpression",
"==",
"null",
")",
"{",
"GroupExpression",
"and",
"=",
"new",
"GroupExpression",
"(",
"GroupExpression",
".",
"Type",
".",
"AND",
")",
";",
"and",
".",
"add",
"(",
"lhsExpression",
")",
";",
"stack",
".",
"push",
"(",
"and",
")",
";",
"expression",
".",
"setExpression",
"(",
"and",
")",
";",
"lhsExpression",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"lastGroupExpression",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"GroupExpression",
".",
"Type",
".",
"AND",
")",
")",
"{",
"// Keep using the existing AND",
"lhsExpression",
"=",
"null",
";",
"return",
"this",
";",
"}",
"else",
"if",
"(",
"lastGroupExpression",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"GroupExpression",
".",
"Type",
".",
"OR",
")",
")",
"{",
"// AND takes precedence over OR, so we steal the OR's RHS",
"GroupExpression",
"or",
"=",
"lastGroupExpression",
";",
"GroupExpression",
"and",
"=",
"new",
"GroupExpression",
"(",
"GroupExpression",
".",
"Type",
".",
"AND",
")",
";",
"or",
".",
"remove",
"(",
"lhsExpression",
")",
";",
"and",
".",
"add",
"(",
"lhsExpression",
")",
";",
"or",
".",
"add",
"(",
"and",
")",
";",
"stack",
".",
"push",
"(",
"and",
")",
";",
"lhsExpression",
"=",
"null",
";",
"}",
"return",
"this",
";",
"}"
] | Appends an AND expression to the RHS of the expression. The current RHS of the expression must be an Operand.
@return this ExpressionBuilder. | [
"Appends",
"an",
"AND",
"expression",
"to",
"the",
"RHS",
"of",
"the",
"expression",
".",
"The",
"current",
"RHS",
"of",
"the",
"expression",
"must",
"be",
"an",
"Operand",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L211-L239 |
139,519 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.not | public ExpressionBuilder not(final ExpressionBuilder exp) {
// Note - NOT Expressions are not added to the stack (like the other group expressions AND and OR) and are
// treated the same as a "compare" expression.
// It is expected a NOT Expression is used by itself or with an AND or NOT.
GroupExpression not = new GroupExpression(Type.NOT);
not.add(exp.expression.getExpression());
appendExpression(not);
return this;
} | java | public ExpressionBuilder not(final ExpressionBuilder exp) {
// Note - NOT Expressions are not added to the stack (like the other group expressions AND and OR) and are
// treated the same as a "compare" expression.
// It is expected a NOT Expression is used by itself or with an AND or NOT.
GroupExpression not = new GroupExpression(Type.NOT);
not.add(exp.expression.getExpression());
appendExpression(not);
return this;
} | [
"public",
"ExpressionBuilder",
"not",
"(",
"final",
"ExpressionBuilder",
"exp",
")",
"{",
"// Note - NOT Expressions are not added to the stack (like the other group expressions AND and OR) and are",
"// treated the same as a \"compare\" expression.",
"// It is expected a NOT Expression is used by itself or with an AND or NOT.",
"GroupExpression",
"not",
"=",
"new",
"GroupExpression",
"(",
"Type",
".",
"NOT",
")",
";",
"not",
".",
"add",
"(",
"exp",
".",
"expression",
".",
"getExpression",
"(",
")",
")",
";",
"appendExpression",
"(",
"not",
")",
";",
"return",
"this",
";",
"}"
] | Appends a NOT expression to this expression.
@param exp the builder containing the expression to NOT with the current expression.
@return this ExpressionBuilder. | [
"Appends",
"a",
"NOT",
"expression",
"to",
"this",
"expression",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L269-L279 |
139,520 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.appendExpression | private void appendExpression(final BooleanExpression newExpression) {
if (lhsExpression != null) {
throw new SyntaxException("Syntax exception: use AND or OR to join expressions");
}
lhsExpression = newExpression;
GroupExpression currentExpression = stack.isEmpty() ? null : stack.peek();
if (currentExpression == null) {
this.expression.setExpression(newExpression);
} else {
currentExpression.add(newExpression);
}
} | java | private void appendExpression(final BooleanExpression newExpression) {
if (lhsExpression != null) {
throw new SyntaxException("Syntax exception: use AND or OR to join expressions");
}
lhsExpression = newExpression;
GroupExpression currentExpression = stack.isEmpty() ? null : stack.peek();
if (currentExpression == null) {
this.expression.setExpression(newExpression);
} else {
currentExpression.add(newExpression);
}
} | [
"private",
"void",
"appendExpression",
"(",
"final",
"BooleanExpression",
"newExpression",
")",
"{",
"if",
"(",
"lhsExpression",
"!=",
"null",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"\"Syntax exception: use AND or OR to join expressions\"",
")",
";",
"}",
"lhsExpression",
"=",
"newExpression",
";",
"GroupExpression",
"currentExpression",
"=",
"stack",
".",
"isEmpty",
"(",
")",
"?",
"null",
":",
"stack",
".",
"peek",
"(",
")",
";",
"if",
"(",
"currentExpression",
"==",
"null",
")",
"{",
"this",
".",
"expression",
".",
"setExpression",
"(",
"newExpression",
")",
";",
"}",
"else",
"{",
"currentExpression",
".",
"add",
"(",
"newExpression",
")",
";",
"}",
"}"
] | Appends the given expression to this expression.
@param newExpression the expression to append. | [
"Appends",
"the",
"given",
"expression",
"to",
"this",
"expression",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L286-L300 |
139,521 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.validate | public boolean validate() {
try {
BooleanExpression built = expression.getExpression();
if (built == null) {
// nothing to evaluate.
return false;
}
// First check the nesting (an expression must not contain itself)
checkNesting(built, new ArrayList<BooleanExpression>());
// If the expression evaluates correctly, the syntax is correct.
built.evaluate();
} catch (Exception e) {
LogFactory.getLog(getClass()).warn("Invalid expression: " + e.getMessage());
return false;
}
return true;
} | java | public boolean validate() {
try {
BooleanExpression built = expression.getExpression();
if (built == null) {
// nothing to evaluate.
return false;
}
// First check the nesting (an expression must not contain itself)
checkNesting(built, new ArrayList<BooleanExpression>());
// If the expression evaluates correctly, the syntax is correct.
built.evaluate();
} catch (Exception e) {
LogFactory.getLog(getClass()).warn("Invalid expression: " + e.getMessage());
return false;
}
return true;
} | [
"public",
"boolean",
"validate",
"(",
")",
"{",
"try",
"{",
"BooleanExpression",
"built",
"=",
"expression",
".",
"getExpression",
"(",
")",
";",
"if",
"(",
"built",
"==",
"null",
")",
"{",
"// nothing to evaluate.",
"return",
"false",
";",
"}",
"// First check the nesting (an expression must not contain itself)",
"checkNesting",
"(",
"built",
",",
"new",
"ArrayList",
"<",
"BooleanExpression",
">",
"(",
")",
")",
";",
"// If the expression evaluates correctly, the syntax is correct.",
"built",
".",
"evaluate",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LogFactory",
".",
"getLog",
"(",
"getClass",
"(",
")",
")",
".",
"warn",
"(",
"\"Invalid expression: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Determines whether the current expression is syntactically correct.
@return true if the current expression is valid, false if not. | [
"Determines",
"whether",
"the",
"current",
"expression",
"is",
"syntactically",
"correct",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L320-L340 |
139,522 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.checkNesting | private static void checkNesting(final BooleanExpression expression,
final List<BooleanExpression> visitedExpressions) {
if (visitedExpressions.contains(expression)) {
// Unfortunately, we can't give much more information - even calling toString() will overflow the stack.
throw new SyntaxException("An expression can not contain itself.");
}
visitedExpressions.add(expression);
if (expression instanceof GroupExpression) {
GroupExpression group = (GroupExpression) expression;
for (BooleanExpression operand : group.getOperands()) {
checkNesting(operand, visitedExpressions);
}
}
} | java | private static void checkNesting(final BooleanExpression expression,
final List<BooleanExpression> visitedExpressions) {
if (visitedExpressions.contains(expression)) {
// Unfortunately, we can't give much more information - even calling toString() will overflow the stack.
throw new SyntaxException("An expression can not contain itself.");
}
visitedExpressions.add(expression);
if (expression instanceof GroupExpression) {
GroupExpression group = (GroupExpression) expression;
for (BooleanExpression operand : group.getOperands()) {
checkNesting(operand, visitedExpressions);
}
}
} | [
"private",
"static",
"void",
"checkNesting",
"(",
"final",
"BooleanExpression",
"expression",
",",
"final",
"List",
"<",
"BooleanExpression",
">",
"visitedExpressions",
")",
"{",
"if",
"(",
"visitedExpressions",
".",
"contains",
"(",
"expression",
")",
")",
"{",
"// Unfortunately, we can't give much more information - even calling toString() will overflow the stack.",
"throw",
"new",
"SyntaxException",
"(",
"\"An expression can not contain itself.\"",
")",
";",
"}",
"visitedExpressions",
".",
"add",
"(",
"expression",
")",
";",
"if",
"(",
"expression",
"instanceof",
"GroupExpression",
")",
"{",
"GroupExpression",
"group",
"=",
"(",
"GroupExpression",
")",
"expression",
";",
"for",
"(",
"BooleanExpression",
"operand",
":",
"group",
".",
"getOperands",
"(",
")",
")",
"{",
"checkNesting",
"(",
"operand",
",",
"visitedExpressions",
")",
";",
"}",
"}",
"}"
] | Checks nesting of expressions to ensure we don't end up in an infinite recursive loop during evaluation.
@param expression the expression to check
@param visitedExpressions a list of expressions which have been visited so far. | [
"Checks",
"nesting",
"of",
"expressions",
"to",
"ensure",
"we",
"don",
"t",
"end",
"up",
"in",
"an",
"infinite",
"recursive",
"loop",
"during",
"evaluation",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L348-L363 |
139,523 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownOptionsExample.java | WDropdownOptionsExample.getDropDownControls | private WFieldSet getDropDownControls() {
WFieldSet fieldSet = new WFieldSet("Drop down configuration");
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
fieldSet.add(layout);
rbsDDType.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
rbsDDType.setSelected(WDropdown.DropdownType.NATIVE);
rbsDDType.setFrameless(true);
layout.addField("Dropdown Type", rbsDDType);
nfWidth.setMinValue(0);
nfWidth.setDecimalPlaces(0);
layout.addField("Width", nfWidth);
layout.addField("ToolTip", tfToolTip);
layout.addField("Include null option", cbNullOption);
rgDefaultOption.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
rgDefaultOption.setButtonColumns(2);
rgDefaultOption.setSelected(NONE);
rgDefaultOption.setFrameless(true);
layout.addField("Default Option", rgDefaultOption);
layout.addField("Action on change", cbActionOnChange);
layout.addField("Ajax", cbAjax);
WField subField = layout.addField("Subordinate", cbSubordinate);
//.getLabel().setHint("Does not work with Dropdown Type COMBO");
layout.addField("Submit on change", cbSubmitOnChange);
layout.addField("Visible", cbVisible);
layout.addField("Disabled", cbDisabled);
// Apply Button
WButton apply = new WButton("Apply");
fieldSet.add(apply);
WSubordinateControl subSubControl = new WSubordinateControl();
Rule rule = new Rule();
subSubControl.addRule(rule);
rule.setCondition(new Equal(rbsDDType, WDropdown.DropdownType.COMBO));
rule.addActionOnTrue(new Disable(subField));
rule.addActionOnFalse(new Enable(subField));
fieldSet.add(subSubControl);
apply.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
applySettings();
}
});
return fieldSet;
} | java | private WFieldSet getDropDownControls() {
WFieldSet fieldSet = new WFieldSet("Drop down configuration");
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
fieldSet.add(layout);
rbsDDType.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
rbsDDType.setSelected(WDropdown.DropdownType.NATIVE);
rbsDDType.setFrameless(true);
layout.addField("Dropdown Type", rbsDDType);
nfWidth.setMinValue(0);
nfWidth.setDecimalPlaces(0);
layout.addField("Width", nfWidth);
layout.addField("ToolTip", tfToolTip);
layout.addField("Include null option", cbNullOption);
rgDefaultOption.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
rgDefaultOption.setButtonColumns(2);
rgDefaultOption.setSelected(NONE);
rgDefaultOption.setFrameless(true);
layout.addField("Default Option", rgDefaultOption);
layout.addField("Action on change", cbActionOnChange);
layout.addField("Ajax", cbAjax);
WField subField = layout.addField("Subordinate", cbSubordinate);
//.getLabel().setHint("Does not work with Dropdown Type COMBO");
layout.addField("Submit on change", cbSubmitOnChange);
layout.addField("Visible", cbVisible);
layout.addField("Disabled", cbDisabled);
// Apply Button
WButton apply = new WButton("Apply");
fieldSet.add(apply);
WSubordinateControl subSubControl = new WSubordinateControl();
Rule rule = new Rule();
subSubControl.addRule(rule);
rule.setCondition(new Equal(rbsDDType, WDropdown.DropdownType.COMBO));
rule.addActionOnTrue(new Disable(subField));
rule.addActionOnFalse(new Enable(subField));
fieldSet.add(subSubControl);
apply.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
applySettings();
}
});
return fieldSet;
} | [
"private",
"WFieldSet",
"getDropDownControls",
"(",
")",
"{",
"WFieldSet",
"fieldSet",
"=",
"new",
"WFieldSet",
"(",
"\"Drop down configuration\"",
")",
";",
"WFieldLayout",
"layout",
"=",
"new",
"WFieldLayout",
"(",
")",
";",
"layout",
".",
"setLabelWidth",
"(",
"25",
")",
";",
"fieldSet",
".",
"add",
"(",
"layout",
")",
";",
"rbsDDType",
".",
"setButtonLayout",
"(",
"WRadioButtonSelect",
".",
"LAYOUT_FLAT",
")",
";",
"rbsDDType",
".",
"setSelected",
"(",
"WDropdown",
".",
"DropdownType",
".",
"NATIVE",
")",
";",
"rbsDDType",
".",
"setFrameless",
"(",
"true",
")",
";",
"layout",
".",
"addField",
"(",
"\"Dropdown Type\"",
",",
"rbsDDType",
")",
";",
"nfWidth",
".",
"setMinValue",
"(",
"0",
")",
";",
"nfWidth",
".",
"setDecimalPlaces",
"(",
"0",
")",
";",
"layout",
".",
"addField",
"(",
"\"Width\"",
",",
"nfWidth",
")",
";",
"layout",
".",
"addField",
"(",
"\"ToolTip\"",
",",
"tfToolTip",
")",
";",
"layout",
".",
"addField",
"(",
"\"Include null option\"",
",",
"cbNullOption",
")",
";",
"rgDefaultOption",
".",
"setButtonLayout",
"(",
"WRadioButtonSelect",
".",
"LAYOUT_COLUMNS",
")",
";",
"rgDefaultOption",
".",
"setButtonColumns",
"(",
"2",
")",
";",
"rgDefaultOption",
".",
"setSelected",
"(",
"NONE",
")",
";",
"rgDefaultOption",
".",
"setFrameless",
"(",
"true",
")",
";",
"layout",
".",
"addField",
"(",
"\"Default Option\"",
",",
"rgDefaultOption",
")",
";",
"layout",
".",
"addField",
"(",
"\"Action on change\"",
",",
"cbActionOnChange",
")",
";",
"layout",
".",
"addField",
"(",
"\"Ajax\"",
",",
"cbAjax",
")",
";",
"WField",
"subField",
"=",
"layout",
".",
"addField",
"(",
"\"Subordinate\"",
",",
"cbSubordinate",
")",
";",
"//.getLabel().setHint(\"Does not work with Dropdown Type COMBO\");",
"layout",
".",
"addField",
"(",
"\"Submit on change\"",
",",
"cbSubmitOnChange",
")",
";",
"layout",
".",
"addField",
"(",
"\"Visible\"",
",",
"cbVisible",
")",
";",
"layout",
".",
"addField",
"(",
"\"Disabled\"",
",",
"cbDisabled",
")",
";",
"// Apply Button",
"WButton",
"apply",
"=",
"new",
"WButton",
"(",
"\"Apply\"",
")",
";",
"fieldSet",
".",
"add",
"(",
"apply",
")",
";",
"WSubordinateControl",
"subSubControl",
"=",
"new",
"WSubordinateControl",
"(",
")",
";",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"subSubControl",
".",
"addRule",
"(",
"rule",
")",
";",
"rule",
".",
"setCondition",
"(",
"new",
"Equal",
"(",
"rbsDDType",
",",
"WDropdown",
".",
"DropdownType",
".",
"COMBO",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Disable",
"(",
"subField",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Enable",
"(",
"subField",
")",
")",
";",
"fieldSet",
".",
"add",
"(",
"subSubControl",
")",
";",
"apply",
".",
"setAction",
"(",
"new",
"Action",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"execute",
"(",
"final",
"ActionEvent",
"event",
")",
"{",
"applySettings",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"fieldSet",
";",
"}"
] | build the drop down controls.
@return a field set containing the dropdown controls. | [
"build",
"the",
"drop",
"down",
"controls",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownOptionsExample.java#L161-L213 |
139,524 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownOptionsExample.java | WDropdownOptionsExample.applySettings | private void applySettings() {
container.reset();
infoPanel.reset();
// create the list of options.
List<String> options = new ArrayList<>(Arrays.asList(OPTIONS_ARRAY));
if (cbNullOption.isSelected()) {
options.add(0, "");
}
// create the dropdown.
final WDropdown dropdown = new WDropdown(options);
// set the dropdown type.
dropdown.setType((DropdownType) rbsDDType.getSelected());
// set the selected option if applicable.
String selected = (String) rgDefaultOption.getSelected();
if (selected != null && !NONE.equals(selected)) {
dropdown.setSelected(selected);
}
// set the width.
if (nfWidth.getValue() != null) {
dropdown.setOptionWidth(nfWidth.getValue().intValue());
}
// set the tool tip.
if (tfToolTip.getText() != null && tfToolTip.getText().length() > 0) {
dropdown.setToolTip(tfToolTip.getText());
}
// set misc options.
dropdown.setVisible(cbVisible.isSelected());
dropdown.setDisabled(cbDisabled.isSelected());
// add the action for action on change, ajax and subordinate.
if (cbActionOnChange.isSelected() || cbAjax.isSelected() || cbSubmitOnChange.isSelected()) {
final WStyledText info = new WStyledText();
info.setWhitespaceMode(WhitespaceMode.PRESERVE);
infoPanel.add(info);
dropdown.setActionOnChange(new Action() {
@Override
public void execute(final ActionEvent event) {
String selectedOption = (String) dropdown.getSelected();
info.setText(selectedOption);
}
});
}
// this has to be below the set action on change so it is
// not over written.
dropdown.setSubmitOnChange(cbSubmitOnChange.isSelected());
// add the ajax target.
if (cbAjax.isSelected()) {
WAjaxControl update = new WAjaxControl(dropdown);
update.addTarget(infoPanel);
container.add(update);
}
// add the subordinate stuff.
if (rbsDDType.getValue() == WDropdown.DropdownType.COMBO) {
//This is to work around a WComponent Subordinate logic flaw.
cbSubordinate.setSelected(false);
}
if (cbSubordinate.isSelected()) {
WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
container.add(group);
WSubordinateControl control = new WSubordinateControl();
container.add(control);
for (String option : OPTIONS_ARRAY) {
buildSubordinatePanel(dropdown, option, group, control);
}
// add a rule for none selected.
Rule rule = new Rule();
control.addRule(rule);
rule.setCondition(new Equal(dropdown, ""));
rule.addActionOnTrue(new Hide(group));
}
WFieldLayout flay = new WFieldLayout();
flay.setLabelWidth(25);
container.add(flay);
flay.addField("Configured dropdown", dropdown);
flay.addField((WLabel) null, new WButton("Submit"));
} | java | private void applySettings() {
container.reset();
infoPanel.reset();
// create the list of options.
List<String> options = new ArrayList<>(Arrays.asList(OPTIONS_ARRAY));
if (cbNullOption.isSelected()) {
options.add(0, "");
}
// create the dropdown.
final WDropdown dropdown = new WDropdown(options);
// set the dropdown type.
dropdown.setType((DropdownType) rbsDDType.getSelected());
// set the selected option if applicable.
String selected = (String) rgDefaultOption.getSelected();
if (selected != null && !NONE.equals(selected)) {
dropdown.setSelected(selected);
}
// set the width.
if (nfWidth.getValue() != null) {
dropdown.setOptionWidth(nfWidth.getValue().intValue());
}
// set the tool tip.
if (tfToolTip.getText() != null && tfToolTip.getText().length() > 0) {
dropdown.setToolTip(tfToolTip.getText());
}
// set misc options.
dropdown.setVisible(cbVisible.isSelected());
dropdown.setDisabled(cbDisabled.isSelected());
// add the action for action on change, ajax and subordinate.
if (cbActionOnChange.isSelected() || cbAjax.isSelected() || cbSubmitOnChange.isSelected()) {
final WStyledText info = new WStyledText();
info.setWhitespaceMode(WhitespaceMode.PRESERVE);
infoPanel.add(info);
dropdown.setActionOnChange(new Action() {
@Override
public void execute(final ActionEvent event) {
String selectedOption = (String) dropdown.getSelected();
info.setText(selectedOption);
}
});
}
// this has to be below the set action on change so it is
// not over written.
dropdown.setSubmitOnChange(cbSubmitOnChange.isSelected());
// add the ajax target.
if (cbAjax.isSelected()) {
WAjaxControl update = new WAjaxControl(dropdown);
update.addTarget(infoPanel);
container.add(update);
}
// add the subordinate stuff.
if (rbsDDType.getValue() == WDropdown.DropdownType.COMBO) {
//This is to work around a WComponent Subordinate logic flaw.
cbSubordinate.setSelected(false);
}
if (cbSubordinate.isSelected()) {
WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
container.add(group);
WSubordinateControl control = new WSubordinateControl();
container.add(control);
for (String option : OPTIONS_ARRAY) {
buildSubordinatePanel(dropdown, option, group, control);
}
// add a rule for none selected.
Rule rule = new Rule();
control.addRule(rule);
rule.setCondition(new Equal(dropdown, ""));
rule.addActionOnTrue(new Hide(group));
}
WFieldLayout flay = new WFieldLayout();
flay.setLabelWidth(25);
container.add(flay);
flay.addField("Configured dropdown", dropdown);
flay.addField((WLabel) null, new WButton("Submit"));
} | [
"private",
"void",
"applySettings",
"(",
")",
"{",
"container",
".",
"reset",
"(",
")",
";",
"infoPanel",
".",
"reset",
"(",
")",
";",
"// create the list of options.",
"List",
"<",
"String",
">",
"options",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"OPTIONS_ARRAY",
")",
")",
";",
"if",
"(",
"cbNullOption",
".",
"isSelected",
"(",
")",
")",
"{",
"options",
".",
"add",
"(",
"0",
",",
"\"\"",
")",
";",
"}",
"// create the dropdown.",
"final",
"WDropdown",
"dropdown",
"=",
"new",
"WDropdown",
"(",
"options",
")",
";",
"// set the dropdown type.",
"dropdown",
".",
"setType",
"(",
"(",
"DropdownType",
")",
"rbsDDType",
".",
"getSelected",
"(",
")",
")",
";",
"// set the selected option if applicable.",
"String",
"selected",
"=",
"(",
"String",
")",
"rgDefaultOption",
".",
"getSelected",
"(",
")",
";",
"if",
"(",
"selected",
"!=",
"null",
"&&",
"!",
"NONE",
".",
"equals",
"(",
"selected",
")",
")",
"{",
"dropdown",
".",
"setSelected",
"(",
"selected",
")",
";",
"}",
"// set the width.",
"if",
"(",
"nfWidth",
".",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"dropdown",
".",
"setOptionWidth",
"(",
"nfWidth",
".",
"getValue",
"(",
")",
".",
"intValue",
"(",
")",
")",
";",
"}",
"// set the tool tip.",
"if",
"(",
"tfToolTip",
".",
"getText",
"(",
")",
"!=",
"null",
"&&",
"tfToolTip",
".",
"getText",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"dropdown",
".",
"setToolTip",
"(",
"tfToolTip",
".",
"getText",
"(",
")",
")",
";",
"}",
"// set misc options.",
"dropdown",
".",
"setVisible",
"(",
"cbVisible",
".",
"isSelected",
"(",
")",
")",
";",
"dropdown",
".",
"setDisabled",
"(",
"cbDisabled",
".",
"isSelected",
"(",
")",
")",
";",
"// add the action for action on change, ajax and subordinate.",
"if",
"(",
"cbActionOnChange",
".",
"isSelected",
"(",
")",
"||",
"cbAjax",
".",
"isSelected",
"(",
")",
"||",
"cbSubmitOnChange",
".",
"isSelected",
"(",
")",
")",
"{",
"final",
"WStyledText",
"info",
"=",
"new",
"WStyledText",
"(",
")",
";",
"info",
".",
"setWhitespaceMode",
"(",
"WhitespaceMode",
".",
"PRESERVE",
")",
";",
"infoPanel",
".",
"add",
"(",
"info",
")",
";",
"dropdown",
".",
"setActionOnChange",
"(",
"new",
"Action",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"execute",
"(",
"final",
"ActionEvent",
"event",
")",
"{",
"String",
"selectedOption",
"=",
"(",
"String",
")",
"dropdown",
".",
"getSelected",
"(",
")",
";",
"info",
".",
"setText",
"(",
"selectedOption",
")",
";",
"}",
"}",
")",
";",
"}",
"// this has to be below the set action on change so it is",
"// not over written.",
"dropdown",
".",
"setSubmitOnChange",
"(",
"cbSubmitOnChange",
".",
"isSelected",
"(",
")",
")",
";",
"// add the ajax target.",
"if",
"(",
"cbAjax",
".",
"isSelected",
"(",
")",
")",
"{",
"WAjaxControl",
"update",
"=",
"new",
"WAjaxControl",
"(",
"dropdown",
")",
";",
"update",
".",
"addTarget",
"(",
"infoPanel",
")",
";",
"container",
".",
"add",
"(",
"update",
")",
";",
"}",
"// add the subordinate stuff.",
"if",
"(",
"rbsDDType",
".",
"getValue",
"(",
")",
"==",
"WDropdown",
".",
"DropdownType",
".",
"COMBO",
")",
"{",
"//This is to work around a WComponent Subordinate logic flaw.",
"cbSubordinate",
".",
"setSelected",
"(",
"false",
")",
";",
"}",
"if",
"(",
"cbSubordinate",
".",
"isSelected",
"(",
")",
")",
"{",
"WComponentGroup",
"<",
"SubordinateTarget",
">",
"group",
"=",
"new",
"WComponentGroup",
"<>",
"(",
")",
";",
"container",
".",
"add",
"(",
"group",
")",
";",
"WSubordinateControl",
"control",
"=",
"new",
"WSubordinateControl",
"(",
")",
";",
"container",
".",
"add",
"(",
"control",
")",
";",
"for",
"(",
"String",
"option",
":",
"OPTIONS_ARRAY",
")",
"{",
"buildSubordinatePanel",
"(",
"dropdown",
",",
"option",
",",
"group",
",",
"control",
")",
";",
"}",
"// add a rule for none selected.",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"rule",
".",
"setCondition",
"(",
"new",
"Equal",
"(",
"dropdown",
",",
"\"\"",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Hide",
"(",
"group",
")",
")",
";",
"}",
"WFieldLayout",
"flay",
"=",
"new",
"WFieldLayout",
"(",
")",
";",
"flay",
".",
"setLabelWidth",
"(",
"25",
")",
";",
"container",
".",
"add",
"(",
"flay",
")",
";",
"flay",
".",
"addField",
"(",
"\"Configured dropdown\"",
",",
"dropdown",
")",
";",
"flay",
".",
"addField",
"(",
"(",
"WLabel",
")",
"null",
",",
"new",
"WButton",
"(",
"\"Submit\"",
")",
")",
";",
"}"
] | Apply the settings from the control table to the drop down. | [
"Apply",
"the",
"settings",
"from",
"the",
"control",
"table",
"to",
"the",
"drop",
"down",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownOptionsExample.java#L234-L324 |
139,525 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownOptionsExample.java | WDropdownOptionsExample.buildSubordinatePanel | private void buildSubordinatePanel(final WDropdown dropdown, final String value,
final WComponentGroup<SubordinateTarget> group,
final WSubordinateControl control) {
// create the panel.
WPanel panel = new WPanel();
WStyledText subordinateInfo = new WStyledText();
subordinateInfo.setWhitespaceMode(WhitespaceMode.PRESERVE);
subordinateInfo.setText(value + " - Subordinate");
panel.add(subordinateInfo);
// add the panel to the screen and group.
infoPanel.add(panel);
group.addToGroup(panel);
// create the rule
Rule rule = new Rule();
control.addRule(rule);
rule.setCondition(new Equal(dropdown, value));
rule.addActionOnTrue(new ShowInGroup(panel, group));
} | java | private void buildSubordinatePanel(final WDropdown dropdown, final String value,
final WComponentGroup<SubordinateTarget> group,
final WSubordinateControl control) {
// create the panel.
WPanel panel = new WPanel();
WStyledText subordinateInfo = new WStyledText();
subordinateInfo.setWhitespaceMode(WhitespaceMode.PRESERVE);
subordinateInfo.setText(value + " - Subordinate");
panel.add(subordinateInfo);
// add the panel to the screen and group.
infoPanel.add(panel);
group.addToGroup(panel);
// create the rule
Rule rule = new Rule();
control.addRule(rule);
rule.setCondition(new Equal(dropdown, value));
rule.addActionOnTrue(new ShowInGroup(panel, group));
} | [
"private",
"void",
"buildSubordinatePanel",
"(",
"final",
"WDropdown",
"dropdown",
",",
"final",
"String",
"value",
",",
"final",
"WComponentGroup",
"<",
"SubordinateTarget",
">",
"group",
",",
"final",
"WSubordinateControl",
"control",
")",
"{",
"// create the panel.",
"WPanel",
"panel",
"=",
"new",
"WPanel",
"(",
")",
";",
"WStyledText",
"subordinateInfo",
"=",
"new",
"WStyledText",
"(",
")",
";",
"subordinateInfo",
".",
"setWhitespaceMode",
"(",
"WhitespaceMode",
".",
"PRESERVE",
")",
";",
"subordinateInfo",
".",
"setText",
"(",
"value",
"+",
"\" - Subordinate\"",
")",
";",
"panel",
".",
"add",
"(",
"subordinateInfo",
")",
";",
"// add the panel to the screen and group.",
"infoPanel",
".",
"add",
"(",
"panel",
")",
";",
"group",
".",
"addToGroup",
"(",
"panel",
")",
";",
"// create the rule",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"rule",
".",
"setCondition",
"(",
"new",
"Equal",
"(",
"dropdown",
",",
"value",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"ShowInGroup",
"(",
"panel",
",",
"group",
")",
")",
";",
"}"
] | Builds a panel for the subordinate control, including the rule for that particular option.
@param dropdown the subordinate trigger.
@param value the dropdown option to be added
@param group the group
@param control the subordinate control | [
"Builds",
"a",
"panel",
"for",
"the",
"subordinate",
"control",
"including",
"the",
"rule",
"for",
"that",
"particular",
"option",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownOptionsExample.java#L334-L353 |
139,526 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletResponse.java | MockHttpServletResponse.setDateHeader | @Override
public void setDateHeader(final String name, final long value) {
headers.put(name, String.valueOf(value));
} | java | @Override
public void setDateHeader(final String name, final long value) {
headers.put(name, String.valueOf(value));
} | [
"@",
"Override",
"public",
"void",
"setDateHeader",
"(",
"final",
"String",
"name",
",",
"final",
"long",
"value",
")",
"{",
"headers",
".",
"put",
"(",
"name",
",",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"}"
] | Sets a date header.
@param name the header name.
@param value the header value. | [
"Sets",
"a",
"date",
"header",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletResponse.java#L175-L178 |
139,527 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletResponse.java | MockHttpServletResponse.setIntHeader | @Override
public void setIntHeader(final String name, final int value) {
headers.put(name, String.valueOf(value));
} | java | @Override
public void setIntHeader(final String name, final int value) {
headers.put(name, String.valueOf(value));
} | [
"@",
"Override",
"public",
"void",
"setIntHeader",
"(",
"final",
"String",
"name",
",",
"final",
"int",
"value",
")",
"{",
"headers",
".",
"put",
"(",
"name",
",",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"}"
] | Sets an integer header.
@param name the header name.
@param value the header value. | [
"Sets",
"an",
"integer",
"header",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletResponse.java#L197-L200 |
139,528 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/AbstractAction.java | AbstractAction.execute | @Override
public void execute() {
if (target instanceof WComponentGroup<?>) {
for (WComponent component : ((WComponentGroup<WComponent>) target).getComponents()) {
if (component instanceof SubordinateTarget) {
applyAction((SubordinateTarget) component, value);
}
}
} else {
// Leaf.
applyAction(target, value);
}
} | java | @Override
public void execute() {
if (target instanceof WComponentGroup<?>) {
for (WComponent component : ((WComponentGroup<WComponent>) target).getComponents()) {
if (component instanceof SubordinateTarget) {
applyAction((SubordinateTarget) component, value);
}
}
} else {
// Leaf.
applyAction(target, value);
}
} | [
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"if",
"(",
"target",
"instanceof",
"WComponentGroup",
"<",
"?",
">",
")",
"{",
"for",
"(",
"WComponent",
"component",
":",
"(",
"(",
"WComponentGroup",
"<",
"WComponent",
">",
")",
"target",
")",
".",
"getComponents",
"(",
")",
")",
"{",
"if",
"(",
"component",
"instanceof",
"SubordinateTarget",
")",
"{",
"applyAction",
"(",
"(",
"SubordinateTarget",
")",
"component",
",",
"value",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// Leaf.",
"applyAction",
"(",
"target",
",",
"value",
")",
";",
"}",
"}"
] | Execute the action. | [
"Execute",
"the",
"action",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/AbstractAction.java#L78-L91 |
139,529 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WStyledTextRenderer.java | WStyledTextRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WStyledText text = (WStyledText) component;
XmlStringBuilder xml = renderContext.getWriter();
String textString = text.getText();
if (textString != null && textString.length() > 0) {
xml.appendTagOpen("ui:text");
xml.appendOptionalAttribute("class", component.getHtmlClass());
switch (text.getType()) {
case EMPHASISED:
xml.appendAttribute("type", "emphasised");
break;
case HIGH_PRIORITY:
xml.appendAttribute("type", "highPriority");
break;
case LOW_PRIORITY:
xml.appendAttribute("type", "lowPriority");
break;
case MEDIUM_PRIORITY:
xml.appendAttribute("type", "mediumPriority");
break;
case ACTIVE_INDICATOR:
xml.appendAttribute("type", "activeIndicator");
break;
case MATCH_INDICATOR:
xml.appendAttribute("type", "matchIndicator");
break;
case INSERT:
xml.appendAttribute("type", "insert");
break;
case DELETE:
xml.appendAttribute("type", "delete");
break;
case MANDATORY_INDICATOR:
xml.appendAttribute("type", "mandatoryIndicator");
break;
case PLAIN:
default:
xml.appendAttribute("type", "plain");
break;
}
switch (text.getWhitespaceMode()) {
case PARAGRAPHS:
xml.appendAttribute("space", "paragraphs");
break;
case PRESERVE:
xml.appendAttribute("space", "preserve");
break;
case DEFAULT:
break;
default:
throw new IllegalArgumentException("Unknown white space mode: " + text.
getWhitespaceMode());
}
xml.appendClose();
if (WStyledText.WhitespaceMode.PARAGRAPHS.equals(text.getWhitespaceMode())) {
textString = text.isEncodeText() ? WebUtilities.encode(textString) : HtmlToXMLUtil.unescapeToXML(textString);
writeParagraphs(textString, xml);
} else {
xml.append(textString, text.isEncodeText());
}
xml.appendEndTag("ui:text");
}
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WStyledText text = (WStyledText) component;
XmlStringBuilder xml = renderContext.getWriter();
String textString = text.getText();
if (textString != null && textString.length() > 0) {
xml.appendTagOpen("ui:text");
xml.appendOptionalAttribute("class", component.getHtmlClass());
switch (text.getType()) {
case EMPHASISED:
xml.appendAttribute("type", "emphasised");
break;
case HIGH_PRIORITY:
xml.appendAttribute("type", "highPriority");
break;
case LOW_PRIORITY:
xml.appendAttribute("type", "lowPriority");
break;
case MEDIUM_PRIORITY:
xml.appendAttribute("type", "mediumPriority");
break;
case ACTIVE_INDICATOR:
xml.appendAttribute("type", "activeIndicator");
break;
case MATCH_INDICATOR:
xml.appendAttribute("type", "matchIndicator");
break;
case INSERT:
xml.appendAttribute("type", "insert");
break;
case DELETE:
xml.appendAttribute("type", "delete");
break;
case MANDATORY_INDICATOR:
xml.appendAttribute("type", "mandatoryIndicator");
break;
case PLAIN:
default:
xml.appendAttribute("type", "plain");
break;
}
switch (text.getWhitespaceMode()) {
case PARAGRAPHS:
xml.appendAttribute("space", "paragraphs");
break;
case PRESERVE:
xml.appendAttribute("space", "preserve");
break;
case DEFAULT:
break;
default:
throw new IllegalArgumentException("Unknown white space mode: " + text.
getWhitespaceMode());
}
xml.appendClose();
if (WStyledText.WhitespaceMode.PARAGRAPHS.equals(text.getWhitespaceMode())) {
textString = text.isEncodeText() ? WebUtilities.encode(textString) : HtmlToXMLUtil.unescapeToXML(textString);
writeParagraphs(textString, xml);
} else {
xml.append(textString, text.isEncodeText());
}
xml.appendEndTag("ui:text");
}
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WStyledText",
"text",
"=",
"(",
"WStyledText",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"String",
"textString",
"=",
"text",
".",
"getText",
"(",
")",
";",
"if",
"(",
"textString",
"!=",
"null",
"&&",
"textString",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:text\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"switch",
"(",
"text",
".",
"getType",
"(",
")",
")",
"{",
"case",
"EMPHASISED",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"emphasised\"",
")",
";",
"break",
";",
"case",
"HIGH_PRIORITY",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"highPriority\"",
")",
";",
"break",
";",
"case",
"LOW_PRIORITY",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"lowPriority\"",
")",
";",
"break",
";",
"case",
"MEDIUM_PRIORITY",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"mediumPriority\"",
")",
";",
"break",
";",
"case",
"ACTIVE_INDICATOR",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"activeIndicator\"",
")",
";",
"break",
";",
"case",
"MATCH_INDICATOR",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"matchIndicator\"",
")",
";",
"break",
";",
"case",
"INSERT",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"insert\"",
")",
";",
"break",
";",
"case",
"DELETE",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"delete\"",
")",
";",
"break",
";",
"case",
"MANDATORY_INDICATOR",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"mandatoryIndicator\"",
")",
";",
"break",
";",
"case",
"PLAIN",
":",
"default",
":",
"xml",
".",
"appendAttribute",
"(",
"\"type\"",
",",
"\"plain\"",
")",
";",
"break",
";",
"}",
"switch",
"(",
"text",
".",
"getWhitespaceMode",
"(",
")",
")",
"{",
"case",
"PARAGRAPHS",
":",
"xml",
".",
"appendAttribute",
"(",
"\"space\"",
",",
"\"paragraphs\"",
")",
";",
"break",
";",
"case",
"PRESERVE",
":",
"xml",
".",
"appendAttribute",
"(",
"\"space\"",
",",
"\"preserve\"",
")",
";",
"break",
";",
"case",
"DEFAULT",
":",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown white space mode: \"",
"+",
"text",
".",
"getWhitespaceMode",
"(",
")",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"if",
"(",
"WStyledText",
".",
"WhitespaceMode",
".",
"PARAGRAPHS",
".",
"equals",
"(",
"text",
".",
"getWhitespaceMode",
"(",
")",
")",
")",
"{",
"textString",
"=",
"text",
".",
"isEncodeText",
"(",
")",
"?",
"WebUtilities",
".",
"encode",
"(",
"textString",
")",
":",
"HtmlToXMLUtil",
".",
"unescapeToXML",
"(",
"textString",
")",
";",
"writeParagraphs",
"(",
"textString",
",",
"xml",
")",
";",
"}",
"else",
"{",
"xml",
".",
"append",
"(",
"textString",
",",
"text",
".",
"isEncodeText",
"(",
")",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:text\"",
")",
";",
"}",
"}"
] | Paints the given WStyledText.
@param component the WStyledText to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WStyledText",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WStyledTextRenderer.java#L26-L107 |
139,530 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WStyledTextRenderer.java | WStyledTextRenderer.writeParagraphs | private static void writeParagraphs(final String text, final XmlStringBuilder xml) {
if (!Util.empty(text)) {
int start = 0;
int end = text.length() - 1;
// Set the start index to the first non-linebreak, so we don't emit leading ui:nl tags
for (; start < end; start++) {
char c = text.charAt(start);
if (c != '\n' && c != '\r') {
break;
}
}
// Set the end index to the last non-linebreak, so we don't emit trailing ui:nl tags
for (; start < end; end--) {
char c = text.charAt(end);
if (c != '\n' && c != '\r') {
break;
}
}
char lastChar = 0;
for (int i = start; i <= end; i++) {
char c = text.charAt(i);
if (c == '\n' || c == '\r') {
if (lastChar != 0) {
xml.write("<ui:nl/>");
}
lastChar = 0;
} else {
xml.write(c);
lastChar = c;
}
}
}
} | java | private static void writeParagraphs(final String text, final XmlStringBuilder xml) {
if (!Util.empty(text)) {
int start = 0;
int end = text.length() - 1;
// Set the start index to the first non-linebreak, so we don't emit leading ui:nl tags
for (; start < end; start++) {
char c = text.charAt(start);
if (c != '\n' && c != '\r') {
break;
}
}
// Set the end index to the last non-linebreak, so we don't emit trailing ui:nl tags
for (; start < end; end--) {
char c = text.charAt(end);
if (c != '\n' && c != '\r') {
break;
}
}
char lastChar = 0;
for (int i = start; i <= end; i++) {
char c = text.charAt(i);
if (c == '\n' || c == '\r') {
if (lastChar != 0) {
xml.write("<ui:nl/>");
}
lastChar = 0;
} else {
xml.write(c);
lastChar = c;
}
}
}
} | [
"private",
"static",
"void",
"writeParagraphs",
"(",
"final",
"String",
"text",
",",
"final",
"XmlStringBuilder",
"xml",
")",
"{",
"if",
"(",
"!",
"Util",
".",
"empty",
"(",
"text",
")",
")",
"{",
"int",
"start",
"=",
"0",
";",
"int",
"end",
"=",
"text",
".",
"length",
"(",
")",
"-",
"1",
";",
"// Set the start index to the first non-linebreak, so we don't emit leading ui:nl tags",
"for",
"(",
";",
"start",
"<",
"end",
";",
"start",
"++",
")",
"{",
"char",
"c",
"=",
"text",
".",
"charAt",
"(",
"start",
")",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
"&&",
"c",
"!=",
"'",
"'",
")",
"{",
"break",
";",
"}",
"}",
"// Set the end index to the last non-linebreak, so we don't emit trailing ui:nl tags",
"for",
"(",
";",
"start",
"<",
"end",
";",
"end",
"--",
")",
"{",
"char",
"c",
"=",
"text",
".",
"charAt",
"(",
"end",
")",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
"&&",
"c",
"!=",
"'",
"'",
")",
"{",
"break",
";",
"}",
"}",
"char",
"lastChar",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<=",
"end",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"text",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"lastChar",
"!=",
"0",
")",
"{",
"xml",
".",
"write",
"(",
"\"<ui:nl/>\"",
")",
";",
"}",
"lastChar",
"=",
"0",
";",
"}",
"else",
"{",
"xml",
".",
"write",
"(",
"c",
")",
";",
"lastChar",
"=",
"c",
";",
"}",
"}",
"}",
"}"
] | Writes out paragraph delimited content.
@param text the String content to output.
@param xml the XmlStringBuilder to paint to. | [
"Writes",
"out",
"paragraph",
"delimited",
"content",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WStyledTextRenderer.java#L115-L155 |
139,531 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java | UicStatsAsHtml.write | public static void write(final PrintWriter writer, final UicStats stats) {
writer.println("<dl>");
writer.print("<dt>Total root wcomponents found in UIC</dt>");
writer.println("<dd>" + stats.getRootWCs().size() + "</dd>");
writer.print("<dt>Size of UIC (by serialization)</dt>");
writer.println("<dd>" + stats.getOverallSerializedSize() + "</dd>");
writer.print("<dt>UI</dt>");
writer.println("<dd>" + stats.getUI().getClass().getName() + "</dd>");
writer.println("</dl>");
for (Iterator<WComponent> it = stats.getWCsAnalysed(); it.hasNext();) {
WComponent comp = it.next();
Map<WComponent, UicStats.Stat> treeStats = stats.getWCTreeStats(comp);
writer.println("<br /><strong>Analysed component:</strong> " + comp);
writer.println("<br /><strong>Number of components in tree:</strong> " + treeStats.size());
writeHeader(writer);
writeProfileForTree(writer, treeStats);
writeFooter(writer);
}
} | java | public static void write(final PrintWriter writer, final UicStats stats) {
writer.println("<dl>");
writer.print("<dt>Total root wcomponents found in UIC</dt>");
writer.println("<dd>" + stats.getRootWCs().size() + "</dd>");
writer.print("<dt>Size of UIC (by serialization)</dt>");
writer.println("<dd>" + stats.getOverallSerializedSize() + "</dd>");
writer.print("<dt>UI</dt>");
writer.println("<dd>" + stats.getUI().getClass().getName() + "</dd>");
writer.println("</dl>");
for (Iterator<WComponent> it = stats.getWCsAnalysed(); it.hasNext();) {
WComponent comp = it.next();
Map<WComponent, UicStats.Stat> treeStats = stats.getWCTreeStats(comp);
writer.println("<br /><strong>Analysed component:</strong> " + comp);
writer.println("<br /><strong>Number of components in tree:</strong> " + treeStats.size());
writeHeader(writer);
writeProfileForTree(writer, treeStats);
writeFooter(writer);
}
} | [
"public",
"static",
"void",
"write",
"(",
"final",
"PrintWriter",
"writer",
",",
"final",
"UicStats",
"stats",
")",
"{",
"writer",
".",
"println",
"(",
"\"<dl>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<dt>Total root wcomponents found in UIC</dt>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"<dd>\"",
"+",
"stats",
".",
"getRootWCs",
"(",
")",
".",
"size",
"(",
")",
"+",
"\"</dd>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<dt>Size of UIC (by serialization)</dt>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"<dd>\"",
"+",
"stats",
".",
"getOverallSerializedSize",
"(",
")",
"+",
"\"</dd>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<dt>UI</dt>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"<dd>\"",
"+",
"stats",
".",
"getUI",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"</dd>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"</dl>\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"WComponent",
">",
"it",
"=",
"stats",
".",
"getWCsAnalysed",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"WComponent",
"comp",
"=",
"it",
".",
"next",
"(",
")",
";",
"Map",
"<",
"WComponent",
",",
"UicStats",
".",
"Stat",
">",
"treeStats",
"=",
"stats",
".",
"getWCTreeStats",
"(",
"comp",
")",
";",
"writer",
".",
"println",
"(",
"\"<br /><strong>Analysed component:</strong> \"",
"+",
"comp",
")",
";",
"writer",
".",
"println",
"(",
"\"<br /><strong>Number of components in tree:</strong> \"",
"+",
"treeStats",
".",
"size",
"(",
")",
")",
";",
"writeHeader",
"(",
"writer",
")",
";",
"writeProfileForTree",
"(",
"writer",
",",
"treeStats",
")",
";",
"writeFooter",
"(",
"writer",
")",
";",
"}",
"}"
] | Writes out the given statistics in HTML format.
@param writer the writer to write to.
@param stats the stats to write. | [
"Writes",
"out",
"the",
"given",
"statistics",
"in",
"HTML",
"format",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java#L32-L57 |
139,532 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java | UicStatsAsHtml.writeProfileForTree | private static void writeProfileForTree(final PrintWriter writer,
final Map<WComponent, UicStats.Stat> treeStats) {
// Copy all the stats into a list so we can sort and cull.
List<UicStats.Stat> statList = new ArrayList<>(treeStats.values());
Comparator<UicStats.Stat> comparator = new Comparator<UicStats.Stat>() {
@Override
public int compare(final UicStats.Stat stat1, final UicStats.Stat stat2) {
if (stat1.getModelState() > stat2.getModelState()) {
return -1;
} else if (stat1.getModelState() < stat2.getModelState()) {
return 1;
} else {
int diff = stat1.getClassName().compareTo(stat2.getClassName());
if (diff == 0) {
diff = stat1.getName().compareTo(stat2.getName());
}
return diff;
}
}
};
Collections.sort(statList, comparator);
for (int i = 0; i < statList.size(); i++) {
UicStats.Stat stat = statList.get(i);
writeRow(writer, stat);
}
} | java | private static void writeProfileForTree(final PrintWriter writer,
final Map<WComponent, UicStats.Stat> treeStats) {
// Copy all the stats into a list so we can sort and cull.
List<UicStats.Stat> statList = new ArrayList<>(treeStats.values());
Comparator<UicStats.Stat> comparator = new Comparator<UicStats.Stat>() {
@Override
public int compare(final UicStats.Stat stat1, final UicStats.Stat stat2) {
if (stat1.getModelState() > stat2.getModelState()) {
return -1;
} else if (stat1.getModelState() < stat2.getModelState()) {
return 1;
} else {
int diff = stat1.getClassName().compareTo(stat2.getClassName());
if (diff == 0) {
diff = stat1.getName().compareTo(stat2.getName());
}
return diff;
}
}
};
Collections.sort(statList, comparator);
for (int i = 0; i < statList.size(); i++) {
UicStats.Stat stat = statList.get(i);
writeRow(writer, stat);
}
} | [
"private",
"static",
"void",
"writeProfileForTree",
"(",
"final",
"PrintWriter",
"writer",
",",
"final",
"Map",
"<",
"WComponent",
",",
"UicStats",
".",
"Stat",
">",
"treeStats",
")",
"{",
"// Copy all the stats into a list so we can sort and cull.",
"List",
"<",
"UicStats",
".",
"Stat",
">",
"statList",
"=",
"new",
"ArrayList",
"<>",
"(",
"treeStats",
".",
"values",
"(",
")",
")",
";",
"Comparator",
"<",
"UicStats",
".",
"Stat",
">",
"comparator",
"=",
"new",
"Comparator",
"<",
"UicStats",
".",
"Stat",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"final",
"UicStats",
".",
"Stat",
"stat1",
",",
"final",
"UicStats",
".",
"Stat",
"stat2",
")",
"{",
"if",
"(",
"stat1",
".",
"getModelState",
"(",
")",
">",
"stat2",
".",
"getModelState",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"stat1",
".",
"getModelState",
"(",
")",
"<",
"stat2",
".",
"getModelState",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"int",
"diff",
"=",
"stat1",
".",
"getClassName",
"(",
")",
".",
"compareTo",
"(",
"stat2",
".",
"getClassName",
"(",
")",
")",
";",
"if",
"(",
"diff",
"==",
"0",
")",
"{",
"diff",
"=",
"stat1",
".",
"getName",
"(",
")",
".",
"compareTo",
"(",
"stat2",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"diff",
";",
"}",
"}",
"}",
";",
"Collections",
".",
"sort",
"(",
"statList",
",",
"comparator",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"statList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"UicStats",
".",
"Stat",
"stat",
"=",
"statList",
".",
"get",
"(",
"i",
")",
";",
"writeRow",
"(",
"writer",
",",
"stat",
")",
";",
"}",
"}"
] | Writes the stats for a single component.
@param writer the writer to write the stats to.
@param treeStats the stats for the component. | [
"Writes",
"the",
"stats",
"for",
"a",
"single",
"component",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java#L65-L95 |
139,533 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java | UicStatsAsHtml.writeHeader | private static void writeHeader(final PrintWriter writer) {
writer.println("<table>");
writer.println("<thead>");
writer.print("<tr>");
writer.print("<th>Class</th>");
writer.print("<th>Model</th>");
writer.print("<th>Size</th>");
writer.print("<th>Ref.</th>");
writer.print("<th>Name</th>");
writer.print("<th>Comment</th>");
writer.println("</tr>");
writer.println("</thead>");
} | java | private static void writeHeader(final PrintWriter writer) {
writer.println("<table>");
writer.println("<thead>");
writer.print("<tr>");
writer.print("<th>Class</th>");
writer.print("<th>Model</th>");
writer.print("<th>Size</th>");
writer.print("<th>Ref.</th>");
writer.print("<th>Name</th>");
writer.print("<th>Comment</th>");
writer.println("</tr>");
writer.println("</thead>");
} | [
"private",
"static",
"void",
"writeHeader",
"(",
"final",
"PrintWriter",
"writer",
")",
"{",
"writer",
".",
"println",
"(",
"\"<table>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"<thead>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<tr>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<th>Class</th>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<th>Model</th>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<th>Size</th>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<th>Ref.</th>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<th>Name</th>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<th>Comment</th>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"</tr>\"",
")",
";",
"writer",
".",
"println",
"(",
"\"</thead>\"",
")",
";",
"}"
] | Writes the stats header HTML.
@param writer the writer to write the header to | [
"Writes",
"the",
"stats",
"header",
"HTML",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java#L102-L114 |
139,534 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java | UicStatsAsHtml.writeRow | private static void writeRow(final PrintWriter writer, final UicStats.Stat stat) {
writer.print("<tr>");
writer.print("<td>" + stat.getClassName() + "</td>");
writer.print("<td>" + stat.getModelStateAsString() + "</td>");
if (stat.getSerializedSize() > 0) {
writer.print("<td>" + stat.getSerializedSize() + "</td>");
} else {
writer.print("<td> </td>");
}
writer.print("<td>" + stat.getRef() + "</td>");
writer.print("<td>" + stat.getName() + "</td>");
if (stat.getComment() == null) {
writer.print("<td> </td>");
} else {
writer.print("<td>" + stat.getComment() + "</td>");
}
writer.println("</tr>");
} | java | private static void writeRow(final PrintWriter writer, final UicStats.Stat stat) {
writer.print("<tr>");
writer.print("<td>" + stat.getClassName() + "</td>");
writer.print("<td>" + stat.getModelStateAsString() + "</td>");
if (stat.getSerializedSize() > 0) {
writer.print("<td>" + stat.getSerializedSize() + "</td>");
} else {
writer.print("<td> </td>");
}
writer.print("<td>" + stat.getRef() + "</td>");
writer.print("<td>" + stat.getName() + "</td>");
if (stat.getComment() == null) {
writer.print("<td> </td>");
} else {
writer.print("<td>" + stat.getComment() + "</td>");
}
writer.println("</tr>");
} | [
"private",
"static",
"void",
"writeRow",
"(",
"final",
"PrintWriter",
"writer",
",",
"final",
"UicStats",
".",
"Stat",
"stat",
")",
"{",
"writer",
".",
"print",
"(",
"\"<tr>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<td>\"",
"+",
"stat",
".",
"getClassName",
"(",
")",
"+",
"\"</td>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<td>\"",
"+",
"stat",
".",
"getModelStateAsString",
"(",
")",
"+",
"\"</td>\"",
")",
";",
"if",
"(",
"stat",
".",
"getSerializedSize",
"(",
")",
">",
"0",
")",
"{",
"writer",
".",
"print",
"(",
"\"<td>\"",
"+",
"stat",
".",
"getSerializedSize",
"(",
")",
"+",
"\"</td>\"",
")",
";",
"}",
"else",
"{",
"writer",
".",
"print",
"(",
"\"<td> </td>\"",
")",
";",
"}",
"writer",
".",
"print",
"(",
"\"<td>\"",
"+",
"stat",
".",
"getRef",
"(",
")",
"+",
"\"</td>\"",
")",
";",
"writer",
".",
"print",
"(",
"\"<td>\"",
"+",
"stat",
".",
"getName",
"(",
")",
"+",
"\"</td>\"",
")",
";",
"if",
"(",
"stat",
".",
"getComment",
"(",
")",
"==",
"null",
")",
"{",
"writer",
".",
"print",
"(",
"\"<td> </td>\"",
")",
";",
"}",
"else",
"{",
"writer",
".",
"print",
"(",
"\"<td>\"",
"+",
"stat",
".",
"getComment",
"(",
")",
"+",
"\"</td>\"",
")",
";",
"}",
"writer",
".",
"println",
"(",
"\"</tr>\"",
")",
";",
"}"
] | Writes a row containing a single stat.
@param writer the writer to write the row to.
@param stat the stat to write. | [
"Writes",
"a",
"row",
"containing",
"a",
"single",
"stat",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/monitor/UicStatsAsHtml.java#L131-L152 |
139,535 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WCancelButtonExample.java | WCancelButtonExample.changePage | private void changePage(final int direction) {
int currentPage = pages.indexOf(cardManager.getVisible());
currentPage = Math.min(2, Math.max(0, currentPage + direction));
cardManager.makeVisible(pages.get(currentPage));
prevButton.setDisabled(currentPage == 0);
nextButton.setDisabled(currentPage == 2);
finishButton.setDisabled(currentPage != 2);
cancelButton.setUnsavedChanges(currentPage > 0);
} | java | private void changePage(final int direction) {
int currentPage = pages.indexOf(cardManager.getVisible());
currentPage = Math.min(2, Math.max(0, currentPage + direction));
cardManager.makeVisible(pages.get(currentPage));
prevButton.setDisabled(currentPage == 0);
nextButton.setDisabled(currentPage == 2);
finishButton.setDisabled(currentPage != 2);
cancelButton.setUnsavedChanges(currentPage > 0);
} | [
"private",
"void",
"changePage",
"(",
"final",
"int",
"direction",
")",
"{",
"int",
"currentPage",
"=",
"pages",
".",
"indexOf",
"(",
"cardManager",
".",
"getVisible",
"(",
")",
")",
";",
"currentPage",
"=",
"Math",
".",
"min",
"(",
"2",
",",
"Math",
".",
"max",
"(",
"0",
",",
"currentPage",
"+",
"direction",
")",
")",
";",
"cardManager",
".",
"makeVisible",
"(",
"pages",
".",
"get",
"(",
"currentPage",
")",
")",
";",
"prevButton",
".",
"setDisabled",
"(",
"currentPage",
"==",
"0",
")",
";",
"nextButton",
".",
"setDisabled",
"(",
"currentPage",
"==",
"2",
")",
";",
"finishButton",
".",
"setDisabled",
"(",
"currentPage",
"!=",
"2",
")",
";",
"cancelButton",
".",
"setUnsavedChanges",
"(",
"currentPage",
">",
"0",
")",
";",
"}"
] | Handles a pagination request.
@param direction the direction and amount of pages to move through. | [
"Handles",
"a",
"pagination",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WCancelButtonExample.java#L153-L164 |
139,536 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WVideoRenderer.java | WVideoRenderer.trackKindToString | private String trackKindToString(final Track.Kind kind) {
if (kind == null) {
return null;
}
switch (kind) {
case SUBTITLES:
return "subtitles";
case CAPTIONS:
return "captions";
case DESCRIPTIONS:
return "descriptions";
case CHAPTERS:
return "chapters";
case METADATA:
return "metadata";
default:
LOG.error("Unknown track kind " + kind);
return null;
}
} | java | private String trackKindToString(final Track.Kind kind) {
if (kind == null) {
return null;
}
switch (kind) {
case SUBTITLES:
return "subtitles";
case CAPTIONS:
return "captions";
case DESCRIPTIONS:
return "descriptions";
case CHAPTERS:
return "chapters";
case METADATA:
return "metadata";
default:
LOG.error("Unknown track kind " + kind);
return null;
}
} | [
"private",
"String",
"trackKindToString",
"(",
"final",
"Track",
".",
"Kind",
"kind",
")",
"{",
"if",
"(",
"kind",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"kind",
")",
"{",
"case",
"SUBTITLES",
":",
"return",
"\"subtitles\"",
";",
"case",
"CAPTIONS",
":",
"return",
"\"captions\"",
";",
"case",
"DESCRIPTIONS",
":",
"return",
"\"descriptions\"",
";",
"case",
"CHAPTERS",
":",
"return",
"\"chapters\"",
";",
"case",
"METADATA",
":",
"return",
"\"metadata\"",
";",
"default",
":",
"LOG",
".",
"error",
"(",
"\"Unknown track kind \"",
"+",
"kind",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Converts a Track kind to the client track kind identifier.
@param kind the Track Kind to convert.
@return a client track kind identifier, or null if it could not be converted. | [
"Converts",
"a",
"Track",
"kind",
"to",
"the",
"client",
"track",
"kind",
"identifier",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WVideoRenderer.java#L154-L179 |
139,537 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.processAction | public void processAction() throws IOException {
if (isDisposed()) {
LOG.error("Skipping action phase. Attempt to reuse disposed ContainerHelper instance");
return;
}
try {
// Check user context has been prepared
if (getNewConversation() == null) {
throw new IllegalStateException(
"User context has not been prepared before the action phase");
}
prepareAction();
UIContext uic = getUIContext();
if (uic == null) {
throw new IllegalStateException("No user context set for the action phase.");
}
UIContextHolder.pushContext(uic);
// Make sure maps are cleared up
uic.clearScratchMap();
uic.clearRequestScratchMap();
prepareRequest();
Request req = getRequest();
getInterceptor().attachResponse(getResponse());
getInterceptor().serviceRequest(req);
if (req.isLogout()) {
handleLogout();
dispose();
}
} catch (ActionEscape esc) {
LOG.debug("ActionEscape performed.");
// Action escapes must be handled in the action phase and then
// do nothing if they reach the render phase (which they will in
// the servlet implementation)
handleEscape(esc);
dispose();
} catch (Escape esc) {
LOG.debug("Escape performed during action phase.");
// We can't handle the escape until the render phase.
} catch (Throwable t) {
// We try not to let any exception propagate to container.
String message = "Caught exception during action phase.";
LOG.error(message, t);
// We can't handle the error until the render phase.
propogateError(t);
} finally {
UIContextHolder.reset();
}
} | java | public void processAction() throws IOException {
if (isDisposed()) {
LOG.error("Skipping action phase. Attempt to reuse disposed ContainerHelper instance");
return;
}
try {
// Check user context has been prepared
if (getNewConversation() == null) {
throw new IllegalStateException(
"User context has not been prepared before the action phase");
}
prepareAction();
UIContext uic = getUIContext();
if (uic == null) {
throw new IllegalStateException("No user context set for the action phase.");
}
UIContextHolder.pushContext(uic);
// Make sure maps are cleared up
uic.clearScratchMap();
uic.clearRequestScratchMap();
prepareRequest();
Request req = getRequest();
getInterceptor().attachResponse(getResponse());
getInterceptor().serviceRequest(req);
if (req.isLogout()) {
handleLogout();
dispose();
}
} catch (ActionEscape esc) {
LOG.debug("ActionEscape performed.");
// Action escapes must be handled in the action phase and then
// do nothing if they reach the render phase (which they will in
// the servlet implementation)
handleEscape(esc);
dispose();
} catch (Escape esc) {
LOG.debug("Escape performed during action phase.");
// We can't handle the escape until the render phase.
} catch (Throwable t) {
// We try not to let any exception propagate to container.
String message = "Caught exception during action phase.";
LOG.error(message, t);
// We can't handle the error until the render phase.
propogateError(t);
} finally {
UIContextHolder.reset();
}
} | [
"public",
"void",
"processAction",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"isDisposed",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Skipping action phase. Attempt to reuse disposed ContainerHelper instance\"",
")",
";",
"return",
";",
"}",
"try",
"{",
"// Check user context has been prepared",
"if",
"(",
"getNewConversation",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"User context has not been prepared before the action phase\"",
")",
";",
"}",
"prepareAction",
"(",
")",
";",
"UIContext",
"uic",
"=",
"getUIContext",
"(",
")",
";",
"if",
"(",
"uic",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No user context set for the action phase.\"",
")",
";",
"}",
"UIContextHolder",
".",
"pushContext",
"(",
"uic",
")",
";",
"// Make sure maps are cleared up",
"uic",
".",
"clearScratchMap",
"(",
")",
";",
"uic",
".",
"clearRequestScratchMap",
"(",
")",
";",
"prepareRequest",
"(",
")",
";",
"Request",
"req",
"=",
"getRequest",
"(",
")",
";",
"getInterceptor",
"(",
")",
".",
"attachResponse",
"(",
"getResponse",
"(",
")",
")",
";",
"getInterceptor",
"(",
")",
".",
"serviceRequest",
"(",
"req",
")",
";",
"if",
"(",
"req",
".",
"isLogout",
"(",
")",
")",
"{",
"handleLogout",
"(",
")",
";",
"dispose",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"ActionEscape",
"esc",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"ActionEscape performed.\"",
")",
";",
"// Action escapes must be handled in the action phase and then",
"// do nothing if they reach the render phase (which they will in",
"// the servlet implementation)",
"handleEscape",
"(",
"esc",
")",
";",
"dispose",
"(",
")",
";",
"}",
"catch",
"(",
"Escape",
"esc",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Escape performed during action phase.\"",
")",
";",
"// We can't handle the escape until the render phase.",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// We try not to let any exception propagate to container.",
"String",
"message",
"=",
"\"Caught exception during action phase.\"",
";",
"LOG",
".",
"error",
"(",
"message",
",",
"t",
")",
";",
"// We can't handle the error until the render phase.",
"propogateError",
"(",
"t",
")",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"reset",
"(",
")",
";",
"}",
"}"
] | Support standard processing of the action phase of a request.
@throws IOException if there is an IO error on writing a response. | [
"Support",
"standard",
"processing",
"of",
"the",
"action",
"phase",
"of",
"a",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L136-L192 |
139,538 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.render | public void render() throws IOException {
if (isDisposed()) {
LOG.debug("Skipping render phase.");
return;
}
try {
// Check user context has been prepared
if (getNewConversation() == null) {
throw new IllegalStateException(
"User context has not been prepared before the render phase");
}
prepareRender();
UIContext uic = getUIContext();
if (uic == null) {
throw new IllegalStateException("No user context set for the render phase.");
}
UIContextHolder.pushContext(uic);
prepareRequest();
// Handle errors from the action phase now.
if (havePropogatedError()) {
handleError(getPropogatedError());
return;
}
WComponent uiComponent = getUI();
if (uiComponent == null) {
throw new SystemException("No UI Component exists.");
}
Environment environment = uiComponent.getEnvironment();
if (environment == null) {
throw new SystemException("No WEnvironment exists.");
}
getInterceptor().attachResponse(getResponse());
getInterceptor().preparePaint(getRequest());
String contentType = getUI().getHeaders().getContentType();
Response response = getResponse();
response.setContentType(contentType);
addGenericHeaders(uic, getUI());
PrintWriter writer = getPrintWriter();
getInterceptor().paint(new WebXmlRenderContext(writer, uic.getLocale()));
// The following only matters for a Portal context
String title = uiComponent instanceof WApplication ? ((WApplication) uiComponent).
getTitle() : null;
if (title != null) {
setTitle(title);
}
} catch (Escape esc) {
LOG.debug("Escape performed during render phase.");
handleEscape(esc);
} catch (Throwable t) {
// We try not to let any exception propagate to container.
String message = "Caught exception during render phase.";
LOG.error(message, t);
handleError(t);
} finally {
UIContextHolder.reset();
dispose();
}
} | java | public void render() throws IOException {
if (isDisposed()) {
LOG.debug("Skipping render phase.");
return;
}
try {
// Check user context has been prepared
if (getNewConversation() == null) {
throw new IllegalStateException(
"User context has not been prepared before the render phase");
}
prepareRender();
UIContext uic = getUIContext();
if (uic == null) {
throw new IllegalStateException("No user context set for the render phase.");
}
UIContextHolder.pushContext(uic);
prepareRequest();
// Handle errors from the action phase now.
if (havePropogatedError()) {
handleError(getPropogatedError());
return;
}
WComponent uiComponent = getUI();
if (uiComponent == null) {
throw new SystemException("No UI Component exists.");
}
Environment environment = uiComponent.getEnvironment();
if (environment == null) {
throw new SystemException("No WEnvironment exists.");
}
getInterceptor().attachResponse(getResponse());
getInterceptor().preparePaint(getRequest());
String contentType = getUI().getHeaders().getContentType();
Response response = getResponse();
response.setContentType(contentType);
addGenericHeaders(uic, getUI());
PrintWriter writer = getPrintWriter();
getInterceptor().paint(new WebXmlRenderContext(writer, uic.getLocale()));
// The following only matters for a Portal context
String title = uiComponent instanceof WApplication ? ((WApplication) uiComponent).
getTitle() : null;
if (title != null) {
setTitle(title);
}
} catch (Escape esc) {
LOG.debug("Escape performed during render phase.");
handleEscape(esc);
} catch (Throwable t) {
// We try not to let any exception propagate to container.
String message = "Caught exception during render phase.";
LOG.error(message, t);
handleError(t);
} finally {
UIContextHolder.reset();
dispose();
}
} | [
"public",
"void",
"render",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"isDisposed",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Skipping render phase.\"",
")",
";",
"return",
";",
"}",
"try",
"{",
"// Check user context has been prepared",
"if",
"(",
"getNewConversation",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"User context has not been prepared before the render phase\"",
")",
";",
"}",
"prepareRender",
"(",
")",
";",
"UIContext",
"uic",
"=",
"getUIContext",
"(",
")",
";",
"if",
"(",
"uic",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No user context set for the render phase.\"",
")",
";",
"}",
"UIContextHolder",
".",
"pushContext",
"(",
"uic",
")",
";",
"prepareRequest",
"(",
")",
";",
"// Handle errors from the action phase now.",
"if",
"(",
"havePropogatedError",
"(",
")",
")",
"{",
"handleError",
"(",
"getPropogatedError",
"(",
")",
")",
";",
"return",
";",
"}",
"WComponent",
"uiComponent",
"=",
"getUI",
"(",
")",
";",
"if",
"(",
"uiComponent",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No UI Component exists.\"",
")",
";",
"}",
"Environment",
"environment",
"=",
"uiComponent",
".",
"getEnvironment",
"(",
")",
";",
"if",
"(",
"environment",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No WEnvironment exists.\"",
")",
";",
"}",
"getInterceptor",
"(",
")",
".",
"attachResponse",
"(",
"getResponse",
"(",
")",
")",
";",
"getInterceptor",
"(",
")",
".",
"preparePaint",
"(",
"getRequest",
"(",
")",
")",
";",
"String",
"contentType",
"=",
"getUI",
"(",
")",
".",
"getHeaders",
"(",
")",
".",
"getContentType",
"(",
")",
";",
"Response",
"response",
"=",
"getResponse",
"(",
")",
";",
"response",
".",
"setContentType",
"(",
"contentType",
")",
";",
"addGenericHeaders",
"(",
"uic",
",",
"getUI",
"(",
")",
")",
";",
"PrintWriter",
"writer",
"=",
"getPrintWriter",
"(",
")",
";",
"getInterceptor",
"(",
")",
".",
"paint",
"(",
"new",
"WebXmlRenderContext",
"(",
"writer",
",",
"uic",
".",
"getLocale",
"(",
")",
")",
")",
";",
"// The following only matters for a Portal context",
"String",
"title",
"=",
"uiComponent",
"instanceof",
"WApplication",
"?",
"(",
"(",
"WApplication",
")",
"uiComponent",
")",
".",
"getTitle",
"(",
")",
":",
"null",
";",
"if",
"(",
"title",
"!=",
"null",
")",
"{",
"setTitle",
"(",
"title",
")",
";",
"}",
"}",
"catch",
"(",
"Escape",
"esc",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Escape performed during render phase.\"",
")",
";",
"handleEscape",
"(",
"esc",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// We try not to let any exception propagate to container.",
"String",
"message",
"=",
"\"Caught exception during render phase.\"",
";",
"LOG",
".",
"error",
"(",
"message",
",",
"t",
")",
";",
"handleError",
"(",
"t",
")",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"reset",
"(",
")",
";",
"dispose",
"(",
")",
";",
"}",
"}"
] | Support standard processing of the render phase of a request.
@throws IOException IO Exception | [
"Support",
"standard",
"processing",
"of",
"the",
"render",
"phase",
"of",
"a",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L199-L271 |
139,539 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.cycleUIContext | protected void cycleUIContext() {
boolean cycleIt = ConfigurationProperties.getDeveloperClusterEmulation();
if (cycleIt) {
UIContext uic = getUIContext();
if (uic instanceof UIContextWrap) {
LOG.info("Cycling the UIContext to simulate clustering");
((UIContextWrap) uic).cycle();
}
}
} | java | protected void cycleUIContext() {
boolean cycleIt = ConfigurationProperties.getDeveloperClusterEmulation();
if (cycleIt) {
UIContext uic = getUIContext();
if (uic instanceof UIContextWrap) {
LOG.info("Cycling the UIContext to simulate clustering");
((UIContextWrap) uic).cycle();
}
}
} | [
"protected",
"void",
"cycleUIContext",
"(",
")",
"{",
"boolean",
"cycleIt",
"=",
"ConfigurationProperties",
".",
"getDeveloperClusterEmulation",
"(",
")",
";",
"if",
"(",
"cycleIt",
")",
"{",
"UIContext",
"uic",
"=",
"getUIContext",
"(",
")",
";",
"if",
"(",
"uic",
"instanceof",
"UIContextWrap",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Cycling the UIContext to simulate clustering\"",
")",
";",
"(",
"(",
"UIContextWrap",
")",
"uic",
")",
".",
"cycle",
"(",
")",
";",
"}",
"}",
"}"
] | Call this method to simulate what would happen if the UIContext was serialized due to clustering of servers. | [
"Call",
"this",
"method",
"to",
"simulate",
"what",
"would",
"happen",
"if",
"the",
"UIContext",
"was",
"serialized",
"due",
"to",
"clustering",
"of",
"servers",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L324-L335 |
139,540 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.prepareRequest | protected void prepareRequest() {
LOG.debug("Preparing for request by adding headers and environment to top wcomponent");
// Configure the UIContext to handle this request.
UIContext uiContext = getUIContext();
// Add WEnvironment if not already done.
// If the component is new, then it will not have a WEnvironment yet.
Environment env;
if (uiContext.isDummyEnvironment()) {
env = createEnvironment();
uiContext.setEnvironment(env);
} else {
env = uiContext.getEnvironment();
}
// Update the environment for the current phase of the request
// processing.
updateEnvironment(env);
// Prepare an implementation of a wcomponent Request suitable to the
// type of
// container we are running in.
if (getRequest() == null) {
setRequest(createRequest());
}
// Update the wcomponent Request for the current phase of the request
// processing.
updateRequest(getRequest());
} | java | protected void prepareRequest() {
LOG.debug("Preparing for request by adding headers and environment to top wcomponent");
// Configure the UIContext to handle this request.
UIContext uiContext = getUIContext();
// Add WEnvironment if not already done.
// If the component is new, then it will not have a WEnvironment yet.
Environment env;
if (uiContext.isDummyEnvironment()) {
env = createEnvironment();
uiContext.setEnvironment(env);
} else {
env = uiContext.getEnvironment();
}
// Update the environment for the current phase of the request
// processing.
updateEnvironment(env);
// Prepare an implementation of a wcomponent Request suitable to the
// type of
// container we are running in.
if (getRequest() == null) {
setRequest(createRequest());
}
// Update the wcomponent Request for the current phase of the request
// processing.
updateRequest(getRequest());
} | [
"protected",
"void",
"prepareRequest",
"(",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Preparing for request by adding headers and environment to top wcomponent\"",
")",
";",
"// Configure the UIContext to handle this request.",
"UIContext",
"uiContext",
"=",
"getUIContext",
"(",
")",
";",
"// Add WEnvironment if not already done.",
"// If the component is new, then it will not have a WEnvironment yet.",
"Environment",
"env",
";",
"if",
"(",
"uiContext",
".",
"isDummyEnvironment",
"(",
")",
")",
"{",
"env",
"=",
"createEnvironment",
"(",
")",
";",
"uiContext",
".",
"setEnvironment",
"(",
"env",
")",
";",
"}",
"else",
"{",
"env",
"=",
"uiContext",
".",
"getEnvironment",
"(",
")",
";",
"}",
"// Update the environment for the current phase of the request",
"// processing.",
"updateEnvironment",
"(",
"env",
")",
";",
"// Prepare an implementation of a wcomponent Request suitable to the",
"// type of",
"// container we are running in.",
"if",
"(",
"getRequest",
"(",
")",
"==",
"null",
")",
"{",
"setRequest",
"(",
"createRequest",
"(",
")",
")",
";",
"}",
"// Update the wcomponent Request for the current phase of the request",
"// processing.",
"updateRequest",
"(",
"getRequest",
"(",
")",
")",
";",
"}"
] | Prepare the session for the current request. | [
"Prepare",
"the",
"session",
"for",
"the",
"current",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L361-L392 |
139,541 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.propogateError | private void propogateError(final Throwable error) {
// Unhandled runtime exceptions from action phase
// must be remembered for subsequent renders
if (getRequest() == null) {
LOG.error("Unable to remember error from action phase beyond this request");
} else {
LOG.debug("Remembering error from action phase");
getRequest().setAttribute(ACTION_ERROR_KEY, error);
}
} | java | private void propogateError(final Throwable error) {
// Unhandled runtime exceptions from action phase
// must be remembered for subsequent renders
if (getRequest() == null) {
LOG.error("Unable to remember error from action phase beyond this request");
} else {
LOG.debug("Remembering error from action phase");
getRequest().setAttribute(ACTION_ERROR_KEY, error);
}
} | [
"private",
"void",
"propogateError",
"(",
"final",
"Throwable",
"error",
")",
"{",
"// Unhandled runtime exceptions from action phase",
"// must be remembered for subsequent renders",
"if",
"(",
"getRequest",
"(",
")",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to remember error from action phase beyond this request\"",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"Remembering error from action phase\"",
")",
";",
"getRequest",
"(",
")",
".",
"setAttribute",
"(",
"ACTION_ERROR_KEY",
",",
"error",
")",
";",
"}",
"}"
] | Propogates an error from the action phase to the render phase.
@param error the error to propogate. | [
"Propogates",
"an",
"error",
"from",
"the",
"action",
"phase",
"to",
"the",
"render",
"phase",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L561-L570 |
139,542 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.havePropogatedError | private boolean havePropogatedError() {
Request req = getRequest();
return req != null && req.getAttribute(ACTION_ERROR_KEY) != null;
} | java | private boolean havePropogatedError() {
Request req = getRequest();
return req != null && req.getAttribute(ACTION_ERROR_KEY) != null;
} | [
"private",
"boolean",
"havePropogatedError",
"(",
")",
"{",
"Request",
"req",
"=",
"getRequest",
"(",
")",
";",
"return",
"req",
"!=",
"null",
"&&",
"req",
".",
"getAttribute",
"(",
"ACTION_ERROR_KEY",
")",
"!=",
"null",
";",
"}"
] | Indicates whether there is an error which has been propogated from the action to the render phase.
@return true if there is a propogated escape, false otherwise. | [
"Indicates",
"whether",
"there",
"is",
"an",
"error",
"which",
"has",
"been",
"propogated",
"from",
"the",
"action",
"to",
"the",
"render",
"phase",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L577-L580 |
139,543 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.getPropogatedError | private Throwable getPropogatedError() {
Request req = getRequest();
if (req != null) {
return (Throwable) req.getAttribute(ACTION_ERROR_KEY);
}
return null;
} | java | private Throwable getPropogatedError() {
Request req = getRequest();
if (req != null) {
return (Throwable) req.getAttribute(ACTION_ERROR_KEY);
}
return null;
} | [
"private",
"Throwable",
"getPropogatedError",
"(",
")",
"{",
"Request",
"req",
"=",
"getRequest",
"(",
")",
";",
"if",
"(",
"req",
"!=",
"null",
")",
"{",
"return",
"(",
"Throwable",
")",
"req",
".",
"getAttribute",
"(",
"ACTION_ERROR_KEY",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieves an error which has been propogated from the action to the render phase.
@return the propogated escape, or null if there isn't one. | [
"Retrieves",
"an",
"error",
"which",
"has",
"been",
"propogated",
"from",
"the",
"action",
"to",
"the",
"render",
"phase",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L587-L595 |
139,544 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.handleError | public void handleError(final Throwable error) throws IOException {
LOG.debug("Start handleError...");
// Should the session be removed upon error?
boolean terminate = ConfigurationProperties.getTerminateSessionOnError();
// If we are unfriendly, terminate the session
if (terminate) {
invalidateSession();
}
// Are we in developer friendly error mode?
boolean friendly = ConfigurationProperties.getDeveloperErrorHandling();
FatalErrorPageFactory factory = Factory.newInstance(FatalErrorPageFactory.class);
WComponent errorPage = factory.createErrorPage(friendly, error);
String html = renderErrorPageToHTML(errorPage);
// Setup the response
Response response = getResponse();
response.setContentType(WebUtilities.CONTENT_TYPE_HTML);
// Make sure not cached
getResponse().setHeader("Cache-Control", CacheType.NO_CACHE.getSettings());
getResponse().setHeader("Pragma", "no-cache");
getResponse().setHeader("Expires", "-1");
getPrintWriter().println(html);
LOG.debug("End handleError");
} | java | public void handleError(final Throwable error) throws IOException {
LOG.debug("Start handleError...");
// Should the session be removed upon error?
boolean terminate = ConfigurationProperties.getTerminateSessionOnError();
// If we are unfriendly, terminate the session
if (terminate) {
invalidateSession();
}
// Are we in developer friendly error mode?
boolean friendly = ConfigurationProperties.getDeveloperErrorHandling();
FatalErrorPageFactory factory = Factory.newInstance(FatalErrorPageFactory.class);
WComponent errorPage = factory.createErrorPage(friendly, error);
String html = renderErrorPageToHTML(errorPage);
// Setup the response
Response response = getResponse();
response.setContentType(WebUtilities.CONTENT_TYPE_HTML);
// Make sure not cached
getResponse().setHeader("Cache-Control", CacheType.NO_CACHE.getSettings());
getResponse().setHeader("Pragma", "no-cache");
getResponse().setHeader("Expires", "-1");
getPrintWriter().println(html);
LOG.debug("End handleError");
} | [
"public",
"void",
"handleError",
"(",
"final",
"Throwable",
"error",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"debug",
"(",
"\"Start handleError...\"",
")",
";",
"// Should the session be removed upon error?",
"boolean",
"terminate",
"=",
"ConfigurationProperties",
".",
"getTerminateSessionOnError",
"(",
")",
";",
"// If we are unfriendly, terminate the session",
"if",
"(",
"terminate",
")",
"{",
"invalidateSession",
"(",
")",
";",
"}",
"// Are we in developer friendly error mode?",
"boolean",
"friendly",
"=",
"ConfigurationProperties",
".",
"getDeveloperErrorHandling",
"(",
")",
";",
"FatalErrorPageFactory",
"factory",
"=",
"Factory",
".",
"newInstance",
"(",
"FatalErrorPageFactory",
".",
"class",
")",
";",
"WComponent",
"errorPage",
"=",
"factory",
".",
"createErrorPage",
"(",
"friendly",
",",
"error",
")",
";",
"String",
"html",
"=",
"renderErrorPageToHTML",
"(",
"errorPage",
")",
";",
"// Setup the response",
"Response",
"response",
"=",
"getResponse",
"(",
")",
";",
"response",
".",
"setContentType",
"(",
"WebUtilities",
".",
"CONTENT_TYPE_HTML",
")",
";",
"// Make sure not cached",
"getResponse",
"(",
")",
".",
"setHeader",
"(",
"\"Cache-Control\"",
",",
"CacheType",
".",
"NO_CACHE",
".",
"getSettings",
"(",
")",
")",
";",
"getResponse",
"(",
")",
".",
"setHeader",
"(",
"\"Pragma\"",
",",
"\"no-cache\"",
")",
";",
"getResponse",
"(",
")",
".",
"setHeader",
"(",
"\"Expires\"",
",",
"\"-1\"",
")",
";",
"getPrintWriter",
"(",
")",
".",
"println",
"(",
"html",
")",
";",
"LOG",
".",
"debug",
"(",
"\"End handleError\"",
")",
";",
"}"
] | Last resort error handling.
@param error the error to handle.
@throws IOException if there is an error writing the error HTML. | [
"Last",
"resort",
"error",
"handling",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L603-L634 |
139,545 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java | AbstractContainerHelper.renderErrorPageToHTML | protected String renderErrorPageToHTML(final WComponent errorPage) {
// Check if using the default error page
boolean defaultErrorPage = errorPage instanceof FatalErrorPage;
String html = null;
// If not default implementation of error page, Transform error page to HTML
if (!defaultErrorPage) {
// Set UIC and Environment (Needed for Theme Paths)
UIContext uic = new UIContextImpl();
uic.setEnvironment(createEnvironment());
UIContextHolder.pushContext(uic);
try {
html = WebUtilities.renderWithTransformToHTML(errorPage);
} catch (Exception e) {
LOG.warn("Could not transform error page.", e);
} finally {
UIContextHolder.popContext();
}
}
// Not transformed. So just render.
if (html == null) {
UIContextHolder.pushContext(new UIContextImpl());
try {
html = WebUtilities.render(errorPage);
} catch (Exception e) {
LOG.warn("Could not render error page.", e);
html = "System error occurred but could not render error page.";
} finally {
UIContextHolder.popContext();
}
}
return html;
} | java | protected String renderErrorPageToHTML(final WComponent errorPage) {
// Check if using the default error page
boolean defaultErrorPage = errorPage instanceof FatalErrorPage;
String html = null;
// If not default implementation of error page, Transform error page to HTML
if (!defaultErrorPage) {
// Set UIC and Environment (Needed for Theme Paths)
UIContext uic = new UIContextImpl();
uic.setEnvironment(createEnvironment());
UIContextHolder.pushContext(uic);
try {
html = WebUtilities.renderWithTransformToHTML(errorPage);
} catch (Exception e) {
LOG.warn("Could not transform error page.", e);
} finally {
UIContextHolder.popContext();
}
}
// Not transformed. So just render.
if (html == null) {
UIContextHolder.pushContext(new UIContextImpl());
try {
html = WebUtilities.render(errorPage);
} catch (Exception e) {
LOG.warn("Could not render error page.", e);
html = "System error occurred but could not render error page.";
} finally {
UIContextHolder.popContext();
}
}
return html;
} | [
"protected",
"String",
"renderErrorPageToHTML",
"(",
"final",
"WComponent",
"errorPage",
")",
"{",
"// Check if using the default error page",
"boolean",
"defaultErrorPage",
"=",
"errorPage",
"instanceof",
"FatalErrorPage",
";",
"String",
"html",
"=",
"null",
";",
"// If not default implementation of error page, Transform error page to HTML",
"if",
"(",
"!",
"defaultErrorPage",
")",
"{",
"// Set UIC and Environment (Needed for Theme Paths)",
"UIContext",
"uic",
"=",
"new",
"UIContextImpl",
"(",
")",
";",
"uic",
".",
"setEnvironment",
"(",
"createEnvironment",
"(",
")",
")",
";",
"UIContextHolder",
".",
"pushContext",
"(",
"uic",
")",
";",
"try",
"{",
"html",
"=",
"WebUtilities",
".",
"renderWithTransformToHTML",
"(",
"errorPage",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Could not transform error page.\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"}",
"// Not transformed. So just render.",
"if",
"(",
"html",
"==",
"null",
")",
"{",
"UIContextHolder",
".",
"pushContext",
"(",
"new",
"UIContextImpl",
"(",
")",
")",
";",
"try",
"{",
"html",
"=",
"WebUtilities",
".",
"render",
"(",
"errorPage",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Could not render error page.\"",
",",
"e",
")",
";",
"html",
"=",
"\"System error occurred but could not render error page.\"",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"}",
"return",
"html",
";",
"}"
] | Render the error page component to HTML.
@param errorPage the error page component
@return the error page as HTML | [
"Render",
"the",
"error",
"page",
"component",
"to",
"HTML",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AbstractContainerHelper.java#L642-L678 |
139,546 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFieldLayoutRenderer.java | WFieldLayoutRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFieldLayout fieldLayout = (WFieldLayout) component;
XmlStringBuilder xml = renderContext.getWriter();
int labelWidth = fieldLayout.getLabelWidth();
String title = fieldLayout.getTitle();
xml.appendTagOpen("ui:fieldlayout");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", fieldLayout.isHidden(), "true");
xml.appendOptionalAttribute("labelWidth", labelWidth > 0, labelWidth);
xml.appendAttribute("layout", fieldLayout.getLayoutType());
xml.appendOptionalAttribute("title", title);
// Ordered layout
if (fieldLayout.isOrdered()) {
xml.appendAttribute("ordered", fieldLayout.getOrderedOffset());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(fieldLayout, renderContext);
// Paint Fields
paintChildren(fieldLayout, renderContext);
xml.appendEndTag("ui:fieldlayout");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFieldLayout fieldLayout = (WFieldLayout) component;
XmlStringBuilder xml = renderContext.getWriter();
int labelWidth = fieldLayout.getLabelWidth();
String title = fieldLayout.getTitle();
xml.appendTagOpen("ui:fieldlayout");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", fieldLayout.isHidden(), "true");
xml.appendOptionalAttribute("labelWidth", labelWidth > 0, labelWidth);
xml.appendAttribute("layout", fieldLayout.getLayoutType());
xml.appendOptionalAttribute("title", title);
// Ordered layout
if (fieldLayout.isOrdered()) {
xml.appendAttribute("ordered", fieldLayout.getOrderedOffset());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(fieldLayout, renderContext);
// Paint Fields
paintChildren(fieldLayout, renderContext);
xml.appendEndTag("ui:fieldlayout");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WFieldLayout",
"fieldLayout",
"=",
"(",
"WFieldLayout",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"int",
"labelWidth",
"=",
"fieldLayout",
".",
"getLabelWidth",
"(",
")",
";",
"String",
"title",
"=",
"fieldLayout",
".",
"getTitle",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:fieldlayout\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"fieldLayout",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"labelWidth\"",
",",
"labelWidth",
">",
"0",
",",
"labelWidth",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"layout\"",
",",
"fieldLayout",
".",
"getLayoutType",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"title\"",
",",
"title",
")",
";",
"// Ordered layout",
"if",
"(",
"fieldLayout",
".",
"isOrdered",
"(",
")",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"ordered\"",
",",
"fieldLayout",
".",
"getOrderedOffset",
"(",
")",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Render margin",
"MarginRendererUtil",
".",
"renderMargin",
"(",
"fieldLayout",
",",
"renderContext",
")",
";",
"// Paint Fields",
"paintChildren",
"(",
"fieldLayout",
",",
"renderContext",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:fieldlayout\"",
")",
";",
"}"
] | Paints the given WFieldLayout.
@param component the WFieldLayout to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WFieldLayout",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFieldLayoutRenderer.java#L23-L51 |
139,547 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WAbbrTextRenderer.java | WAbbrTextRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WAbbrText abbrText = (WAbbrText) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("abbr");
xml.appendOptionalAttribute("title", abbrText.getToolTip());
xml.appendOptionalAttribute("class", abbrText.getHtmlClass());
xml.appendClose();
xml.append(abbrText.getText(), abbrText.isEncodeText());
xml.appendEndTag("abbr");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WAbbrText abbrText = (WAbbrText) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("abbr");
xml.appendOptionalAttribute("title", abbrText.getToolTip());
xml.appendOptionalAttribute("class", abbrText.getHtmlClass());
xml.appendClose();
xml.append(abbrText.getText(), abbrText.isEncodeText());
xml.appendEndTag("abbr");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WAbbrText",
"abbrText",
"=",
"(",
"WAbbrText",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"abbr\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"title\"",
",",
"abbrText",
".",
"getToolTip",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"abbrText",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"xml",
".",
"append",
"(",
"abbrText",
".",
"getText",
"(",
")",
",",
"abbrText",
".",
"isEncodeText",
"(",
")",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"abbr\"",
")",
";",
"}"
] | Paints the given WAbbrText.
@param component the WAbbrText to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WAbbrText",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WAbbrTextRenderer.java#L23-L34 |
139,548 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java | MockHttpServletRequest.getCookies | @Override
public Cookie[] getCookies() {
Collection<Cookie> entries = cookies.values();
return entries.toArray(new Cookie[0]);
} | java | @Override
public Cookie[] getCookies() {
Collection<Cookie> entries = cookies.values();
return entries.toArray(new Cookie[0]);
} | [
"@",
"Override",
"public",
"Cookie",
"[",
"]",
"getCookies",
"(",
")",
"{",
"Collection",
"<",
"Cookie",
">",
"entries",
"=",
"cookies",
".",
"values",
"(",
")",
";",
"return",
"entries",
".",
"toArray",
"(",
"new",
"Cookie",
"[",
"0",
"]",
")",
";",
"}"
] | Get all the cookies on this request.
@return An array of all Cookie objects associated with this request. | [
"Get",
"all",
"the",
"cookies",
"on",
"this",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java#L83-L87 |
139,549 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java | MockHttpServletRequest.setCookie | public void setCookie(final String name, final String value) {
if (name != null) {
Cookie cookie = new Cookie(name, value);
cookies.put(name, cookie);
}
} | java | public void setCookie(final String name, final String value) {
if (name != null) {
Cookie cookie = new Cookie(name, value);
cookies.put(name, cookie);
}
} | [
"public",
"void",
"setCookie",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"Cookie",
"cookie",
"=",
"new",
"Cookie",
"(",
"name",
",",
"value",
")",
";",
"cookies",
".",
"put",
"(",
"name",
",",
"cookie",
")",
";",
"}",
"}"
] | Sets a cookie on this request instance.
@param name The cookie name.
@param value The value of the cookie to set. | [
"Sets",
"a",
"cookie",
"on",
"this",
"request",
"instance",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java#L94-L99 |
139,550 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java | MockHttpServletRequest.setParameter | public void setParameter(final String name, final String value) {
String[] currentValue = (String[]) parameters.get(name);
if (currentValue == null) {
currentValue = new String[]{value};
} else {
// convert the current values into a new array..
String[] newValues = new String[currentValue.length + 1];
System.arraycopy(currentValue, 0, newValues, 0, currentValue.length);
newValues[newValues.length - 1] = value;
currentValue = newValues;
}
parameters.put(name, currentValue);
} | java | public void setParameter(final String name, final String value) {
String[] currentValue = (String[]) parameters.get(name);
if (currentValue == null) {
currentValue = new String[]{value};
} else {
// convert the current values into a new array..
String[] newValues = new String[currentValue.length + 1];
System.arraycopy(currentValue, 0, newValues, 0, currentValue.length);
newValues[newValues.length - 1] = value;
currentValue = newValues;
}
parameters.put(name, currentValue);
} | [
"public",
"void",
"setParameter",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"String",
"[",
"]",
"currentValue",
"=",
"(",
"String",
"[",
"]",
")",
"parameters",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"currentValue",
"==",
"null",
")",
"{",
"currentValue",
"=",
"new",
"String",
"[",
"]",
"{",
"value",
"}",
";",
"}",
"else",
"{",
"// convert the current values into a new array..",
"String",
"[",
"]",
"newValues",
"=",
"new",
"String",
"[",
"currentValue",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"currentValue",
",",
"0",
",",
"newValues",
",",
"0",
",",
"currentValue",
".",
"length",
")",
";",
"newValues",
"[",
"newValues",
".",
"length",
"-",
"1",
"]",
"=",
"value",
";",
"currentValue",
"=",
"newValues",
";",
"}",
"parameters",
".",
"put",
"(",
"name",
",",
"currentValue",
")",
";",
"}"
] | Sets a parameter. If the parameter already exists, another value will be added to the parameter values.
@param name the parameter name
@param value the parameter value | [
"Sets",
"a",
"parameter",
".",
"If",
"the",
"parameter",
"already",
"exists",
"another",
"value",
"will",
"be",
"added",
"to",
"the",
"parameter",
"values",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java#L490-L504 |
139,551 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Factory.java | Factory.newInstance | public static <T> T newInstance(final Class<T> interfaz) {
String classname = ConfigurationProperties.getFactoryImplementation(interfaz.getName());
if (classname == null) {
// Hmmm - this is bad. For the time being let's dump the parameters.
LOG.fatal("No implementing class for " + interfaz.getName());
LOG.fatal("There needs to be a parameter defined for " + ConfigurationProperties.FACTORY_PREFIX + interfaz.getName());
throw new SystemException("No implementing class for " + interfaz.getName() + "; "
+ "There needs to be a parameter defined for " + ConfigurationProperties.FACTORY_PREFIX + interfaz.getName());
}
try {
Class<T> clas = (Class<T>) Class.forName(classname.trim());
return clas.newInstance();
} catch (Exception ex) {
throw new SystemException("Failed to instantiate object of class " + classname, ex);
}
} | java | public static <T> T newInstance(final Class<T> interfaz) {
String classname = ConfigurationProperties.getFactoryImplementation(interfaz.getName());
if (classname == null) {
// Hmmm - this is bad. For the time being let's dump the parameters.
LOG.fatal("No implementing class for " + interfaz.getName());
LOG.fatal("There needs to be a parameter defined for " + ConfigurationProperties.FACTORY_PREFIX + interfaz.getName());
throw new SystemException("No implementing class for " + interfaz.getName() + "; "
+ "There needs to be a parameter defined for " + ConfigurationProperties.FACTORY_PREFIX + interfaz.getName());
}
try {
Class<T> clas = (Class<T>) Class.forName(classname.trim());
return clas.newInstance();
} catch (Exception ex) {
throw new SystemException("Failed to instantiate object of class " + classname, ex);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"final",
"Class",
"<",
"T",
">",
"interfaz",
")",
"{",
"String",
"classname",
"=",
"ConfigurationProperties",
".",
"getFactoryImplementation",
"(",
"interfaz",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"classname",
"==",
"null",
")",
"{",
"// Hmmm - this is bad. For the time being let's dump the parameters.",
"LOG",
".",
"fatal",
"(",
"\"No implementing class for \"",
"+",
"interfaz",
".",
"getName",
"(",
")",
")",
";",
"LOG",
".",
"fatal",
"(",
"\"There needs to be a parameter defined for \"",
"+",
"ConfigurationProperties",
".",
"FACTORY_PREFIX",
"+",
"interfaz",
".",
"getName",
"(",
")",
")",
";",
"throw",
"new",
"SystemException",
"(",
"\"No implementing class for \"",
"+",
"interfaz",
".",
"getName",
"(",
")",
"+",
"\"; \"",
"+",
"\"There needs to be a parameter defined for \"",
"+",
"ConfigurationProperties",
".",
"FACTORY_PREFIX",
"+",
"interfaz",
".",
"getName",
"(",
")",
")",
";",
"}",
"try",
"{",
"Class",
"<",
"T",
">",
"clas",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"Class",
".",
"forName",
"(",
"classname",
".",
"trim",
"(",
")",
")",
";",
"return",
"clas",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"Failed to instantiate object of class \"",
"+",
"classname",
",",
"ex",
")",
";",
"}",
"}"
] | Given an interface, instantiate a class implementing that interface.
The classname to instantiate is obtained by looking in the runtime {@link Config configuration}, under the
bordertech.wcomponents.factory.impl.<interface name> key.
@param <T> the interface type.
@param interfaz the interface to instantiate an implementation for.
@return an Object which implements the given interface.
@throws SystemException if no implementing class is registered in the {@link Config configuration}. | [
"Given",
"an",
"interface",
"instantiate",
"a",
"class",
"implementing",
"that",
"interface",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/Factory.java#L46-L64 |
139,552 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiSelectPairRenderer.java | WMultiSelectPairRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiSelectPair multiSelectPair = (WMultiSelectPair) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = multiSelectPair.isReadOnly();
xml.appendTagOpen("ui:multiselectpair");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", multiSelectPair.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int rows = multiSelectPair.getRows();
int min = multiSelectPair.getMinSelect();
int max = multiSelectPair.getMaxSelect();
xml.appendAttribute("size", rows < 2 ? WMultiSelectPair.DEFAULT_ROWS : rows);
xml.appendOptionalAttribute("disabled", multiSelectPair.isDisabled(), "true");
xml.appendOptionalAttribute("required", multiSelectPair.isMandatory(), "true");
xml.appendOptionalAttribute("shuffle", multiSelectPair.isShuffle(), "true");
xml.appendOptionalAttribute("fromListName", multiSelectPair.getAvailableListName());
xml.appendOptionalAttribute("toListName", multiSelectPair.getSelectedListName());
xml.appendOptionalAttribute("accessibleText", multiSelectPair.getAccessibleText());
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
}
xml.appendClose();
// Options
List<?> options = multiSelectPair.getOptions();
boolean renderSelectionsOnly = readOnly;
if (options != null) {
if (multiSelectPair.isShuffle()) {
// We need to render the selected options in order
renderOrderedOptions(multiSelectPair, options, 0, xml, renderSelectionsOnly);
} else {
renderUnorderedOptions(multiSelectPair, options, 0, xml, renderSelectionsOnly);
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(multiSelectPair, renderContext);
}
xml.appendEndTag("ui:multiselectpair");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiSelectPair multiSelectPair = (WMultiSelectPair) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = multiSelectPair.isReadOnly();
xml.appendTagOpen("ui:multiselectpair");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", multiSelectPair.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int rows = multiSelectPair.getRows();
int min = multiSelectPair.getMinSelect();
int max = multiSelectPair.getMaxSelect();
xml.appendAttribute("size", rows < 2 ? WMultiSelectPair.DEFAULT_ROWS : rows);
xml.appendOptionalAttribute("disabled", multiSelectPair.isDisabled(), "true");
xml.appendOptionalAttribute("required", multiSelectPair.isMandatory(), "true");
xml.appendOptionalAttribute("shuffle", multiSelectPair.isShuffle(), "true");
xml.appendOptionalAttribute("fromListName", multiSelectPair.getAvailableListName());
xml.appendOptionalAttribute("toListName", multiSelectPair.getSelectedListName());
xml.appendOptionalAttribute("accessibleText", multiSelectPair.getAccessibleText());
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
}
xml.appendClose();
// Options
List<?> options = multiSelectPair.getOptions();
boolean renderSelectionsOnly = readOnly;
if (options != null) {
if (multiSelectPair.isShuffle()) {
// We need to render the selected options in order
renderOrderedOptions(multiSelectPair, options, 0, xml, renderSelectionsOnly);
} else {
renderUnorderedOptions(multiSelectPair, options, 0, xml, renderSelectionsOnly);
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(multiSelectPair, renderContext);
}
xml.appendEndTag("ui:multiselectpair");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WMultiSelectPair",
"multiSelectPair",
"=",
"(",
"WMultiSelectPair",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"readOnly",
"=",
"multiSelectPair",
".",
"isReadOnly",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:multiselectpair\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"multiSelectPair",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"readOnly",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"readOnly\"",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"int",
"rows",
"=",
"multiSelectPair",
".",
"getRows",
"(",
")",
";",
"int",
"min",
"=",
"multiSelectPair",
".",
"getMinSelect",
"(",
")",
";",
"int",
"max",
"=",
"multiSelectPair",
".",
"getMaxSelect",
"(",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"size\"",
",",
"rows",
"<",
"2",
"?",
"WMultiSelectPair",
".",
"DEFAULT_ROWS",
":",
"rows",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"multiSelectPair",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"required\"",
",",
"multiSelectPair",
".",
"isMandatory",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"shuffle\"",
",",
"multiSelectPair",
".",
"isShuffle",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"fromListName\"",
",",
"multiSelectPair",
".",
"getAvailableListName",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"toListName\"",
",",
"multiSelectPair",
".",
"getSelectedListName",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"accessibleText\"",
",",
"multiSelectPair",
".",
"getAccessibleText",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"min\"",
",",
"min",
">",
"0",
",",
"min",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"max\"",
",",
"max",
">",
"0",
",",
"max",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Options",
"List",
"<",
"?",
">",
"options",
"=",
"multiSelectPair",
".",
"getOptions",
"(",
")",
";",
"boolean",
"renderSelectionsOnly",
"=",
"readOnly",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"if",
"(",
"multiSelectPair",
".",
"isShuffle",
"(",
")",
")",
"{",
"// We need to render the selected options in order",
"renderOrderedOptions",
"(",
"multiSelectPair",
",",
"options",
",",
"0",
",",
"xml",
",",
"renderSelectionsOnly",
")",
";",
"}",
"else",
"{",
"renderUnorderedOptions",
"(",
"multiSelectPair",
",",
"options",
",",
"0",
",",
"xml",
",",
"renderSelectionsOnly",
")",
";",
"}",
"}",
"if",
"(",
"!",
"readOnly",
")",
"{",
"DiagnosticRenderUtil",
".",
"renderDiagnostics",
"(",
"multiSelectPair",
",",
"renderContext",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:multiselectpair\"",
")",
";",
"}"
] | Paints the given WMultiSelectPair.
@param component the WMultiSelectPair to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WMultiSelectPair",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiSelectPairRenderer.java#L29-L75 |
139,553 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiSelectPairRenderer.java | WMultiSelectPairRenderer.renderOrderedOptions | private int renderOrderedOptions(final WMultiSelectPair multiSelectPair, final List<?> options,
final int startIndex, final XmlStringBuilder xml,
final boolean renderSelectionsOnly) {
List<?> selections = multiSelectPair.getSelected();
int optionIndex = startIndex;
// We can't just render all the unselected options followed by the selected ones
// in the order they are given to us, as unselected/selected may be intermingled
// due to the option groups. We therefore recursively render each group.
// For each group, we:
// - iterate through the options and
// - render the unselected ones
// - keep track of the selected ones (index within the selection list + index within the option list)
// - Once all the unselected items have been rendered, we render the selections
// This maps selection indices to option indices for the current group
Map<Integer, Integer> currentSelectionIndices = new HashMap<>();
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
// Recurse to render options inside option groups.
List<?> nestedOptions = ((OptionGroup) option).getOptions();
optionIndex += renderOrderedOptions(multiSelectPair, nestedOptions, optionIndex, xml,
renderSelectionsOnly);
xml.appendEndTag("ui:optgroup");
} else {
int index = selections.indexOf(option);
if (index == -1) {
renderOption(multiSelectPair, option, optionIndex++, xml, selections,
renderSelectionsOnly);
} else {
currentSelectionIndices.put(index, optionIndex++);
}
}
}
if (!currentSelectionIndices.isEmpty()) {
// Now sort the selected item's indices and render them in the correct order.
List<Integer> sortedSelectedIndices = new ArrayList<>(currentSelectionIndices.keySet());
Collections.sort(sortedSelectedIndices);
for (int selectionIndex : sortedSelectedIndices) {
int selectionOptionIndex = currentSelectionIndices.get(selectionIndex);
renderOption(multiSelectPair, selections.get(selectionIndex), selectionOptionIndex,
xml, selections, renderSelectionsOnly);
}
}
return optionIndex - startIndex;
} | java | private int renderOrderedOptions(final WMultiSelectPair multiSelectPair, final List<?> options,
final int startIndex, final XmlStringBuilder xml,
final boolean renderSelectionsOnly) {
List<?> selections = multiSelectPair.getSelected();
int optionIndex = startIndex;
// We can't just render all the unselected options followed by the selected ones
// in the order they are given to us, as unselected/selected may be intermingled
// due to the option groups. We therefore recursively render each group.
// For each group, we:
// - iterate through the options and
// - render the unselected ones
// - keep track of the selected ones (index within the selection list + index within the option list)
// - Once all the unselected items have been rendered, we render the selections
// This maps selection indices to option indices for the current group
Map<Integer, Integer> currentSelectionIndices = new HashMap<>();
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
// Recurse to render options inside option groups.
List<?> nestedOptions = ((OptionGroup) option).getOptions();
optionIndex += renderOrderedOptions(multiSelectPair, nestedOptions, optionIndex, xml,
renderSelectionsOnly);
xml.appendEndTag("ui:optgroup");
} else {
int index = selections.indexOf(option);
if (index == -1) {
renderOption(multiSelectPair, option, optionIndex++, xml, selections,
renderSelectionsOnly);
} else {
currentSelectionIndices.put(index, optionIndex++);
}
}
}
if (!currentSelectionIndices.isEmpty()) {
// Now sort the selected item's indices and render them in the correct order.
List<Integer> sortedSelectedIndices = new ArrayList<>(currentSelectionIndices.keySet());
Collections.sort(sortedSelectedIndices);
for (int selectionIndex : sortedSelectedIndices) {
int selectionOptionIndex = currentSelectionIndices.get(selectionIndex);
renderOption(multiSelectPair, selections.get(selectionIndex), selectionOptionIndex,
xml, selections, renderSelectionsOnly);
}
}
return optionIndex - startIndex;
} | [
"private",
"int",
"renderOrderedOptions",
"(",
"final",
"WMultiSelectPair",
"multiSelectPair",
",",
"final",
"List",
"<",
"?",
">",
"options",
",",
"final",
"int",
"startIndex",
",",
"final",
"XmlStringBuilder",
"xml",
",",
"final",
"boolean",
"renderSelectionsOnly",
")",
"{",
"List",
"<",
"?",
">",
"selections",
"=",
"multiSelectPair",
".",
"getSelected",
"(",
")",
";",
"int",
"optionIndex",
"=",
"startIndex",
";",
"// We can't just render all the unselected options followed by the selected ones",
"// in the order they are given to us, as unselected/selected may be intermingled",
"// due to the option groups. We therefore recursively render each group.",
"// For each group, we:",
"// - iterate through the options and",
"// - render the unselected ones",
"// - keep track of the selected ones (index within the selection list + index within the option list)",
"// - Once all the unselected items have been rendered, we render the selections",
"// This maps selection indices to option indices for the current group",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"currentSelectionIndices",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"option",
":",
"options",
")",
"{",
"if",
"(",
"option",
"instanceof",
"OptionGroup",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:optgroup\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"label\"",
",",
"(",
"(",
"OptionGroup",
")",
"option",
")",
".",
"getDesc",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Recurse to render options inside option groups.",
"List",
"<",
"?",
">",
"nestedOptions",
"=",
"(",
"(",
"OptionGroup",
")",
"option",
")",
".",
"getOptions",
"(",
")",
";",
"optionIndex",
"+=",
"renderOrderedOptions",
"(",
"multiSelectPair",
",",
"nestedOptions",
",",
"optionIndex",
",",
"xml",
",",
"renderSelectionsOnly",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:optgroup\"",
")",
";",
"}",
"else",
"{",
"int",
"index",
"=",
"selections",
".",
"indexOf",
"(",
"option",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"renderOption",
"(",
"multiSelectPair",
",",
"option",
",",
"optionIndex",
"++",
",",
"xml",
",",
"selections",
",",
"renderSelectionsOnly",
")",
";",
"}",
"else",
"{",
"currentSelectionIndices",
".",
"put",
"(",
"index",
",",
"optionIndex",
"++",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"currentSelectionIndices",
".",
"isEmpty",
"(",
")",
")",
"{",
"// Now sort the selected item's indices and render them in the correct order.",
"List",
"<",
"Integer",
">",
"sortedSelectedIndices",
"=",
"new",
"ArrayList",
"<>",
"(",
"currentSelectionIndices",
".",
"keySet",
"(",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"sortedSelectedIndices",
")",
";",
"for",
"(",
"int",
"selectionIndex",
":",
"sortedSelectedIndices",
")",
"{",
"int",
"selectionOptionIndex",
"=",
"currentSelectionIndices",
".",
"get",
"(",
"selectionIndex",
")",
";",
"renderOption",
"(",
"multiSelectPair",
",",
"selections",
".",
"get",
"(",
"selectionIndex",
")",
",",
"selectionOptionIndex",
",",
"xml",
",",
"selections",
",",
"renderSelectionsOnly",
")",
";",
"}",
"}",
"return",
"optionIndex",
"-",
"startIndex",
";",
"}"
] | Renders the options in selection order. Note, though, that this does not support the legacy allowNull or
setSelected using String representations.
@param multiSelectPair the WMultiSelectPair to paint.
@param options the options to render
@param startIndex the starting option index
@param xml the XmlStringBuilder to paint to.
@param renderSelectionsOnly true to only render selected options, false to render all options.
@return the number of options painted. | [
"Renders",
"the",
"options",
"in",
"selection",
"order",
".",
"Note",
"though",
"that",
"this",
"does",
"not",
"support",
"the",
"legacy",
"allowNull",
"or",
"setSelected",
"using",
"String",
"representations",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiSelectPairRenderer.java#L89-L145 |
139,554 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiSelectPairRenderer.java | WMultiSelectPairRenderer.renderUnorderedOptions | private int renderUnorderedOptions(final WMultiSelectPair multiSelectPair, final List<?> options,
final int startIndex,
final XmlStringBuilder xml, final boolean renderSelectionsOnly) {
List<?> selections = multiSelectPair.getSelected();
int optionIndex = startIndex;
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
// Recurse to render options inside option groups.
List<?> nestedOptions = ((OptionGroup) option).getOptions();
optionIndex += renderUnorderedOptions(multiSelectPair, nestedOptions, optionIndex,
xml, renderSelectionsOnly);
xml.appendEndTag("ui:optgroup");
} else {
renderOption(multiSelectPair, option, optionIndex++, xml, selections,
renderSelectionsOnly);
}
}
return optionIndex - startIndex;
} | java | private int renderUnorderedOptions(final WMultiSelectPair multiSelectPair, final List<?> options,
final int startIndex,
final XmlStringBuilder xml, final boolean renderSelectionsOnly) {
List<?> selections = multiSelectPair.getSelected();
int optionIndex = startIndex;
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
// Recurse to render options inside option groups.
List<?> nestedOptions = ((OptionGroup) option).getOptions();
optionIndex += renderUnorderedOptions(multiSelectPair, nestedOptions, optionIndex,
xml, renderSelectionsOnly);
xml.appendEndTag("ui:optgroup");
} else {
renderOption(multiSelectPair, option, optionIndex++, xml, selections,
renderSelectionsOnly);
}
}
return optionIndex - startIndex;
} | [
"private",
"int",
"renderUnorderedOptions",
"(",
"final",
"WMultiSelectPair",
"multiSelectPair",
",",
"final",
"List",
"<",
"?",
">",
"options",
",",
"final",
"int",
"startIndex",
",",
"final",
"XmlStringBuilder",
"xml",
",",
"final",
"boolean",
"renderSelectionsOnly",
")",
"{",
"List",
"<",
"?",
">",
"selections",
"=",
"multiSelectPair",
".",
"getSelected",
"(",
")",
";",
"int",
"optionIndex",
"=",
"startIndex",
";",
"for",
"(",
"Object",
"option",
":",
"options",
")",
"{",
"if",
"(",
"option",
"instanceof",
"OptionGroup",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:optgroup\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"label\"",
",",
"(",
"(",
"OptionGroup",
")",
"option",
")",
".",
"getDesc",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Recurse to render options inside option groups.",
"List",
"<",
"?",
">",
"nestedOptions",
"=",
"(",
"(",
"OptionGroup",
")",
"option",
")",
".",
"getOptions",
"(",
")",
";",
"optionIndex",
"+=",
"renderUnorderedOptions",
"(",
"multiSelectPair",
",",
"nestedOptions",
",",
"optionIndex",
",",
"xml",
",",
"renderSelectionsOnly",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:optgroup\"",
")",
";",
"}",
"else",
"{",
"renderOption",
"(",
"multiSelectPair",
",",
"option",
",",
"optionIndex",
"++",
",",
"xml",
",",
"selections",
",",
"renderSelectionsOnly",
")",
";",
"}",
"}",
"return",
"optionIndex",
"-",
"startIndex",
";",
"}"
] | Renders the options in list order.
@param multiSelectPair the WMultiSelectPair to paint.
@param options the options to render
@param startIndex the starting option index
@param xml the XmlStringBuilder to paint to.
@param renderSelectionsOnly true to only render selected options, false to render all options.
@return the number of options which were rendered. | [
"Renders",
"the",
"options",
"in",
"list",
"order",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiSelectPairRenderer.java#L158-L183 |
139,555 | podio/podio-java | src/main/java/com/podio/conversation/ConversationAPI.java | ConversationAPI.getConversationsOnObject | public List<Conversation> getConversationsOnObject(Reference object) {
return getResourceFactory().getApiResource(
"/conversation/" + object.toURLFragment()).get(
new GenericType<List<Conversation>>() {
});
} | java | public List<Conversation> getConversationsOnObject(Reference object) {
return getResourceFactory().getApiResource(
"/conversation/" + object.toURLFragment()).get(
new GenericType<List<Conversation>>() {
});
} | [
"public",
"List",
"<",
"Conversation",
">",
"getConversationsOnObject",
"(",
"Reference",
"object",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/conversation/\"",
"+",
"object",
".",
"toURLFragment",
"(",
")",
")",
".",
"get",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"Conversation",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Returns a list of all the conversations on the object that the active
user is part of.
@param object
The object to get conversations on
@return The list of conversations | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"conversations",
"on",
"the",
"object",
"that",
"the",
"active",
"user",
"is",
"part",
"of",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/conversation/ConversationAPI.java#L90-L95 |
139,556 | podio/podio-java | src/main/java/com/podio/conversation/ConversationAPI.java | ConversationAPI.addReply | public int addReply(int conversationId, String text) {
return getResourceFactory()
.getApiResource("/conversation/" + conversationId + "/reply")
.entity(new MessageCreate(text),
MediaType.APPLICATION_JSON_TYPE)
.get(MessageCreateResponse.class).getMessageId();
} | java | public int addReply(int conversationId, String text) {
return getResourceFactory()
.getApiResource("/conversation/" + conversationId + "/reply")
.entity(new MessageCreate(text),
MediaType.APPLICATION_JSON_TYPE)
.get(MessageCreateResponse.class).getMessageId();
} | [
"public",
"int",
"addReply",
"(",
"int",
"conversationId",
",",
"String",
"text",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/conversation/\"",
"+",
"conversationId",
"+",
"\"/reply\"",
")",
".",
"entity",
"(",
"new",
"MessageCreate",
"(",
"text",
")",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"get",
"(",
"MessageCreateResponse",
".",
"class",
")",
".",
"getMessageId",
"(",
")",
";",
"}"
] | Creates a reply to the conversation.
@param conversationId
The id of the conversation to reply to
@param text
The text of the reply
@return The id of the new message | [
"Creates",
"a",
"reply",
"to",
"the",
"conversation",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/conversation/ConversationAPI.java#L106-L112 |
139,557 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WApplicationRenderer.java | WApplicationRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WApplication application = (WApplication) component;
XmlStringBuilder xml = renderContext.getWriter();
UIContext uic = UIContextHolder.getCurrent();
String focusId = uic.getFocussedId();
// Check that this is the top level component
if (application.getParent() != null) {
LOG.warn("WApplication component should be the top level component.");
}
xml.appendTagOpen("ui:application");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendUrlAttribute("applicationUrl", uic.getEnvironment().getPostPath());
xml.appendUrlAttribute("ajaxUrl", uic.getEnvironment().getWServletPath());
xml.appendOptionalAttribute("unsavedChanges", application.hasUnsavedChanges(), "true");
xml.appendOptionalAttribute("title", application.getTitle());
xml.appendOptionalAttribute("defaultFocusId", uic.isFocusRequired() && !Util.empty(focusId),
focusId);
xml.appendOptionalUrlAttribute("icon", WApplication.getIcon());
xml.appendClose();
// Tracking enabled globally
if (TrackingUtil.isTrackingEnabled()) {
xml.appendTagOpen("ui:analytic");
xml.appendAttribute("clientId", TrackingUtil.getClientId());
xml.appendOptionalAttribute("cd", TrackingUtil.getCookieDomain());
xml.appendOptionalAttribute("dcd", TrackingUtil.getDataCollectionDomain());
xml.appendOptionalAttribute("name", TrackingUtil.getApplicationName());
xml.appendEnd();
}
// Hidden fields
Map<String, String> hiddenFields = uic.getEnvironment().getHiddenParameters();
if (hiddenFields != null) {
for (Map.Entry<String, String> entry : hiddenFields.entrySet()) {
xml.appendTagOpen("ui:param");
xml.appendAttribute("name", entry.getKey());
xml.appendAttribute("value", entry.getValue());
xml.appendEnd();
}
}
// Custom CSS Resources (if any)
for (WApplication.ApplicationResource resource : application.getCssResources()) {
String url = resource.getTargetUrl();
if (!Util.empty(url)) {
xml.appendTagOpen("ui:css");
xml.appendUrlAttribute("url", url);
xml.appendEnd();
}
}
// Custom JavaScript Resources (if any)
for (WApplication.ApplicationResource resource : application.getJsResources()) {
String url = resource.getTargetUrl();
if (!Util.empty(url)) {
xml.appendTagOpen("ui:js");
xml.appendUrlAttribute("url", url);
xml.appendEnd();
}
}
paintChildren(application, renderContext);
xml.appendEndTag("ui:application");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WApplication application = (WApplication) component;
XmlStringBuilder xml = renderContext.getWriter();
UIContext uic = UIContextHolder.getCurrent();
String focusId = uic.getFocussedId();
// Check that this is the top level component
if (application.getParent() != null) {
LOG.warn("WApplication component should be the top level component.");
}
xml.appendTagOpen("ui:application");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendUrlAttribute("applicationUrl", uic.getEnvironment().getPostPath());
xml.appendUrlAttribute("ajaxUrl", uic.getEnvironment().getWServletPath());
xml.appendOptionalAttribute("unsavedChanges", application.hasUnsavedChanges(), "true");
xml.appendOptionalAttribute("title", application.getTitle());
xml.appendOptionalAttribute("defaultFocusId", uic.isFocusRequired() && !Util.empty(focusId),
focusId);
xml.appendOptionalUrlAttribute("icon", WApplication.getIcon());
xml.appendClose();
// Tracking enabled globally
if (TrackingUtil.isTrackingEnabled()) {
xml.appendTagOpen("ui:analytic");
xml.appendAttribute("clientId", TrackingUtil.getClientId());
xml.appendOptionalAttribute("cd", TrackingUtil.getCookieDomain());
xml.appendOptionalAttribute("dcd", TrackingUtil.getDataCollectionDomain());
xml.appendOptionalAttribute("name", TrackingUtil.getApplicationName());
xml.appendEnd();
}
// Hidden fields
Map<String, String> hiddenFields = uic.getEnvironment().getHiddenParameters();
if (hiddenFields != null) {
for (Map.Entry<String, String> entry : hiddenFields.entrySet()) {
xml.appendTagOpen("ui:param");
xml.appendAttribute("name", entry.getKey());
xml.appendAttribute("value", entry.getValue());
xml.appendEnd();
}
}
// Custom CSS Resources (if any)
for (WApplication.ApplicationResource resource : application.getCssResources()) {
String url = resource.getTargetUrl();
if (!Util.empty(url)) {
xml.appendTagOpen("ui:css");
xml.appendUrlAttribute("url", url);
xml.appendEnd();
}
}
// Custom JavaScript Resources (if any)
for (WApplication.ApplicationResource resource : application.getJsResources()) {
String url = resource.getTargetUrl();
if (!Util.empty(url)) {
xml.appendTagOpen("ui:js");
xml.appendUrlAttribute("url", url);
xml.appendEnd();
}
}
paintChildren(application, renderContext);
xml.appendEndTag("ui:application");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WApplication",
"application",
"=",
"(",
"WApplication",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"UIContext",
"uic",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"String",
"focusId",
"=",
"uic",
".",
"getFocussedId",
"(",
")",
";",
"// Check that this is the top level component",
"if",
"(",
"application",
".",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"WApplication component should be the top level component.\"",
")",
";",
"}",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:application\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendUrlAttribute",
"(",
"\"applicationUrl\"",
",",
"uic",
".",
"getEnvironment",
"(",
")",
".",
"getPostPath",
"(",
")",
")",
";",
"xml",
".",
"appendUrlAttribute",
"(",
"\"ajaxUrl\"",
",",
"uic",
".",
"getEnvironment",
"(",
")",
".",
"getWServletPath",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"unsavedChanges\"",
",",
"application",
".",
"hasUnsavedChanges",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"title\"",
",",
"application",
".",
"getTitle",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"defaultFocusId\"",
",",
"uic",
".",
"isFocusRequired",
"(",
")",
"&&",
"!",
"Util",
".",
"empty",
"(",
"focusId",
")",
",",
"focusId",
")",
";",
"xml",
".",
"appendOptionalUrlAttribute",
"(",
"\"icon\"",
",",
"WApplication",
".",
"getIcon",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Tracking enabled globally",
"if",
"(",
"TrackingUtil",
".",
"isTrackingEnabled",
"(",
")",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:analytic\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"clientId\"",
",",
"TrackingUtil",
".",
"getClientId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"cd\"",
",",
"TrackingUtil",
".",
"getCookieDomain",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"dcd\"",
",",
"TrackingUtil",
".",
"getDataCollectionDomain",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"name\"",
",",
"TrackingUtil",
".",
"getApplicationName",
"(",
")",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"// Hidden fields",
"Map",
"<",
"String",
",",
"String",
">",
"hiddenFields",
"=",
"uic",
".",
"getEnvironment",
"(",
")",
".",
"getHiddenParameters",
"(",
")",
";",
"if",
"(",
"hiddenFields",
"!=",
"null",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"hiddenFields",
".",
"entrySet",
"(",
")",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:param\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"name\"",
",",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"value\"",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"}",
"// Custom CSS Resources (if any)",
"for",
"(",
"WApplication",
".",
"ApplicationResource",
"resource",
":",
"application",
".",
"getCssResources",
"(",
")",
")",
"{",
"String",
"url",
"=",
"resource",
".",
"getTargetUrl",
"(",
")",
";",
"if",
"(",
"!",
"Util",
".",
"empty",
"(",
"url",
")",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:css\"",
")",
";",
"xml",
".",
"appendUrlAttribute",
"(",
"\"url\"",
",",
"url",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"}",
"// Custom JavaScript Resources (if any)",
"for",
"(",
"WApplication",
".",
"ApplicationResource",
"resource",
":",
"application",
".",
"getJsResources",
"(",
")",
")",
"{",
"String",
"url",
"=",
"resource",
".",
"getTargetUrl",
"(",
")",
";",
"if",
"(",
"!",
"Util",
".",
"empty",
"(",
"url",
")",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:js\"",
")",
";",
"xml",
".",
"appendUrlAttribute",
"(",
"\"url\"",
",",
"url",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"}",
"paintChildren",
"(",
"application",
",",
"renderContext",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:application\"",
")",
";",
"}"
] | Paints the given WApplication.
@param component the WApplication to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WApplication",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WApplicationRenderer.java#L35-L104 |
139,558 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WShufflerExample.java | WShufflerExample.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
StringBuffer text = new StringBuffer("Options: ");
for (Object option : shuffler.getOptions()) {
text.append(option).append(", ");
}
order.setText(text.toString());
} | java | @Override
protected void preparePaintComponent(final Request request) {
StringBuffer text = new StringBuffer("Options: ");
for (Object option : shuffler.getOptions()) {
text.append(option).append(", ");
}
order.setText(text.toString());
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"StringBuffer",
"text",
"=",
"new",
"StringBuffer",
"(",
"\"Options: \"",
")",
";",
"for",
"(",
"Object",
"option",
":",
"shuffler",
".",
"getOptions",
"(",
")",
")",
"{",
"text",
".",
"append",
"(",
"option",
")",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"order",
".",
"setText",
"(",
"text",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Concatenate the options to display in the text field.
@param request the current request being processed | [
"Concatenate",
"the",
"options",
"to",
"display",
"in",
"the",
"text",
"field",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WShufflerExample.java#L71-L80 |
139,559 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiTextFieldRenderer.java | WMultiTextFieldRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiTextField textField = (WMultiTextField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = textField.isReadOnly();
String[] values = textField.getTextInputs();
xml.appendTagOpen("ui:multitextfield");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", textField.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int cols = textField.getColumns();
int minLength = textField.getMinLength();
int maxLength = textField.getMaxLength();
int maxInputs = textField.getMaxInputs();
String pattern = textField.getPattern();
xml.appendOptionalAttribute("disabled", textField.isDisabled(), "true");
xml.appendOptionalAttribute("required", textField.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", textField.getToolTip());
xml.appendOptionalAttribute("accessibleText", textField.getAccessibleText());
xml.appendOptionalAttribute("size", cols > 0, cols);
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("max", maxInputs > 0, maxInputs);
xml.appendOptionalAttribute("pattern", !Util.empty(pattern), pattern);
// NOTE: do not use HtmlRenderUtil.getEffectivePlaceholder for placeholder - we do not want to echo "required" in every field.
String placeholder = textField.getPlaceholder();
xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder);
xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTITEXTFIELD_TIP));
}
xml.appendClose();
if (values != null) {
for (String value : values) {
xml.appendTag("ui:value");
xml.appendEscaped(value);
xml.appendEndTag("ui:value");
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(textField, renderContext);
}
xml.appendEndTag("ui:multitextfield");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiTextField textField = (WMultiTextField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = textField.isReadOnly();
String[] values = textField.getTextInputs();
xml.appendTagOpen("ui:multitextfield");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", textField.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int cols = textField.getColumns();
int minLength = textField.getMinLength();
int maxLength = textField.getMaxLength();
int maxInputs = textField.getMaxInputs();
String pattern = textField.getPattern();
xml.appendOptionalAttribute("disabled", textField.isDisabled(), "true");
xml.appendOptionalAttribute("required", textField.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", textField.getToolTip());
xml.appendOptionalAttribute("accessibleText", textField.getAccessibleText());
xml.appendOptionalAttribute("size", cols > 0, cols);
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("max", maxInputs > 0, maxInputs);
xml.appendOptionalAttribute("pattern", !Util.empty(pattern), pattern);
// NOTE: do not use HtmlRenderUtil.getEffectivePlaceholder for placeholder - we do not want to echo "required" in every field.
String placeholder = textField.getPlaceholder();
xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder);
xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTITEXTFIELD_TIP));
}
xml.appendClose();
if (values != null) {
for (String value : values) {
xml.appendTag("ui:value");
xml.appendEscaped(value);
xml.appendEndTag("ui:value");
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(textField, renderContext);
}
xml.appendEndTag("ui:multitextfield");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WMultiTextField",
"textField",
"=",
"(",
"WMultiTextField",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"readOnly",
"=",
"textField",
".",
"isReadOnly",
"(",
")",
";",
"String",
"[",
"]",
"values",
"=",
"textField",
".",
"getTextInputs",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:multitextfield\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"textField",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"readOnly",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"readOnly\"",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"int",
"cols",
"=",
"textField",
".",
"getColumns",
"(",
")",
";",
"int",
"minLength",
"=",
"textField",
".",
"getMinLength",
"(",
")",
";",
"int",
"maxLength",
"=",
"textField",
".",
"getMaxLength",
"(",
")",
";",
"int",
"maxInputs",
"=",
"textField",
".",
"getMaxInputs",
"(",
")",
";",
"String",
"pattern",
"=",
"textField",
".",
"getPattern",
"(",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"textField",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"required\"",
",",
"textField",
".",
"isMandatory",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"toolTip\"",
",",
"textField",
".",
"getToolTip",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"accessibleText\"",
",",
"textField",
".",
"getAccessibleText",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"size\"",
",",
"cols",
">",
"0",
",",
"cols",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"minLength\"",
",",
"minLength",
">",
"0",
",",
"minLength",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"maxLength\"",
",",
"maxLength",
">",
"0",
",",
"maxLength",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"max\"",
",",
"maxInputs",
">",
"0",
",",
"maxInputs",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"pattern\"",
",",
"!",
"Util",
".",
"empty",
"(",
"pattern",
")",
",",
"pattern",
")",
";",
"// NOTE: do not use HtmlRenderUtil.getEffectivePlaceholder for placeholder - we do not want to echo \"required\" in every field.",
"String",
"placeholder",
"=",
"textField",
".",
"getPlaceholder",
"(",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"placeholder\"",
",",
"!",
"Util",
".",
"empty",
"(",
"placeholder",
")",
",",
"placeholder",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"title\"",
",",
"I18nUtilities",
".",
"format",
"(",
"null",
",",
"InternalMessages",
".",
"DEFAULT_MULTITEXTFIELD_TIP",
")",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"if",
"(",
"values",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"value",
":",
"values",
")",
"{",
"xml",
".",
"appendTag",
"(",
"\"ui:value\"",
")",
";",
"xml",
".",
"appendEscaped",
"(",
"value",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:value\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"readOnly",
")",
"{",
"DiagnosticRenderUtil",
".",
"renderDiagnostics",
"(",
"textField",
",",
"renderContext",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:multitextfield\"",
")",
";",
"}"
] | Paints the given WMultiTextField.
@param component the WMultiTextField to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WMultiTextField",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WMultiTextFieldRenderer.java#L27-L78 |
139,560 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WTextExample.java | WTextExample.fakeServiceCall | private static ExampleBean fakeServiceCall(final String text) {
ExampleBean exampleBean = new ExampleBean();
exampleBean.setBeanAttribute("(beanAttribute) " + text);
ExampleBean.DummyInnerBean dummyInnerBean = new ExampleBean.DummyInnerBean();
dummyInnerBean.setInnerAttribute("(innerBean.innerAttribute) " + text);
exampleBean.setInnerBean(dummyInnerBean);
return exampleBean;
} | java | private static ExampleBean fakeServiceCall(final String text) {
ExampleBean exampleBean = new ExampleBean();
exampleBean.setBeanAttribute("(beanAttribute) " + text);
ExampleBean.DummyInnerBean dummyInnerBean = new ExampleBean.DummyInnerBean();
dummyInnerBean.setInnerAttribute("(innerBean.innerAttribute) " + text);
exampleBean.setInnerBean(dummyInnerBean);
return exampleBean;
} | [
"private",
"static",
"ExampleBean",
"fakeServiceCall",
"(",
"final",
"String",
"text",
")",
"{",
"ExampleBean",
"exampleBean",
"=",
"new",
"ExampleBean",
"(",
")",
";",
"exampleBean",
".",
"setBeanAttribute",
"(",
"\"(beanAttribute) \"",
"+",
"text",
")",
";",
"ExampleBean",
".",
"DummyInnerBean",
"dummyInnerBean",
"=",
"new",
"ExampleBean",
".",
"DummyInnerBean",
"(",
")",
";",
"dummyInnerBean",
".",
"setInnerAttribute",
"(",
"\"(innerBean.innerAttribute) \"",
"+",
"text",
")",
";",
"exampleBean",
".",
"setInnerBean",
"(",
"dummyInnerBean",
")",
";",
"return",
"exampleBean",
";",
"}"
] | Fakes a service call and just returns dummy data.
@param text the text to insert in the dummy data.
@return a ExampleBean containing the specified text. | [
"Fakes",
"a",
"service",
"call",
"and",
"just",
"returns",
"dummy",
"data",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WTextExample.java#L124-L133 |
139,561 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.processRequest | public static void processRequest(final HttpServletHelper helper, final WComponent ui,
final InterceptorComponent interceptorChain) throws ServletException, IOException {
try {
// Tell the support container about the top most web component
// that will service the request/response.
if (interceptorChain == null) {
helper.setWebComponent(ui);
} else {
interceptorChain.attachUI(ui);
helper.setWebComponent(interceptorChain);
}
// Prepare user context
UIContext uic = helper.prepareUserContext();
synchronized (uic) {
// Process the action phase.
helper.processAction();
// Process the render phase.
helper.render();
}
} finally {
// We need to ensure that the AJAX operation is cleared
// The interceptors can not guarantee this
// TODO: Investigate changing to not use a thread-local
AjaxHelper.clearCurrentOperationDetails();
}
} | java | public static void processRequest(final HttpServletHelper helper, final WComponent ui,
final InterceptorComponent interceptorChain) throws ServletException, IOException {
try {
// Tell the support container about the top most web component
// that will service the request/response.
if (interceptorChain == null) {
helper.setWebComponent(ui);
} else {
interceptorChain.attachUI(ui);
helper.setWebComponent(interceptorChain);
}
// Prepare user context
UIContext uic = helper.prepareUserContext();
synchronized (uic) {
// Process the action phase.
helper.processAction();
// Process the render phase.
helper.render();
}
} finally {
// We need to ensure that the AJAX operation is cleared
// The interceptors can not guarantee this
// TODO: Investigate changing to not use a thread-local
AjaxHelper.clearCurrentOperationDetails();
}
} | [
"public",
"static",
"void",
"processRequest",
"(",
"final",
"HttpServletHelper",
"helper",
",",
"final",
"WComponent",
"ui",
",",
"final",
"InterceptorComponent",
"interceptorChain",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"try",
"{",
"// Tell the support container about the top most web component",
"// that will service the request/response.",
"if",
"(",
"interceptorChain",
"==",
"null",
")",
"{",
"helper",
".",
"setWebComponent",
"(",
"ui",
")",
";",
"}",
"else",
"{",
"interceptorChain",
".",
"attachUI",
"(",
"ui",
")",
";",
"helper",
".",
"setWebComponent",
"(",
"interceptorChain",
")",
";",
"}",
"// Prepare user context",
"UIContext",
"uic",
"=",
"helper",
".",
"prepareUserContext",
"(",
")",
";",
"synchronized",
"(",
"uic",
")",
"{",
"// Process the action phase.",
"helper",
".",
"processAction",
"(",
")",
";",
"// Process the render phase.",
"helper",
".",
"render",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"// We need to ensure that the AJAX operation is cleared",
"// The interceptors can not guarantee this",
"// TODO: Investigate changing to not use a thread-local",
"AjaxHelper",
".",
"clearCurrentOperationDetails",
"(",
")",
";",
"}",
"}"
] | This method does the real work in servicing the http request. It integrates wcomponents into a servlet
environment via a servlet specific helper class.
@param helper the servlet helper
@param ui the application ui
@param interceptorChain the chain of interceptors
@throws ServletException a servlet exception
@throws IOException an IO Exception | [
"This",
"method",
"does",
"the",
"real",
"work",
"in",
"servicing",
"the",
"http",
"request",
".",
"It",
"integrates",
"wcomponents",
"into",
"a",
"servlet",
"environment",
"via",
"a",
"servlet",
"specific",
"helper",
"class",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L173-L202 |
139,562 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.handleStaticResourceRequest | public static void handleStaticResourceRequest(final HttpServletRequest request,
final HttpServletResponse response) {
String staticRequest = request.getParameter(WServlet.STATIC_RESOURCE_PARAM_NAME);
try {
InternalResource staticResource = InternalResourceMap.getResource(staticRequest);
boolean headersOnly = "HEAD".equals(request.getMethod());
if (staticResource == null) {
LOG.warn("Static resource [" + staticRequest + "] not found.");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
InputStream resourceStream = staticResource.getStream();
if (resourceStream == null) {
LOG.warn(
"Static resource [" + staticRequest + "] not found. Stream for content is null.");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
int size = resourceStream.available();
String fileName = WebUtilities.encodeForContentDispositionHeader(staticRequest.
substring(staticRequest
.lastIndexOf('/') + 1));
if (size > 0) {
response.setContentLength(size);
}
response.setContentType(WebUtilities.getContentType(staticRequest));
response.setHeader("Cache-Control", CacheType.CONTENT_CACHE.getSettings());
String param = request.getParameter(WContent.URL_CONTENT_MODE_PARAMETER_KEY);
if ("inline".equals(param)) {
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
} else if ("attach".equals(param)) {
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
} else {
// added "filename=" to comply with https://tools.ietf.org/html/rfc6266
response.setHeader("Content-Disposition", "filename=" + fileName);
}
if (!headersOnly) {
StreamUtil.copy(resourceStream, response.getOutputStream());
}
} catch (IOException e) {
LOG.warn("Could not process static resource [" + staticRequest + "]. ", e);
response.reset();
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} | java | public static void handleStaticResourceRequest(final HttpServletRequest request,
final HttpServletResponse response) {
String staticRequest = request.getParameter(WServlet.STATIC_RESOURCE_PARAM_NAME);
try {
InternalResource staticResource = InternalResourceMap.getResource(staticRequest);
boolean headersOnly = "HEAD".equals(request.getMethod());
if (staticResource == null) {
LOG.warn("Static resource [" + staticRequest + "] not found.");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
InputStream resourceStream = staticResource.getStream();
if (resourceStream == null) {
LOG.warn(
"Static resource [" + staticRequest + "] not found. Stream for content is null.");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
int size = resourceStream.available();
String fileName = WebUtilities.encodeForContentDispositionHeader(staticRequest.
substring(staticRequest
.lastIndexOf('/') + 1));
if (size > 0) {
response.setContentLength(size);
}
response.setContentType(WebUtilities.getContentType(staticRequest));
response.setHeader("Cache-Control", CacheType.CONTENT_CACHE.getSettings());
String param = request.getParameter(WContent.URL_CONTENT_MODE_PARAMETER_KEY);
if ("inline".equals(param)) {
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
} else if ("attach".equals(param)) {
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
} else {
// added "filename=" to comply with https://tools.ietf.org/html/rfc6266
response.setHeader("Content-Disposition", "filename=" + fileName);
}
if (!headersOnly) {
StreamUtil.copy(resourceStream, response.getOutputStream());
}
} catch (IOException e) {
LOG.warn("Could not process static resource [" + staticRequest + "]. ", e);
response.reset();
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} | [
"public",
"static",
"void",
"handleStaticResourceRequest",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
")",
"{",
"String",
"staticRequest",
"=",
"request",
".",
"getParameter",
"(",
"WServlet",
".",
"STATIC_RESOURCE_PARAM_NAME",
")",
";",
"try",
"{",
"InternalResource",
"staticResource",
"=",
"InternalResourceMap",
".",
"getResource",
"(",
"staticRequest",
")",
";",
"boolean",
"headersOnly",
"=",
"\"HEAD\"",
".",
"equals",
"(",
"request",
".",
"getMethod",
"(",
")",
")",
";",
"if",
"(",
"staticResource",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Static resource [\"",
"+",
"staticRequest",
"+",
"\"] not found.\"",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_FOUND",
")",
";",
"return",
";",
"}",
"InputStream",
"resourceStream",
"=",
"staticResource",
".",
"getStream",
"(",
")",
";",
"if",
"(",
"resourceStream",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Static resource [\"",
"+",
"staticRequest",
"+",
"\"] not found. Stream for content is null.\"",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_FOUND",
")",
";",
"return",
";",
"}",
"int",
"size",
"=",
"resourceStream",
".",
"available",
"(",
")",
";",
"String",
"fileName",
"=",
"WebUtilities",
".",
"encodeForContentDispositionHeader",
"(",
"staticRequest",
".",
"substring",
"(",
"staticRequest",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
")",
";",
"if",
"(",
"size",
">",
"0",
")",
"{",
"response",
".",
"setContentLength",
"(",
"size",
")",
";",
"}",
"response",
".",
"setContentType",
"(",
"WebUtilities",
".",
"getContentType",
"(",
"staticRequest",
")",
")",
";",
"response",
".",
"setHeader",
"(",
"\"Cache-Control\"",
",",
"CacheType",
".",
"CONTENT_CACHE",
".",
"getSettings",
"(",
")",
")",
";",
"String",
"param",
"=",
"request",
".",
"getParameter",
"(",
"WContent",
".",
"URL_CONTENT_MODE_PARAMETER_KEY",
")",
";",
"if",
"(",
"\"inline\"",
".",
"equals",
"(",
"param",
")",
")",
"{",
"response",
".",
"setHeader",
"(",
"\"Content-Disposition\"",
",",
"\"inline; filename=\"",
"+",
"fileName",
")",
";",
"}",
"else",
"if",
"(",
"\"attach\"",
".",
"equals",
"(",
"param",
")",
")",
"{",
"response",
".",
"setHeader",
"(",
"\"Content-Disposition\"",
",",
"\"attachment; filename=\"",
"+",
"fileName",
")",
";",
"}",
"else",
"{",
"// added \"filename=\" to comply with https://tools.ietf.org/html/rfc6266",
"response",
".",
"setHeader",
"(",
"\"Content-Disposition\"",
",",
"\"filename=\"",
"+",
"fileName",
")",
";",
"}",
"if",
"(",
"!",
"headersOnly",
")",
"{",
"StreamUtil",
".",
"copy",
"(",
"resourceStream",
",",
"response",
".",
"getOutputStream",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Could not process static resource [\"",
"+",
"staticRequest",
"+",
"\"]. \"",
",",
"e",
")",
";",
"response",
".",
"reset",
"(",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_FOUND",
")",
";",
"}",
"}"
] | Handles a request for static resources.
@param request the http request.
@param response the http response. | [
"Handles",
"a",
"request",
"for",
"static",
"resources",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L218-L270 |
139,563 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.handleThemeResourceRequest | public static void handleThemeResourceRequest(final HttpServletRequest req,
final HttpServletResponse resp)
throws ServletException, IOException {
if (req.getHeader("If-Modified-Since") != null) {
resp.reset();
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
String fileName = req.getParameter("f");
String path = req.getPathInfo();
if (fileName == null && !Util.empty(path)) {
int offset = path.startsWith(THEME_RESOURCE_PATH_PARAM) ? THEME_RESOURCE_PATH_PARAM.
length() : 1;
fileName = path.substring(offset);
}
if (fileName == null || !checkThemeFile(fileName)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
InputStream resourceStream = null;
try {
URL url = null;
// Check for project translation file
if (fileName.startsWith(THEME_TRANSLATION_RESOURCE_PREFIX)) {
String resourceFileName = fileName.substring(THEME_TRANSLATION_RESOURCE_PREFIX.length());
url = ServletUtil.class.getResource(THEME_PROJECT_TRANSLATION_RESOURCE_PATH + resourceFileName);
}
// Load from the theme path
if (url == null) {
String resourceName = ThemeUtil.getThemeBase() + fileName;
url = ServletUtil.class.getResource(resourceName);
}
if (url == null) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
} else {
URLConnection connection = url.openConnection();
resourceStream = connection.getInputStream();
int size = resourceStream.available();
if (size > 0) {
resp.setContentLength(size);
}
/*
I have commented out the setting of the Content-Disposition on static theme resources because, well why is it there?
If this needs to be reinstated please provide a thorough justification comment here so the reasons are clear.
Note that setting this header breaks Polymer 1.0 when it is present on HTML imports.
String encodedName = WebUtilities.encodeForContentDispositionHeader(fileName.
substring(fileName
.lastIndexOf('/') + 1));
resp.setHeader("Content-Disposition", "filename=" + encodedName); // "filename=" to comply with https://tools.ietf.org/html/rfc6266
*/
resp.setContentType(WebUtilities.getContentType(fileName));
resp.setHeader("Cache-Control", CacheType.THEME_CACHE.getSettings());
resp.setHeader("Expires", "31536000");
resp.setHeader("ETag", "\"" + WebUtilities.getProjectVersion() + "\"");
// resp.setHeader("Last-Modified", "Mon, 02 Jan 2015 01:00:00 GMT");
long modified = connection.getLastModified();
resp.setDateHeader("Last-Modified", modified);
StreamUtil.copy(resourceStream, resp.getOutputStream());
}
} finally {
StreamUtil.safeClose(resourceStream);
}
} | java | public static void handleThemeResourceRequest(final HttpServletRequest req,
final HttpServletResponse resp)
throws ServletException, IOException {
if (req.getHeader("If-Modified-Since") != null) {
resp.reset();
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
String fileName = req.getParameter("f");
String path = req.getPathInfo();
if (fileName == null && !Util.empty(path)) {
int offset = path.startsWith(THEME_RESOURCE_PATH_PARAM) ? THEME_RESOURCE_PATH_PARAM.
length() : 1;
fileName = path.substring(offset);
}
if (fileName == null || !checkThemeFile(fileName)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
InputStream resourceStream = null;
try {
URL url = null;
// Check for project translation file
if (fileName.startsWith(THEME_TRANSLATION_RESOURCE_PREFIX)) {
String resourceFileName = fileName.substring(THEME_TRANSLATION_RESOURCE_PREFIX.length());
url = ServletUtil.class.getResource(THEME_PROJECT_TRANSLATION_RESOURCE_PATH + resourceFileName);
}
// Load from the theme path
if (url == null) {
String resourceName = ThemeUtil.getThemeBase() + fileName;
url = ServletUtil.class.getResource(resourceName);
}
if (url == null) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
} else {
URLConnection connection = url.openConnection();
resourceStream = connection.getInputStream();
int size = resourceStream.available();
if (size > 0) {
resp.setContentLength(size);
}
/*
I have commented out the setting of the Content-Disposition on static theme resources because, well why is it there?
If this needs to be reinstated please provide a thorough justification comment here so the reasons are clear.
Note that setting this header breaks Polymer 1.0 when it is present on HTML imports.
String encodedName = WebUtilities.encodeForContentDispositionHeader(fileName.
substring(fileName
.lastIndexOf('/') + 1));
resp.setHeader("Content-Disposition", "filename=" + encodedName); // "filename=" to comply with https://tools.ietf.org/html/rfc6266
*/
resp.setContentType(WebUtilities.getContentType(fileName));
resp.setHeader("Cache-Control", CacheType.THEME_CACHE.getSettings());
resp.setHeader("Expires", "31536000");
resp.setHeader("ETag", "\"" + WebUtilities.getProjectVersion() + "\"");
// resp.setHeader("Last-Modified", "Mon, 02 Jan 2015 01:00:00 GMT");
long modified = connection.getLastModified();
resp.setDateHeader("Last-Modified", modified);
StreamUtil.copy(resourceStream, resp.getOutputStream());
}
} finally {
StreamUtil.safeClose(resourceStream);
}
} | [
"public",
"static",
"void",
"handleThemeResourceRequest",
"(",
"final",
"HttpServletRequest",
"req",
",",
"final",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"if",
"(",
"req",
".",
"getHeader",
"(",
"\"If-Modified-Since\"",
")",
"!=",
"null",
")",
"{",
"resp",
".",
"reset",
"(",
")",
";",
"resp",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_MODIFIED",
")",
";",
"return",
";",
"}",
"String",
"fileName",
"=",
"req",
".",
"getParameter",
"(",
"\"f\"",
")",
";",
"String",
"path",
"=",
"req",
".",
"getPathInfo",
"(",
")",
";",
"if",
"(",
"fileName",
"==",
"null",
"&&",
"!",
"Util",
".",
"empty",
"(",
"path",
")",
")",
"{",
"int",
"offset",
"=",
"path",
".",
"startsWith",
"(",
"THEME_RESOURCE_PATH_PARAM",
")",
"?",
"THEME_RESOURCE_PATH_PARAM",
".",
"length",
"(",
")",
":",
"1",
";",
"fileName",
"=",
"path",
".",
"substring",
"(",
"offset",
")",
";",
"}",
"if",
"(",
"fileName",
"==",
"null",
"||",
"!",
"checkThemeFile",
"(",
"fileName",
")",
")",
"{",
"resp",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_FOUND",
")",
";",
"return",
";",
"}",
"InputStream",
"resourceStream",
"=",
"null",
";",
"try",
"{",
"URL",
"url",
"=",
"null",
";",
"// Check for project translation file",
"if",
"(",
"fileName",
".",
"startsWith",
"(",
"THEME_TRANSLATION_RESOURCE_PREFIX",
")",
")",
"{",
"String",
"resourceFileName",
"=",
"fileName",
".",
"substring",
"(",
"THEME_TRANSLATION_RESOURCE_PREFIX",
".",
"length",
"(",
")",
")",
";",
"url",
"=",
"ServletUtil",
".",
"class",
".",
"getResource",
"(",
"THEME_PROJECT_TRANSLATION_RESOURCE_PATH",
"+",
"resourceFileName",
")",
";",
"}",
"// Load from the theme path",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"String",
"resourceName",
"=",
"ThemeUtil",
".",
"getThemeBase",
"(",
")",
"+",
"fileName",
";",
"url",
"=",
"ServletUtil",
".",
"class",
".",
"getResource",
"(",
"resourceName",
")",
";",
"}",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"resp",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_FOUND",
")",
";",
"}",
"else",
"{",
"URLConnection",
"connection",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"resourceStream",
"=",
"connection",
".",
"getInputStream",
"(",
")",
";",
"int",
"size",
"=",
"resourceStream",
".",
"available",
"(",
")",
";",
"if",
"(",
"size",
">",
"0",
")",
"{",
"resp",
".",
"setContentLength",
"(",
"size",
")",
";",
"}",
"/*\n\t\t\t\tI have commented out the setting of the Content-Disposition on static theme resources because, well why is it there?\n\t\t\t\tIf this needs to be reinstated please provide a thorough justification comment here so the reasons are clear.\n\n\t\t\t\tNote that setting this header breaks Polymer 1.0 when it is present on HTML imports.\n\n\t\t\t\tString encodedName = WebUtilities.encodeForContentDispositionHeader(fileName.\n\t\t\t\t\t\tsubstring(fileName\n\t\t\t\t\t\t\t\t.lastIndexOf('/') + 1));\n\t\t\t\tresp.setHeader(\"Content-Disposition\", \"filename=\" + encodedName); // \"filename=\" to comply with https://tools.ietf.org/html/rfc6266\n\t\t\t\t */",
"resp",
".",
"setContentType",
"(",
"WebUtilities",
".",
"getContentType",
"(",
"fileName",
")",
")",
";",
"resp",
".",
"setHeader",
"(",
"\"Cache-Control\"",
",",
"CacheType",
".",
"THEME_CACHE",
".",
"getSettings",
"(",
")",
")",
";",
"resp",
".",
"setHeader",
"(",
"\"Expires\"",
",",
"\"31536000\"",
")",
";",
"resp",
".",
"setHeader",
"(",
"\"ETag\"",
",",
"\"\\\"\"",
"+",
"WebUtilities",
".",
"getProjectVersion",
"(",
")",
"+",
"\"\\\"\"",
")",
";",
"// resp.setHeader(\"Last-Modified\", \"Mon, 02 Jan 2015 01:00:00 GMT\");",
"long",
"modified",
"=",
"connection",
".",
"getLastModified",
"(",
")",
";",
"resp",
".",
"setDateHeader",
"(",
"\"Last-Modified\"",
",",
"modified",
")",
";",
"StreamUtil",
".",
"copy",
"(",
"resourceStream",
",",
"resp",
".",
"getOutputStream",
"(",
")",
")",
";",
"}",
"}",
"finally",
"{",
"StreamUtil",
".",
"safeClose",
"(",
"resourceStream",
")",
";",
"}",
"}"
] | Serves up a file from the theme. In practice it is generally a bad idea to use this servlet to serve up static
resources. Instead it would make more sense to move CSS, JS, HTML resources to a CDN or similar.
@param req the request with the file name in parameter "f", or following the servlet path.
@param resp the response to write to.
@throws ServletException on error.
@throws IOException if there is an error reading the file / writing the response. | [
"Serves",
"up",
"a",
"file",
"from",
"the",
"theme",
".",
"In",
"practice",
"it",
"is",
"generally",
"a",
"bad",
"idea",
"to",
"use",
"this",
"servlet",
"to",
"serve",
"up",
"static",
"resources",
".",
"Instead",
"it",
"would",
"make",
"more",
"sense",
"to",
"move",
"CSS",
"JS",
"HTML",
"resources",
"to",
"a",
"CDN",
"or",
"similar",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L291-L366 |
139,564 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.checkThemeFile | private static boolean checkThemeFile(final String name) {
return !(Util.empty(name) // name must exist
|| name.contains("..") // prevent directory traversal
|| name.charAt(0) == '/' // all theme references should be relative
|| name.indexOf(':') != -1 // forbid use of protocols such as jar:, http: etc.
);
} | java | private static boolean checkThemeFile(final String name) {
return !(Util.empty(name) // name must exist
|| name.contains("..") // prevent directory traversal
|| name.charAt(0) == '/' // all theme references should be relative
|| name.indexOf(':') != -1 // forbid use of protocols such as jar:, http: etc.
);
} | [
"private",
"static",
"boolean",
"checkThemeFile",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"!",
"(",
"Util",
".",
"empty",
"(",
"name",
")",
"// name must exist",
"||",
"name",
".",
"contains",
"(",
"\"..\"",
")",
"// prevent directory traversal",
"||",
"name",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
"// all theme references should be relative",
"||",
"name",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
"// forbid use of protocols such as jar:, http: etc.",
")",
";",
"}"
] | Performs basic sanity checks on the file being requested.
@param name the file name
@return true if the requested file name is ok, false if not. | [
"Performs",
"basic",
"sanity",
"checks",
"on",
"the",
"file",
"being",
"requested",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L374-L380 |
139,565 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.createInterceptorChain | public static InterceptorComponent createInterceptorChain(final HttpServletRequest request) {
// Allow for multi part parameters
Map<String, String[]> parameters = getRequestParameters(request);
InterceptorComponent[] chain;
if (parameters.get(WServlet.DATA_LIST_PARAM_NAME) != null) { // Datalist
chain = new InterceptorComponent[]{
new TransformXMLInterceptor(),
new DataListInterceptor()};
} else if (parameters.get(WServlet.AJAX_TRIGGER_PARAM_NAME) != null) { // AJAX
chain = new InterceptorComponent[]{
new TemplateRenderInterceptor(),
new TransformXMLInterceptor(),
new ValidateXMLInterceptor(),
new AjaxErrorInterceptor(),
new SessionTokenAjaxInterceptor(),
new ResponseCacheInterceptor(CacheType.NO_CACHE),
new UIContextDumpInterceptor(),
new AjaxSetupInterceptor(),
new WWindowInterceptor(true),
new WrongStepAjaxInterceptor(),
new ContextCleanupInterceptor(),
new WhitespaceFilterInterceptor(),
new SubordinateControlInterceptor(),
new AjaxPageShellInterceptor(),
new AjaxDebugStructureInterceptor(),
new AjaxInterceptor()};
} else if (parameters.get(WServlet.TARGET_ID_PARAM_NAME) != null) { // Targetted Content
chain = new InterceptorComponent[]{
new TargetableErrorInterceptor(),
new SessionTokenContentInterceptor(),
new UIContextDumpInterceptor(),
new TargetableInterceptor(),
new WWindowInterceptor(false),
new WrongStepContentInterceptor()};
} else {
chain = new InterceptorComponent[]{ // Page submit
new TemplateRenderInterceptor(),
new TransformXMLInterceptor(),
new ValidateXMLInterceptor(),
new SessionTokenInterceptor(),
new ResponseCacheInterceptor(CacheType.NO_CACHE),
new UIContextDumpInterceptor(),
new WWindowInterceptor(true),
new WrongStepServerInterceptor(),
new AjaxCleanupInterceptor(),
new ContextCleanupInterceptor(),
new WhitespaceFilterInterceptor(),
new SubordinateControlInterceptor(),
new PageShellInterceptor(),
new FormInterceptor(),
new DebugStructureInterceptor()};
}
// Link the interceptors together in a chain.
for (int i = 0; i < chain.length - 1; i++) {
chain[i].setBackingComponent(chain[i + 1]);
}
// Return the top of the chain.
return chain[0];
} | java | public static InterceptorComponent createInterceptorChain(final HttpServletRequest request) {
// Allow for multi part parameters
Map<String, String[]> parameters = getRequestParameters(request);
InterceptorComponent[] chain;
if (parameters.get(WServlet.DATA_LIST_PARAM_NAME) != null) { // Datalist
chain = new InterceptorComponent[]{
new TransformXMLInterceptor(),
new DataListInterceptor()};
} else if (parameters.get(WServlet.AJAX_TRIGGER_PARAM_NAME) != null) { // AJAX
chain = new InterceptorComponent[]{
new TemplateRenderInterceptor(),
new TransformXMLInterceptor(),
new ValidateXMLInterceptor(),
new AjaxErrorInterceptor(),
new SessionTokenAjaxInterceptor(),
new ResponseCacheInterceptor(CacheType.NO_CACHE),
new UIContextDumpInterceptor(),
new AjaxSetupInterceptor(),
new WWindowInterceptor(true),
new WrongStepAjaxInterceptor(),
new ContextCleanupInterceptor(),
new WhitespaceFilterInterceptor(),
new SubordinateControlInterceptor(),
new AjaxPageShellInterceptor(),
new AjaxDebugStructureInterceptor(),
new AjaxInterceptor()};
} else if (parameters.get(WServlet.TARGET_ID_PARAM_NAME) != null) { // Targetted Content
chain = new InterceptorComponent[]{
new TargetableErrorInterceptor(),
new SessionTokenContentInterceptor(),
new UIContextDumpInterceptor(),
new TargetableInterceptor(),
new WWindowInterceptor(false),
new WrongStepContentInterceptor()};
} else {
chain = new InterceptorComponent[]{ // Page submit
new TemplateRenderInterceptor(),
new TransformXMLInterceptor(),
new ValidateXMLInterceptor(),
new SessionTokenInterceptor(),
new ResponseCacheInterceptor(CacheType.NO_CACHE),
new UIContextDumpInterceptor(),
new WWindowInterceptor(true),
new WrongStepServerInterceptor(),
new AjaxCleanupInterceptor(),
new ContextCleanupInterceptor(),
new WhitespaceFilterInterceptor(),
new SubordinateControlInterceptor(),
new PageShellInterceptor(),
new FormInterceptor(),
new DebugStructureInterceptor()};
}
// Link the interceptors together in a chain.
for (int i = 0; i < chain.length - 1; i++) {
chain[i].setBackingComponent(chain[i + 1]);
}
// Return the top of the chain.
return chain[0];
} | [
"public",
"static",
"InterceptorComponent",
"createInterceptorChain",
"(",
"final",
"HttpServletRequest",
"request",
")",
"{",
"// Allow for multi part parameters",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
"=",
"getRequestParameters",
"(",
"request",
")",
";",
"InterceptorComponent",
"[",
"]",
"chain",
";",
"if",
"(",
"parameters",
".",
"get",
"(",
"WServlet",
".",
"DATA_LIST_PARAM_NAME",
")",
"!=",
"null",
")",
"{",
"// Datalist",
"chain",
"=",
"new",
"InterceptorComponent",
"[",
"]",
"{",
"new",
"TransformXMLInterceptor",
"(",
")",
",",
"new",
"DataListInterceptor",
"(",
")",
"}",
";",
"}",
"else",
"if",
"(",
"parameters",
".",
"get",
"(",
"WServlet",
".",
"AJAX_TRIGGER_PARAM_NAME",
")",
"!=",
"null",
")",
"{",
"// AJAX",
"chain",
"=",
"new",
"InterceptorComponent",
"[",
"]",
"{",
"new",
"TemplateRenderInterceptor",
"(",
")",
",",
"new",
"TransformXMLInterceptor",
"(",
")",
",",
"new",
"ValidateXMLInterceptor",
"(",
")",
",",
"new",
"AjaxErrorInterceptor",
"(",
")",
",",
"new",
"SessionTokenAjaxInterceptor",
"(",
")",
",",
"new",
"ResponseCacheInterceptor",
"(",
"CacheType",
".",
"NO_CACHE",
")",
",",
"new",
"UIContextDumpInterceptor",
"(",
")",
",",
"new",
"AjaxSetupInterceptor",
"(",
")",
",",
"new",
"WWindowInterceptor",
"(",
"true",
")",
",",
"new",
"WrongStepAjaxInterceptor",
"(",
")",
",",
"new",
"ContextCleanupInterceptor",
"(",
")",
",",
"new",
"WhitespaceFilterInterceptor",
"(",
")",
",",
"new",
"SubordinateControlInterceptor",
"(",
")",
",",
"new",
"AjaxPageShellInterceptor",
"(",
")",
",",
"new",
"AjaxDebugStructureInterceptor",
"(",
")",
",",
"new",
"AjaxInterceptor",
"(",
")",
"}",
";",
"}",
"else",
"if",
"(",
"parameters",
".",
"get",
"(",
"WServlet",
".",
"TARGET_ID_PARAM_NAME",
")",
"!=",
"null",
")",
"{",
"// Targetted Content",
"chain",
"=",
"new",
"InterceptorComponent",
"[",
"]",
"{",
"new",
"TargetableErrorInterceptor",
"(",
")",
",",
"new",
"SessionTokenContentInterceptor",
"(",
")",
",",
"new",
"UIContextDumpInterceptor",
"(",
")",
",",
"new",
"TargetableInterceptor",
"(",
")",
",",
"new",
"WWindowInterceptor",
"(",
"false",
")",
",",
"new",
"WrongStepContentInterceptor",
"(",
")",
"}",
";",
"}",
"else",
"{",
"chain",
"=",
"new",
"InterceptorComponent",
"[",
"]",
"{",
"// Page submit",
"new",
"TemplateRenderInterceptor",
"(",
")",
",",
"new",
"TransformXMLInterceptor",
"(",
")",
",",
"new",
"ValidateXMLInterceptor",
"(",
")",
",",
"new",
"SessionTokenInterceptor",
"(",
")",
",",
"new",
"ResponseCacheInterceptor",
"(",
"CacheType",
".",
"NO_CACHE",
")",
",",
"new",
"UIContextDumpInterceptor",
"(",
")",
",",
"new",
"WWindowInterceptor",
"(",
"true",
")",
",",
"new",
"WrongStepServerInterceptor",
"(",
")",
",",
"new",
"AjaxCleanupInterceptor",
"(",
")",
",",
"new",
"ContextCleanupInterceptor",
"(",
")",
",",
"new",
"WhitespaceFilterInterceptor",
"(",
")",
",",
"new",
"SubordinateControlInterceptor",
"(",
")",
",",
"new",
"PageShellInterceptor",
"(",
")",
",",
"new",
"FormInterceptor",
"(",
")",
",",
"new",
"DebugStructureInterceptor",
"(",
")",
"}",
";",
"}",
"// Link the interceptors together in a chain.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chain",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"chain",
"[",
"i",
"]",
".",
"setBackingComponent",
"(",
"chain",
"[",
"i",
"+",
"1",
"]",
")",
";",
"}",
"// Return the top of the chain.",
"return",
"chain",
"[",
"0",
"]",
";",
"}"
] | Creates a new interceptor chain to handle the given request.
@param request the request to handle
@return a new interceptor chain for the request. | [
"Creates",
"a",
"new",
"interceptor",
"chain",
"to",
"handle",
"the",
"given",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L388-L454 |
139,566 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestParameters | public static Map<String, String[]> getRequestParameters(final HttpServletRequest request) {
if (request.getAttribute(REQUEST_PROCESSED_KEY) == null) {
setupRequestParameters(request);
}
return (Map<String, String[]>) request.getAttribute(REQUEST_PARAMETERS_KEY);
} | java | public static Map<String, String[]> getRequestParameters(final HttpServletRequest request) {
if (request.getAttribute(REQUEST_PROCESSED_KEY) == null) {
setupRequestParameters(request);
}
return (Map<String, String[]>) request.getAttribute(REQUEST_PARAMETERS_KEY);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"getRequestParameters",
"(",
"final",
"HttpServletRequest",
"request",
")",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"REQUEST_PROCESSED_KEY",
")",
"==",
"null",
")",
"{",
"setupRequestParameters",
"(",
"request",
")",
";",
"}",
"return",
"(",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
")",
"request",
".",
"getAttribute",
"(",
"REQUEST_PARAMETERS_KEY",
")",
";",
"}"
] | Get a map of request parameters allowing for multi part form fields.
@param request the request being processed
@return a map of parameters on the request | [
"Get",
"a",
"map",
"of",
"request",
"parameters",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L531-L536 |
139,567 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestParameterValue | public static String getRequestParameterValue(final HttpServletRequest request, final String key) {
String[] values = getRequestParameterValues(request, key);
return values == null || values.length == 0 ? null : values[0];
} | java | public static String getRequestParameterValue(final HttpServletRequest request, final String key) {
String[] values = getRequestParameterValues(request, key);
return values == null || values.length == 0 ? null : values[0];
} | [
"public",
"static",
"String",
"getRequestParameterValue",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"key",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"getRequestParameterValues",
"(",
"request",
",",
"key",
")",
";",
"return",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
"0",
"?",
"null",
":",
"values",
"[",
"0",
"]",
";",
"}"
] | Get a value for a request parameter allowing for multi part form fields.
@param request the request being processed
@param key the parameter key to return
@return the parameter value | [
"Get",
"a",
"value",
"for",
"a",
"request",
"parameter",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L545-L548 |
139,568 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestParameterValues | public static String[] getRequestParameterValues(final HttpServletRequest request, final String key) {
return getRequestParameters(request).get(key);
} | java | public static String[] getRequestParameterValues(final HttpServletRequest request, final String key) {
return getRequestParameters(request).get(key);
} | [
"public",
"static",
"String",
"[",
"]",
"getRequestParameterValues",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"key",
")",
"{",
"return",
"getRequestParameters",
"(",
"request",
")",
".",
"get",
"(",
"key",
")",
";",
"}"
] | Get the values for a request parameter allowing for multi part form fields.
@param request the request being processed
@param key the parameter key to return
@return the parameter values | [
"Get",
"the",
"values",
"for",
"a",
"request",
"parameter",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L557-L559 |
139,569 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestFileItems | public static Map<String, FileItem[]> getRequestFileItems(final HttpServletRequest request) {
if (request.getAttribute(REQUEST_PROCESSED_KEY) == null) {
setupRequestParameters(request);
}
return (Map<String, FileItem[]>) request.getAttribute(REQUEST_FILES_KEY);
} | java | public static Map<String, FileItem[]> getRequestFileItems(final HttpServletRequest request) {
if (request.getAttribute(REQUEST_PROCESSED_KEY) == null) {
setupRequestParameters(request);
}
return (Map<String, FileItem[]>) request.getAttribute(REQUEST_FILES_KEY);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"FileItem",
"[",
"]",
">",
"getRequestFileItems",
"(",
"final",
"HttpServletRequest",
"request",
")",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"REQUEST_PROCESSED_KEY",
")",
"==",
"null",
")",
"{",
"setupRequestParameters",
"(",
"request",
")",
";",
"}",
"return",
"(",
"Map",
"<",
"String",
",",
"FileItem",
"[",
"]",
">",
")",
"request",
".",
"getAttribute",
"(",
"REQUEST_FILES_KEY",
")",
";",
"}"
] | Get a map of file items in the request allowing for multi part form fields.
@param request the request being processed
@return a map of files on the request | [
"Get",
"a",
"map",
"of",
"file",
"items",
"in",
"the",
"request",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L567-L572 |
139,570 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestFileItemValue | public static FileItem getRequestFileItemValue(final HttpServletRequest request, final String key) {
FileItem[] values = getRequestFileItemValues(request, key);
return values == null || values.length == 0 ? null : values[0];
} | java | public static FileItem getRequestFileItemValue(final HttpServletRequest request, final String key) {
FileItem[] values = getRequestFileItemValues(request, key);
return values == null || values.length == 0 ? null : values[0];
} | [
"public",
"static",
"FileItem",
"getRequestFileItemValue",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"key",
")",
"{",
"FileItem",
"[",
"]",
"values",
"=",
"getRequestFileItemValues",
"(",
"request",
",",
"key",
")",
";",
"return",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
"0",
"?",
"null",
":",
"values",
"[",
"0",
"]",
";",
"}"
] | Get a file item value from the request allowing for multi part form fields.
@param request the request being processed
@param key the file parameter key to return
@return the file item value | [
"Get",
"a",
"file",
"item",
"value",
"from",
"the",
"request",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L581-L584 |
139,571 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.getRequestFileItemValues | public static FileItem[] getRequestFileItemValues(final HttpServletRequest request, final String key) {
return getRequestFileItems(request).get(key);
} | java | public static FileItem[] getRequestFileItemValues(final HttpServletRequest request, final String key) {
return getRequestFileItems(request).get(key);
} | [
"public",
"static",
"FileItem",
"[",
"]",
"getRequestFileItemValues",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"key",
")",
"{",
"return",
"getRequestFileItems",
"(",
"request",
")",
".",
"get",
"(",
"key",
")",
";",
"}"
] | Get file item values from the request allowing for multi part form fields.
@param request the request being processed
@param key the file parameter key to return
@return the file item values | [
"Get",
"file",
"item",
"values",
"from",
"the",
"request",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L593-L595 |
139,572 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.setupRequestParameters | public static void setupRequestParameters(final HttpServletRequest request) {
// Check already processed
if (request.getAttribute(REQUEST_PROCESSED_KEY) != null) {
return;
}
Map<String, String[]> parameters = new HashMap<>();
Map<String, FileItem[]> files = new HashMap<>();
extractParameterMap(request, parameters, files);
request.setAttribute(REQUEST_PROCESSED_KEY, "Y");
request.setAttribute(REQUEST_PARAMETERS_KEY, Collections.unmodifiableMap(parameters));
request.setAttribute(REQUEST_FILES_KEY, Collections.unmodifiableMap(files));
} | java | public static void setupRequestParameters(final HttpServletRequest request) {
// Check already processed
if (request.getAttribute(REQUEST_PROCESSED_KEY) != null) {
return;
}
Map<String, String[]> parameters = new HashMap<>();
Map<String, FileItem[]> files = new HashMap<>();
extractParameterMap(request, parameters, files);
request.setAttribute(REQUEST_PROCESSED_KEY, "Y");
request.setAttribute(REQUEST_PARAMETERS_KEY, Collections.unmodifiableMap(parameters));
request.setAttribute(REQUEST_FILES_KEY, Collections.unmodifiableMap(files));
} | [
"public",
"static",
"void",
"setupRequestParameters",
"(",
"final",
"HttpServletRequest",
"request",
")",
"{",
"// Check already processed",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"REQUEST_PROCESSED_KEY",
")",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"String",
",",
"FileItem",
"[",
"]",
">",
"files",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"extractParameterMap",
"(",
"request",
",",
"parameters",
",",
"files",
")",
";",
"request",
".",
"setAttribute",
"(",
"REQUEST_PROCESSED_KEY",
",",
"\"Y\"",
")",
";",
"request",
".",
"setAttribute",
"(",
"REQUEST_PARAMETERS_KEY",
",",
"Collections",
".",
"unmodifiableMap",
"(",
"parameters",
")",
")",
";",
"request",
".",
"setAttribute",
"(",
"REQUEST_FILES_KEY",
",",
"Collections",
".",
"unmodifiableMap",
"(",
"files",
")",
")",
";",
"}"
] | Process the request parameters allowing for multi part form fields.
@param request the request being processed | [
"Process",
"the",
"request",
"parameters",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L602-L617 |
139,573 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.extractParameterMap | public static void extractParameterMap(final HttpServletRequest request, final Map<String, String[]> parameters,
final Map<String, FileItem[]> files) {
if (isMultipart(request)) {
ServletFileUpload upload = new ServletFileUpload();
upload.setFileItemFactory(new DiskFileItemFactory());
try {
List fileItems = upload.parseRequest(request);
uploadFileItems(fileItems, parameters, files);
} catch (FileUploadException ex) {
throw new SystemException(ex);
}
// Include Query String Parameters (only if parameters were not included in the form fields)
for (Object entry : request.getParameterMap().entrySet()) {
Map.Entry<String, String[]> param = (Map.Entry<String, String[]>) entry;
if (!parameters.containsKey(param.getKey())) {
parameters.put(param.getKey(), param.getValue());
}
}
} else {
parameters.putAll(request.getParameterMap());
}
} | java | public static void extractParameterMap(final HttpServletRequest request, final Map<String, String[]> parameters,
final Map<String, FileItem[]> files) {
if (isMultipart(request)) {
ServletFileUpload upload = new ServletFileUpload();
upload.setFileItemFactory(new DiskFileItemFactory());
try {
List fileItems = upload.parseRequest(request);
uploadFileItems(fileItems, parameters, files);
} catch (FileUploadException ex) {
throw new SystemException(ex);
}
// Include Query String Parameters (only if parameters were not included in the form fields)
for (Object entry : request.getParameterMap().entrySet()) {
Map.Entry<String, String[]> param = (Map.Entry<String, String[]>) entry;
if (!parameters.containsKey(param.getKey())) {
parameters.put(param.getKey(), param.getValue());
}
}
} else {
parameters.putAll(request.getParameterMap());
}
} | [
"public",
"static",
"void",
"extractParameterMap",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
",",
"final",
"Map",
"<",
"String",
",",
"FileItem",
"[",
"]",
">",
"files",
")",
"{",
"if",
"(",
"isMultipart",
"(",
"request",
")",
")",
"{",
"ServletFileUpload",
"upload",
"=",
"new",
"ServletFileUpload",
"(",
")",
";",
"upload",
".",
"setFileItemFactory",
"(",
"new",
"DiskFileItemFactory",
"(",
")",
")",
";",
"try",
"{",
"List",
"fileItems",
"=",
"upload",
".",
"parseRequest",
"(",
"request",
")",
";",
"uploadFileItems",
"(",
"fileItems",
",",
"parameters",
",",
"files",
")",
";",
"}",
"catch",
"(",
"FileUploadException",
"ex",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"ex",
")",
";",
"}",
"// Include Query String Parameters (only if parameters were not included in the form fields)",
"for",
"(",
"Object",
"entry",
":",
"request",
".",
"getParameterMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
"[",
"]",
">",
"param",
"=",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
"[",
"]",
">",
")",
"entry",
";",
"if",
"(",
"!",
"parameters",
".",
"containsKey",
"(",
"param",
".",
"getKey",
"(",
")",
")",
")",
"{",
"parameters",
".",
"put",
"(",
"param",
".",
"getKey",
"(",
")",
",",
"param",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"parameters",
".",
"putAll",
"(",
"request",
".",
"getParameterMap",
"(",
")",
")",
";",
"}",
"}"
] | Extract the parameters and file items allowing for multi part form fields.
@param request the request being processed
@param parameters the map to store non-file request parameters in.
@param files the map to store the uploaded file parameters in. | [
"Extract",
"the",
"parameters",
"and",
"file",
"items",
"allowing",
"for",
"multi",
"part",
"form",
"fields",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L626-L649 |
139,574 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java | ServletUtil.extractCookie | public static String extractCookie(final HttpServletRequest request, final String name) {
for (Cookie cookie : request.getCookies()) {
if (cookie.getName().equals(name)) {
return cookie.getValue();
}
}
return null;
} | java | public static String extractCookie(final HttpServletRequest request, final String name) {
for (Cookie cookie : request.getCookies()) {
if (cookie.getName().equals(name)) {
return cookie.getValue();
}
}
return null;
} | [
"public",
"static",
"String",
"extractCookie",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"name",
")",
"{",
"for",
"(",
"Cookie",
"cookie",
":",
"request",
".",
"getCookies",
"(",
")",
")",
"{",
"if",
"(",
"cookie",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"cookie",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Find the value of a cookie on the request, by name.
@param request The request on which to check for the cookie.
@param name The name of the cookie we want the value of.
@return The value of the cookie, if present, otherwise null. | [
"Find",
"the",
"value",
"of",
"a",
"cookie",
"on",
"the",
"request",
"by",
"name",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/servlet/ServletUtil.java#L657-L664 |
139,575 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WRadioButtonSubmitOnChangeExample.java | WRadioButtonSubmitOnChangeExample.updateRegion | private void updateRegion() {
actMessagePanel.setVisible(false);
if (rbtACT.isSelected()) {
actMessagePanel.setVisible(true);
regionFields.setVisible(true);
regionSelector.setOptions(new String[]{null, "Belconnen", "City", "Woden"});
regionSelector.setVisible(true);
} else if (rbtNSW.isSelected()) {
regionFields.setVisible(true);
regionSelector.setOptions(
new String[]{null, "Hunter", "Riverina", "Southern Tablelands"});
regionSelector.setVisible(true);
} else if (rbtVIC.isSelected()) {
regionFields.setVisible(true);
regionSelector.setOptions(
new String[]{null, "Gippsland", "Melbourne", "Mornington Peninsula"});
regionSelector.setVisible(true);
} else {
regionSelector.setOptions(new Object[]{null});
regionSelector.setVisible(false);
regionFields.setVisible(false);
}
} | java | private void updateRegion() {
actMessagePanel.setVisible(false);
if (rbtACT.isSelected()) {
actMessagePanel.setVisible(true);
regionFields.setVisible(true);
regionSelector.setOptions(new String[]{null, "Belconnen", "City", "Woden"});
regionSelector.setVisible(true);
} else if (rbtNSW.isSelected()) {
regionFields.setVisible(true);
regionSelector.setOptions(
new String[]{null, "Hunter", "Riverina", "Southern Tablelands"});
regionSelector.setVisible(true);
} else if (rbtVIC.isSelected()) {
regionFields.setVisible(true);
regionSelector.setOptions(
new String[]{null, "Gippsland", "Melbourne", "Mornington Peninsula"});
regionSelector.setVisible(true);
} else {
regionSelector.setOptions(new Object[]{null});
regionSelector.setVisible(false);
regionFields.setVisible(false);
}
} | [
"private",
"void",
"updateRegion",
"(",
")",
"{",
"actMessagePanel",
".",
"setVisible",
"(",
"false",
")",
";",
"if",
"(",
"rbtACT",
".",
"isSelected",
"(",
")",
")",
"{",
"actMessagePanel",
".",
"setVisible",
"(",
"true",
")",
";",
"regionFields",
".",
"setVisible",
"(",
"true",
")",
";",
"regionSelector",
".",
"setOptions",
"(",
"new",
"String",
"[",
"]",
"{",
"null",
",",
"\"Belconnen\"",
",",
"\"City\"",
",",
"\"Woden\"",
"}",
")",
";",
"regionSelector",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"else",
"if",
"(",
"rbtNSW",
".",
"isSelected",
"(",
")",
")",
"{",
"regionFields",
".",
"setVisible",
"(",
"true",
")",
";",
"regionSelector",
".",
"setOptions",
"(",
"new",
"String",
"[",
"]",
"{",
"null",
",",
"\"Hunter\"",
",",
"\"Riverina\"",
",",
"\"Southern Tablelands\"",
"}",
")",
";",
"regionSelector",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"else",
"if",
"(",
"rbtVIC",
".",
"isSelected",
"(",
")",
")",
"{",
"regionFields",
".",
"setVisible",
"(",
"true",
")",
";",
"regionSelector",
".",
"setOptions",
"(",
"new",
"String",
"[",
"]",
"{",
"null",
",",
"\"Gippsland\"",
",",
"\"Melbourne\"",
",",
"\"Mornington Peninsula\"",
"}",
")",
";",
"regionSelector",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"else",
"{",
"regionSelector",
".",
"setOptions",
"(",
"new",
"Object",
"[",
"]",
"{",
"null",
"}",
")",
";",
"regionSelector",
".",
"setVisible",
"(",
"false",
")",
";",
"regionFields",
".",
"setVisible",
"(",
"false",
")",
";",
"}",
"}"
] | Updates the visibility and options present in the region selector, depending on the state selector's value. | [
"Updates",
"the",
"visibility",
"and",
"options",
"present",
"in",
"the",
"region",
"selector",
"depending",
"on",
"the",
"state",
"selector",
"s",
"value",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WRadioButtonSubmitOnChangeExample.java#L89-L112 |
139,576 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.setContent | public void setContent(final WComponent content) {
WindowModel model = getOrCreateComponentModel();
// If the previous content had been wrapped, then remove it from the wrapping WApplication.
if (model.wrappedContent != null && model.wrappedContent != model.content) {
model.wrappedContent.removeAll();
}
model.content = content;
// Wrap content in a WApplication
if (content instanceof WApplication) {
model.wrappedContent = (WApplication) content;
} else {
model.wrappedContent = new WApplication();
model.wrappedContent.add(content);
}
// There should only be one content.
holder.removeAll();
holder.add(model.wrappedContent);
} | java | public void setContent(final WComponent content) {
WindowModel model = getOrCreateComponentModel();
// If the previous content had been wrapped, then remove it from the wrapping WApplication.
if (model.wrappedContent != null && model.wrappedContent != model.content) {
model.wrappedContent.removeAll();
}
model.content = content;
// Wrap content in a WApplication
if (content instanceof WApplication) {
model.wrappedContent = (WApplication) content;
} else {
model.wrappedContent = new WApplication();
model.wrappedContent.add(content);
}
// There should only be one content.
holder.removeAll();
holder.add(model.wrappedContent);
} | [
"public",
"void",
"setContent",
"(",
"final",
"WComponent",
"content",
")",
"{",
"WindowModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"// If the previous content had been wrapped, then remove it from the wrapping WApplication.",
"if",
"(",
"model",
".",
"wrappedContent",
"!=",
"null",
"&&",
"model",
".",
"wrappedContent",
"!=",
"model",
".",
"content",
")",
"{",
"model",
".",
"wrappedContent",
".",
"removeAll",
"(",
")",
";",
"}",
"model",
".",
"content",
"=",
"content",
";",
"// Wrap content in a WApplication",
"if",
"(",
"content",
"instanceof",
"WApplication",
")",
"{",
"model",
".",
"wrappedContent",
"=",
"(",
"WApplication",
")",
"content",
";",
"}",
"else",
"{",
"model",
".",
"wrappedContent",
"=",
"new",
"WApplication",
"(",
")",
";",
"model",
".",
"wrappedContent",
".",
"add",
"(",
"content",
")",
";",
"}",
"// There should only be one content.",
"holder",
".",
"removeAll",
"(",
")",
";",
"holder",
".",
"add",
"(",
"model",
".",
"wrappedContent",
")",
";",
"}"
] | Set the WComponent that will handle the content for this pop up window.
@param content the window content. | [
"Set",
"the",
"WComponent",
"that",
"will",
"handle",
"the",
"content",
"for",
"this",
"pop",
"up",
"window",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L86-L107 |
139,577 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.setTitle | public void setTitle(final String title) {
String currTitle = getTitle();
if (!Objects.equals(title, currTitle)) {
getOrCreateComponentModel().title = title;
}
} | java | public void setTitle(final String title) {
String currTitle = getTitle();
if (!Objects.equals(title, currTitle)) {
getOrCreateComponentModel().title = title;
}
} | [
"public",
"void",
"setTitle",
"(",
"final",
"String",
"title",
")",
"{",
"String",
"currTitle",
"=",
"getTitle",
"(",
")",
";",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"title",
",",
"currTitle",
")",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"title",
"=",
"title",
";",
"}",
"}"
] | Sets the window title.
@param title The title to set. | [
"Sets",
"the",
"window",
"title",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L128-L134 |
139,578 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.getUrl | public String getUrl() {
Environment env = getEnvironment();
Map<String, String> parameters = env.getHiddenParameters();
parameters.put(WWINDOW_REQUEST_PARAM_KEY, getId());
// Override the step count with WWindow step
parameters.put(Environment.STEP_VARIABLE, String.valueOf(getStep()));
String url = env.getWServletPath();
return WebUtilities.getPath(url, parameters, true);
} | java | public String getUrl() {
Environment env = getEnvironment();
Map<String, String> parameters = env.getHiddenParameters();
parameters.put(WWINDOW_REQUEST_PARAM_KEY, getId());
// Override the step count with WWindow step
parameters.put(Environment.STEP_VARIABLE, String.valueOf(getStep()));
String url = env.getWServletPath();
return WebUtilities.getPath(url, parameters, true);
} | [
"public",
"String",
"getUrl",
"(",
")",
"{",
"Environment",
"env",
"=",
"getEnvironment",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"env",
".",
"getHiddenParameters",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"WWINDOW_REQUEST_PARAM_KEY",
",",
"getId",
"(",
")",
")",
";",
"// Override the step count with WWindow step",
"parameters",
".",
"put",
"(",
"Environment",
".",
"STEP_VARIABLE",
",",
"String",
".",
"valueOf",
"(",
"getStep",
"(",
")",
")",
")",
";",
"String",
"url",
"=",
"env",
".",
"getWServletPath",
"(",
")",
";",
"return",
"WebUtilities",
".",
"getPath",
"(",
"url",
",",
"parameters",
",",
"true",
")",
";",
"}"
] | Returns a dynamic URL that this wwindow component can be accessed from.
@return the URL to access this wwindow component. | [
"Returns",
"a",
"dynamic",
"URL",
"that",
"this",
"wwindow",
"component",
"can",
"be",
"accessed",
"from",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L348-L358 |
139,579 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
// Check if window in request (might not have gone through handle request, eg Step error)
boolean targeted = isPresent(request);
setTargeted(targeted);
if (getState() == ACTIVE_STATE && isTargeted()) {
getComponentModel().wrappedContent.preparePaint(request);
}
} | java | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
// Check if window in request (might not have gone through handle request, eg Step error)
boolean targeted = isPresent(request);
setTargeted(targeted);
if (getState() == ACTIVE_STATE && isTargeted()) {
getComponentModel().wrappedContent.preparePaint(request);
}
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"super",
".",
"preparePaintComponent",
"(",
"request",
")",
";",
"// Check if window in request (might not have gone through handle request, eg Step error)",
"boolean",
"targeted",
"=",
"isPresent",
"(",
"request",
")",
";",
"setTargeted",
"(",
"targeted",
")",
";",
"if",
"(",
"getState",
"(",
")",
"==",
"ACTIVE_STATE",
"&&",
"isTargeted",
"(",
")",
")",
"{",
"getComponentModel",
"(",
")",
".",
"wrappedContent",
".",
"preparePaint",
"(",
"request",
")",
";",
"}",
"}"
] | Override preparePaintComponent to clear the scratch map before the window content is being painted.
@param request the request being responded to. | [
"Override",
"preparePaintComponent",
"to",
"clear",
"the",
"scratch",
"map",
"before",
"the",
"window",
"content",
"is",
"being",
"painted",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L409-L420 |
139,580 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.paintComponent | @Override
protected void paintComponent(final RenderContext renderContext) {
if (getState() == DISPLAY_STATE) {
setState(ACTIVE_STATE);
showWindow(renderContext);
} else if (getState() == ACTIVE_STATE && isTargeted()) {
getComponentModel().wrappedContent.paint(renderContext);
}
} | java | @Override
protected void paintComponent(final RenderContext renderContext) {
if (getState() == DISPLAY_STATE) {
setState(ACTIVE_STATE);
showWindow(renderContext);
} else if (getState() == ACTIVE_STATE && isTargeted()) {
getComponentModel().wrappedContent.paint(renderContext);
}
} | [
"@",
"Override",
"protected",
"void",
"paintComponent",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"if",
"(",
"getState",
"(",
")",
"==",
"DISPLAY_STATE",
")",
"{",
"setState",
"(",
"ACTIVE_STATE",
")",
";",
"showWindow",
"(",
"renderContext",
")",
";",
"}",
"else",
"if",
"(",
"getState",
"(",
")",
"==",
"ACTIVE_STATE",
"&&",
"isTargeted",
"(",
")",
")",
"{",
"getComponentModel",
"(",
")",
".",
"wrappedContent",
".",
"paint",
"(",
"renderContext",
")",
";",
"}",
"}"
] | Override paintComponent in order to paint the window or its content, depending on the window state.
@param renderContext the RenderContext to send the output to. | [
"Override",
"paintComponent",
"in",
"order",
"to",
"paint",
"the",
"window",
"or",
"its",
"content",
"depending",
"on",
"the",
"window",
"state",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L427-L435 |
139,581 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java | WWindow.showWindow | protected void showWindow(final RenderContext renderContext) {
// Get current step
int current = UIContextHolder.getCurrent().getEnvironment().getStep();
// Get window current step (may have already been launched)
int window = getStep();
// Combine step counts to make previous window (if still open) invalid
setStep(window + current);
// TODO: This should be in a renderer, not included in this class
if (renderContext instanceof WebXmlRenderContext) {
PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();
writer.print("\n<ui:popup");
writer.print(" url=\"" + WebUtilities.encode(getUrl()) + '"');
writer.print(" width=\"" + getWidth() + '"');
writer.print(" height=\"" + getHeight() + '"');
if (isResizable()) {
writer.print(" resizable=\"true\"");
}
if (isScrollable()) {
writer.print(" showScrollbars=\"true\"");
}
if (isShowMenuBar()) {
writer.print(" showMenubar=\"true\"");
}
if (isShowToolbar()) {
writer.print(" showToolbar=\"true\"");
}
if (isShowLocation()) {
writer.print(" showLocation=\"true\"");
}
if (isShowStatus()) {
writer.print(" showStatus=\"true\"");
}
if (getTop() >= 0) {
writer.print(" top=\"" + getTop() + '\'');
}
if (getLeft() >= 0) {
writer.print(" left=\"" + getLeft() + '\'');
}
writer.println("/>");
}
} | java | protected void showWindow(final RenderContext renderContext) {
// Get current step
int current = UIContextHolder.getCurrent().getEnvironment().getStep();
// Get window current step (may have already been launched)
int window = getStep();
// Combine step counts to make previous window (if still open) invalid
setStep(window + current);
// TODO: This should be in a renderer, not included in this class
if (renderContext instanceof WebXmlRenderContext) {
PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();
writer.print("\n<ui:popup");
writer.print(" url=\"" + WebUtilities.encode(getUrl()) + '"');
writer.print(" width=\"" + getWidth() + '"');
writer.print(" height=\"" + getHeight() + '"');
if (isResizable()) {
writer.print(" resizable=\"true\"");
}
if (isScrollable()) {
writer.print(" showScrollbars=\"true\"");
}
if (isShowMenuBar()) {
writer.print(" showMenubar=\"true\"");
}
if (isShowToolbar()) {
writer.print(" showToolbar=\"true\"");
}
if (isShowLocation()) {
writer.print(" showLocation=\"true\"");
}
if (isShowStatus()) {
writer.print(" showStatus=\"true\"");
}
if (getTop() >= 0) {
writer.print(" top=\"" + getTop() + '\'');
}
if (getLeft() >= 0) {
writer.print(" left=\"" + getLeft() + '\'');
}
writer.println("/>");
}
} | [
"protected",
"void",
"showWindow",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"// Get current step",
"int",
"current",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
".",
"getEnvironment",
"(",
")",
".",
"getStep",
"(",
")",
";",
"// Get window current step (may have already been launched)",
"int",
"window",
"=",
"getStep",
"(",
")",
";",
"// Combine step counts to make previous window (if still open) invalid",
"setStep",
"(",
"window",
"+",
"current",
")",
";",
"// TODO: This should be in a renderer, not included in this class",
"if",
"(",
"renderContext",
"instanceof",
"WebXmlRenderContext",
")",
"{",
"PrintWriter",
"writer",
"=",
"(",
"(",
"WebXmlRenderContext",
")",
"renderContext",
")",
".",
"getWriter",
"(",
")",
";",
"writer",
".",
"print",
"(",
"\"\\n<ui:popup\"",
")",
";",
"writer",
".",
"print",
"(",
"\" url=\\\"\"",
"+",
"WebUtilities",
".",
"encode",
"(",
"getUrl",
"(",
")",
")",
"+",
"'",
"'",
")",
";",
"writer",
".",
"print",
"(",
"\" width=\\\"\"",
"+",
"getWidth",
"(",
")",
"+",
"'",
"'",
")",
";",
"writer",
".",
"print",
"(",
"\" height=\\\"\"",
"+",
"getHeight",
"(",
")",
"+",
"'",
"'",
")",
";",
"if",
"(",
"isResizable",
"(",
")",
")",
"{",
"writer",
".",
"print",
"(",
"\" resizable=\\\"true\\\"\"",
")",
";",
"}",
"if",
"(",
"isScrollable",
"(",
")",
")",
"{",
"writer",
".",
"print",
"(",
"\" showScrollbars=\\\"true\\\"\"",
")",
";",
"}",
"if",
"(",
"isShowMenuBar",
"(",
")",
")",
"{",
"writer",
".",
"print",
"(",
"\" showMenubar=\\\"true\\\"\"",
")",
";",
"}",
"if",
"(",
"isShowToolbar",
"(",
")",
")",
"{",
"writer",
".",
"print",
"(",
"\" showToolbar=\\\"true\\\"\"",
")",
";",
"}",
"if",
"(",
"isShowLocation",
"(",
")",
")",
"{",
"writer",
".",
"print",
"(",
"\" showLocation=\\\"true\\\"\"",
")",
";",
"}",
"if",
"(",
"isShowStatus",
"(",
")",
")",
"{",
"writer",
".",
"print",
"(",
"\" showStatus=\\\"true\\\"\"",
")",
";",
"}",
"if",
"(",
"getTop",
"(",
")",
">=",
"0",
")",
"{",
"writer",
".",
"print",
"(",
"\" top=\\\"\"",
"+",
"getTop",
"(",
")",
"+",
"'",
"'",
")",
";",
"}",
"if",
"(",
"getLeft",
"(",
")",
">=",
"0",
")",
"{",
"writer",
".",
"print",
"(",
"\" left=\\\"\"",
"+",
"getLeft",
"(",
")",
"+",
"'",
"'",
")",
";",
"}",
"writer",
".",
"println",
"(",
"\"/>\"",
")",
";",
"}",
"}"
] | Emits the mark-up which pops up the window.
@param renderContext the RenderContext to send the output to. | [
"Emits",
"the",
"mark",
"-",
"up",
"which",
"pops",
"up",
"the",
"window",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WWindow.java#L448-L499 |
139,582 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFileWidgetRenderer.java | WFileWidgetRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFileWidget fileWidget = (WFileWidget) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = fileWidget.isReadOnly();
xml.appendTagOpen(TAG_NAME);
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
xml.appendEnd();
return;
}
xml.appendOptionalAttribute("disabled", fileWidget.isDisabled(), "true");
xml.appendOptionalAttribute("required", fileWidget.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", fileWidget.getToolTip());
xml.appendOptionalAttribute("accessibleText", fileWidget.getAccessibleText());
xml.appendOptionalAttribute("acceptedMimeTypes", typesToString(fileWidget.getFileTypes()));
long maxFileSize = fileWidget.getMaxFileSize();
xml.appendOptionalAttribute("maxFileSize", maxFileSize > 0, maxFileSize);
List<Diagnostic> diags = fileWidget.getDiagnostics(Diagnostic.ERROR);
if (diags == null || diags.isEmpty()) {
xml.appendEnd();
return;
}
xml.appendClose();
DiagnosticRenderUtil.renderDiagnostics(fileWidget, renderContext);
xml.appendEndTag(TAG_NAME);
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFileWidget fileWidget = (WFileWidget) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = fileWidget.isReadOnly();
xml.appendTagOpen(TAG_NAME);
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
xml.appendEnd();
return;
}
xml.appendOptionalAttribute("disabled", fileWidget.isDisabled(), "true");
xml.appendOptionalAttribute("required", fileWidget.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", fileWidget.getToolTip());
xml.appendOptionalAttribute("accessibleText", fileWidget.getAccessibleText());
xml.appendOptionalAttribute("acceptedMimeTypes", typesToString(fileWidget.getFileTypes()));
long maxFileSize = fileWidget.getMaxFileSize();
xml.appendOptionalAttribute("maxFileSize", maxFileSize > 0, maxFileSize);
List<Diagnostic> diags = fileWidget.getDiagnostics(Diagnostic.ERROR);
if (diags == null || diags.isEmpty()) {
xml.appendEnd();
return;
}
xml.appendClose();
DiagnosticRenderUtil.renderDiagnostics(fileWidget, renderContext);
xml.appendEndTag(TAG_NAME);
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WFileWidget",
"fileWidget",
"=",
"(",
"WFileWidget",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"readOnly",
"=",
"fileWidget",
".",
"isReadOnly",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"TAG_NAME",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"component",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"readOnly",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"readOnly\"",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"return",
";",
"}",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"fileWidget",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"required\"",
",",
"fileWidget",
".",
"isMandatory",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"toolTip\"",
",",
"fileWidget",
".",
"getToolTip",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"accessibleText\"",
",",
"fileWidget",
".",
"getAccessibleText",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"acceptedMimeTypes\"",
",",
"typesToString",
"(",
"fileWidget",
".",
"getFileTypes",
"(",
")",
")",
")",
";",
"long",
"maxFileSize",
"=",
"fileWidget",
".",
"getMaxFileSize",
"(",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"maxFileSize\"",
",",
"maxFileSize",
">",
"0",
",",
"maxFileSize",
")",
";",
"List",
"<",
"Diagnostic",
">",
"diags",
"=",
"fileWidget",
".",
"getDiagnostics",
"(",
"Diagnostic",
".",
"ERROR",
")",
";",
"if",
"(",
"diags",
"==",
"null",
"||",
"diags",
".",
"isEmpty",
"(",
")",
")",
"{",
"xml",
".",
"appendEnd",
"(",
")",
";",
"return",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"DiagnosticRenderUtil",
".",
"renderDiagnostics",
"(",
"fileWidget",
",",
"renderContext",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"TAG_NAME",
")",
";",
"}"
] | Paints the given WFileWidget.
@param component the WFileWidget to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WFileWidget",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFileWidgetRenderer.java#L29-L61 |
139,583 | podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.createOrganization | public OrganizationCreateResponse createOrganization(OrganizationCreate data) {
return getResourceFactory().getApiResource("/org/")
.entity(data, MediaType.APPLICATION_JSON_TYPE)
.post(OrganizationCreateResponse.class);
} | java | public OrganizationCreateResponse createOrganization(OrganizationCreate data) {
return getResourceFactory().getApiResource("/org/")
.entity(data, MediaType.APPLICATION_JSON_TYPE)
.post(OrganizationCreateResponse.class);
} | [
"public",
"OrganizationCreateResponse",
"createOrganization",
"(",
"OrganizationCreate",
"data",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/\"",
")",
".",
"entity",
"(",
"data",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"post",
"(",
"OrganizationCreateResponse",
".",
"class",
")",
";",
"}"
] | Creates a new organization
@param data
The data for the new organization
@return The data for the newly created organization | [
"Creates",
"a",
"new",
"organization"
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L27-L31 |
139,584 | podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.updateOrganization | public void updateOrganization(int orgId, OrganizationCreate data) {
getResourceFactory().getApiResource("/org/" + orgId)
.entity(data, MediaType.APPLICATION_JSON_TYPE).put();
} | java | public void updateOrganization(int orgId, OrganizationCreate data) {
getResourceFactory().getApiResource("/org/" + orgId)
.entity(data, MediaType.APPLICATION_JSON_TYPE).put();
} | [
"public",
"void",
"updateOrganization",
"(",
"int",
"orgId",
",",
"OrganizationCreate",
"data",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/\"",
"+",
"orgId",
")",
".",
"entity",
"(",
"data",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"put",
"(",
")",
";",
"}"
] | Updates an organization with new name and logo. Note that the URL of the
organization will not change even though the name changes.
@param orgId
The id of the organization
@param data
The new data | [
"Updates",
"an",
"organization",
"with",
"new",
"name",
"and",
"logo",
".",
"Note",
"that",
"the",
"URL",
"of",
"the",
"organization",
"will",
"not",
"change",
"even",
"though",
"the",
"name",
"changes",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L42-L45 |
139,585 | podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.getOrganizationByURL | public OrganizationMini getOrganizationByURL(String url) {
return getResourceFactory().getApiResource("/org/url")
.queryParam("url", url).get(OrganizationMini.class);
} | java | public OrganizationMini getOrganizationByURL(String url) {
return getResourceFactory().getApiResource("/org/url")
.queryParam("url", url).get(OrganizationMini.class);
} | [
"public",
"OrganizationMini",
"getOrganizationByURL",
"(",
"String",
"url",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/url\"",
")",
".",
"queryParam",
"(",
"\"url\"",
",",
"url",
")",
".",
"get",
"(",
"OrganizationMini",
".",
"class",
")",
";",
"}"
] | Returns the organization with the given full URL. The URL does not have
to be truncated to the root, it can be to any resource on the URL.
@param url
The URL to find the organization for
@return The organization | [
"Returns",
"the",
"organization",
"with",
"the",
"given",
"full",
"URL",
".",
"The",
"URL",
"does",
"not",
"have",
"to",
"be",
"truncated",
"to",
"the",
"root",
"it",
"can",
"be",
"to",
"any",
"resource",
"on",
"the",
"URL",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L77-L80 |
139,586 | podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.getSharedOrganizations | public List<OrganizationWithSpaces> getSharedOrganizations(int userId) {
return getResourceFactory().getApiResource("/org/shared/" + userId)
.get(new GenericType<List<OrganizationWithSpaces>>() {
});
} | java | public List<OrganizationWithSpaces> getSharedOrganizations(int userId) {
return getResourceFactory().getApiResource("/org/shared/" + userId)
.get(new GenericType<List<OrganizationWithSpaces>>() {
});
} | [
"public",
"List",
"<",
"OrganizationWithSpaces",
">",
"getSharedOrganizations",
"(",
"int",
"userId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/shared/\"",
"+",
"userId",
")",
".",
"get",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"OrganizationWithSpaces",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Returns the organizations and spaces that the logged in user shares with
the specified user. The organizations and spaces will be returned sorted
by name.
@param userId
The id of the user
@return The organizations with spaces that are shared with the user | [
"Returns",
"the",
"organizations",
"and",
"spaces",
"that",
"the",
"logged",
"in",
"user",
"shares",
"with",
"the",
"specified",
"user",
".",
"The",
"organizations",
"and",
"spaces",
"will",
"be",
"returned",
"sorted",
"by",
"name",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L91-L95 |
139,587 | podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.getSpaces | public List<Space> getSpaces(int orgId) {
return getResourceFactory().getApiResource("/org/" + orgId + "/space/")
.get(new GenericType<List<Space>>() {
});
} | java | public List<Space> getSpaces(int orgId) {
return getResourceFactory().getApiResource("/org/" + orgId + "/space/")
.get(new GenericType<List<Space>>() {
});
} | [
"public",
"List",
"<",
"Space",
">",
"getSpaces",
"(",
"int",
"orgId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/\"",
"+",
"orgId",
"+",
"\"/space/\"",
")",
".",
"get",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"Space",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Returns all the spaces for the organization.
@param orgId
The id of the organization
@return The spaces in the organization | [
"Returns",
"all",
"the",
"spaces",
"for",
"the",
"organization",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L121-L125 |
139,588 | podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.getEndMemberInfo | public EndMemberInfo getEndMemberInfo(int orgId, int userId) {
return getResourceFactory().getApiResource(
"/org/" + orgId + "/member/" + userId + "/end_member_info").get(
EndMemberInfo.class);
} | java | public EndMemberInfo getEndMemberInfo(int orgId, int userId) {
return getResourceFactory().getApiResource(
"/org/" + orgId + "/member/" + userId + "/end_member_info").get(
EndMemberInfo.class);
} | [
"public",
"EndMemberInfo",
"getEndMemberInfo",
"(",
"int",
"orgId",
",",
"int",
"userId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/\"",
"+",
"orgId",
"+",
"\"/member/\"",
"+",
"userId",
"+",
"\"/end_member_info\"",
")",
".",
"get",
"(",
"EndMemberInfo",
".",
"class",
")",
";",
"}"
] | Returns information about what would happen if this user would be removed from the org
@param orgId
The id of the organization
@param userId
The id of the user
@return The information about the users workspace memberships in the org | [
"Returns",
"information",
"about",
"what",
"would",
"happen",
"if",
"this",
"user",
"would",
"be",
"removed",
"from",
"the",
"org"
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L224-L228 |
139,589 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImageEditor.java | WImageEditor.setUseCamera | public void setUseCamera(final boolean useCamera) {
if (useCamera != getUseCamera()) {
ImageEditModel model = getOrCreateComponentModel();
model.useCamera = useCamera;
}
} | java | public void setUseCamera(final boolean useCamera) {
if (useCamera != getUseCamera()) {
ImageEditModel model = getOrCreateComponentModel();
model.useCamera = useCamera;
}
} | [
"public",
"void",
"setUseCamera",
"(",
"final",
"boolean",
"useCamera",
")",
"{",
"if",
"(",
"useCamera",
"!=",
"getUseCamera",
"(",
")",
")",
"{",
"ImageEditModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"model",
".",
"useCamera",
"=",
"useCamera",
";",
"}",
"}"
] | Set to true if you wish to allow the user to capture an image from an attached camera.
This feature is completely dependent on browser support and will essentially be ignored if the browser does not
provide the necessary APIs.
@param useCamera the overlay image URL. | [
"Set",
"to",
"true",
"if",
"you",
"wish",
"to",
"allow",
"the",
"user",
"to",
"capture",
"an",
"image",
"from",
"an",
"attached",
"camera",
".",
"This",
"feature",
"is",
"completely",
"dependent",
"on",
"browser",
"support",
"and",
"will",
"essentially",
"be",
"ignored",
"if",
"the",
"browser",
"does",
"not",
"provide",
"the",
"necessary",
"APIs",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImageEditor.java#L55-L60 |
139,590 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImageEditor.java | WImageEditor.setIsFace | public void setIsFace(final boolean isFace) {
if (isFace != getIsFace()) {
ImageEditModel model = getOrCreateComponentModel();
model.isFace = isFace;
}
} | java | public void setIsFace(final boolean isFace) {
if (isFace != getIsFace()) {
ImageEditModel model = getOrCreateComponentModel();
model.isFace = isFace;
}
} | [
"public",
"void",
"setIsFace",
"(",
"final",
"boolean",
"isFace",
")",
"{",
"if",
"(",
"isFace",
"!=",
"getIsFace",
"(",
")",
")",
"{",
"ImageEditModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"model",
".",
"isFace",
"=",
"isFace",
";",
"}",
"}"
] | Set to true to turn on face detection.
@param isFace turn face detection on or off. | [
"Set",
"to",
"true",
"to",
"turn",
"on",
"face",
"detection",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImageEditor.java#L74-L79 |
139,591 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImageEditor.java | WImageEditor.setRenderInline | public void setRenderInline(final boolean renderInline) {
if (renderInline != getRenderInline()) {
ImageEditModel model = getOrCreateComponentModel();
model.renderInline = renderInline;
}
} | java | public void setRenderInline(final boolean renderInline) {
if (renderInline != getRenderInline()) {
ImageEditModel model = getOrCreateComponentModel();
model.renderInline = renderInline;
}
} | [
"public",
"void",
"setRenderInline",
"(",
"final",
"boolean",
"renderInline",
")",
"{",
"if",
"(",
"renderInline",
"!=",
"getRenderInline",
"(",
")",
")",
"{",
"ImageEditModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"model",
".",
"renderInline",
"=",
"renderInline",
";",
"}",
"}"
] | If true then the image editor will render where it is added in the tree instead of in a popup.
@param renderInline Set to true to render inline. | [
"If",
"true",
"then",
"the",
"image",
"editor",
"will",
"render",
"where",
"it",
"is",
"added",
"in",
"the",
"tree",
"instead",
"of",
"in",
"a",
"popup",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WImageEditor.java#L93-L98 |
139,592 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFigureRenderer.java | WFigureRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFigure figure = (WFigure) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean renderChildren = isRenderContent(figure);
xml.appendTagOpen("ui:figure");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
if (FigureMode.LAZY.equals(figure.getMode())) {
xml.appendOptionalAttribute("hidden", !renderChildren, "true");
} else {
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
}
FigureMode mode = figure.getMode();
if (mode != null) {
switch (mode) {
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
default:
throw new SystemException("Unknown figure mode: " + figure.getMode());
}
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(figure, renderContext);
if (renderChildren) {
// Label
figure.getDecoratedLabel().paint(renderContext);
// Content
xml.appendTagOpen("ui:content");
xml.appendAttribute("id", component.getId() + "-content");
xml.appendClose();
figure.getContent().paint(renderContext);
xml.appendEndTag("ui:content");
}
xml.appendEndTag("ui:figure");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFigure figure = (WFigure) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean renderChildren = isRenderContent(figure);
xml.appendTagOpen("ui:figure");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
if (FigureMode.LAZY.equals(figure.getMode())) {
xml.appendOptionalAttribute("hidden", !renderChildren, "true");
} else {
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
}
FigureMode mode = figure.getMode();
if (mode != null) {
switch (mode) {
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
default:
throw new SystemException("Unknown figure mode: " + figure.getMode());
}
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(figure, renderContext);
if (renderChildren) {
// Label
figure.getDecoratedLabel().paint(renderContext);
// Content
xml.appendTagOpen("ui:content");
xml.appendAttribute("id", component.getId() + "-content");
xml.appendClose();
figure.getContent().paint(renderContext);
xml.appendEndTag("ui:content");
}
xml.appendEndTag("ui:figure");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WFigure",
"figure",
"=",
"(",
"WFigure",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"renderChildren",
"=",
"isRenderContent",
"(",
"figure",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:figure\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"FigureMode",
".",
"LAZY",
".",
"equals",
"(",
"figure",
".",
"getMode",
"(",
")",
")",
")",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"!",
"renderChildren",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"component",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"}",
"FigureMode",
"mode",
"=",
"figure",
".",
"getMode",
"(",
")",
";",
"if",
"(",
"mode",
"!=",
"null",
")",
"{",
"switch",
"(",
"mode",
")",
"{",
"case",
"LAZY",
":",
"xml",
".",
"appendAttribute",
"(",
"\"mode\"",
",",
"\"lazy\"",
")",
";",
"break",
";",
"case",
"EAGER",
":",
"xml",
".",
"appendAttribute",
"(",
"\"mode\"",
",",
"\"eager\"",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"SystemException",
"(",
"\"Unknown figure mode: \"",
"+",
"figure",
".",
"getMode",
"(",
")",
")",
";",
"}",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Render margin",
"MarginRendererUtil",
".",
"renderMargin",
"(",
"figure",
",",
"renderContext",
")",
";",
"if",
"(",
"renderChildren",
")",
"{",
"// Label",
"figure",
".",
"getDecoratedLabel",
"(",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"// Content",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:content\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
"+",
"\"-content\"",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"figure",
".",
"getContent",
"(",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:content\"",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:figure\"",
")",
";",
"}"
] | Paints the given WFigure.
@param component the WFigure to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WFigure",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFigureRenderer.java#L25-L74 |
139,593 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/AppPreferenceParameterExample.java | AppPreferenceParameterExample.preparePaintComponent | @Override
public void preparePaintComponent(final Request request) {
if (!this.isInitialised() || resetButton.isPressed()) {
String preferredState = request.getAppPreferenceParameter("example.preferred.state");
stateSelector.setSelected(preferredState);
this.setInitialised(true);
}
} | java | @Override
public void preparePaintComponent(final Request request) {
if (!this.isInitialised() || resetButton.isPressed()) {
String preferredState = request.getAppPreferenceParameter("example.preferred.state");
stateSelector.setSelected(preferredState);
this.setInitialised(true);
}
} | [
"@",
"Override",
"public",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isInitialised",
"(",
")",
"||",
"resetButton",
".",
"isPressed",
"(",
")",
")",
"{",
"String",
"preferredState",
"=",
"request",
".",
"getAppPreferenceParameter",
"(",
"\"example.preferred.state\"",
")",
";",
"stateSelector",
".",
"setSelected",
"(",
"preferredState",
")",
";",
"this",
".",
"setInitialised",
"(",
"true",
")",
";",
"}",
"}"
] | Override preparePaintComponent to set the initial selection from the app preferences. The selection is set the
first time the example is accessed or when the reset button is used.
@param request the request being responded to. | [
"Override",
"preparePaintComponent",
"to",
"set",
"the",
"initial",
"selection",
"from",
"the",
"app",
"preferences",
".",
"The",
"selection",
"is",
"set",
"the",
"first",
"time",
"the",
"example",
"is",
"accessed",
"or",
"when",
"the",
"reset",
"button",
"is",
"used",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/AppPreferenceParameterExample.java#L44-L51 |
139,594 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.addColumn | public void addColumn(final WTableColumn column) {
columns.add(column);
WDataTableRowRenderer renderer = (WDataTableRowRenderer) repeater.getRepeatedComponent();
renderer.addColumn(column, columns.getChildCount() - 1);
} | java | public void addColumn(final WTableColumn column) {
columns.add(column);
WDataTableRowRenderer renderer = (WDataTableRowRenderer) repeater.getRepeatedComponent();
renderer.addColumn(column, columns.getChildCount() - 1);
} | [
"public",
"void",
"addColumn",
"(",
"final",
"WTableColumn",
"column",
")",
"{",
"columns",
".",
"add",
"(",
"column",
")",
";",
"WDataTableRowRenderer",
"renderer",
"=",
"(",
"WDataTableRowRenderer",
")",
"repeater",
".",
"getRepeatedComponent",
"(",
")",
";",
"renderer",
".",
"addColumn",
"(",
"column",
",",
"columns",
".",
"getChildCount",
"(",
")",
"-",
"1",
")",
";",
"}"
] | Adds a column to the table.
@param column the column to add. | [
"Adds",
"a",
"column",
"to",
"the",
"table",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L249-L253 |
139,595 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.setDataModel | public void setDataModel(final TableDataModel dataModel) {
getOrCreateComponentModel().dataModel = dataModel;
getOrCreateComponentModel().rowIndexMapping = null;
if (dataModel instanceof BeanTableDataModel) {
((BeanTableDataModel) dataModel).setBeanProvider(new DataTableBeanProvider(this));
((BeanTableDataModel) dataModel).setBeanProperty(".");
}
if (dataModel instanceof ScrollableTableDataModel) {
int startIndex = getCurrentPage() * getRowsPerPage();
int endIndex = startIndex + getRowsPerPage() - 1;
((ScrollableTableDataModel) dataModel).setCurrentRows(startIndex, endIndex);
}
// Flush the repeater's row contexts and scratch maps
repeater.reset();
} | java | public void setDataModel(final TableDataModel dataModel) {
getOrCreateComponentModel().dataModel = dataModel;
getOrCreateComponentModel().rowIndexMapping = null;
if (dataModel instanceof BeanTableDataModel) {
((BeanTableDataModel) dataModel).setBeanProvider(new DataTableBeanProvider(this));
((BeanTableDataModel) dataModel).setBeanProperty(".");
}
if (dataModel instanceof ScrollableTableDataModel) {
int startIndex = getCurrentPage() * getRowsPerPage();
int endIndex = startIndex + getRowsPerPage() - 1;
((ScrollableTableDataModel) dataModel).setCurrentRows(startIndex, endIndex);
}
// Flush the repeater's row contexts and scratch maps
repeater.reset();
} | [
"public",
"void",
"setDataModel",
"(",
"final",
"TableDataModel",
"dataModel",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"dataModel",
"=",
"dataModel",
";",
"getOrCreateComponentModel",
"(",
")",
".",
"rowIndexMapping",
"=",
"null",
";",
"if",
"(",
"dataModel",
"instanceof",
"BeanTableDataModel",
")",
"{",
"(",
"(",
"BeanTableDataModel",
")",
"dataModel",
")",
".",
"setBeanProvider",
"(",
"new",
"DataTableBeanProvider",
"(",
"this",
")",
")",
";",
"(",
"(",
"BeanTableDataModel",
")",
"dataModel",
")",
".",
"setBeanProperty",
"(",
"\".\"",
")",
";",
"}",
"if",
"(",
"dataModel",
"instanceof",
"ScrollableTableDataModel",
")",
"{",
"int",
"startIndex",
"=",
"getCurrentPage",
"(",
")",
"*",
"getRowsPerPage",
"(",
")",
";",
"int",
"endIndex",
"=",
"startIndex",
"+",
"getRowsPerPage",
"(",
")",
"-",
"1",
";",
"(",
"(",
"ScrollableTableDataModel",
")",
"dataModel",
")",
".",
"setCurrentRows",
"(",
"startIndex",
",",
"endIndex",
")",
";",
"}",
"// Flush the repeater's row contexts and scratch maps",
"repeater",
".",
"reset",
"(",
")",
";",
"}"
] | Sets the data model.
@param dataModel The dataModel to set. | [
"Sets",
"the",
"data",
"model",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L320-L337 |
139,596 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.setPaginationMode | public void setPaginationMode(final PaginationMode paginationMode) {
getOrCreateComponentModel().paginationMode = PaginationMode.SERVER.equals(paginationMode) ? PaginationMode.DYNAMIC
: paginationMode;
} | java | public void setPaginationMode(final PaginationMode paginationMode) {
getOrCreateComponentModel().paginationMode = PaginationMode.SERVER.equals(paginationMode) ? PaginationMode.DYNAMIC
: paginationMode;
} | [
"public",
"void",
"setPaginationMode",
"(",
"final",
"PaginationMode",
"paginationMode",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"paginationMode",
"=",
"PaginationMode",
".",
"SERVER",
".",
"equals",
"(",
"paginationMode",
")",
"?",
"PaginationMode",
".",
"DYNAMIC",
":",
"paginationMode",
";",
"}"
] | Sets the pagination mode. Mode.SERVER mapped to Mode.DYNAMIC to overcome accessibility problem.
@param paginationMode The paginationMode to set. | [
"Sets",
"the",
"pagination",
"mode",
".",
"Mode",
".",
"SERVER",
"mapped",
"to",
"Mode",
".",
"DYNAMIC",
"to",
"overcome",
"accessibility",
"problem",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L642-L645 |
139,597 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.setExpandMode | public void setExpandMode(final ExpandMode expandMode) {
getOrCreateComponentModel().expandMode = ExpandMode.SERVER.equals(expandMode) ? ExpandMode.DYNAMIC
: expandMode;
} | java | public void setExpandMode(final ExpandMode expandMode) {
getOrCreateComponentModel().expandMode = ExpandMode.SERVER.equals(expandMode) ? ExpandMode.DYNAMIC
: expandMode;
} | [
"public",
"void",
"setExpandMode",
"(",
"final",
"ExpandMode",
"expandMode",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"expandMode",
"=",
"ExpandMode",
".",
"SERVER",
".",
"equals",
"(",
"expandMode",
")",
"?",
"ExpandMode",
".",
"DYNAMIC",
":",
"expandMode",
";",
"}"
] | Sets the row expansion mode. ExpandMode.SERVER mapped to ExpandMode.DYNAMIC to overcome accessibility problems.
@param expandMode The expand mode to set. | [
"Sets",
"the",
"row",
"expansion",
"mode",
".",
"ExpandMode",
".",
"SERVER",
"mapped",
"to",
"ExpandMode",
".",
"DYNAMIC",
"to",
"overcome",
"accessibility",
"problems",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L760-L763 |
139,598 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.handleRequest | @Override
public void handleRequest(final Request request) {
super.handleRequest(request);
if (isPresent(request)) {
if (getExpandMode() != ExpandMode.NONE) {
handleExpansionRequest(request);
}
if (getSelectMode() != SelectMode.NONE) {
handleSelectionRequest(request);
}
if (getPaginationMode() != PaginationMode.NONE) {
handlePaginationRequest(request);
}
if (isFilterable()) {
handleFilterRequest(request);
}
if (isSortable()) {
handleSortRequest(request);
}
}
} | java | @Override
public void handleRequest(final Request request) {
super.handleRequest(request);
if (isPresent(request)) {
if (getExpandMode() != ExpandMode.NONE) {
handleExpansionRequest(request);
}
if (getSelectMode() != SelectMode.NONE) {
handleSelectionRequest(request);
}
if (getPaginationMode() != PaginationMode.NONE) {
handlePaginationRequest(request);
}
if (isFilterable()) {
handleFilterRequest(request);
}
if (isSortable()) {
handleSortRequest(request);
}
}
} | [
"@",
"Override",
"public",
"void",
"handleRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"super",
".",
"handleRequest",
"(",
"request",
")",
";",
"if",
"(",
"isPresent",
"(",
"request",
")",
")",
"{",
"if",
"(",
"getExpandMode",
"(",
")",
"!=",
"ExpandMode",
".",
"NONE",
")",
"{",
"handleExpansionRequest",
"(",
"request",
")",
";",
"}",
"if",
"(",
"getSelectMode",
"(",
")",
"!=",
"SelectMode",
".",
"NONE",
")",
"{",
"handleSelectionRequest",
"(",
"request",
")",
";",
"}",
"if",
"(",
"getPaginationMode",
"(",
")",
"!=",
"PaginationMode",
".",
"NONE",
")",
"{",
"handlePaginationRequest",
"(",
"request",
")",
";",
"}",
"if",
"(",
"isFilterable",
"(",
")",
")",
"{",
"handleFilterRequest",
"(",
"request",
")",
";",
"}",
"if",
"(",
"isSortable",
"(",
")",
")",
"{",
"handleSortRequest",
"(",
"request",
")",
";",
"}",
"}",
"}"
] | Override handleRequest to add table-specific functionality such as pagination and row selection.
@param request the request being responded to. | [
"Override",
"handleRequest",
"to",
"add",
"table",
"-",
"specific",
"functionality",
"such",
"as",
"pagination",
"and",
"row",
"selection",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L972-L997 |
139,599 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.handleFilterRequest | private void handleFilterRequest(final Request request) {
String[] paramValues = request.getParameterValues(getId() + ".filters");
if (paramValues == null) {
setActiveFilters(new ArrayList<String>(0));
} else {
List<String> filters = Arrays.asList(paramValues);
setActiveFilters(filters);
}
} | java | private void handleFilterRequest(final Request request) {
String[] paramValues = request.getParameterValues(getId() + ".filters");
if (paramValues == null) {
setActiveFilters(new ArrayList<String>(0));
} else {
List<String> filters = Arrays.asList(paramValues);
setActiveFilters(filters);
}
} | [
"private",
"void",
"handleFilterRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"String",
"[",
"]",
"paramValues",
"=",
"request",
".",
"getParameterValues",
"(",
"getId",
"(",
")",
"+",
"\".filters\"",
")",
";",
"if",
"(",
"paramValues",
"==",
"null",
")",
"{",
"setActiveFilters",
"(",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"0",
")",
")",
";",
"}",
"else",
"{",
"List",
"<",
"String",
">",
"filters",
"=",
"Arrays",
".",
"asList",
"(",
"paramValues",
")",
";",
"setActiveFilters",
"(",
"filters",
")",
";",
"}",
"}"
] | Handles a request containing filtering data.
@param request the request containing filtering data. | [
"Handles",
"a",
"request",
"containing",
"filtering",
"data",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L1065-L1074 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.