propertyMap);
layout.addMember(valuesCanvas);
if (isDynamic && !isReadOnly(propertyDefinitionMap, propertyMap)) {
// Map is not read-only - add footer with New and Delete buttons to allow user to add or remove members.
EnhancedToolStrip buttonBar = new EnhancedToolStrip();
buttonBar.setPadding(5);
buttonBar.setMembersMargin(15);
final IButton newButton = new EnhancedIButton(MSG.common_button_new(), ButtonColor.BLUE);
newButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
newButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
SC.askforValue(MSG.view_configEdit_enterPropName(), new ValueCallback() {
public void execute(String propertyName) {
if (propertyMap.get(propertyName) != null) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_configEdit_error_3(propertyName), Message.Severity.Error,
EnumSet.of(Message.Option.Transient)));
} else {
PropertySimple memberPropertySimple = new PropertySimple(propertyName, null);
addPropertyToDynamicMap(memberPropertySimple, propertyMap);
firePropertyChangedEvent(propertyMap, propertyDefinitionMapFinal, true);
reload();
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_configEdit_msg_1(propertyName), EnumSet
.of(Message.Option.Transient)));
}
}
});
}
});
buttonBar.addMember(newButton);
HLayout spacer = new HLayout();
spacer.setWidth(12);
buttonBar.addMember(spacer);
EnhancedHLayout deleteControlsLayout = new EnhancedHLayout();
deleteControlsLayout.setMargin(3);
deleteControlsLayout.setMembersMargin(3);
deleteControlsLayout.setWidth100();
DynamicForm deleteForm = new DynamicForm();
deleteForm.setWidth100();
final SelectItem selectItem = new SortedSelectItem();
selectItem.setMultiple(true);
selectItem.setMultipleAppearance(MultipleAppearance.GRID);
selectItem.setTitle(MSG.common_button_delete());
selectItem.setValueMap(propertyDefinitionMap.getMap().keySet()
.toArray(new String[propertyDefinitionMap.getMap().size()]));
final EnhancedIButton okButton = new EnhancedIButton(MSG.common_button_ok(), ButtonColor.BLUE);
okButton.setDisabled(true);
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
SC.confirm(MSG.view_configEdit_confirm_1(), new BooleanCallback() {
@Override
public void execute(Boolean confirmed) {
if (confirmed) {
Object value = selectItem.getValue();
if (value != null) {
String stringValue = value.toString();
String[] memberPropertyNames = stringValue.split(",");
for (final String memberPropertyName : memberPropertyNames) {
PropertySimple memberPropertySimple = propertyMap.getSimple(memberPropertyName);
removePropertyFromDynamicMap(memberPropertySimple);
firePropertyChangedEvent(propertyMap, propertyDefinitionMapFinal, true);
}
}
reload();
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_configEdit_msg_2(), EnumSet.of(Message.Option.Transient)));
}
}
});
}
});
selectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent changedEvent) {
Object value = changedEvent.getValue();
if (value != null) {
String stringValue = value.toString();
String[] memberPropertyNames = stringValue.split(",");
okButton.setDisabled(memberPropertyNames.length == 0);
}
}
});
deleteForm.setFields(selectItem);
deleteControlsLayout.addMember(deleteForm);
deleteControlsLayout.addMember(okButton);
buttonBar.addMember(deleteControlsLayout);
layout.addMember(buttonBar);
}
CanvasItem canvasItem = buildComplexPropertyField(layout);
canvasItem.setColSpan(3);