Search in sources :

Example 1 with IRiskFieldEditor

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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IRiskFieldEditor(org.eclipse.titanium.metrics.preferences.IRiskFieldEditor) IRiskEditorPropertyListener(org.eclipse.titanium.metrics.preferences.IRiskEditorPropertyListener) IMetricEnum(org.eclipse.titanium.metrics.IMetricEnum) MetricGroup(org.eclipse.titanium.metrics.MetricGroup) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) IRiskEditorListener(org.eclipse.titanium.metrics.preferences.IRiskEditorListener)

Example 2 with IRiskFieldEditor

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();
}
Also used : IRiskFieldEditor(org.eclipse.titanium.metrics.preferences.IRiskFieldEditor)

Aggregations

IRiskFieldEditor (org.eclipse.titanium.metrics.preferences.IRiskFieldEditor)2 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 IMetricEnum (org.eclipse.titanium.metrics.IMetricEnum)1 MetricGroup (org.eclipse.titanium.metrics.MetricGroup)1 IRiskEditorListener (org.eclipse.titanium.metrics.preferences.IRiskEditorListener)1 IRiskEditorPropertyListener (org.eclipse.titanium.metrics.preferences.IRiskEditorPropertyListener)1