Search in sources :

Example 1 with BarChartConfig

use of org.netxms.ui.eclipse.dashboard.widgets.internal.BarChartConfig in project netxms by netxms.

the class AbstractChart method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    config = (AbstractChartConfig) getElement().getAdapter(AbstractChartConfig.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = false;
    dialogArea.setLayout(layout);
    title = new LabeledText(dialogArea, SWT.NONE);
    title.setLabel(Messages.get().AbstractChart_Title);
    title.setText(config.getTitle());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    title.setLayoutData(gd);
    legendPosition = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, Messages.get().AbstractChart_LegendPosition, WidgetHelper.DEFAULT_LAYOUT_DATA);
    legendPosition.add(Messages.get().AbstractChart_Left);
    legendPosition.add(Messages.get().AbstractChart_Right);
    legendPosition.add(Messages.get().AbstractChart_Top);
    legendPosition.add(Messages.get().AbstractChart_Bottom);
    legendPosition.select(positionIndexFromValue(config.getLegendPosition()));
    Group optionsGroup = new Group(dialogArea, SWT.NONE);
    optionsGroup.setText(Messages.get().AbstractChart_Options);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalSpan = (config instanceof LineChartConfig) ? 3 : 2;
    optionsGroup.setLayoutData(gd);
    GridLayout optionsLayout = new GridLayout();
    optionsGroup.setLayout(optionsLayout);
    checkShowTitle = new Button(optionsGroup, SWT.CHECK);
    checkShowTitle.setText(Messages.get().AbstractChart_ShowTitle);
    checkShowTitle.setSelection(config.isShowTitle());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    checkShowTitle.setLayoutData(gd);
    checkShowLegend = new Button(optionsGroup, SWT.CHECK);
    checkShowLegend.setText(Messages.get().AbstractChart_ShowLegend);
    checkShowLegend.setSelection(config.isShowLegend());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    checkShowLegend.setLayoutData(gd);
    if (config instanceof LineChartConfig) {
        checkExtendedLegend = new Button(optionsGroup, SWT.CHECK);
        checkExtendedLegend.setText(Messages.get().AbstractChart_ExtendedLegend);
        checkExtendedLegend.setSelection(((LineChartConfig) config).isExtendedLegend());
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        checkExtendedLegend.setLayoutData(gd);
        checkLogScale = new Button(optionsGroup, SWT.CHECK);
        checkLogScale.setText(Messages.get().AbstractChart_LogartithmicScale);
        checkLogScale.setSelection(((LineChartConfig) config).isLogScaleEnabled());
        gd = new GridData();
        gd.horizontalSpan = layout.numColumns;
        checkLogScale.setLayoutData(gd);
        checkStacked = new Button(optionsGroup, SWT.CHECK);
        checkStacked.setText(Messages.get().AbstractChart_Stacked);
        checkStacked.setSelection(((LineChartConfig) config).isStacked());
        gd = new GridData();
        gd.horizontalSpan = layout.numColumns;
        checkStacked.setLayoutData(gd);
        checkAreaChart = new Button(optionsGroup, SWT.CHECK);
        checkAreaChart.setText("&Area chart");
        checkAreaChart.setSelection(((LineChartConfig) config).isArea());
        gd = new GridData();
        gd.horizontalSpan = layout.numColumns;
        checkAreaChart.setLayoutData(gd);
    }
    checkTranslucent = new Button(optionsGroup, SWT.CHECK);
    checkTranslucent.setText(Messages.get().AbstractChart_Translucent);
    checkTranslucent.setSelection(config.isTranslucent());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    checkTranslucent.setLayoutData(gd);
    if (config instanceof ComparisonChartConfig) {
        checkShowIn3D = new Button(optionsGroup, SWT.CHECK);
        checkShowIn3D.setText(Messages.get().AbstractChart_3DView);
        checkShowIn3D.setSelection(((ComparisonChartConfig) config).isShowIn3D());
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        checkShowIn3D.setLayoutData(gd);
        if ((config instanceof BarChartConfig) || (config instanceof TubeChartConfig)) {
            checkTransposed = new Button(optionsGroup, SWT.CHECK);
            checkTransposed.setText(Messages.get().AbstractChart_Transposed);
            checkTransposed.setSelection((config instanceof BarChartConfig) ? ((BarChartConfig) config).isTransposed() : ((TubeChartConfig) config).isTransposed());
            gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            checkTransposed.setLayoutData(gd);
        }
    }
    if (config instanceof LineChartConfig) {
        checkShowGrid = new Button(optionsGroup, SWT.CHECK);
        checkShowGrid.setText(Messages.get().AbstractChart_ShowGrid);
        checkShowGrid.setSelection(((LineChartConfig) config).isShowGrid());
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        checkShowGrid.setLayoutData(gd);
        checkInteractive = new Button(optionsGroup, SWT.CHECK);
        checkInteractive.setText("&Interactive");
        checkInteractive.setSelection(((LineChartConfig) config).isInteractive());
        gd = new GridData();
        gd.horizontalSpan = layout.numColumns;
        checkInteractive.setLayoutData(gd);
        Composite timeRangeArea = new Composite(dialogArea, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
        timeRangeArea.setLayout(layout);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        timeRangeArea.setLayoutData(gd);
        timeRange = WidgetHelper.createLabeledSpinner(timeRangeArea, SWT.BORDER, Messages.get().AbstractChart_TimeInterval, 1, 10000, WidgetHelper.DEFAULT_LAYOUT_DATA);
        timeRange.setSelection(((LineChartConfig) config).getTimeRange());
        timeUnits = WidgetHelper.createLabeledCombo(timeRangeArea, SWT.READ_ONLY, Messages.get().AbstractChart_TimeUnits, WidgetHelper.DEFAULT_LAYOUT_DATA);
        timeUnits.add(Messages.get().AbstractChart_Minutes);
        timeUnits.add(Messages.get().AbstractChart_Hours);
        timeUnits.add(Messages.get().AbstractChart_Days);
        timeUnits.select(((LineChartConfig) config).getTimeUnits());
    }
    Composite rateAndWidthArea = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = (config instanceof LineChartConfig) ? 2 : 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.makeColumnsEqualWidth = true;
    rateAndWidthArea.setLayout(layout);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    rateAndWidthArea.setLayoutData(gd);
    refreshRate = new LabeledSpinner(rateAndWidthArea, SWT.NONE);
    refreshRate.setLabel(Messages.get().AbstractChart_RefreshInterval);
    refreshRate.setRange(1, 10000);
    refreshRate.setSelection(config.getRefreshRate());
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    refreshRate.setLayoutData(gd);
    if (config instanceof LineChartConfig) {
        lineWidth = new LabeledSpinner(rateAndWidthArea, SWT.NONE);
        lineWidth.setLabel(Messages.get().AbstractChart_LineWidth);
        lineWidth.setRange(1, 32);
        lineWidth.setSelection(((LineChartConfig) config).getLineWidth());
        gd = new GridData();
        gd.verticalAlignment = SWT.TOP;
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        lineWidth.setLayoutData(gd);
    }
    if (!(config instanceof PieChartConfig)) {
        yAxisRange = new YAxisRangeEditor(dialogArea, SWT.NONE);
        gd = new GridData();
        gd.horizontalSpan = layout.numColumns;
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        yAxisRange.setLayoutData(gd);
        yAxisRange.setSelection(config.isAutoScale(), config.modifyYBase(), config.getMinYScaleValue(), config.getMaxYScaleValue());
    }
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) BarChartConfig(org.netxms.ui.eclipse.dashboard.widgets.internal.BarChartConfig) TubeChartConfig(org.netxms.ui.eclipse.dashboard.widgets.internal.TubeChartConfig) PieChartConfig(org.netxms.ui.eclipse.dashboard.widgets.internal.PieChartConfig) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) GridLayout(org.eclipse.swt.layout.GridLayout) ComparisonChartConfig(org.netxms.ui.eclipse.dashboard.widgets.internal.ComparisonChartConfig) Button(org.eclipse.swt.widgets.Button) LineChartConfig(org.netxms.ui.eclipse.dashboard.widgets.internal.LineChartConfig) GridData(org.eclipse.swt.layout.GridData) YAxisRangeEditor(org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor)

Aggregations

GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 BarChartConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.BarChartConfig)1 ComparisonChartConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.ComparisonChartConfig)1 LineChartConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.LineChartConfig)1 PieChartConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.PieChartConfig)1 TubeChartConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.TubeChartConfig)1 YAxisRangeEditor (org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor)1 LabeledSpinner (org.netxms.ui.eclipse.widgets.LabeledSpinner)1 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)1