Search in sources :

Example 1 with PerfTabGraphSettings

use of org.netxms.ui.eclipse.perfview.PerfTabGraphSettings in project netxms by netxms.

the class PerfTab method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = (Composite) super.createContents(parent);
    dci = editor.getObjectAsItem();
    try {
        settings = PerfTabGraphSettings.createFromXml(dci.getPerfTabSettings());
    } catch (Exception e) {
        // Create default empty settings
        settings = new PerfTabGraphSettings();
    }
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 4;
    dialogArea.setLayout(layout);
    checkShow = new Button(dialogArea, SWT.CHECK);
    checkShow.setText(Messages.get().PerfTab_ShowOnPerfTab);
    checkShow.setSelection(settings.isEnabled());
    GridData gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkShow.setLayoutData(gd);
    title = new LabeledText(dialogArea, SWT.NONE);
    title.setLabel(Messages.get().PerfTab_Title);
    title.setText(settings.getTitle());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    title.setLayoutData(gd);
    Composite colors = new Composite(dialogArea, SWT.NONE);
    colors.setLayout(new RowLayout(SWT.VERTICAL));
    new Label(colors, SWT.NONE).setText(Messages.get().PerfTab_Color);
    color = new ColorSelector(colors);
    color.setColorValue(ColorConverter.rgbFromInt(settings.getColorAsInt()));
    type = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, Messages.get().PerfTab_Type, new GridData(SWT.LEFT, SWT.CENTER, false, false));
    type.add(Messages.get().PerfTab_Line);
    type.add(Messages.get().PerfTab_Area);
    type.select(settings.getType());
    orderNumber = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().PerfTab_Order, 0, 65535, new GridData(SWT.LEFT, SWT.CENTER, false, false));
    orderNumber.setSelection(settings.getOrder());
    groupName = new LabeledText(dialogArea, SWT.NONE);
    groupName.setLabel("Group");
    groupName.setText(settings.getGroupName());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    groupName.setLayoutData(gd);
    name = new LabeledText(dialogArea, SWT.NONE);
    name.setLabel(Messages.get().PerfTab_NameInLegend);
    name.setText(settings.getName());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = layout.numColumns;
    name.setLayoutData(gd);
    Group timeGroup = new Group(dialogArea, SWT.NONE);
    timeGroup.setText(Messages.get().PerfTab_TeimePeriod);
    GridLayout timeGroupLayout = new GridLayout();
    timeGroupLayout.marginWidth = WidgetHelper.OUTER_SPACING;
    timeGroupLayout.marginHeight = WidgetHelper.OUTER_SPACING;
    timeGroupLayout.horizontalSpacing = 16;
    timeGroupLayout.makeColumnsEqualWidth = true;
    timeGroupLayout.numColumns = 1;
    timeGroup.setLayout(timeGroupLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = timeGroupLayout.numColumns;
    timeGroup.setLayoutData(gd);
    Composite timeRangeArea = new Composite(timeGroup, SWT.NONE);
    timeGroupLayout = new GridLayout();
    timeGroupLayout.numColumns = 2;
    timeGroupLayout.marginWidth = 0;
    timeGroupLayout.marginHeight = 0;
    timeGroupLayout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    timeRangeArea.setLayout(timeGroupLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    timeRangeArea.setLayoutData(gd);
    timeRange = WidgetHelper.createLabeledSpinner(timeRangeArea, SWT.BORDER, Messages.get().PerfTab_TimeInterval, 1, 10000, WidgetHelper.DEFAULT_LAYOUT_DATA);
    timeRange.setSelection(settings.getTimeRange());
    timeUnits = WidgetHelper.createLabeledCombo(timeRangeArea, SWT.READ_ONLY, Messages.get().PerfTab_TimeUnits, WidgetHelper.DEFAULT_LAYOUT_DATA);
    timeUnits.add(Messages.get().PerfTab_Minutes);
    timeUnits.add(Messages.get().PerfTab_Hours);
    timeUnits.add(Messages.get().PerfTab_Days);
    timeUnits.select(settings.getTimeUnits());
    Group optionsGroup = new Group(dialogArea, SWT.NONE);
    optionsGroup.setText(Messages.get().PerfTab_Options);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 3;
    gd.verticalSpan = 2;
    optionsGroup.setLayoutData(gd);
    GridLayout optionsLayout = new GridLayout();
    optionsGroup.setLayout(optionsLayout);
    checkShowThresholds = new Button(optionsGroup, SWT.CHECK);
    checkShowThresholds.setText(Messages.get().PerfTab_ShowThresholds);
    checkShowThresholds.setSelection(settings.isShowThresholds());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkShowThresholds.setLayoutData(gd);
    checkLogScale = new Button(optionsGroup, SWT.CHECK);
    checkLogScale.setText(Messages.get().PerfTab_LogarithmicScale);
    checkLogScale.setSelection(settings.isLogScaleEnabled());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkLogScale.setLayoutData(gd);
    checkStacked = new Button(optionsGroup, SWT.CHECK);
    checkStacked.setText("&Stacked");
    checkStacked.setSelection(settings.isStacked());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkStacked.setLayoutData(gd);
    checkShowLegendAlways = new Button(optionsGroup, SWT.CHECK);
    checkShowLegendAlways.setText("Always show &legend");
    checkShowLegendAlways.setSelection(settings.isShowLegendAlways());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkShowLegendAlways.setLayoutData(gd);
    checkExtendedLegend = new Button(optionsGroup, SWT.CHECK);
    checkExtendedLegend.setText("&Extended legend");
    checkExtendedLegend.setSelection(settings.isExtendedLegend());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkExtendedLegend.setLayoutData(gd);
    checkInvertValues = new Button(optionsGroup, SWT.CHECK);
    checkInvertValues.setText("&Inverted values");
    checkInvertValues.setSelection(settings.isInvertedValues());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkInvertValues.setLayoutData(gd);
    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(settings.isAutoScale(), settings.modifyYBase(), settings.getMinYScaleValue(), settings.getMaxYScaleValue());
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) RowLayout(org.eclipse.swt.layout.RowLayout) PerfTabGraphSettings(org.netxms.ui.eclipse.perfview.PerfTabGraphSettings) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) YAxisRangeEditor(org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 2 with PerfTabGraphSettings

use of org.netxms.ui.eclipse.perfview.PerfTabGraphSettings in project netxms by netxms.

the class PerformanceTab method update.

/**
 * Update tab with received DCIs
 *
 * @param items Performance tab items
 */
private void update(final PerfTabDci[] items) {
    if (waitingImage != null) {
        waitingImage.dispose();
        waitingImage = null;
    }
    for (PerfTabGraph chart : charts.values()) chart.dispose();
    charts.clear();
    List<PerfTabGraphSettings> settings = new ArrayList<PerfTabGraphSettings>(items.length);
    for (int i = 0; i < items.length; i++) {
        try {
            PerfTabGraphSettings s = PerfTabGraphSettings.createFromXml(items[i].getPerfTabSettings());
            if (s.isEnabled()) {
                s.setRuntimeDciInfo(items[i]);
                settings.add(s);
            }
        } catch (Exception e) {
        }
    }
    // Sort DCIs: by group name, then by order number, then alphabetically
    Collections.sort(settings, new Comparator<PerfTabGraphSettings>() {

        @Override
        public int compare(PerfTabGraphSettings o1, PerfTabGraphSettings o2) {
            int result = Integer.signum(o1.getOrder() - o2.getOrder());
            if (result == 0)
                result = o1.getGroupName().compareToIgnoreCase(o2.getGroupName());
            if (result == 0) {
                // Sort top-level DCI's by chart title, and attached DCIs by legend name
                if (o1.getGroupName().isEmpty())
                    result = o1.getRuntimeTitle().compareToIgnoreCase(o2.getRuntimeTitle());
                else
                    result = o1.getRuntimeName().compareToIgnoreCase(o2.getRuntimeName());
            }
            return result;
        }
    });
    for (PerfTabGraphSettings s : settings) {
        String groupName = s.getGroupName();
        PerfTabGraph chart = groupName.isEmpty() ? null : charts.get(groupName);
        if (chart == null) {
            chart = new PerfTabGraph(chartArea, getObject().getObjectId(), s.getRuntimeDciInfo(), s, getViewPart(), new VisibilityValidator() {

                @Override
                public boolean isVisible() {
                    return isActive();
                }
            });
            charts.put(groupName.isEmpty() ? "##" + Long.toString(s.getRuntimeDciInfo().getId()) : groupName, chart);
            final GridData gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            gd.heightHint = 320;
            chart.setLayoutData(gd);
        } else {
            chart.addItem(s.getRuntimeDciInfo(), s);
        }
    }
    for (PerfTabGraph chart : charts.values()) chart.start();
    updateChartAreaLayout();
}
Also used : VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) PerfTabGraphSettings(org.netxms.ui.eclipse.perfview.PerfTabGraphSettings) ArrayList(java.util.ArrayList) GridData(org.eclipse.swt.layout.GridData) PerfTabGraph(org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph) MalformedURLException(java.net.MalformedURLException)

Example 3 with PerfTabGraphSettings

use of org.netxms.ui.eclipse.perfview.PerfTabGraphSettings in project netxms by netxms.

the class PerfTab method performDefaults.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
	 */
@Override
protected void performDefaults() {
    super.performDefaults();
    PerfTabGraphSettings defaults = new PerfTabGraphSettings();
    checkShow.setSelection(defaults.isEnabled());
    title.setText(defaults.getTitle());
    color.setColorValue(ColorConverter.rgbFromInt(defaults.getColorAsInt()));
    groupName.setText("");
    orderNumber.setSelection(100);
}
Also used : PerfTabGraphSettings(org.netxms.ui.eclipse.perfview.PerfTabGraphSettings)

Aggregations

PerfTabGraphSettings (org.netxms.ui.eclipse.perfview.PerfTabGraphSettings)3 GridData (org.eclipse.swt.layout.GridData)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 ColorSelector (org.eclipse.jface.preference.ColorSelector)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 PerfTabGraph (org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph)1 YAxisRangeEditor (org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor)1 VisibilityValidator (org.netxms.ui.eclipse.tools.VisibilityValidator)1 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)1