Search in sources :

Example 26 with SelectionChangeEvent

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

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

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

the class ImportsPageViewImpl method initialiseAvailableImports.

private void initialiseAvailableImports() {
    availableImportsContainer.add(availableImportsWidget);
    availableImportsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    availableImportsWidget.setMinimumWidth(270);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoAvailableImports());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    availableImportsWidget.setEmptyListWidget(lstEmpty);
    availableImportsWidget.setSelectionModel(availableImportsSelectionModel);
    availableImportsSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

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

Example 29 with SelectionChangeEvent

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

the class ImportsPageViewImpl method initialiseChosenImports.

private void initialiseChosenImports() {
    chosenImportsContainer.add(chosenImportsWidget);
    chosenImportsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    chosenImportsWidget.setMinimumWidth(270);
    final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenImports());
    lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
    chosenImportsWidget.setEmptyListWidget(lstEmpty);
    chosenImportsWidget.setSelectionModel(chosenImportsSelectionModel);
    chosenImportsSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

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

Example 30 with SelectionChangeEvent

use of com.google.gwt.view.client.SelectionChangeEvent in project perun by CESNET.

the class AddFacilityManagerGroupTabItem method fillGroupsContent.

private Widget fillGroupsContent(GetAllGroups groups, TabMenu tabMenu, final ListBoxWithObjects<VirtualOrganization> box) {
    getAllGroups = groups;
    getAllGroups.setCoreGroupsCheckable(true);
    final CellTable<Group> table = getAllGroups.getTable();
    getAllGroups.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        private boolean found = false;

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            for (Group g : getAllGroups.getTableSelectedList()) {
                if (g.isCoreGroup()) {
                    if (!found) {
                        // display only once
                        UiElements.generateInfo("You have selected 'all vo members' group", "If this group will be added as 'manager group', all new members of VO " + box.getSelectedObject().getName() + " will be automatically managers of your Facility and all removed members will lose management rights.");
                    }
                    found = true;
                    return;
                }
            }
            found = false;
        }
    });
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersGroupToGroup());
    tabMenu.addWidget(0, addButton);
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Group> list = getAllGroups.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    if (i == list.size() - 1) {
                        AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            public void onFinished(JavaScriptObject jso) {
                                session.getTabManager().closeTab(tab, isRefreshParentOnClose());
                            }
                        }));
                        request.addFacilityAdminGroup(facility, list.get(i));
                    } else {
                        AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.addFacilityAdminGroup(facility, list.get(i));
                    }
                }
            }
        }
    });
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(getAllGroups, table, addButton);
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) AddAdmin(cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)31 Label (org.gwtbootstrap3.client.ui.Label)16 MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)12 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)9 Column (com.google.gwt.user.cellview.client.Column)6 ArrayList (java.util.ArrayList)5 TextCell (com.google.gwt.cell.client.TextCell)4 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)4 Group (cz.metacentrum.perun.webgui.model.Group)4 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 Handler (com.google.gwt.view.client.SelectionChangeEvent.Handler)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)3 Revision (org.eclipse.che.api.git.shared.Revision)3 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)2