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;
}
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();
}
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());
}
}
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());
}
}
}
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);
}
}
}
}
Aggregations