Search in sources :

Example 1 with HasEnabled

use of com.google.gwt.user.client.ui.HasEnabled in project gerrit by GerritCodeReview.

the class ProjectInfoScreen method getPluginConfigValues.

private Map<String, Map<String, ConfigParameterValue>> getPluginConfigValues() {
    Map<String, Map<String, ConfigParameterValue>> pluginConfigValues = new HashMap<>(pluginConfigWidgets.size());
    for (Entry<String, Map<String, HasEnabled>> e : pluginConfigWidgets.entrySet()) {
        Map<String, ConfigParameterValue> values = new HashMap<>(e.getValue().size());
        pluginConfigValues.put(e.getKey(), values);
        for (Entry<String, HasEnabled> e2 : e.getValue().entrySet()) {
            HasEnabled widget = e2.getValue();
            if (widget instanceof TextBox) {
                values.put(e2.getKey(), ConfigParameterValue.create().value(((TextBox) widget).getValue().trim()));
            } else if (widget instanceof CheckBox) {
                values.put(e2.getKey(), ConfigParameterValue.create().value(Boolean.toString(((CheckBox) widget).getValue())));
            } else if (widget instanceof ListBox) {
                ListBox listBox = (ListBox) widget;
                // the inherited value is at index 0,
                // if it is selected no value should be set on this project
                String value = listBox.getSelectedIndex() > 0 ? listBox.getValue(listBox.getSelectedIndex()) : null;
                values.put(e2.getKey(), ConfigParameterValue.create().value(value));
            } else if (widget instanceof StringListPanel) {
                values.put(e2.getKey(), ConfigParameterValue.create().values(((StringListPanel) widget).getValues(0).toArray(new String[] {})));
            } else {
                throw new UnsupportedOperationException("unsupported widget type");
            }
        }
    }
    return pluginConfigValues;
}
Also used : HasEnabled(com.google.gwt.user.client.ui.HasEnabled) HashMap(java.util.HashMap) ConfigParameterValue(com.google.gerrit.client.projects.ConfigInfo.ConfigParameterValue) TextBox(com.google.gwt.user.client.ui.TextBox) NpIntTextBox(com.google.gerrit.client.ui.NpIntTextBox) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox) CheckBox(com.google.gwt.user.client.ui.CheckBox) AccessMap(com.google.gerrit.client.access.AccessMap) Map(java.util.Map) HashMap(java.util.HashMap) NativeMap(com.google.gerrit.client.rpc.NativeMap) ListBox(com.google.gwt.user.client.ui.ListBox) StringListPanel(com.google.gerrit.client.StringListPanel)

Example 2 with HasEnabled

use of com.google.gwt.user.client.ui.HasEnabled in project gerrit by GerritCodeReview.

the class ProjectInfoScreen method initPluginOptions.

private void initPluginOptions(ConfigInfo info) {
    pluginOptionsPanel.clear();
    pluginConfigWidgets = new HashMap<>();
    for (String pluginName : info.pluginConfig().keySet()) {
        Map<String, HasEnabled> widgetMap = new HashMap<>();
        pluginConfigWidgets.put(pluginName, widgetMap);
        LabeledWidgetsGrid g = new LabeledWidgetsGrid();
        g.addHeader(new SmallHeading(AdminMessages.I.pluginProjectOptionsTitle(pluginName)));
        pluginOptionsPanel.add(g);
        NativeMap<ConfigParameterInfo> pluginConfig = info.pluginConfig(pluginName);
        pluginConfig.copyKeysIntoChildren("name");
        for (ConfigParameterInfo param : Natives.asList(pluginConfig.values())) {
            HasEnabled w;
            switch(param.type()) {
                case "STRING":
                case "INT":
                case "LONG":
                    w = renderTextBox(g, param);
                    break;
                case "BOOLEAN":
                    w = renderCheckBox(g, param);
                    break;
                case "LIST":
                    w = renderListBox(g, param);
                    break;
                case "ARRAY":
                    w = renderStringListPanel(g, param);
                    break;
                default:
                    throw new UnsupportedOperationException("unsupported widget type");
            }
            if (param.editable()) {
                widgetMap.put(param.name(), w);
            } else {
                w.setEnabled(false);
            }
        }
    }
    enableForm();
}
Also used : SmallHeading(com.google.gerrit.client.ui.SmallHeading) HasEnabled(com.google.gwt.user.client.ui.HasEnabled) HashMap(java.util.HashMap) ConfigParameterInfo(com.google.gerrit.client.projects.ConfigInfo.ConfigParameterInfo)

