/** * @param actionCommand Evaluate || Numeric || Substitute * @return true iff any substitution applied */ protected boolean apply(String actionCommand) { CASTable table = getCASView().getConsoleTable(); // create substitution list StringBuilder substList = new StringBuilder("{"); StringBuilder substComment = new StringBuilder(); for (int i = 0; i < data.size(); i++) { String fromExpr = data.get(i).get(0).trim(); String toExpr = data.get(i).get(1).trim(); if (!"".equals(fromExpr) && !"".equals(toExpr)) { if (substList.length() > 1) { substList.append(','); substComment.append(','); } fromExpr = getCASView().resolveCASrowReferences(fromExpr, editRow); toExpr = getCASView().resolveCASrowReferences(toExpr, editRow); substList.append(fromExpr); substList.append('='); substList.append(toExpr); substComment.append(fromExpr); substComment.append('='); substComment.append(toExpr); } } substList.append('}'); if ("{}".equals(substList.toString())) return false; // make sure pure substitute is not evaluated boolean keepInput = false; // substitute command String subCmd = "Substitute[" + evalText + "," + substList + "]"; if ("Substitute".equals(actionCommand)) { subCmd = "Substitute[" + evalText + "," + substList + "]"; keepInput = true; } else if ("Numeric".equals(actionCommand)) { subCmd = "Numeric[" + subCmd + "]"; keepInput = false; } try { GeoCasCell currCell = table.getGeoCasCell(editRow); currCell.setProcessingInformation(prefix, subCmd, postfix); currCell.setEvalCommand("Substitute"); currCell.setEvalComment(substComment.toString()); // make sure pure substitute is not evaluated currCell.setKeepInputUsed(keepInput); getCASView().processRowThenEdit(editRow, true); // table.startEditingRow(editRow + 1); return true; } catch (Throwable e) { e.printStackTrace(); return false; } }