Search in sources :

Example 1 with MBeanAttribute

use of org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute in project tdi-studio-se by Talend.

the class ShowInTimelineAction method selectionChanged.

/*
     * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
     */
@Override
public void selectionChanged(SelectionChangedEvent event) {
    IActiveJvm jvm = section.getJvm();
    if (!(event.getSelection() instanceof StructuredSelection) || jvm == null || !jvm.isConnected()) {
        setEnabled(false);
        return;
    }
    Object[] elements = ((StructuredSelection) event.getSelection()).toArray();
    if (elements.length == 0) {
        setEnabled(false);
        return;
    }
    boolean enabled = true;
    selections.clear();
    for (Object element : elements) {
        MBeanAttribute attribute = getMBeanAttribute(element);
        if (attribute != null) {
            selections.add(attribute);
        }
        if (!getEnabled(element)) {
            enabled = false;
        }
    }
    setEnabled(enabled);
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MBeanAttribute(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute)

Example 2 with MBeanAttribute

use of org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute in project tdi-studio-se by Talend.

the class ShowInTimelineAction method performShowInTimeline.

/**
     * Performs showing a new chart with attributes in Timeline tab.
     * 
     * @param chartTitle The chart title
     * @param axisUnit The axis unit
     * @param attributes The attributes
     */
private void performShowInTimeline(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes) {
    IActiveJvm jvm = section.getJvm();
    if (jvm == null) {
        return;
    }
    IMonitoredMXBeanGroup group = jvm.getMBeanServer().addMonitoredAttributeGroup(chartTitle, axisUnit);
    for (MBeanAttribute attribute : attributes) {
        ObjectName objectName = attribute.getObjectName();
        String attributeName = attribute.getAttributeName();
        RGB rgb = attribute.getRgb();
        try {
            group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
        } catch (JvmCoreException e) {
            Activator.log(NLS.bind(Messages.addAttributeFailedMsg, attributeName), e);
        }
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) MBeanAttribute(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)2 MBeanAttribute (org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute)2 ObjectName (javax.management.ObjectName)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 RGB (org.eclipse.swt.graphics.RGB)1 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)1 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)1