Search in sources :

Example 51 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class ActionSetFieldsPageViewImpl method initialiseChosenFields.

private void initialiseChosenFields() {
    chosenFieldsContainer.add(chosenFieldsWidget);
    chosenFieldsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    chosenFieldsWidget.setMinimumWidth(170);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenFields());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    chosenFieldsWidget.setEmptyListWidget(lstEmpty);
    final MultiSelectionModel<ActionSetFieldCol52> selectionModel = new MultiSelectionModel<ActionSetFieldCol52>(System::identityHashCode);
    chosenFieldsWidget.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(final SelectionChangeEvent event) {
            chosenFieldsSelections = selectionModel.getSelectedSet();
            chosenConditionsSelected(chosenFieldsSelections);
        }

        private void chosenConditionsSelected(final Set<ActionSetFieldCol52> cws) {
            btnRemove.setEnabled(true);
            if (cws.size() == 1) {
                chosenFieldsSelection = cws.iterator().next();
                fieldDefinition.setVisible(true);
                validateFieldHeader();
                populateFieldDefinition();
            } else {
                chosenFieldsSelection = null;
                fieldDefinition.setVisible(false);
                txtColumnHeader.setEnabled(false);
                txtValueList.setEnabled(false);
                defaultValueContainer.setVisible(false);
                chkUpdateEngine.setEnabled(false);
            }
        }

        private void populateFieldDefinition() {
            // Fields common to all table formats
            txtColumnHeader.setEnabled(true);
            chkUpdateEngine.setEnabled(true);
            txtColumnHeader.setText(chosenFieldsSelection.getHeader());
            chkUpdateEngine.setValue(chosenFieldsSelection.isUpdate());
            criteriaExtendedEntry.setVisible(presenter.getTableFormat() == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
            criteriaLimitedEntry.setVisible(presenter.getTableFormat() == GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
            // Fields specific to the table format
            switch(presenter.getTableFormat()) {
                case EXTENDED_ENTRY:
                    txtValueList.setEnabled(!presenter.hasEnums(chosenFieldsSelection));
                    txtValueList.setText(chosenFieldsSelection.getValueList());
                    makeDefaultValueWidget();
                    defaultValueContainer.setVisible(true);
                    break;
                case LIMITED_ENTRY:
                    makeLimitedValueWidget();
                    limitedEntryValueContainer.setVisible(true);
                    break;
            }
        }

        private void makeLimitedValueWidget() {
            if (!(chosenFieldsSelection instanceof LimitedEntryActionSetFieldCol52)) {
                return;
            }
            final LimitedEntryActionSetFieldCol52 lea = (LimitedEntryActionSetFieldCol52) chosenFieldsSelection;
            if (lea.getValue() == null) {
                lea.setValue(factory.makeNewValue(availablePatternsSelection, chosenFieldsSelection));
            }
            limitedEntryValueWidgetContainer.setWidget(factory.getWidget(availablePatternsSelection, chosenFieldsSelection, lea.getValue()));
        }
    });
}
Also used : MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)

Example 52 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class ActionSetFieldsPageViewImpl method btnRemoveClick.

@UiHandler(value = "btnRemove")
public void btnRemoveClick(final ClickEvent event) {
    for (ActionSetFieldCol52 a : chosenFieldsSelections) {
        chosenFields.remove(a);
    }
    chosenFieldsSelections.clear();
    setChosenFields(chosenFields);
    presenter.stateChanged();
    txtColumnHeader.setText("");
    txtValueList.setText("");
    defaultValueContainer.setVisible(false);
    fieldDefinition.setVisible(false);
    btnRemove.setEnabled(false);
}
Also used : ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 53 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class DependentEnumsUtilities method getCurrentValueMap.

/**
 * Create a map of Field Values keyed on Field Names used by
 * SuggestionCompletionEngine.getEnums(String, String, Map<String, String>)
 * to drive dependent enumerations.
 *
 * @param context The Context of the cell being edited containing physical
 *                coordinate in the data-space.
 */
