Search in sources :

Example 1 with DataTypeListItem

use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.

the class DataTypeSearchBarView method showSearchResults.

@Override
public void showSearchResults(final List<DataType> results) {
    final AtomicInteger position = new AtomicInteger(0);
    final List<DataTypeListItem> listItems = presenter.getDataTypeListItemsSortedByPositionY();
    expandListItems(listItems);
    final List<DataTypeListItem> grouped = groupElementsWithItsParents(listItems);
    for (final DataTypeListItem listItem : grouped) {
        final HTMLElement element = listItem.getDragAndDropElement();
        if (results.contains(listItem.getDataType())) {
            showElementAt(element, position);
        } else {
            hideElement(element);
        }
    }
    refreshItemsPosition();
    enableSearch();
    refreshDragAreaSize();
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) HTMLElement(elemental2.dom.HTMLElement) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 2 with DataTypeListItem

use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.

the class DataTypeListShortcuts method onEscape.

void onEscape() {
    final Optional<DataTypeListItem> currentDataTypeListItem = getCurrentDataTypeListItem();
    if (currentDataTypeListItem.isPresent()) {
        final DataTypeListItem dataTypeListItem = currentDataTypeListItem.get();
        dataTypeListItem.disableEditMode();
        highlight(dataTypeListItem.getDragAndDropElement());
    } else {
        getVisibleDataTypeListItems().forEach(DataTypeListItem::disableEditMode);
        reset();
    }
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)

Example 3 with DataTypeListItem

use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.

the class DNDDataTypesHandlerTest method testShiftCurrentByReferenceWhenCurrentIsCollapsedAndItIsTopLevelShiftOperation.

