Search in sources :

Example 81 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.

the class GroupManagersTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": managers");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    final ListBox box = new ListBox();
    box.addItem("Users");
    box.addItem("Groups");
    box.setSelectedIndex(selectedDropDownIndex);
    final ScrollPanel sp = new ScrollPanel();
    sp.addStyleName("perun-tableScrollPanel");
    // menu
    final TabMenu menu = new TabMenu();
    // group members
    final GetRichAdminsWithAttributes admins = new GetRichAdminsWithAttributes(PerunEntity.GROUP, groupId, null);
    final GetAdminGroups adminGroups = new GetAdminGroups(PerunEntity.GROUP, groupId);
    box.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            if (box.getSelectedIndex() == 0) {
                selectedDropDownIndex = 0;
                sp.setWidget(fillContentUsers(admins, menu));
            } else {
                selectedDropDownIndex = 1;
                sp.setWidget(fillContentGroups(adminGroups, menu));
            }
        }
    });
    if (selectedDropDownIndex == 0) {
        sp.setWidget(fillContentUsers(admins, menu));
    } else {
        sp.setWidget(fillContentGroups(adminGroups, menu));
    }
    menu.addWidget(3, new HTML("<strong>Select mode: </strong>"));
    menu.addWidget(4, box);
    session.getUiElements().resizePerunTable(sp, 350, this);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(sp);
    sp.setStyleName("perun-tableScrollPanel");
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : GetRichAdminsWithAttributes(cz.metacentrum.perun.webgui.json.authzResolver.GetRichAdminsWithAttributes) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) GetAdminGroups(cz.metacentrum.perun.webgui.json.authzResolver.GetAdminGroups) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 82 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.

the class DTCellValueWidgetFactory method makeListBoxForColumn.

private ListBox makeListBoxForColumn(final DropDownData dd, final Pattern52 basePattern, final BaseColumn baseCondition, final DTCellValue52 dcv, final boolean isMultipleSelect) {
    final ListBox lb = makeListBox(dd, isMultipleSelect, dcv);
    // Wire up update handler
    lb.setEnabled(!isReadOnly);
    if (!isReadOnly) {
        lb.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                String value = null;
                if (lb.isMultipleSelect()) {
                    for (int i = 0; i < lb.getItemCount(); i++) {
                        if (lb.isItemSelected(i)) {
                            if (value == null) {
                                value = lb.getValue(i);
                            } else {
                                value = value + "," + lb.getValue(i);
                            }
                        }
                    }
                } else {
                    int index = lb.getSelectedIndex();
                    if (index > -1) {
                        // Set base column value
                        value = lb.getValue(index);
                    }
                }
                dcv.setStringValue(value);
                // Update any dependent enumerations
                final LimitedEntryDropDownManager.Context context = new LimitedEntryDropDownManager.Context(basePattern, baseCondition);
                Set<Integer> dependentColumnIndexes = dropDownManager.getDependentColumnIndexes(context);
                for (Integer iCol : dependentColumnIndexes) {
                    BaseColumn column = model.getExpandedColumns().get(iCol);
                    if (column instanceof LimitedEntryCol) {
                        ((LimitedEntryCol) column).setValue(null);
                    } else if (column instanceof DTColumnConfig52) {
                        ((DTColumnConfig52) column).setDefaultValue(null);
                    }
                }
            }
        });
    }
    return lb;
}
Also used : BigInteger(java.math.BigInteger) Set(java.util.Set) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) LimitedEntryDropDownManager(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.LimitedEntryDropDownManager) ListBox(org.gwtbootstrap3.client.ui.ListBox) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol)

Example 83 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.

the class OperatorPage method cepOperatorsDropdown.

private void cepOperatorsDropdown(final Consumer<IsWidget> widgetSupplier) {
    getOperatorCompletions(options -> {
        final String[] operatorsArray = filterOptionsForConstraintTypeLiteral(options);
        final CEPOperatorsDropdown dropdown = newCepOperatorsDropdown(operatorsArray);
        final ListBox box = dropdown.getBox();
        final int currentValueIndex = getCurrentIndexFromList(getOperator(), box);
        box.addChangeHandler((ChangeEvent valueChangeEvent) -> setOperator(box.getValue(box.getSelectedIndex())));
        if (currentValueIndex != box.getSelectedIndex()) {
            box.setSelectedIndex(currentValueIndex);
        }
        widgetSupplier.accept(dropdown);
    });
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) CEPOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown) ListBox(org.gwtbootstrap3.client.ui.ListBox) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

Example 84 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.

the class EditActionInsertPopup method initialiseClassNames.

private void initialiseClassNames() {
    // Extract all class names available
    final String[] classNames = oracle.getFactTypes();
    classNameListBox.setEnabled(!(classNames == null || classNames.length == 0));
    if (classNames == null || classNames.length == 0) {
        classNameListBox.addItem(GuidedDecisionTreeConstants.INSTANCE.noBindings());
        return;
    }
    // Add them to the ListBox
    int selectedIndex = 0;
    for (String className : classNames) {
        classNameListBox.addItem(className);
        if (className.equals(clone.getClassName())) {
            selectedIndex = classNameListBox.getItemCount() - 1;
        }
    }
    // Attach event handler before we set the selected index in case we're selecting the first item
    classNameListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(final ChangeEvent event) {
            final String className = classNameListBox.getItemText(classNameListBox.getSelectedIndex());
            clone.setClassName(className);
            clone.getFieldValues().clear();
            initialiseFieldValues();
        }
    });
    classNameListBox.setSelectedIndex(selectedIndex);
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Example 85 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.

the class EditConstraintPopup method initialiseOperators.

private void initialiseOperators() {
    oracle.getOperatorCompletions(clone.getClassName(), clone.getFieldName(), new Callback<String[]>() {

        @Override
        public void callback(final String[] operators) {
            operatorListBox.clear();
            operatorListBox.setEnabled(false);
            if (operators == null) {
                return;
            }
            int selectedIndex = 0;
            operatorListBox.setEnabled(true);
            operatorListBox.addItem(GuidedDecisionTreeConstants.INSTANCE.noOperator());
            for (int index = 0; index < operators.length; index++) {
                final String operator = operators[index];
                if (operator.equals(clone.getOperator())) {
                    selectedIndex = index + 1;
                }
                operatorListBox.addItem(HumanReadable.getOperatorDisplayName(operator), operator);
            }
            operatorListBox.setSelectedIndex(selectedIndex);
            initialiseValue();
        }
    });
    operatorListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(final ChangeEvent event) {
            final int selectedIndex = operatorListBox.getSelectedIndex();
            if (selectedIndex == 0) {
                clone.setOperator(null);
            } else {
                clone.setOperator(operatorListBox.getValue(selectedIndex));
            }
            initialiseValue();
        }
    });
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)99 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)98 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)41 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)41 ListBox (org.gwtbootstrap3.client.ui.ListBox)32 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)31 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)28 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)27 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)27 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 ArrayList (java.util.ArrayList)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)20 PerunError (cz.metacentrum.perun.webgui.model.PerunError)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)12 HashMap (java.util.HashMap)11 Map (java.util.Map)9 Button (org.gwtbootstrap3.client.ui.Button)9 HTML (com.google.gwt.user.client.ui.HTML)7