@Override
public Map<String, String> getCurrentValueMap(final Context context) {
    Map<String, String> currentValueMap = new HashMap<String, String>();
    final int iBaseRowIndex = context.getRowIndex();
    final int iBaseColIndex = context.getColumnIndex();
    final List<DTCellValue52> rowData = this.model.getData().get(iBaseRowIndex);
    // Get the column for the cell being edited
    final List<BaseColumn> allColumns = this.model.getExpandedColumns();
    final BaseColumn baseColumn = allColumns.get(iBaseColIndex);
    // Get values for all Constraints or Actions on the same pattern as the baseColumn
    if (baseColumn instanceof BRLConditionVariableColumn) {
        final BRLConditionVariableColumn baseBRLConditionColumn = (BRLConditionVariableColumn) baseColumn;
        final BRLConditionColumn brl = model.getBRLColumn(baseBRLConditionColumn);
        final RuleModel rm = new RuleModel();
        IPattern[] lhs = new IPattern[brl.getDefinition().size()];
        brl.getDefinition().toArray(lhs);
        rm.lhs = lhs;
        final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(rm, baseBRLConditionColumn.getVarName());
        List<ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
        // Add other variables values
        for (ValueHolder valueHolder : peerVariables) {
            switch(valueHolder.getType()) {
                case TEMPLATE_KEY:
                    final BRLConditionVariableColumn vc = getConditionVariableColumnIndex(brl.getChildColumns(), valueHolder.getValue());
                    final int iCol = allColumns.indexOf(vc);
                    final DTCellValue52 dcv = rowData.get(iCol);
                    final String field = vc.getFactField();
                    currentValueMap.put(field, cellUtilities.asString(dcv));
                    break;
                case VALUE:
                    currentValueMap.put(valueHolder.getFieldName(), valueHolder.getValue());
            }
        }
    } else if (baseColumn instanceof BRLActionVariableColumn) {
        final BRLActionVariableColumn baseBRLActionColumn = (BRLActionVariableColumn) baseColumn;
        final BRLActionColumn brl = model.getBRLColumn(baseBRLActionColumn);
        final RuleModel rm = new RuleModel();
        IAction[] rhs = new IAction[brl.getDefinition().size()];
        brl.getDefinition().toArray(rhs);
        rm.rhs = rhs;
        final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(rm, baseBRLActionColumn.getVarName());
        List<ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
        // Add other variables values
        for (ValueHolder valueHolder : peerVariables) {
            switch(valueHolder.getType()) {
                case TEMPLATE_KEY:
                    final BRLActionVariableColumn vc = getActionVariableColumnIndex(brl.getChildColumns(), valueHolder.getValue());
                    final int iCol = allColumns.indexOf(vc);
                    final DTCellValue52 dcv = rowData.get(iCol);
                    final String field = vc.getFactField();
                    currentValueMap.put(field, cellUtilities.asString(dcv));
                    break;
                case VALUE:
                    currentValueMap.put(valueHolder.getFieldName(), valueHolder.getValue());
            }
        }
    } else if (baseColumn instanceof ConditionCol52) {
        final ConditionCol52 baseConditionColumn = (ConditionCol52) baseColumn;
        final Pattern52 basePattern = this.model.getPattern(baseConditionColumn);
        for (ConditionCol52 cc : basePattern.getChildColumns()) {
            final int iCol = allColumns.indexOf(cc);
            final DTCellValue52 dcv = rowData.get(iCol);
            currentValueMap.put(cc.getFactField(), cellUtilities.asString(dcv));
        }
    } else if (baseColumn instanceof ActionSetFieldCol52) {
        ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52) baseColumn;
        final String binding = baseActionColumn.getBoundName();
        for (ActionCol52 ac : this.model.getActionCols()) {
            if (ac instanceof ActionSetFieldCol52) {
                final ActionSetFieldCol52 asf = (ActionSetFieldCol52) ac;
                if (asf.getBoundName().equals(binding)) {
                    final int iCol = allColumns.indexOf(asf);
                    final DTCellValue52 dcv = rowData.get(iCol);
                    currentValueMap.put(asf.getFactField(), cellUtilities.asString(dcv));
                }
            }
        }
    } else if (baseColumn instanceof ActionInsertFactCol52) {
        ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52) baseColumn;
        final String binding = baseActionColumn.getBoundName();
        for (ActionCol52 ac : this.model.getActionCols()) {
            if (ac instanceof ActionInsertFactCol52) {
                final ActionInsertFactCol52 aif = (ActionInsertFactCol52) ac;
                if (aif.getBoundName().equals(binding)) {
                    final int iCol = allColumns.indexOf(aif);
                    final DTCellValue52 dcv = rowData.get(iCol);
                    currentValueMap.put(aif.getFactField(), cellUtilities.asString(dcv));
                }
            }
        }
    }
    return currentValueMap;
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) HashMap(java.util.HashMap) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ValueHolder(org.drools.workbench.screens.guided.template.client.editor.RuleModelPeerVariableVisitor.ValueHolder) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) RuleModelPeerVariableVisitor(org.drools.workbench.screens.guided.template.client.editor.RuleModelPeerVariableVisitor) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) List(java.util.List) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 54 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class ActionSetFieldColumnConverter method makeHeaderMetaData.

