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();
}
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();
}
}
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();
}
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);
}
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();
}
Aggregations