@Test
public void testShiftCurrentByReferenceWhenCurrentIsCollapsedAndItIsTopLevelShiftOperation() {
    final DataType current = mock(DataType.class);
    final DataType clone = mock(DataType.class);
    final DataType reference = mock(DataType.class);
    final DataType cloneParent1 = mock(DataType.class);
    final DataType cloneParent2 = mock(DataType.class);
    final DNDDataTypesHandlerShiftStrategy strategy = INSERT_INTO_HOVERED_DATA_TYPE;
    final String referenceHash = "referenceHash";
    final String cloneHash = "cloneHash";
    final DataTypeListItem oldItem = mock(DataTypeListItem.class);
    final DataTypeListItem referenceItem = mock(DataTypeListItem.class);
    final DataTypeListItem cloneItem = mock(DataTypeListItem.class);
    final HTMLElement cloneHTMLElement = mock(HTMLElement.class);
    final String cloneParent1UUID = "cloneParent1UUID";
    final String cloneParent2UUID = "cloneParent2UUID";
    final DataTypeListItem cloneParent1Item = mock(DataTypeListItem.class);
    final DataTypeListItem cloneParent2Item = mock(DataTypeListItem.class);
    doReturn(clone).when(handler).cloneDataType(current);
    doReturn(true).when(handler).isTopLevelShiftOperation(current, strategy);
    when(dataTypeList.calculateHash(reference)).thenReturn(referenceHash);
    when(dataTypeList.calculateHash(clone)).thenReturn(cloneHash);
    when(dataTypeList.findItem(current)).thenReturn(Optional.of(oldItem));
    when(dataTypeList.findItemByDataTypeHash(referenceHash)).thenReturn(Optional.of(referenceItem));
    when(dataTypeList.findItemByDataTypeHash(cloneHash)).thenReturn(Optional.of(cloneItem));
    when(cloneItem.getDragAndDropElement()).thenReturn(cloneHTMLElement);
    when(oldItem.isCollapsed()).thenReturn(true);
    when(cloneItem.getDataType()).thenReturn(clone);
    when(clone.getParentUUID()).thenReturn(cloneParent1UUID);
    when(cloneParent1.getParentUUID()).thenReturn(cloneParent2UUID);
    when(cloneParent1.getUUID()).thenReturn(cloneParent1UUID);
    when(cloneParent2.getUUID()).thenReturn(cloneParent2UUID);
    when(dataTypeStore.get(cloneParent1UUID)).thenReturn(cloneParent1);
    when(dataTypeStore.get(cloneParent2UUID)).thenReturn(cloneParent2);
    when(dataTypeList.findItem(cloneParent1)).thenReturn(Optional.of(cloneParent1Item));
    when(dataTypeList.findItem(cloneParent2)).thenReturn(Optional.of(cloneParent2Item));
    handler.shiftCurrentByReference(current, reference, strategy);
    verify(cloneItem).collapse();
    verify(oldItem).destroyWithoutDependentTypes();
    verify(referenceItem).insertNestedField(clone);
    verify(dataTypeList).highlightLevel(cloneHTMLElement);
    verify(cloneParent1Item).expand();
    verify(cloneParent2Item).expand();
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) HTMLElement(elemental2.dom.HTMLElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 4 with DataTypeListItem

use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.

the class DMNDataTypesSubIndexTest method testHighlight.

@Test
public void testHighlight() {
    final DataTypeListItem listItem = mock(DataTypeListItem.class);
    final DataTypeListItem parentListItem = mock(DataTypeListItem.class);
    final DataType dataType = mock(DataType.class);
    final DataType parent = mock(DataType.class);
    final HTMLElement htmlElement = mock(HTMLElement.class);
    final String parentUUID = "parentUUID";
    final String dataTypeUUID = "dataTypeUUID";
    when(listItem.getDataType()).thenReturn(dataType);
    when(parentListItem.getDataType()).thenReturn(parent);
    when(listItem.getDragAndDropElement()).thenReturn(htmlElement);
    when(dataType.getParentUUID()).thenReturn(parentUUID);
    when(dataType.getUUID()).thenReturn(dataTypeUUID);
    when(parent.getUUID()).thenReturn(parentUUID);
    when(dataTypeStore.get(parentUUID)).thenReturn(parent);
    when(dataTypeStore.get(dataTypeUUID)).thenReturn(dataType);
    when(dataTypeList.getItems()).thenReturn(asList(listItem, parentListItem));
    index.highlight(listItem);
    verify(listItem).expand();
    verify(parentListItem).expand();
    verify(dataTypeShortcuts).highlight(htmlElement);
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) HTMLElement(elemental2.dom.HTMLElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 5 with DataTypeListItem

use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.

the class DataTypeConstraintTest method testInit.

@Test
public void testInit() {
    final DataTypeListItem expectedListItem = mock(DataTypeListItem.class);
    final DataType datatype = mock(DataType.class);
    final String expectedConstraint = "constraint";
    final ConstraintType expectedType = mock(ConstraintType.class);
    when(expectedListItem.getDataType()).thenReturn(datatype);
    when(datatype.getConstraint()).thenReturn(expectedConstraint);
    when(datatype.getConstraintType()).thenReturn(expectedType);
    dataTypeConstraint.init(expectedListItem);
    final DataTypeListItem actualListItem = dataTypeConstraint.getListItem();
    final String actualConstraint = dataTypeConstraint.getValue();
    final ConstraintType actualType = dataTypeConstraint.getConstraintType();
    assertEquals(expectedType, actualType);
    assertEquals(expectedListItem, actualListItem);
    assertEquals(expectedConstraint, actualConstraint);
    verify(dataTypeConstraint).refreshView();
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Test(org.junit.Test)

Aggregations

DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)30 Test (org.junit.Test)27 HTMLElement (elemental2.dom.HTMLElement)22 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)15 ArrayList (java.util.ArrayList)5 DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)4 DataTypeList (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeList)3 DOMTokenList (elemental2.dom.DOMTokenList)2 Element (elemental2.dom.Element)2 HashMap (java.util.HashMap)2 ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BiConsumer (java.util.function.BiConsumer)1 ManagedInstance (org.jboss.errai.ioc.client.api.ManagedInstance)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertSame (org.junit.Assert.assertSame)1