@Override
public DynamicForm getCustomSettingsForm() {
final DynamicForm form = new DynamicForm();
final ResourceLookupComboBoxItem resourceLookupComboBoxItem = new ResourceLookupComboBoxItem(CFG_RESOURCE_ID,
MSG.common_title_resource());
resourceLookupComboBoxItem.setWidth(300);
final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
Integer integerValue = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue();
if (integerValue != null) {
form.setValue(CFG_RESOURCE_ID, integerValue);
}
}
form.setFields(resourceLookupComboBoxItem);
form.addSubmitValuesHandler(new SubmitValuesHandler() {
public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
storedPortlet.getConfiguration().put(
new PropertySimple(CFG_RESOURCE_ID, form.getValue(CFG_RESOURCE_ID)));
String name = resourceLookupComboBoxItem.getDisplayValue();
ListGridRecord r = resourceLookupComboBoxItem.getSelectedRecord();
String ancestry = AncestryUtil.getAncestryValue(r, false);
String title = NAME + ": " + name;
title = ancestry.isEmpty() ? title : title + " [" + ancestry + "]";
storedPortlet.getConfiguration().put(new PropertySimple(CFG_TITLE, title));