public void resetData() { if (StringUtils.hasText(param.getDescription())) { commentJL.setText(StringUtils.getHTMLFormattedComment(param.getDescription(), null, false)); } else { commentJL.setText(""); } commentJL.updateUI(); String paramName = Utilities.getParamDisplayName(param); if (param.getIsTabularData()) { StringBuffer html = new StringBuffer(); int rc = 1; if (param.isPAEnabled() && !param.isSingleRow() && param.getParameterAnalysis().getPaTableList() != null && !param.getParameterAnalysis().getPaTableList().isEmpty()) { rc = param.getParameterAnalysis().getPaTableList().iterator().next().length; } else if (param.getTabularData() != null && param.getTabularData().length > 0) { rc = param.getTabularData().length; } html.append( "<html><body><table border=0 cellspacing=0 cellpadding=0><tr><td>" + paramName + "</td></tr>"); while (--rc != 0) { html.append("<tr><td><font color='orange'>&</font></td></tr>"); } html.append("</table></body></html>"); paramName = html.toString(); } paramNameJL.setText(paramName); if (param.isPAEnabled()) { PAValueStatus stat = new PAValueStatus(); paramValueJL.setText(getPAValueText(stat)); if (stat.isError) { setMarkerMessage( "Following values are generated in multiple ranges. [" + stat.message + "]", Color.RED); } else { setMarkerMessage( "This Parameter is configured for Parameter Studies. The values displayed here are only for suggestion.", Color.BLUE); } } else { paramValueJL.setText(getParamValueText()); clearMarker(); } paramNameJL.updateUI(); paramValueJL.updateUI(); }
private String getParamValueText() { StringBuffer sb = new StringBuffer(); if (!param.getIsTabularData()) { if (param.getValue() != null) { if (param.getDataType().equals("file")) sb.append(StringUtils.createFileName(param.getValue().getValue().toString())); else sb.append(param.getValue().getValue().toString()); } } else { String[] types = param.getColumnTypes(); Value[][] data = param.getTabularData(); if (data != null && data.length > 0) { sb.append("<html><table border=0 cellspacing=0 cellpadding=0>"); for (int i = 0; i < data.length; i++) { Value[] rec = data[i]; sb.append("<tr>"); for (int j = 0; j < rec.length; j++) { Value value = rec[j]; sb.append("<td style='padding-right:5px;'>"); if (value != null) { if (types[j].equals("file")) sb.append(StringUtils.createFileName(value.getValue().toString())); else sb.append(value.getValue().toString()); } sb.append("</td>"); } if (i < data.length - 1) { sb.append("<td><font color='orange'>&</font></td>"); } else { sb.append("<td></td>"); } sb.append("</tr>"); } sb.append("</table></html>"); } } return sb.toString(); }
// TODO 2 Re-factor to merge the PA and non PA method private String getPAValueText(PAValueStatus stat) { StringBuffer sb = new StringBuffer(); if (!param.getIsTabularData()) { Value val = Value.valueFactory(""); if (param.getDataType().equals("int") || param.getDataType().equals("float")) { Value[] values = PAValueUtility.createValuesForRanges(param, stat); if (values.length > 0) val = values[0]; } else if (param.getDataType().equals("string") || param.getDataType().equals("list")) { List<Value> values = param.getParameterAnalysis().getPaValueList(); if (values.size() > 0) val = values.get(0); } sb.append(val.getValue().toString()); } else { Value[][] data = null; String[] types = param.getColumnTypes(); if (param.isSingleRow()) { data = param.getParameterAnalysis().getPaRowList(); if (data != null) data = new Value[][] {data[0]}; } else if (!param.getParameterAnalysis().getPaTableList().isEmpty()) { data = param.getParameterAnalysis().getPaTableList().iterator().next(); } if (data != null && data.length > 0) { sb.append("<html><table border=0 cellspacing=0 cellpadding=0>"); for (int i = 0; i < data.length; i++) { Value[] rec = data[i]; sb.append("<tr>"); for (int j = 0; j < rec.length; j++) { Value value = rec[j]; sb.append("<td style='padding-right:5px;'>"); if (value != null) { if (types[j].equals("file")) sb.append(StringUtils.createFileName(value.getValue().toString())); else sb.append(value.getValue().toString()); } sb.append("</td>"); } if (i < data.length - 1) { sb.append("<td><font color='orange'>&</font></td>"); } else { sb.append("<td></td>"); } sb.append("</tr>"); } sb.append("</table></html>"); } } return sb.toString(); }