use of org.eclipse.titanium.metrics.preferences.IRiskFieldEditor in project titan.EclipsePlug-ins by eclipse.
the class MetricsLimitPreferencePage method createContents.
@Override
protected Control createContents(final Composite parent) {
final Composite page = new Composite(parent, 0);
final GridLayout l = new GridLayout();
l.numColumns = 2;
page.setLayout(l);
for (final MetricGroup type : MetricGroup.values()) {
final Label header = new Label(page, 0);
header.setText(type.getGroupName() + " metrics");
final GridData headerData = new GridData();
headerData.horizontalSpan = 2;
header.setLayoutData(headerData);
final Composite padding = new Composite(page, 0);
padding.setLayoutData(new GridData(25, 0));
final Composite inner = new Composite(page, 0);
final GridLayout layout = new GridLayout();
layout.numColumns = 2;
inner.setLayout(layout);
final IRiskEditorListener listener = new IRiskEditorListener() {
@Override
public void editorChanged() {
inner.layout();
page.layout();
}
};
final IRiskEditorPropertyListener propertyListener = new IRiskEditorPropertyListener() {
@Override
public void propertyChange(final boolean valid) {
if (!valid) {
setValid(false);
updateApplyButton();
} else if (!isValid()) {
checkState();
}
}
};
for (final IMetricEnum metric : type.getMetrics()) {
final Label name = new Label(inner, 0);
name.setText(metric.getName());
name.setToolTipText(metric.getHint());
final IRiskFieldEditor editor = getRiskEditor(inner, metric);
editor.addRiskEditorListener(listener);
editor.setPropListener(propertyListener);
editor.load();
editors.add(editor);
}
}
checkState();
return page;
}
use of org.eclipse.titanium.metrics.preferences.IRiskFieldEditor in project titan.EclipsePlug-ins by eclipse.
the class MetricsLimitPreferencePage method checkState.
protected void checkState() {
boolean valid = true;
for (final IRiskFieldEditor ed : editors) {
valid = valid && ed.isValid();
if (!valid) {
break;
}
}
setValid(valid);
updateApplyButton();
}
Aggregations