Search in sources :

Example 1 with ConfigParameterInfo

use of com.google.gerrit.client.projects.ConfigInfo.ConfigParameterInfo 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)

Aggregations

ConfigParameterInfo (com.google.gerrit.client.projects.ConfigInfo.ConfigParameterInfo)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 HasEnabled (com.google.gwt.user.client.ui.HasEnabled)1 HashMap (java.util.HashMap)1