Search in sources :

Example 11 with IMonitoredMXBeanAttribute

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.

the class ConfigureChartAction method performConfiguration.

/**
     * Performs the configuration.
     * 
     * @param chartTitle The chart title
     * @param axisUnit The axis unit
     * @param attributes The attributes
     * @param removedAttributes The removed attributes
     */
private void performConfiguration(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes, List<MBeanAttribute> removedAttributes) {
    IMonitoredMXBeanGroup group = chart.getAttributeGroup();
    group.setName(chartTitle);
    group.setAxisUnit(axisUnit);
    for (MBeanAttribute attribute : attributes) {
        ObjectName objectName = attribute.getObjectName();
        String attributeName = attribute.getAttributeName();
        IMonitoredMXBeanAttribute monitoredAttribute = group.getAttribute(objectName, attributeName);
        RGB rgb = attribute.getRgb();
        if (monitoredAttribute == null) {
            try {
                group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
            } catch (JvmCoreException e) {
                Activator.log(Messages.addAttributeFailedMsg, e);
            }
        } else {
            monitoredAttribute.setRGB(rgb.red, rgb.green, rgb.blue);
        }
    }
    for (MBeanAttribute removedAttribute : removedAttributes) {
        group.removeAttribute(removedAttribute.getObjectName().getCanonicalName(), removedAttribute.getAttributeName());
    }
    chart.refresh();
}
Also used : IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 12 with IMonitoredMXBeanAttribute

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.

the class TimelineChart method refreshChartWidget.

/**
     * Refreshes the chart widget.
     */
void refreshChartWidget() {
    if (isDisposed()) {
        return;
    }
    deleteMonitoredSeries();
    for (IMonitoredMXBeanAttribute attribute : attributeGroup.getAttributes()) {
        String seriesId = getSeriesId(attribute);
        ISeries series = getSeriesSet().getSeries(seriesId);
        if (series == null) {
            boolean enableArea = true;
            series = addMonitoredSeries(attribute, enableArea);
            if (series == null) {
                return;
            }
        }
        series.setXDateSeries(attribute.getDates().toArray(new Date[0]));
        series.setYSeries(getYSeries(attribute));
        setColor((ILineSeries) series, attribute.getRGB());
    }
    AxisUnit axisUnit = attributeGroup.getAxisUnit();
    if (axisUnit == AxisUnit.MBytes) {
        //$NON-NLS-1$
        getAxisSet().getYAxis(0).getTick().setFormat(new DecimalFormat("#####.#M"));
        getAxisSet().adjustRange();
    } else if (axisUnit == AxisUnit.Percent) {
        //$NON-NLS-1$
        getAxisSet().getYAxis(0).getTick().setFormat(new DecimalFormat("###%"));
        getAxisSet().getXAxis(0).adjustRange();
        int y = getSize().y;
        if (y > 0) {
            getAxisSet().getYAxis(0).setRange(new Range(0, (y + 10) / (double) y));
        }
    } else if (axisUnit == AxisUnit.Count) {
        getAxisSet().getYAxis(0).getTick().setFormat(NumberFormat.getIntegerInstance());
        getAxisSet().adjustRange();
    } else {
        getAxisSet().adjustRange();
    }
    section.setText(attributeGroup.getName());
    section.layout();
    marker.redraw();
    redraw();
}
Also used : AxisUnit(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit) DecimalFormat(java.text.DecimalFormat) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) Range(org.swtchart.Range) ISeries(org.swtchart.ISeries) Date(java.util.Date)

Aggregations

IMonitoredMXBeanAttribute (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute)12 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 ObjectName (javax.management.ObjectName)4 RGB (org.eclipse.swt.graphics.RGB)4 ISeries (org.swtchart.ISeries)2 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)2 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)2 DecimalFormat (java.text.DecimalFormat)1 List (java.util.List)1 Action (org.eclipse.jface.action.Action)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 IMemento (org.eclipse.ui.IMemento)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 ISeriesSet (org.swtchart.ISeriesSet)1