use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class PluginHandlerTest method testEditWhenColumnIsABRLActionColumn.
@Test
public void testEditWhenColumnIsABRLActionColumn() {
final BRLActionColumn originalColumn = mock(BRLActionColumn.class);
final BRLActionColumnPlugin plugin = spy(new BRLActionColumnPlugin(ruleModellerPage, new MockInstanceImpl<>(new ArrayList<>()), additionalInfoPage, event, translationService));
testEditActionColumn(plugin, brlActionColumnPlugin, originalColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class ColumnManagementViewTest method testRenderColumnActionsNotEditable.
@Test
public void testRenderColumnActionsNotEditable() throws Exception {
final BRLActionColumn brlActionColumn = mock(BRLActionColumn.class);
final ActionInsertFactCol52 actionInsertFactColumn = mock(ActionInsertFactCol52.class);
final ActionRetractFactCol52 retractFactColumn = mock(ActionRetractFactCol52.class);
final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {
{
put(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), Arrays.asList(brlActionColumn, actionInsertFactColumn, retractFactColumn));
}
};
final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
view.renderColumns(columnGroups);
verify(view).renderColumn(brlActionColumn);
verify(view).renderColumn(actionInsertFactColumn);
verify(view).renderColumn(retractFactColumn);
// There are three action columns
verify(horizontalPanel, times(3)).add(columnLabel);
verify(view, times(3)).editAnchor(any(ClickHandler.class));
verify(view, never()).deleteAnchor(eq("one"), any(Command.class));
verify(view, never()).deleteAnchor(eq("two"), any(Command.class));
verify(view, never()).deleteAnchor(eq("three"), any(Command.class));
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class ColumnManagementViewTest method testRenderColumnActionsEditable.
@Test
public void testRenderColumnActionsEditable() throws Exception {
final BRLActionColumn brlActionColumn = mock(BRLActionColumn.class);
final ActionInsertFactCol52 actionInsertFactColumn = mock(ActionInsertFactCol52.class);
final ActionRetractFactCol52 retractFactColumn = mock(ActionRetractFactCol52.class);
final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {
{
put(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), Arrays.asList(brlActionColumn, actionInsertFactColumn, retractFactColumn));
}
};
final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
doReturn(true).when(modellerPresenter).isActiveDecisionTableEditable();
doReturn("one").when(brlActionColumn).getHeader();
doReturn("two").when(actionInsertFactColumn).getHeader();
doReturn("three").when(retractFactColumn).getHeader();
view.renderColumns(columnGroups);
verify(view).renderColumn(brlActionColumn);
verify(view).renderColumn(actionInsertFactColumn);
verify(view).renderColumn(retractFactColumn);
// There are three action columns
verify(horizontalPanel, times(3)).add(columnLabel);
verify(view, times(3)).editAnchor(clickHandlerCaptor.capture());
verify(view).deleteAnchor(eq("one"), deleteCommandCaptor.capture());
verify(view).deleteAnchor(eq("two"), deleteCommandCaptor.capture());
verify(view).deleteAnchor(eq("three"), deleteCommandCaptor.capture());
clickHandlerCaptor.getAllValues().get(0).onClick(mock(ClickEvent.class));
verify(decisionTablePresenter).editAction(eq(brlActionColumn));
clickHandlerCaptor.getAllValues().get(1).onClick(mock(ClickEvent.class));
verify(decisionTablePresenter).editAction(eq(actionInsertFactColumn));
clickHandlerCaptor.getAllValues().get(2).onClick(mock(ClickEvent.class));
verify(decisionTablePresenter).editAction(eq(retractFactColumn));
deleteCommandCaptor.getAllValues().get(0).execute();
verify(decisionTablePresenter).deleteColumn(brlActionColumn);
deleteCommandCaptor.getAllValues().get(1).execute();
verify(decisionTablePresenter).deleteColumn(actionInsertFactColumn);
deleteCommandCaptor.getAllValues().get(2).execute();
verify(decisionTablePresenter).deleteColumn(retractFactColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class BRLActionColumnSynchronizer method doMoveBRLFragment.
private void doMoveBRLFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
final MoveColumnToMetaData md = metaData.get(0);
final BRLActionVariableColumn srcModelColumn = (BRLActionVariableColumn) md.getColumn();
final BRLActionColumn srcModelBRLFragment = model.getBRLColumn(srcModelColumn);
if (srcModelBRLFragment == null) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<BRLActionVariableColumn> srcModelBRLFragmentColumns = srcModelBRLFragment.getChildColumns();
final int srcModelBRLFragmentColumnsCount = srcModelBRLFragmentColumns.size();
if (srcModelBRLFragmentColumnsCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
if (srcModelBRLFragmentColumnsCount != metaData.size()) {
throw new ModelSynchronizer.MoveVetoException();
}
final int tgtColumnIndex = md.getTargetColumnIndex();
final int tgtActionIndex = findTargetActionIndex(md);
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)), allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)) + srcModelBRLFragmentColumnsCount - 1);
model.getActionCols().remove(srcModelBRLFragment);
model.getActionCols().add(tgtActionIndex, srcModelBRLFragment);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class BRLActionColumnSynchronizer method append.
@Override
public void append(final ColumnMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesAppend(metaData)) {
return;
}
final BRLActionColumn column = (BRLActionColumn) metaData.getColumn();
model.getActionCols().add(column);
for (BRLActionVariableColumn childModelColumn : column.getChildColumns()) {
synchroniseAppendColumn(childModelColumn);
}
}
Aggregations