Пример #1
0
 // Create a new row + dataset.
 public void addRow(List<String> row) {
   WF_Table_Row rowWidget =
       new WF_Table_Row(
           tableView,
           (rowNumber++) + "",
           inflater.inflate(R.layout.table_row, null),
           myContext,
           true);
   rowWidget.addEntryField(row);
   list.add(rowWidget);
 }
Пример #2
0
  public void addColumn(String header, String colKey, String type, String width) {
    // Copy the key and add the variator.
    Map<String, String> colHash = Tools.copyKeyHash(myContext.getKeyHash());
    colHash.put(myVariator, colKey);

    // Add header to the header row? Duh!!
    headerRow.addHeaderCell(header);

    // Create all row entries.
    for (Listable l : list) {
      WF_Table_Row wft = (WF_Table_Row) l;
      wft.addCell(header, colKey, colHash, type, width);
    }
    columnKeys.add(colKey);
  }
Пример #3
0
  // How about using the Container's panel?? TODO
  public WF_Table(
      String id,
      boolean isVisible,
      WF_Context ctx,
      String namePrefix,
      String variatorColumn,
      View tableV) {
    super(id, isVisible, ctx, tableV);
    this.tableView = (TableLayout) tableV.findViewById(R.id.table);
    ;
    myContext = ctx;
    gs = GlobalState.getInstance();
    o = gs.getLogger();
    al = gs.getVariableConfiguration();
    myVariator = variatorColumn;
    // myTable = new GridView(ctx.getContext());

    // Create rows.
    inflater = (LayoutInflater) ctx.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Add the header.
    headerRow =
        new WF_Table_Row(
            tableView,
            ColHeadId,
            inflater.inflate(R.layout.header_table_row, null),
            myContext,
            true);
    // Add a first empty cell
    headerRow.addEmptyCell(id);
    tableView.addView(headerRow.getWidget());

    varNamePrefix = namePrefix;

    allInstances = gs.getDb().preFetchValues(myContext.getKeyHash(), namePrefix, myVariator);
    Log.d(
        "nils",
        "in update entry fields. AllInstances contain "
            + allInstances.size()
            + ": "
            + allInstances.toString());
    tableView.setStretchAllColumns(true);
    addSorter(new WF_Alphanumeric_Sorter());
  }
Пример #4
0
  public void addVariableToEveryCell(
      String variableSuffix,
      boolean displayOut,
      String format,
      boolean isVisible,
      boolean showHistorical,
      String initialValue) {

    // Map<String, String> colHash = Tools.copyKeyHash(myContext.getKeyHash());

    // get rows.
    for (Listable l : list) {
      WF_Table_Row wft = (WF_Table_Row) l;
      Set<String> varIds = varIdMap.get(wft.getLabel());
      String varGrId = null;
      if (varIds == null) {
        Log.e("vortex", "No variableIds found for " + wft.getLabel());
        return;
      } else {
        Log.d("vortex", "varIds contains " + varIds.size() + " variables");
        for (String varGr : varIds) {
          Log.d("vortex", "varGr: " + varGr);
          if (varGr.endsWith(variableSuffix)) {
            varGrId = varGr;
            break;
          }
        }
      }
      if (varGrId == null) {
        Log.e("vortex", "found no variable with suffix: " + variableSuffix);
        o.addRow("");
        o.addRedText(
            "Could not add variables with suffix: "
                + variableSuffix
                + ". No instances found. Check spelling and case");
        return;
      }
      // Construct variablename.
      // String varId =
      // varNamePrefix+Constants.VariableSeparator+varGrId+Constants.VariableSeparator+variableSuffix;
      Log.d("vortex", "Adding variable " + varGrId);
      // Get prefetchvalue per variator value.
      Map<String, String> valueMap = allInstances.get(varGrId);

      // add to each cell

      int columnIndex = 0;
      for (WF_Cell cell : wft.getCells()) {
        // Get columnKey
        String colKey = columnKeys.get(columnIndex);

        // Get value for this column
        String prefetchValue = null;
        if (valueMap != null) {
          prefetchValue = valueMap.get(colKey);
        }
        if (prefetchValue != null) {
          Log.d("vortex", "valueMap: " + valueMap.toString() + " colKey: " + colKey);
          Log.d("vortex", "found prefetch value " + prefetchValue);
        }
        cell.addVariable(varGrId, displayOut, format, isVisible, showHistorical, prefetchValue);
        columnIndex++;
      }
    }
  }
Пример #5
0
 @Override
 protected void prepareDraw() {
   tableView.removeAllViews();
   tableView.addView(headerRow.getWidget());
 }