コード例 #1
0
ファイル: ComboBox.java プロジェクト: romartin/jbpm-designer
 @Override
 public String addCustomValueToListBoxValues(String newValue, String oldValue) {
   if (quoteStringValues) {
     newValue = StringUtils.createQuotedConstant(newValue);
     oldValue = StringUtils.createQuotedConstant(oldValue);
   }
   return listBoxValues.addCustomValue(newValue, oldValue);
 }
コード例 #2
0
  @Test
  public void testProcessVarComboBox() {
    initComboBoxTest(
        processVarQuoteStringValues,
        processVarConstantPrompt,
        processVarConstantPlaceholder,
        processVarEditPrefix,
        processVarEditSuffix,
        processVarListBoxStartValues);

    setNonCustomValue(processVarListBoxStartValues.get(2), 1);

    String customStringValue1 = "first constant";
    setCustomValue(customStringValue1);

    setNonCustomValue(processVarListBoxStartValues.get(2), 2);

    String customNumericValue1 = "123";
    setCustomValue(customNumericValue1);

    setNonCustomValue(StringUtils.createQuotedConstant(customStringValue1), 2);

    String customNumericValue2 = "123.456";
    setCustomValue(customNumericValue2);

    aboutToEditCustomValue(customNumericValue2, 2);

    String customNumericValue3 = "100";
    editCustomValue(customNumericValue3);

    String customStringValue2 = "second constant";
    setCustomValue(customStringValue2);

    setNonCustomValue(StringUtils.createQuotedConstant(customStringValue1), 3);

    setNonCustomValue(processVarListBoxStartValues.get(2), 3);

    assertTrue(
        getListBoxValues()
            .getAcceptableValuesWithCustomValues()
            .contains(StringUtils.createQuotedConstant(customStringValue1)));
    assertTrue(
        getListBoxValues().getAcceptableValuesWithCustomValues().contains(customNumericValue1));
    assertTrue(
        !getListBoxValues().getAcceptableValuesWithCustomValues().contains(customNumericValue2));
    assertTrue(
        getListBoxValues().getAcceptableValuesWithCustomValues().contains(customNumericValue3));

    assertTrue(
        getListBoxValues()
            .getAcceptableValuesWithCustomValues()
            .contains(StringUtils.createQuotedConstant(customStringValue2)));

    //        System.out.println(comboBox.getListBoxValues().toString());
  }
コード例 #3
0
ファイル: ComboBox.java プロジェクト: romartin/jbpm-designer
 @Override
 public void listBoxValueChanged(String newValue) {
   if (customPrompt.equals(newValue)) {
     // "Custom..." selected, show textBox with empty value
     setListBoxValue("");
     setTextBoxValue("");
     view.setListBoxVisible(false);
     view.setTextBoxVisible(true);
     view.setTextBoxFocus(true);
   } else if (newValue.startsWith("*")) {
     // Not a valid value
     setListBoxValue("");
     setTextBoxValue("");
   } else if (newValue.startsWith(listBoxValues.getEditPrefix())) {
     // "Edit <value> ..." selected, show textBox with appropriate value
     String value = view.getModelValue();
     setTextBoxValue(value);
     view.setListBoxVisible(false);
     view.setTextBoxVisible(true);
     view.setTextBoxFocus(true);
   } else if (listBoxValues.isCustomValue(newValue)) {
     // A Custom value has been selected
     String textValue = listBoxValues.getValueForDisplayValue(newValue);
     if (quoteStringValues) {
       textValue = StringUtils.createUnquotedConstant(textValue);
     }
     setListBoxValue(newValue);
     setTextBoxValue(textValue);
   } else if (newValue != null) {
     // A non-custom value has been selected
     setListBoxValue(newValue);
     setTextBoxValue("");
   }
   updateListBoxValues(view.getListBoxValue());
 }
コード例 #4
0
  private void editCustomValue(String value) {

    comboBox.view.textBoxGotFocus();
    textBox.setValue(value);
    comboBox.view.textBoxLostFocus();
    comboBox.view.listBoxGotFocus();
    assertEquals(listBox.isVisible(), true);
    assertEquals(textBox.isVisible(), false);

    String listBoxValue = this.quoteStringValues ? StringUtils.createQuotedConstant(value) : value;
    verify(modelPresenter).setTextBoxModelValue(textBox, listBoxValue);
    assertEquals(comboBox.getValue(), listBoxValue);
  }