use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer in project drools-wb by kiegroup.
the class BaseGuidedDecisionTablePresenterTest method setupPresenter.
protected GuidedDecisionTablePresenter setupPresenter() {
final GuidedDecisionTablePresenter wrapped = new GuidedDecisionTablePresenter(identity, resourceType, ruleNameServiceCaller, decisionTableSelectedEvent, decisionTableColumnSelectedEvent, decisionTableSelectionsChangedEvent, refreshAttributesPanelEvent, refreshMetaDataPanelEvent, refreshConditionsPanelEvent, refreshActionsPanelEvent, refreshMenusEvent, notificationEvent, gridWidgetCellFactory, gridWidgetColumnFactory, oracleFactory, synchronizer, beanManager, lockManager, linkManager, clipboard, decisionTableAnalyzerProvider, enumLoaderUtilities, pluginHandler, authorizationManager, sessionInfo) {
@Override
void initialiseLockManager() {
// Do nothing for tests
}
@Override
GuidedDecisionTableRenderer makeViewRenderer() {
return renderer;
}
@Override
GuidedDecisionTableView makeView(final Set<PortableWorkDefinition> workItemDefinitions) {
return view;
}
@Override
void initialiseAuditLog() {
// Do nothing for tests
}
@Override
List<BaseColumnConverter> getConverters() {
final List<BaseColumnConverter> converters = new ArrayList<BaseColumnConverter>();
converters.add(new ActionInsertFactColumnConverter());
converters.add(new ActionRetractFactColumnConverter());
converters.add(new ActionSetFieldColumnConverter());
converters.add(new ActionWorkItemExecuteColumnConverter());
converters.add(new ActionWorkItemInsertFactColumnConverter());
converters.add(new ActionWorkItemSetFieldColumnConverter());
converters.add(new AttributeColumnConverter());
converters.add(new BRLActionVariableColumnConverter());
converters.add(new BRLConditionVariableColumnConverter());
converters.add(new ConditionColumnConverter());
converters.add(new DescriptionColumnConverter());
converters.add(new LimitedEntryColumnConverter());
converters.add(new MetaDataColumnConverter());
converters.add(new RowNumberColumnConverter());
return converters;
}
@Override
List<Synchronizer<? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData>> getSynchronizers() {
final List<Synchronizer<? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData>> synchronizers = new ArrayList<>();
synchronizers.add(new ActionColumnSynchronizer());
synchronizers.add(new ActionInsertFactColumnSynchronizer());
synchronizers.add(new ActionRetractFactColumnSynchronizer());
synchronizers.add(new ActionSetFieldColumnSynchronizer());
synchronizers.add(new ActionWorkItemExecuteColumnSynchronizer());
synchronizers.add(new ActionWorkItemInsertFactColumnSynchronizer());
synchronizers.add(new ActionWorkItemSetFieldColumnSynchronizer());
synchronizers.add(new AttributeColumnSynchronizer());
synchronizers.add(new BRLActionColumnSynchronizer());
synchronizers.add(new BRLConditionColumnSynchronizer());
synchronizers.add(new ConditionColumnSynchronizer());
synchronizers.add(new LimitedEntryBRLActionColumnSynchronizer());
synchronizers.add(new LimitedEntryBRLConditionColumnSynchronizer());
synchronizers.add(new MetaDataColumnSynchronizer());
synchronizers.add(new RowSynchronizer());
return synchronizers;
}
};
GuidedDecisionTablePresenter presenter = spy(wrapped);
model = new GuidedDecisionTable52();
final PackageDataModelOracleBaselinePayload dmoBaseline = mock(PackageDataModelOracleBaselinePayload.class);
final Set<PortableWorkDefinition> workItemDefinitions = Collections.emptySet();
final Overview overview = mock(Overview.class);
dtContent = new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dmoBaseline);
when(oracleFactory.makeAsyncPackageDataModelOracle(any(Path.class), any(GuidedDecisionTable52.class), eq(dmoBaseline))).thenReturn(oracle);
when(view.getLayer()).thenReturn(gridLayer);
when(modellerPresenter.getView()).thenReturn(modellerView);
when(modellerView.getGridLayerView()).thenReturn(gridLayer);
when(presenter.getModellerPresenter()).thenReturn(modellerPresenter);
presenter.setContent(dtPath, dtPlaceRequest, dtContent, modellerPresenter, false);
return presenter;
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer in project drools-wb by kiegroup.
the class BaseSynchronizerTest method setup.
@Before
public void setup() {
// Setup model related classes
model = new GuidedDecisionTable52();
uiModel = new GuidedDecisionTableUiModel(modelSynchronizer);
incrementalDataModelServiceCaller = new CallerMock<>(incrementalDataModelService);
final BRLRuleModel rm = new BRLRuleModel(model);
final CellUtilities cellUtilities = new CellUtilities();
final ColumnUtilities columnUtilities = new ColumnUtilities(model, oracle);
final DependentEnumsUtilities enumsUtilities = new DependentEnumsUtilities(model, oracle);
final GridWidgetCellFactory gridWidgetCellFactory = new GridWidgetCellFactoryImpl();
// Setup mocks
final GuidedDecisionTableModellerView.Presenter modellerPresenter = mock(GuidedDecisionTableModellerView.Presenter.class);
final GuidedDecisionTableModellerView modellerView = mock(GuidedDecisionTableModellerView.class);
final GridLayer gridLayer = mock(GridLayer.class);
final AbsolutePanel domElementContainer = mock(AbsolutePanel.class);
final GuidedDecisionTableView.Presenter dtablePresenter = mock(GuidedDecisionTableView.Presenter.class);
final EventBus eventBus = mock(EventBus.class);
when(dtablePresenter.getModellerPresenter()).thenReturn(modellerPresenter);
when(modellerPresenter.getView()).thenReturn(modellerView);
when(modellerView.getGridLayerView()).thenReturn(gridLayer);
when(gridLayer.getDomElementContainer()).thenReturn(domElementContainer);
when(domElementContainer.iterator()).thenReturn(mock(Iterator.class));
// Setup column converters
final List<BaseColumnConverter> converters = getConverters();
gridWidgetColumnFactory.setConverters(converters);
gridWidgetColumnFactory.initialise(model, oracle, columnUtilities, dtablePresenter);
// Setup synchronizers
final List<Synchronizer<? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData>> synchronizers = getSynchronizers();
modelSynchronizer.setSynchronizers(synchronizers);
modelSynchronizer.initialise(model, uiModel, cellUtilities, columnUtilities, enumsUtilities, gridWidgetCellFactory, gridWidgetColumnFactory, view, rm, eventBus, editable);
// Dummy columns for Row number and Description
uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new RowNumberCol52(), readOnly, view));
uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new DescriptionCol52(), readOnly, view));
ApplicationPreferences.setUp(new HashMap<String, String>() {
{
put(ApplicationPreferences.DATE_FORMAT, "dd-MM-yyyy");
}
});
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer in project drools-wb by kiegroup.
the class ModelSynchronizerImpl method moveColumnsTo.
@Override
@SuppressWarnings("unchecked")
public void moveColumnsTo(final int targetColumnIndex, final List<GridColumn<?>> columns) throws VetoException {
// Generate meta-data to handle moves
final List<MoveColumnToMetaData> metaData = new ArrayList<MoveColumnToMetaData>();
for (int index = 0; index < columns.size(); index++) {
final GridColumn<?> column = columns.get(index);
final int sourceColumnIndex = uiModel.getColumns().indexOf(column);
if (sourceColumnIndex == targetColumnIndex) {
throw new MoveVetoException();
}
final BaseColumn modelColumn = model.getExpandedColumns().get(sourceColumnIndex);
metaData.add(new MoveColumnToMetaDataImpl(sourceColumnIndex, targetColumnIndex + index, modelColumn));
}
Synchronizer handler = null;
for (Synchronizer synchronizer : synchronizers) {
if (synchronizer.handlesMoveColumnsTo(metaData)) {
handler = synchronizer;
break;
}
}
if (handler == null) {
throw new MoveVetoException();
}
handler.moveColumnsTo(metaData);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer in project drools-wb by kiegroup.
the class ModelSynchronizerImpl method moveColumnTo.
@Override
@SuppressWarnings("unchecked")
public void moveColumnTo(final int targetColumnIndex, final GridColumn<?> column) throws VetoException {
final int sourceColumnIndex = uiModel.getColumns().indexOf(column);
if (sourceColumnIndex == targetColumnIndex) {
throw new MoveVetoException();
}
final BaseColumn modelColumn = model.getExpandedColumns().get(sourceColumnIndex);
final List<MoveColumnToMetaData> metaData = new ArrayList<MoveColumnToMetaData>() {
{
add(new MoveColumnToMetaDataImpl(sourceColumnIndex, targetColumnIndex, modelColumn));
}
};
final List<Synchronizer> handlers = new ArrayList<Synchronizer>();
for (Synchronizer synchronizer : synchronizers) {
if (synchronizer.handlesMoveColumnsTo(metaData)) {
handlers.add(synchronizer);
}
}
if (handlers.isEmpty()) {
throw new MoveVetoException();
}
for (Synchronizer synchronizer : handlers) {
synchronizer.moveColumnsTo(metaData);
}
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer in project drools-wb by kiegroup.
the class ModelSynchronizerImpl method appendColumn.
@Override
@SuppressWarnings("unchecked")
public void appendColumn(final Pattern52 pattern, final ConditionCol52 column) throws VetoException {
final PatternConditionMetaData metaData = new PatternConditionMetaData(pattern, column);
for (Synchronizer synchronizer : synchronizers) {
if (synchronizer.handlesAppend(metaData)) {
synchronizer.append(metaData);
break;
}
}
fireAfterColumnInsertedEvent(column);
}
Aggregations