use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn 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.BaseColumn in project drools-wb by kiegroup.
the class BaseColumnSynchronizer method findTargetActionIndex.
protected int findTargetActionIndex(final MoveColumnToMetaData md) throws ModelSynchronizer.MoveVetoException {
int tgtActionIndex = -1;
final int tgtColumnIndex = md.getTargetColumnIndex();
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
final List<ActionCol52> allModelActions = model.getActionCols();
for (int actionIndex = 0; actionIndex < allModelActions.size(); actionIndex++) {
final ActionCol52 ac = allModelActions.get(actionIndex);
final List<ActionCol52> children = getChildren(ac);
if (children == null || children.isEmpty()) {
continue;
}
final BaseColumn firstChild = children.get(0);
final BaseColumn lastChild = children.get(children.size() - 1);
final int firstChildIndex = allModelColumns.indexOf(firstChild);
final int lastChildIndex = allModelColumns.indexOf(lastChild);
if (tgtColumnIndex >= firstChildIndex && tgtColumnIndex <= lastChildIndex) {
tgtActionIndex = actionIndex;
break;
}
}
if (tgtActionIndex < 0) {
throw new ModelSynchronizer.MoveVetoException();
}
return tgtActionIndex;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ColumnHeaderPopOverImpl method showSource.
private void showSource(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) {
final BaseColumn column = dtPresenter.getModel().getExpandedColumns().get(uiColumnIndex);
final int screenX = getScreenX(modellerView, dtPresenter, uiColumnIndex);
final int screenY = getScreenY(modellerView, dtPresenter);
view.show((Callback<PopOverView.Content> callback) -> columnDefinitionFactory.generateColumnDefinition(dtPresenter, column, (String definition) -> callback.callback(new PopOverView.Content() {
@Override
public String getContent() {
return definition;
}
@Override
public int getX() {
return screenX;
}
@Override
public int getY() {
return screenY;
}
})));
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLConditionColumnSynchronizer method moveColumnsTo.
@Override
public void moveColumnsTo(final List<MoveColumnToMetaData> metaData) throws VetoException {
// Check operation is supported
if (!handlesMoveColumnsTo(metaData)) {
return;
}
final MoveColumnToMetaData md = metaData.get(0);
final LimitedEntryBRLConditionColumn modelColumn = (LimitedEntryBRLConditionColumn) md.getColumn();
final List<CompositeColumn<? extends BaseColumn>> modelConditionColumns = model.getConditions();
final int modelConditionColumnCount = modelConditionColumns.size();
if (modelConditionColumnCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
final int minColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(0));
final int maxColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(modelConditionColumnCount - 1));
final int targetColumnIndex = md.getTargetColumnIndex();
final int sourceColumnIndex = md.getSourceColumnIndex();
if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
throw new ModelSynchronizer.MoveVetoException();
}
moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
modelConditionColumns.remove(modelColumn);
modelConditionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ModelSynchronizerImpl method setCellOtherwiseState.
@Override
public void setCellOtherwiseState(final int rowIndex, final int columnIndex) {
final BaseColumn modelColumn = model.getExpandedColumns().get(columnIndex);
final DTCellValue52 modelCell = model.getData().get(rowIndex).get(columnIndex);
modelCell.clearValues();
modelCell.setOtherwise(true);
// BaseGridData is sparsely populated; only add values if needed.
if (modelCell.hasValue()) {
uiModel.setCellValueInternal(rowIndex, columnIndex, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
}
uiModel.indexColumn(columnIndex);
}
Aggregations