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);
    }
  }
  public void matchAndRecalculateMe() {
    String variablesWithNoValue = "[";
    Long sum = Long.valueOf(0);
    if (targetList == null) return;

    for (Variable v : allMatchingVariables) {
      String val = v.getValue();
      if (val != null && !val.isEmpty()) {
        // Log.d("nils","VALUE: "+v.getValue());
        if (myType == Type.count) {
          sum++;
        } else {
          try {
            sum += Long.parseLong(val);
          } catch (NumberFormatException e) {
            Log.e("vortex", "Numberformatexception for " + val);
          }
        }

      } else variablesWithNoValue += v.getId() + ",";
    }
    /*
    for (Listable l:targetList.getList()) {
    	Set<Variable> vars = l.getAssociatedVariables();
    	//Log.d("nils","now in matchandrecalculate with list size "+vars.size()+" my label: "+this.getLabel());
    	if (vars!=null && !vars.isEmpty()) {
    		for (Variable v:vars) {
    			if (v.getId().matches(myPattern)) {
    				Log.d("nils","Match for "+v.getId());
    				if (v.getValue()!=null) {
    					//Log.d("nils","VALUE: "+v.getValue());
    					if (myType == Type.count) {
    						sum++;
    					}

    					else {
    						String val=v.getValue();
    						if (val!=null && !val.isEmpty()) {
    							try {
    							sum+=Long.parseLong(v.getValue());
    							} catch (NumberFormatException e) {
    								sum+=0;
    							}
    						}
    					}
    				} else {
    					variablesWithNoValue += v.getId()+",";
    				}
    			}


    		}

    	} else {
    		Log.d("nils ","Vars for "+l.getLabel()+" empty");
    	}
    }*/
    if (sum == 0) {
      variablesWithNoValue += "]";
      o.addRow("");
      o.addYellowText(
          "Sum zero in Count/Add Block. with pattern [" + myPattern + "] No value found for:");
      o.addRow(variablesWithNoValue);
    } else {
      o.addRow("");
      o.addGreenText("Found match(es) in Count/Add Block with pattern [" + myPattern + "]");
    }

    if (myVar != null) myVar.setValue(sum.toString());
  }