package name.abuchen.portfolio.ui.views.dashboard; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import name.abuchen.portfolio.model.Dashboard.Widget; public abstract class AbstractIndicatorWidget extends WidgetDelegate { protected Label title; protected Label indicator; public AbstractIndicatorWidget(Widget widget, DashboardData dashboardData, boolean supportsBenchmarks) { super(widget, dashboardData); addConfig(new DataSeriesConfig(this, supportsBenchmarks)); addConfig(new ReportingPeriodConfig(this)); } @Override public Composite createControl(Composite parent, DashboardResources resources) { Composite container = new Composite(parent, SWT.NONE); container.setBackground(parent.getBackground()); GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 5).applyTo(container); title = new Label(container, SWT.NONE); title.setText(getWidget().getLabel()); GridDataFactory.fillDefaults().grab(true, false).applyTo(title); indicator = new Label(container, SWT.NONE); indicator.setFont(resources.getKpiFont()); indicator.setText(""); //$NON-NLS-1$ GridDataFactory.fillDefaults().grab(true, false).applyTo(indicator); return container; } @Override Control getTitleControl() { return title; } @Override void update() { this.title.setText(getWidget().getLabel()); } }