Search in sources :

Example 81 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler 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 ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler 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 ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler 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 84 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler 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)

Example 85 with ChangeHandler

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

the class ActionValueEditor method boundVariable.

private Widget boundVariable() {
    // If there is a bound variable that is the same type of the current variable type, then display a list
    ListBox listVariable = new ListBox();
    listVariable.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    List<String> bindings = getApplicableBindings();
    for (String v : bindings) {
        listVariable.addItem(v);
    }
    // Pre-select applicable item
    if (value.getValue().equals("=")) {
        listVariable.setSelectedIndex(0);
    } else {
        for (int i = 0; i < listVariable.getItemCount(); i++) {
            if (listVariable.getItemText(i).equals(value.getValue().substring(1))) {
                listVariable.setSelectedIndex(i);
            }
        }
    }
    // Add event handler
    if (listVariable.getItemCount() > 0) {
        listVariable.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                ListBox w = (ListBox) event.getSource();
                value.setValue("=" + w.getValue(w.getSelectedIndex()));
                executeOnChangeCommand();
                refresh();
            }
        });
    }
    if (this.readOnly) {
        return new SmallLabel(listVariable.getItemText(listVariable.getSelectedIndex()));
    }
    return listVariable;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) 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) ListBox(org.gwtbootstrap3.client.ui.ListBox) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)98 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 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)31 ListBox (org.gwtbootstrap3.client.ui.ListBox)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