use of net.sf.eclipsecs.ui.config.widgets.IConfigPropertyWidget in project eclipse-cs by checkstyle.
the class RuleConfigurationEditDialog method okPressed.
/**
* OK button was selected.
*/
@Override
protected void okPressed() {
//
// Get the selected severity level.
//
Severity severity = mRule.getSeverity();
try {
severity = (Severity) ((IStructuredSelection) mSeverityCombo.getSelection()).getFirstElement();
} catch (IllegalArgumentException e) {
CheckstyleLog.log(e);
}
// Get the comment.
final String comment = Strings.emptyToNull(mCommentText.getText());
// Get the id
final String id = Strings.emptyToNull(mIdText.getText());
// Get the custom message
for (Map.Entry<String, Text> entry : mCustomMessages.entrySet()) {
String msgKey = entry.getKey();
String standardMessage = MetadataFactory.getStandardMessage(msgKey, mRule.getMetaData().getInternalName());
if (standardMessage == null) {
// $NON-NLS-1$
standardMessage = "";
}
String message = Strings.emptyToNull(entry.getValue().getText());
if (message != null && !message.equals(standardMessage)) {
mRule.getCustomMessages().put(msgKey, message);
} else {
mRule.getCustomMessages().remove(msgKey);
}
}
//
if (mConfigPropertyWidgets != null) {
for (int i = 0; i < mConfigPropertyWidgets.length; i++) {
IConfigPropertyWidget widget = mConfigPropertyWidgets[i];
ConfigProperty property = widget.getConfigProperty();
try {
widget.validate();
} catch (CheckstylePluginException e) {
String message = NLS.bind(Messages.RuleConfigurationEditDialog_msgInvalidPropertyValue, property.getMetaData().getName());
this.setErrorMessage(message);
return;
}
property.setValue(widget.getValue());
}
}
//
// If we made it this far then all of the user input validated and we
// can
// update the final rule with the values the user entered.
//
mRule.setSeverity(severity);
mRule.setComment(comment);
mRule.setId(id);
super.okPressed();
}
Aggregations