Example 3 with HasEnabled

use of com.google.gwt.user.client.ui.HasEnabled in project ovirt-engine by oVirt.

the class FenceAgentWidget method setEnabled.

@Override
public void setEnabled(boolean enabled) {
    concurrentList.setEnabled(enabled);
    for (int i = 0; i < concurrentPanel.getWidgetCount(); i++) {
        IsWidget widget = concurrentPanel.getWidget(i);
        if (widget instanceof HasEnabled) {
            ((HasEnabled) widget).setEnabled(enabled);
        }
    }
    editFenceAgent.setEnabled(enabled);
    if (enabled) {
        orderLabel.removeStyleName(OvirtCss.LABEL_DISABLED);
        concurrentGroupLabel.removeStyleName(OvirtCss.LABEL_DISABLED);
        agentLabel.removeStyleName(OvirtCss.LABEL_DISABLED);
        agentLabel.addStyleName(style.fakeAnchor());
    } else {
        orderLabel.addStyleName(OvirtCss.LABEL_DISABLED);
        concurrentGroupLabel.addStyleName(OvirtCss.LABEL_DISABLED);
        agentLabel.addStyleName(OvirtCss.LABEL_DISABLED);
        agentLabel.removeStyleName(style.fakeAnchor());
    }
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) HasEnabled(com.google.gwt.user.client.ui.HasEnabled)

Example 4 with HasEnabled

use of com.google.gwt.user.client.ui.HasEnabled in project cuba by cuba-platform.

the class CubaOptionGroupWidget method updateEnabledState.

@Override
protected void updateEnabledState() {
    for (Widget w : panel) {
        if (w instanceof HasEnabled) {
            HasEnabled hasEnabled = (HasEnabled) w;
            hasEnabled.setEnabled(isEnabled());
            w.setStyleName("v-readonly", isReadonly());
        }
    }
}
Also used : HasEnabled(com.google.gwt.user.client.ui.HasEnabled) Widget(com.google.gwt.user.client.ui.Widget)

Example 5 with HasEnabled

use of com.google.gwt.user.client.ui.HasEnabled in project gerrit by GerritCodeReview.

the class ProjectInfoScreen method enableForm.

private void enableForm(boolean isOwner) {
    state.setEnabled(isOwner);
    submitType.setEnabled(isOwner);
    setEnabledForUseContentMerge();
    newChangeForAllNotInTarget.setEnabled(isOwner);
    if (enableSignedPush != null) {
        enableSignedPush.setEnabled(isOwner);
    }
    descTxt.setEnabled(isOwner);
    contributorAgreements.setEnabled(isOwner);
    signedOffBy.setEnabled(isOwner);
    requireChangeID.setEnabled(isOwner);
    rejectImplicitMerges.setEnabled(isOwner);
    maxObjectSizeLimit.setEnabled(isOwner);
    enableReviewerByEmail.setEnabled(isOwner);
    if (pluginConfigWidgets != null) {
        for (Map<String, HasEnabled> widgetMap : pluginConfigWidgets.values()) {
            for (HasEnabled widget : widgetMap.values()) {
                widget.setEnabled(isOwner);
            }
        }
    }
}
Also used : HasEnabled(com.google.gwt.user.client.ui.HasEnabled)

Aggregations

HasEnabled (com.google.gwt.user.client.ui.HasEnabled)7 Widget (com.google.gwt.user.client.ui.Widget)2 HashMap (java.util.HashMap)2 StringListPanel (com.google.gerrit.client.StringListPanel)1 AccessMap (com.google.gerrit.client.access.AccessMap)1 ConfigParameterInfo (com.google.gerrit.client.projects.ConfigInfo.ConfigParameterInfo)1 ConfigParameterValue (com.google.gerrit.client.projects.ConfigInfo.ConfigParameterValue)1 NativeMap (com.google.gerrit.client.rpc.NativeMap)1 NpIntTextBox (com.google.gerrit.client.ui.NpIntTextBox)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 ListBox (com.google.gwt.user.client.ui.ListBox)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)1 Map (java.util.Map)1