public TextFile openDBforFile(String dbName, String fileName, String tablePrefix) { perFile = new perFileStruc(); cliDB = new sqlSolver(); initialScript(dbName, tablePrefix); if (checkMisprog(cliDB == null, "cliDB")) return null; if (checkMisprog(cached == null, "cached")) return null; cliDB.openScript(); out( "INSERT INTO " + cached.tabPrefix + "_files VALUES (" + cached.fileID + ", '" + cliDB.escapeString(DateFormat.getTodayStr()) + "', '" + fileName + "');"); log.dbg(2, "processOneFile", "start parsing [" + fileName + "]"); TextFile tf = new TextFile(); if (!tf.fopen(fileName, "rb")) // mode "rb" to be able to get the InputStream! { log.err("processOneFile", "file to parse [" + fileName + "] cannot be openned!"); return null; } return tf; }
private void precalculateAll() { if (isPrecalculated) return; if (!checkLayoutInfo()) { log.err("checkLayoutInfo", "layout [" + lay.getName() + "] is not of type EVA"); // do not return! some variables has to be initialized anyway } log.dbg(2, "precalculateAll", "layout " + lay.getName() + " perform precalculation."); Hmargin = Math.max(0, stdlib.atoi(lay.getValue(0, 1))); Vmargin = Math.max(0, stdlib.atoi(lay.getValue(0, 2))); Hgap = Math.max(0, stdlib.atoi(lay.getValue(0, 3))); Vgap = Math.max(0, stdlib.atoi(lay.getValue(0, 4))); log.dbg(4, "precalculateAll", nColumns() + " columns x " + nRows() + " rows"); log.dbg( 4, "precalculateAll", "margins xm=" + Hmargin + ", ym=" + Vmargin + ", yg=" + Hgap + ", yg=" + Vgap); mnCols = -1; // reset cached number of cols mnRows = -1; // reset cached number of rows HdimMin = new int[nColumns()]; HdimPref = new int[nColumns()]; Hpos = new int[nColumns()]; VdimMin = new int[nRows()]; VdimPref = new int[nRows()]; Vpos = new int[nRows()]; columnsReparto = new Vector(); rowsReparto = new Vector(); // for all components ... int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); // if (child.getVisibility() != GONE) EvaLayout.LayoutParams lp = (EvaLayout.LayoutParams) child.getLayoutParams(); lp.isLaidOut = false; } // compute Vdim (Note: it might be precalculated if needed) fijoV = Vmargin; for (int rr = 0; rr < nRows(); rr++) { String heaRow = rowHeader(rr); int typ = headType(heaRow); int gap = (rr == 0) ? 0 : Vgap; if (typ == HEADER_ORIGINAL) { // maximum-minimum of the row VdimPref[rr] = minHeightOfRow(rr, true); VdimMin[rr] = minHeightOfRow(rr, false); log.dbg(2, "precalculateAll", "Adaption... VdimPref[rr] = " + VdimPref[rr]); } else if (typ == HEADER_EXPAND) { rowsReparto.add(new int[] {rr}); // compute later log.dbg(2, "precalculateAll", "Expand... VdimPref[rr] = " + VdimPref[rr]); } else { // indicated size VdimPref[rr] = VdimMin[rr] = stdlib.atoi(heaRow); log.dbg(2, "precalculateAll", "Explicit... VdimPref[rr] = " + VdimPref[rr]); } Vpos[rr] = fijoV + gap; fijoV += VdimPref[rr]; fijoV += gap; } fijoV += Vmargin; log.dbg(2, "precalculateAll", "fijoV = " + fijoV + " Vmargin = " + Vmargin + " Vgap = " + Vgap); // DEBUG .... if (log.isDebugging(2)) { String vertical = "Vertical array (posY/prefHeight/minHeight)"; for (int rr = 0; rr < Vpos.length; rr++) vertical += " " + rr + ") " + Vpos[rr] + "/" + VdimPref[rr] + "/" + VdimMin[rr]; log.dbg(2, "precalculateAll", vertical); } // compute Hdim (Note: it might be precalculated if needed) fijoH = Hmargin; for (int cc = 0; cc < nColumns(); cc++) { String heaCol = columnHeader(cc); int typ = headType(heaCol); int gap = (cc == 0) ? 0 : Hgap; if (typ == HEADER_ORIGINAL) { // maximum-minimum of the column HdimPref[cc] = minWidthOfColumn(cc, true); HdimMin[cc] = minWidthOfColumn(cc, false); } else if (typ == HEADER_EXPAND) columnsReparto.add(new int[] {cc}); // compute later else HdimPref[cc] = HdimMin[cc] = stdlib.atoi(heaCol); // indicated size Hpos[cc] = fijoH + gap; fijoH += HdimPref[cc]; fijoH += gap; } fijoH += Hmargin; log.dbg(2, "precalculateAll", "fijoH = " + fijoH); // DEBUG .... if (log.isDebugging(2)) { String horizontal = "Horizontal array (posX/prefWidth/minWidth)"; for (int cc = 0; cc < Hpos.length; cc++) horizontal += " " + cc + ") " + Hpos[cc] + "/" + HdimPref[cc] + "/" + HdimMin[cc]; log.dbg(2, "precalculateAll", horizontal); } // finding all components in the layout array for (int cc = 0; cc < nColumns(); cc++) { for (int rr = 0; rr < nRows(); rr++) { String name = widgetAt(rr, cc); LayoutParams wid = theComponent(name); if (wid == null) continue; // set position x,y wid.posCol0 = cc; wid.posRow0 = rr; // set position x2,y2 int ava = cc; while (ava + 1 < nColumns() && widgetAt(rr, ava + 1).equals(EXPAND_HORIZONTAL)) ava++; wid.posCol1 = ava; ava = rr; while (ava + 1 < nRows() && widgetAt(ava + 1, cc).equals(EXPAND_VERTICAL)) ava++; wid.posRow1 = ava; wid.isLaidOut = true; // DEBUG .... if (log.isDebugging(2)) { log.dbg( 2, "precalculateAll", wid.name + " leftTop (" + wid.posCol0 + ", " + wid.posRow0 + ") rightBottom (" + wid.posCol1 + ", " + wid.posRow1 + ")"); } } } isPrecalculated = true; }