Search in sources :

Example 1 with DataTypeEditModeToggleEvent

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);
}
Also used : DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent)

Example 2 with DataTypeEditModeToggleEvent

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));
}
Also used : DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent)

Example 3 with DataTypeEditModeToggleEvent

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();
}
Also used : DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent) Test(org.junit.Test)

Example 4 with DataTypeEditModeToggleEvent

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);
}
Also used : Consumer(java.util.function.Consumer) Menus(org.uberfire.workbench.model.menu.Menus) MenuItem(org.uberfire.workbench.model.menu.MenuItem) DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent) Test(org.junit.Test)

Example 5 with DataTypeEditModeToggleEvent

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);
}
Also used : Consumer(java.util.function.Consumer) Menus(org.uberfire.workbench.model.menu.Menus) MenuItem(org.uberfire.workbench.model.menu.MenuItem) DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent) Test(org.junit.Test)

Aggregations

DataTypeEditModeToggleEvent (org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent)9 Test (org.junit.Test)7 Consumer (java.util.function.Consumer)2 AbstractProjectDiagramEditorTest (org.kie.workbench.common.stunner.project.client.editor.AbstractProjectDiagramEditorTest)2 MenuItem (org.uberfire.workbench.model.menu.MenuItem)2 Menus (org.uberfire.workbench.model.menu.Menus)2