_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3 values | text stringlengths 73 34.1k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q178800 | PicturesUtility.generatePictureStyle | test | public static String generatePictureStyle(final Sheet sheet1,
final FacesCell fcell, final Cell cell, final Picture pic) {
ClientAnchor anchor = pic.getClientAnchor();
if (anchor != null) {
AnchorSize anchorSize = getAnchorSize(sheet1, fcell, cell,
anchor);
if (anchorSize != null) {
return "MARGIN-LEFT:"
+ String.format("%.2f", anchorSize.getPercentLeft())
+ "%;MARGIN-TOP:"
+ String.format("%.2f", anchorSize.getPercentTop())
+ "%;width:" + String.format("%.2f",
anchorSize.getPercentWidth())
+ "%;";
}
}
return "";
} | java | {
"resource": ""
} |
q178801 | PicturesUtility.generateChartStyle | test | public static String generateChartStyle(final Sheet sheet1,
final FacesCell fcell, final Cell cell, final String chartId,
final Map<String, ClientAnchor> anchorsMap) {
ClientAnchor anchor = anchorsMap.get(chartId);
if (anchor != null) {
AnchorSize anchorSize = getAnchorSize(sheet1, fcell, cell,
anchor);
if (anchorSize != null) {
return "MARGIN-LEFT:"
+ String.format("%.2f", anchorSize.getPercentLeft())
+ "%;MARGIN-TOP:"
+ String.format("%.2f", anchorSize.getPercentTop())
+ "%;width:"
+ String.format("%.2f",
anchorSize.getPercentWidth())
+ "%;height:135%;";
}
}
return "";
} | java | {
"resource": ""
} |
q178802 | PicturesUtility.getAnchorSize | test | public static AnchorSize getAnchorSize(final Sheet sheet1,
final FacesCell fcell, final Cell cell,
final ClientAnchor anchor) {
if (!(sheet1 instanceof XSSFSheet)) {
return null;
}
double picWidth = 0.0;
double picHeight = 0.0;
int left = anchor.getDx1()
/ org.apache.poi.util.Units.EMU_PER_PIXEL;
int top = (int) ((double) anchor.getDy1()
/ org.apache.poi.util.Units.EMU_PER_PIXEL
/ WebSheetUtility.PICTURE_HEIGHT_ADJUST);
int right = anchor.getDx2()
/ org.apache.poi.util.Units.EMU_PER_PIXEL;
int bottom = (int) ((double) anchor.getDy2()
/ org.apache.poi.util.Units.EMU_PER_PIXEL
/ WebSheetUtility.PICTURE_HEIGHT_ADJUST);
double cellWidth = 0.0;
double cellHeight = 0.0;
if ((cell != null) && (fcell != null)) {
for (int col = cell.getColumnIndex(); col < cell
.getColumnIndex() + fcell.getColspan(); col++) {
cellWidth += sheet1.getColumnWidthInPixels(col);
}
double lastCellWidth = sheet1.getColumnWidthInPixels(
cell.getColumnIndex() + fcell.getColspan() - 1);
for (int rowIndex = cell.getRowIndex(); rowIndex < cell
.getRowIndex() + fcell.getRowspan(); rowIndex++) {
cellHeight += WebSheetUtility.pointsToPixels(
sheet1.getRow(rowIndex).getHeightInPoints());
}
double lastCellHeight = WebSheetUtility.pointsToPixels(sheet1
.getRow(cell.getRowIndex() + fcell.getRowspan() - 1)
.getHeightInPoints());
picWidth = cellWidth - lastCellWidth + right - left;
picHeight = cellHeight - lastCellHeight + bottom - top;
} else {
for (short col = anchor.getCol1(); col < anchor
.getCol2(); col++) {
picWidth += sheet1.getColumnWidthInPixels(col);
}
for (int rowindex = anchor.getRow1(); rowindex < anchor
.getRow2(); rowindex++) {
Row row = sheet1.getRow(rowindex);
if (row != null) {
picHeight += WebSheetUtility
.pointsToPixels(row.getHeightInPoints());
}
}
}
return new AnchorSize(left, top, (int) picWidth, (int) picHeight,
cellWidth, cellHeight);
} | java | {
"resource": ""
} |
q178803 | TieCommandAlias.getPattern | test | public Pattern getPattern() {
if ((this.pattern == null) && (alias != null)) {
this.pattern = Pattern.compile("\\s*" + ParserUtility.wildcardToRegex(alias));
}
return pattern;
} | java | {
"resource": ""
} |
q178804 | TieWebSheetChartsService.getChart | test | public StreamedContent getChart() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
// So, we're rendering the HTML. Return a stub StreamedContent so
// that it will generate right URL.
LOG.fine(" return empty chart picture");
return new DefaultStreamedContent();
} else {
// So, browser is requesting the image. Return a real
// StreamedContent with the image bytes.
String chartId = context.getExternalContext()
.getRequestParameterMap().get("chartViewId");
BufferedImage bufferedImg = (BufferedImage) FacesContext
.getCurrentInstance().getExternalContext()
.getSessionMap().get(chartId);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(bufferedImg, "png", os);
FacesContext.getCurrentInstance().getExternalContext()
.getSessionMap().remove(chartId);
return new DefaultStreamedContent(new ByteArrayInputStream(
os.toByteArray()), "image/png");
}
} | java | {
"resource": ""
} |
q178805 | SerialCell.recover | test | public final void recover(final Sheet sheet) {
if (this.cellAddr != null) {
this.setCell(sheet.getRow(this.cellAddr.getRow())
.getCell(this.cellAddr.getColumn()));
}
} | java | {
"resource": ""
} |
q178806 | CellStyleUtility.getRowStyle | test | public static String getRowStyle(final Workbook wb, final Cell poiCell,
final String inputType, final float rowHeight,
final int rowspan) {
CellStyle cellStyle = poiCell.getCellStyle();
if ((cellStyle != null) && (rowspan == 1)) {
short fontIdx = cellStyle.getFontIndex();
Font font = wb.getFontAt(fontIdx);
float maxHeight = rowHeight;
if (!inputType.isEmpty()) {
maxHeight = Math.min(font.getFontHeightInPoints() + 8f,
rowHeight);
}
return "height:" + WebSheetUtility.pointsToPixels(maxHeight)
+ "px;";
}
return "";
} | java | {
"resource": ""
} |
q178807 | CellStyleUtility.getCellFontStyle | test | public static String getCellFontStyle(final Workbook wb,
final Cell poiCell) {
CellStyle cellStyle = poiCell.getCellStyle();
StringBuilder webStyle = new StringBuilder();
if (cellStyle != null) {
short fontIdx = cellStyle.getFontIndex();
Font font = wb.getFontAt(fontIdx);
if (font.getItalic()) {
webStyle.append("font-style: italic;");
}
if (font.getBold()) {
webStyle.append("font-weight: bold;");
}
webStyle.append(
"font-size: " + font.getFontHeightInPoints() + "pt;");
String decoration = getCellFontDecoration(font);
if (decoration.length() > 0) {
webStyle.append("text-decoration:" + decoration + ";");
}
webStyle.append(getCellFontColor(font));
}
return webStyle.toString();
} | java | {
"resource": ""
} |
q178808 | CellStyleUtility.getCellFontColor | test | private static String getCellFontColor(final Font font) {
short[] rgbfix = { TieConstants.RGB_MAX, TieConstants.RGB_MAX,
TieConstants.RGB_MAX };
if (font instanceof XSSFFont) {
XSSFColor color = ((XSSFFont) font).getXSSFColor();
if (color != null) {
rgbfix = ColorUtility.getTripletFromXSSFColor(color);
}
}
if (rgbfix[0] != TieConstants.RGB_MAX) {
return "color:rgb(" + FacesUtility.strJoin(rgbfix, ",") + ");";
}
return "";
} | java | {
"resource": ""
} |
q178809 | CellStyleUtility.getCellFontDecoration | test | private static String getCellFontDecoration(final Font font) {
StringBuilder decoration = new StringBuilder();
if (font.getUnderline() != 0) {
decoration.append(" underline");
}
if (font.getStrikeout()) {
decoration.append(" line-through");
}
return decoration.toString();
} | java | {
"resource": ""
} |
q178810 | CellStyleUtility.getCellStyle | test | public static String getCellStyle(final Workbook wb, final Cell poiCell,
final String inputType) {
CellStyle cellStyle = poiCell.getCellStyle();
StringBuilder webStyle = new StringBuilder();
if (cellStyle != null) {
if (!inputType.isEmpty()) {
webStyle.append(getAlignmentFromCell(poiCell, cellStyle));
webStyle.append(getVerticalAlignmentFromCell(cellStyle));
}
webStyle.append(ColorUtility.getBgColorFromCell(wb, poiCell,
cellStyle));
}
return webStyle.toString();
} | java | {
"resource": ""
} |
q178811 | CellStyleUtility.getColumnStyle | test | public static String getColumnStyle(final Workbook wb,
final FacesCell fcell, final Cell poiCell,
final float rowHeight) {
String inputType = fcell.getInputType();
CellStyle cellStyle = poiCell.getCellStyle();
StringBuilder webStyle = new StringBuilder();
if (cellStyle != null) {
if (fcell.isContainPic() || fcell.isContainChart()) {
webStyle.append("vertical-align: top;");
} else {
webStyle.append(getAlignmentFromCell(poiCell, cellStyle));
webStyle.append(getVerticalAlignmentFromCell(cellStyle));
}
webStyle.append(ColorUtility.getBgColorFromCell(wb, poiCell,
cellStyle));
webStyle.append(getRowStyle(wb, poiCell, inputType, rowHeight,
fcell.getRowspan()));
} else {
webStyle.append(getAlignmentFromCellType(poiCell));
}
return webStyle.toString();
} | java | {
"resource": ""
} |
q178812 | CellStyleUtility.getAlignmentFromCell | test | private static String getAlignmentFromCell(final Cell poiCell,
final CellStyle cellStyle) {
String style = "";
switch (cellStyle.getAlignmentEnum()) {
case LEFT:
style = TieConstants.TEXT_ALIGN_LEFT;
break;
case RIGHT:
style = TieConstants.TEXT_ALIGN_RIGHT;
break;
case CENTER:
style = TieConstants.TEXT_ALIGN_CENTER;
break;
case GENERAL:
style = getAlignmentFromCellType(poiCell);
break;
default:
break;
}
return style;
} | java | {
"resource": ""
} |
q178813 | CellStyleUtility.getVerticalAlignmentFromCell | test | private static String getVerticalAlignmentFromCell(
final CellStyle cellStyle) {
String style = "";
switch (cellStyle.getVerticalAlignmentEnum()) {
case TOP:
style = TieConstants.VERTICAL_ALIGN_TOP;
break;
case CENTER:
style = TieConstants.VERTICAL_ALIGN_CENTER;
break;
case BOTTOM:
style = TieConstants.VERTICAL_ALIGN_BOTTOM;
break;
default:
break;
}
return style;
} | java | {
"resource": ""
} |
q178814 | CellStyleUtility.calcTotalHeight | test | public static int calcTotalHeight(final Sheet sheet1,
final int firstRow, final int lastRow,
final int additionalHeight) {
int totalHeight = additionalHeight;
for (int i = firstRow; i <= lastRow; i++) {
totalHeight += sheet1.getRow(i).getHeight();
}
return totalHeight;
} | java | {
"resource": ""
} |
q178815 | CellStyleUtility.setupCellStyle | test | public static void setupCellStyle(final Workbook wb,
final FacesCell fcell, final Cell poiCell,
final float rowHeight) {
CellStyle cellStyle = poiCell.getCellStyle();
if ((cellStyle != null) && (!cellStyle.getLocked())) {
// not locked
if (fcell.getInputType().isEmpty()) {
fcell.setInputType(
CellStyleUtility.getInputTypeFromCellType(poiCell));
}
if (fcell.getControl().isEmpty()
&& (!fcell.getInputType().isEmpty())) {
fcell.setControl("text");
}
setInputStyleBaseOnInputType(fcell, poiCell);
}
String webStyle = getCellStyle(wb, poiCell, fcell.getInputType())
+ getCellFontStyle(wb, poiCell)
+ getRowStyle(wb, poiCell, fcell.getInputType(), rowHeight,
fcell.getRowspan());
fcell.setStyle(webStyle);
fcell.setColumnStyle(getColumnStyle(wb, fcell, poiCell, rowHeight));
} | java | {
"resource": ""
} |
q178816 | CellStyleUtility.getInputTypeFromCellType | test | @SuppressWarnings("deprecation")
private static String getInputTypeFromCellType(final Cell cell) {
String inputType = TieConstants.CELL_INPUT_TYPE_TEXT;
if (cell.getCellTypeEnum() == CellType.NUMERIC) {
inputType = TieConstants.CELL_INPUT_TYPE_DOUBLE;
}
CellStyle style = cell.getCellStyle();
if (style != null) {
int formatIndex = style.getDataFormat();
String formatString = style.getDataFormatString();
if (DateUtil.isADateFormat(formatIndex, formatString)) {
inputType = TieConstants.CELL_INPUT_TYPE_DATE;
} else {
if (isAPercentageCell(formatString)) {
inputType = TieConstants.CELL_INPUT_TYPE_PERCENTAGE;
}
}
}
return inputType;
} | java | {
"resource": ""
} |
q178817 | FacesUtility.getResourcePaths | test | public static Set<String> getResourcePaths(final FacesContext context,
final String path) {
return context.getExternalContext().getResourcePaths(path);
} | java | {
"resource": ""
} |
q178818 | FacesUtility.getResourceAsStream | test | public static InputStream getResourceAsStream(
final FacesContext context, final String path) {
return context.getExternalContext().getResourceAsStream(path);
} | java | {
"resource": ""
} |
q178819 | FacesUtility.removePrefixPath | test | public static String removePrefixPath(final String prefix,
final String resource) {
String normalizedResource = resource;
if (normalizedResource.startsWith(prefix)) {
normalizedResource = normalizedResource
.substring(prefix.length() - 1);
}
return normalizedResource;
} | java | {
"resource": ""
} |
q178820 | FacesUtility.evalInputType | test | public static boolean evalInputType(final String input,
final String type) {
Scanner scanner = new Scanner(input);
boolean ireturn = false;
if ("Integer".equalsIgnoreCase(type)) {
ireturn = scanner.hasNextInt();
} else if ("Double".equalsIgnoreCase(type)) {
ireturn = scanner.hasNextDouble();
} else if ("Boolean".equalsIgnoreCase(type)) {
ireturn = scanner.hasNextBoolean();
} else if ("Byte".equalsIgnoreCase(type)) {
ireturn = scanner.hasNextByte();
} else if (type.toLowerCase().startsWith("text")) {
ireturn = true;
}
scanner.close();
return ireturn;
} | java | {
"resource": ""
} |
q178821 | FacesUtility.findBean | test | @SuppressWarnings("unchecked")
public static <T> T findBean(final String beanName) {
FacesContext context = FacesContext.getCurrentInstance();
return (T) context.getApplication().evaluateExpressionGet(context,
TieConstants.EL_START + beanName + TieConstants.EL_END,
Object.class);
} | java | {
"resource": ""
} |
q178822 | FacesUtility.strJoin | test | public static String strJoin(final short[] aArr, final String sSep) {
StringBuilder sbStr = new StringBuilder();
for (int i = 0, il = aArr.length; i < il; i++) {
if (i > 0) {
sbStr.append(sSep);
}
sbStr.append(aArr[i]);
}
return sbStr.toString();
} | java | {
"resource": ""
} |
q178823 | FacesUtility.round | test | public static double round(final double value, final int places) {
if (places < 0) {
throw new IllegalArgumentException();
}
BigDecimal bd = BigDecimal.valueOf(value);
bd = bd.setScale(places, RoundingMode.HALF_UP);
return bd.doubleValue();
} | java | {
"resource": ""
} |
q178824 | TieWebSheetView.getTabType | test | public String getTabType() {
int sheetId = webFormTabView.getActiveIndex();
if ((sheetId >= 0) && (tabs != null)) {
if (sheetId >= tabs.size()) {
sheetId = 0;
}
tabType = tabs.get(sheetId).type.toLowerCase();
} else {
tabType = TieConstants.TAB_TYPE_NONE;
}
return tabType;
} | java | {
"resource": ""
} |
q178825 | TieWebSheetView.getTabStyle | test | public String getTabStyle() {
String tabStyle = TieConstants.TAB_STYLE_VISIBLE;
int sheetId = webFormTabView.getActiveIndex();
if ((sheetId >= 0) && (sheetId < tabs.size())) {
tabStyle = TieConstants.TAB_STYLE_INVISIBLE;
}
return tabStyle;
} | java | {
"resource": ""
} |
q178826 | TieWebSheetView.getDefaultDatePattern | test | public String getDefaultDatePattern() {
if (defaultDatePattern == null) {
DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
defaultDatePattern = ((SimpleDateFormat) formatter).toLocalizedPattern();
}
return defaultDatePattern;
} | java | {
"resource": ""
} |
q178827 | TieWebSheetView.getDecimalSeparatorByDefaultLocale | test | public String getDecimalSeparatorByDefaultLocale() {
final DecimalFormat nf = (DecimalFormat) DecimalFormat.getInstance(getDefaultLocale());
return "" + nf.getDecimalFormatSymbols().getDecimalSeparator();
} | java | {
"resource": ""
} |
q178828 | TieWebSheetView.getThousandSeparatorByDefaultLocale | test | public String getThousandSeparatorByDefaultLocale() {
final DecimalFormat nf = (DecimalFormat) DecimalFormat.getInstance(getDefaultLocale());
return "" + nf.getDecimalFormatSymbols().getGroupingSeparator();
} | java | {
"resource": ""
} |
q178829 | TieWebSheetView.setTieCommandAliasList | test | public void setTieCommandAliasList(String aliasListJson) {
Gson gson = new Gson();
Type aliasListType = new TypeToken<ArrayList<TieCommandAlias>>(){}.getType();
this.tieCommandAliasList = gson.fromJson(aliasListJson, aliasListType);
} | java | {
"resource": ""
} |
q178830 | FormCommand.buildFormWatchList | test | private List<Integer> buildFormWatchList(
final XSSFEvaluationWorkbook wbWrapper, final Sheet sheet) {
List<Integer> watchList = new ArrayList<>();
ConfigRange cRange = this.getConfigRange();
List<ConfigCommand> commandList = cRange.getCommandList();
if (commandList.isEmpty()) {
// if no command then no dynamic changes. then no need formula
// shifts.
return watchList;
}
int lastStaticRow = commandList.get(0).getTopRow() - 1;
if (lastStaticRow < 0) {
lastStaticRow = this.getTopRow();
}
int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet);
for (int i = this.getTopRow(); i <= this.getLastRow(); i++) {
Row row = sheet.getRow(i);
for (Cell cell : row) {
if (cell.getCellTypeEnum() == CellType.FORMULA) {
buildWatchListForCell(wbWrapper, sheetIndex, cell,
watchList, lastStaticRow);
}
}
}
return watchList;
} | java | {
"resource": ""
} |
q178831 | FormCommand.buildWatchListForCell | test | private void buildWatchListForCell(
final XSSFEvaluationWorkbook wbWrapper, final int sheetIndex,
final Cell cell, final List<Integer> watchList, final int lastStaticRow) {
String formula = cell.getCellFormula();
Ptg[] ptgs = FormulaParser.parse(formula, wbWrapper,
FormulaType.CELL, sheetIndex);
for (int k = 0; k < ptgs.length; k++) {
Object ptg = ptgs[k];
// For area formula, only first row is watched.
// Reason is the lastRow must shift same rows with
// firstRow.
// Otherwise it's difficult to calculate.
// In case some situation cannot fit, then should make
// change to the formula.
int areaInt = ShiftFormulaUtility
.getFirstSupportedRowNumFromPtg(ptg);
if (areaInt >= 0) {
addToWatchList(areaInt, lastStaticRow, watchList);
}
}
// when insert row, the formula may changed. so here is the
// workaround.
// change formula to user formula to preserve the row
// changes.
cell.setCellType(CellType.STRING);
cell.setCellValue(TieConstants.USER_FORMULA_PREFIX + formula
+ TieConstants.USER_FORMULA_SUFFIX);
} | java | {
"resource": ""
} |
q178832 | FormCommand.addToWatchList | test | private void addToWatchList(final int addRow, final int lastStaticRow,
final List<Integer> watchList) {
if ((addRow > lastStaticRow) && !(watchList.contains(addRow))) {
watchList.add(addRow);
}
} | java | {
"resource": ""
} |
q178833 | ParserUtility.isCommandString | test | public static boolean isCommandString(final String str) {
if (str == null) {
return false;
}
return str.startsWith(TieConstants.COMMAND_PREFIX);
} | java | {
"resource": ""
} |
q178834 | ParserUtility.parseWidgetAttributes | test | public static void parseWidgetAttributes(final Cell cell,
final String newComment,
final CellAttributesMap cellAttributesMap) {
if ((newComment == null) || (newComment.isEmpty())) {
return;
}
int widgetStart = newComment
.indexOf(TieConstants.METHOD_WIDGET_PREFIX);
int elStart = newComment.indexOf(TieConstants.EL_START_BRACKET);
if ((widgetStart < 0) || (widgetStart >= elStart)) {
return;
}
String type = newComment.substring(
widgetStart + TieConstants.METHOD_WIDGET_PREFIX.length(),
elStart);
String values = getStringBetweenBracket(newComment);
if (values == null) {
return;
}
// map's key is sheetName!$columnIndex$rowIndex
String key = getAttributeKeyInMapByCell(cell);
// one cell only has one control widget
cellAttributesMap.getCellInputType().put(key, type);
List<CellFormAttributes> inputs = cellAttributesMap
.getCellInputAttributes().get(key);
if (inputs == null) {
inputs = new ArrayList<>();
cellAttributesMap.getCellInputAttributes().put(key, inputs);
}
parseInputAttributes(inputs, values);
parseSpecialAttributes(key, type, inputs, cellAttributesMap);
} | java | {
"resource": ""
} |
q178835 | ParserUtility.getAttributeKeyInMapByCell | test | public static String getAttributeKeyInMapByCell(final Cell cell) {
if (cell == null) {
return null;
}
// map's key is sheetName!$columnIndex$rowIndex
return cell.getSheet().getSheetName() + "!"
+ CellUtility.getCellIndexNumberKey(cell);
} | java | {
"resource": ""
} |
q178836 | ParserUtility.parseValidateAttributes | test | public static void parseValidateAttributes(final Cell cell,
final String newComment,
final CellAttributesMap cellAttributesMap) {
if ((newComment == null) || (newComment.isEmpty())) {
return;
}
if (!newComment.startsWith(TieConstants.METHOD_VALIDATE_PREFIX)) {
return;
}
String values = getStringBetweenBracket(newComment);
if (values == null) {
return;
}
// map's key is sheetName!$columnIndex$rowIndex
String key = getAttributeKeyInMapByCell(cell);
List<CellFormAttributes> attrs = cellAttributesMap
.getCellValidateAttributes().get(key);
if (attrs == null) {
attrs = new ArrayList<>();
cellAttributesMap.getCellValidateAttributes().put(key, attrs);
}
parseValidateAttributes(attrs, values);
} | java | {
"resource": ""
} |
q178837 | ParserUtility.findPairBracketPosition | test | private static int findPairBracketPosition(final String str, final int startPos) {
int bracketNum = 0;
for (int i = startPos; i < str.length(); i++)
{
char current = str.charAt(i);
if (current == TieConstants.EL_START_BRACKET)
{
bracketNum++;
} else if (current == TieConstants.EL_END )
{
bracketNum--;
if (bracketNum <=0 ) {
return i;
}
}
}
return -1;
} | java | {
"resource": ""
} |
q178838 | ParserUtility.parseCommandAttributes | test | public static Map<String, String> parseCommandAttributes(
final String attrString) {
Map<String, String> attrMap = new LinkedHashMap<>();
Matcher attrMatcher = TieConstants.ATTR_REGEX_PATTERN
.matcher(attrString);
while (attrMatcher.find()) {
String attrData = attrMatcher.group();
int attrNameEndIndex = attrData.indexOf('=');
String attrName = attrData.substring(0, attrNameEndIndex)
.trim();
String attrValuePart = attrData.substring(attrNameEndIndex + 1)
.trim();
String attrValue = attrValuePart.substring(1,
attrValuePart.length() - 1);
attrMap.put(attrName, attrValue);
}
return attrMap;
} | java | {
"resource": ""
} |
q178839 | ParserUtility.parseInputAttributes | test | public static void parseInputAttributes(
final List<CellFormAttributes> clist,
final String controlAttrs) {
// only one type control allowed for one cell.
clist.clear();
if (controlAttrs != null) {
String[] cattrs = controlAttrs.split(
TieConstants.SPLIT_SPACE_SEPERATE_ATTRS_REGX, -1);
for (String cattr : cattrs) {
String[] details = splitByEualSign(cattr);
if (details.length > 1) {
CellFormAttributes attr = new CellFormAttributes();
attr.setType(details[0].trim());
attr.setValue(details[1].replaceAll("\"", ""));
clist.add(attr);
}
}
}
} | java | {
"resource": ""
} |
q178840 | ParserUtility.parseValidateAttributes | test | public static void parseValidateAttributes(
final List<CellFormAttributes> clist,
final String controlAttrs) {
// one cell could have multiple validation rules.
if (controlAttrs == null) {
return;
}
String[] cattrs = controlAttrs
.split(TieConstants.SPLIT_SPACE_SEPERATE_ATTRS_REGX, -1);
CellFormAttributes attr = new CellFormAttributes();
for (String cattr : cattrs) {
extractValidationAttributes(attr, cattr);
}
if ((attr.getValue() != null) && (!attr.getValue().isEmpty())) {
clist.add(attr);
}
} | java | {
"resource": ""
} |
q178841 | ParserUtility.splitByEualSign | test | private static String[] splitByEualSign(final String attrData) {
int attrNameEndIndex = attrData.indexOf('=');
if (attrNameEndIndex < 0) {
return new String[0];
}
String attrName = attrData.substring(0, attrNameEndIndex).trim();
String attrValue = attrData.substring(attrNameEndIndex + 1).trim();
String[] rlist = new String[2];
rlist[0] = attrName;
rlist[1] = attrValue;
return rlist;
} | java | {
"resource": ""
} |
q178842 | ParserUtility.parseSpecialAttributes | test | public static void parseSpecialAttributes(final String key,
final String type, final List<CellFormAttributes> inputs,
final CellAttributesMap cellAttributesMap) {
SpecialAttributes sAttr = new SpecialAttributes();
for (CellFormAttributes attr : inputs) {
gatherSpecialAttributes(type, sAttr, attr);
}
if (sAttr.selectLabels != null) {
processSelectItemAttributes(key, cellAttributesMap, sAttr);
}
if (type.equalsIgnoreCase(TieConstants.WIDGET_CALENDAR)) {
processCalendarAttributes(key, cellAttributesMap, sAttr);
}
} | java | {
"resource": ""
} |
q178843 | ParserUtility.processCalendarAttributes | test | private static void processCalendarAttributes(final String key,
final CellAttributesMap cellAttributesMap,
final SpecialAttributes sAttr) {
cellAttributesMap.getCellDatePattern().put(key,
sAttr.defaultDatePattern);
} | java | {
"resource": ""
} |
q178844 | ParserUtility.processSelectItemAttributes | test | private static void processSelectItemAttributes(final String key,
final CellAttributesMap cellAttributesMap,
final SpecialAttributes sAttr) {
if ((sAttr.selectValues == null)
|| (sAttr.selectValues.length != sAttr.selectLabels.length)) {
sAttr.selectValues = sAttr.selectLabels;
}
Map<String, String> smap = cellAttributesMap
.getCellSelectItemsAttributes().get(key);
if (smap == null) {
smap = new LinkedHashMap<>();
}
smap.clear();
if (sAttr.defaultSelectLabel != null) {
smap.put(sAttr.defaultSelectLabel, sAttr.defaultSelectValue);
}
for (int i = 0; i < sAttr.selectLabels.length; i++) {
smap.put(sAttr.selectLabels[i], sAttr.selectValues[i]);
}
cellAttributesMap.getCellSelectItemsAttributes().put(key, smap);
} | java | {
"resource": ""
} |
q178845 | ParserUtility.gatherSpecialAttributes | test | private static void gatherSpecialAttributes(final String type,
final SpecialAttributes sAttr, final CellFormAttributes attr) {
String attrKey = attr.getType();
if (attrKey.equalsIgnoreCase(TieConstants.SELECT_ITEM_LABELS)) {
sAttr.selectLabels = attr.getValue().split(";");
}
if (attrKey.equalsIgnoreCase(TieConstants.SELECT_ITEM_VALUES)) {
sAttr.selectValues = attr.getValue().split(";");
}
if (attrKey.equalsIgnoreCase(
TieConstants.DEFAULT_SELECT_ITEM_LABEL)) {
sAttr.defaultSelectLabel = attr.getValue();
}
if (attrKey.equalsIgnoreCase(
TieConstants.DEFAULT_SELECT_ITEM_VALUE)) {
sAttr.defaultSelectValue = attr.getValue();
}
if (type.equalsIgnoreCase(TieConstants.WIDGET_CALENDAR)
&& attrKey.equalsIgnoreCase(
TieConstants.WIDGET_ATTR_PATTERN)) {
sAttr.defaultDatePattern = attr.getValue();
}
} | java | {
"resource": ""
} |
q178846 | ParserUtility.parseCommentToMap | test | public static void parseCommentToMap(final String cellKey,
final String newComment,
final Map<String, Map<String, String>> sheetCommentMap,
final boolean normalComment) {
if ((newComment != null) && (!newComment.trim().isEmpty())) {
// normal comment key is $$
String commentKey = TieConstants.NORMAL_COMMENT_KEY_IN_MAP;
if (!normalComment) {
// not normal comment. e.g. ${... or $init{... or
// key = $ or key = $init
commentKey = newComment.substring(0,
newComment.indexOf(TieConstants.EL_START_BRACKET));
}
Map<String, String> map = sheetCommentMap.get(commentKey);
if (map == null) {
map = new HashMap<>();
}
// inner map's key is sheetName!$columnIndex$rowIndex
map.put(cellKey, newComment);
sheetCommentMap.put(commentKey, map);
}
} | java | {
"resource": ""
} |
q178847 | ParserUtility.findFirstNonCellNamePosition | test | public static int findFirstNonCellNamePosition(String input, int startPosition) {
char c;
for (int i = startPosition; i < input.length(); i++) {
c = input.charAt(i);
if ( c!='$' && !Character.isLetterOrDigit(c)) {
return i;
}
}
return -1; // not found
} | java | {
"resource": ""
} |
q178848 | ParserUtility.removeCharsFromString | test | public static String removeCharsFromString(String inputStr, int start, int end) {
StringBuilder sb = new StringBuilder(inputStr);
sb.delete(start, end);
// if ((start > 0) && (inputStr.charAt(start - 1) ==' ')) {
// // if end with a space, then remove it as well.
// sb.deleteCharAt(start - 1);
// }
return sb.toString();
} | java | {
"resource": ""
} |
q178849 | WebSheetUtility.getExcelColumnName | test | public static String getExcelColumnName(final int pnumber) {
StringBuilder converted = new StringBuilder();
// Repeatedly divide the number by 26 and convert the
// remainder into the appropriate letter.
int number = pnumber;
while (number >= 0) {
int remainder = number % TieConstants.EXCEL_LETTER_NUMBERS;
converted.insert(0, (char) (remainder + 'A'));
number = (number / TieConstants.EXCEL_LETTER_NUMBERS) - 1;
}
return converted.toString();
} | java | {
"resource": ""
} |
q178850 | WebSheetUtility.convertColToInt | test | public static int convertColToInt(final String col) {
String name = col.toUpperCase();
int number = 0;
int pow = 1;
for (int i = name.length() - 1; i >= 0; i--) {
number += (name.charAt(i) - 'A' + 1) * pow;
pow *= TieConstants.EXCEL_LETTER_NUMBERS;
}
return number - 1;
} | java | {
"resource": ""
} |
q178851 | WebSheetUtility.getCellByReference | test | public static Cell getCellByReference(final String cellRef,
final Sheet sheet) {
Cell c = null;
try {
CellReference ref = new CellReference(cellRef);
Row r = sheet.getRow(ref.getRow());
if (r != null) {
c = r.getCell(ref.getCol(),
MissingCellPolicy.CREATE_NULL_AS_BLANK);
}
} catch (Exception ex) {
// use log.debug because mostly it's expected
LOG.log(Level.SEVERE,
"WebForm WebFormHelper getCellByReference cellRef = "
+ cellRef + "; error = "
+ ex.getLocalizedMessage(),
ex);
}
return c;
} | java | {
"resource": ""
} |
q178852 | WebSheetUtility.heightUnits2Pixel | test | public static int heightUnits2Pixel(final short heightUnits) {
int pixels = heightUnits / EXCEL_ROW_HEIGHT_FACTOR;
int offsetHeightUnits = heightUnits % EXCEL_ROW_HEIGHT_FACTOR;
pixels += Math.round((float) offsetHeightUnits
/ ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH
/ 2));
pixels += (Math.floor(pixels / PIXEL_HEIGHT_ASPC_ADJUST) + 1) * 4;
return pixels;
} | java | {
"resource": ""
} |
q178853 | WebSheetUtility.isDate | test | public static boolean isDate(final String s) {
Pattern pattern = Pattern.compile(DATE_REGEX_4_DIGIT_YEAR);
String[] terms = s.split(" ");
Matcher matcher;
for (String term : terms) {
matcher = pattern.matcher(term);
if (matcher.matches()) {
return true;
}
}
pattern = Pattern.compile(DATE_REGEX_2_DIGIT_YEAR);
terms = s.split(" ");
for (String term : terms) {
matcher = pattern.matcher(term);
if (matcher.matches()) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q178854 | WebSheetUtility.parseDate | test | public static String parseDate(final String entry) {
Pattern pattern = Pattern.compile(DATE_REGEX_4_DIGIT_YEAR);
String[] terms = entry.split(" ");
Matcher matcher;
for (String term : terms) {
matcher = pattern.matcher(term);
if (matcher.matches()) {
return matcher.group();
}
}
pattern = Pattern.compile(DATE_REGEX_2_DIGIT_YEAR);
terms = entry.split(" ");
for (String term : terms) {
matcher = pattern.matcher(term);
if (matcher.matches()) {
return matcher.group();
}
}
return "";
} | java | {
"resource": ""
} |
q178855 | WebSheetUtility.isNumeric | test | public static boolean isNumeric(final String str) {
String s = str;
if (s.startsWith("-")) {
s = s.substring(1);
}
char c;
int i;
int sLen = s.length();
ShouldContinueParameter sPara = new ShouldContinueParameter(false,
false, 0);
for (i = 0; i < sLen; i++) {
c = s.charAt(i);
if (c < '0' || c > '9') {
if (!shouldContinue(c, sPara)) {
return false;
}
} else {
if (sPara.isCommaHit()) {
sPara.setSinceLastComma(sPara.getSinceLastComma() + 1);
}
}
}
return true;
} | java | {
"resource": ""
} |
q178856 | WebSheetUtility.shouldContinue | test | private static boolean shouldContinue(final char c,
final ShouldContinueParameter para) {
if (c == '.' && !para.isDecimalHit()) {
para.setDecimalHit(true);
if (para.isCommaHit() && para.getSinceLastComma() != 3) {
return false;
}
return true;
} else if (c == ',' && !para.isDecimalHit()) {
if (para.isCommaHit()) {
if (para.getSinceLastComma() != 3) {
return false;
}
para.setSinceLastComma(0);
}
para.setCommaHit(true);
return true;
}
return false;
} | java | {
"resource": ""
} |
q178857 | WebSheetUtility.setObjectProperty | test | public static void setObjectProperty(final Object obj,
final String propertyName, final String propertyValue,
final boolean ignoreNonExisting) {
try {
Method method = obj.getClass().getMethod(
"set" + Character.toUpperCase(propertyName.charAt(0))
+ propertyName.substring(1),
new Class[] { String.class });
method.invoke(obj, propertyValue);
} catch (Exception e) {
String msg = "failed to set property '" + propertyName
+ "' to value '" + propertyValue + "' for object "
+ obj;
if (ignoreNonExisting) {
LOG.info(msg);
} else {
LOG.warning(msg);
throw new IllegalArgumentException(e);
}
}
} | java | {
"resource": ""
} |
q178858 | WebSheetUtility.cellCompareTo | test | public static int cellCompareTo(final Cell thisCell,
final Cell otherCell) {
int r = thisCell.getRowIndex() - otherCell.getRowIndex();
if (r != 0) {
return r;
}
r = thisCell.getColumnIndex() - otherCell.getColumnIndex();
if (r != 0) {
return r;
}
return 0;
} | java | {
"resource": ""
} |
q178859 | WebSheetUtility.insideRange | test | public static boolean insideRange(final ConfigRange child,
final ConfigRange parent) {
return ((cellCompareTo(child.getFirstRowRef(),
parent.getFirstRowRef()) >= 0)
&& (cellCompareTo(child.getLastRowPlusRef(),
parent.getLastRowPlusRef()) <= 0));
} | java | {
"resource": ""
} |
q178860 | WebSheetUtility.clearHiddenColumns | test | public static void clearHiddenColumns(final Sheet sheet) {
for (Row row : sheet) {
if (row.getLastCellNum() > TieConstants.MAX_COLUMNS_IN_SHEET) {
deleteHiddenColumnsInRow(row);
}
}
} | java | {
"resource": ""
} |
q178861 | WebSheetUtility.deleteHiddenColumnsInRow | test | private static void deleteHiddenColumnsInRow(final Row row) {
deleteCellFromRow(row,
TieConstants.HIDDEN_SAVE_OBJECTS_COLUMN);
deleteCellFromRow(row,
TieConstants.HIDDEN_ORIGIN_ROW_NUMBER_COLUMN);
deleteCellFromRow(row,
TieConstants.HIDDEN_FULL_NAME_COLUMN);
} | java | {
"resource": ""
} |
q178862 | WebSheetUtility.deleteCellFromRow | test | private static void deleteCellFromRow(final Row row,
final int cellNum) {
Cell cell = row.getCell(cellNum);
if (cell != null) {
row.removeCell(cell);
}
} | java | {
"resource": ""
} |
q178863 | PostConstructApplicationEventListener.processEvent | test | @Override
public final void processEvent(final SystemEvent event) {
LOGGER.log(Level.INFO, "Running on TieFaces {0}",
AppUtils.getBuildVersion());
} | java | {
"resource": ""
} |
q178864 | ValidationHandler.refreshAfterStatusChanged | test | private void refreshAfterStatusChanged(final boolean oldStatus, final boolean newStatus, final int formRow,
final int formCol, final FacesCell cell, final boolean updateGui) {
if (!newStatus) {
cell.setErrormsg("");
}
cell.setInvalid(newStatus);
if (updateGui && (oldStatus != newStatus) && (parent.getWebFormClientId() != null)) {
RequestContext.getCurrentInstance()
.update(parent.getWebFormClientId() + ":" + (formRow) + ":group" + (formCol));
}
} | java | {
"resource": ""
} |
q178865 | ValidationHandler.validateWithRowColInCurrentPage | test | public boolean validateWithRowColInCurrentPage(final int row, final int col, boolean updateGui) {
//until now passEmptyCheck has one to one relation to submitMode
//e.g. when passEmptyCheck = false, then submitMode = true.
boolean submitMode = parent.getSubmitMode();
boolean passEmptyCheck = !submitMode;
int topRow = parent.getCurrent().getCurrentTopRow();
int leftCol = parent.getCurrent().getCurrentLeftColumn();
boolean pass = true;
FacesRow fRow = CellUtility.getFacesRowFromBodyRow(row, parent.getBodyRows(), topRow);
if (fRow == null) {
return pass;
}
FacesCell cell = CellUtility.getFacesCellFromBodyRow(row, col, parent.getBodyRows(), topRow, leftCol);
if (cell == null) {
return pass;
}
Cell poiCell = parent.getCellHelper().getPoiCellWithRowColFromCurrentPage(row, col);
boolean oldStatus = cell.isInvalid();
String value = CellUtility.getCellValueWithoutFormat(poiCell);
if (value == null) {
value = "";
} else {
value = value.trim();
}
if (passEmptyCheck && value.isEmpty()) {
refreshAfterStatusChanged(oldStatus, false, row - topRow, col - leftCol, cell, updateGui);
return pass;
}
if (((parent.isOnlyValidateInSubmitMode() && submitMode ) || !parent.isOnlyValidateInSubmitMode())
&& !validateByTieWebSheetValidationBean(poiCell, topRow, leftCol, cell, value, updateGui)) {
return false;
}
SheetConfiguration sheetConfig = parent.getSheetConfigMap().get(parent.getCurrent().getCurrentTabName());
List<CellFormAttributes> cellAttributes = CellControlsUtility.findCellValidateAttributes(
parent.getCellAttributesMap().getCellValidateAttributes(), fRow.getOriginRowIndex(), poiCell);
if (parent.isAdvancedContext() && parent.getConfigAdvancedContext().getErrorSuffix() != null
&& !checkErrorMessageFromObjectInContext(row - topRow, col - leftCol, cell, poiCell, value,
sheetConfig, updateGui)) {
return false;
}
if (cellAttributes != null) {
pass = validateAllRulesForSingleCell(row - topRow, col - leftCol, cell, poiCell, value, sheetConfig,
cellAttributes, updateGui);
}
if (pass) {
refreshAfterStatusChanged(oldStatus, false, row - topRow, col - leftCol, cell, updateGui);
}
return pass;
} | java | {
"resource": ""
} |
q178866 | ValidationHandler.validateByTieWebSheetValidationBean | test | private boolean validateByTieWebSheetValidationBean(final Cell poiCell, final int topRow, final int leftCol,
final FacesCell cell, final String value, boolean updateGui) {
if (parent.getTieWebSheetValidationBean() != null) {
String errormsg = null;
String fullName = ConfigurationUtility.getFullNameFromRow(poiCell.getRow());
String saveAttr = SaveAttrsUtility.prepareContextAndAttrsForCell(poiCell, fullName, parent.getCellHelper());
if (saveAttr != null) {
int row = poiCell.getRowIndex();
int col = poiCell.getColumnIndex();
errormsg = parent.getTieWebSheetValidationBean().validate(
parent.getSerialDataContext().getDataContext(), saveAttr, ConfigurationUtility
.getFullNameFromRow(poiCell.getRow()), poiCell.getSheet().getSheetName(),
row, col, value);
if ((errormsg != null) && (!errormsg.isEmpty())) {
cell.setErrormsg(errormsg);
refreshAfterStatusChanged(false, true, row - topRow, col - leftCol, cell, updateGui);
return false;
}
}
}
return true;
} | java | {
"resource": ""
} |
q178867 | ValidationHandler.checkErrorMessageFromObjectInContext | test | private boolean checkErrorMessageFromObjectInContext(final int formRow, final int formCol, final FacesCell cell,
final Cell poiCell, final String value, final SheetConfiguration sheetConfig, boolean updateGui) {
@SuppressWarnings("unchecked")
HashMap<String, TieCell> tieCells = (HashMap<String, TieCell>) parent.getSerialDataContext().getDataContext()
.get("tiecells");
if (tieCells != null) {
TieCell tieCell = tieCells.get(CellUtility.getSkeyFromPoiCell(poiCell));
if (tieCell != null && tieCell.getContextObject() != null) {
String errorMethod = tieCell.getMethodStr() + parent.getConfigAdvancedContext().getErrorSuffix();
String errorMessage = CellControlsUtility.getObjectPropertyValue(tieCell.getContextObject(),
errorMethod, true);
if (errorMessage != null && !errorMessage.isEmpty()) {
cell.setErrormsg(errorMessage);
LOG.log(Level.INFO, "Validation failed for sheet {0} row {1} column {2} : {3}",
new Object[] { poiCell.getSheet().getSheetName(), poiCell.getRowIndex(),
poiCell.getColumnIndex(), errorMessage });
refreshAfterStatusChanged(false, true, formRow, formCol, cell, updateGui);
return false;
}
}
}
return true;
} | java | {
"resource": ""
} |
q178868 | ValidationHandler.validateAllRulesForSingleCell | test | private boolean validateAllRulesForSingleCell(final int formRow, final int formCol, final FacesCell cell,
final Cell poiCell, final String value, final SheetConfiguration sheetConfig,
final List<CellFormAttributes> cellAttributes, boolean updateGui) {
Sheet sheet1 = parent.getWb().getSheet(sheetConfig.getSheetName());
for (CellFormAttributes attr : cellAttributes) {
boolean pass = doValidation(value, attr, poiCell.getRowIndex(), poiCell.getColumnIndex(), sheet1);
if (!pass) {
String errmsg = attr.getMessage();
if (errmsg == null) {
errmsg = TieConstants.DEFALT_MSG_INVALID_INPUT;
}
cell.setErrormsg(errmsg);
LOG.log(Level.INFO, "Validation failed for sheet {0} row {1} column {2} : {3}", new Object[] {
poiCell.getSheet().getSheetName(), poiCell.getRowIndex(), poiCell.getColumnIndex(), errmsg });
refreshAfterStatusChanged(false, true, formRow, formCol, cell, updateGui);
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q178869 | ValidationHandler.doValidation | test | private boolean doValidation(final Object value, final CellFormAttributes attr, final int rowIndex,
final int colIndex, final Sheet sheet) {
boolean pass;
String attrValue = attr.getValue();
attrValue = attrValue.replace("$value", value.toString() + "").replace("$rowIndex", rowIndex + "")
.replace("$colIndex", colIndex + "").replace("$sheetName", sheet.getSheetName());
attrValue = ConfigurationUtility.replaceExpressionWithCellValue(attrValue, rowIndex, sheet);
if (attrValue.contains(TieConstants.EL_START)) {
Object returnObj = FacesUtility.evaluateExpression(attrValue, Object.class);
attrValue = returnObj.toString();
pass = Boolean.parseBoolean(attrValue);
} else {
pass = parent.getCellHelper().evalBoolExpression(attrValue);
}
return pass;
} | java | {
"resource": ""
} |
q178870 | ValidationHandler.validateCell | test | public final boolean validateCell(final UIComponent target) {
int[] rowcol = CellUtility.getRowColFromComponentAttributes(target);
int row = rowcol[0];
int col = rowcol[1];
return validateWithRowColInCurrentPage(row, col, true);
} | java | {
"resource": ""
} |
q178871 | ValidationHandler.validateCurrentPage | test | public final boolean validateCurrentPage() {
boolean allpass = true;
int top = parent.getCurrent().getCurrentTopRow();
for (int irow = 0; irow < parent.getBodyRows().size(); irow++) {
if (!validateRowInCurrentPage(irow + top, false)) {
allpass = false;
}
}
return allpass;
} | java | {
"resource": ""
} |
q178872 | ValidationHandler.validateRowInCurrentPage | test | public final boolean validateRowInCurrentPage(final int irow, final boolean updateGui) {
SheetConfiguration sheetConfig = parent.getSheetConfigMap().get(parent.getCurrent().getCurrentTabName());
return this.validateRow(irow, sheetConfig, updateGui);
} | java | {
"resource": ""
} |
q178873 | ValidationHandler.validateRow | test | private boolean validateRow(final int irow, final SheetConfiguration sheetConfig, boolean updateGui) {
boolean pass = true;
if (sheetConfig == null) {
return pass;
}
int top = sheetConfig.getBodyCellRange().getTopRow();
List<FacesCell> cellRow = parent.getBodyRows().get(irow - top).getCells();
for (int index = 0; index < cellRow.size(); index++) {
FacesCell fcell = cellRow.get(index);
if ((fcell != null) && (!validateWithRowColInCurrentPage(irow, fcell.getColumnIndex(), updateGui))) {
pass = false;
}
}
return pass;
} | java | {
"resource": ""
} |
q178874 | ValidationHandler.refreshCachedCellsInCurrentPage | test | private void refreshCachedCellsInCurrentPage(final FacesContext facesContext, final String tblName) {
// refresh current page calculation fields
UIComponent s = facesContext.getViewRoot().findComponent(tblName);
if (s == null) {
return;
}
DataTable webDataTable = (DataTable) s;
int first = webDataTable.getFirst();
int rowsToRender = webDataTable.getRowsToRender();
int rowCounts = webDataTable.getRowCount();
int top = parent.getCurrent().getCurrentTopRow();
int left = parent.getCurrent().getCurrentLeftColumn();
for (int i = first; i <= (first + rowsToRender); i++) {
if (i < rowCounts) {
refreshCachedCellsInRow(tblName, top, left, i);
}
}
} | java | {
"resource": ""
} |
q178875 | ValidationHandler.refreshCachedCellsInRow | test | private void refreshCachedCellsInRow(final String tblName, final int top, final int left, final int i) {
FacesRow dataRow = parent.getBodyRows().get(i);
int isize = dataRow.getCells().size();
for (int index = 0; index < isize; index++) {
FacesCell fcell = dataRow.getCells().get(index);
Cell poiCell = parent.getCellHelper().getPoiCellWithRowColFromCurrentPage(i + top, index + left);
if (poiCell != null) {
parent.getHelper().getWebSheetLoader().refreshCachedCell(tblName, i, index, poiCell, fcell);
}
}
} | java | {
"resource": ""
} |
q178876 | ValidationHandler.setSubmitModeInView | test | public void setSubmitModeInView(final Boolean fullflag) {
if (FacesContext.getCurrentInstance() != null) {
Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();
if (viewMap != null) {
Boolean flag = (Boolean) viewMap.get(TieConstants.SUBMITMODE);
if ((flag == null) || (!flag.equals(fullflag))) {
viewMap.put(TieConstants.SUBMITMODE, fullflag);
}
}
}
} | java | {
"resource": ""
} |
q178877 | ValidationHandler.preValidation | test | public boolean preValidation() {
String currentTabName = parent.getCurrent().getCurrentTabName();
String tabName = null;
String firstInvalidTabName = null;
boolean reload = false;
for (Map.Entry<String, SheetConfiguration> entry : parent.getSheetConfigMap().entrySet()) {
tabName = entry.getKey();
// if not reload and tabname==current then skip reloading.
if (reload || (!tabName.equals(currentTabName))) {
parent.getWebSheetLoader().prepareWorkShee(tabName);
reload = true;
}
if (!parent.getValidationHandler().validateCurrentPage() &&
(firstInvalidTabName == null)) {
firstInvalidTabName = tabName;
}
}
if (firstInvalidTabName != null) {
if (!tabName.equals(firstInvalidTabName)) {
parent.getHelper().getWebSheetLoader().loadWorkSheet(firstInvalidTabName);
}
return false;
}
return true;
} | java | {
"resource": ""
} |
q178878 | CellAttributesMap.clear | test | public final void clear() {
if (this.templateCommentMap != null) {
this.templateCommentMap.clear();
}
if (this.cellDatePattern != null) {
this.cellDatePattern.clear();
}
if (this.cellInputAttributes != null) {
this.cellInputAttributes.clear();
}
if (this.cellInputType != null) {
this.cellInputType.clear();
}
if (this.cellSelectItemsAttributes != null) {
this.cellSelectItemsAttributes.clear();
}
} | java | {
"resource": ""
} |
q178879 | WebSheetLoader.loadHeaderRows | test | private void loadHeaderRows(final SheetConfiguration sheetConfig, final Map<String, CellRangeAddress> cellRangeMap,
final List<String> skippedRegionCells) {
int top = sheetConfig.getHeaderCellRange().getTopRow();
int bottom = sheetConfig.getHeaderCellRange().getBottomRow();
int left = sheetConfig.getHeaderCellRange().getLeftCol();
int right = sheetConfig.getHeaderCellRange().getRightCol();
String sheetName = sheetConfig.getSheetName();
Sheet sheet1 = parent.getWb().getSheet(sheetName);
int totalWidth = CellStyleUtility.calcTotalWidth(sheet1, left, right,
WebSheetUtility.pixel2WidthUnits(parent.getLineNumberColumnWidth() + parent.getAddRowColumnWidth()));
RangeBuildRef rangeBuildRef = new RangeBuildRef(left, right, totalWidth, sheet1);
if (sheetConfig.isFixedWidthStyle()) {
parent.setTableWidthStyle(
"table-layout: fixed; width:" + WebSheetUtility.widthUnits2Pixel(totalWidth) + "px;");
}
parent.setLineNumberColumnWidthStyle(
getWidthStyle(WebSheetUtility.pixel2WidthUnits(parent.getLineNumberColumnWidth()), totalWidth));
parent.setAddRowColumnWidthStyle("width:" + parent.getAddRowColumnWidth() + "px;");
parent.getHeaderRows().clear();
if (top < 0) {
// this is blank configuration. set column letter as header
parent.getHeaderRows().add(loadHeaderRowWithoutConfigurationTab(rangeBuildRef, true));
// set showlinenumber to true as default
parent.setShowLineNumber(true);
} else {
parent.getHeaderRows().add(loadHeaderRowWithoutConfigurationTab(rangeBuildRef, false));
for (int i = top; i <= bottom; i++) {
parent.getHeaderRows().add(loadHeaderRowWithConfigurationTab(sheetConfig, rangeBuildRef, i,
cellRangeMap, skippedRegionCells));
}
// set showlinenumber to false as default
parent.setShowLineNumber(false);
}
} | java | {
"resource": ""
} |
q178880 | WebSheetLoader.loadHeaderRowWithoutConfigurationTab | test | private List<HeaderCell> loadHeaderRowWithoutConfigurationTab(final RangeBuildRef rangeBuildRef,
final boolean rendered) {
int firstCol = rangeBuildRef.getLeft();
int lastCol = rangeBuildRef.getRight();
double totalWidth = (double) rangeBuildRef.getTotalWidth();
Sheet sheet1 = rangeBuildRef.getSheet();
List<HeaderCell> headercells = new ArrayList<>();
for (int i = firstCol; i <= lastCol; i++) {
if (!sheet1.isColumnHidden(i)) {
String style = getHeaderColumnStyle(parent.getWb(), null, sheet1.getColumnWidth(i), totalWidth);
headercells.add(
new HeaderCell("1", "1", style, style, WebSheetUtility.getExcelColumnName(i), rendered, true));
}
}
fillToMaxColumns(headercells);
return headercells;
} | java | {
"resource": ""
} |
q178881 | WebSheetLoader.fillToMaxColumns | test | private void fillToMaxColumns(final List<HeaderCell> headercells) {
if (headercells.size() < parent.getMaxColCounts()) {
int fills = parent.getMaxColCounts() - headercells.size();
for (int s = 0; s < fills; s++) {
headercells.add(new HeaderCell("1", "1", "", "", "", false, false));
}
}
} | java | {
"resource": ""
} |
q178882 | WebSheetLoader.getHeaderColumnStyle | test | private String getHeaderColumnStyle(final Workbook wb, final Cell cell, final double colWidth,
final double totalWidth) {
String columnstyle = "";
if (cell != null) {
columnstyle += CellStyleUtility.getCellStyle(wb, cell, "") + CellStyleUtility.getCellFontStyle(wb, cell); // +
}
columnstyle = columnstyle + getWidthStyle(colWidth, totalWidth);
return columnstyle;
} | java | {
"resource": ""
} |
q178883 | WebSheetLoader.getWidthStyle | test | private String getWidthStyle(final double colWidth, final double totalWidth) {
double percentage = FacesUtility.round(TieConstants.CELL_FORMAT_PERCENTAGE_VALUE * colWidth / totalWidth, 2);
return "width:" + percentage + TieConstants.CELL_FORMAT_PERCENTAGE_SYMBOL + ";";
} | java | {
"resource": ""
} |
q178884 | WebSheetLoader.loadHeaderRowWithConfigurationTab | test | private List<HeaderCell> loadHeaderRowWithConfigurationTab(final SheetConfiguration sheetConfig,
final RangeBuildRef rangeBuildRef, final int currentRow, final Map<String, CellRangeAddress> cellRangeMap,
final List<String> skippedRegionCells) {
Sheet sheet1 = rangeBuildRef.getSheet();
int left = rangeBuildRef.getLeft();
int right = rangeBuildRef.getRight();
double totalWidth = (double) rangeBuildRef.getTotalWidth();
Row row = sheet1.getRow(currentRow);
List<HeaderCell> headercells = new ArrayList<>();
for (int cindex = left; cindex <= right; cindex++) {
String cellindex = CellUtility.getCellIndexNumberKey(cindex, currentRow);
if (!skippedRegionCells.contains(cellindex) && !sheet1.isColumnHidden(cindex)) {
Cell cell = null;
if (row != null) {
cell = row.getCell(cindex, MissingCellPolicy.CREATE_NULL_AS_BLANK);
}
int originRowIndex = ConfigurationUtility.getOriginalRowNumInHiddenColumn(row);
if (cell != null) {
FacesCell fcell = new FacesCell();
CellUtility.convertCell(sheetConfig, fcell, cell, cellRangeMap, originRowIndex,
parent.getCellAttributesMap(), null);
parent.getPicHelper().setupFacesCellPictureCharts(sheet1, fcell, cell,
WebSheetUtility.getFullCellRefName(sheet1, cell));
CellStyleUtility.setupCellStyle(parent.getWb(), fcell, cell, row.getHeightInPoints());
fcell.setColumnStyle(fcell.getColumnStyle()
+ getColumnWidthStyle(sheet1, cellRangeMap, cellindex, cindex, totalWidth));
fcell.setColumnIndex(cindex);
headercells.add(
new HeaderCell(Integer.toString(fcell.getRowspan()), Integer.toString(fcell.getColspan()),
fcell.getStyle(), fcell.getColumnStyle(), CellUtility.getCellValueWithFormat(cell,
parent.getFormulaEvaluator(), parent.getDataFormatter()),
true, true));
}
}
}
fillToMaxColumns(headercells);
return headercells;
} | java | {
"resource": ""
} |
q178885 | WebSheetLoader.getColumnWidthStyle | test | private String getColumnWidthStyle(final Sheet sheet1, final Map<String, CellRangeAddress> cellRangeMap,
final String cellindex, final int cindex, final double totalWidth) {
CellRangeAddress caddress = cellRangeMap.get(cellindex);
double colWidth;
// check whether the cell has rowspan or colspan
if (caddress != null) {
colWidth = CellStyleUtility.calcTotalWidth(sheet1, caddress.getFirstColumn(), caddress.getLastColumn(), 0);
} else {
colWidth = sheet1.getColumnWidth(cindex);
}
return getWidthStyle(colWidth, totalWidth);
} | java | {
"resource": ""
} |
q178886 | WebSheetLoader.clearWorkbook | test | private void clearWorkbook() {
parent.setFormulaEvaluator(null);
parent.setDataFormatter(null);
parent.setSheetConfigMap(null);
parent.setTabs(null);
parent.getSerialDataContext().setDataContext(null);
parent.setPicturesMap(null);
parent.setHeaderRows(null);
parent.setBodyRows(null);
parent.setWb(null);
parent.getHeaderRows().clear();
parent.getBodyRows().clear();
parent.getCharsData().getChartsMap().clear();
parent.getCharsData().getChartDataMap().clear();
parent.getCharsData().getChartAnchorsMap().clear();
parent.getCharsData().getChartPositionMap().clear();
parent.getCellAttributesMap().clear();
} | java | {
"resource": ""
} |
q178887 | WebSheetLoader.initTabs | test | private void initTabs() {
parent.setTabs(new ArrayList<TabModel>());
if (parent.getSheetConfigMap() != null) {
for (String key : parent.getSheetConfigMap().keySet()) {
parent.getTabs().add(new TabModel("form_" + key, key, "form"));
}
}
} | java | {
"resource": ""
} |
q178888 | WebSheetLoader.loadData | test | private void loadData() {
if (parent.getSerialDataContext().getDataContext() == null) {
// no data objects available.
return;
}
if (parent.isAdvancedContext()) {
parent.getSerialDataContext().getDataContext().put("tiecells", new HashMap<String, TieCell>());
}
for (SheetConfiguration sheetConfig : parent.getSheetConfigMap().values()) {
List<RowsMapping> currentRowsMappingList = null;
ConfigBuildRef configBuildRef = new ConfigBuildRef(parent.getWbWrapper(),
parent.getWb().getSheet(sheetConfig.getSheetName()), parent.getExpEngine(), parent.getCellHelper(),
sheetConfig.getCachedCells(), parent.getCellAttributesMap(), sheetConfig.getFinalCommentMap());
int length = sheetConfig.getFormCommand().buildAt(null, configBuildRef,
sheetConfig.getFormCommand().getTopRow(), parent.getSerialDataContext().getDataContext(),
currentRowsMappingList);
sheetConfig.setShiftMap(configBuildRef.getShiftMap());
sheetConfig.setCollectionObjNameMap(configBuildRef.getCollectionObjNameMap());
sheetConfig.setCommandIndexMap(configBuildRef.getCommandIndexMap());
sheetConfig.setWatchList(configBuildRef.getWatchList());
sheetConfig.setBodyAllowAddRows(configBuildRef.isBodyAllowAdd());
sheetConfig.getBodyCellRange().setBottomRow(sheetConfig.getFormCommand().getTopRow() + length - 1);
sheetConfig.setBodyPopulated(true);
}
parent.getCellHelper().reCalc();
} | java | {
"resource": ""
} |
q178889 | WebSheetLoader.refreshData | test | public void refreshData() {
if (parent.getSerialDataContext().getDataContext() == null) {
// no data objects available.
return;
}
for (SheetConfiguration sheetConfig : parent.getSheetConfigMap().values()) {
for (int irow = sheetConfig.getFormCommand().getTopRow(); irow < sheetConfig.getFormCommand()
.getLastRow(); irow++) {
refreshDataForRow(parent.getWb().getSheet(sheetConfig.getSheetName()).getRow(irow));
}
}
parent.getCellHelper().reCalc();
} | java | {
"resource": ""
} |
q178890 | WebSheetLoader.refreshDataForRow | test | private void refreshDataForRow(Row row) {
if (row == null) {
return;
}
String saveAttrList = SaveAttrsUtility.getSaveAttrListFromRow(row);
if (saveAttrList!= null) {
String[] saveAttrs = saveAttrList.split(",");
for (String fullSaveAttr : saveAttrs) {
refreshDataForCell(row, fullSaveAttr);
}
}
} | java | {
"resource": ""
} |
q178891 | WebSheetLoader.refreshDataForCell | test | private void refreshDataForCell(Row row, String fullSaveAttr) {
if (fullSaveAttr != null) {
try {
String fullName = ConfigurationUtility.getFullNameFromRow(row);
if (fullName != null) {
parent.getCellHelper().restoreDataContext(fullName);
SaveAttrsUtility.refreshSheetRowFromContext(parent.getSerialDataContext().getDataContext(),
fullSaveAttr, row, parent.getExpEngine());
}
}catch (Exception ex) {
LOG.log(Level.SEVERE, "refreshDataForCell with fullAaveAttr ="+fullSaveAttr+" error = " + ex.getMessage(), ex);
}
}
} | java | {
"resource": ""
} |
q178892 | WebSheetLoader.findTabIndexWithName | test | public final int findTabIndexWithName(final String tabname) {
for (int i = 0; i < parent.getTabs().size(); i++) {
if (parent.getTabs().get(i).getTitle().equalsIgnoreCase(tabname)) {
return i;
}
}
return -1;
} | java | {
"resource": ""
} |
q178893 | WebSheetLoader.loadWorkSheet | test | public final void loadWorkSheet(final String tabName) {
prepareWorkShee(tabName);
parent.getValidationHandler().validateCurrentPage();
createDynamicColumns(tabName);
// reset datatable current page to 1
setDataTablePage(0);
parent.getCurrent().setCurrentDataContextName(null);
saveObjs();
if ((RequestContext.getCurrentInstance() != null) && (parent.getClientId() != null)) {
RequestContext.getCurrentInstance().update(parent.getClientId() + ":websheettab");
}
} | java | {
"resource": ""
} |
q178894 | WebSheetLoader.prepareWorkShee | test | public final void prepareWorkShee(final String tabName) {
int tabIndex = findTabIndexWithName(tabName);
if (parent.getWebFormTabView() != null) {
parent.getWebFormTabView().setActiveIndex(tabIndex);
}
parent.getCurrent().setCurrentTabName(tabName);
String sheetName = parent.getSheetConfigMap().get(tabName).getSheetName();
Sheet sheet1 = parent.getWb().getSheet(sheetName);
parent.getWb().setActiveSheet(parent.getWb().getSheetIndex(sheet1));
SheetConfiguration sheetConfig = parent.getSheetConfigMap().get(tabName);
parent.setMaxRowsPerPage(parent.getSheetConfigMap().get(tabName).getMaxRowPerPage());
parent.setBodyAllowAddRows(parent.getSheetConfigMap().get(tabName).isBodyAllowAddRows());
// populate repeat rows before setup cell range map
Map<String, CellRangeAddress> cellRangeMap = ConfigurationUtility.indexMergedRegion(sheet1);
List<String> skippedRegionCells = ConfigurationUtility.skippedRegionCells(sheet1);
loadHeaderRows(sheetConfig, cellRangeMap, skippedRegionCells);
loadBodyRows(sheetConfig, cellRangeMap, skippedRegionCells);
} | java | {
"resource": ""
} |
q178895 | WebSheetLoader.setDataTablePage | test | private void setDataTablePage(final int first) {
if (parent.getWebFormClientId() != null) {
final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent(parent.getWebFormClientId());
if (d != null) {
d.setFirst(first);
}
}
} | java | {
"resource": ""
} |
q178896 | WebSheetLoader.saveObjs | test | private void saveObjs() {
try {
if (FacesContext.getCurrentInstance() != null) {
Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();
viewMap.put("currentTabName", parent.getCurrent().getCurrentTabName());
viewMap.put(TieConstants.SUBMITMODE, parent.getSubmitMode());
}
} catch (Exception ex) {
LOG.log(Level.SEVERE, "saveobjs in viewMap error = " + ex.getMessage(), ex);
}
} | java | {
"resource": ""
} |
q178897 | WebSheetLoader.setupRowInfo | test | private void setupRowInfo(final FacesRow facesRow, final Sheet sheet1, final Row row, final int rowIndex,
final boolean allowAdd) {
facesRow.setAllowAdd(allowAdd);
if (row != null) {
facesRow.setRendered(!row.getZeroHeight());
facesRow.setRowheight(row.getHeight());
int rowNum = ConfigurationUtility.getOriginalRowNumInHiddenColumn(row);
facesRow.setOriginRowIndex(rowNum);
} else {
facesRow.setRendered(true);
facesRow.setRowheight(sheet1.getDefaultRowHeight());
facesRow.setOriginRowIndex(rowIndex);
}
} | java | {
"resource": ""
} |
q178898 | WebSheetLoader.loadBodyRows | test | private void loadBodyRows(final SheetConfiguration sheetConfig, final Map<String, CellRangeAddress> cellRangeMap,
final List<String> skippedRegionCells) {
int top = sheetConfig.getBodyCellRange().getTopRow();
int bottom = CellUtility.getBodyBottomFromConfig(sheetConfig);
int left = sheetConfig.getBodyCellRange().getLeftCol();
int right = sheetConfig.getBodyCellRange().getRightCol();
String sheetName = sheetConfig.getSheetName();
Sheet sheet1 = parent.getWb().getSheet(sheetName);
parent.getBodyRows().clear();
clearCache();
for (int i = top; i <= bottom; i++) {
parent.getBodyRows()
.add(assembleFacesBodyRow(i, sheet1, left, right, sheetConfig, cellRangeMap, skippedRegionCells));
}
sheetConfig.setBodyPopulated(true);
parent.getCurrent().setCurrentTopRow(top);
parent.getCurrent().setCurrentLeftColumn(left);
} | java | {
"resource": ""
} |
q178899 | WebSheetLoader.assembleFacesBodyRow | test | private FacesRow assembleFacesBodyRow(final int rowIndex, final Sheet sheet1, final int left, final int right,
final SheetConfiguration sheetConfig, final Map<String, CellRangeAddress> cellRangeMap,
final List<String> skippedRegionCells) {
FacesRow facesRow = new FacesRow(rowIndex);
Row row = sheet1.getRow(rowIndex);
setupRowInfo(facesRow, sheet1, row, rowIndex, CommandUtility.isRowAllowAdd(row, sheetConfig));
String saveAttrList = SaveAttrsUtility.getSaveAttrListFromRow(row);
List<FacesCell> bodycells = new ArrayList<>();
for (int cindex = left; cindex <= right; cindex++) {
String cellindex = CellUtility.getCellIndexNumberKey(cindex, rowIndex);
if (!skippedRegionCells.contains(cellindex) && !sheet1.isColumnHidden(cindex)) {
Cell cell = null;
if (row != null) {
cell = row.getCell(cindex, MissingCellPolicy.CREATE_NULL_AS_BLANK);
}
if (cell != null) {
FacesCell fcell = new FacesCell();
CellUtility.convertCell(sheetConfig, fcell, cell, cellRangeMap, facesRow.getOriginRowIndex(),
parent.getCellAttributesMap(), saveAttrList);
parent.getPicHelper().setupFacesCellPictureCharts(sheet1, fcell, cell,
WebSheetUtility.getFullCellRefName(sheet1, cell));
CellStyleUtility.setupCellStyle(parent.getWb(), fcell, cell, row.getHeightInPoints());
fcell.setColumnIndex(cindex);
bodycells.add(fcell);
addCache(cell);
} else {
bodycells.add(null);
}
} else {
bodycells.add(null);
}
}
facesRow.setCells(bodycells);
return facesRow;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.