use of org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent in project kie-wb-common by kiegroup.
the class DataTypeListItem method enableEditMode.
public void enableEditMode() {
if (view.isOnFocusMode()) {
return;
}
oldName = getDataType().getName();
oldType = getDataType().getType();
oldConstraint = getDataType().getConstraint();
oldIsList = getDataType().isList();
oldConstraintType = getDataType().getConstraintType();
view.showSaveButton();
view.showDataTypeNameInput();
view.showListContainer();
view.hideListYesLabel();
view.enableFocusMode();
dataTypeSelectComponent.enableEditMode();
dataTypeConstraintComponent.enableEditMode();
editModeToggleEvent.fire(new DataTypeEditModeToggleEvent(true, this));
dataTypeList.fireOnDataTypeListItemUpdateCallback(this);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent in project kie-wb-common by kiegroup.
the class DataTypeListItem method closeEditMode.
void closeEditMode() {
view.hideDataTypeNameInput();
view.hideListContainer();
view.showEditButton();
view.disableFocusMode();
refreshListYesLabel();
dataTypeSelectComponent.disableEditMode();
dataTypeConstraintComponent.disableEditMode();
editModeToggleEvent.fire(new DataTypeEditModeToggleEvent(false, this));
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent in project kie-wb-common by kiegroup.
the class DataTypeListTest method testOnDataTypeEditModeToggleChangedCurrentEditingItem.
@Test
public void testOnDataTypeEditModeToggleChangedCurrentEditingItem() {
final DataTypeListItem currentEditingItem = mock(DataTypeListItem.class);
final DataTypeListItem previousEditingItem = mock(DataTypeListItem.class);
final List<DataTypeListItem> listItems = asList(currentEditingItem, previousEditingItem);
doReturn(listItems).when(dataTypeList).getItems();
final DataTypeEditModeToggleEvent event = new DataTypeEditModeToggleEvent(true, currentEditingItem);
dataTypeList.setCurrentEditingItem(previousEditingItem);
dataTypeList.onDataTypeEditModeToggle(event);
final DataTypeListItem actual = dataTypeList.getCurrentEditingItem();
verify(searchBar).reset();
assertEquals(currentEditingItem, actual);
verify(previousEditingItem).disableEditMode();
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent in project kie-wb-common by kiegroup.
the class DMNDiagramEditorTest method testOnDataTypeEditModeToggleWhenEditModeIsNotEnabled.
@Test
@SuppressWarnings("unchecked")
public void testOnDataTypeEditModeToggleWhenEditModeIsNotEnabled() {
final DataTypeEditModeToggleEvent event = mock(DataTypeEditModeToggleEvent.class);
final MenuItem menuItem = mock(MenuItem.class);
final Menus menus = mock(Menus.class);
final List<MenuItem> items = singletonList(menuItem);
when(menus.getItems()).thenReturn(items);
when(event.isEditModeEnabled()).thenReturn(false);
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, Consumer.class).accept(menus);
return null;
}).when(editor).getMenu(any());
editor.onDataTypeEditModeToggle(event);
verify(menuItem).setEnabled(true);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent in project kie-wb-common by kiegroup.
the class DMNDiagramEditorTest method testOnDataTypeEditModeToggleWhenEditModeIsEnabled.
@Test
@SuppressWarnings("unchecked")
public void testOnDataTypeEditModeToggleWhenEditModeIsEnabled() {
final DataTypeEditModeToggleEvent event = mock(DataTypeEditModeToggleEvent.class);
final MenuItem menuItem = mock(MenuItem.class);
final Menus menus = mock(Menus.class);
final List<MenuItem> items = singletonList(menuItem);
when(menus.getItems()).thenReturn(items);
when(event.isEditModeEnabled()).thenReturn(true);
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, Consumer.class).accept(menus);
return null;
}).when(editor).getMenu(any());
editor.onDataTypeEditModeToggle(event);
verify(menuItem).setEnabled(false);
}
Aggregations