editForm = new DynamicForm();
editForm.setMargin(5);
editForm.setAutoWidth();
editForm.setNumCols(canEditName() ? 12 : 10);
TextItem nameItem = null;
if (dashboardContainer.supportsDashboardNameEdit()) {
nameItem = new TextItem("name", MSG.common_title_dashboard_name());
nameItem.setValue(storedDashboard.getName());
nameItem.setLength(200);
nameItem.setWrapTitle(false);
nameItem.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent blurEvent) {
FormItem nameItem = blurEvent.getItem();
String name = (String) nameItem.getValue();
String trimmedName = (name == null) ? "" : name.trim();
if (dashboardContainer.isValidDashboardName(trimmedName)) {
storedDashboard.setName(trimmedName);
save();
dashboardContainer.updateDashboardNames();
} else {
// TODO: i18n
Message message = new Message("There is already a dashboard named '" + trimmedName
+ "'. Please specify a name that is not already in use.", Message.Severity.Error, EnumSet
.of(Message.Option.Transient));
CoreGUI.getMessageCenter().notify(message);
nameItem.setValue(storedDashboard.getName());
}
}
});
}