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,600 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.getCurrentPageStartRow | private int getCurrentPageStartRow() {
int startRow = 0;
if (getPaginationMode() != PaginationMode.NONE) {
int rowsPerPage = getRowsPerPage();
TableDataModel model = getDataModel();
if (model instanceof TreeTableDataModel) {
// For tree tables, pagination only occurs on first-level nodes (ie. those
// underneath the root node), however they might not be consecutively
// numbered. Therefore, the start and end row indices need to be adjusted.
TreeTableDataModel treeModel = (TreeTableDataModel) model;
TreeNode root = treeModel.getNodeAtLine(0).getRoot();
int startNode = getCurrentPage() * rowsPerPage;
startRow = ((TableTreeNode) root.getChildAt(startNode)).getRowIndex() - 1; // -1 as the root is not included in the table
} else {
startRow = getCurrentPage() * rowsPerPage;
}
}
return startRow;
} | java | private int getCurrentPageStartRow() {
int startRow = 0;
if (getPaginationMode() != PaginationMode.NONE) {
int rowsPerPage = getRowsPerPage();
TableDataModel model = getDataModel();
if (model instanceof TreeTableDataModel) {
// For tree tables, pagination only occurs on first-level nodes (ie. those
// underneath the root node), however they might not be consecutively
// numbered. Therefore, the start and end row indices need to be adjusted.
TreeTableDataModel treeModel = (TreeTableDataModel) model;
TreeNode root = treeModel.getNodeAtLine(0).getRoot();
int startNode = getCurrentPage() * rowsPerPage;
startRow = ((TableTreeNode) root.getChildAt(startNode)).getRowIndex() - 1; // -1 as the root is not included in the table
} else {
startRow = getCurrentPage() * rowsPerPage;
}
}
return startRow;
} | [
"private",
"int",
"getCurrentPageStartRow",
"(",
")",
"{",
"int",
"startRow",
"=",
"0",
";",
"if",
"(",
"getPaginationMode",
"(",
")",
"!=",
"PaginationMode",
".",
"NONE",
")",
"{",
"int",
"rowsPerPage",
"=",
"getRowsPerPage",
"(",
")",
";",
"TableDataModel",
"model",
"=",
"getDataModel",
"(",
")",
";",
"if",
"(",
"model",
"instanceof",
"TreeTableDataModel",
")",
"{",
"// For tree tables, pagination only occurs on first-level nodes (ie. those",
"// underneath the root node), however they might not be consecutively",
"// numbered. Therefore, the start and end row indices need to be adjusted.",
"TreeTableDataModel",
"treeModel",
"=",
"(",
"TreeTableDataModel",
")",
"model",
";",
"TreeNode",
"root",
"=",
"treeModel",
".",
"getNodeAtLine",
"(",
"0",
")",
".",
"getRoot",
"(",
")",
";",
"int",
"startNode",
"=",
"getCurrentPage",
"(",
")",
"*",
"rowsPerPage",
";",
"startRow",
"=",
"(",
"(",
"TableTreeNode",
")",
"root",
".",
"getChildAt",
"(",
"startNode",
")",
")",
".",
"getRowIndex",
"(",
")",
"-",
"1",
";",
"// -1 as the root is not included in the table",
"}",
"else",
"{",
"startRow",
"=",
"getCurrentPage",
"(",
")",
"*",
"rowsPerPage",
";",
"}",
"}",
"return",
"startRow",
";",
"}"
] | Retrieves the starting row index for the current page. Will always return zero for tables which are not
paginated.
@return the starting row index for the current page. | [
"Retrieves",
"the",
"starting",
"row",
"index",
"for",
"the",
"current",
"page",
".",
"Will",
"always",
"return",
"zero",
"for",
"tables",
"which",
"are",
"not",
"paginated",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L1141-L1163 |
139,601 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java | WDataTable.getCurrentPageEndRow | private int getCurrentPageEndRow() {
TableDataModel model = getDataModel();
int rowsPerPage = getRowsPerPage();
int endRow = model.getRowCount() - 1;
if (getPaginationMode() != PaginationMode.NONE) {
if (model instanceof TreeTableDataModel) {
// For tree tables, pagination only occurs on first-level nodes (ie. those
// underneath the root node), however they might not be consecutively
// numbered. Therefore, the start and end row indices need to be adjusted.
TreeTableDataModel treeModel = (TreeTableDataModel) model;
TreeNode root = treeModel.getNodeAtLine(0).getRoot();
int endNode = Math.min(root.getChildCount() - 1,
(getCurrentPage() + 1) * rowsPerPage - 1);
endRow = ((TableTreeNode) root.getChildAt(endNode)).getRowIndex() - 1 // -1 as the root is not included in the table
+ ((TableTreeNode) root.getChildAt(endNode)).getNodeCount();
} else {
endRow = Math.min(model.getRowCount() - 1, (getCurrentPage() + 1) * rowsPerPage - 1);
}
}
return endRow;
} | java | private int getCurrentPageEndRow() {
TableDataModel model = getDataModel();
int rowsPerPage = getRowsPerPage();
int endRow = model.getRowCount() - 1;
if (getPaginationMode() != PaginationMode.NONE) {
if (model instanceof TreeTableDataModel) {
// For tree tables, pagination only occurs on first-level nodes (ie. those
// underneath the root node), however they might not be consecutively
// numbered. Therefore, the start and end row indices need to be adjusted.
TreeTableDataModel treeModel = (TreeTableDataModel) model;
TreeNode root = treeModel.getNodeAtLine(0).getRoot();
int endNode = Math.min(root.getChildCount() - 1,
(getCurrentPage() + 1) * rowsPerPage - 1);
endRow = ((TableTreeNode) root.getChildAt(endNode)).getRowIndex() - 1 // -1 as the root is not included in the table
+ ((TableTreeNode) root.getChildAt(endNode)).getNodeCount();
} else {
endRow = Math.min(model.getRowCount() - 1, (getCurrentPage() + 1) * rowsPerPage - 1);
}
}
return endRow;
} | [
"private",
"int",
"getCurrentPageEndRow",
"(",
")",
"{",
"TableDataModel",
"model",
"=",
"getDataModel",
"(",
")",
";",
"int",
"rowsPerPage",
"=",
"getRowsPerPage",
"(",
")",
";",
"int",
"endRow",
"=",
"model",
".",
"getRowCount",
"(",
")",
"-",
"1",
";",
"if",
"(",
"getPaginationMode",
"(",
")",
"!=",
"PaginationMode",
".",
"NONE",
")",
"{",
"if",
"(",
"model",
"instanceof",
"TreeTableDataModel",
")",
"{",
"// For tree tables, pagination only occurs on first-level nodes (ie. those",
"// underneath the root node), however they might not be consecutively",
"// numbered. Therefore, the start and end row indices need to be adjusted.",
"TreeTableDataModel",
"treeModel",
"=",
"(",
"TreeTableDataModel",
")",
"model",
";",
"TreeNode",
"root",
"=",
"treeModel",
".",
"getNodeAtLine",
"(",
"0",
")",
".",
"getRoot",
"(",
")",
";",
"int",
"endNode",
"=",
"Math",
".",
"min",
"(",
"root",
".",
"getChildCount",
"(",
")",
"-",
"1",
",",
"(",
"getCurrentPage",
"(",
")",
"+",
"1",
")",
"*",
"rowsPerPage",
"-",
"1",
")",
";",
"endRow",
"=",
"(",
"(",
"TableTreeNode",
")",
"root",
".",
"getChildAt",
"(",
"endNode",
")",
")",
".",
"getRowIndex",
"(",
")",
"-",
"1",
"// -1 as the root is not included in the table",
"+",
"(",
"(",
"TableTreeNode",
")",
"root",
".",
"getChildAt",
"(",
"endNode",
")",
")",
".",
"getNodeCount",
"(",
")",
";",
"}",
"else",
"{",
"endRow",
"=",
"Math",
".",
"min",
"(",
"model",
".",
"getRowCount",
"(",
")",
"-",
"1",
",",
"(",
"getCurrentPage",
"(",
")",
"+",
"1",
")",
"*",
"rowsPerPage",
"-",
"1",
")",
";",
"}",
"}",
"return",
"endRow",
";",
"}"
] | Retrieves the ending row index for the current page. Will always return the row count minus 1 for tables which
are not paginated.
@return the starting row index for the current page. | [
"Retrieves",
"the",
"ending",
"row",
"index",
"for",
"the",
"current",
"page",
".",
"Will",
"always",
"return",
"the",
"row",
"count",
"minus",
"1",
"for",
"tables",
"which",
"are",
"not",
"paginated",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTable.java#L1171-L1195 |
139,602 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/FatalErrorPage.java | FatalErrorPage.paintComponent | @Override
protected void paintComponent(final RenderContext renderContext) {
if (renderContext instanceof WebXmlRenderContext) {
PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();
writer.println(getMessage());
if (developerFriendly) {
writer.println("<pre style=\"background: lightgrey\">");
writer.println("Additional details for the developer:");
writer.println();
error.printStackTrace(writer);
writer.println("</pre>");
}
}
} | java | @Override
protected void paintComponent(final RenderContext renderContext) {
if (renderContext instanceof WebXmlRenderContext) {
PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();
writer.println(getMessage());
if (developerFriendly) {
writer.println("<pre style=\"background: lightgrey\">");
writer.println("Additional details for the developer:");
writer.println();
error.printStackTrace(writer);
writer.println("</pre>");
}
}
} | [
"@",
"Override",
"protected",
"void",
"paintComponent",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"if",
"(",
"renderContext",
"instanceof",
"WebXmlRenderContext",
")",
"{",
"PrintWriter",
"writer",
"=",
"(",
"(",
"WebXmlRenderContext",
")",
"renderContext",
")",
".",
"getWriter",
"(",
")",
";",
"writer",
".",
"println",
"(",
"getMessage",
"(",
")",
")",
";",
"if",
"(",
"developerFriendly",
")",
"{",
"writer",
".",
"println",
"(",
"\"<pre style=\\\"background: lightgrey\\\">\"",
")",
";",
"writer",
".",
"println",
"(",
"\"Additional details for the developer:\"",
")",
";",
"writer",
".",
"println",
"(",
")",
";",
"error",
".",
"printStackTrace",
"(",
"writer",
")",
";",
"writer",
".",
"println",
"(",
"\"</pre>\"",
")",
";",
"}",
"}",
"}"
] | Renders this FatalErrorPage.
@param renderContext the RenderContext to send the rendered output to. | [
"Renders",
"this",
"FatalErrorPage",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/FatalErrorPage.java#L51-L65 |
139,603 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLabel.java | WLabel.setText | public void setText(final String text, final Serializable... args) {
Serializable currText = getComponentModel().text;
Serializable textToBeSet = I18nUtilities.asMessage(text, args);
if (!Objects.equals(textToBeSet, currText)) {
getOrCreateComponentModel().text = textToBeSet;
}
} | java | public void setText(final String text, final Serializable... args) {
Serializable currText = getComponentModel().text;
Serializable textToBeSet = I18nUtilities.asMessage(text, args);
if (!Objects.equals(textToBeSet, currText)) {
getOrCreateComponentModel().text = textToBeSet;
}
} | [
"public",
"void",
"setText",
"(",
"final",
"String",
"text",
",",
"final",
"Serializable",
"...",
"args",
")",
"{",
"Serializable",
"currText",
"=",
"getComponentModel",
"(",
")",
".",
"text",
";",
"Serializable",
"textToBeSet",
"=",
"I18nUtilities",
".",
"asMessage",
"(",
"text",
",",
"args",
")",
";",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"textToBeSet",
",",
"currText",
")",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"text",
"=",
"textToBeSet",
";",
"}",
"}"
] | Sets the label's text.
@param text the label text, using {@link MessageFormat} syntax.
@param args optional arguments for the message format string. | [
"Sets",
"the",
"label",
"s",
"text",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLabel.java#L113-L120 |
139,604 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLabel.java | WLabel.setHint | public void setHint(final String hint, final Serializable... args) {
Serializable currHint = getComponentModel().hint;
Serializable hintToBeSet = I18nUtilities.asMessage(hint, args);
if (!Objects.equals(hintToBeSet, currHint)) {
getOrCreateComponentModel().hint = hintToBeSet;
}
} | java | public void setHint(final String hint, final Serializable... args) {
Serializable currHint = getComponentModel().hint;
Serializable hintToBeSet = I18nUtilities.asMessage(hint, args);
if (!Objects.equals(hintToBeSet, currHint)) {
getOrCreateComponentModel().hint = hintToBeSet;
}
} | [
"public",
"void",
"setHint",
"(",
"final",
"String",
"hint",
",",
"final",
"Serializable",
"...",
"args",
")",
"{",
"Serializable",
"currHint",
"=",
"getComponentModel",
"(",
")",
".",
"hint",
";",
"Serializable",
"hintToBeSet",
"=",
"I18nUtilities",
".",
"asMessage",
"(",
"hint",
",",
"args",
")",
";",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"hintToBeSet",
",",
"currHint",
")",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"hint",
"=",
"hintToBeSet",
";",
"}",
"}"
] | Sets the label "hint" text, which can be used to provide additional information to the user.
@param hint the hint text, using {@link MessageFormat} syntax.
@param args optional arguments for the message format string. | [
"Sets",
"the",
"label",
"hint",
"text",
"which",
"can",
"be",
"used",
"to",
"provide",
"additional",
"information",
"to",
"the",
"user",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLabel.java#L128-L135 |
139,605 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLabel.java | WLabel.setForComponent | public void setForComponent(final WComponent forComponent) {
getOrCreateComponentModel().forComponent = forComponent;
if (forComponent instanceof AbstractWComponent) {
((AbstractWComponent) forComponent).setLabel(this);
}
} | java | public void setForComponent(final WComponent forComponent) {
getOrCreateComponentModel().forComponent = forComponent;
if (forComponent instanceof AbstractWComponent) {
((AbstractWComponent) forComponent).setLabel(this);
}
} | [
"public",
"void",
"setForComponent",
"(",
"final",
"WComponent",
"forComponent",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"forComponent",
"=",
"forComponent",
";",
"if",
"(",
"forComponent",
"instanceof",
"AbstractWComponent",
")",
"{",
"(",
"(",
"AbstractWComponent",
")",
"forComponent",
")",
".",
"setLabel",
"(",
"this",
")",
";",
"}",
"}"
] | Sets the component that this label is associated with.
@param forComponent the associated component. | [
"Sets",
"the",
"component",
"that",
"this",
"label",
"is",
"associated",
"with",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLabel.java#L149-L155 |
139,606 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/ajax/AjaxWRepeaterExample.java | AjaxWRepeaterExample.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
if (!isInitialised()) {
repeat.setData(getNames());
setInitialised(true);
}
} | java | @Override
protected void preparePaintComponent(final Request request) {
if (!isInitialised()) {
repeat.setData(getNames());
setInitialised(true);
}
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"if",
"(",
"!",
"isInitialised",
"(",
")",
")",
"{",
"repeat",
".",
"setData",
"(",
"getNames",
"(",
")",
")",
";",
"setInitialised",
"(",
"true",
")",
";",
"}",
"}"
] | Initialise the WRepeater data.
@param request the request being processed | [
"Initialise",
"the",
"WRepeater",
"data",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/ajax/AjaxWRepeaterExample.java#L77-L83 |
139,607 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/TextDuplicator.java | TextDuplicator.setupUI | private void setupUI(final String labelText) {
WButton dupBtn = new WButton("Duplicate");
dupBtn.setAction(new DuplicateAction());
WButton clrBtn = new WButton("Clear");
clrBtn.setAction(new ClearAction());
add(new WLabel(labelText, textFld));
add(textFld);
add(dupBtn);
add(clrBtn);
add(new WAjaxControl(dupBtn, this));
add(new WAjaxControl(clrBtn, this));
} | java | private void setupUI(final String labelText) {
WButton dupBtn = new WButton("Duplicate");
dupBtn.setAction(new DuplicateAction());
WButton clrBtn = new WButton("Clear");
clrBtn.setAction(new ClearAction());
add(new WLabel(labelText, textFld));
add(textFld);
add(dupBtn);
add(clrBtn);
add(new WAjaxControl(dupBtn, this));
add(new WAjaxControl(clrBtn, this));
} | [
"private",
"void",
"setupUI",
"(",
"final",
"String",
"labelText",
")",
"{",
"WButton",
"dupBtn",
"=",
"new",
"WButton",
"(",
"\"Duplicate\"",
")",
";",
"dupBtn",
".",
"setAction",
"(",
"new",
"DuplicateAction",
"(",
")",
")",
";",
"WButton",
"clrBtn",
"=",
"new",
"WButton",
"(",
"\"Clear\"",
")",
";",
"clrBtn",
".",
"setAction",
"(",
"new",
"ClearAction",
"(",
")",
")",
";",
"add",
"(",
"new",
"WLabel",
"(",
"labelText",
",",
"textFld",
")",
")",
";",
"add",
"(",
"textFld",
")",
";",
"add",
"(",
"dupBtn",
")",
";",
"add",
"(",
"clrBtn",
")",
";",
"add",
"(",
"new",
"WAjaxControl",
"(",
"dupBtn",
",",
"this",
")",
")",
";",
"add",
"(",
"new",
"WAjaxControl",
"(",
"clrBtn",
",",
"this",
")",
")",
";",
"}"
] | Add the controls to the UI.
@param labelText the text to show in the duplicator field's label. | [
"Add",
"the",
"controls",
"to",
"the",
"UI",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/TextDuplicator.java#L48-L61 |
139,608 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java | MenuPanel.addRecentExample | private void addRecentExample(final String text, final ExampleData data, final boolean select) {
WMenuItem item = new WMenuItem(text, new SelectExampleAction());
item.setCancel(true);
menu.add(item);
item.setActionObject(data);
if (select) {
menu.setSelectedMenuItem(item);
}
} | java | private void addRecentExample(final String text, final ExampleData data, final boolean select) {
WMenuItem item = new WMenuItem(text, new SelectExampleAction());
item.setCancel(true);
menu.add(item);
item.setActionObject(data);
if (select) {
menu.setSelectedMenuItem(item);
}
} | [
"private",
"void",
"addRecentExample",
"(",
"final",
"String",
"text",
",",
"final",
"ExampleData",
"data",
",",
"final",
"boolean",
"select",
")",
"{",
"WMenuItem",
"item",
"=",
"new",
"WMenuItem",
"(",
"text",
",",
"new",
"SelectExampleAction",
"(",
")",
")",
";",
"item",
".",
"setCancel",
"(",
"true",
")",
";",
"menu",
".",
"add",
"(",
"item",
")",
";",
"item",
".",
"setActionObject",
"(",
"data",
")",
";",
"if",
"(",
"select",
")",
"{",
"menu",
".",
"setSelectedMenuItem",
"(",
"item",
")",
";",
"}",
"}"
] | Adds an example to the recent subMenu.
@param text the text to display.
@param data the example data instance
@param select should the menuItem be selected | [
"Adds",
"an",
"example",
"to",
"the",
"recent",
"subMenu",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L119-L127 |
139,609 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java | MenuPanel.getMatch | private ExampleData getMatch(final WComponent node, final String name, final boolean partial) {
if (node instanceof WMenuItem) {
ExampleData data = (ExampleData) ((WMenuItem) node).getActionObject();
Class<? extends WComponent> clazz = data.getExampleClass();
if (clazz.getName().equals(name) || data.getExampleName().equals(name)
|| (partial && clazz.getSimpleName().toLowerCase().contains(name.toLowerCase()))
|| (partial && data.getExampleName().toLowerCase().contains(name.toLowerCase()))) {
return data;
}
} else if (node instanceof Container) {
for (int i = 0; i < ((Container) node).getChildCount(); i++) {
ExampleData result = getMatch(((Container) node).getChildAt(i), name, partial);
if (result != null) {
return result;
}
}
}
return null;
} | java | private ExampleData getMatch(final WComponent node, final String name, final boolean partial) {
if (node instanceof WMenuItem) {
ExampleData data = (ExampleData) ((WMenuItem) node).getActionObject();
Class<? extends WComponent> clazz = data.getExampleClass();
if (clazz.getName().equals(name) || data.getExampleName().equals(name)
|| (partial && clazz.getSimpleName().toLowerCase().contains(name.toLowerCase()))
|| (partial && data.getExampleName().toLowerCase().contains(name.toLowerCase()))) {
return data;
}
} else if (node instanceof Container) {
for (int i = 0; i < ((Container) node).getChildCount(); i++) {
ExampleData result = getMatch(((Container) node).getChildAt(i), name, partial);
if (result != null) {
return result;
}
}
}
return null;
} | [
"private",
"ExampleData",
"getMatch",
"(",
"final",
"WComponent",
"node",
",",
"final",
"String",
"name",
",",
"final",
"boolean",
"partial",
")",
"{",
"if",
"(",
"node",
"instanceof",
"WMenuItem",
")",
"{",
"ExampleData",
"data",
"=",
"(",
"ExampleData",
")",
"(",
"(",
"WMenuItem",
")",
"node",
")",
".",
"getActionObject",
"(",
")",
";",
"Class",
"<",
"?",
"extends",
"WComponent",
">",
"clazz",
"=",
"data",
".",
"getExampleClass",
"(",
")",
";",
"if",
"(",
"clazz",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
"||",
"data",
".",
"getExampleName",
"(",
")",
".",
"equals",
"(",
"name",
")",
"||",
"(",
"partial",
"&&",
"clazz",
".",
"getSimpleName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
")",
"||",
"(",
"partial",
"&&",
"data",
".",
"getExampleName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
")",
")",
"{",
"return",
"data",
";",
"}",
"}",
"else",
"if",
"(",
"node",
"instanceof",
"Container",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"(",
"Container",
")",
"node",
")",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"ExampleData",
"result",
"=",
"getMatch",
"(",
"(",
"(",
"Container",
")",
"node",
")",
".",
"getChildAt",
"(",
"i",
")",
",",
"name",
",",
"partial",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Recursively searches the menu for a match to a WComponent with the given name.
@param node the current node in the menu being searched.
@param name the component class name to search for.
@param partial if true, perform a case-insensitive partial name search.
@return the class for the given name, or null if not found. | [
"Recursively",
"searches",
"the",
"menu",
"for",
"a",
"match",
"to",
"a",
"WComponent",
"with",
"the",
"given",
"name",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L172-L194 |
139,610 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java | MenuPanel.loadRecentList | private void loadRecentList() {
recent.clear();
File file = new File(RECENT_FILE_NAME);
if (file.exists()) {
try {
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
XMLDecoder decoder = new XMLDecoder(inputStream);
List result = (List) decoder.readObject();
decoder.close();
for (Object obj : result) {
if (obj instanceof ExampleData) {
recent.add((ExampleData) obj);
}
}
} catch (IOException ex) {
LogFactory.getLog(getClass()).error("Unable to load recent list", ex);
}
}
} | java | private void loadRecentList() {
recent.clear();
File file = new File(RECENT_FILE_NAME);
if (file.exists()) {
try {
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
XMLDecoder decoder = new XMLDecoder(inputStream);
List result = (List) decoder.readObject();
decoder.close();
for (Object obj : result) {
if (obj instanceof ExampleData) {
recent.add((ExampleData) obj);
}
}
} catch (IOException ex) {
LogFactory.getLog(getClass()).error("Unable to load recent list", ex);
}
}
} | [
"private",
"void",
"loadRecentList",
"(",
")",
"{",
"recent",
".",
"clear",
"(",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"RECENT_FILE_NAME",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"InputStream",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
";",
"XMLDecoder",
"decoder",
"=",
"new",
"XMLDecoder",
"(",
"inputStream",
")",
";",
"List",
"result",
"=",
"(",
"List",
")",
"decoder",
".",
"readObject",
"(",
")",
";",
"decoder",
".",
"close",
"(",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"result",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"ExampleData",
")",
"{",
"recent",
".",
"add",
"(",
"(",
"ExampleData",
")",
"obj",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LogFactory",
".",
"getLog",
"(",
"getClass",
"(",
")",
")",
".",
"error",
"(",
"\"Unable to load recent list\"",
",",
"ex",
")",
";",
"}",
"}",
"}"
] | Reads the list of recently selected examples from a file on the file system. | [
"Reads",
"the",
"list",
"of",
"recently",
"selected",
"examples",
"from",
"a",
"file",
"on",
"the",
"file",
"system",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L199-L219 |
139,611 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java | MenuPanel.storeRecentList | private void storeRecentList() {
synchronized (recent) {
try {
OutputStream out = new BufferedOutputStream(new FileOutputStream(RECENT_FILE_NAME));
XMLEncoder encoder = new XMLEncoder(out);
encoder.writeObject(recent);
encoder.close();
} catch (IOException ex) {
LogFactory.getLog(getClass()).error("Unable to save recent list", ex);
}
}
} | java | private void storeRecentList() {
synchronized (recent) {
try {
OutputStream out = new BufferedOutputStream(new FileOutputStream(RECENT_FILE_NAME));
XMLEncoder encoder = new XMLEncoder(out);
encoder.writeObject(recent);
encoder.close();
} catch (IOException ex) {
LogFactory.getLog(getClass()).error("Unable to save recent list", ex);
}
}
} | [
"private",
"void",
"storeRecentList",
"(",
")",
"{",
"synchronized",
"(",
"recent",
")",
"{",
"try",
"{",
"OutputStream",
"out",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"RECENT_FILE_NAME",
")",
")",
";",
"XMLEncoder",
"encoder",
"=",
"new",
"XMLEncoder",
"(",
"out",
")",
";",
"encoder",
".",
"writeObject",
"(",
"recent",
")",
";",
"encoder",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LogFactory",
".",
"getLog",
"(",
"getClass",
"(",
")",
")",
".",
"error",
"(",
"\"Unable to save recent list\"",
",",
"ex",
")",
";",
"}",
"}",
"}"
] | Writes the list of recent selections to a file on the file system. | [
"Writes",
"the",
"list",
"of",
"recent",
"selections",
"to",
"a",
"file",
"on",
"the",
"file",
"system",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L224-L235 |
139,612 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java | MenuPanel.addToRecent | public void addToRecent(final ExampleData example) {
synchronized (recent) {
recent.remove(example); // only add it once
recent.add(0, example);
// Only keep the last few entries.
while (recent.size() > MAX_RECENT_ITEMS) {
recent.remove(MAX_RECENT_ITEMS);
}
storeRecentList();
setInitialised(false);
}
} | java | public void addToRecent(final ExampleData example) {
synchronized (recent) {
recent.remove(example); // only add it once
recent.add(0, example);
// Only keep the last few entries.
while (recent.size() > MAX_RECENT_ITEMS) {
recent.remove(MAX_RECENT_ITEMS);
}
storeRecentList();
setInitialised(false);
}
} | [
"public",
"void",
"addToRecent",
"(",
"final",
"ExampleData",
"example",
")",
"{",
"synchronized",
"(",
"recent",
")",
"{",
"recent",
".",
"remove",
"(",
"example",
")",
";",
"// only add it once",
"recent",
".",
"add",
"(",
"0",
",",
"example",
")",
";",
"// Only keep the last few entries.",
"while",
"(",
"recent",
".",
"size",
"(",
")",
">",
"MAX_RECENT_ITEMS",
")",
"{",
"recent",
".",
"remove",
"(",
"MAX_RECENT_ITEMS",
")",
";",
"}",
"storeRecentList",
"(",
")",
";",
"setInitialised",
"(",
"false",
")",
";",
"}",
"}"
] | Adds an example to the list of recently accessed examples. The list of recently examples will be persisted to the
file system.
@param example the data for the recently accessed example. | [
"Adds",
"an",
"example",
"to",
"the",
"list",
"of",
"recently",
"accessed",
"examples",
".",
"The",
"list",
"of",
"recently",
"examples",
"will",
"be",
"persisted",
"to",
"the",
"file",
"system",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L243-L256 |
139,613 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java | MenuPanel.updateRecentMenu | private void updateRecentMenu() {
menu.removeAllMenuItems();
int index = 1;
boolean first = true;
for (Iterator<ExampleData> i = recent.iterator(); i.hasNext();) {
ExampleData data = i.next();
try {
StringBuilder builder = new StringBuilder(Integer.toString(index++)).append(". ");
if (data.getExampleGroupName() != null) {
builder.append(data.getExampleGroupName()).append(" - ");
}
builder.append(data.getExampleName());
addRecentExample(builder.toString(), data, first);
first = false;
} catch (Exception e) {
i.remove();
LogFactory.getLog(getClass()).error("Unable to read recent class: " + data.getExampleName());
}
}
} | java | private void updateRecentMenu() {
menu.removeAllMenuItems();
int index = 1;
boolean first = true;
for (Iterator<ExampleData> i = recent.iterator(); i.hasNext();) {
ExampleData data = i.next();
try {
StringBuilder builder = new StringBuilder(Integer.toString(index++)).append(". ");
if (data.getExampleGroupName() != null) {
builder.append(data.getExampleGroupName()).append(" - ");
}
builder.append(data.getExampleName());
addRecentExample(builder.toString(), data, first);
first = false;
} catch (Exception e) {
i.remove();
LogFactory.getLog(getClass()).error("Unable to read recent class: " + data.getExampleName());
}
}
} | [
"private",
"void",
"updateRecentMenu",
"(",
")",
"{",
"menu",
".",
"removeAllMenuItems",
"(",
")",
";",
"int",
"index",
"=",
"1",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"Iterator",
"<",
"ExampleData",
">",
"i",
"=",
"recent",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ExampleData",
"data",
"=",
"i",
".",
"next",
"(",
")",
";",
"try",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"Integer",
".",
"toString",
"(",
"index",
"++",
")",
")",
".",
"append",
"(",
"\". \"",
")",
";",
"if",
"(",
"data",
".",
"getExampleGroupName",
"(",
")",
"!=",
"null",
")",
"{",
"builder",
".",
"append",
"(",
"data",
".",
"getExampleGroupName",
"(",
")",
")",
".",
"append",
"(",
"\" - \"",
")",
";",
"}",
"builder",
".",
"append",
"(",
"data",
".",
"getExampleName",
"(",
")",
")",
";",
"addRecentExample",
"(",
"builder",
".",
"toString",
"(",
")",
",",
"data",
",",
"first",
")",
";",
"first",
"=",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"i",
".",
"remove",
"(",
")",
";",
"LogFactory",
".",
"getLog",
"(",
"getClass",
"(",
")",
")",
".",
"error",
"(",
"\"Unable to read recent class: \"",
"+",
"data",
".",
"getExampleName",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Updates the entries in the "Recent" sub-menu. | [
"Updates",
"the",
"entries",
"in",
"the",
"Recent",
"sub",
"-",
"menu",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/MenuPanel.java#L261-L285 |
139,614 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTab.java | WTab.setContent | public void setContent(final WComponent content) {
WComponent oldContent = getContent();
if (oldContent != null) {
remove(oldContent);
}
if (content != null) {
add(content);
}
} | java | public void setContent(final WComponent content) {
WComponent oldContent = getContent();
if (oldContent != null) {
remove(oldContent);
}
if (content != null) {
add(content);
}
} | [
"public",
"void",
"setContent",
"(",
"final",
"WComponent",
"content",
")",
"{",
"WComponent",
"oldContent",
"=",
"getContent",
"(",
")",
";",
"if",
"(",
"oldContent",
"!=",
"null",
")",
"{",
"remove",
"(",
"oldContent",
")",
";",
"}",
"if",
"(",
"content",
"!=",
"null",
")",
"{",
"add",
"(",
"content",
")",
";",
"}",
"}"
] | Sets the tab content.
@param content the tab content. | [
"Sets",
"the",
"tab",
"content",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTab.java#L101-L111 |
139,615 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTab.java | WTab.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
WComponent content = getContent();
if (content != null) {
switch (getMode()) {
case EAGER: {
// Will always be visible
content.setVisible(true);
AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
break;
}
case LAZY: {
content.setVisible(isOpen());
if (!isOpen()) {
AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
}
break;
}
case DYNAMIC: {
content.setVisible(isOpen());
AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
break;
}
case SERVER: {
content.setVisible(isOpen());
break;
}
case CLIENT: {
// Will always be visible
content.setVisible(true);
break;
}
default:
// do nothing.
break;
}
}
} | java | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
WComponent content = getContent();
if (content != null) {
switch (getMode()) {
case EAGER: {
// Will always be visible
content.setVisible(true);
AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
break;
}
case LAZY: {
content.setVisible(isOpen());
if (!isOpen()) {
AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
}
break;
}
case DYNAMIC: {
content.setVisible(isOpen());
AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
break;
}
case SERVER: {
content.setVisible(isOpen());
break;
}
case CLIENT: {
// Will always be visible
content.setVisible(true);
break;
}
default:
// do nothing.
break;
}
}
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"super",
".",
"preparePaintComponent",
"(",
"request",
")",
";",
"WComponent",
"content",
"=",
"getContent",
"(",
")",
";",
"if",
"(",
"content",
"!=",
"null",
")",
"{",
"switch",
"(",
"getMode",
"(",
")",
")",
"{",
"case",
"EAGER",
":",
"{",
"// Will always be visible",
"content",
".",
"setVisible",
"(",
"true",
")",
";",
"AjaxHelper",
".",
"registerContainer",
"(",
"getId",
"(",
")",
",",
"getId",
"(",
")",
"+",
"\"-content\"",
",",
"content",
".",
"getId",
"(",
")",
")",
";",
"break",
";",
"}",
"case",
"LAZY",
":",
"{",
"content",
".",
"setVisible",
"(",
"isOpen",
"(",
")",
")",
";",
"if",
"(",
"!",
"isOpen",
"(",
")",
")",
"{",
"AjaxHelper",
".",
"registerContainer",
"(",
"getId",
"(",
")",
",",
"getId",
"(",
")",
"+",
"\"-content\"",
",",
"content",
".",
"getId",
"(",
")",
")",
";",
"}",
"break",
";",
"}",
"case",
"DYNAMIC",
":",
"{",
"content",
".",
"setVisible",
"(",
"isOpen",
"(",
")",
")",
";",
"AjaxHelper",
".",
"registerContainer",
"(",
"getId",
"(",
")",
",",
"getId",
"(",
")",
"+",
"\"-content\"",
",",
"content",
".",
"getId",
"(",
")",
")",
";",
"break",
";",
"}",
"case",
"SERVER",
":",
"{",
"content",
".",
"setVisible",
"(",
"isOpen",
"(",
")",
")",
";",
"break",
";",
"}",
"case",
"CLIENT",
":",
"{",
"// Will always be visible",
"content",
".",
"setVisible",
"(",
"true",
")",
";",
"break",
";",
"}",
"default",
":",
"// do nothing.",
"break",
";",
"}",
"}",
"}"
] | Override preparePaintComponent in order to correct the visibility of the tab's content before it is rendered.
@param request the request being responded to. | [
"Override",
"preparePaintComponent",
"in",
"order",
"to",
"correct",
"the",
"visibility",
"of",
"the",
"tab",
"s",
"content",
"before",
"it",
"is",
"rendered",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTab.java#L185-L226 |
139,616 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.createSpace | public SpaceCreateResponse createSpace(SpaceCreate data) {
return getResourceFactory().getApiResource("/space/")
.entity(data, MediaType.APPLICATION_JSON_TYPE)
.post(SpaceCreateResponse.class);
} | java | public SpaceCreateResponse createSpace(SpaceCreate data) {
return getResourceFactory().getApiResource("/space/")
.entity(data, MediaType.APPLICATION_JSON_TYPE)
.post(SpaceCreateResponse.class);
} | [
"public",
"SpaceCreateResponse",
"createSpace",
"(",
"SpaceCreate",
"data",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/\"",
")",
".",
"entity",
"(",
"data",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"post",
"(",
"SpaceCreateResponse",
".",
"class",
")",
";",
"}"
] | Add a new space to an organization.
@param data
The data for the new space
@return The data about the new created space | [
"Add",
"a",
"new",
"space",
"to",
"an",
"organization",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L27-L31 |
139,617 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.updateSpace | public void updateSpace(int spaceId, SpaceUpdate data) {
getResourceFactory().getApiResource("/space/" + spaceId)
.entity(data, MediaType.APPLICATION_JSON_TYPE).put();
} | java | public void updateSpace(int spaceId, SpaceUpdate data) {
getResourceFactory().getApiResource("/space/" + spaceId)
.entity(data, MediaType.APPLICATION_JSON_TYPE).put();
} | [
"public",
"void",
"updateSpace",
"(",
"int",
"spaceId",
",",
"SpaceUpdate",
"data",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/\"",
"+",
"spaceId",
")",
".",
"entity",
"(",
"data",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"put",
"(",
")",
";",
"}"
] | Updates the space with the given id
@param spaceId
The id of the space to update
@param data
The updated data of the space | [
"Updates",
"the",
"space",
"with",
"the",
"given",
"id"
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L53-L56 |
139,618 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.getSpaceByURL | public SpaceWithOrganization getSpaceByURL(String url) {
return getResourceFactory().getApiResource("/space/url")
.queryParam("url", url).get(SpaceWithOrganization.class);
} | java | public SpaceWithOrganization getSpaceByURL(String url) {
return getResourceFactory().getApiResource("/space/url")
.queryParam("url", url).get(SpaceWithOrganization.class);
} | [
"public",
"SpaceWithOrganization",
"getSpaceByURL",
"(",
"String",
"url",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/url\"",
")",
".",
"queryParam",
"(",
"\"url\"",
",",
"url",
")",
".",
"get",
"(",
"SpaceWithOrganization",
".",
"class",
")",
";",
"}"
] | Returns the space and organization with the given full URL.
@param url
The full URL of the space
@return The space with organization | [
"Returns",
"the",
"space",
"and",
"organization",
"with",
"the",
"given",
"full",
"URL",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L65-L68 |
139,619 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.getSpaceMembership | public SpaceMember getSpaceMembership(int spaceId, int userId) {
return getResourceFactory().getApiResource(
"/space/" + spaceId + "/member/" + userId).get(
SpaceMember.class);
} | java | public SpaceMember getSpaceMembership(int spaceId, int userId) {
return getResourceFactory().getApiResource(
"/space/" + spaceId + "/member/" + userId).get(
SpaceMember.class);
} | [
"public",
"SpaceMember",
"getSpaceMembership",
"(",
"int",
"spaceId",
",",
"int",
"userId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/\"",
"+",
"spaceId",
"+",
"\"/member/\"",
"+",
"userId",
")",
".",
"get",
"(",
"SpaceMember",
".",
"class",
")",
";",
"}"
] | Used to get the details of an active users membership of a space.
@param spaceId
The id of the space
@param userId
The ud of the user
@return The details about the space membership | [
"Used",
"to",
"get",
"the",
"details",
"of",
"an",
"active",
"users",
"membership",
"of",
"a",
"space",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L94-L98 |
139,620 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.updateSpaceMembership | public void updateSpaceMembership(int spaceId, int userId, Role role) {
getResourceFactory()
.getApiResource("/space/" + spaceId + "/member/" + userId)
.entity(new SpaceMemberUpdate(role),
MediaType.APPLICATION_JSON_TYPE).put();
} | java | public void updateSpaceMembership(int spaceId, int userId, Role role) {
getResourceFactory()
.getApiResource("/space/" + spaceId + "/member/" + userId)
.entity(new SpaceMemberUpdate(role),
MediaType.APPLICATION_JSON_TYPE).put();
} | [
"public",
"void",
"updateSpaceMembership",
"(",
"int",
"spaceId",
",",
"int",
"userId",
",",
"Role",
"role",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/\"",
"+",
"spaceId",
"+",
"\"/member/\"",
"+",
"userId",
")",
".",
"entity",
"(",
"new",
"SpaceMemberUpdate",
"(",
"role",
")",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"put",
"(",
")",
";",
"}"
] | Updates a space membership with another role
@param spaceId
The id of the space
@param userId
The id of the user
@param role
The new role for the membership | [
"Updates",
"a",
"space",
"membership",
"with",
"another",
"role"
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L110-L115 |
139,621 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.getActiveMembers | public List<SpaceMember> getActiveMembers(int spaceId) {
return getResourceFactory().getApiResource(
"/space/" + spaceId + "/member/").get(
new GenericType<List<SpaceMember>>() {
});
} | java | public List<SpaceMember> getActiveMembers(int spaceId) {
return getResourceFactory().getApiResource(
"/space/" + spaceId + "/member/").get(
new GenericType<List<SpaceMember>>() {
});
} | [
"public",
"List",
"<",
"SpaceMember",
">",
"getActiveMembers",
"(",
"int",
"spaceId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/\"",
"+",
"spaceId",
"+",
"\"/member/\"",
")",
".",
"get",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"SpaceMember",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Returns the active members of the given space.
@param spaceId
The id of the space
@return The active members of the space | [
"Returns",
"the",
"active",
"members",
"of",
"the",
"given",
"space",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L138-L143 |
139,622 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.getEndedMembers | public List<SpaceMember> getEndedMembers(int spaceId) {
return getResourceFactory().getApiResource(
"/space/" + spaceId + "/member/ended/").get(
new GenericType<List<SpaceMember>>() {
});
} | java | public List<SpaceMember> getEndedMembers(int spaceId) {
return getResourceFactory().getApiResource(
"/space/" + spaceId + "/member/ended/").get(
new GenericType<List<SpaceMember>>() {
});
} | [
"public",
"List",
"<",
"SpaceMember",
">",
"getEndedMembers",
"(",
"int",
"spaceId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/\"",
"+",
"spaceId",
"+",
"\"/member/ended/\"",
")",
".",
"get",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"SpaceMember",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Returns a list of the members that have been removed from the space.
@param spaceId
The id of the space
@return The active members of the space | [
"Returns",
"a",
"list",
"of",
"the",
"members",
"that",
"have",
"been",
"removed",
"from",
"the",
"space",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L187-L192 |
139,623 | podio/podio-java | src/main/java/com/podio/space/SpaceAPI.java | SpaceAPI.getTopSpaces | public List<SpaceWithOrganization> getTopSpaces(Integer limit) {
WebResource resource = getResourceFactory().getApiResource(
"/space/top/");
if (limit != null) {
resource = resource.queryParam("limit", limit.toString());
}
return resource.get(new GenericType<List<SpaceWithOrganization>>() {
});
} | java | public List<SpaceWithOrganization> getTopSpaces(Integer limit) {
WebResource resource = getResourceFactory().getApiResource(
"/space/top/");
if (limit != null) {
resource = resource.queryParam("limit", limit.toString());
}
return resource.get(new GenericType<List<SpaceWithOrganization>>() {
});
} | [
"public",
"List",
"<",
"SpaceWithOrganization",
">",
"getTopSpaces",
"(",
"Integer",
"limit",
")",
"{",
"WebResource",
"resource",
"=",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/space/top/\"",
")",
";",
"if",
"(",
"limit",
"!=",
"null",
")",
"{",
"resource",
"=",
"resource",
".",
"queryParam",
"(",
"\"limit\"",
",",
"limit",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"resource",
".",
"get",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"SpaceWithOrganization",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Returns the top spaces for the user
@param limit
The max number of members to return, defaults to 6
@return The top spaces for the user | [
"Returns",
"the",
"top",
"spaces",
"for",
"the",
"user"
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/space/SpaceAPI.java#L201-L210 |
139,624 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/LookupTableHelper.java | LookupTableHelper.registerList | public static void registerList(final String key, final Request request) {
request.setSessionAttribute(DATA_LIST_UIC_SESSION_KEY, UIContextHolder.getCurrentPrimaryUIContext());
} | java | public static void registerList(final String key, final Request request) {
request.setSessionAttribute(DATA_LIST_UIC_SESSION_KEY, UIContextHolder.getCurrentPrimaryUIContext());
} | [
"public",
"static",
"void",
"registerList",
"(",
"final",
"String",
"key",
",",
"final",
"Request",
"request",
")",
"{",
"request",
".",
"setSessionAttribute",
"(",
"DATA_LIST_UIC_SESSION_KEY",
",",
"UIContextHolder",
".",
"getCurrentPrimaryUIContext",
"(",
")",
")",
";",
"}"
] | Registers a data list with the servlet.
@param key the list key.
@param request the current request being responded to. | [
"Registers",
"a",
"data",
"list",
"with",
"the",
"servlet",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/LookupTableHelper.java#L35-L37 |
139,625 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/LookupTableHelper.java | LookupTableHelper.getContext | public static UIContext getContext(final String key, final Request request) {
return (UIContext) request.getSessionAttribute(DATA_LIST_UIC_SESSION_KEY);
} | java | public static UIContext getContext(final String key, final Request request) {
return (UIContext) request.getSessionAttribute(DATA_LIST_UIC_SESSION_KEY);
} | [
"public",
"static",
"UIContext",
"getContext",
"(",
"final",
"String",
"key",
",",
"final",
"Request",
"request",
")",
"{",
"return",
"(",
"UIContext",
")",
"request",
".",
"getSessionAttribute",
"(",
"DATA_LIST_UIC_SESSION_KEY",
")",
";",
"}"
] | Retrieves the UIContext for the given data list.
@param key the list key.
@param request the current request being responded to.
@return the UIContext for the given key. | [
"Retrieves",
"the",
"UIContext",
"for",
"the",
"given",
"data",
"list",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/LookupTableHelper.java#L47-L49 |
139,626 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.collateVisibles | public static List<ComponentWithContext> collateVisibles(final WComponent comp) {
final List<ComponentWithContext> list = new ArrayList<>();
WComponentTreeVisitor visitor = new WComponentTreeVisitor() {
@Override
public VisitorResult visit(final WComponent comp) {
// In traversing the tree, special components like WInvisbleContainer, WRepeatRoot are still traversed
// (so ignore them)
if (comp.isVisible()) {
list.add(new ComponentWithContext(comp, UIContextHolder.getCurrent()));
}
return VisitorResult.CONTINUE;
}
};
traverseVisible(comp, visitor);
return list;
} | java | public static List<ComponentWithContext> collateVisibles(final WComponent comp) {
final List<ComponentWithContext> list = new ArrayList<>();
WComponentTreeVisitor visitor = new WComponentTreeVisitor() {
@Override
public VisitorResult visit(final WComponent comp) {
// In traversing the tree, special components like WInvisbleContainer, WRepeatRoot are still traversed
// (so ignore them)
if (comp.isVisible()) {
list.add(new ComponentWithContext(comp, UIContextHolder.getCurrent()));
}
return VisitorResult.CONTINUE;
}
};
traverseVisible(comp, visitor);
return list;
} | [
"public",
"static",
"List",
"<",
"ComponentWithContext",
">",
"collateVisibles",
"(",
"final",
"WComponent",
"comp",
")",
"{",
"final",
"List",
"<",
"ComponentWithContext",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"WComponentTreeVisitor",
"visitor",
"=",
"new",
"WComponentTreeVisitor",
"(",
")",
"{",
"@",
"Override",
"public",
"VisitorResult",
"visit",
"(",
"final",
"WComponent",
"comp",
")",
"{",
"// In traversing the tree, special components like WInvisbleContainer, WRepeatRoot are still traversed",
"// (so ignore them)",
"if",
"(",
"comp",
".",
"isVisible",
"(",
")",
")",
"{",
"list",
".",
"add",
"(",
"new",
"ComponentWithContext",
"(",
"comp",
",",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
")",
")",
";",
"}",
"return",
"VisitorResult",
".",
"CONTINUE",
";",
"}",
"}",
";",
"traverseVisible",
"(",
"comp",
",",
"visitor",
")",
";",
"return",
"list",
";",
"}"
] | Obtains a list of components which are visible in the given tree. Repeated components will be returned multiple
times, one for each row which they are visible in.
@param comp the root component to search from.
@return a list of components which are visible in the given context. | [
"Obtains",
"a",
"list",
"of",
"components",
"which",
"are",
"visible",
"in",
"the",
"given",
"tree",
".",
"Repeated",
"components",
"will",
"be",
"returned",
"multiple",
"times",
"one",
"for",
"each",
"row",
"which",
"they",
"are",
"visible",
"in",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L45-L63 |
139,627 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.getRoot | public static WComponent getRoot(final UIContext uic, final WComponent comp) {
UIContextHolder.pushContext(uic);
try {
return WebUtilities.getTop(comp);
} finally {
UIContextHolder.popContext();
}
} | java | public static WComponent getRoot(final UIContext uic, final WComponent comp) {
UIContextHolder.pushContext(uic);
try {
return WebUtilities.getTop(comp);
} finally {
UIContextHolder.popContext();
}
} | [
"public",
"static",
"WComponent",
"getRoot",
"(",
"final",
"UIContext",
"uic",
",",
"final",
"WComponent",
"comp",
")",
"{",
"UIContextHolder",
".",
"pushContext",
"(",
"uic",
")",
";",
"try",
"{",
"return",
"WebUtilities",
".",
"getTop",
"(",
"comp",
")",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"}"
] | Retrieves the root component of a WComponent hierarchy.
@param uic the context to retrieve the root component for.
@param comp a component in the tree.
@return the root of the tree. | [
"Retrieves",
"the",
"root",
"component",
"of",
"a",
"WComponent",
"hierarchy",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L72-L80 |
139,628 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.findComponentsByClass | public static List<ComponentWithContext> findComponentsByClass(final WComponent root, final String className,
final boolean includeRoot, final boolean visibleOnly) {
FindComponentsByClassVisitor visitor = new FindComponentsByClassVisitor(root, className, includeRoot);
doTraverse(root, visibleOnly, visitor);
return visitor.getResult() == null ? Collections.EMPTY_LIST : visitor.getResult();
} | java | public static List<ComponentWithContext> findComponentsByClass(final WComponent root, final String className,
final boolean includeRoot, final boolean visibleOnly) {
FindComponentsByClassVisitor visitor = new FindComponentsByClassVisitor(root, className, includeRoot);
doTraverse(root, visibleOnly, visitor);
return visitor.getResult() == null ? Collections.EMPTY_LIST : visitor.getResult();
} | [
"public",
"static",
"List",
"<",
"ComponentWithContext",
">",
"findComponentsByClass",
"(",
"final",
"WComponent",
"root",
",",
"final",
"String",
"className",
",",
"final",
"boolean",
"includeRoot",
",",
"final",
"boolean",
"visibleOnly",
")",
"{",
"FindComponentsByClassVisitor",
"visitor",
"=",
"new",
"FindComponentsByClassVisitor",
"(",
"root",
",",
"className",
",",
"includeRoot",
")",
";",
"doTraverse",
"(",
"root",
",",
"visibleOnly",
",",
"visitor",
")",
";",
"return",
"visitor",
".",
"getResult",
"(",
")",
"==",
"null",
"?",
"Collections",
".",
"EMPTY_LIST",
":",
"visitor",
".",
"getResult",
"(",
")",
";",
"}"
] | Search for components implementing a particular class name.
@param root the root component to search from
@param className the class name to search for
@param includeRoot check the root component as well
@param visibleOnly true if process visible only
@return the list of components implementing the class name | [
"Search",
"for",
"components",
"implementing",
"a",
"particular",
"class",
"name",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L107-L115 |
139,629 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.getComponentWithId | public static WComponent getComponentWithId(final WComponent root, final String id,
final boolean visibleOnly) {
ComponentWithContext comp = getComponentWithContextForId(root, id, visibleOnly);
return comp == null ? null : comp.getComponent();
} | java | public static WComponent getComponentWithId(final WComponent root, final String id,
final boolean visibleOnly) {
ComponentWithContext comp = getComponentWithContextForId(root, id, visibleOnly);
return comp == null ? null : comp.getComponent();
} | [
"public",
"static",
"WComponent",
"getComponentWithId",
"(",
"final",
"WComponent",
"root",
",",
"final",
"String",
"id",
",",
"final",
"boolean",
"visibleOnly",
")",
"{",
"ComponentWithContext",
"comp",
"=",
"getComponentWithContextForId",
"(",
"root",
",",
"id",
",",
"visibleOnly",
")",
";",
"return",
"comp",
"==",
"null",
"?",
"null",
":",
"comp",
".",
"getComponent",
"(",
")",
";",
"}"
] | Retrieves the component with the given Id.
@param root the root component to search from.
@param id the id to search for.
@param visibleOnly true if process visible only
@return the component with the given id, or null if not found. | [
"Retrieves",
"the",
"component",
"with",
"the",
"given",
"Id",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L139-L143 |
139,630 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.getClosestContextForId | public static UIContext getClosestContextForId(final WComponent root, final String id,
final boolean visibleOnly) {
FindComponentByIdVisitor visitor = new FindComponentByIdVisitor(id) {
@Override
public VisitorResult visit(final WComponent comp) {
VisitorResult result = super.visit(comp);
if (result == VisitorResult.CONTINUE) {
// Save closest UIC as processing tree
setResult(new ComponentWithContext(comp, UIContextHolder.getCurrent()));
}
return result;
}
};
doTraverse(root, visibleOnly, visitor);
return visitor.getResult() == null ? null : visitor.getResult().getContext();
} | java | public static UIContext getClosestContextForId(final WComponent root, final String id,
final boolean visibleOnly) {
FindComponentByIdVisitor visitor = new FindComponentByIdVisitor(id) {
@Override
public VisitorResult visit(final WComponent comp) {
VisitorResult result = super.visit(comp);
if (result == VisitorResult.CONTINUE) {
// Save closest UIC as processing tree
setResult(new ComponentWithContext(comp, UIContextHolder.getCurrent()));
}
return result;
}
};
doTraverse(root, visibleOnly, visitor);
return visitor.getResult() == null ? null : visitor.getResult().getContext();
} | [
"public",
"static",
"UIContext",
"getClosestContextForId",
"(",
"final",
"WComponent",
"root",
",",
"final",
"String",
"id",
",",
"final",
"boolean",
"visibleOnly",
")",
"{",
"FindComponentByIdVisitor",
"visitor",
"=",
"new",
"FindComponentByIdVisitor",
"(",
"id",
")",
"{",
"@",
"Override",
"public",
"VisitorResult",
"visit",
"(",
"final",
"WComponent",
"comp",
")",
"{",
"VisitorResult",
"result",
"=",
"super",
".",
"visit",
"(",
"comp",
")",
";",
"if",
"(",
"result",
"==",
"VisitorResult",
".",
"CONTINUE",
")",
"{",
"// Save closest UIC as processing tree",
"setResult",
"(",
"new",
"ComponentWithContext",
"(",
"comp",
",",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
")",
")",
";",
"}",
"return",
"result",
";",
"}",
"}",
";",
"doTraverse",
"(",
"root",
",",
"visibleOnly",
",",
"visitor",
")",
";",
"return",
"visitor",
".",
"getResult",
"(",
")",
"==",
"null",
"?",
"null",
":",
"visitor",
".",
"getResult",
"(",
")",
".",
"getContext",
"(",
")",
";",
"}"
] | Retrieves the closest context for the component with the given Id.
@param root the root component to search from.
@param id the id to search for.
@param visibleOnly true if process visible only
@return the closest context for the component with the given id, or null if not found. | [
"Retrieves",
"the",
"closest",
"context",
"for",
"the",
"component",
"with",
"the",
"given",
"Id",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L226-L244 |
139,631 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.doTraverse | private static VisitorResult doTraverse(final WComponent node, final boolean visibleOnly,
final WComponentTreeVisitor visitor) {
if (visibleOnly) {
// Push through Invisible Containers
// Certain components have their visibility altered to implement custom processing.
if (node instanceof WInvisibleContainer) {
WComponent parent = node.getParent();
// If inside a CardManager, skip the InvisibleContainer and process the visible card.
if (parent instanceof WCardManager) {
WComponent visible = ((WCardManager) node.getParent()).getVisible();
if (visible == null) {
return VisitorResult.ABORT_BRANCH;
}
return doTraverse(visible, visibleOnly, visitor);
} else if (parent instanceof WWindow) { // If inside a WWindow, only process if it is Active
// Abort branch if WWindow is not in ACTIVE state
if (((WWindow) parent).getState() != WWindow.ACTIVE_STATE) {
return VisitorResult.ABORT_BRANCH;
}
}
} else if (node instanceof WRepeatRoot) {
// Let be processed.
} else if (!node.isVisible()) {
// For most components, we just need to see if they're marked as visible
return VisitorResult.ABORT_BRANCH;
}
}
VisitorResult result = visitor.visit(node);
switch (result) {
case ABORT_BRANCH:
// Continue processing, but not down this branch
return VisitorResult.CONTINUE;
case CONTINUE:
// Process repeater rows
if (node instanceof WRepeater) {
// Get parent repeater
WRepeater repeater = (WRepeater) node;
// Get row contexts
List<UIContext> rowContextList = repeater.getRowContexts();
WRepeatRoot repeatRoot = (WRepeatRoot) repeater.getRepeatedComponent().getParent();
for (UIContext rowContext : rowContextList) {
UIContextHolder.pushContext(rowContext);
try {
result = doTraverse(repeatRoot, visibleOnly, visitor);
} finally {
UIContextHolder.popContext();
}
if (VisitorResult.ABORT.equals(result)) {
return VisitorResult.ABORT;
}
}
} else if (node instanceof Container) {
Container container = (Container) node;
for (int i = 0; i < container.getChildCount(); i++) {
result = doTraverse(container.getChildAt(i), visibleOnly, visitor);
if (VisitorResult.ABORT.equals(result)) {
return VisitorResult.ABORT;
}
}
}
return VisitorResult.CONTINUE;
default:
// Abort entire traversal
return VisitorResult.ABORT;
}
} | java | private static VisitorResult doTraverse(final WComponent node, final boolean visibleOnly,
final WComponentTreeVisitor visitor) {
if (visibleOnly) {
// Push through Invisible Containers
// Certain components have their visibility altered to implement custom processing.
if (node instanceof WInvisibleContainer) {
WComponent parent = node.getParent();
// If inside a CardManager, skip the InvisibleContainer and process the visible card.
if (parent instanceof WCardManager) {
WComponent visible = ((WCardManager) node.getParent()).getVisible();
if (visible == null) {
return VisitorResult.ABORT_BRANCH;
}
return doTraverse(visible, visibleOnly, visitor);
} else if (parent instanceof WWindow) { // If inside a WWindow, only process if it is Active
// Abort branch if WWindow is not in ACTIVE state
if (((WWindow) parent).getState() != WWindow.ACTIVE_STATE) {
return VisitorResult.ABORT_BRANCH;
}
}
} else if (node instanceof WRepeatRoot) {
// Let be processed.
} else if (!node.isVisible()) {
// For most components, we just need to see if they're marked as visible
return VisitorResult.ABORT_BRANCH;
}
}
VisitorResult result = visitor.visit(node);
switch (result) {
case ABORT_BRANCH:
// Continue processing, but not down this branch
return VisitorResult.CONTINUE;
case CONTINUE:
// Process repeater rows
if (node instanceof WRepeater) {
// Get parent repeater
WRepeater repeater = (WRepeater) node;
// Get row contexts
List<UIContext> rowContextList = repeater.getRowContexts();
WRepeatRoot repeatRoot = (WRepeatRoot) repeater.getRepeatedComponent().getParent();
for (UIContext rowContext : rowContextList) {
UIContextHolder.pushContext(rowContext);
try {
result = doTraverse(repeatRoot, visibleOnly, visitor);
} finally {
UIContextHolder.popContext();
}
if (VisitorResult.ABORT.equals(result)) {
return VisitorResult.ABORT;
}
}
} else if (node instanceof Container) {
Container container = (Container) node;
for (int i = 0; i < container.getChildCount(); i++) {
result = doTraverse(container.getChildAt(i), visibleOnly, visitor);
if (VisitorResult.ABORT.equals(result)) {
return VisitorResult.ABORT;
}
}
}
return VisitorResult.CONTINUE;
default:
// Abort entire traversal
return VisitorResult.ABORT;
}
} | [
"private",
"static",
"VisitorResult",
"doTraverse",
"(",
"final",
"WComponent",
"node",
",",
"final",
"boolean",
"visibleOnly",
",",
"final",
"WComponentTreeVisitor",
"visitor",
")",
"{",
"if",
"(",
"visibleOnly",
")",
"{",
"// Push through Invisible Containers",
"// Certain components have their visibility altered to implement custom processing.",
"if",
"(",
"node",
"instanceof",
"WInvisibleContainer",
")",
"{",
"WComponent",
"parent",
"=",
"node",
".",
"getParent",
"(",
")",
";",
"// If inside a CardManager, skip the InvisibleContainer and process the visible card.",
"if",
"(",
"parent",
"instanceof",
"WCardManager",
")",
"{",
"WComponent",
"visible",
"=",
"(",
"(",
"WCardManager",
")",
"node",
".",
"getParent",
"(",
")",
")",
".",
"getVisible",
"(",
")",
";",
"if",
"(",
"visible",
"==",
"null",
")",
"{",
"return",
"VisitorResult",
".",
"ABORT_BRANCH",
";",
"}",
"return",
"doTraverse",
"(",
"visible",
",",
"visibleOnly",
",",
"visitor",
")",
";",
"}",
"else",
"if",
"(",
"parent",
"instanceof",
"WWindow",
")",
"{",
"// If inside a WWindow, only process if it is Active",
"// Abort branch if WWindow is not in ACTIVE state",
"if",
"(",
"(",
"(",
"WWindow",
")",
"parent",
")",
".",
"getState",
"(",
")",
"!=",
"WWindow",
".",
"ACTIVE_STATE",
")",
"{",
"return",
"VisitorResult",
".",
"ABORT_BRANCH",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"node",
"instanceof",
"WRepeatRoot",
")",
"{",
"// Let be processed.",
"}",
"else",
"if",
"(",
"!",
"node",
".",
"isVisible",
"(",
")",
")",
"{",
"// For most components, we just need to see if they're marked as visible",
"return",
"VisitorResult",
".",
"ABORT_BRANCH",
";",
"}",
"}",
"VisitorResult",
"result",
"=",
"visitor",
".",
"visit",
"(",
"node",
")",
";",
"switch",
"(",
"result",
")",
"{",
"case",
"ABORT_BRANCH",
":",
"// Continue processing, but not down this branch",
"return",
"VisitorResult",
".",
"CONTINUE",
";",
"case",
"CONTINUE",
":",
"// Process repeater rows",
"if",
"(",
"node",
"instanceof",
"WRepeater",
")",
"{",
"// Get parent repeater",
"WRepeater",
"repeater",
"=",
"(",
"WRepeater",
")",
"node",
";",
"// Get row contexts",
"List",
"<",
"UIContext",
">",
"rowContextList",
"=",
"repeater",
".",
"getRowContexts",
"(",
")",
";",
"WRepeatRoot",
"repeatRoot",
"=",
"(",
"WRepeatRoot",
")",
"repeater",
".",
"getRepeatedComponent",
"(",
")",
".",
"getParent",
"(",
")",
";",
"for",
"(",
"UIContext",
"rowContext",
":",
"rowContextList",
")",
"{",
"UIContextHolder",
".",
"pushContext",
"(",
"rowContext",
")",
";",
"try",
"{",
"result",
"=",
"doTraverse",
"(",
"repeatRoot",
",",
"visibleOnly",
",",
"visitor",
")",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"if",
"(",
"VisitorResult",
".",
"ABORT",
".",
"equals",
"(",
"result",
")",
")",
"{",
"return",
"VisitorResult",
".",
"ABORT",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"node",
"instanceof",
"Container",
")",
"{",
"Container",
"container",
"=",
"(",
"Container",
")",
"node",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"container",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"result",
"=",
"doTraverse",
"(",
"container",
".",
"getChildAt",
"(",
"i",
")",
",",
"visibleOnly",
",",
"visitor",
")",
";",
"if",
"(",
"VisitorResult",
".",
"ABORT",
".",
"equals",
"(",
"result",
")",
")",
"{",
"return",
"VisitorResult",
".",
"ABORT",
";",
"}",
"}",
"}",
"return",
"VisitorResult",
".",
"CONTINUE",
";",
"default",
":",
"// Abort entire traversal",
"return",
"VisitorResult",
".",
"ABORT",
";",
"}",
"}"
] | Internal implementation of tree traversal method.
@param node the node to traverse.
@param visibleOnly if true, only visit visible components.
@param visitor the visitor to notify as the tree is traversed.
@return how the traversal should continue. | [
"Internal",
"implementation",
"of",
"tree",
"traversal",
"method",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L306-L382 |
139,632 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java | WLink.setText | public void setText(final String text, final Serializable... args) {
getOrCreateComponentModel().text = I18nUtilities.asMessage(text, args);
} | java | public void setText(final String text, final Serializable... args) {
getOrCreateComponentModel().text = I18nUtilities.asMessage(text, args);
} | [
"public",
"void",
"setText",
"(",
"final",
"String",
"text",
",",
"final",
"Serializable",
"...",
"args",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"text",
"=",
"I18nUtilities",
".",
"asMessage",
"(",
"text",
",",
"args",
")",
";",
"}"
] | Sets the text displayed on the link.
@param text the text to set, using {@link MessageFormat} syntax.
@param args optional arguments for the message format string. | [
"Sets",
"the",
"text",
"displayed",
"on",
"the",
"link",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java#L140-L142 |
139,633 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java | WLink.handleRequest | @Override
public void handleRequest(final Request request) {
// Check if this link was the AJAX Trigger
AjaxOperation operation = AjaxHelper.getCurrentOperation();
boolean pressed = (operation != null && getId().equals(operation.getTriggerId()));
// Protect against client-side tampering of disabled/read-only fields.
if (isDisabled() && pressed) {
LOG.warn("A disabled link has been triggered. " + getText() + ". " + getId());
return;
}
// If an action has been supplied then execute it, but only after
// handle request has been performed on the entire component tree.
final Action action = getAction();
if (pressed && action != null) {
final ActionEvent event = new ActionEvent(this, getActionCommand(), getActionObject());
Runnable later = new Runnable() {
@Override
public void run() {
action.execute(event);
}
};
invokeLater(later);
}
} | java | @Override
public void handleRequest(final Request request) {
// Check if this link was the AJAX Trigger
AjaxOperation operation = AjaxHelper.getCurrentOperation();
boolean pressed = (operation != null && getId().equals(operation.getTriggerId()));
// Protect against client-side tampering of disabled/read-only fields.
if (isDisabled() && pressed) {
LOG.warn("A disabled link has been triggered. " + getText() + ". " + getId());
return;
}
// If an action has been supplied then execute it, but only after
// handle request has been performed on the entire component tree.
final Action action = getAction();
if (pressed && action != null) {
final ActionEvent event = new ActionEvent(this, getActionCommand(), getActionObject());
Runnable later = new Runnable() {
@Override
public void run() {
action.execute(event);
}
};
invokeLater(later);
}
} | [
"@",
"Override",
"public",
"void",
"handleRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"// Check if this link was the AJAX Trigger",
"AjaxOperation",
"operation",
"=",
"AjaxHelper",
".",
"getCurrentOperation",
"(",
")",
";",
"boolean",
"pressed",
"=",
"(",
"operation",
"!=",
"null",
"&&",
"getId",
"(",
")",
".",
"equals",
"(",
"operation",
".",
"getTriggerId",
"(",
")",
")",
")",
";",
"// Protect against client-side tampering of disabled/read-only fields.",
"if",
"(",
"isDisabled",
"(",
")",
"&&",
"pressed",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"A disabled link has been triggered. \"",
"+",
"getText",
"(",
")",
"+",
"\". \"",
"+",
"getId",
"(",
")",
")",
";",
"return",
";",
"}",
"// If an action has been supplied then execute it, but only after",
"// handle request has been performed on the entire component tree.",
"final",
"Action",
"action",
"=",
"getAction",
"(",
")",
";",
"if",
"(",
"pressed",
"&&",
"action",
"!=",
"null",
")",
"{",
"final",
"ActionEvent",
"event",
"=",
"new",
"ActionEvent",
"(",
"this",
",",
"getActionCommand",
"(",
")",
",",
"getActionObject",
"(",
")",
")",
";",
"Runnable",
"later",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"action",
".",
"execute",
"(",
"event",
")",
";",
"}",
"}",
";",
"invokeLater",
"(",
"later",
")",
";",
"}",
"}"
] | Override handleRequest in order to perform processing for this component. This implementation checks whether the
link has been pressed via the current ajax operation.
@param request the request being responded to. | [
"Override",
"handleRequest",
"in",
"order",
"to",
"perform",
"processing",
"for",
"this",
"component",
".",
"This",
"implementation",
"checks",
"whether",
"the",
"link",
"has",
"been",
"pressed",
"via",
"the",
"current",
"ajax",
"operation",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java#L377-L405 |
139,634 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java | WLink.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
UIContext uic = UIContextHolder.getCurrent();
// If the link has an action, register it for AJAX
final Action action = getAction();
final AjaxTarget[] actionTargets = getActionTargets();
if (action != null && uic.getUI() != null) {
// Register AJAX operation if AJAX targets are set, otherwise rely on InternalAjax request
if (actionTargets != null && actionTargets.length > 0) {
List<String> targetIds = new ArrayList<>();
for (AjaxTarget target : actionTargets) {
targetIds.add(target.getId());
}
// Register the action targets
AjaxHelper.registerComponents(targetIds, getId());
}
}
} | java | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
UIContext uic = UIContextHolder.getCurrent();
// If the link has an action, register it for AJAX
final Action action = getAction();
final AjaxTarget[] actionTargets = getActionTargets();
if (action != null && uic.getUI() != null) {
// Register AJAX operation if AJAX targets are set, otherwise rely on InternalAjax request
if (actionTargets != null && actionTargets.length > 0) {
List<String> targetIds = new ArrayList<>();
for (AjaxTarget target : actionTargets) {
targetIds.add(target.getId());
}
// Register the action targets
AjaxHelper.registerComponents(targetIds, getId());
}
}
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"super",
".",
"preparePaintComponent",
"(",
"request",
")",
";",
"UIContext",
"uic",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"// If the link has an action, register it for AJAX",
"final",
"Action",
"action",
"=",
"getAction",
"(",
")",
";",
"final",
"AjaxTarget",
"[",
"]",
"actionTargets",
"=",
"getActionTargets",
"(",
")",
";",
"if",
"(",
"action",
"!=",
"null",
"&&",
"uic",
".",
"getUI",
"(",
")",
"!=",
"null",
")",
"{",
"// Register AJAX operation if AJAX targets are set, otherwise rely on InternalAjax request",
"if",
"(",
"actionTargets",
"!=",
"null",
"&&",
"actionTargets",
".",
"length",
">",
"0",
")",
"{",
"List",
"<",
"String",
">",
"targetIds",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"AjaxTarget",
"target",
":",
"actionTargets",
")",
"{",
"targetIds",
".",
"add",
"(",
"target",
".",
"getId",
"(",
")",
")",
";",
"}",
"// Register the action targets",
"AjaxHelper",
".",
"registerComponents",
"(",
"targetIds",
",",
"getId",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Override preparePaintComponent to register an AJAX operation if this link has an action.
@param request the request being responded to. | [
"Override",
"preparePaintComponent",
"to",
"register",
"an",
"AJAX",
"operation",
"if",
"this",
"link",
"has",
"an",
"action",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java#L412-L432 |
139,635 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java | WLink.setImage | public void setImage(final Image image) {
LinkModel model = getOrCreateComponentModel();
model.image = image;
model.imageUrl = null;
} | java | public void setImage(final Image image) {
LinkModel model = getOrCreateComponentModel();
model.image = image;
model.imageUrl = null;
} | [
"public",
"void",
"setImage",
"(",
"final",
"Image",
"image",
")",
"{",
"LinkModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"model",
".",
"image",
"=",
"image",
";",
"model",
".",
"imageUrl",
"=",
"null",
";",
"}"
] | Sets the image to display on the link.
@param image the image, or null for no image. | [
"Sets",
"the",
"image",
"to",
"display",
"on",
"the",
"link",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java#L448-L452 |
139,636 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java | WLink.setImageUrl | public void setImageUrl(final String imageUrl) {
LinkModel model = getOrCreateComponentModel();
model.imageUrl = imageUrl;
model.image = null;
} | java | public void setImageUrl(final String imageUrl) {
LinkModel model = getOrCreateComponentModel();
model.imageUrl = imageUrl;
model.image = null;
} | [
"public",
"void",
"setImageUrl",
"(",
"final",
"String",
"imageUrl",
")",
"{",
"LinkModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"model",
".",
"imageUrl",
"=",
"imageUrl",
";",
"model",
".",
"image",
"=",
"null",
";",
"}"
] | Sets the URL of the image to display on the link.
@param imageUrl the image url, or null for no image. | [
"Sets",
"the",
"URL",
"of",
"the",
"image",
"to",
"display",
"on",
"the",
"link",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WLink.java#L490-L494 |
139,637 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.addFile | public void addFile(final FileWidgetUpload file) {
List<FileWidgetUpload> files = (List<FileWidgetUpload>) getData();
if (files == null) {
files = new ArrayList<>();
setData(files);
}
files.add(file);
MemoryUtil.checkSize(files.size(), this.getClass().getSimpleName());
} | java | public void addFile(final FileWidgetUpload file) {
List<FileWidgetUpload> files = (List<FileWidgetUpload>) getData();
if (files == null) {
files = new ArrayList<>();
setData(files);
}
files.add(file);
MemoryUtil.checkSize(files.size(), this.getClass().getSimpleName());
} | [
"public",
"void",
"addFile",
"(",
"final",
"FileWidgetUpload",
"file",
")",
"{",
"List",
"<",
"FileWidgetUpload",
">",
"files",
"=",
"(",
"List",
"<",
"FileWidgetUpload",
">",
")",
"getData",
"(",
")",
";",
"if",
"(",
"files",
"==",
"null",
")",
"{",
"files",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"setData",
"(",
"files",
")",
";",
"}",
"files",
".",
"add",
"(",
"file",
")",
";",
"MemoryUtil",
".",
"checkSize",
"(",
"files",
".",
"size",
"(",
")",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}"
] | Add a file item to this widget.
@param file the file item | [
"Add",
"a",
"file",
"item",
"to",
"this",
"widget",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L126-L134 |
139,638 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.removeFile | public void removeFile(final FileWidgetUpload file) {
List<FileWidgetUpload> files = (List<FileWidgetUpload>) getData();
if (files != null) {
files.remove(file);
if (files.isEmpty()) {
setData(null);
}
}
} | java | public void removeFile(final FileWidgetUpload file) {
List<FileWidgetUpload> files = (List<FileWidgetUpload>) getData();
if (files != null) {
files.remove(file);
if (files.isEmpty()) {
setData(null);
}
}
} | [
"public",
"void",
"removeFile",
"(",
"final",
"FileWidgetUpload",
"file",
")",
"{",
"List",
"<",
"FileWidgetUpload",
">",
"files",
"=",
"(",
"List",
"<",
"FileWidgetUpload",
">",
")",
"getData",
"(",
")",
";",
"if",
"(",
"files",
"!=",
"null",
")",
"{",
"files",
".",
"remove",
"(",
"file",
")",
";",
"if",
"(",
"files",
".",
"isEmpty",
"(",
")",
")",
"{",
"setData",
"(",
"null",
")",
";",
"}",
"}",
"}"
] | Remove the file.
@param file the file to remove | [
"Remove",
"the",
"file",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L141-L149 |
139,639 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.isValid | private boolean isValid(final String fileType) {
boolean result = false;
if (fileType != null && fileType.length() > 1) { // the shortest I can think of would be something like ".h"
if (fileType.startsWith(".")) { // assume it's a file extension
result = true;
} else if (fileType.length() > 2 && fileType.indexOf('/') > 0) { // some imaginary mimetype like "a/*" would be at least 3 characters
result = true;
}
}
return result;
} | java | private boolean isValid(final String fileType) {
boolean result = false;
if (fileType != null && fileType.length() > 1) { // the shortest I can think of would be something like ".h"
if (fileType.startsWith(".")) { // assume it's a file extension
result = true;
} else if (fileType.length() > 2 && fileType.indexOf('/') > 0) { // some imaginary mimetype like "a/*" would be at least 3 characters
result = true;
}
}
return result;
} | [
"private",
"boolean",
"isValid",
"(",
"final",
"String",
"fileType",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"fileType",
"!=",
"null",
"&&",
"fileType",
".",
"length",
"(",
")",
">",
"1",
")",
"{",
"// the shortest I can think of would be something like \".h\"",
"if",
"(",
"fileType",
".",
"startsWith",
"(",
"\".\"",
")",
")",
"{",
"// assume it's a file extension",
"result",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"fileType",
".",
"length",
"(",
")",
">",
"2",
"&&",
"fileType",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"0",
")",
"{",
"// some imaginary mimetype like \"a/*\" would be at least 3 characters",
"result",
"=",
"true",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Check that the file type SEEMS to be legit.
@param fileType The file type to check
@return true if the file type is valid. | [
"Check",
"that",
"the",
"file",
"type",
"SEEMS",
"to",
"be",
"legit",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L280-L290 |
139,640 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.getFileTypes | public List<String> getFileTypes() {
Set<String> fileTypes = getComponentModel().fileTypes;
List<String> result;
if (fileTypes == null || fileTypes.isEmpty()) {
return Collections.emptyList();
}
result = new ArrayList<>(fileTypes);
return result;
} | java | public List<String> getFileTypes() {
Set<String> fileTypes = getComponentModel().fileTypes;
List<String> result;
if (fileTypes == null || fileTypes.isEmpty()) {
return Collections.emptyList();
}
result = new ArrayList<>(fileTypes);
return result;
} | [
"public",
"List",
"<",
"String",
">",
"getFileTypes",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"fileTypes",
"=",
"getComponentModel",
"(",
")",
".",
"fileTypes",
";",
"List",
"<",
"String",
">",
"result",
";",
"if",
"(",
"fileTypes",
"==",
"null",
"||",
"fileTypes",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
"fileTypes",
")",
";",
"return",
"result",
";",
"}"
] | Returns a list of file types accepted by the file input.
@see #setFileTypes(Collection) for a description of what constitutes an allowable file types
If no types have been added an empty list is returned. An empty list indicates that all file types are accepted.
@return The file types accepted by this file input e.g. "image/*", ".vis", "text/plain", "text/html",
"application/pdf". | [
"Returns",
"a",
"list",
"of",
"file",
"types",
"accepted",
"by",
"the",
"file",
"input",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L302-L310 |
139,641 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.setColumns | public void setColumns(final Integer cols) {
if (cols != null && cols < 0) {
throw new IllegalArgumentException("Must have zero or more columns");
}
Integer currColumns = getColumns();
if (!Objects.equals(cols, currColumns)) {
getOrCreateComponentModel().cols = cols;
}
} | java | public void setColumns(final Integer cols) {
if (cols != null && cols < 0) {
throw new IllegalArgumentException("Must have zero or more columns");
}
Integer currColumns = getColumns();
if (!Objects.equals(cols, currColumns)) {
getOrCreateComponentModel().cols = cols;
}
} | [
"public",
"void",
"setColumns",
"(",
"final",
"Integer",
"cols",
")",
"{",
"if",
"(",
"cols",
"!=",
"null",
"&&",
"cols",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must have zero or more columns\"",
")",
";",
"}",
"Integer",
"currColumns",
"=",
"getColumns",
"(",
")",
";",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"cols",
",",
"currColumns",
")",
")",
"{",
"getOrCreateComponentModel",
"(",
")",
".",
"cols",
"=",
"cols",
";",
"}",
"}"
] | Sets the layout of uploaded files to be a certain number of columns. Null uses the theme default.
@param cols the number of columns. | [
"Sets",
"the",
"layout",
"of",
"uploaded",
"files",
"to",
"be",
"a",
"certain",
"number",
"of",
"columns",
".",
"Null",
"uses",
"the",
"theme",
"default",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L440-L448 |
139,642 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.doHandleFileAjaxActionRequest | protected void doHandleFileAjaxActionRequest(final Request request) {
// Protect against client-side tampering of disabled components
if (isDisabled()) {
throw new SystemException("File widget is disabled.");
}
// Check for file id
String fileId = request.getParameter(FILE_UPLOAD_ID_KEY);
if (fileId == null) {
throw new SystemException("No file id provided for ajax action.");
}
// Check valid file id
FileWidgetUpload file = getFile(fileId);
if (file == null) {
throw new SystemException("Invalid file id [" + fileId + "].");
}
// Run the action
final Action action = getFileAjaxAction();
if (action == null) {
throw new SystemException("No action set for file ajax action request.");
}
// Set the selected file id as the action object
final ActionEvent event = new ActionEvent(this, "fileajax", fileId);
Runnable later = new Runnable() {
@Override
public void run() {
action.execute(event);
}
};
invokeLater(later);
} | java | protected void doHandleFileAjaxActionRequest(final Request request) {
// Protect against client-side tampering of disabled components
if (isDisabled()) {
throw new SystemException("File widget is disabled.");
}
// Check for file id
String fileId = request.getParameter(FILE_UPLOAD_ID_KEY);
if (fileId == null) {
throw new SystemException("No file id provided for ajax action.");
}
// Check valid file id
FileWidgetUpload file = getFile(fileId);
if (file == null) {
throw new SystemException("Invalid file id [" + fileId + "].");
}
// Run the action
final Action action = getFileAjaxAction();
if (action == null) {
throw new SystemException("No action set for file ajax action request.");
}
// Set the selected file id as the action object
final ActionEvent event = new ActionEvent(this, "fileajax", fileId);
Runnable later = new Runnable() {
@Override
public void run() {
action.execute(event);
}
};
invokeLater(later);
} | [
"protected",
"void",
"doHandleFileAjaxActionRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"// Protect against client-side tampering of disabled components",
"if",
"(",
"isDisabled",
"(",
")",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"File widget is disabled.\"",
")",
";",
"}",
"// Check for file id",
"String",
"fileId",
"=",
"request",
".",
"getParameter",
"(",
"FILE_UPLOAD_ID_KEY",
")",
";",
"if",
"(",
"fileId",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No file id provided for ajax action.\"",
")",
";",
"}",
"// Check valid file id",
"FileWidgetUpload",
"file",
"=",
"getFile",
"(",
"fileId",
")",
";",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"Invalid file id [\"",
"+",
"fileId",
"+",
"\"].\"",
")",
";",
"}",
"// Run the action",
"final",
"Action",
"action",
"=",
"getFileAjaxAction",
"(",
")",
";",
"if",
"(",
"action",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No action set for file ajax action request.\"",
")",
";",
"}",
"// Set the selected file id as the action object",
"final",
"ActionEvent",
"event",
"=",
"new",
"ActionEvent",
"(",
"this",
",",
"\"fileajax\"",
",",
"fileId",
")",
";",
"Runnable",
"later",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"action",
".",
"execute",
"(",
"event",
")",
";",
"}",
"}",
";",
"invokeLater",
"(",
"later",
")",
";",
"}"
] | Handle a file action AJAX request.
@param request the request being processed | [
"Handle",
"a",
"file",
"action",
"AJAX",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L647-L681 |
139,643 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.doHandleTargetedRequest | protected void doHandleTargetedRequest(final Request request) {
// Check for file id
String fileId = request.getParameter(FILE_UPLOAD_ID_KEY);
if (fileId == null) {
throw new SystemException("No file id provided for content request.");
}
// Check valid file id
FileWidgetUpload file = getFile(fileId);
if (file == null) {
throw new SystemException("Invalid file id [" + fileId + "].");
}
// Check if thumb nail requested
boolean thumbNail = request.getParameter(FILE_UPLOAD_THUMB_NAIL_KEY) != null;
if (thumbNail) {
doHandleThumbnailRequest(file);
} else {
doHandleFileContentRequest(file);
}
} | java | protected void doHandleTargetedRequest(final Request request) {
// Check for file id
String fileId = request.getParameter(FILE_UPLOAD_ID_KEY);
if (fileId == null) {
throw new SystemException("No file id provided for content request.");
}
// Check valid file id
FileWidgetUpload file = getFile(fileId);
if (file == null) {
throw new SystemException("Invalid file id [" + fileId + "].");
}
// Check if thumb nail requested
boolean thumbNail = request.getParameter(FILE_UPLOAD_THUMB_NAIL_KEY) != null;
if (thumbNail) {
doHandleThumbnailRequest(file);
} else {
doHandleFileContentRequest(file);
}
} | [
"protected",
"void",
"doHandleTargetedRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"// Check for file id",
"String",
"fileId",
"=",
"request",
".",
"getParameter",
"(",
"FILE_UPLOAD_ID_KEY",
")",
";",
"if",
"(",
"fileId",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No file id provided for content request.\"",
")",
";",
"}",
"// Check valid file id",
"FileWidgetUpload",
"file",
"=",
"getFile",
"(",
"fileId",
")",
";",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"Invalid file id [\"",
"+",
"fileId",
"+",
"\"].\"",
")",
";",
"}",
"// Check if thumb nail requested",
"boolean",
"thumbNail",
"=",
"request",
".",
"getParameter",
"(",
"FILE_UPLOAD_THUMB_NAIL_KEY",
")",
"!=",
"null",
";",
"if",
"(",
"thumbNail",
")",
"{",
"doHandleThumbnailRequest",
"(",
"file",
")",
";",
"}",
"else",
"{",
"doHandleFileContentRequest",
"(",
"file",
")",
";",
"}",
"}"
] | Handle a targeted request. Can be a file upload, thumbnail request or file content request.
@param request the request being processed | [
"Handle",
"a",
"targeted",
"request",
".",
"Can",
"be",
"a",
"file",
"upload",
"thumbnail",
"request",
"or",
"file",
"content",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L689-L710 |
139,644 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.doHandleUploadRequest | protected void doHandleUploadRequest(final Request request) {
// Protect against client-side tampering of disabled/read-only fields.
if (isDisabled() || isReadOnly()) {
throw new SystemException("File widget cannot be updated.");
}
// Only process on a POST
if (!"POST".equals(request.getMethod())) {
throw new SystemException(
"File widget cannot be updated by " + request.getMethod() + ".");
}
// Check only one file item in the request
FileItem[] items = request.getFileItems(getId());
if (items.length > 1) {
throw new SystemException("More than one file item received on the request.");
}
// Check the client provided a fileID
String fileId = request.getParameter(FILE_UPLOAD_MULTI_PART_ID_KEY);
if (fileId == null) {
throw new SystemException("No file id provided for file upload.");
}
// Wrap the file item
FileItemWrap wrap = new FileItemWrap(items[0]);
// if fileType is supplied then validate it
if (hasFileTypes() && !FileUtil.validateFileType(wrap, getFileTypes())) {
String invalidMessage = FileUtil.getInvalidFileTypeMessage(getFileTypes());
throw new SystemException(invalidMessage);
}
// if fileSize is supplied then validate it
if (hasMaxFileSize() && !FileUtil.validateFileSize(wrap, getMaxFileSize())) {
String invalidMessage = FileUtil.getInvalidFileSizeMessage(getMaxFileSize());
throw new SystemException(invalidMessage);
}
FileWidgetUpload file = new FileWidgetUpload(fileId, wrap);
addFile(file);
// Set the file id to be used ion the renderer
setFileUploadRequestId(fileId);
setNewUpload(true);
} | java | protected void doHandleUploadRequest(final Request request) {
// Protect against client-side tampering of disabled/read-only fields.
if (isDisabled() || isReadOnly()) {
throw new SystemException("File widget cannot be updated.");
}
// Only process on a POST
if (!"POST".equals(request.getMethod())) {
throw new SystemException(
"File widget cannot be updated by " + request.getMethod() + ".");
}
// Check only one file item in the request
FileItem[] items = request.getFileItems(getId());
if (items.length > 1) {
throw new SystemException("More than one file item received on the request.");
}
// Check the client provided a fileID
String fileId = request.getParameter(FILE_UPLOAD_MULTI_PART_ID_KEY);
if (fileId == null) {
throw new SystemException("No file id provided for file upload.");
}
// Wrap the file item
FileItemWrap wrap = new FileItemWrap(items[0]);
// if fileType is supplied then validate it
if (hasFileTypes() && !FileUtil.validateFileType(wrap, getFileTypes())) {
String invalidMessage = FileUtil.getInvalidFileTypeMessage(getFileTypes());
throw new SystemException(invalidMessage);
}
// if fileSize is supplied then validate it
if (hasMaxFileSize() && !FileUtil.validateFileSize(wrap, getMaxFileSize())) {
String invalidMessage = FileUtil.getInvalidFileSizeMessage(getMaxFileSize());
throw new SystemException(invalidMessage);
}
FileWidgetUpload file = new FileWidgetUpload(fileId, wrap);
addFile(file);
// Set the file id to be used ion the renderer
setFileUploadRequestId(fileId);
setNewUpload(true);
} | [
"protected",
"void",
"doHandleUploadRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"// Protect against client-side tampering of disabled/read-only fields.",
"if",
"(",
"isDisabled",
"(",
")",
"||",
"isReadOnly",
"(",
")",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"File widget cannot be updated.\"",
")",
";",
"}",
"// Only process on a POST",
"if",
"(",
"!",
"\"POST\"",
".",
"equals",
"(",
"request",
".",
"getMethod",
"(",
")",
")",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"File widget cannot be updated by \"",
"+",
"request",
".",
"getMethod",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"// Check only one file item in the request",
"FileItem",
"[",
"]",
"items",
"=",
"request",
".",
"getFileItems",
"(",
"getId",
"(",
")",
")",
";",
"if",
"(",
"items",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"More than one file item received on the request.\"",
")",
";",
"}",
"// Check the client provided a fileID",
"String",
"fileId",
"=",
"request",
".",
"getParameter",
"(",
"FILE_UPLOAD_MULTI_PART_ID_KEY",
")",
";",
"if",
"(",
"fileId",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No file id provided for file upload.\"",
")",
";",
"}",
"// Wrap the file item",
"FileItemWrap",
"wrap",
"=",
"new",
"FileItemWrap",
"(",
"items",
"[",
"0",
"]",
")",
";",
"// if fileType is supplied then validate it",
"if",
"(",
"hasFileTypes",
"(",
")",
"&&",
"!",
"FileUtil",
".",
"validateFileType",
"(",
"wrap",
",",
"getFileTypes",
"(",
")",
")",
")",
"{",
"String",
"invalidMessage",
"=",
"FileUtil",
".",
"getInvalidFileTypeMessage",
"(",
"getFileTypes",
"(",
")",
")",
";",
"throw",
"new",
"SystemException",
"(",
"invalidMessage",
")",
";",
"}",
"// if fileSize is supplied then validate it",
"if",
"(",
"hasMaxFileSize",
"(",
")",
"&&",
"!",
"FileUtil",
".",
"validateFileSize",
"(",
"wrap",
",",
"getMaxFileSize",
"(",
")",
")",
")",
"{",
"String",
"invalidMessage",
"=",
"FileUtil",
".",
"getInvalidFileSizeMessage",
"(",
"getMaxFileSize",
"(",
")",
")",
";",
"throw",
"new",
"SystemException",
"(",
"invalidMessage",
")",
";",
"}",
"FileWidgetUpload",
"file",
"=",
"new",
"FileWidgetUpload",
"(",
"fileId",
",",
"wrap",
")",
";",
"addFile",
"(",
"file",
")",
";",
"// Set the file id to be used ion the renderer",
"setFileUploadRequestId",
"(",
"fileId",
")",
";",
"setNewUpload",
"(",
"true",
")",
";",
"}"
] | The request is a targeted file upload request. Upload the file and respond with the file information.
@param request the request being processed. | [
"The",
"request",
"is",
"a",
"targeted",
"file",
"upload",
"request",
".",
"Upload",
"the",
"file",
"and",
"respond",
"with",
"the",
"file",
"information",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L717-L762 |
139,645 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.doHandleThumbnailRequest | protected void doHandleThumbnailRequest(final FileWidgetUpload file) {
// Create thumb nail (if required)
if (file.getThumbnail() == null) {
Image thumbnail = createThumbNail(file.getFile());
file.setThumbnail(thumbnail);
}
ContentEscape escape = new ContentEscape(file.getThumbnail());
throw escape;
} | java | protected void doHandleThumbnailRequest(final FileWidgetUpload file) {
// Create thumb nail (if required)
if (file.getThumbnail() == null) {
Image thumbnail = createThumbNail(file.getFile());
file.setThumbnail(thumbnail);
}
ContentEscape escape = new ContentEscape(file.getThumbnail());
throw escape;
} | [
"protected",
"void",
"doHandleThumbnailRequest",
"(",
"final",
"FileWidgetUpload",
"file",
")",
"{",
"// Create thumb nail (if required)",
"if",
"(",
"file",
".",
"getThumbnail",
"(",
")",
"==",
"null",
")",
"{",
"Image",
"thumbnail",
"=",
"createThumbNail",
"(",
"file",
".",
"getFile",
"(",
")",
")",
";",
"file",
".",
"setThumbnail",
"(",
"thumbnail",
")",
";",
"}",
"ContentEscape",
"escape",
"=",
"new",
"ContentEscape",
"(",
"file",
".",
"getThumbnail",
"(",
")",
")",
";",
"throw",
"escape",
";",
"}"
] | Handle the thumb nail request.
@param file the file to process | [
"Handle",
"the",
"thumb",
"nail",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L769-L777 |
139,646 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.getFileUrl | public String getFileUrl(final String fileId) {
FileWidgetUpload file = getFile(fileId);
if (file == null) {
return null;
}
Environment env = getEnvironment();
Map<String, String> parameters = env.getHiddenParameters();
parameters.put(Environment.TARGET_ID, getTargetId());
if (Util.empty(file.getFileCacheKey())) {
// Add some randomness to the URL to prevent caching
String random = WebUtilities.generateRandom();
parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
} else {
// Remove step counter as not required for cached content
parameters.remove(Environment.STEP_VARIABLE);
parameters.remove(Environment.SESSION_TOKEN_VARIABLE);
// Add the cache key
parameters.put(Environment.CONTENT_CACHE_KEY, file.getFileCacheKey());
}
// File id
parameters.put(FILE_UPLOAD_ID_KEY, fileId);
// The targetable path needs to be configured for the portal environment.
String url = env.getWServletPath();
// Note the last parameter. In javascript we don't want to encode "&".
return WebUtilities.getPath(url, parameters, true);
} | java | public String getFileUrl(final String fileId) {
FileWidgetUpload file = getFile(fileId);
if (file == null) {
return null;
}
Environment env = getEnvironment();
Map<String, String> parameters = env.getHiddenParameters();
parameters.put(Environment.TARGET_ID, getTargetId());
if (Util.empty(file.getFileCacheKey())) {
// Add some randomness to the URL to prevent caching
String random = WebUtilities.generateRandom();
parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
} else {
// Remove step counter as not required for cached content
parameters.remove(Environment.STEP_VARIABLE);
parameters.remove(Environment.SESSION_TOKEN_VARIABLE);
// Add the cache key
parameters.put(Environment.CONTENT_CACHE_KEY, file.getFileCacheKey());
}
// File id
parameters.put(FILE_UPLOAD_ID_KEY, fileId);
// The targetable path needs to be configured for the portal environment.
String url = env.getWServletPath();
// Note the last parameter. In javascript we don't want to encode "&".
return WebUtilities.getPath(url, parameters, true);
} | [
"public",
"String",
"getFileUrl",
"(",
"final",
"String",
"fileId",
")",
"{",
"FileWidgetUpload",
"file",
"=",
"getFile",
"(",
"fileId",
")",
";",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Environment",
"env",
"=",
"getEnvironment",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"env",
".",
"getHiddenParameters",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"Environment",
".",
"TARGET_ID",
",",
"getTargetId",
"(",
")",
")",
";",
"if",
"(",
"Util",
".",
"empty",
"(",
"file",
".",
"getFileCacheKey",
"(",
")",
")",
")",
"{",
"// Add some randomness to the URL to prevent caching",
"String",
"random",
"=",
"WebUtilities",
".",
"generateRandom",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"Environment",
".",
"UNIQUE_RANDOM_PARAM",
",",
"random",
")",
";",
"}",
"else",
"{",
"// Remove step counter as not required for cached content",
"parameters",
".",
"remove",
"(",
"Environment",
".",
"STEP_VARIABLE",
")",
";",
"parameters",
".",
"remove",
"(",
"Environment",
".",
"SESSION_TOKEN_VARIABLE",
")",
";",
"// Add the cache key",
"parameters",
".",
"put",
"(",
"Environment",
".",
"CONTENT_CACHE_KEY",
",",
"file",
".",
"getFileCacheKey",
"(",
")",
")",
";",
"}",
"// File id",
"parameters",
".",
"put",
"(",
"FILE_UPLOAD_ID_KEY",
",",
"fileId",
")",
";",
"// The targetable path needs to be configured for the portal environment.",
"String",
"url",
"=",
"env",
".",
"getWServletPath",
"(",
")",
";",
"// Note the last parameter. In javascript we don't want to encode \"&\".",
"return",
"WebUtilities",
".",
"getPath",
"(",
"url",
",",
"parameters",
",",
"true",
")",
";",
"}"
] | Retrieves a URL for the uploaded file content.
@param fileId the file id
@return the URL to access the uploaded file. | [
"Retrieves",
"a",
"URL",
"for",
"the",
"uploaded",
"file",
"content",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L811-L841 |
139,647 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java | WMultiFileWidget.getFileThumbnailUrl | public String getFileThumbnailUrl(final String fileId) {
FileWidgetUpload file = getFile(fileId);
if (file == null) {
return null;
}
// Check static resource
Image thumbnail = file.getThumbnail();
if (thumbnail instanceof InternalResource) {
return ((InternalResource) thumbnail).getTargetUrl();
}
Environment env = getEnvironment();
Map<String, String> parameters = env.getHiddenParameters();
parameters.put(Environment.TARGET_ID, getTargetId());
if (Util.empty(file.getThumbnailCacheKey())) {
// Add some randomness to the URL to prevent caching
String random = WebUtilities.generateRandom();
parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
} else {
// Remove step counter as not required for cached content
parameters.remove(Environment.STEP_VARIABLE);
parameters.remove(Environment.SESSION_TOKEN_VARIABLE);
// Add the cache key
parameters.put(Environment.CONTENT_CACHE_KEY, file.getThumbnailCacheKey());
}
// File id
parameters.put(FILE_UPLOAD_ID_KEY, fileId);
// Thumbnail flag
parameters.put(FILE_UPLOAD_THUMB_NAIL_KEY, "Y");
// The targetable path needs to be configured for the portal environment.
String url = env.getWServletPath();
// Note the last parameter. In javascript we don't want to encode "&".
return WebUtilities.getPath(url, parameters, true);
} | java | public String getFileThumbnailUrl(final String fileId) {
FileWidgetUpload file = getFile(fileId);
if (file == null) {
return null;
}
// Check static resource
Image thumbnail = file.getThumbnail();
if (thumbnail instanceof InternalResource) {
return ((InternalResource) thumbnail).getTargetUrl();
}
Environment env = getEnvironment();
Map<String, String> parameters = env.getHiddenParameters();
parameters.put(Environment.TARGET_ID, getTargetId());
if (Util.empty(file.getThumbnailCacheKey())) {
// Add some randomness to the URL to prevent caching
String random = WebUtilities.generateRandom();
parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
} else {
// Remove step counter as not required for cached content
parameters.remove(Environment.STEP_VARIABLE);
parameters.remove(Environment.SESSION_TOKEN_VARIABLE);
// Add the cache key
parameters.put(Environment.CONTENT_CACHE_KEY, file.getThumbnailCacheKey());
}
// File id
parameters.put(FILE_UPLOAD_ID_KEY, fileId);
// Thumbnail flag
parameters.put(FILE_UPLOAD_THUMB_NAIL_KEY, "Y");
// The targetable path needs to be configured for the portal environment.
String url = env.getWServletPath();
// Note the last parameter. In javascript we don't want to encode "&".
return WebUtilities.getPath(url, parameters, true);
} | [
"public",
"String",
"getFileThumbnailUrl",
"(",
"final",
"String",
"fileId",
")",
"{",
"FileWidgetUpload",
"file",
"=",
"getFile",
"(",
"fileId",
")",
";",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// Check static resource",
"Image",
"thumbnail",
"=",
"file",
".",
"getThumbnail",
"(",
")",
";",
"if",
"(",
"thumbnail",
"instanceof",
"InternalResource",
")",
"{",
"return",
"(",
"(",
"InternalResource",
")",
"thumbnail",
")",
".",
"getTargetUrl",
"(",
")",
";",
"}",
"Environment",
"env",
"=",
"getEnvironment",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"env",
".",
"getHiddenParameters",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"Environment",
".",
"TARGET_ID",
",",
"getTargetId",
"(",
")",
")",
";",
"if",
"(",
"Util",
".",
"empty",
"(",
"file",
".",
"getThumbnailCacheKey",
"(",
")",
")",
")",
"{",
"// Add some randomness to the URL to prevent caching",
"String",
"random",
"=",
"WebUtilities",
".",
"generateRandom",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"Environment",
".",
"UNIQUE_RANDOM_PARAM",
",",
"random",
")",
";",
"}",
"else",
"{",
"// Remove step counter as not required for cached content",
"parameters",
".",
"remove",
"(",
"Environment",
".",
"STEP_VARIABLE",
")",
";",
"parameters",
".",
"remove",
"(",
"Environment",
".",
"SESSION_TOKEN_VARIABLE",
")",
";",
"// Add the cache key",
"parameters",
".",
"put",
"(",
"Environment",
".",
"CONTENT_CACHE_KEY",
",",
"file",
".",
"getThumbnailCacheKey",
"(",
")",
")",
";",
"}",
"// File id",
"parameters",
".",
"put",
"(",
"FILE_UPLOAD_ID_KEY",
",",
"fileId",
")",
";",
"// Thumbnail flag",
"parameters",
".",
"put",
"(",
"FILE_UPLOAD_THUMB_NAIL_KEY",
",",
"\"Y\"",
")",
";",
"// The targetable path needs to be configured for the portal environment.",
"String",
"url",
"=",
"env",
".",
"getWServletPath",
"(",
")",
";",
"// Note the last parameter. In javascript we don't want to encode \"&\".",
"return",
"WebUtilities",
".",
"getPath",
"(",
"url",
",",
"parameters",
",",
"true",
")",
";",
"}"
] | Retrieves a URL for the thumbnail of an uploaded file.
@param fileId the file id
@return the URL to access the thumbnail for an uploaded file. | [
"Retrieves",
"a",
"URL",
"for",
"the",
"thumbnail",
"of",
"an",
"uploaded",
"file",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMultiFileWidget.java#L849-L888 |
139,648 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/FormInterceptor.java | FormInterceptor.serviceRequest | @Override
public void serviceRequest(final Request request) {
// Reset the focus for this new request.
UIContext uic = UIContextHolder.getCurrent();
uic.setFocussed(null, null);
// We've hit the action phase, so we do want focus on this app.
uic.setFocusRequired(true);
super.serviceRequest(request);
} | java | @Override
public void serviceRequest(final Request request) {
// Reset the focus for this new request.
UIContext uic = UIContextHolder.getCurrent();
uic.setFocussed(null, null);
// We've hit the action phase, so we do want focus on this app.
uic.setFocusRequired(true);
super.serviceRequest(request);
} | [
"@",
"Override",
"public",
"void",
"serviceRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"// Reset the focus for this new request.",
"UIContext",
"uic",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"uic",
".",
"setFocussed",
"(",
"null",
",",
"null",
")",
";",
"// We've hit the action phase, so we do want focus on this app.",
"uic",
".",
"setFocusRequired",
"(",
"true",
")",
";",
"super",
".",
"serviceRequest",
"(",
"request",
")",
";",
"}"
] | Override serviceRequest in order to perform processing specific to this interceptor.
@param request the request being responded to. | [
"Override",
"serviceRequest",
"in",
"order",
"to",
"perform",
"processing",
"specific",
"to",
"this",
"interceptor",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/FormInterceptor.java#L22-L32 |
139,649 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/FormInterceptor.java | FormInterceptor.paint | @Override
public void paint(final RenderContext renderContext) {
getBackingComponent().paint(renderContext);
// We don't want to remember the focus for the next render because on
// a multi portlet page, we'd end up with multiple portlets trying to
// set the focus.
UIContext uic = UIContextHolder.getCurrent();
if (uic.isFocusRequired()) {
boolean sticky = ConfigurationProperties.getStickyFocus();
if (!sticky) {
uic.setFocussed(null, null);
uic.setFocusRequired(false);
}
}
} | java | @Override
public void paint(final RenderContext renderContext) {
getBackingComponent().paint(renderContext);
// We don't want to remember the focus for the next render because on
// a multi portlet page, we'd end up with multiple portlets trying to
// set the focus.
UIContext uic = UIContextHolder.getCurrent();
if (uic.isFocusRequired()) {
boolean sticky = ConfigurationProperties.getStickyFocus();
if (!sticky) {
uic.setFocussed(null, null);
uic.setFocusRequired(false);
}
}
} | [
"@",
"Override",
"public",
"void",
"paint",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"getBackingComponent",
"(",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"// We don't want to remember the focus for the next render because on",
"// a multi portlet page, we'd end up with multiple portlets trying to",
"// set the focus.",
"UIContext",
"uic",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"if",
"(",
"uic",
".",
"isFocusRequired",
"(",
")",
")",
"{",
"boolean",
"sticky",
"=",
"ConfigurationProperties",
".",
"getStickyFocus",
"(",
")",
";",
"if",
"(",
"!",
"sticky",
")",
"{",
"uic",
".",
"setFocussed",
"(",
"null",
",",
"null",
")",
";",
"uic",
".",
"setFocusRequired",
"(",
"false",
")",
";",
"}",
"}",
"}"
] | Override paint in order to perform processing specific to this interceptor.
@param renderContext the renderContext to send the output to. | [
"Override",
"paint",
"in",
"order",
"to",
"perform",
"processing",
"specific",
"to",
"this",
"interceptor",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/FormInterceptor.java#L53-L70 |
139,650 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/AbstractSetEnable.java | AbstractSetEnable.applyEnableAction | private void applyEnableAction(final WComponent target, final boolean enabled) {
// Found Disableable component
if (target instanceof Disableable) {
target.setValidate(enabled);
((Disableable) target).setDisabled(!enabled);
} else if (target instanceof Container) { // Apply to any Disableable children
Container cont = (Container) target;
final int size = cont.getChildCount();
for (int i = 0; i < size; i++) {
WComponent child = cont.getChildAt(i);
applyEnableAction(child, enabled);
}
}
} | java | private void applyEnableAction(final WComponent target, final boolean enabled) {
// Found Disableable component
if (target instanceof Disableable) {
target.setValidate(enabled);
((Disableable) target).setDisabled(!enabled);
} else if (target instanceof Container) { // Apply to any Disableable children
Container cont = (Container) target;
final int size = cont.getChildCount();
for (int i = 0; i < size; i++) {
WComponent child = cont.getChildAt(i);
applyEnableAction(child, enabled);
}
}
} | [
"private",
"void",
"applyEnableAction",
"(",
"final",
"WComponent",
"target",
",",
"final",
"boolean",
"enabled",
")",
"{",
"// Found Disableable component",
"if",
"(",
"target",
"instanceof",
"Disableable",
")",
"{",
"target",
".",
"setValidate",
"(",
"enabled",
")",
";",
"(",
"(",
"Disableable",
")",
"target",
")",
".",
"setDisabled",
"(",
"!",
"enabled",
")",
";",
"}",
"else",
"if",
"(",
"target",
"instanceof",
"Container",
")",
"{",
"// Apply to any Disableable children",
"Container",
"cont",
"=",
"(",
"Container",
")",
"target",
";",
"final",
"int",
"size",
"=",
"cont",
".",
"getChildCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"WComponent",
"child",
"=",
"cont",
".",
"getChildAt",
"(",
"i",
")",
";",
"applyEnableAction",
"(",
"child",
",",
"enabled",
")",
";",
"}",
"}",
"}"
] | Apply the enable action against the target and its children.
@param target the target of this action
@param enabled is the evaluated value | [
"Apply",
"the",
"enable",
"action",
"against",
"the",
"target",
"and",
"its",
"children",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/AbstractSetEnable.java#L47-L61 |
139,651 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/TableLoadPerformance.java | TableLoadPerformance.startLoad | private void startLoad() {
tableLayout.setVisible(true);
List<PersonBean> beans = ExampleDataUtil.createExampleData(numRows.getNumber().intValue(),
numDocs.getNumber()
.intValue());
if (isLoadWTable()) {
table.setBean(beans);
}
if (isLoadWDataTable()) {
TableTreeNode tree = createTree(beans);
datatable.setDataModel(new SimpleBeanTreeTableDataModel(
new String[]{"firstName", "lastName",
"dateOfBirth"}, tree));
}
if (isLoadWTable()) {
ajax2.setVisible(true);
tableShim.setVisible(isLoadWTable());
} else {
ajax4.setVisible(true);
dataShim.setVisible(isLoadWDataTable());
}
} | java | private void startLoad() {
tableLayout.setVisible(true);
List<PersonBean> beans = ExampleDataUtil.createExampleData(numRows.getNumber().intValue(),
numDocs.getNumber()
.intValue());
if (isLoadWTable()) {
table.setBean(beans);
}
if (isLoadWDataTable()) {
TableTreeNode tree = createTree(beans);
datatable.setDataModel(new SimpleBeanTreeTableDataModel(
new String[]{"firstName", "lastName",
"dateOfBirth"}, tree));
}
if (isLoadWTable()) {
ajax2.setVisible(true);
tableShim.setVisible(isLoadWTable());
} else {
ajax4.setVisible(true);
dataShim.setVisible(isLoadWDataTable());
}
} | [
"private",
"void",
"startLoad",
"(",
")",
"{",
"tableLayout",
".",
"setVisible",
"(",
"true",
")",
";",
"List",
"<",
"PersonBean",
">",
"beans",
"=",
"ExampleDataUtil",
".",
"createExampleData",
"(",
"numRows",
".",
"getNumber",
"(",
")",
".",
"intValue",
"(",
")",
",",
"numDocs",
".",
"getNumber",
"(",
")",
".",
"intValue",
"(",
")",
")",
";",
"if",
"(",
"isLoadWTable",
"(",
")",
")",
"{",
"table",
".",
"setBean",
"(",
"beans",
")",
";",
"}",
"if",
"(",
"isLoadWDataTable",
"(",
")",
")",
"{",
"TableTreeNode",
"tree",
"=",
"createTree",
"(",
"beans",
")",
";",
"datatable",
".",
"setDataModel",
"(",
"new",
"SimpleBeanTreeTableDataModel",
"(",
"new",
"String",
"[",
"]",
"{",
"\"firstName\"",
",",
"\"lastName\"",
",",
"\"dateOfBirth\"",
"}",
",",
"tree",
")",
")",
";",
"}",
"if",
"(",
"isLoadWTable",
"(",
")",
")",
"{",
"ajax2",
".",
"setVisible",
"(",
"true",
")",
";",
"tableShim",
".",
"setVisible",
"(",
"isLoadWTable",
"(",
")",
")",
";",
"}",
"else",
"{",
"ajax4",
".",
"setVisible",
"(",
"true",
")",
";",
"dataShim",
".",
"setVisible",
"(",
"isLoadWDataTable",
"(",
")",
")",
";",
"}",
"}"
] | Start load. | [
"Start",
"load",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/table/TableLoadPerformance.java#L424-L450 |
139,652 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/AbstractSetMandatory.java | AbstractSetMandatory.applyMandatoryAction | private void applyMandatoryAction(final WComponent target, final boolean mandatory) {
if (target instanceof Mandatable) {
((Mandatable) target).setMandatory(mandatory);
} else if (target instanceof Container) { // Apply to the Mandatable children
Container cont = (Container) target;
final int size = cont.getChildCount();
for (int i = 0; i < size; i++) {
WComponent child = cont.getChildAt(i);
applyMandatoryAction(child, mandatory);
}
}
} | java | private void applyMandatoryAction(final WComponent target, final boolean mandatory) {
if (target instanceof Mandatable) {
((Mandatable) target).setMandatory(mandatory);
} else if (target instanceof Container) { // Apply to the Mandatable children
Container cont = (Container) target;
final int size = cont.getChildCount();
for (int i = 0; i < size; i++) {
WComponent child = cont.getChildAt(i);
applyMandatoryAction(child, mandatory);
}
}
} | [
"private",
"void",
"applyMandatoryAction",
"(",
"final",
"WComponent",
"target",
",",
"final",
"boolean",
"mandatory",
")",
"{",
"if",
"(",
"target",
"instanceof",
"Mandatable",
")",
"{",
"(",
"(",
"Mandatable",
")",
"target",
")",
".",
"setMandatory",
"(",
"mandatory",
")",
";",
"}",
"else",
"if",
"(",
"target",
"instanceof",
"Container",
")",
"{",
"// Apply to the Mandatable children",
"Container",
"cont",
"=",
"(",
"Container",
")",
"target",
";",
"final",
"int",
"size",
"=",
"cont",
".",
"getChildCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"WComponent",
"child",
"=",
"cont",
".",
"getChildAt",
"(",
"i",
")",
";",
"applyMandatoryAction",
"(",
"child",
",",
"mandatory",
")",
";",
"}",
"}",
"}"
] | Apply the mandatory action against the target and its children.
@param target the target of this action
@param mandatory is the evaluated value | [
"Apply",
"the",
"mandatory",
"action",
"against",
"the",
"target",
"and",
"its",
"children",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/AbstractSetMandatory.java#L46-L58 |
139,653 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WShufflerRenderer.java | WShufflerRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WShuffler shuffler = (WShuffler) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = shuffler.isReadOnly();
// Start tag
xml.appendTagOpen("ui:shuffler");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", shuffler.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendOptionalAttribute("disabled", shuffler.isDisabled(), "true");
xml.appendOptionalAttribute("toolTip", shuffler.getToolTip());
xml.appendOptionalAttribute("accessibleText", shuffler.getAccessibleText());
int rows = shuffler.getRows();
xml.appendOptionalAttribute("rows", rows > 0, rows);
}
xml.appendClose();
// Options
List<?> options = shuffler.getOptions();
if (options != null && !options.isEmpty()) {
for (int i = 0; i < options.size(); i++) {
String stringOption = String.valueOf(options.get(i));
xml.appendTagOpen("ui:option");
xml.appendAttribute("value", stringOption);
xml.appendClose();
xml.appendEscaped(stringOption);
xml.appendEndTag("ui:option");
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(shuffler, renderContext);
}
// End tag
xml.appendEndTag("ui:shuffler");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WShuffler shuffler = (WShuffler) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = shuffler.isReadOnly();
// Start tag
xml.appendTagOpen("ui:shuffler");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", shuffler.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendOptionalAttribute("disabled", shuffler.isDisabled(), "true");
xml.appendOptionalAttribute("toolTip", shuffler.getToolTip());
xml.appendOptionalAttribute("accessibleText", shuffler.getAccessibleText());
int rows = shuffler.getRows();
xml.appendOptionalAttribute("rows", rows > 0, rows);
}
xml.appendClose();
// Options
List<?> options = shuffler.getOptions();
if (options != null && !options.isEmpty()) {
for (int i = 0; i < options.size(); i++) {
String stringOption = String.valueOf(options.get(i));
xml.appendTagOpen("ui:option");
xml.appendAttribute("value", stringOption);
xml.appendClose();
xml.appendEscaped(stringOption);
xml.appendEndTag("ui:option");
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(shuffler, renderContext);
}
// End tag
xml.appendEndTag("ui:shuffler");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WShuffler",
"shuffler",
"=",
"(",
"WShuffler",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"readOnly",
"=",
"shuffler",
".",
"isReadOnly",
"(",
")",
";",
"// Start tag",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:shuffler\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"shuffler",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"if",
"(",
"readOnly",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"readOnly\"",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"shuffler",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"toolTip\"",
",",
"shuffler",
".",
"getToolTip",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"accessibleText\"",
",",
"shuffler",
".",
"getAccessibleText",
"(",
")",
")",
";",
"int",
"rows",
"=",
"shuffler",
".",
"getRows",
"(",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"rows\"",
",",
"rows",
">",
"0",
",",
"rows",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Options",
"List",
"<",
"?",
">",
"options",
"=",
"shuffler",
".",
"getOptions",
"(",
")",
";",
"if",
"(",
"options",
"!=",
"null",
"&&",
"!",
"options",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"stringOption",
"=",
"String",
".",
"valueOf",
"(",
"options",
".",
"get",
"(",
"i",
")",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:option\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"value\"",
",",
"stringOption",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"xml",
".",
"appendEscaped",
"(",
"stringOption",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:option\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"readOnly",
")",
"{",
"DiagnosticRenderUtil",
".",
"renderDiagnostics",
"(",
"shuffler",
",",
"renderContext",
")",
";",
"}",
"// End tag",
"xml",
".",
"appendEndTag",
"(",
"\"ui:shuffler\"",
")",
";",
"}"
] | Paints the given WShuffler.
@param component the WShuffler to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WShuffler",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WShufflerRenderer.java#L24-L66 |
139,654 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.deriveId | private String deriveId(final String idName) {
// Find parent naming context
NamingContextable parent = WebUtilities.getParentNamingContext(this);
// No Parent
if (parent == null) {
return idName;
}
// Get ID prefix
String prefix = parent.getNamingContextId();
// No Prefix, just use id name
if (prefix.length() == 0) {
return idName;
}
// Add Prefix
StringBuffer nameBuf = new StringBuffer(prefix.length() + idName.length() + 1);
nameBuf.append(prefix);
nameBuf.append(ID_CONTEXT_SEPERATOR);
nameBuf.append(idName);
return nameBuf.toString();
} | java | private String deriveId(final String idName) {
// Find parent naming context
NamingContextable parent = WebUtilities.getParentNamingContext(this);
// No Parent
if (parent == null) {
return idName;
}
// Get ID prefix
String prefix = parent.getNamingContextId();
// No Prefix, just use id name
if (prefix.length() == 0) {
return idName;
}
// Add Prefix
StringBuffer nameBuf = new StringBuffer(prefix.length() + idName.length() + 1);
nameBuf.append(prefix);
nameBuf.append(ID_CONTEXT_SEPERATOR);
nameBuf.append(idName);
return nameBuf.toString();
} | [
"private",
"String",
"deriveId",
"(",
"final",
"String",
"idName",
")",
"{",
"// Find parent naming context",
"NamingContextable",
"parent",
"=",
"WebUtilities",
".",
"getParentNamingContext",
"(",
"this",
")",
";",
"// No Parent",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
"idName",
";",
"}",
"// Get ID prefix",
"String",
"prefix",
"=",
"parent",
".",
"getNamingContextId",
"(",
")",
";",
"// No Prefix, just use id name",
"if",
"(",
"prefix",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"idName",
";",
"}",
"// Add Prefix",
"StringBuffer",
"nameBuf",
"=",
"new",
"StringBuffer",
"(",
"prefix",
".",
"length",
"(",
")",
"+",
"idName",
".",
"length",
"(",
")",
"+",
"1",
")",
";",
"nameBuf",
".",
"append",
"(",
"prefix",
")",
";",
"nameBuf",
".",
"append",
"(",
"ID_CONTEXT_SEPERATOR",
")",
";",
"nameBuf",
".",
"append",
"(",
"idName",
")",
";",
"return",
"nameBuf",
".",
"toString",
"(",
")",
";",
"}"
] | Derive the full id from its naming context.
@param idName the component id name
@return the derived id in its context | [
"Derive",
"the",
"full",
"id",
"from",
"its",
"naming",
"context",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L283-L307 |
139,655 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.registerInContext | void registerInContext() {
if (!ConfigurationProperties.getCheckDuplicateIds()) {
return;
}
// Register Component if it has an ID name set
if (getIdName() != null) {
// Find parent context
NamingContextable context = WebUtilities.getParentNamingContext(this);
if (context == null) {
// If this is the top context, then register itself
if (WebUtilities.isActiveNamingContext(this)) {
this.registerId(this);
} else {
LOG.warn("Component with id name [" + getIdName()
+ "] is not in a naming context and cannot be verified for duplicate id.");
}
return;
}
// Assume context is AbstractWComponent
((AbstractWComponent) context).registerId(this);
}
} | java | void registerInContext() {
if (!ConfigurationProperties.getCheckDuplicateIds()) {
return;
}
// Register Component if it has an ID name set
if (getIdName() != null) {
// Find parent context
NamingContextable context = WebUtilities.getParentNamingContext(this);
if (context == null) {
// If this is the top context, then register itself
if (WebUtilities.isActiveNamingContext(this)) {
this.registerId(this);
} else {
LOG.warn("Component with id name [" + getIdName()
+ "] is not in a naming context and cannot be verified for duplicate id.");
}
return;
}
// Assume context is AbstractWComponent
((AbstractWComponent) context).registerId(this);
}
} | [
"void",
"registerInContext",
"(",
")",
"{",
"if",
"(",
"!",
"ConfigurationProperties",
".",
"getCheckDuplicateIds",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Register Component if it has an ID name set",
"if",
"(",
"getIdName",
"(",
")",
"!=",
"null",
")",
"{",
"// Find parent context",
"NamingContextable",
"context",
"=",
"WebUtilities",
".",
"getParentNamingContext",
"(",
"this",
")",
";",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"// If this is the top context, then register itself",
"if",
"(",
"WebUtilities",
".",
"isActiveNamingContext",
"(",
"this",
")",
")",
"{",
"this",
".",
"registerId",
"(",
"this",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Component with id name [\"",
"+",
"getIdName",
"(",
")",
"+",
"\"] is not in a naming context and cannot be verified for duplicate id.\"",
")",
";",
"}",
"return",
";",
"}",
"// Assume context is AbstractWComponent",
"(",
"(",
"AbstractWComponent",
")",
"context",
")",
".",
"registerId",
"(",
"this",
")",
";",
"}",
"}"
] | Register this component's ID in its naming context. | [
"Register",
"this",
"component",
"s",
"ID",
"in",
"its",
"naming",
"context",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L312-L335 |
139,656 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.invokeLaters | protected void invokeLaters() {
if (getParent() == null) {
UIContext uic = UIContextHolder.getCurrent();
if (uic != null) {
uic.doInvokeLaters();
}
}
} | java | protected void invokeLaters() {
if (getParent() == null) {
UIContext uic = UIContextHolder.getCurrent();
if (uic != null) {
uic.doInvokeLaters();
}
}
} | [
"protected",
"void",
"invokeLaters",
"(",
")",
"{",
"if",
"(",
"getParent",
"(",
")",
"==",
"null",
")",
"{",
"UIContext",
"uic",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"if",
"(",
"uic",
"!=",
"null",
")",
"{",
"uic",
".",
"doInvokeLaters",
"(",
")",
";",
"}",
"}",
"}"
] | The framework calls this method at the end of the serviceRequest method. The default implementation is that only
a root wcomponent actually runs them. | [
"The",
"framework",
"calls",
"this",
"method",
"at",
"the",
"end",
"of",
"the",
"serviceRequest",
"method",
".",
"The",
"default",
"implementation",
"is",
"that",
"only",
"a",
"root",
"wcomponent",
"actually",
"runs",
"them",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L454-L462 |
139,657 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.paintComponent | protected void paintComponent(final RenderContext renderContext) {
Renderer renderer = UIManager.getRenderer(this, renderContext);
if (getTemplate() != null || getTemplateMarkUp() != null) {
Renderer templateRenderer = UIManager.getTemplateRenderer(renderContext);
templateRenderer.render(this, renderContext);
} else if (renderer == null) {
// Default is juxtaposition
List<WComponent> children = getComponentModel().getChildren();
if (children != null) {
final int size = children.size();
for (int i = 0; i < size; i++) {
children.get(i).paint(renderContext);
}
}
} else {
renderer.render(this, renderContext);
}
} | java | protected void paintComponent(final RenderContext renderContext) {
Renderer renderer = UIManager.getRenderer(this, renderContext);
if (getTemplate() != null || getTemplateMarkUp() != null) {
Renderer templateRenderer = UIManager.getTemplateRenderer(renderContext);
templateRenderer.render(this, renderContext);
} else if (renderer == null) {
// Default is juxtaposition
List<WComponent> children = getComponentModel().getChildren();
if (children != null) {
final int size = children.size();
for (int i = 0; i < size; i++) {
children.get(i).paint(renderContext);
}
}
} else {
renderer.render(this, renderContext);
}
} | [
"protected",
"void",
"paintComponent",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"Renderer",
"renderer",
"=",
"UIManager",
".",
"getRenderer",
"(",
"this",
",",
"renderContext",
")",
";",
"if",
"(",
"getTemplate",
"(",
")",
"!=",
"null",
"||",
"getTemplateMarkUp",
"(",
")",
"!=",
"null",
")",
"{",
"Renderer",
"templateRenderer",
"=",
"UIManager",
".",
"getTemplateRenderer",
"(",
"renderContext",
")",
";",
"templateRenderer",
".",
"render",
"(",
"this",
",",
"renderContext",
")",
";",
"}",
"else",
"if",
"(",
"renderer",
"==",
"null",
")",
"{",
"// Default is juxtaposition",
"List",
"<",
"WComponent",
">",
"children",
"=",
"getComponentModel",
"(",
")",
".",
"getChildren",
"(",
")",
";",
"if",
"(",
"children",
"!=",
"null",
")",
"{",
"final",
"int",
"size",
"=",
"children",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"children",
".",
"get",
"(",
"i",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"}",
"}",
"}",
"else",
"{",
"renderer",
".",
"render",
"(",
"this",
",",
"renderContext",
")",
";",
"}",
"}"
] | This is where most of the painting work is normally done. If a layout has been supplied either directly or by
supplying a velocity template, then painting is delegated to the layout manager. If there is no layout, the
default behaviour is to paint the child components in sequence.
@param renderContext the context to render to. | [
"This",
"is",
"where",
"most",
"of",
"the",
"painting",
"work",
"is",
"normally",
"done",
".",
"If",
"a",
"layout",
"has",
"been",
"supplied",
"either",
"directly",
"or",
"by",
"supplying",
"a",
"velocity",
"template",
"then",
"painting",
"is",
"delegated",
"to",
"the",
"layout",
"manager",
".",
"If",
"there",
"is",
"no",
"layout",
"the",
"default",
"behaviour",
"is",
"to",
"paint",
"the",
"child",
"components",
"in",
"sequence",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L672-L692 |
139,658 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.createErrorDiagnostic | protected Diagnostic createErrorDiagnostic(final WComponent source, final String message,
final Serializable... args) {
return new DiagnosticImpl(Diagnostic.ERROR, source, message, args);
} | java | protected Diagnostic createErrorDiagnostic(final WComponent source, final String message,
final Serializable... args) {
return new DiagnosticImpl(Diagnostic.ERROR, source, message, args);
} | [
"protected",
"Diagnostic",
"createErrorDiagnostic",
"(",
"final",
"WComponent",
"source",
",",
"final",
"String",
"message",
",",
"final",
"Serializable",
"...",
"args",
")",
"{",
"return",
"new",
"DiagnosticImpl",
"(",
"Diagnostic",
".",
"ERROR",
",",
"source",
",",
"message",
",",
"args",
")",
";",
"}"
] | Create and return an error diagnostic associated to the given error source.
@param source the source of the error.
@param message the error message, using {@link MessageFormat} syntax.
@param args optional arguments for the message.
@return an error diagnostic for this component. | [
"Create",
"and",
"return",
"an",
"error",
"diagnostic",
"associated",
"to",
"the",
"given",
"error",
"source",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L772-L775 |
139,659 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.setFlag | protected void setFlag(final int mask, final boolean flag) {
// Only store the flag value if it is not the default.
if (flag != isFlagSet(mask)) {
ComponentModel model = getOrCreateComponentModel();
model.setFlags(switchFlag(model.getFlags(), mask, flag));
}
} | java | protected void setFlag(final int mask, final boolean flag) {
// Only store the flag value if it is not the default.
if (flag != isFlagSet(mask)) {
ComponentModel model = getOrCreateComponentModel();
model.setFlags(switchFlag(model.getFlags(), mask, flag));
}
} | [
"protected",
"void",
"setFlag",
"(",
"final",
"int",
"mask",
",",
"final",
"boolean",
"flag",
")",
"{",
"// Only store the flag value if it is not the default.",
"if",
"(",
"flag",
"!=",
"isFlagSet",
"(",
"mask",
")",
")",
"{",
"ComponentModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"model",
".",
"setFlags",
"(",
"switchFlag",
"(",
"model",
".",
"getFlags",
"(",
")",
",",
"mask",
",",
"flag",
")",
")",
";",
"}",
"}"
] | Sets or clears one or more component flags in the component model for the given context..
@param mask the bit mask for the flags to set/clear.
@param flag true to set the flag(s), false to clear. | [
"Sets",
"or",
"clears",
"one",
"or",
"more",
"component",
"flags",
"in",
"the",
"component",
"model",
"for",
"the",
"given",
"context",
".."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L977-L983 |
139,660 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.switchFlag | private static int switchFlag(final int flags, final int mask, final boolean value) {
int newFlags = value ? flags | mask : flags & ~mask;
return newFlags;
} | java | private static int switchFlag(final int flags, final int mask, final boolean value) {
int newFlags = value ? flags | mask : flags & ~mask;
return newFlags;
} | [
"private",
"static",
"int",
"switchFlag",
"(",
"final",
"int",
"flags",
",",
"final",
"int",
"mask",
",",
"final",
"boolean",
"value",
")",
"{",
"int",
"newFlags",
"=",
"value",
"?",
"flags",
"|",
"mask",
":",
"flags",
"&",
"~",
"mask",
";",
"return",
"newFlags",
";",
"}"
] | A utility method to set or clear one or more bits in the given set of flags.
@param flags the current set of flags.
@param mask the bit mask for the flags to set/clear.
@param value true to set the flag(s), false to clear.
@return the new set of flags. | [
"A",
"utility",
"method",
"to",
"set",
"or",
"clear",
"one",
"or",
"more",
"bits",
"in",
"the",
"given",
"set",
"of",
"flags",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L993-L996 |
139,661 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.getComponentModel | protected ComponentModel getComponentModel() {
UIContext effectiveContext = UIContextHolder.getCurrent();
if (effectiveContext == null) {
return sharedModel;
} else {
ComponentModel model = (ComponentModel) effectiveContext.getModel(this);
if (model == null) {
return sharedModel;
} else if (model.getSharedModel() == null) {
// The reference to the sharedModel has disappeared,
// probably due to session serialization
model.setSharedModel(sharedModel);
}
return model;
}
} | java | protected ComponentModel getComponentModel() {
UIContext effectiveContext = UIContextHolder.getCurrent();
if (effectiveContext == null) {
return sharedModel;
} else {
ComponentModel model = (ComponentModel) effectiveContext.getModel(this);
if (model == null) {
return sharedModel;
} else if (model.getSharedModel() == null) {
// The reference to the sharedModel has disappeared,
// probably due to session serialization
model.setSharedModel(sharedModel);
}
return model;
}
} | [
"protected",
"ComponentModel",
"getComponentModel",
"(",
")",
"{",
"UIContext",
"effectiveContext",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"if",
"(",
"effectiveContext",
"==",
"null",
")",
"{",
"return",
"sharedModel",
";",
"}",
"else",
"{",
"ComponentModel",
"model",
"=",
"(",
"ComponentModel",
")",
"effectiveContext",
".",
"getModel",
"(",
"this",
")",
";",
"if",
"(",
"model",
"==",
"null",
")",
"{",
"return",
"sharedModel",
";",
"}",
"else",
"if",
"(",
"model",
".",
"getSharedModel",
"(",
")",
"==",
"null",
")",
"{",
"// The reference to the sharedModel has disappeared,",
"// probably due to session serialization",
"model",
".",
"setSharedModel",
"(",
"sharedModel",
")",
";",
"}",
"return",
"model",
";",
"}",
"}"
] | Returns the effective component model for this component. Subclass may override this method to narrow the return
type to their specific model type.
@return the effective component model | [
"Returns",
"the",
"effective",
"component",
"model",
"for",
"this",
"component",
".",
"Subclass",
"may",
"override",
"this",
"method",
"to",
"narrow",
"the",
"return",
"type",
"to",
"their",
"specific",
"model",
"type",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1113-L1131 |
139,662 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.getOrCreateComponentModel | protected ComponentModel getOrCreateComponentModel() {
ComponentModel model = getComponentModel();
if (locked && model == sharedModel) {
UIContext effectiveContext = UIContextHolder.getCurrent();
if (effectiveContext != null) {
model = newComponentModel();
model.setSharedModel(sharedModel);
effectiveContext.setModel(this, model);
initialiseComponentModel();
}
}
return model;
} | java | protected ComponentModel getOrCreateComponentModel() {
ComponentModel model = getComponentModel();
if (locked && model == sharedModel) {
UIContext effectiveContext = UIContextHolder.getCurrent();
if (effectiveContext != null) {
model = newComponentModel();
model.setSharedModel(sharedModel);
effectiveContext.setModel(this, model);
initialiseComponentModel();
}
}
return model;
} | [
"protected",
"ComponentModel",
"getOrCreateComponentModel",
"(",
")",
"{",
"ComponentModel",
"model",
"=",
"getComponentModel",
"(",
")",
";",
"if",
"(",
"locked",
"&&",
"model",
"==",
"sharedModel",
")",
"{",
"UIContext",
"effectiveContext",
"=",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
";",
"if",
"(",
"effectiveContext",
"!=",
"null",
")",
"{",
"model",
"=",
"newComponentModel",
"(",
")",
";",
"model",
".",
"setSharedModel",
"(",
"sharedModel",
")",
";",
"effectiveContext",
".",
"setModel",
"(",
"this",
",",
"model",
")",
";",
"initialiseComponentModel",
"(",
")",
";",
"}",
"}",
"return",
"model",
";",
"}"
] | Retrieves the model for this component so that it can be modified. If this method is called during request
processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override
this method to narrow the return type to their specific model type.
@return the model for this component | [
"Retrieves",
"the",
"model",
"for",
"this",
"component",
"so",
"that",
"it",
"can",
"be",
"modified",
".",
"If",
"this",
"method",
"is",
"called",
"during",
"request",
"processing",
"and",
"a",
"session",
"specific",
"model",
"does",
"not",
"yet",
"exist",
"then",
"a",
"new",
"model",
"is",
"created",
".",
"Subclasses",
"may",
"override",
"this",
"method",
"to",
"narrow",
"the",
"return",
"type",
"to",
"their",
"specific",
"model",
"type",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1150-L1166 |
139,663 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.getChildAt | WComponent getChildAt(final int index) {
ComponentModel model = getComponentModel();
return model.getChildren().get(index);
} | java | WComponent getChildAt(final int index) {
ComponentModel model = getComponentModel();
return model.getChildren().get(index);
} | [
"WComponent",
"getChildAt",
"(",
"final",
"int",
"index",
")",
"{",
"ComponentModel",
"model",
"=",
"getComponentModel",
"(",
")",
";",
"return",
"model",
".",
"getChildren",
"(",
")",
".",
"get",
"(",
"index",
")",
";",
"}"
] | Retrieves a child component by its index.
@param index the index of the child component to be retrieved.
@return the child component at the given index. | [
"Retrieves",
"a",
"child",
"component",
"by",
"its",
"index",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1303-L1306 |
139,664 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.getIndexOfChild | int getIndexOfChild(final WComponent childComponent) {
ComponentModel model = getComponentModel();
List<WComponent> children = model.getChildren();
return children == null ? -1 : children.indexOf(childComponent);
} | java | int getIndexOfChild(final WComponent childComponent) {
ComponentModel model = getComponentModel();
List<WComponent> children = model.getChildren();
return children == null ? -1 : children.indexOf(childComponent);
} | [
"int",
"getIndexOfChild",
"(",
"final",
"WComponent",
"childComponent",
")",
"{",
"ComponentModel",
"model",
"=",
"getComponentModel",
"(",
")",
";",
"List",
"<",
"WComponent",
">",
"children",
"=",
"model",
".",
"getChildren",
"(",
")",
";",
"return",
"children",
"==",
"null",
"?",
"-",
"1",
":",
"children",
".",
"indexOf",
"(",
"childComponent",
")",
";",
"}"
] | Retrieves the index of the given child.
@param childComponent the child component to retrieve the index for.
@return the index of the given child component, or -1 if the component is not a child of this component. | [
"Retrieves",
"the",
"index",
"of",
"the",
"given",
"child",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1314-L1319 |
139,665 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.getChildren | List<WComponent> getChildren() {
List<WComponent> children = getComponentModel().getChildren();
return children != null && !children.isEmpty()
? Collections.unmodifiableList(children)
: Collections.<WComponent>emptyList();
} | java | List<WComponent> getChildren() {
List<WComponent> children = getComponentModel().getChildren();
return children != null && !children.isEmpty()
? Collections.unmodifiableList(children)
: Collections.<WComponent>emptyList();
} | [
"List",
"<",
"WComponent",
">",
"getChildren",
"(",
")",
"{",
"List",
"<",
"WComponent",
">",
"children",
"=",
"getComponentModel",
"(",
")",
".",
"getChildren",
"(",
")",
";",
"return",
"children",
"!=",
"null",
"&&",
"!",
"children",
".",
"isEmpty",
"(",
")",
"?",
"Collections",
".",
"unmodifiableList",
"(",
"children",
")",
":",
"Collections",
".",
"<",
"WComponent",
">",
"emptyList",
"(",
")",
";",
"}"
] | Retrieves the children of this component.
@return a list containing the children of this component, or an empty list. | [
"Retrieves",
"the",
"children",
"of",
"this",
"component",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1326-L1332 |
139,666 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.add | void add(final WComponent component) {
assertAddSupported(component);
assertNotReparenting(component);
if (!(this instanceof Container)) {
throw new UnsupportedOperationException("Components can only be added to a container");
}
ComponentModel model = getOrCreateComponentModel();
if (model.getChildren() == null) {
model.setChildren(new ArrayList<WComponent>(1));
}
model.getChildren().add(component);
if (isLocked()) {
component.setLocked(true);
}
if (component instanceof AbstractWComponent) {
((AbstractWComponent) component).getOrCreateComponentModel().setParent((Container) this);
((AbstractWComponent) component).addNotify();
}
} | java | void add(final WComponent component) {
assertAddSupported(component);
assertNotReparenting(component);
if (!(this instanceof Container)) {
throw new UnsupportedOperationException("Components can only be added to a container");
}
ComponentModel model = getOrCreateComponentModel();
if (model.getChildren() == null) {
model.setChildren(new ArrayList<WComponent>(1));
}
model.getChildren().add(component);
if (isLocked()) {
component.setLocked(true);
}
if (component instanceof AbstractWComponent) {
((AbstractWComponent) component).getOrCreateComponentModel().setParent((Container) this);
((AbstractWComponent) component).addNotify();
}
} | [
"void",
"add",
"(",
"final",
"WComponent",
"component",
")",
"{",
"assertAddSupported",
"(",
"component",
")",
";",
"assertNotReparenting",
"(",
"component",
")",
";",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Container",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Components can only be added to a container\"",
")",
";",
"}",
"ComponentModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"if",
"(",
"model",
".",
"getChildren",
"(",
")",
"==",
"null",
")",
"{",
"model",
".",
"setChildren",
"(",
"new",
"ArrayList",
"<",
"WComponent",
">",
"(",
"1",
")",
")",
";",
"}",
"model",
".",
"getChildren",
"(",
")",
".",
"add",
"(",
"component",
")",
";",
"if",
"(",
"isLocked",
"(",
")",
")",
"{",
"component",
".",
"setLocked",
"(",
"true",
")",
";",
"}",
"if",
"(",
"component",
"instanceof",
"AbstractWComponent",
")",
"{",
"(",
"(",
"AbstractWComponent",
")",
"component",
")",
".",
"getOrCreateComponentModel",
"(",
")",
".",
"setParent",
"(",
"(",
"Container",
")",
"this",
")",
";",
"(",
"(",
"AbstractWComponent",
")",
"component",
")",
".",
"addNotify",
"(",
")",
";",
"}",
"}"
] | Adds the given component as a child of this component.
@param component the component to add. | [
"Adds",
"the",
"given",
"component",
"as",
"a",
"child",
"of",
"this",
"component",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1364-L1388 |
139,667 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.remove | void remove(final WComponent aChild) {
ComponentModel model = getOrCreateComponentModel();
if (model.getChildren() == null) {
model.setChildren(copyChildren(getComponentModel().getChildren()));
}
if (model.getChildren().remove(aChild)) {
// Deallocate children list if possible, to reduce session size.
if (model.getChildren().isEmpty()) {
model.setChildren(null);
}
// The child component has been successfully removed so clean up the context.
aChild.reset();
// If the parent has been set in the shared model, we must override
// it in the session model for the component to be considered removed.
// This unfortunately means that the model will remain in the user's session.
if (aChild.getParent() != null && aChild instanceof AbstractWComponent) {
((AbstractWComponent) aChild).getOrCreateComponentModel().setParent(null);
((AbstractWComponent) aChild).removeNotify();
}
}
} | java | void remove(final WComponent aChild) {
ComponentModel model = getOrCreateComponentModel();
if (model.getChildren() == null) {
model.setChildren(copyChildren(getComponentModel().getChildren()));
}
if (model.getChildren().remove(aChild)) {
// Deallocate children list if possible, to reduce session size.
if (model.getChildren().isEmpty()) {
model.setChildren(null);
}
// The child component has been successfully removed so clean up the context.
aChild.reset();
// If the parent has been set in the shared model, we must override
// it in the session model for the component to be considered removed.
// This unfortunately means that the model will remain in the user's session.
if (aChild.getParent() != null && aChild instanceof AbstractWComponent) {
((AbstractWComponent) aChild).getOrCreateComponentModel().setParent(null);
((AbstractWComponent) aChild).removeNotify();
}
}
} | [
"void",
"remove",
"(",
"final",
"WComponent",
"aChild",
")",
"{",
"ComponentModel",
"model",
"=",
"getOrCreateComponentModel",
"(",
")",
";",
"if",
"(",
"model",
".",
"getChildren",
"(",
")",
"==",
"null",
")",
"{",
"model",
".",
"setChildren",
"(",
"copyChildren",
"(",
"getComponentModel",
"(",
")",
".",
"getChildren",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"model",
".",
"getChildren",
"(",
")",
".",
"remove",
"(",
"aChild",
")",
")",
"{",
"// Deallocate children list if possible, to reduce session size.",
"if",
"(",
"model",
".",
"getChildren",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"model",
".",
"setChildren",
"(",
"null",
")",
";",
"}",
"// The child component has been successfully removed so clean up the context.",
"aChild",
".",
"reset",
"(",
")",
";",
"// If the parent has been set in the shared model, we must override",
"// it in the session model for the component to be considered removed.",
"// This unfortunately means that the model will remain in the user's session.",
"if",
"(",
"aChild",
".",
"getParent",
"(",
")",
"!=",
"null",
"&&",
"aChild",
"instanceof",
"AbstractWComponent",
")",
"{",
"(",
"(",
"AbstractWComponent",
")",
"aChild",
")",
".",
"getOrCreateComponentModel",
"(",
")",
".",
"setParent",
"(",
"null",
")",
";",
"(",
"(",
"AbstractWComponent",
")",
"aChild",
")",
".",
"removeNotify",
"(",
")",
";",
"}",
"}",
"}"
] | Removes the given component from this component's list of children.
@param aChild child component | [
"Removes",
"the",
"given",
"component",
"from",
"this",
"component",
"s",
"list",
"of",
"children",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1419-L1443 |
139,668 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.copyChildren | private static List<WComponent> copyChildren(final List<WComponent> children) {
ArrayList<WComponent> copy;
if (children == null) {
copy = new ArrayList<>(1);
} else {
copy = new ArrayList<>(children);
}
return copy;
} | java | private static List<WComponent> copyChildren(final List<WComponent> children) {
ArrayList<WComponent> copy;
if (children == null) {
copy = new ArrayList<>(1);
} else {
copy = new ArrayList<>(children);
}
return copy;
} | [
"private",
"static",
"List",
"<",
"WComponent",
">",
"copyChildren",
"(",
"final",
"List",
"<",
"WComponent",
">",
"children",
")",
"{",
"ArrayList",
"<",
"WComponent",
">",
"copy",
";",
"if",
"(",
"children",
"==",
"null",
")",
"{",
"copy",
"=",
"new",
"ArrayList",
"<>",
"(",
"1",
")",
";",
"}",
"else",
"{",
"copy",
"=",
"new",
"ArrayList",
"<>",
"(",
"children",
")",
";",
"}",
"return",
"copy",
";",
"}"
] | Creates a copy of the given list of components.
@param children the list to copy.
@return a copy of the list. | [
"Creates",
"a",
"copy",
"of",
"the",
"given",
"list",
"of",
"components",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1460-L1470 |
139,669 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java | AbstractWComponent.writeReplace | protected Object writeReplace() throws ObjectStreamException {
WComponent top = WebUtilities.getTop(this);
String repositoryKey;
if (top instanceof WApplication) {
repositoryKey = ((WApplication) top).getUiVersionKey();
} else {
repositoryKey = top.getClass().getName();
}
if (UIRegistry.getInstance().isRegistered(repositoryKey)
&& top == UIRegistry.getInstance().getUI(repositoryKey)) {
// Calculate the node location.
// The node location is a list of "shared" child indexes of each
// ancestor going right back to the top node.
ArrayList<Integer> reversedIndexList = new ArrayList<>();
WComponent node = this;
Container parent = node.getParent();
try {
while (parent != null) {
int index = getIndexOfChild(parent, node);
reversedIndexList.add(index);
node = parent;
parent = node.getParent();
}
} catch (Exception ex) {
LOG.error("Unable to determine component index relative to top.", ex);
}
final int depth = reversedIndexList.size();
int[] nodeLocation = new int[depth];
for (int i = 0; i < depth; i++) {
Integer index = reversedIndexList.get(depth - i - 1);
nodeLocation[i] = index.intValue();
}
WComponentRef ref = new WComponentRef(repositoryKey, nodeLocation);
if (LOG.isDebugEnabled()) {
LOG.debug(
"WComponent converted to reference. Ref = " + ref + ". Component = " + getClass().
getName());
}
return ref;
} else {
LOG.debug(
"WComponent not accessible via the repository, so it will be serialised. Component = "
+ getClass().getName());
return this;
}
} | java | protected Object writeReplace() throws ObjectStreamException {
WComponent top = WebUtilities.getTop(this);
String repositoryKey;
if (top instanceof WApplication) {
repositoryKey = ((WApplication) top).getUiVersionKey();
} else {
repositoryKey = top.getClass().getName();
}
if (UIRegistry.getInstance().isRegistered(repositoryKey)
&& top == UIRegistry.getInstance().getUI(repositoryKey)) {
// Calculate the node location.
// The node location is a list of "shared" child indexes of each
// ancestor going right back to the top node.
ArrayList<Integer> reversedIndexList = new ArrayList<>();
WComponent node = this;
Container parent = node.getParent();
try {
while (parent != null) {
int index = getIndexOfChild(parent, node);
reversedIndexList.add(index);
node = parent;
parent = node.getParent();
}
} catch (Exception ex) {
LOG.error("Unable to determine component index relative to top.", ex);
}
final int depth = reversedIndexList.size();
int[] nodeLocation = new int[depth];
for (int i = 0; i < depth; i++) {
Integer index = reversedIndexList.get(depth - i - 1);
nodeLocation[i] = index.intValue();
}
WComponentRef ref = new WComponentRef(repositoryKey, nodeLocation);
if (LOG.isDebugEnabled()) {
LOG.debug(
"WComponent converted to reference. Ref = " + ref + ". Component = " + getClass().
getName());
}
return ref;
} else {
LOG.debug(
"WComponent not accessible via the repository, so it will be serialised. Component = "
+ getClass().getName());
return this;
}
} | [
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"ObjectStreamException",
"{",
"WComponent",
"top",
"=",
"WebUtilities",
".",
"getTop",
"(",
"this",
")",
";",
"String",
"repositoryKey",
";",
"if",
"(",
"top",
"instanceof",
"WApplication",
")",
"{",
"repositoryKey",
"=",
"(",
"(",
"WApplication",
")",
"top",
")",
".",
"getUiVersionKey",
"(",
")",
";",
"}",
"else",
"{",
"repositoryKey",
"=",
"top",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"UIRegistry",
".",
"getInstance",
"(",
")",
".",
"isRegistered",
"(",
"repositoryKey",
")",
"&&",
"top",
"==",
"UIRegistry",
".",
"getInstance",
"(",
")",
".",
"getUI",
"(",
"repositoryKey",
")",
")",
"{",
"// Calculate the node location.",
"// The node location is a list of \"shared\" child indexes of each",
"// ancestor going right back to the top node.",
"ArrayList",
"<",
"Integer",
">",
"reversedIndexList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"WComponent",
"node",
"=",
"this",
";",
"Container",
"parent",
"=",
"node",
".",
"getParent",
"(",
")",
";",
"try",
"{",
"while",
"(",
"parent",
"!=",
"null",
")",
"{",
"int",
"index",
"=",
"getIndexOfChild",
"(",
"parent",
",",
"node",
")",
";",
"reversedIndexList",
".",
"add",
"(",
"index",
")",
";",
"node",
"=",
"parent",
";",
"parent",
"=",
"node",
".",
"getParent",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to determine component index relative to top.\"",
",",
"ex",
")",
";",
"}",
"final",
"int",
"depth",
"=",
"reversedIndexList",
".",
"size",
"(",
")",
";",
"int",
"[",
"]",
"nodeLocation",
"=",
"new",
"int",
"[",
"depth",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"depth",
";",
"i",
"++",
")",
"{",
"Integer",
"index",
"=",
"reversedIndexList",
".",
"get",
"(",
"depth",
"-",
"i",
"-",
"1",
")",
";",
"nodeLocation",
"[",
"i",
"]",
"=",
"index",
".",
"intValue",
"(",
")",
";",
"}",
"WComponentRef",
"ref",
"=",
"new",
"WComponentRef",
"(",
"repositoryKey",
",",
"nodeLocation",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"WComponent converted to reference. Ref = \"",
"+",
"ref",
"+",
"\". Component = \"",
"+",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"ref",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"WComponent not accessible via the repository, so it will be serialised. Component = \"",
"+",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"}"
] | Implement writeReplace so that on serialization, WComponents that are registered in the UIRegistry write a
reference to the registered component rather than the component itself. This ensures that, on deserialization,
only one copy of the registered component will be present in the VM.
@return the WComponent instance that is registered with the registry.
@throws ObjectStreamException never, but Serializable requires this method signature to declare it.
@see java.io.Serializable | [
"Implement",
"writeReplace",
"so",
"that",
"on",
"serialization",
"WComponents",
"that",
"are",
"registered",
"in",
"the",
"UIRegistry",
"write",
"a",
"reference",
"to",
"the",
"registered",
"component",
"rather",
"than",
"the",
"component",
"itself",
".",
"This",
"ensures",
"that",
"on",
"deserialization",
"only",
"one",
"copy",
"of",
"the",
"registered",
"component",
"will",
"be",
"present",
"in",
"the",
"VM",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractWComponent.java#L1956-L2009 |
139,670 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/othersys/LinkExamples.java | LinkExamples.addLink | private void addLink(final WSubMenu subMenu, final WLink link) {
subMenu.add(new WMenuItem(new WDecoratedLabel(link)));
} | java | private void addLink(final WSubMenu subMenu, final WLink link) {
subMenu.add(new WMenuItem(new WDecoratedLabel(link)));
} | [
"private",
"void",
"addLink",
"(",
"final",
"WSubMenu",
"subMenu",
",",
"final",
"WLink",
"link",
")",
"{",
"subMenu",
".",
"add",
"(",
"new",
"WMenuItem",
"(",
"new",
"WDecoratedLabel",
"(",
"link",
")",
")",
")",
";",
"}"
] | Adds a WLink to a sub-menu.
@param subMenu the sub-menu to add the link to
@param link the link to add. | [
"Adds",
"a",
"WLink",
"to",
"a",
"sub",
"-",
"menu",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/othersys/LinkExamples.java#L62-L64 |
139,671 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldLayout.java | WFieldLayout.setLabelWidth | public void setLabelWidth(final int labelWidth) {
if (labelWidth > 100) {
throw new IllegalArgumentException(
"labelWidth (" + labelWidth + ") cannot be greater than 100 percent.");
}
getOrCreateComponentModel().labelWidth = Math.max(0, labelWidth);
} | java | public void setLabelWidth(final int labelWidth) {
if (labelWidth > 100) {
throw new IllegalArgumentException(
"labelWidth (" + labelWidth + ") cannot be greater than 100 percent.");
}
getOrCreateComponentModel().labelWidth = Math.max(0, labelWidth);
} | [
"public",
"void",
"setLabelWidth",
"(",
"final",
"int",
"labelWidth",
")",
"{",
"if",
"(",
"labelWidth",
">",
"100",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"labelWidth (\"",
"+",
"labelWidth",
"+",
"\") cannot be greater than 100 percent.\"",
")",
";",
"}",
"getOrCreateComponentModel",
"(",
")",
".",
"labelWidth",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"labelWidth",
")",
";",
"}"
] | Sets the label width.
@param labelWidth the percentage width, or <= 0 to use the default field width. | [
"Sets",
"the",
"label",
"width",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldLayout.java#L113-L119 |
139,672 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldLayout.java | WFieldLayout.addField | public WField addField(final WButton button) {
WField field = new WField((WLabel) null, button);
add(field);
return field;
} | java | public WField addField(final WButton button) {
WField field = new WField((WLabel) null, button);
add(field);
return field;
} | [
"public",
"WField",
"addField",
"(",
"final",
"WButton",
"button",
")",
"{",
"WField",
"field",
"=",
"new",
"WField",
"(",
"(",
"WLabel",
")",
"null",
",",
"button",
")",
";",
"add",
"(",
"field",
")",
";",
"return",
"field",
";",
"}"
] | Add a field consisting of a WButton with a null label.
@param button the WButton to add to the layout.
@return the field added to the layout. | [
"Add",
"a",
"field",
"consisting",
"of",
"a",
"WButton",
"with",
"a",
"null",
"label",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WFieldLayout.java#L209-L213 |
139,673 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPartialDateFieldRenderer.java | WPartialDateFieldRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPartialDateField dateField = (WPartialDateField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = dateField.isReadOnly();
String date = formatDate(dateField);
xml.appendTagOpen("ui:datefield");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", dateField.isHidden(), "true");
xml.appendOptionalAttribute("date", date);
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendAttribute("allowPartial", "true");
xml.appendOptionalAttribute("disabled", dateField.isDisabled(), "true");
xml.appendOptionalAttribute("required", dateField.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", dateField.getToolTip());
xml.appendOptionalAttribute("accessibleText", dateField.getAccessibleText());
WComponent submitControl = dateField.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("buttonId", submitControlId);
}
xml.appendClose();
if (date == null) {
xml.appendEscaped(dateField.getText());
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(dateField, renderContext);
}
xml.appendEndTag("ui:datefield");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPartialDateField dateField = (WPartialDateField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = dateField.isReadOnly();
String date = formatDate(dateField);
xml.appendTagOpen("ui:datefield");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", dateField.isHidden(), "true");
xml.appendOptionalAttribute("date", date);
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendAttribute("allowPartial", "true");
xml.appendOptionalAttribute("disabled", dateField.isDisabled(), "true");
xml.appendOptionalAttribute("required", dateField.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", dateField.getToolTip());
xml.appendOptionalAttribute("accessibleText", dateField.getAccessibleText());
WComponent submitControl = dateField.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("buttonId", submitControlId);
}
xml.appendClose();
if (date == null) {
xml.appendEscaped(dateField.getText());
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(dateField, renderContext);
}
xml.appendEndTag("ui:datefield");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WPartialDateField",
"dateField",
"=",
"(",
"WPartialDateField",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"boolean",
"readOnly",
"=",
"dateField",
".",
"isReadOnly",
"(",
")",
";",
"String",
"date",
"=",
"formatDate",
"(",
"dateField",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:datefield\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"hidden\"",
",",
"dateField",
".",
"isHidden",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"date\"",
",",
"date",
")",
";",
"if",
"(",
"readOnly",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"readOnly\"",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"allowPartial\"",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"dateField",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"required\"",
",",
"dateField",
".",
"isMandatory",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"toolTip\"",
",",
"dateField",
".",
"getToolTip",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"accessibleText\"",
",",
"dateField",
".",
"getAccessibleText",
"(",
")",
")",
";",
"WComponent",
"submitControl",
"=",
"dateField",
".",
"getDefaultSubmitButton",
"(",
")",
";",
"String",
"submitControlId",
"=",
"submitControl",
"==",
"null",
"?",
"null",
":",
"submitControl",
".",
"getId",
"(",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"buttonId\"",
",",
"submitControlId",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"if",
"(",
"date",
"==",
"null",
")",
"{",
"xml",
".",
"appendEscaped",
"(",
"dateField",
".",
"getText",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"readOnly",
")",
"{",
"DiagnosticRenderUtil",
".",
"renderDiagnostics",
"(",
"dateField",
",",
"renderContext",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:datefield\"",
")",
";",
"}"
] | Paints the given WPartialDateField.
@param component the WPartialDateField to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WPartialDateField",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPartialDateFieldRenderer.java#L23-L60 |
139,674 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPartialDateFieldRenderer.java | WPartialDateFieldRenderer.formatDate | private String formatDate(final WPartialDateField dateField) {
Integer day = dateField.getDay();
Integer month = dateField.getMonth();
Integer year = dateField.getYear();
if (day != null || month != null || year != null) {
StringBuffer buf = new StringBuffer(10);
append(buf, year, 4);
buf.append('-');
append(buf, month, 2);
buf.append('-');
append(buf, day, 2);
return buf.toString();
}
return null;
} | java | private String formatDate(final WPartialDateField dateField) {
Integer day = dateField.getDay();
Integer month = dateField.getMonth();
Integer year = dateField.getYear();
if (day != null || month != null || year != null) {
StringBuffer buf = new StringBuffer(10);
append(buf, year, 4);
buf.append('-');
append(buf, month, 2);
buf.append('-');
append(buf, day, 2);
return buf.toString();
}
return null;
} | [
"private",
"String",
"formatDate",
"(",
"final",
"WPartialDateField",
"dateField",
")",
"{",
"Integer",
"day",
"=",
"dateField",
".",
"getDay",
"(",
")",
";",
"Integer",
"month",
"=",
"dateField",
".",
"getMonth",
"(",
")",
";",
"Integer",
"year",
"=",
"dateField",
".",
"getYear",
"(",
")",
";",
"if",
"(",
"day",
"!=",
"null",
"||",
"month",
"!=",
"null",
"||",
"year",
"!=",
"null",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"10",
")",
";",
"append",
"(",
"buf",
",",
"year",
",",
"4",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"append",
"(",
"buf",
",",
"month",
",",
"2",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"append",
"(",
"buf",
",",
"day",
",",
"2",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Formats a partial date to the format required by the schema.
@param dateField the date field containing the date to format.
@return the formatted date. | [
"Formats",
"a",
"partial",
"date",
"to",
"the",
"format",
"required",
"by",
"the",
"schema",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPartialDateFieldRenderer.java#L68-L86 |
139,675 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPartialDateFieldRenderer.java | WPartialDateFieldRenderer.append | private void append(final StringBuffer buf, final Integer num, final int digits) {
if (num == null) {
for (int i = 0; i < digits; i++) {
buf.append('?');
}
} else {
for (int digit = 1, test = 10; digit < digits; digit++, test *= 10) {
if (num < test) {
buf.append('0');
}
}
buf.append(num);
}
} | java | private void append(final StringBuffer buf, final Integer num, final int digits) {
if (num == null) {
for (int i = 0; i < digits; i++) {
buf.append('?');
}
} else {
for (int digit = 1, test = 10; digit < digits; digit++, test *= 10) {
if (num < test) {
buf.append('0');
}
}
buf.append(num);
}
} | [
"private",
"void",
"append",
"(",
"final",
"StringBuffer",
"buf",
",",
"final",
"Integer",
"num",
",",
"final",
"int",
"digits",
")",
"{",
"if",
"(",
"num",
"==",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"digits",
";",
"i",
"++",
")",
"{",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"digit",
"=",
"1",
",",
"test",
"=",
"10",
";",
"digit",
"<",
"digits",
";",
"digit",
"++",
",",
"test",
"*=",
"10",
")",
"{",
"if",
"(",
"num",
"<",
"test",
")",
"{",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"buf",
".",
"append",
"(",
"num",
")",
";",
"}",
"}"
] | Appends a single date component to the given StringBuffer. Nulls are replaced with question marks, and numbers
are padded with zeros.
@param buf the buffer to append to.
@param num the number to append, may be null.
@param digits the minimum number of digits to append. | [
"Appends",
"a",
"single",
"date",
"component",
"to",
"the",
"given",
"StringBuffer",
".",
"Nulls",
"are",
"replaced",
"with",
"question",
"marks",
"and",
"numbers",
"are",
"padded",
"with",
"zeros",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPartialDateFieldRenderer.java#L96-L110 |
139,676 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/validation/basic/BasicFields.java | BasicFields.validateComponent | @Override
protected void validateComponent(final List<Diagnostic> diags) {
String text1 = field1.getText();
String text2 = field2.getText();
String text3 = field3.getText();
if (text1 != null && text1.length() > 0 && text1.equals(text2)) {
// Note that this error will hyperlink to Field 2.
diags.add(createErrorDiagnostic(field2, "Fields 1 and 2 cannot be the same."));
}
int len = 0;
if (text1 != null) {
len += text1.length();
}
if (text2 != null) {
len += text2.length();
}
if (len > 20) {
// Note that this error does not link to a specific field.
diags.add(createErrorDiagnostic(
"The total length of Field 1 plus Field 2 can exceed 20 characters."));
}
// Sample Warning Message
if (Util.empty(text3)) {
diags.add(new DiagnosticImpl(Diagnostic.WARNING, UIContextHolder.getCurrent(), field3,
"Warning that this should not be blank"));
}
} | java | @Override
protected void validateComponent(final List<Diagnostic> diags) {
String text1 = field1.getText();
String text2 = field2.getText();
String text3 = field3.getText();
if (text1 != null && text1.length() > 0 && text1.equals(text2)) {
// Note that this error will hyperlink to Field 2.
diags.add(createErrorDiagnostic(field2, "Fields 1 and 2 cannot be the same."));
}
int len = 0;
if (text1 != null) {
len += text1.length();
}
if (text2 != null) {
len += text2.length();
}
if (len > 20) {
// Note that this error does not link to a specific field.
diags.add(createErrorDiagnostic(
"The total length of Field 1 plus Field 2 can exceed 20 characters."));
}
// Sample Warning Message
if (Util.empty(text3)) {
diags.add(new DiagnosticImpl(Diagnostic.WARNING, UIContextHolder.getCurrent(), field3,
"Warning that this should not be blank"));
}
} | [
"@",
"Override",
"protected",
"void",
"validateComponent",
"(",
"final",
"List",
"<",
"Diagnostic",
">",
"diags",
")",
"{",
"String",
"text1",
"=",
"field1",
".",
"getText",
"(",
")",
";",
"String",
"text2",
"=",
"field2",
".",
"getText",
"(",
")",
";",
"String",
"text3",
"=",
"field3",
".",
"getText",
"(",
")",
";",
"if",
"(",
"text1",
"!=",
"null",
"&&",
"text1",
".",
"length",
"(",
")",
">",
"0",
"&&",
"text1",
".",
"equals",
"(",
"text2",
")",
")",
"{",
"// Note that this error will hyperlink to Field 2.",
"diags",
".",
"add",
"(",
"createErrorDiagnostic",
"(",
"field2",
",",
"\"Fields 1 and 2 cannot be the same.\"",
")",
")",
";",
"}",
"int",
"len",
"=",
"0",
";",
"if",
"(",
"text1",
"!=",
"null",
")",
"{",
"len",
"+=",
"text1",
".",
"length",
"(",
")",
";",
"}",
"if",
"(",
"text2",
"!=",
"null",
")",
"{",
"len",
"+=",
"text2",
".",
"length",
"(",
")",
";",
"}",
"if",
"(",
"len",
">",
"20",
")",
"{",
"// Note that this error does not link to a specific field.",
"diags",
".",
"add",
"(",
"createErrorDiagnostic",
"(",
"\"The total length of Field 1 plus Field 2 can exceed 20 characters.\"",
")",
")",
";",
"}",
"// Sample Warning Message",
"if",
"(",
"Util",
".",
"empty",
"(",
"text3",
")",
")",
"{",
"diags",
".",
"add",
"(",
"new",
"DiagnosticImpl",
"(",
"Diagnostic",
".",
"WARNING",
",",
"UIContextHolder",
".",
"getCurrent",
"(",
")",
",",
"field3",
",",
"\"Warning that this should not be blank\"",
")",
")",
";",
"}",
"}"
] | An example of cross field validation. | [
"An",
"example",
"of",
"cross",
"field",
"validation",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/validation/basic/BasicFields.java#L103-L132 |
139,677 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/WhiteSpaceFilterStateMachine.java | WhiteSpaceFilterStateMachine.nextState | public StateChange nextState(final char c) {
StateChange change = currentState.getChange(c);
currentState = change.getNewState();
return change;
} | java | public StateChange nextState(final char c) {
StateChange change = currentState.getChange(c);
currentState = change.getNewState();
return change;
} | [
"public",
"StateChange",
"nextState",
"(",
"final",
"char",
"c",
")",
"{",
"StateChange",
"change",
"=",
"currentState",
".",
"getChange",
"(",
"c",
")",
";",
"currentState",
"=",
"change",
".",
"getNewState",
"(",
")",
";",
"return",
"change",
";",
"}"
] | Moves the machine to the next state, based on the input character.
@param c the input character.
@return the state change. | [
"Moves",
"the",
"machine",
"to",
"the",
"next",
"state",
"based",
"on",
"the",
"input",
"character",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/WhiteSpaceFilterStateMachine.java#L647-L652 |
139,678 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/RadioButtonGroup.java | RadioButtonGroup.doHandleRequest | @Override
protected boolean doHandleRequest(final Request request) {
// Check if the group has a value on the Request
if (request.getParameter(getId()) != null) {
// Allow the handle request to be processed by the radio buttons
return false;
}
// If no value, then clear the current value (if required)
if (getValue() != null) {
setData(null);
return true;
}
return false;
} | java | @Override
protected boolean doHandleRequest(final Request request) {
// Check if the group has a value on the Request
if (request.getParameter(getId()) != null) {
// Allow the handle request to be processed by the radio buttons
return false;
}
// If no value, then clear the current value (if required)
if (getValue() != null) {
setData(null);
return true;
}
return false;
} | [
"@",
"Override",
"protected",
"boolean",
"doHandleRequest",
"(",
"final",
"Request",
"request",
")",
"{",
"// Check if the group has a value on the Request",
"if",
"(",
"request",
".",
"getParameter",
"(",
"getId",
"(",
")",
")",
"!=",
"null",
")",
"{",
"// Allow the handle request to be processed by the radio buttons",
"return",
"false",
";",
"}",
"// If no value, then clear the current value (if required)",
"if",
"(",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"setData",
"(",
"null",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | This method will only processes a request where the group is on the request and has no value. If the group has no
value, then none of the group's radio buttons will be triggered to process the request.
@param request the request being responded to.
@return true if the group has changed, otherwise false | [
"This",
"method",
"will",
"only",
"processes",
"a",
"request",
"where",
"the",
"group",
"is",
"on",
"the",
"request",
"and",
"has",
"no",
"value",
".",
"If",
"the",
"group",
"has",
"no",
"value",
"then",
"none",
"of",
"the",
"group",
"s",
"radio",
"buttons",
"will",
"be",
"triggered",
"to",
"process",
"the",
"request",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/RadioButtonGroup.java#L62-L77 |
139,679 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WDateFieldExample.java | WDateFieldExample.addDateRangeExample | private void addDateRangeExample() {
add(new WHeading(HeadingLevel.H2, "Example of a date range component"));
WFieldSet dateRange = new WFieldSet("Enter the expected arrival and departure dates.");
add(dateRange);
WPanel dateRangePanel = new WPanel();
dateRangePanel.setLayout(new FlowLayout(FlowLayout.LEFT, Size.MEDIUM));
dateRange.add(dateRangePanel);
final WDateField arrivalDate = new WDateField();
final WDateField departureDate = new WDateField();
//One could add some validation rules around this so that "arrival" was always earlier than or equal to "departure"
WLabel arrivalLabel = new WLabel("Arrival", arrivalDate);
arrivalLabel.setHint("dd MMM yyyy");
WLabel departureLabel = new WLabel("Departure", departureDate);
departureLabel.setHint("dd MMM yyyy");
dateRangePanel.add(arrivalLabel);
dateRangePanel.add(arrivalDate);
dateRangePanel.add(departureLabel);
dateRangePanel.add(departureDate);
//subordinate control to ensure that the departure date is only enabled if the arrival date is populated
WSubordinateControl control = new WSubordinateControl();
add(control);
Rule rule = new Rule(new Equal(arrivalDate, null));
control.addRule(rule);
rule.addActionOnTrue(new Disable(departureDate));
rule.addActionOnFalse(new Enable(departureDate));
control.addRule(rule);
} | java | private void addDateRangeExample() {
add(new WHeading(HeadingLevel.H2, "Example of a date range component"));
WFieldSet dateRange = new WFieldSet("Enter the expected arrival and departure dates.");
add(dateRange);
WPanel dateRangePanel = new WPanel();
dateRangePanel.setLayout(new FlowLayout(FlowLayout.LEFT, Size.MEDIUM));
dateRange.add(dateRangePanel);
final WDateField arrivalDate = new WDateField();
final WDateField departureDate = new WDateField();
//One could add some validation rules around this so that "arrival" was always earlier than or equal to "departure"
WLabel arrivalLabel = new WLabel("Arrival", arrivalDate);
arrivalLabel.setHint("dd MMM yyyy");
WLabel departureLabel = new WLabel("Departure", departureDate);
departureLabel.setHint("dd MMM yyyy");
dateRangePanel.add(arrivalLabel);
dateRangePanel.add(arrivalDate);
dateRangePanel.add(departureLabel);
dateRangePanel.add(departureDate);
//subordinate control to ensure that the departure date is only enabled if the arrival date is populated
WSubordinateControl control = new WSubordinateControl();
add(control);
Rule rule = new Rule(new Equal(arrivalDate, null));
control.addRule(rule);
rule.addActionOnTrue(new Disable(departureDate));
rule.addActionOnFalse(new Enable(departureDate));
control.addRule(rule);
} | [
"private",
"void",
"addDateRangeExample",
"(",
")",
"{",
"add",
"(",
"new",
"WHeading",
"(",
"HeadingLevel",
".",
"H2",
",",
"\"Example of a date range component\"",
")",
")",
";",
"WFieldSet",
"dateRange",
"=",
"new",
"WFieldSet",
"(",
"\"Enter the expected arrival and departure dates.\"",
")",
";",
"add",
"(",
"dateRange",
")",
";",
"WPanel",
"dateRangePanel",
"=",
"new",
"WPanel",
"(",
")",
";",
"dateRangePanel",
".",
"setLayout",
"(",
"new",
"FlowLayout",
"(",
"FlowLayout",
".",
"LEFT",
",",
"Size",
".",
"MEDIUM",
")",
")",
";",
"dateRange",
".",
"add",
"(",
"dateRangePanel",
")",
";",
"final",
"WDateField",
"arrivalDate",
"=",
"new",
"WDateField",
"(",
")",
";",
"final",
"WDateField",
"departureDate",
"=",
"new",
"WDateField",
"(",
")",
";",
"//One could add some validation rules around this so that \"arrival\" was always earlier than or equal to \"departure\"",
"WLabel",
"arrivalLabel",
"=",
"new",
"WLabel",
"(",
"\"Arrival\"",
",",
"arrivalDate",
")",
";",
"arrivalLabel",
".",
"setHint",
"(",
"\"dd MMM yyyy\"",
")",
";",
"WLabel",
"departureLabel",
"=",
"new",
"WLabel",
"(",
"\"Departure\"",
",",
"departureDate",
")",
";",
"departureLabel",
".",
"setHint",
"(",
"\"dd MMM yyyy\"",
")",
";",
"dateRangePanel",
".",
"add",
"(",
"arrivalLabel",
")",
";",
"dateRangePanel",
".",
"add",
"(",
"arrivalDate",
")",
";",
"dateRangePanel",
".",
"add",
"(",
"departureLabel",
")",
";",
"dateRangePanel",
".",
"add",
"(",
"departureDate",
")",
";",
"//subordinate control to ensure that the departure date is only enabled if the arrival date is populated",
"WSubordinateControl",
"control",
"=",
"new",
"WSubordinateControl",
"(",
")",
";",
"add",
"(",
"control",
")",
";",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
"new",
"Equal",
"(",
"arrivalDate",
",",
"null",
")",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Disable",
"(",
"departureDate",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Enable",
"(",
"departureDate",
")",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"}"
] | Add date range example. | [
"Add",
"date",
"range",
"example",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WDateFieldExample.java#L164-L193 |
139,680 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WDateFieldExample.java | WDateFieldExample.addContraintExamples | private void addContraintExamples() {
add(new WHeading(HeadingLevel.H2, "Date fields with input constraints"));
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(33);
add(layout);
/* mandatory */
WDateField constrainedDateField = new WDateField();
constrainedDateField.setMandatory(true);
layout.addField("Mandatory date field", constrainedDateField);
/* min date */
constrainedDateField = new WDateField();
constrainedDateField.setMinDate(new Date());
layout.addField("Minimum date today", constrainedDateField);
/* max date */
constrainedDateField = new WDateField();
constrainedDateField.setMaxDate(new Date());
layout.addField("Maximum date today", constrainedDateField);
/* auto complete */
constrainedDateField = new WDateField();
constrainedDateField.setBirthdayAutocomplete();
layout.addField("With autocomplete hint", constrainedDateField);
constrainedDateField = new WDateField();
constrainedDateField.setAutocompleteOff();
layout.addField("With autocomplete off", constrainedDateField);
} | java | private void addContraintExamples() {
add(new WHeading(HeadingLevel.H2, "Date fields with input constraints"));
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(33);
add(layout);
/* mandatory */
WDateField constrainedDateField = new WDateField();
constrainedDateField.setMandatory(true);
layout.addField("Mandatory date field", constrainedDateField);
/* min date */
constrainedDateField = new WDateField();
constrainedDateField.setMinDate(new Date());
layout.addField("Minimum date today", constrainedDateField);
/* max date */
constrainedDateField = new WDateField();
constrainedDateField.setMaxDate(new Date());
layout.addField("Maximum date today", constrainedDateField);
/* auto complete */
constrainedDateField = new WDateField();
constrainedDateField.setBirthdayAutocomplete();
layout.addField("With autocomplete hint", constrainedDateField);
constrainedDateField = new WDateField();
constrainedDateField.setAutocompleteOff();
layout.addField("With autocomplete off", constrainedDateField);
} | [
"private",
"void",
"addContraintExamples",
"(",
")",
"{",
"add",
"(",
"new",
"WHeading",
"(",
"HeadingLevel",
".",
"H2",
",",
"\"Date fields with input constraints\"",
")",
")",
";",
"WFieldLayout",
"layout",
"=",
"new",
"WFieldLayout",
"(",
")",
";",
"layout",
".",
"setLabelWidth",
"(",
"33",
")",
";",
"add",
"(",
"layout",
")",
";",
"/* mandatory */",
"WDateField",
"constrainedDateField",
"=",
"new",
"WDateField",
"(",
")",
";",
"constrainedDateField",
".",
"setMandatory",
"(",
"true",
")",
";",
"layout",
".",
"addField",
"(",
"\"Mandatory date field\"",
",",
"constrainedDateField",
")",
";",
"/* min date */",
"constrainedDateField",
"=",
"new",
"WDateField",
"(",
")",
";",
"constrainedDateField",
".",
"setMinDate",
"(",
"new",
"Date",
"(",
")",
")",
";",
"layout",
".",
"addField",
"(",
"\"Minimum date today\"",
",",
"constrainedDateField",
")",
";",
"/* max date */",
"constrainedDateField",
"=",
"new",
"WDateField",
"(",
")",
";",
"constrainedDateField",
".",
"setMaxDate",
"(",
"new",
"Date",
"(",
")",
")",
";",
"layout",
".",
"addField",
"(",
"\"Maximum date today\"",
",",
"constrainedDateField",
")",
";",
"/* auto complete */",
"constrainedDateField",
"=",
"new",
"WDateField",
"(",
")",
";",
"constrainedDateField",
".",
"setBirthdayAutocomplete",
"(",
")",
";",
"layout",
".",
"addField",
"(",
"\"With autocomplete hint\"",
",",
"constrainedDateField",
")",
";",
"constrainedDateField",
"=",
"new",
"WDateField",
"(",
")",
";",
"constrainedDateField",
".",
"setAutocompleteOff",
"(",
")",
";",
"layout",
".",
"addField",
"(",
"\"With autocomplete off\"",
",",
"constrainedDateField",
")",
";",
"}"
] | Add constraint example. | [
"Add",
"constraint",
"example",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WDateFieldExample.java#L198-L226 |
139,681 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSelectToggleRenderer.java | WSelectToggleRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSelectToggle toggle = (WSelectToggle) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:selecttoggle");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
State state = toggle.getState();
if (State.ALL.equals(state)) {
xml.appendAttribute("selected", "all");
} else if (State.NONE.equals(state)) {
xml.appendAttribute("selected", "none");
} else {
xml.appendAttribute("selected", "some");
}
xml.appendOptionalAttribute("disabled", toggle.isDisabled(), "true");
xml.appendAttribute("target", toggle.getTarget().getId());
xml.appendAttribute("renderAs", toggle.isRenderAsText() ? "text" : "control");
xml.appendOptionalAttribute("roundTrip", !toggle.isClientSide(), "true");
xml.appendEnd();
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSelectToggle toggle = (WSelectToggle) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:selecttoggle");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
State state = toggle.getState();
if (State.ALL.equals(state)) {
xml.appendAttribute("selected", "all");
} else if (State.NONE.equals(state)) {
xml.appendAttribute("selected", "none");
} else {
xml.appendAttribute("selected", "some");
}
xml.appendOptionalAttribute("disabled", toggle.isDisabled(), "true");
xml.appendAttribute("target", toggle.getTarget().getId());
xml.appendAttribute("renderAs", toggle.isRenderAsText() ? "text" : "control");
xml.appendOptionalAttribute("roundTrip", !toggle.isClientSide(), "true");
xml.appendEnd();
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WSelectToggle",
"toggle",
"=",
"(",
"WSelectToggle",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:selecttoggle\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"State",
"state",
"=",
"toggle",
".",
"getState",
"(",
")",
";",
"if",
"(",
"State",
".",
"ALL",
".",
"equals",
"(",
"state",
")",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"selected\"",
",",
"\"all\"",
")",
";",
"}",
"else",
"if",
"(",
"State",
".",
"NONE",
".",
"equals",
"(",
"state",
")",
")",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"selected\"",
",",
"\"none\"",
")",
";",
"}",
"else",
"{",
"xml",
".",
"appendAttribute",
"(",
"\"selected\"",
",",
"\"some\"",
")",
";",
"}",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"disabled\"",
",",
"toggle",
".",
"isDisabled",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"target\"",
",",
"toggle",
".",
"getTarget",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"renderAs\"",
",",
"toggle",
".",
"isRenderAsText",
"(",
")",
"?",
"\"text\"",
":",
"\"control\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"roundTrip\"",
",",
"!",
"toggle",
".",
"isClientSide",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}"
] | Paints the given WSelectToggle.
@param component the WSelectToggle to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WSelectToggle",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSelectToggleRenderer.java#L23-L48 |
139,682 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WAudioExample.java | WAudioExample.buildUI | private void buildUI() {
// build the configuration options UI.
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
layout.setMargin(new Margin(null, null, Size.LARGE, null));
add(layout);
layout.addField("Autoplay", cbAutoPlay);
layout.addField("Loop", cbLoop);
layout.addField("Disable", cbDisable);
layout.addField("Show only play/pause", cbControls);
layout.addField((WLabel) null, btnApply);
// enable disable option only when control PLAY_PAUSE is used.
WSubordinateControl control = new WSubordinateControl();
add(control);
Rule rule = new Rule();
rule.setCondition(new Equal(cbControls, Boolean.TRUE.toString()));
rule.addActionOnTrue(new Enable(cbDisable));
rule.addActionOnFalse(new Disable(cbDisable));
control.addRule(rule);
// allow config to change without reloading the whole page.
add(new WAjaxControl(btnApply, audio));
// add the audio to the UI
add(audio);
} | java | private void buildUI() {
// build the configuration options UI.
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
layout.setMargin(new Margin(null, null, Size.LARGE, null));
add(layout);
layout.addField("Autoplay", cbAutoPlay);
layout.addField("Loop", cbLoop);
layout.addField("Disable", cbDisable);
layout.addField("Show only play/pause", cbControls);
layout.addField((WLabel) null, btnApply);
// enable disable option only when control PLAY_PAUSE is used.
WSubordinateControl control = new WSubordinateControl();
add(control);
Rule rule = new Rule();
rule.setCondition(new Equal(cbControls, Boolean.TRUE.toString()));
rule.addActionOnTrue(new Enable(cbDisable));
rule.addActionOnFalse(new Disable(cbDisable));
control.addRule(rule);
// allow config to change without reloading the whole page.
add(new WAjaxControl(btnApply, audio));
// add the audio to the UI
add(audio);
} | [
"private",
"void",
"buildUI",
"(",
")",
"{",
"// build the configuration options UI.",
"WFieldLayout",
"layout",
"=",
"new",
"WFieldLayout",
"(",
"WFieldLayout",
".",
"LAYOUT_STACKED",
")",
";",
"layout",
".",
"setMargin",
"(",
"new",
"Margin",
"(",
"null",
",",
"null",
",",
"Size",
".",
"LARGE",
",",
"null",
")",
")",
";",
"add",
"(",
"layout",
")",
";",
"layout",
".",
"addField",
"(",
"\"Autoplay\"",
",",
"cbAutoPlay",
")",
";",
"layout",
".",
"addField",
"(",
"\"Loop\"",
",",
"cbLoop",
")",
";",
"layout",
".",
"addField",
"(",
"\"Disable\"",
",",
"cbDisable",
")",
";",
"layout",
".",
"addField",
"(",
"\"Show only play/pause\"",
",",
"cbControls",
")",
";",
"layout",
".",
"addField",
"(",
"(",
"WLabel",
")",
"null",
",",
"btnApply",
")",
";",
"// enable disable option only when control PLAY_PAUSE is used.",
"WSubordinateControl",
"control",
"=",
"new",
"WSubordinateControl",
"(",
")",
";",
"add",
"(",
"control",
")",
";",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"rule",
".",
"setCondition",
"(",
"new",
"Equal",
"(",
"cbControls",
",",
"Boolean",
".",
"TRUE",
".",
"toString",
"(",
")",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Enable",
"(",
"cbDisable",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Disable",
"(",
"cbDisable",
")",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"// allow config to change without reloading the whole page.",
"add",
"(",
"new",
"WAjaxControl",
"(",
"btnApply",
",",
"audio",
")",
")",
";",
"// add the audio to the UI",
"add",
"(",
"audio",
")",
";",
"}"
] | Build the UI for this example. | [
"Build",
"the",
"UI",
"for",
"this",
"example",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WAudioExample.java#L90-L115 |
139,683 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WAudioExample.java | WAudioExample.preparePaintComponent | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request); //To change body of generated methods, choose Tools | Templates.
if (!isInitialised()) {
setInitialised(true);
setupAudio();
}
} | java | @Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request); //To change body of generated methods, choose Tools | Templates.
if (!isInitialised()) {
setInitialised(true);
setupAudio();
}
} | [
"@",
"Override",
"protected",
"void",
"preparePaintComponent",
"(",
"final",
"Request",
"request",
")",
"{",
"super",
".",
"preparePaintComponent",
"(",
"request",
")",
";",
"//To change body of generated methods, choose Tools | Templates.",
"if",
"(",
"!",
"isInitialised",
"(",
")",
")",
"{",
"setInitialised",
"(",
"true",
")",
";",
"setupAudio",
"(",
")",
";",
"}",
"}"
] | Set up the initial state of the audio component.
@param request The http request being processed. | [
"Set",
"up",
"the",
"initial",
"state",
"of",
"the",
"audio",
"component",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WAudioExample.java#L121-L128 |
139,684 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WAudioExample.java | WAudioExample.setupAudio | private void setupAudio() {
audio.setAutoplay(cbAutoPlay.isSelected());
audio.setLoop(!cbLoop.isDisabled() && cbLoop.isSelected());
audio.setControls(cbControls.isSelected() ? WAudio.Controls.PLAY_PAUSE : WAudio.Controls.NATIVE);
audio.setDisabled(cbControls.isSelected() && cbDisable.isSelected());
} | java | private void setupAudio() {
audio.setAutoplay(cbAutoPlay.isSelected());
audio.setLoop(!cbLoop.isDisabled() && cbLoop.isSelected());
audio.setControls(cbControls.isSelected() ? WAudio.Controls.PLAY_PAUSE : WAudio.Controls.NATIVE);
audio.setDisabled(cbControls.isSelected() && cbDisable.isSelected());
} | [
"private",
"void",
"setupAudio",
"(",
")",
"{",
"audio",
".",
"setAutoplay",
"(",
"cbAutoPlay",
".",
"isSelected",
"(",
")",
")",
";",
"audio",
".",
"setLoop",
"(",
"!",
"cbLoop",
".",
"isDisabled",
"(",
")",
"&&",
"cbLoop",
".",
"isSelected",
"(",
")",
")",
";",
"audio",
".",
"setControls",
"(",
"cbControls",
".",
"isSelected",
"(",
")",
"?",
"WAudio",
".",
"Controls",
".",
"PLAY_PAUSE",
":",
"WAudio",
".",
"Controls",
".",
"NATIVE",
")",
";",
"audio",
".",
"setDisabled",
"(",
"cbControls",
".",
"isSelected",
"(",
")",
"&&",
"cbDisable",
".",
"isSelected",
"(",
")",
")",
";",
"}"
] | Set the audio configuration options. | [
"Set",
"the",
"audio",
"configuration",
"options",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WAudioExample.java#L133-L138 |
139,685 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractTransientDataContainer.java | AbstractTransientDataContainer.afterPaint | @Override
protected void afterPaint(final RenderContext renderContext) {
super.afterPaint(renderContext);
final int size = getChildCount();
for (int i = 0; i < size; i++) {
WComponent child = getChildAt(i);
child.reset();
}
} | java | @Override
protected void afterPaint(final RenderContext renderContext) {
super.afterPaint(renderContext);
final int size = getChildCount();
for (int i = 0; i < size; i++) {
WComponent child = getChildAt(i);
child.reset();
}
} | [
"@",
"Override",
"protected",
"void",
"afterPaint",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"super",
".",
"afterPaint",
"(",
"renderContext",
")",
";",
"final",
"int",
"size",
"=",
"getChildCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"WComponent",
"child",
"=",
"getChildAt",
"(",
"i",
")",
";",
"child",
".",
"reset",
"(",
")",
";",
"}",
"}"
] | After the component has been painted, the UIContexts for this component and all its children are cleared.
@param renderContext the renderContext to send output to. | [
"After",
"the",
"component",
"has",
"been",
"painted",
"the",
"UIContexts",
"for",
"this",
"component",
"and",
"all",
"its",
"children",
"are",
"cleared",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractTransientDataContainer.java#L21-L31 |
139,686 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/CollapsibleGroup.java | CollapsibleGroup.getGroupName | public String getGroupName() {
if (collapsibleToggle != null) {
return collapsibleToggle.getId();
} else if (!collapsibleList.isEmpty()) {
// This is only to retain compatibility with the
// previous implementation, and should be removed post-Sfp11,
// as it doesn't make much sense to create a group without
// something to toggle it.
return collapsibleList.get(0).getId();
}
return "";
} | java | public String getGroupName() {
if (collapsibleToggle != null) {
return collapsibleToggle.getId();
} else if (!collapsibleList.isEmpty()) {
// This is only to retain compatibility with the
// previous implementation, and should be removed post-Sfp11,
// as it doesn't make much sense to create a group without
// something to toggle it.
return collapsibleList.get(0).getId();
}
return "";
} | [
"public",
"String",
"getGroupName",
"(",
")",
"{",
"if",
"(",
"collapsibleToggle",
"!=",
"null",
")",
"{",
"return",
"collapsibleToggle",
".",
"getId",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"collapsibleList",
".",
"isEmpty",
"(",
")",
")",
"{",
"// This is only to retain compatibility with the",
"// previous implementation, and should be removed post-Sfp11,",
"// as it doesn't make much sense to create a group without",
"// something to toggle it.",
"return",
"collapsibleList",
".",
"get",
"(",
"0",
")",
".",
"getId",
"(",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] | Retrieves the common name used by all collapsible components in the group.
@return the common name to use. | [
"Retrieves",
"the",
"common",
"name",
"used",
"by",
"all",
"collapsible",
"components",
"in",
"the",
"group",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/CollapsibleGroup.java#L45-L57 |
139,687 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/CollapsibleGroup.java | CollapsibleGroup.addComponent | private void addComponent(final WComponent component) {
collapsibleList.add(component);
MemoryUtil.checkSize(collapsibleList.size(), this.getClass().getSimpleName());
} | java | private void addComponent(final WComponent component) {
collapsibleList.add(component);
MemoryUtil.checkSize(collapsibleList.size(), this.getClass().getSimpleName());
} | [
"private",
"void",
"addComponent",
"(",
"final",
"WComponent",
"component",
")",
"{",
"collapsibleList",
".",
"add",
"(",
"component",
")",
";",
"MemoryUtil",
".",
"checkSize",
"(",
"collapsibleList",
".",
"size",
"(",
")",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}"
] | Responsible for updating the underlying group store.
@param component The component to add to the group. | [
"Responsible",
"for",
"updating",
"the",
"underlying",
"group",
"store",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/CollapsibleGroup.java#L80-L83 |
139,688 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WShuffler.java | WShuffler.getNewOptions | private List<?> getNewOptions(final String[] paramValues) {
// Take a copy of the old options
List<?> copyOldOptions = new ArrayList(getOptions());
// Create a new list to hold the shuffled options
List<Object> newOptions = new ArrayList<>(paramValues.length);
// Process the option parameters
for (String param : paramValues) {
for (Object oldOption : copyOldOptions) {
// Match the string value of the option
String stringOldOption = String.valueOf(oldOption);
if (Util.equals(stringOldOption, param)) {
newOptions.add(oldOption);
copyOldOptions.remove(oldOption);
break;
}
}
}
return newOptions;
} | java | private List<?> getNewOptions(final String[] paramValues) {
// Take a copy of the old options
List<?> copyOldOptions = new ArrayList(getOptions());
// Create a new list to hold the shuffled options
List<Object> newOptions = new ArrayList<>(paramValues.length);
// Process the option parameters
for (String param : paramValues) {
for (Object oldOption : copyOldOptions) {
// Match the string value of the option
String stringOldOption = String.valueOf(oldOption);
if (Util.equals(stringOldOption, param)) {
newOptions.add(oldOption);
copyOldOptions.remove(oldOption);
break;
}
}
}
return newOptions;
} | [
"private",
"List",
"<",
"?",
">",
"getNewOptions",
"(",
"final",
"String",
"[",
"]",
"paramValues",
")",
"{",
"// Take a copy of the old options",
"List",
"<",
"?",
">",
"copyOldOptions",
"=",
"new",
"ArrayList",
"(",
"getOptions",
"(",
")",
")",
";",
"// Create a new list to hold the shuffled options",
"List",
"<",
"Object",
">",
"newOptions",
"=",
"new",
"ArrayList",
"<>",
"(",
"paramValues",
".",
"length",
")",
";",
"// Process the option parameters",
"for",
"(",
"String",
"param",
":",
"paramValues",
")",
"{",
"for",
"(",
"Object",
"oldOption",
":",
"copyOldOptions",
")",
"{",
"// Match the string value of the option",
"String",
"stringOldOption",
"=",
"String",
".",
"valueOf",
"(",
"oldOption",
")",
";",
"if",
"(",
"Util",
".",
"equals",
"(",
"stringOldOption",
",",
"param",
")",
")",
"{",
"newOptions",
".",
"add",
"(",
"oldOption",
")",
";",
"copyOldOptions",
".",
"remove",
"(",
"oldOption",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"newOptions",
";",
"}"
] | Shuffle the options.
@param paramValues the array of option indexes as shuffled by the user
@return the shuffled options | [
"Shuffle",
"the",
"options",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WShuffler.java#L131-L152 |
139,689 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDefinitionListExample.java | WDefinitionListExample.addListItems | private void addListItems(final WDefinitionList list) {
// Example of adding multiple data items at once.
list.addTerm("Colours", new WText("Red"), new WText("Green"), new WText("Blue"));
// Example of adding multiple data items using multiple calls.
list.addTerm("Shapes", new WText("Circle"));
list.addTerm("Shapes", new WText("Square"), new WText("Triangle"));
} | java | private void addListItems(final WDefinitionList list) {
// Example of adding multiple data items at once.
list.addTerm("Colours", new WText("Red"), new WText("Green"), new WText("Blue"));
// Example of adding multiple data items using multiple calls.
list.addTerm("Shapes", new WText("Circle"));
list.addTerm("Shapes", new WText("Square"), new WText("Triangle"));
} | [
"private",
"void",
"addListItems",
"(",
"final",
"WDefinitionList",
"list",
")",
"{",
"// Example of adding multiple data items at once.",
"list",
".",
"addTerm",
"(",
"\"Colours\"",
",",
"new",
"WText",
"(",
"\"Red\"",
")",
",",
"new",
"WText",
"(",
"\"Green\"",
")",
",",
"new",
"WText",
"(",
"\"Blue\"",
")",
")",
";",
"// Example of adding multiple data items using multiple calls.",
"list",
".",
"addTerm",
"(",
"\"Shapes\"",
",",
"new",
"WText",
"(",
"\"Circle\"",
")",
")",
";",
"list",
".",
"addTerm",
"(",
"\"Shapes\"",
",",
"new",
"WText",
"(",
"\"Square\"",
")",
",",
"new",
"WText",
"(",
"\"Triangle\"",
")",
")",
";",
"}"
] | Adds some items to a definition list.
@param list the list to add the items to. | [
"Adds",
"some",
"items",
"to",
"a",
"definition",
"list",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDefinitionListExample.java#L46-L53 |
139,690 | BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/GridLayoutOptionsExample.java | GridLayoutOptionsExample.applySettings | private void applySettings() {
container.reset();
// Now show an example of the number of different columns
WPanel gridLayoutPanel = new WPanel();
if (cbResponsive.isSelected()) {
gridLayoutPanel.setHtmlClass(HtmlClassProperties.RESPOND);
}
GridLayout layout = new GridLayout(rowCount.getValue().intValue(), columnCount.getValue()
.intValue(),
hGap.getValue().intValue(),
vGap.getValue().intValue()
);
gridLayoutPanel.setLayout(layout);
addBoxes(gridLayoutPanel, boxCount.getValue().intValue()); // give approx 3 rows, with a different number
// of boxes on the final row
container.add(gridLayoutPanel);
gridLayoutPanel.setVisible(cbVisible.isSelected());
} | java | private void applySettings() {
container.reset();
// Now show an example of the number of different columns
WPanel gridLayoutPanel = new WPanel();
if (cbResponsive.isSelected()) {
gridLayoutPanel.setHtmlClass(HtmlClassProperties.RESPOND);
}
GridLayout layout = new GridLayout(rowCount.getValue().intValue(), columnCount.getValue()
.intValue(),
hGap.getValue().intValue(),
vGap.getValue().intValue()
);
gridLayoutPanel.setLayout(layout);
addBoxes(gridLayoutPanel, boxCount.getValue().intValue()); // give approx 3 rows, with a different number
// of boxes on the final row
container.add(gridLayoutPanel);
gridLayoutPanel.setVisible(cbVisible.isSelected());
} | [
"private",
"void",
"applySettings",
"(",
")",
"{",
"container",
".",
"reset",
"(",
")",
";",
"// Now show an example of the number of different columns",
"WPanel",
"gridLayoutPanel",
"=",
"new",
"WPanel",
"(",
")",
";",
"if",
"(",
"cbResponsive",
".",
"isSelected",
"(",
")",
")",
"{",
"gridLayoutPanel",
".",
"setHtmlClass",
"(",
"HtmlClassProperties",
".",
"RESPOND",
")",
";",
"}",
"GridLayout",
"layout",
"=",
"new",
"GridLayout",
"(",
"rowCount",
".",
"getValue",
"(",
")",
".",
"intValue",
"(",
")",
",",
"columnCount",
".",
"getValue",
"(",
")",
".",
"intValue",
"(",
")",
",",
"hGap",
".",
"getValue",
"(",
")",
".",
"intValue",
"(",
")",
",",
"vGap",
".",
"getValue",
"(",
")",
".",
"intValue",
"(",
")",
")",
";",
"gridLayoutPanel",
".",
"setLayout",
"(",
"layout",
")",
";",
"addBoxes",
"(",
"gridLayoutPanel",
",",
"boxCount",
".",
"getValue",
"(",
")",
".",
"intValue",
"(",
")",
")",
";",
"// give approx 3 rows, with a different number",
"// of boxes on the final row",
"container",
".",
"add",
"(",
"gridLayoutPanel",
")",
";",
"gridLayoutPanel",
".",
"setVisible",
"(",
"cbVisible",
".",
"isSelected",
"(",
")",
")",
";",
"}"
] | reset the container that holds the grid layout and create a new grid layout with the appropriate properties. | [
"reset",
"the",
"container",
"that",
"holds",
"the",
"grid",
"layout",
"and",
"create",
"a",
"new",
"grid",
"layout",
"with",
"the",
"appropriate",
"properties",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/layout/GridLayoutOptionsExample.java#L160-L183 |
139,691 | podio/podio-java | src/main/java/com/podio/subscription/SubscriptionAPI.java | SubscriptionAPI.getSubscription | public Subscription getSubscription(Reference reference) {
return getResourceFactory().getApiResource(
"/subscription/" + reference.toURLFragment(false)).get(
Subscription.class);
} | java | public Subscription getSubscription(Reference reference) {
return getResourceFactory().getApiResource(
"/subscription/" + reference.toURLFragment(false)).get(
Subscription.class);
} | [
"public",
"Subscription",
"getSubscription",
"(",
"Reference",
"reference",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/subscription/\"",
"+",
"reference",
".",
"toURLFragment",
"(",
"false",
")",
")",
".",
"get",
"(",
"Subscription",
".",
"class",
")",
";",
"}"
] | Get the subscription for the given object
@param reference
The reference to object
@return The subscription on the object | [
"Get",
"the",
"subscription",
"for",
"the",
"given",
"object"
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/subscription/SubscriptionAPI.java#L39-L43 |
139,692 | podio/podio-java | src/main/java/com/podio/subscription/SubscriptionAPI.java | SubscriptionAPI.subscribe | public void subscribe(Reference reference) {
getResourceFactory()
.getApiResource(
"/subscription/" + reference.toURLFragment(false))
.entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post();
} | java | public void subscribe(Reference reference) {
getResourceFactory()
.getApiResource(
"/subscription/" + reference.toURLFragment(false))
.entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post();
} | [
"public",
"void",
"subscribe",
"(",
"Reference",
"reference",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/subscription/\"",
"+",
"reference",
".",
"toURLFragment",
"(",
"false",
")",
")",
".",
"entity",
"(",
"new",
"Empty",
"(",
")",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"post",
"(",
")",
";",
"}"
] | Subscribes the user to the given object. Based on the object type, the
user will receive notifications when actions are performed on the object.
See the area for more details.
@param reference
The reference to the object to subscribe to | [
"Subscribes",
"the",
"user",
"to",
"the",
"given",
"object",
".",
"Based",
"on",
"the",
"object",
"type",
"the",
"user",
"will",
"receive",
"notifications",
"when",
"actions",
"are",
"performed",
"on",
"the",
"object",
".",
"See",
"the",
"area",
"for",
"more",
"details",
"."
] | a520b23bac118c957ce02cdd8ff42a6c7d17b49a | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/subscription/SubscriptionAPI.java#L53-L58 |
139,693 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxInterceptor.java | AjaxInterceptor.paint | @Override
public void paint(final RenderContext renderContext) {
AjaxOperation operation = AjaxHelper.getCurrentOperation();
if (operation == null) {
// the request attribute that we place in the ui context in the action phase can't be null
throw new SystemException(
"Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation.");
}
if (operation.getTargetContainerId() != null) {
paintContainerResponse(renderContext, operation);
} else {
paintResponse(renderContext, operation);
}
} | java | @Override
public void paint(final RenderContext renderContext) {
AjaxOperation operation = AjaxHelper.getCurrentOperation();
if (operation == null) {
// the request attribute that we place in the ui context in the action phase can't be null
throw new SystemException(
"Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation.");
}
if (operation.getTargetContainerId() != null) {
paintContainerResponse(renderContext, operation);
} else {
paintResponse(renderContext, operation);
}
} | [
"@",
"Override",
"public",
"void",
"paint",
"(",
"final",
"RenderContext",
"renderContext",
")",
"{",
"AjaxOperation",
"operation",
"=",
"AjaxHelper",
".",
"getCurrentOperation",
"(",
")",
";",
"if",
"(",
"operation",
"==",
"null",
")",
"{",
"// the request attribute that we place in the ui context in the action phase can't be null",
"throw",
"new",
"SystemException",
"(",
"\"Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation.\"",
")",
";",
"}",
"if",
"(",
"operation",
".",
"getTargetContainerId",
"(",
")",
"!=",
"null",
")",
"{",
"paintContainerResponse",
"(",
"renderContext",
",",
"operation",
")",
";",
"}",
"else",
"{",
"paintResponse",
"(",
"renderContext",
",",
"operation",
")",
";",
"}",
"}"
] | Paints the targeted ajax regions. The format of the response is an agreement between the server and the client
side JavaScript handling our ajax response.
@param renderContext the renderContext to send the output to. | [
"Paints",
"the",
"targeted",
"ajax",
"regions",
".",
"The",
"format",
"of",
"the",
"response",
"is",
"an",
"agreement",
"between",
"the",
"server",
"and",
"the",
"client",
"side",
"JavaScript",
"handling",
"our",
"ajax",
"response",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxInterceptor.java#L92-L106 |
139,694 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxInterceptor.java | AjaxInterceptor.paintContainerResponse | private void paintContainerResponse(final RenderContext renderContext,
final AjaxOperation operation) {
WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
XmlStringBuilder xml = webRenderContext.getWriter();
// Get trigger's context
ComponentWithContext trigger = AjaxHelper.getCurrentTriggerAndContext();
if (trigger == null) {
throw new SystemException("No context available for trigger " + operation.getTriggerId());
}
xml.appendTagOpen("ui:ajaxtarget");
xml.appendAttribute("id", operation.getTargetContainerId());
xml.appendAttribute("action", AjaxOperation.AjaxAction.REPLACE_CONTENT.getDesc());
xml.appendClose();
// Paint targets - Assume targets are in the same context as the trigger
UIContextHolder.pushContext(trigger.getContext());
try {
for (String targetId : operation.getTargets()) {
ComponentWithContext target;
if (targetId.equals(operation.getTriggerId())) {
target = trigger;
} else {
target = WebUtilities.getComponentById(targetId, true);
if (target == null) {
LOG.warn("Could not find ajax target to render [" + targetId + "]");
continue;
}
}
target.getComponent().paint(renderContext);
}
} finally {
UIContextHolder.popContext();
}
xml.appendEndTag("ui:ajaxtarget");
} | java | private void paintContainerResponse(final RenderContext renderContext,
final AjaxOperation operation) {
WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
XmlStringBuilder xml = webRenderContext.getWriter();
// Get trigger's context
ComponentWithContext trigger = AjaxHelper.getCurrentTriggerAndContext();
if (trigger == null) {
throw new SystemException("No context available for trigger " + operation.getTriggerId());
}
xml.appendTagOpen("ui:ajaxtarget");
xml.appendAttribute("id", operation.getTargetContainerId());
xml.appendAttribute("action", AjaxOperation.AjaxAction.REPLACE_CONTENT.getDesc());
xml.appendClose();
// Paint targets - Assume targets are in the same context as the trigger
UIContextHolder.pushContext(trigger.getContext());
try {
for (String targetId : operation.getTargets()) {
ComponentWithContext target;
if (targetId.equals(operation.getTriggerId())) {
target = trigger;
} else {
target = WebUtilities.getComponentById(targetId, true);
if (target == null) {
LOG.warn("Could not find ajax target to render [" + targetId + "]");
continue;
}
}
target.getComponent().paint(renderContext);
}
} finally {
UIContextHolder.popContext();
}
xml.appendEndTag("ui:ajaxtarget");
} | [
"private",
"void",
"paintContainerResponse",
"(",
"final",
"RenderContext",
"renderContext",
",",
"final",
"AjaxOperation",
"operation",
")",
"{",
"WebXmlRenderContext",
"webRenderContext",
"=",
"(",
"WebXmlRenderContext",
")",
"renderContext",
";",
"XmlStringBuilder",
"xml",
"=",
"webRenderContext",
".",
"getWriter",
"(",
")",
";",
"// Get trigger's context",
"ComponentWithContext",
"trigger",
"=",
"AjaxHelper",
".",
"getCurrentTriggerAndContext",
"(",
")",
";",
"if",
"(",
"trigger",
"==",
"null",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"No context available for trigger \"",
"+",
"operation",
".",
"getTriggerId",
"(",
")",
")",
";",
"}",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:ajaxtarget\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"operation",
".",
"getTargetContainerId",
"(",
")",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"action\"",
",",
"AjaxOperation",
".",
"AjaxAction",
".",
"REPLACE_CONTENT",
".",
"getDesc",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Paint targets - Assume targets are in the same context as the trigger",
"UIContextHolder",
".",
"pushContext",
"(",
"trigger",
".",
"getContext",
"(",
")",
")",
";",
"try",
"{",
"for",
"(",
"String",
"targetId",
":",
"operation",
".",
"getTargets",
"(",
")",
")",
"{",
"ComponentWithContext",
"target",
";",
"if",
"(",
"targetId",
".",
"equals",
"(",
"operation",
".",
"getTriggerId",
"(",
")",
")",
")",
"{",
"target",
"=",
"trigger",
";",
"}",
"else",
"{",
"target",
"=",
"WebUtilities",
".",
"getComponentById",
"(",
"targetId",
",",
"true",
")",
";",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Could not find ajax target to render [\"",
"+",
"targetId",
"+",
"\"]\"",
")",
";",
"continue",
";",
"}",
"}",
"target",
".",
"getComponent",
"(",
")",
".",
"paint",
"(",
"renderContext",
")",
";",
"}",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"xml",
".",
"appendEndTag",
"(",
"\"ui:ajaxtarget\"",
")",
";",
"}"
] | Paint the ajax container response.
@param renderContext the render context
@param operation the ajax operation | [
"Paint",
"the",
"ajax",
"container",
"response",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxInterceptor.java#L114-L151 |
139,695 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxInterceptor.java | AjaxInterceptor.isProcessTriggerOnly | private boolean isProcessTriggerOnly(final ComponentWithContext triggerWithContext,
final AjaxOperation operation) {
// Target container implies only process the trigger or is Internal Ajax
if (operation.getTargetContainerId() != null || operation.isInternalAjaxRequest()) {
return true;
}
WComponent trigger = triggerWithContext.getComponent();
// Check if trigger is a polling AJAX control
if (trigger instanceof WAjaxControl) {
// Get user context
UIContext uic = triggerWithContext.getContext();
UIContextHolder.pushContext(uic);
try {
WAjaxControl ajax = (WAjaxControl) trigger;
// Is a polling region so only process trigger
if (ajax.getDelay() > 0) {
return true;
}
} finally {
UIContextHolder.popContext();
}
}
return false;
} | java | private boolean isProcessTriggerOnly(final ComponentWithContext triggerWithContext,
final AjaxOperation operation) {
// Target container implies only process the trigger or is Internal Ajax
if (operation.getTargetContainerId() != null || operation.isInternalAjaxRequest()) {
return true;
}
WComponent trigger = triggerWithContext.getComponent();
// Check if trigger is a polling AJAX control
if (trigger instanceof WAjaxControl) {
// Get user context
UIContext uic = triggerWithContext.getContext();
UIContextHolder.pushContext(uic);
try {
WAjaxControl ajax = (WAjaxControl) trigger;
// Is a polling region so only process trigger
if (ajax.getDelay() > 0) {
return true;
}
} finally {
UIContextHolder.popContext();
}
}
return false;
} | [
"private",
"boolean",
"isProcessTriggerOnly",
"(",
"final",
"ComponentWithContext",
"triggerWithContext",
",",
"final",
"AjaxOperation",
"operation",
")",
"{",
"// Target container implies only process the trigger or is Internal Ajax",
"if",
"(",
"operation",
".",
"getTargetContainerId",
"(",
")",
"!=",
"null",
"||",
"operation",
".",
"isInternalAjaxRequest",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"WComponent",
"trigger",
"=",
"triggerWithContext",
".",
"getComponent",
"(",
")",
";",
"// Check if trigger is a polling AJAX control",
"if",
"(",
"trigger",
"instanceof",
"WAjaxControl",
")",
"{",
"// Get user context",
"UIContext",
"uic",
"=",
"triggerWithContext",
".",
"getContext",
"(",
")",
";",
"UIContextHolder",
".",
"pushContext",
"(",
"uic",
")",
";",
"try",
"{",
"WAjaxControl",
"ajax",
"=",
"(",
"WAjaxControl",
")",
"trigger",
";",
"// Is a polling region so only process trigger",
"if",
"(",
"ajax",
".",
"getDelay",
"(",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if process this trigger only.
@param triggerWithContext the trigger with its context
@param operation current ajax operation
@return true if process this trigger only | [
"Check",
"if",
"process",
"this",
"trigger",
"only",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/AjaxInterceptor.java#L204-L231 |
139,696 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ConfigurationProperties.java | ConfigurationProperties.getHandleErrorWithFatalErrorPageFactory | public static boolean getHandleErrorWithFatalErrorPageFactory() {
Boolean parameterValue = get().getBoolean(HANDLE_ERROR_WITH_FATAL_PAGE_FACTORY, null);
if (parameterValue != null) {
return parameterValue;
}
// fall-back to the old parameter value if the new value is not set.
return get().getBoolean(HANDLE_ERROR_WITH_FATAL_PAGE_FACTORY_DEPRECATED, false);
} | java | public static boolean getHandleErrorWithFatalErrorPageFactory() {
Boolean parameterValue = get().getBoolean(HANDLE_ERROR_WITH_FATAL_PAGE_FACTORY, null);
if (parameterValue != null) {
return parameterValue;
}
// fall-back to the old parameter value if the new value is not set.
return get().getBoolean(HANDLE_ERROR_WITH_FATAL_PAGE_FACTORY_DEPRECATED, false);
} | [
"public",
"static",
"boolean",
"getHandleErrorWithFatalErrorPageFactory",
"(",
")",
"{",
"Boolean",
"parameterValue",
"=",
"get",
"(",
")",
".",
"getBoolean",
"(",
"HANDLE_ERROR_WITH_FATAL_PAGE_FACTORY",
",",
"null",
")",
";",
"if",
"(",
"parameterValue",
"!=",
"null",
")",
"{",
"return",
"parameterValue",
";",
"}",
"// fall-back to the old parameter value if the new value is not set.",
"return",
"get",
"(",
")",
".",
"getBoolean",
"(",
"HANDLE_ERROR_WITH_FATAL_PAGE_FACTORY_DEPRECATED",
",",
"false",
")",
";",
"}"
] | The flag indicating whether to handle an error with a fatal error page factory.
@return the new parameter value if set, else the old parameter value if set, or false if neither set. | [
"The",
"flag",
"indicating",
"whether",
"to",
"handle",
"an",
"error",
"with",
"a",
"fatal",
"error",
"page",
"factory",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ConfigurationProperties.java#L645-L653 |
139,697 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ConfigurationProperties.java | ConfigurationProperties.getRendererOverride | public static String getRendererOverride(final String classname) {
if (StringUtils.isBlank(classname)) {
throw new IllegalArgumentException("classname cannot be blank.");
}
return get().getString(RENDERER_OVERRIDE_PREFIX + classname);
} | java | public static String getRendererOverride(final String classname) {
if (StringUtils.isBlank(classname)) {
throw new IllegalArgumentException("classname cannot be blank.");
}
return get().getString(RENDERER_OVERRIDE_PREFIX + classname);
} | [
"public",
"static",
"String",
"getRendererOverride",
"(",
"final",
"String",
"classname",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"classname",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"classname cannot be blank.\"",
")",
";",
"}",
"return",
"get",
"(",
")",
".",
"getString",
"(",
"RENDERER_OVERRIDE_PREFIX",
"+",
"classname",
")",
";",
"}"
] | The overridden renderer class for the given fully qualified classname.
@param classname the fully qualified classname of the WComponent to check for an overridden renderer.
@return the parameter value, else null if not set. | [
"The",
"overridden",
"renderer",
"class",
"for",
"the",
"given",
"fully",
"qualified",
"classname",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ConfigurationProperties.java#L852-L858 |
139,698 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ConfigurationProperties.java | ConfigurationProperties.getResponseCacheHeaderSettings | public static String getResponseCacheHeaderSettings(final String contentType) {
String parameter = MessageFormat.format(RESPONSE_CACHE_HEADER_SETTINGS, contentType);
return get().getString(parameter);
} | java | public static String getResponseCacheHeaderSettings(final String contentType) {
String parameter = MessageFormat.format(RESPONSE_CACHE_HEADER_SETTINGS, contentType);
return get().getString(parameter);
} | [
"public",
"static",
"String",
"getResponseCacheHeaderSettings",
"(",
"final",
"String",
"contentType",
")",
"{",
"String",
"parameter",
"=",
"MessageFormat",
".",
"format",
"(",
"RESPONSE_CACHE_HEADER_SETTINGS",
",",
"contentType",
")",
";",
"return",
"get",
"(",
")",
".",
"getString",
"(",
"parameter",
")",
";",
"}"
] | The response cache header settings for the given contentType.
@param contentType the content type in the format 'type.[cache | nocache]', e.g. 'page.nocache'.
@return the parameter value if set, or null if not set. | [
"The",
"response",
"cache",
"header",
"settings",
"for",
"the",
"given",
"contentType",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ConfigurationProperties.java#L866-L869 |
139,699 | BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSuggestionsRenderer.java | WSuggestionsRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSuggestions suggestions = (WSuggestions) component;
XmlStringBuilder xml = renderContext.getWriter();
// Cache key for a lookup table
String dataKey = suggestions.getListCacheKey();
// Use AJAX if not using a cached list and have a refresh action
boolean useAjax = dataKey == null && suggestions.getRefreshAction() != null;
// Start tag
xml.appendTagOpen("ui:suggestions");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("min", suggestions.getMinRefresh() > 0, suggestions.
getMinRefresh());
xml.appendOptionalAttribute("ajax", useAjax, "true");
xml.appendOptionalAttribute("data", dataKey);
WSuggestions.Autocomplete autocomplete = suggestions.getAutocomplete();
if (autocomplete == WSuggestions.Autocomplete.LIST) {
xml.appendOptionalAttribute("autocomplete", "list");
}
xml.appendClose();
// Check if this is the current AJAX trigger
boolean isTrigger = useAjax && AjaxHelper.isCurrentAjaxTrigger(suggestions);
// Render suggestions
if (isTrigger || (dataKey == null && !useAjax)) {
for (String suggestion : suggestions.getSuggestions()) {
xml.appendTagOpen("ui:suggestion");
xml.appendAttribute("value", suggestion);
xml.appendEnd();
}
}
// End tag
xml.appendEndTag("ui:suggestions");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSuggestions suggestions = (WSuggestions) component;
XmlStringBuilder xml = renderContext.getWriter();
// Cache key for a lookup table
String dataKey = suggestions.getListCacheKey();
// Use AJAX if not using a cached list and have a refresh action
boolean useAjax = dataKey == null && suggestions.getRefreshAction() != null;
// Start tag
xml.appendTagOpen("ui:suggestions");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("min", suggestions.getMinRefresh() > 0, suggestions.
getMinRefresh());
xml.appendOptionalAttribute("ajax", useAjax, "true");
xml.appendOptionalAttribute("data", dataKey);
WSuggestions.Autocomplete autocomplete = suggestions.getAutocomplete();
if (autocomplete == WSuggestions.Autocomplete.LIST) {
xml.appendOptionalAttribute("autocomplete", "list");
}
xml.appendClose();
// Check if this is the current AJAX trigger
boolean isTrigger = useAjax && AjaxHelper.isCurrentAjaxTrigger(suggestions);
// Render suggestions
if (isTrigger || (dataKey == null && !useAjax)) {
for (String suggestion : suggestions.getSuggestions()) {
xml.appendTagOpen("ui:suggestion");
xml.appendAttribute("value", suggestion);
xml.appendEnd();
}
}
// End tag
xml.appendEndTag("ui:suggestions");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WSuggestions",
"suggestions",
"=",
"(",
"WSuggestions",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"// Cache key for a lookup table",
"String",
"dataKey",
"=",
"suggestions",
".",
"getListCacheKey",
"(",
")",
";",
"// Use AJAX if not using a cached list and have a refresh action",
"boolean",
"useAjax",
"=",
"dataKey",
"==",
"null",
"&&",
"suggestions",
".",
"getRefreshAction",
"(",
")",
"!=",
"null",
";",
"// Start tag",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:suggestions\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"class\"",
",",
"component",
".",
"getHtmlClass",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"track\"",
",",
"component",
".",
"isTracking",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"min\"",
",",
"suggestions",
".",
"getMinRefresh",
"(",
")",
">",
"0",
",",
"suggestions",
".",
"getMinRefresh",
"(",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"ajax\"",
",",
"useAjax",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"data\"",
",",
"dataKey",
")",
";",
"WSuggestions",
".",
"Autocomplete",
"autocomplete",
"=",
"suggestions",
".",
"getAutocomplete",
"(",
")",
";",
"if",
"(",
"autocomplete",
"==",
"WSuggestions",
".",
"Autocomplete",
".",
"LIST",
")",
"{",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"autocomplete\"",
",",
"\"list\"",
")",
";",
"}",
"xml",
".",
"appendClose",
"(",
")",
";",
"// Check if this is the current AJAX trigger",
"boolean",
"isTrigger",
"=",
"useAjax",
"&&",
"AjaxHelper",
".",
"isCurrentAjaxTrigger",
"(",
"suggestions",
")",
";",
"// Render suggestions",
"if",
"(",
"isTrigger",
"||",
"(",
"dataKey",
"==",
"null",
"&&",
"!",
"useAjax",
")",
")",
"{",
"for",
"(",
"String",
"suggestion",
":",
"suggestions",
".",
"getSuggestions",
"(",
")",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:suggestion\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"value\"",
",",
"suggestion",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"}",
"// End tag",
"xml",
".",
"appendEndTag",
"(",
"\"ui:suggestions\"",
")",
";",
"}"
] | Paints the given WSuggestions.
@param component the WSuggestions to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WSuggestions",
"."
] | d1a2b2243270067db030feb36ca74255aaa94436 | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSuggestionsRenderer.java#L24-L63 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.