use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class GuidedDecisionTableSalienceBuilder method populateDecisionTable.
@Override
public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
final AttributeCol52 column = new AttributeCol52();
column.setAttribute(GuidedDecisionTable52.SALIENCE_ATTR);
// If sequential set column to use reverse row number
if (isSequential) {
column.setUseRowNumber(true);
column.setReverseOrder(true);
final int maxRow = this.values.size();
for (int iRow = 0; iRow < maxRow; iRow++) {
final DTCellValue52 dcv = this.values.get(iRow);
dcv.setNumericValue(Integer.valueOf(maxRow - iRow));
}
}
dtable.getAttributeCols().add(column);
if (this.values.size() < maxRowCount) {
for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
final DTCellValue52 dcv = new DTCellValue52(0);
this.values.add(dcv);
}
}
addColumnData(dtable, column);
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnConfigRow method init.
public void init(final AttributeCol52 attributeColumn, final GuidedDecisionTableModellerView.Presenter presenter) {
view.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
view.addColumnLabel(attributeColumn);
final AttributeCol52 originalColumn = attributeColumn;
if (attributeColumn.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) {
useRowNumberCheckBox = view.addUseRowNumberCheckBox(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> {
final AttributeCol52 editedColumn = originalColumn.cloneColumn();
editedColumn.setUseRowNumber(useRowNumberCheckBox.getValue());
reverseOrderCheckBox.setEnabled(useRowNumberCheckBox.getValue());
try {
final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
if (dtPresenter.isPresent()) {
dtPresenter.get().updateColumn(originalColumn, editedColumn);
}
} catch (VetoException veto) {
presenter.getView().showGenericVetoMessage();
}
});
view.add(new Span("("));
reverseOrderCheckBox = view.addReverseOrderCheckBox(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> {
final AttributeCol52 editedColumn = originalColumn.cloneColumn();
editedColumn.setReverseOrder(reverseOrderCheckBox.getValue());
try {
final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
if (dtPresenter.isPresent()) {
dtPresenter.get().updateColumn(originalColumn, editedColumn);
}
} catch (VetoException veto) {
presenter.getView().showGenericVetoMessage();
}
});
view.add(new Span(")"));
}
view.addDefaultValue(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> {
final AttributeCol52 editedColumn = originalColumn.cloneColumn();
editedColumn.setDefaultValue(event.getEditedDefaultValue());
try {
final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
if (dtPresenter.isPresent()) {
dtPresenter.get().updateColumn(originalColumn, editedColumn);
}
} catch (VetoException veto) {
presenter.getView().showGenericVetoMessage();
}
});
hideColumnCheckBox = view.addHideColumnCheckBox(attributeColumn, (event) -> {
final AttributeCol52 editedColumn = originalColumn.cloneColumn();
editedColumn.setHideColumn(hideColumnCheckBox.getValue());
try {
final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
if (dtPresenter.isPresent()) {
dtPresenter.get().updateColumn(originalColumn, editedColumn);
}
} catch (VetoException veto) {
presenter.getView().showGenericVetoMessage();
}
});
addRemoveAttributeButton(attributeColumn, presenter);
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnConverter method convertColumn.
@Override
public GridColumn<?> convertColumn(final BaseColumn column, final GuidedDecisionTablePresenter.Access access, final GuidedDecisionTableView gridWidget) {
final AttributeCol52 attributeColumn = (AttributeCol52) column;
final String attributeName = attributeColumn.getAttribute();
if (attributeName.equals(RuleAttributeWidget.SALIENCE_ATTR)) {
return newSalienceColumn(makeSalienceHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH + 30), true, !column.isHideColumn(), access, attributeColumn.isUseRowNumber(), gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.ENABLED_ATTR)) {
return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.NO_LOOP_ATTR)) {
return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.DURATION_ATTR)) {
return newLongColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.TIMER_ATTR)) {
return newStringColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.CALENDARS_ATTR)) {
return newStringColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.AUTO_FOCUS_ATTR)) {
return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.LOCK_ON_ACTIVE_ATTR)) {
return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.DATE_EFFECTIVE_ATTR)) {
return newDateColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.DATE_EXPIRES_ATTR)) {
return newDateColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.DIALECT_ATTR)) {
return newDialectColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
} else if (attributeName.equals(GuidedDecisionTable52.NEGATE_RULE_ATTR)) {
return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
}
return newStringColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnSynchronizer 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 AttributeCol52 modelColumn = (AttributeCol52) md.getColumn();
final List<AttributeCol52> modelAttributeColumns = model.getAttributeCols();
final int modelAttributeColumnCount = modelAttributeColumns.size();
if (modelAttributeColumnCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
final int minColumnIndex = allModelColumns.indexOf(modelAttributeColumns.get(0));
final int maxColumnIndex = allModelColumns.indexOf(modelAttributeColumns.get(modelAttributeColumnCount - 1));
final int targetColumnIndex = md.getTargetColumnIndex();
final int sourceColumnIndex = md.getSourceColumnIndex();
if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
throw new ModelSynchronizer.MoveVetoException();
}
moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
modelAttributeColumns.remove(modelColumn);
modelAttributeColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.
the class AttributeColumnSynchronizer method append.
@Override
public void append(final ColumnMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesAppend(metaData)) {
return;
}
final AttributeCol52 column = (AttributeCol52) metaData.getColumn();
model.getAttributeCols().add(column);
synchroniseAppendColumn(column);
}
Aggregations