@Override
public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) {
    return new ArrayList<GridColumn.HeaderMetaData>() {

        {
            if (column instanceof ActionSetFieldCol52) {
                ActionSetFieldCol52 actionSetFieldColumn = (ActionSetFieldCol52) column;
                if (actionSetFieldColumn.getBoundName() != null && !actionSetFieldColumn.getBoundName().isEmpty()) {
                    add(new BaseHeaderMetaData(actionSetFieldColumn.getBoundName(), ActionCol52.class.getName()));
                    add(new BaseHeaderMetaData(column.getHeader(), actionSetFieldColumn.getBoundName()));
                }
            } else {
                add(new BaseHeaderMetaData(column.getHeader(), ActionCol52.class.getName()));
            }
        }
    };
}
Also used : ArrayList(java.util.ArrayList) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 55 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class ActionSetFieldColumnSynchronizer method update.

@Override
public List<BaseColumnFieldDiff> update(final ColumnMetaData originalMetaData, final ColumnMetaData editedMetaData) throws VetoException {
    // Check operation is supported
    if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
        return Collections.emptyList();
    }
    // Get differences between original and edited column
    final ActionSetFieldCol52 originalColumn = (ActionSetFieldCol52) originalMetaData.getColumn();
    final ActionSetFieldCol52 editedColumn = (ActionSetFieldCol52) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
    update(originalColumn, editedColumn);
    final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionSetFieldCol52.FIELD_HIDE_COLUMN, diffs);
    final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionSetFieldCol52.FIELD_HEADER, diffs);
    final boolean isBoundNameUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionSetFieldCol52.FIELD_BOUND_NAME, diffs);
    final boolean isFactFieldUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionSetFieldCol52.FIELD_FACT_FIELD, diffs);
    if (isBoundNameUpdated || isFactFieldUpdated) {
        clearColumnData(originalColumn);
    } else {
        cleanColumnData(originalColumn, editedColumn, diffs);
    }
    synchroniseUpdateColumn(originalColumn);
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    if (isHeaderUpdated) {
        setColumnHeader(originalColumn, originalColumn.getHeader());
    }
    return diffs;
}
Also used : BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Aggregations

ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)75 Test (org.junit.Test)49 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)39 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)38 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)29 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)27 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)23 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)16 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)16 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)12 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)12 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)12 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)12 Path (org.uberfire.backend.vfs.Path)12 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)11 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)11 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)10 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)9 ActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)8 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)8