Support description for project plugin configuration parameter

For project plugin configuration parameter it is now possible to
provide a description. If set this description is shown as a tooltip
on an info icon that is displayed for the project plugin configuration
parameter on the ProjectInfoScreen.

The info icon is taken from the Tango Icon Library [1].

[1] http://tango.freedesktop.org/Tango_Icon_Library

Change-Id: I1f680aa24dca919ad63a6b1a8b48203734e3dfa7
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin 2014-01-27 21:55:46 +01:00
parent fcb38f52b7
commit d92196d4b8
7 changed files with 90 additions and 13 deletions

View File

@ -1294,6 +1294,8 @@ parameter.
|Field Name ||Description
|`display_name` |optional|
The display name of the configuration parameter.
|`description` |optional|
The description of the configuration parameter.
|`type` ||
The type of the configuration parameter, can be `STRING`, `INT`,
`LONG`, `BOOLEAN` or `LIST`.

View File

@ -60,4 +60,7 @@ public interface GerritResources extends ClientBundle {
@Source("readOnly.png")
public ImageResource readOnly();
@Source("info.png")
public ImageResource info();
}

View File

@ -47,6 +47,7 @@ import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel;
@ -401,10 +402,10 @@ public class ProjectInfoScreen extends ProjectScreen {
HorizontalPanel p = new HorizontalPanel();
p.add(textBox);
p.add(inheritedLabel);
g.add(getDisplayName(param), p);
addWidget(g, p, param);
} else {
textBox.setValue(param.value());
g.add(getDisplayName(param), textBox);
addWidget(g, textBox, param);
}
saveEnabler.listenTo(textBox);
return textBox;
@ -414,7 +415,14 @@ public class ProjectInfoScreen extends ProjectScreen {
ConfigParameterInfo param) {
CheckBox checkBox = new CheckBox(getDisplayName(param));
checkBox.setValue(Boolean.parseBoolean(param.value()));
g.add(null, checkBox);
HorizontalPanel p = new HorizontalPanel();
p.add(checkBox);
if (param.description() != null) {
Image infoImg = new Image(Gerrit.RESOURCES.info());
infoImg.setTitle(param.description());
p.add(infoImg);
}
g.add((String)null, p);
saveEnabler.listenTo(checkBox);
return checkBox;
}
@ -447,7 +455,7 @@ public class ProjectInfoScreen extends ProjectScreen {
if (param.editable()) {
saveEnabler.listenTo(listBox);
g.add(getDisplayName(param), listBox);
addWidget(g, listBox, param);
} else {
listBox.setEnabled(false);
@ -463,15 +471,28 @@ public class ProjectInfoScreen extends ProjectScreen {
HorizontalPanel p = new HorizontalPanel();
p.add(listBox);
p.add(inheritedLabel);
g.add(getDisplayName(param), p);
addWidget(g, p, param);
} else {
g.add(getDisplayName(param), listBox);
addWidget(g, listBox, param);
}
}
return listBox;
}
private void addWidget(LabeledWidgetsGrid g, Widget w, ConfigParameterInfo param) {
if (param.description() != null) {
HorizontalPanel p = new HorizontalPanel();
Image infoImg = new Image(Gerrit.RESOURCES.info());
infoImg.setTitle(param.description());
p.add(new Label(getDisplayName(param)));
p.add(infoImg);
g.add(p, w);
} else {
g.add(getDisplayName(param), w);
}
}
private String getDisplayName(ConfigParameterInfo param) {
return param.displayName() != null ? param.displayName() : param.name();
}
@ -598,5 +619,11 @@ public class ProjectInfoScreen extends ProjectScreen {
add(label, true, widget);
}
public void add(Widget label, Widget widget) {
int row = getRowCount();
insertRow(row);
setWidget(row, 0, label);
setWidget(row, 1, widget);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

View File

@ -149,6 +149,7 @@ public class ConfigInfo extends JavaScriptObject {
public static class ConfigParameterInfo extends JavaScriptObject {
public final native String name() /*-{ return this.name; }-*/;
public final native String displayName() /*-{ return this.display_name; }-*/;
public final native String description() /*-{ return this.description; }-*/;
public final native String type() /*-{ return this.type; }-*/;
public final native String value() /*-{ return this.value; }-*/;
public final native boolean editable() /*-{ return this.editable ? true : false; }-*/;

View File

@ -44,6 +44,7 @@ public class ProjectConfigEntry {
}
private final String displayName;
private final String description;
private final boolean inheritable;
private final String defaultValue;
private final Type type;
@ -55,7 +56,12 @@ public class ProjectConfigEntry {
public ProjectConfigEntry(String displayName, String defaultValue,
boolean inheritable) {
this(displayName, defaultValue, Type.STRING, null, inheritable);
this(displayName, defaultValue, inheritable, null);
}
public ProjectConfigEntry(String displayName, String defaultValue,
boolean inheritable, String description) {
this(displayName, defaultValue, Type.STRING, null, inheritable, description);
}
public ProjectConfigEntry(String displayName, int defaultValue) {
@ -64,8 +70,13 @@ public class ProjectConfigEntry {
public ProjectConfigEntry(String displayName, int defaultValue,
boolean inheritable) {
this(displayName, defaultValue, inheritable, null);
}
public ProjectConfigEntry(String displayName, int defaultValue,
boolean inheritable, String description) {
this(displayName, Integer.toString(defaultValue), Type.INT, null,
inheritable);
inheritable, description);
}
public ProjectConfigEntry(String displayName, long defaultValue) {
@ -74,12 +85,25 @@ public class ProjectConfigEntry {
public ProjectConfigEntry(String displayName, long defaultValue,
boolean inheritable) {
this(displayName, Long.toString(defaultValue), Type.LONG, null, inheritable);
this(displayName, defaultValue, inheritable, null);
}
public ProjectConfigEntry(String displayName, long defaultValue,
boolean inheritable, String description) {
this(displayName, Long.toString(defaultValue), Type.LONG, null,
inheritable, description);
}
// For inheritable boolean use 'LIST' type with InheritableBoolean
public ProjectConfigEntry(String displayName, boolean defaultValue) {
this(displayName, Boolean.toString(defaultValue), Type.BOOLEAN, null, false);
this(displayName, defaultValue, null);
}
//For inheritable boolean use 'LIST' type with InheritableBoolean
public ProjectConfigEntry(String displayName, boolean defaultValue,
String description) {
this(displayName, Boolean.toString(defaultValue), Type.BOOLEAN, null,
false, description);
}
public ProjectConfigEntry(String displayName, String defaultValue,
@ -89,7 +113,13 @@ public class ProjectConfigEntry {
public ProjectConfigEntry(String displayName, String defaultValue,
List<String> permittedValues, boolean inheritable) {
this(displayName, defaultValue, Type.LIST, permittedValues, inheritable);
this(displayName, defaultValue, permittedValues, inheritable, null);
}
public ProjectConfigEntry(String displayName, String defaultValue,
List<String> permittedValues, boolean inheritable, String description) {
this(displayName, defaultValue, Type.LIST, permittedValues, inheritable,
description);
}
public <T extends Enum<?>> ProjectConfigEntry(String displayName,
@ -99,6 +129,12 @@ public class ProjectConfigEntry {
public <T extends Enum<?>> ProjectConfigEntry(String displayName,
T defaultValue, Class<T> permittedValues, boolean inheritable) {
this(displayName, defaultValue, permittedValues, inheritable, null);
}
public <T extends Enum<?>> ProjectConfigEntry(String displayName,
T defaultValue, Class<T> permittedValues, boolean inheritable,
String description) {
this(displayName, defaultValue.name(), Type.LIST, Lists.transform(
Arrays.asList(permittedValues.getEnumConstants()),
new Function<Enum<?>, String>() {
@ -106,22 +142,28 @@ public class ProjectConfigEntry {
public String apply(Enum<?> e) {
return e.name();
}
}), inheritable);
}), inheritable, description);
}
private ProjectConfigEntry(String displayName, String defaultValue,
Type type, List<String> permittedValues, boolean inheritable) {
Type type, List<String> permittedValues, boolean inheritable,
String description) {
this.displayName = displayName;
this.defaultValue = defaultValue;
this.type = type;
this.permittedValues = permittedValues;
this.inheritable = inheritable;
this.description = description;
}
public String getDisplayName() {
return displayName;
}
public String getDescription() {
return description;
}
public boolean isInheritable() {
return inheritable;
}

View File

@ -138,6 +138,7 @@ public class ConfigInfo {
String configuredValue = cfg.getString(e.getExportName());
ConfigParameterInfo p = new ConfigParameterInfo();
p.displayName = configEntry.getDisplayName();
p.description = configEntry.getDescription();
p.type = configEntry.getType();
p.permittedValues = configEntry.getPermittedValues();
p.editable = configEntry.isEditable(project) ? true : null;
@ -193,6 +194,7 @@ public class ConfigInfo {
public static class ConfigParameterInfo {
public String displayName;
public String description;
public ProjectConfigEntry.Type type;
public String value;
public Boolean editable;