Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/src/org/labkey/api/data/AbstractFileDisplayColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public void renderInputHtml(RenderContext ctx, Writer out, Object value) throws

Input.InputBuilder input = new Input.InputBuilder()
.type("file")
.name(getInputPrefix() + formFieldName)
.name(formFieldName)
.disabled(isDisabledInput(ctx))
.needsWrapping(false);

Expand All @@ -288,7 +288,6 @@ public void renderInputHtml(RenderContext ctx, Writer out, Object value) throws
/**
* Enable subclasses to override the warning text
* @param filename being displayed
* @return
*/
protected String getRemovalWarningText(String filename)
{
Expand Down
88 changes: 42 additions & 46 deletions api/src/org/labkey/api/data/DataColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ public DataColumn(ColumnInfo col, boolean withLookups)
{
_width = _displayColumn.getWidth();
}
StringExpression url = withLookups ?
_boundColumn.getEffectiveURL() :
_boundColumn.getURL();
StringExpression url = withLookups ? _boundColumn.getEffectiveURL() : _boundColumn.getURL();
if (null != url)
super.setURLExpression(url);
setLinkTarget(_boundColumn.getURLTargetWindow());
Expand All @@ -129,7 +127,6 @@ public DataColumn(ColumnInfo col, boolean withLookups)
else
_inputType = "select";
}

}
catch (QueryParseException qpe)
{
Expand All @@ -143,7 +140,6 @@ public DataColumn(ColumnInfo col, boolean withLookups)
_caption = StringExpressionFactory.create(_boundColumn.getLabel());
_editable = !_boundColumn.isReadOnly() && _boundColumn.isUserEditable();
_textAlign = _displayColumn.getTextAlign();

}


Expand Down Expand Up @@ -282,7 +278,7 @@ public void addQueryColumns(Set<ColumnInfo> columns)
@Override
public boolean isSortable()
{
return _sortFieldKeys != null && _sortFieldKeys.size() > 0;
return _sortFieldKeys != null && !_sortFieldKeys.isEmpty();
}

