Search in sources :

Example 1 with VariableRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.

the class VariablesEditorFieldRenderer method isDuplicateName.

/**
 * Tests whether a Row name occurs more than once in the list of rows
 * @param name
 * @return
 */
public boolean isDuplicateName(final String name) {
    if (name == null || name.trim().isEmpty()) {
        return false;
    }
    List<VariableRow> as = view.getVariableRows();
    if (as != null && !as.isEmpty()) {
        int nameCount = 0;
        String currName = name.trim();
        for (VariableRow row : as) {
            String rowName = row.getName();
            if (rowName != null && currName.compareTo(rowName.trim()) == 0) {
                nameCount++;
                if (nameCount > 1) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : VariableRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow)

Example 2 with VariableRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.

the class VariablesEditorFieldRenderer method addVariable.

@Override
public void addVariable() {
    List<VariableRow> as = view.getVariableRows();
    if (as.isEmpty()) {
        view.setTableDisplayStyle();
    }
    VariableRow newVariable = new VariableRow();
    newVariable.setVariableType(variableType);
    as.add(newVariable);
    VariableListItemWidgetView widget = view.getVariableWidget(view.getVariableRowsCount() - 1);
    widget.setDataTypes(dataTypeListBoxValues);
    widget.setParentWidget(this);
}
Also used : VariableRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow)

Example 3 with VariableRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.

the class VariableListItemWidgetViewImplTest method testHandleDeleteButton.

@Test
public void testHandleDeleteButton() {
    VariablesEditorWidgetView.Presenter widget = mock(VariablesEditorWidgetView.Presenter.class);
    VariableRow model = mock(VariableRow.class);
    when(view.getModel()).thenReturn(model);
    view.setParentWidget(widget);
    view.handleDeleteButton(null);
    verify(widget).removeVariable(model);
}
Also used : VariableRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow) Test(org.junit.Test)

Example 4 with VariableRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.

the class VariablesEditorFieldRendererTest method testIsDuplicateName.

@Test
public void testIsDuplicateName() {
    List<VariableRow> variableRows = new ArrayList<VariableRow>();
    variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var1", "String", null));
    variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var2", "Integer", null));
    variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var3", "org.stuff.Potato", null));
    variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var2", "Integer", null));
    variableRows.add(new VariableRow(Variable.VariableType.PROCESS, null, "Object", null));
    variableRows.add(new VariableRow(Variable.VariableType.PROCESS, null, null, null));
    when(variablesEditorWidgetView.getVariableRows()).thenReturn(variableRows);
    assertTrue(variablesEditor.isDuplicateName("var2"));
    assertFalse(variablesEditor.isDuplicateName("var1"));
}
Also used : ArrayList(java.util.ArrayList) VariableRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow) Test(org.junit.Test)

Example 5 with VariableRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.

the class VariableListItemWidgetTest method initTestCase.

@Before
public void initTestCase() {
    GwtMockito.initMocks(this);
    dataType = mock(ValueListBox.class);
    customDataType = mock(TextBox.class);
    dataTypeComboBox = mock(ComboBox.class);
    widget = GWT.create(VariableListItemWidgetViewImpl.class);
    VariableRow variableRow = new VariableRow();
    widget.dataType = dataType;
    widget.customDataType = customDataType;
    widget.dataTypeComboBox = dataTypeComboBox;
    widget.name = name;
    widget.deleteButton = deleteButton;
    widget.variableRow = variable;
    Mockito.doCallRealMethod().when(widget).setTextBoxModelValue(any(TextBox.class), anyString());
    Mockito.doCallRealMethod().when(widget).setListBoxModelValue(any(ValueListBox.class), anyString());
    Mockito.doCallRealMethod().when(widget).getModelValue(any(ValueListBox.class));
    Mockito.doCallRealMethod().when(widget).setDataTypeDisplayName(anyString());
    Mockito.doCallRealMethod().when(widget).getDataTypeDisplayName();
    Mockito.doCallRealMethod().when(widget).setCustomDataType(anyString());
    Mockito.doCallRealMethod().when(widget).getCustomDataType();
    Mockito.doCallRealMethod().when(widget).setDataTypes(any(ListBoxValues.class));
    Mockito.doCallRealMethod().when(widget).init();
    Mockito.doCallRealMethod().when(widget).setModel(any(VariableRow.class));
    when(widget.getModel()).thenReturn(variableRow);
}
Also used : ValueListBox(org.gwtbootstrap3.client.ui.ValueListBox) ComboBox(org.kie.workbench.common.stunner.bpmn.client.forms.widgets.ComboBox) TextBox(org.gwtbootstrap3.client.ui.TextBox) VariableNameTextBox(org.kie.workbench.common.stunner.bpmn.client.forms.widgets.VariableNameTextBox) VariableRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow) ListBoxValues(org.kie.workbench.common.stunner.bpmn.client.forms.util.ListBoxValues) Before(org.junit.Before)

Aggregations

VariableRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow)12 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 Before (org.junit.Before)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 TextBox (org.gwtbootstrap3.client.ui.TextBox)2 ValueListBox (org.gwtbootstrap3.client.ui.ValueListBox)2 ComboBox (org.kie.workbench.common.stunner.bpmn.client.forms.widgets.ComboBox)2 VariableNameTextBox (org.kie.workbench.common.stunner.bpmn.client.forms.widgets.VariableNameTextBox)2 HashMap (java.util.HashMap)1 List (java.util.List)1 ListBoxValues (org.kie.workbench.common.stunner.bpmn.client.forms.util.ListBoxValues)1 Mockito.anyString (org.mockito.Mockito.anyString)1