use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPage method initialise.
@Override
public void initialise() {
view.init(this);
view.setValidator(getValidator());
patternToActionsMap.clear();
// Set-up validator for the pattern-to-action mapping voodoo
getValidator().setPatternToActionInsertFactFieldsMap(patternToActionsMap);
// Set-up a factory for value editors
view.setDTCellValueWidgetFactory(DTCellValueWidgetFactory.getInstance(model, oracle, false, allowEmptyValues()));
// Available types
final List<String> availableTypes = Arrays.asList(oracle.getFactTypes());
view.setAvailableFactTypes(availableTypes);
// Existing ActionInsertFactCols (should be empty for a new Decision Table)
for (ActionCol52 a : model.getActionCols()) {
if (a instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
final ActionInsertFactFieldsPattern p = lookupExistingInsertFactPattern(aif.getBoundName());
final List<ActionInsertFactCol52> actions = patternToActionsMap.get(p);
getValidator().addActionPattern(p);
actions.add(aif);
}
}
view.setChosenPatterns(new ArrayList<ActionInsertFactFieldsPattern>());
view.setAvailableFields(new ArrayList<AvailableField>());
view.setChosenFields(new ArrayList<ActionInsertFactCol52>());
content.setWidget(view);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPage method makeResult.
@Override
public void makeResult(final GuidedDecisionTable52 model) {
// Copy actions to decision table model
int fi = 1;
for (Map.Entry<ActionInsertFactFieldsPattern, List<ActionInsertFactCol52>> ps : patternToActionsMap.entrySet()) {
final ActionInsertFactFieldsPattern p = ps.getKey();
if (!getValidator().isPatternValid(p)) {
String binding = NEW_FACT_PREFIX + (fi++);
p.setBoundName(binding);
while (!getValidator().isPatternBindingUnique(p)) {
binding = NEW_FACT_PREFIX + (fi++);
p.setBoundName(binding);
}
}
final String factType = p.getFactType();
final String boundName = p.getBoundName();
final boolean isLogicalInsert = p.isInsertedLogically();
for (ActionInsertFactCol52 aif : ps.getValue()) {
aif.setFactType(factType);
aif.setBoundName(boundName);
aif.setInsertLogical(isLogicalInsert);
model.getActionCols().add(aif);
}
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPageViewImpl method btnAddFactTypesClick.
@UiHandler(value = "btnAddFactTypes")
public void btnAddFactTypesClick(final ClickEvent event) {
for (String type : availableFactTypesSelections) {
ActionInsertFactFieldsPattern pattern = new ActionInsertFactFieldsPattern();
pattern.setFactType(type);
chosenPatterns.add(pattern);
presenter.addPattern(pattern);
}
setChosenPatterns(chosenPatterns);
presenter.stateChanged();
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPageViewImpl method initialiseChosenPatterns.
private void initialiseChosenPatterns() {
chosenPatternsContainer.add(chosenPatternsWidget);
chosenPatternsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
chosenPatternsWidget.setMinimumWidth(130);
final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenPatterns());
lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
chosenPatternsWidget.setEmptyListWidget(lstEmpty);
final MultiSelectionModel<ActionInsertFactFieldsPattern> selectionModel = new MultiSelectionModel<ActionInsertFactFieldsPattern>(System::identityHashCode);
chosenPatternsWidget.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(final SelectionChangeEvent event) {
chosenPatternsSelections = selectionModel.getSelectedSet();
chosenPatternsSelected(chosenPatternsSelections);
}
private void chosenPatternsSelected(final Set<ActionInsertFactFieldsPattern> cps) {
btnRemoveFactTypes.setEnabled(cps.size() > 0);
fieldDefinition.setVisible(false);
if (cps.size() == 1) {
chosenPatternsSelection = cps.iterator().next();
presenter.selectPattern(chosenPatternsSelection);
patternDefinition.setVisible(true);
validateBinding();
txtBinding.setEnabled(true);
txtBinding.setVisible(true);
txtBinding.setText(chosenPatternsSelection.getBoundName());
chkLogicalInsert.setEnabled(true);
chkLogicalInsert.setVisible(true);
chkLogicalInsert.setValue(chosenPatternsSelection.isInsertedLogically());
} else {
chosenPatternsSelection = null;
setAvailableFields(new ArrayList<AvailableField>());
setChosenFields(new ArrayList<ActionInsertFactCol52>());
patternDefinition.setVisible(false);
txtBinding.setEnabled(false);
txtBinding.setVisible(false);
txtBinding.setText("");
chkLogicalInsert.setEnabled(false);
chkLogicalInsert.setVisible(false);
}
}
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPage method lookupExistingInsertFactPattern.
private ActionInsertFactFieldsPattern lookupExistingInsertFactPattern(final String boundName) {
for (ActionInsertFactFieldsPattern p : patternToActionsMap.keySet()) {
if (p.getBoundName().equals(boundName)) {
return p;
}
}
final ActionInsertFactFieldsPattern p = new ActionInsertFactFieldsPattern();
patternToActionsMap.put(p, new ArrayList<ActionInsertFactCol52>());
return p;
}
Aggregations