@Override
Expand Down Expand Up @@ -718,9 +714,9 @@ private void renderSelectFormInput(
) throws IOException
{
Select.SelectBuilder select = new Select.SelectBuilder()
.disabled(disabledInput)
.multiple("select.multiple".equalsIgnoreCase(_inputType))
.name(getInputPrefix() + formFieldName);
.disabled(disabledInput)
.multiple("select.multiple".equalsIgnoreCase(_inputType))
.name(formFieldName);

List<Option> options = new ArrayList<>();

Expand Down Expand Up @@ -794,10 +790,10 @@ protected void renderFileFormInput(RenderContext ctx, Writer out, String formFie
throws IOException
{
var input = new Input.InputBuilder<>()
.type("file")
.name(getInputPrefix() + formFieldName)
.disabled(disabledInput)
.needsWrapping(false);
.type("file")
.name(formFieldName)
.disabled(disabledInput)
.needsWrapping(false);

out.write(input.build().toString());
}
Expand All @@ -808,12 +804,12 @@ protected void renderCheckboxFormInput(RenderContext ctx, Writer out, String for
boolean checked = ColumnInfo.booleanFromObj(ConvertUtils.convert(value));

var input = new Input.InputBuilder<>()
.type("checkbox")
.name(getInputPrefix() + formFieldName)
.disabled(disabledInput)
.value("1")
.checked(checked)
.needsWrapping(false);
.type("checkbox")
.name(formFieldName)
.disabled(disabledInput)
.value("1")
.checked(checked)
.needsWrapping(false);

out.write(input.build().toString());

Expand All @@ -838,11 +834,11 @@ protected void renderTextAreaFormInput(RenderContext ctx, Writer out, String for
throws IOException
{
TextArea.TextAreaBuilder input = new TextArea.TextAreaBuilder()
.columns(_inputLength)
.rows(_inputRows)
.name(getInputPrefix() + formFieldName)
.disabled(disabledInput)
.value(strVal);
.columns(_inputLength)
.rows(_inputRows)
.name(formFieldName)
.disabled(disabledInput)
.value(strVal);

out.write(input.build().toString());

Expand All @@ -855,11 +851,11 @@ protected void renderTextFormInput(RenderContext ctx, Writer out, String formFie
throws IOException
{
var input = new Input.InputBuilder<>()
.name(getInputPrefix() + formFieldName)
.disabled(disabledInput)
.size(_inputLength)
.value(strVal)
.needsWrapping(false);
.name(formFieldName)
.disabled(disabledInput)
.size(_inputLength)
.value(strVal)
.needsWrapping(false);

out.write(input.build().toString());

Expand All @@ -874,22 +870,22 @@ protected void renderAutoCompleteFormInput(RenderContext ctx, Writer out, String
String renderId = "auto-complete-div-" + UniqueID.getRequestScopedUID(ctx.getRequest());
out.write("<div id='" + renderId + "'></div>");
String initScript =
"Ext4.onReady(function(){\n" +
" Ext4.create('LABKEY.element.AutoCompletionField', {\n" +
" renderTo : " + PageFlowUtil.jsString(renderId) + ",\n" +
" completionUrl : " + PageFlowUtil.jsString(autoCompleteURLPrefix) + ",\n" +
" sharedStore : true,\n" +
" sharedStoreId : " + PageFlowUtil.jsString(autoCompleteURLPrefix) + ",\n" +
" tagConfig : {\n" +
" tag : 'input',\n" +
" type : 'text',\n" +
" name : " + PageFlowUtil.jsString(formFieldName) + ",\n" +
" size : " + _inputLength + ",\n" +
" value : " + PageFlowUtil.jsString(strVal) + ",\n" +
" autocomplete : 'off'\n" +
" }\n" +
" });\n" +
" });\n"
"Ext4.onReady(function(){\n" +
" Ext4.create('LABKEY.element.AutoCompletionField', {\n" +
" renderTo : " + PageFlowUtil.jsString(renderId) + ",\n" +
" completionUrl : " + PageFlowUtil.jsString(autoCompleteURLPrefix) + ",\n" +
" sharedStore : true,\n" +
" sharedStoreId : " + PageFlowUtil.jsString(autoCompleteURLPrefix) + ",\n" +
" tagConfig : {\n" +
" tag : 'input',\n" +
" type : 'text',\n" +
" name : " + PageFlowUtil.jsString(formFieldName) + ",\n" +
" size : " + _inputLength + ",\n" +
" value : " + PageFlowUtil.jsString(strVal) + ",\n" +
" autocomplete : 'off'\n" +
" }\n" +
" });\n" +
" });\n"
;
HttpView.currentPageConfig().addDOMContentLoadedHandler(JavaScriptFragment.unsafe(initScript));
}
Expand All @@ -915,7 +911,7 @@ protected String h(Object value)
@Override
public String getSortHandler(RenderContext ctx, Sort.SortDirection sort)
{
if (_displayColumn == null || _sortFieldKeys == null || _sortFieldKeys.size() == 0)
if (_displayColumn == null || _sortFieldKeys == null || _sortFieldKeys.isEmpty())
return "";

String regionName = ctx.getCurrentRegion().getName();
Expand Down
21 changes: 0 additions & 21 deletions api/src/org/labkey/api/data/DataRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public class DataRegion extends DisplayElement
private ButtonBar _insertButtonBar = new ButtonBar();
private ButtonBar _updateButtonBar = new ButtonBar();
private ButtonBar _detailsButtonBar = new ButtonBar();
private String _inputPrefix = null;
private List<String> _recordSelectorValueColumns;
private int _maxRows = Table.ALL_ROWS; // Display all rows by default
private final List<Pair<String, Object>> _hiddenFormFields = new ArrayList<>(); // Hidden params to be posted (e.g., to pass a query string along with selected grid rows)
Expand Down Expand Up @@ -280,8 +279,6 @@ public void addDisplayColumn(@NotNull DisplayColumn col)
if (null == col)
return;
_displayColumns.add(col);
if (null != _inputPrefix)
col.setInputPrefix(_inputPrefix);
}

public void addDisplayColumn(int index, @NotNull DisplayColumn col)
Expand All @@ -290,14 +287,6 @@ public void addDisplayColumn(int index, @NotNull DisplayColumn col)
if (null == col)
return;
_displayColumns.add(index, col);
if (null != _inputPrefix)
col.setInputPrefix(_inputPrefix);
}

public void addDisplayColumns(List<DisplayColumn> displayColumns)
{
for (DisplayColumn displayColumn : displayColumns)
addDisplayColumn(displayColumn);
}

/* We don't want callers to modify this list directly. However, this is the only way for subclasses to modify the list */
Expand Down Expand Up @@ -355,9 +344,6 @@ public void setDisplayColumns(List<DisplayColumn> displayColumns)
* however, this breaks MS2 which seems to do funny things with nested RenderContexts
*/
_displayColumns = displayColumns;
if (null != _inputPrefix)
for (DisplayColumn dc : _displayColumns)
dc.setInputPrefix(_inputPrefix);
}

public void removeColumns(String... columns)
Expand Down Expand Up @@ -417,13 +403,6 @@ public void replaceDisplayColumn(String name, DisplayColumn replacement)
}
}

public void setInputPrefix(String inputPrefix)
{
_inputPrefix = inputPrefix;
for (DisplayColumn dc : _displayColumns)
dc.setInputPrefix(_inputPrefix);
}

public void addButtonBarConfig(ButtonBarConfig buttonBarConfig)
{
assert buttonBarConfig != null : "Cannot add a null ButtonBarConfig";
Expand Down
55 changes: 19 additions & 36 deletions api/src/org/labkey/api/data/DisplayColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public abstract class DisplayColumn extends RenderColumn
private StringExpression _textExpression = null;
private StringExpression _textExpressionCompiled = null;
protected String _gridHeaderClass = "labkey-col-header-filter";
private String _inputPrefix = "";
private String _description = null;
protected boolean _requiresHtmlFiltering = true;
private String _displayClass;
Expand Down Expand Up @@ -334,16 +333,6 @@ public String getName()
return super.getName();
}

protected String getInputPrefix()
{
return _inputPrefix;
}

protected void setInputPrefix(String inputPrefix)
{
_inputPrefix = inputPrefix;
}

/** If width is null, no width will be requested in the HTML table */
public void setWidth(@Nullable String width)
{
Expand Down Expand Up @@ -596,7 +585,7 @@ public String getJsonTypeName()
return getJsonTypeName(getValueClass());
}

public static String getJsonTypeName(Class valueClass)
public static String getJsonTypeName(Class<?> valueClass)
{
if (String.class.isAssignableFrom(valueClass))
return "string";
Expand All @@ -623,18 +612,16 @@ public static Class getClassFromJsonTypeName(String typeName)
if (typeName == null)
return String.class;

switch (typeName)
return switch (typeName)
{
case "boolean": return Boolean.class;
case "int": return Integer.class;
case "float": return Float.class;
case "date": return Date.class;
case "string":
default: return String.class;
}
case "boolean" -> Boolean.class;
case "int" -> Integer.class;
case "float" -> Float.class;
case "date" -> Date.class;
default -> String.class;
};
}


/** The value to display. Not HTML or otherwise encoded. */
public Object getDisplayValue(RenderContext ctx)
{
Expand Down Expand Up @@ -770,7 +757,7 @@ public void renderGridHeaderCell(RenderContext ctx, Writer out, String headerCla
{
if (!getColumnInfo().getFieldKey().toString().equals(getColumnInfo().getLabel()))
{
boolean suffix = tooltip.length() > 0;
boolean suffix = !tooltip.isEmpty();
if (suffix)
{
tooltip.append(" (");
Expand All @@ -792,18 +779,18 @@ public void renderGridHeaderCell(RenderContext ctx, Writer out, String headerCla
if (null != concept)
conceptDisplay = concept.getLabel() + " (" + conceptDisplay + ")";
}
tooltip.append("\nConcept Annotation: " + conceptDisplay);
tooltip.append("\nConcept Annotation: ").append(conceptDisplay);
}

if (isPhiProtected())
{
if (tooltip.length() > 0)
if (!tooltip.isEmpty())
tooltip.append("\n");
tooltip.append("(PHI protected data removed)");
}
}

if (tooltip.length() > 0)
if (!tooltip.isEmpty())
{
out.write(" title=\"");
out.write(PageFlowUtil.filter(tooltip.toString()));
Expand All @@ -823,7 +810,7 @@ public void renderGridHeaderCell(RenderContext ctx, Writer out, String headerCla
style += ";width:" + getWidth() + "px;";

out.write("<div ");
if (!"".equals(style))
if (!style.isEmpty())
{
out.write("style=\"");
out.write(style);
Expand All @@ -844,7 +831,7 @@ public void renderGridHeaderCell(RenderContext ctx, Writer out, String headerCla
// 31304: click target should fill the entire cell
out.write("<div class=\"dropdown-toggle\" data-toggle=\"dropdown\"></div>");
out.write("<ul class=\"dropdown-menu\"");
if (tooltip.length() > 0) // 36050
if (!tooltip.isEmpty()) // 36050
out.write(" title=\"\"");
out.write(">");
PopupMenuView.renderTree(navTree, out);
Expand Down Expand Up @@ -894,11 +881,7 @@ private boolean isFiltered(RenderContext ctx)
ActionURL url = ctx.getSortFilterURLHelper();
SimpleFilter filter = new SimpleFilter(url, rgn.getName());

filteredColSet = new HashSet<>();
for (FieldKey fieldKey : filter.getWhereParamFieldKeys())
{
filteredColSet.add(fieldKey);
}
filteredColSet = new HashSet<>(filter.getWhereParamFieldKeys());
ctx.put(rgn.getName() + ".filteredCols", filteredColSet);
}

Expand Down Expand Up @@ -1115,13 +1098,13 @@ protected String getHoverTitle(RenderContext ctx)
return null;
}

@NotNull /** Always return a non-null string to make it easy to concatenate values */
@NotNull /* Always return a non-null string to make it easy to concatenate values */
public String getDisplayClass(RenderContext ctx)
{
return _displayClass != null ? _displayClass : "";
}

@NotNull /** Always return a non-null string to make it easy to concatenate values */
@NotNull /* Always return a non-null string to make it easy to concatenate values */
public String getCssStyle(RenderContext ctx)
{
String style = "";
Expand Down Expand Up @@ -1265,7 +1248,7 @@ public String getFormFieldName(RenderContext ctx)
protected void outputName(RenderContext ctx, Writer out, String formFieldName) throws IOException
{
out.write(" name=\"");
out.write(PageFlowUtil.filter(getInputPrefix() + formFieldName));
out.write(PageFlowUtil.filter(formFieldName));
out.write("\"");

String setFocusId = (String)ctx.get("setFocusId");
Expand All @@ -1284,7 +1267,7 @@ public void renderHiddenFormInput(RenderContext ctx, Writer out) throws IOExcept
protected void renderHiddenFormInput(RenderContext ctx, Writer out, String formFieldName, Object value) throws IOException
{
out.write(new Input.InputBuilder()
.name(getInputPrefix() + formFieldName)
.name(formFieldName)
.type("hidden")
.value(null != value ? value.toString() : null)
.toString());
Expand Down
Loading
Loading