public WF_Not_ClickableField_SumAndCountOfVariables(
      String header,
      String descriptionT,
      WF_Context myContext,
      String myTarget,
      String pattern,
      Type sumOrCount,
      boolean isVisible,
      String textColor,
      String bgColor) {
    super(
        header,
        descriptionT,
        myContext,
        LayoutInflater.from(myContext.getContext())
            .inflate(R.layout.selection_field_normal_colored, null),
        isVisible);
    this.myContext = myContext;
    o = GlobalState.getInstance().getLogger();
    targetList = myContext.getList(myTarget);
    myType = sumOrCount;
    myPattern = pattern;
    allMatchingVariables = new HashSet<Variable>();
    TextView text = (TextView) getWidget().findViewById(R.id.editfieldtext);
    LinearLayout bg = (LinearLayout) getWidget().findViewById(R.id.background);
    if (bgColor != null) bg.setBackgroundColor(Color.parseColor(bgColor));
    if (textColor != null) text.setTextColor(Color.parseColor(textColor));

    if (targetList == null) {
      o.addRow("");
      o.addRedText(
          "Couldn't create " + header + " since target list: " + myTarget + " does not exist");
      Log.e(
          "parser",
          "couldn't create SumAndCountOfVariables - could not find target list " + myTarget);
    } else {

      for (Listable l : targetList.getList()) {
        Set<Variable> vars = l.getAssociatedVariables();
        for (Variable v : vars) {
          if (v.getId().matches(myPattern)) allMatchingVariables.add(v);
        }
      }

      myContext.addEventListener(this, EventType.onRedraw);
    }
  }
示例#2
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());
  }
示例#3
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);
  }
示例#4
0
  public WF_SimpleCounter(
      String targetId, String label, String descriptionT, WF_Context myContext, boolean isVisible) {
    super(
        label,
        descriptionT,
        myContext,
        LayoutInflater.from(myContext.getContext()).inflate(R.layout.selection_field_normal, null),
        isVisible);

    gs = GlobalState.getInstance(myContext.getContext());
    myTarget = gs.getArtLista().getVariableInstance(targetId);
    if (myTarget == null) {
      o.addRow("");
      o.addRedText("Missing target variable " + targetId + " in SimpleCounter");
    } else {
      List<String> listElems = gs.getArtLista().getListElements(myTarget.getBackingDataSet());
      int count = 0;
      if (listElems != null) count = listElems.size();
      Variable noOfAvslutade = gs.getArtLista().getVariableInstance("noOfAvslutade");
      noOfAvslutade.setValue(count + "");
      this.addVariable(noOfAvslutade, true, null, true);
      this.refreshOutputFields();
    }
  }
 @Override
 public LinearLayout getFieldLayout() {
   return (LinearLayout)
       LayoutInflater.from(myContext.getContext())
           .inflate(R.layout.output_field_selection_element, null);
 }