final IButton saveButtonPC = new EnhancedIButton(MSG.common_button_save(), ButtonColor.BLUE);
final IButton resetButtonPC = new EnhancedIButton(MSG.common_button_reset(), ButtonColor.RED);
Configuration config = plugin.getPluginConfiguration();
final ConfigurationEditor editorPC = new ConfigurationEditor(def, config);
editorPC.setOverflow(Overflow.AUTO);
editorPC.addPropertyValueChangeListener(new PropertyValueChangeListener() {
public void propertyValueChanged(PropertyValueChangeEvent event) {
if (event.isInvalidPropertySetChanged()) {
Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
saveButtonPC.enable();
} else {
saveButtonPC.disable();
}
}
}
});
resetButtonPC.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
editorPC.reset();
}
});
saveButtonPC.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!editorPC.validate()) {
Message msg = new Message(MSG.view_admin_plugins_serverConfig_badSettings(),
Severity.Warning, EnumSet.of(Message.Option.Transient));
CoreGUI.getMessageCenter().notify(msg);
return;
}
pluginManager.updateServerPluginConfiguration(pluginKey, editorPC.getConfiguration(),
new AsyncCallback<Void>() {
public void onSuccess(Void result) {
Message m = new Message(MSG.view_admin_plugins_serverConfig_settingsSaved());
CoreGUI.getMessageCenter().notify(m);
}