Search in sources :

Example 1 with DecisionTableSelectionsChangedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method makeUiModel.

// Instantiate UiModel overriding cell selection to inform MenuItems about changes to selected cells.
GuidedDecisionTableUiModel makeUiModel() {
    return new GuidedDecisionTableUiModel(synchronizer) {

        @Override
        public Range selectCell(final int rowIndex, final int columnIndex) {
            final Range rows = super.selectCell(rowIndex, columnIndex);
            decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
            return rows;
        }

        @Override
        public Range selectCells(final int rowIndex, final int columnIndex, final int width, final int height) {
            final Range rows = super.selectCells(rowIndex, columnIndex, width, height);
            decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
            return rows;
        }

        @Override
        public boolean isRowDraggingEnabled() {
            return access.isEditable();
        }

        @Override
        public boolean isColumnDraggingEnabled() {
            return access.isEditable();
        }

        @Override
        public Range deleteCell(int rowIndex, int columnIndex) {
            Range cellRange = super.deleteCell(rowIndex, columnIndex);
            decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
            return cellRange;
        }

        @Override
        public void deleteColumn(GridColumn<?> column) {
            super.deleteColumn(column);
            decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
        }

        @Override
        public Range deleteRow(int rowIndex) {
            Range rowRange = super.deleteRow(rowIndex);
            decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
            return rowRange;
        }
    };
}
Also used : GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) DecisionTableSelectionsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Example 2 with DecisionTableSelectionsChangedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent in project drools-wb by kiegroup.

the class CellContextMenuTest method testOnDecisionTableSelectionsChangedEventWithSelectionsWithClipboardPopulated.

@Test
public void testOnDecisionTableSelectionsChangedEventWithSelectionsWithClipboardPopulated() {
    model.getMetadataCols().add(new MetadataCol52());
    model.getData().add(new ArrayList<DTCellValue52>() {

        {
            add(new DTCellValue52(1));
            add(new DTCellValue52("descr"));
            add(new DTCellValue52("md"));
        }
    });
    uiModel.selectCell(0, 2);
    clipboard.setData(new HashSet<Clipboard.ClipboardData>() {

        {
            add(new DefaultClipboard.ClipboardDataImpl(0, 2, model.getData().get(0).get(2)));
        }
    });
    menu.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter));
    verify(view, times(1)).enableCutMenuItem(eq(true));
    verify(view, times(1)).enableCopyMenuItem(eq(true));
    verify(view, times(1)).enablePasteMenuItem(eq(true));
    verify(view, times(1)).enableDeleteCellMenuItem(eq(true));
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) DecisionTableSelectionsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 3 with DecisionTableSelectionsChangedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent in project drools-wb by kiegroup.

the class CellContextMenuTest method testOnDecisionTableSelectionsChangedEventWithNoSelections.

@Test
public void testOnDecisionTableSelectionsChangedEventWithNoSelections() {
    menu.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter));
    verify(view, times(1)).enableCutMenuItem(eq(false));
    verify(view, times(1)).enableCopyMenuItem(eq(false));
    verify(view, times(1)).enablePasteMenuItem(eq(false));
    verify(view, times(1)).enableDeleteCellMenuItem(eq(false));
}
Also used : DecisionTableSelectionsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent) Test(org.junit.Test)

Example 4 with DecisionTableSelectionsChangedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent in project drools-wb by kiegroup.

the class InsertMenuBuilderTest method testOnDecisionTableSelectionsChangedEventWithNoSelectionsAndItHasEditableColumns.

@Test
public void testOnDecisionTableSelectionsChangedEventWithNoSelectionsAndItHasEditableColumns() {
    builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter));
    assertTrue(builder.miAppendRow.getMenuItem().isEnabled());
    assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled());
    assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled());
    assertTrue(builder.miInsertColumn.getMenuItem().isEnabled());
}
Also used : DecisionTableSelectionsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent) Test(org.junit.Test)

Example 5 with DecisionTableSelectionsChangedEvent

use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent in project drools-wb by kiegroup.

the class InsertMenuBuilderTest method testOnDecisionTableSelectionsChangedEventWithMultipleRowsSelectedAndItHasEditableColumns.

@Test
public void testOnDecisionTableSelectionsChangedEventWithMultipleRowsSelectedAndItHasEditableColumns() {
    model.getConditions().add(makePattern52());
    model.getData().add(makeDTCellValue52List());
    model.getData().add(makeDTCellValue52List());
    uiModel.selectCells(0, 2, 1, 2);
    builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter));
    assertTrue(builder.miAppendRow.getMenuItem().isEnabled());
    assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled());
    assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled());
    assertTrue(builder.miInsertColumn.getMenuItem().isEnabled());
}
Also used : DecisionTableSelectionsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent) Test(org.junit.Test)

Aggregations

DecisionTableSelectionsChangedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent)23 Test (org.junit.Test)22 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)8 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)5 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)1 GuidedDecisionTableUiModel (org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel)1 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)1