コード例 #1
0
ファイル: TestListWidget.java プロジェクト: plibin/regadb
  public void init(InteractionState interactionState, IForm form, FormTable table) {
    Transaction tr = RegaDBMain.getApp().createTransaction();

    for (UITestItem ti : testItems) {
      Test t = getTest(tr, ti);
      if (t != null) {
        Label l = new Label(TestComboBox.getLabel(t));
        FormField testResultField;
        if (ValueTypes.getValueType(t.getTestType().getValueType()) == ValueTypes.NOMINAL_VALUE) {
          testResultField = new ComboBox(interactionState, form);
          for (TestNominalValue tnv : t.getTestType().getTestNominalValues()) {
            ((ComboBox) testResultField)
                .addItem(new DataComboMessage<TestNominalValue>(tnv, tnv.getValue()));
          }
          ((ComboBox) testResultField).sort();

          if (ti.noValueSelected) ((ComboBox) testResultField).addNoSelectionItem();

          ((ComboBox) testResultField).selectIndex(0);

          if (ti.defaultValue != null && interactionState.isEditable())
            ((ComboBox) testResultField).selectItem(ti.defaultValue);
        } else {
          testResultField =
              FormField.getTextField(
                  ValueTypes.getValueType(t.getTestType().getValueType()), interactionState, form);
        }

        table.addLineToTable(l, testResultField);
        testFormFields.add(testResultField);
      } else {
        System.err.println("ViralIsolateForm: test does not exist: '" + ti.description + '\'');
      }
    }
  }
コード例 #2
0
ファイル: TestListWidget.java プロジェクト: plibin/regadb
  public void fillData(Set<TestResult> testResults) {
    Transaction tra = RegaDBMain.getApp().createTransaction();

    for (int i = 0; i < testItems.size(); i++) {
      TestItem ti = testItems.get(i);
      Test test = getTest(tra, ti);
      if (test == null) continue;

      TestResult theTr = null;
      for (TestResult tr : testResults) {
        if (tr.getTest().getDescription().equals(test.getDescription())) {
          theTr = tr;
          break;
        }
      }

      FormField f = testFormFields.get(i);
      if (theTr != null) {
        if (f instanceof ComboBox) {
          ((ComboBox) f).selectItem(theTr.getTestNominalValue().getValue());
        } else {
          if (theTr.getValue() != null) f.setText(theTr.getValue());
          else f.setText(new String(theTr.getData()));
        }
      }
    }
  }