use of com.google.gerrit.client.StringListPanel 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.gerrit.client.StringListPanel in project gerrit by GerritCodeReview.
the class ProjectInfoScreen method renderStringListPanel.
private StringListPanel renderStringListPanel(LabeledWidgetsGrid g, ConfigParameterInfo param) {
StringListPanel p = new StringListPanel(null, Arrays.asList(getDisplayName(param)), saveProject, false);
List<List<String>> values = new ArrayList<>();
for (String v : Natives.asList(param.values())) {
values.add(Arrays.asList(v));
}
p.display(values);
if (!param.editable()) {
p.setEnabled(false);
}
addWidget(g, p, param);
return p;
}
Aggregations