Search in sources :

Example 6 with MultiSelectionModel

use of com.google.gwt.view.client.MultiSelectionModel in project drools-wb by kiegroup.

the class ActionInsertFactFieldsPageViewImpl method initialiseChosenFields.

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

        @Override
        public void onSelectionChange(final SelectionChangeEvent event) {
            chosenFieldsSelections = new HashSet<ActionInsertFactCol52>();
            final Set<ActionInsertFactCol52> selections = selectionModel.getSelectedSet();
            for (ActionInsertFactCol52 a : selections) {
                chosenFieldsSelections.add(a);
            }
            chosenConditionsSelected(chosenFieldsSelections);
        }

        private void chosenConditionsSelected(final Set<ActionInsertFactCol52> 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);
            }
        }

        private void populateFieldDefinition() {
            // Fields common to all table formats
            txtColumnHeader.setEnabled(true);
            txtColumnHeader.setText(chosenFieldsSelection.getHeader());
            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 LimitedEntryActionInsertFactCol52)) {
                return;
            }
            LimitedEntryActionInsertFactCol52 lea = (LimitedEntryActionInsertFactCol52) chosenFieldsSelection;
            if (lea.getValue() == null) {
                lea.setValue(factory.makeNewValue(chosenFieldsSelection));
            }
            limitedEntryValueWidgetContainer.setWidget(factory.getWidget(chosenFieldsSelection, lea.getValue()));
        }
    });
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) HashSet(java.util.HashSet) Set(java.util.Set) MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) HashSet(java.util.HashSet)

Example 7 with MultiSelectionModel

use of com.google.gwt.view.client.MultiSelectionModel in project drools-wb by kiegroup.

the class ActionInsertFactFieldsPageViewImpl method initialiseAvailableFields.

private void initialiseAvailableFields() {
    availableFieldsContainer.add(availableFieldsWidget);
    availableFieldsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    availableFieldsWidget.setMinimumWidth(130);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoAvailableFields());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    availableFieldsWidget.setEmptyListWidget(lstEmpty);
    final MultiSelectionModel<AvailableField> selectionModel = new MultiSelectionModel<AvailableField>();
    availableFieldsWidget.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(final SelectionChangeEvent event) {
            availableFieldsSelections = selectionModel.getSelectedSet();
            btnAdd.setEnabled(availableFieldsSelections.size() > 0);
        }
    });
}
Also used : MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 8 with MultiSelectionModel

use of com.google.gwt.view.client.MultiSelectionModel 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 9 with MultiSelectionModel

use of com.google.gwt.view.client.MultiSelectionModel in project drools-wb by kiegroup.

the class ActionSetFieldsPageViewImpl method initialiseAvailableFields.

private void initialiseAvailableFields() {
    availableFieldsContainer.add(availableFieldsWidget);
    availableFieldsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    availableFieldsWidget.setMinimumWidth(170);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoAvailableFields());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    availableFieldsWidget.setEmptyListWidget(lstEmpty);
    final MultiSelectionModel<AvailableField> selectionModel = new MultiSelectionModel<AvailableField>();
    availableFieldsWidget.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(final SelectionChangeEvent event) {
            availableFieldsSelections = selectionModel.getSelectedSet();
            btnAdd.setEnabled(availableFieldsSelections.size() > 0);
        }
    });
}
Also used : MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 10 with MultiSelectionModel

use of com.google.gwt.view.client.MultiSelectionModel in project drools-wb by kiegroup.

the class FactPatternsPageViewImpl method initialiseChosenPatterns.

private void initialiseChosenPatterns() {
    chosenPatternsContainer.add(chosenPatternWidget);
    chosenPatternWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    chosenPatternWidget.setMinimumWidth(270);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenPatterns());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    chosenPatternWidget.setEmptyListWidget(lstEmpty);
    final MultiSelectionModel<Pattern52> selectionModel = new MultiSelectionModel<Pattern52>(System::identityHashCode);
    chosenPatternWidget.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

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

        private void chosenTypesSelected(final Set<Pattern52> ps) {
            btnRemove.setEnabled(true);
            if (ps.size() == 1) {
                chosenPatternSelection = ps.iterator().next();
                patternDefinition.setVisible(true);
                validateBinding();
                txtBinding.setEnabled(true);
                txtBinding.setText(chosenPatternSelection.getBoundName());
                txtEntryPoint.setEnabled(true);
                txtEntryPoint.setText(chosenPatternSelection.getEntryPointName());
                enableMoveUpButton();
                enableMoveDownButton();
                presenter.isPatternEvent(chosenPatternSelection, new Callback<Boolean>() {

                    @Override
                    public void callback(final Boolean result) {
                        if (Boolean.TRUE.equals(result)) {
                            ddCEPWindow.setCEPWindow(chosenPatternSelection);
                            cepWindowContainer.setVisible(true);
                        } else {
                            cepWindowContainer.setVisible(false);
                        }
                    }
                });
            } else {
                chosenPatternSelection = null;
                patternDefinition.setVisible(false);
                txtBinding.setEnabled(false);
                txtBinding.setText("");
                txtEntryPoint.setEnabled(false);
                txtEntryPoint.setText("");
                btnMoveUp.setEnabled(false);
                btnMoveDown.setEnabled(false);
                cepWindowContainer.setVisible(false);
            }
        }
    });
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) Callback(org.uberfire.client.callbacks.Callback) MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) Label(org.gwtbootstrap3.client.ui.Label) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Aggregations

MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)10 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)10 Label (org.gwtbootstrap3.client.ui.Label)10 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)2 Callback (org.uberfire.client.callbacks.Callback)2 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 ArrayList (java.util.ArrayList)1 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)1 ActionInsertFactFieldsPattern (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern)1 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)1 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)1 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)1 CEPOperatorsDropdown (org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)1