Search in sources :

Example 1 with IMonitoredMXBeanGroup

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

the class ConfigChartAction method run.

/*
     * @see Action#run()
     */
@Override
public void run() {
    IActiveJvm jvm = runtimeComposite.getJvm();
    if (jvm == null) {
        return;
    }
    String title = chart.getSection().getText();
    IMonitoredMXBeanGroup group = chart.getAttributeGroup();
    AxisUnit unit = group.getAxisUnit();
    List<MBeanAttribute> attributes = getAttributes();
    ConfigureChartDialog dialog = new ConfigureChartDialog(chart.getShell(), title, unit, attributes, jvm, true);
    if (dialog.open() == Window.OK) {
        performConfiguration(dialog.getChartTitle(), dialog.getAxisUnit(), dialog.getAttributes(), dialog.getRemovedAttributes());
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) AxisUnit(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit)

Example 2 with IMonitoredMXBeanGroup

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

the class ConfigChartAction 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 3 with IMonitoredMXBeanGroup

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

the class ConfigureChartAction method run.

/*
     * @see Action#run()
     */
@Override
public void run() {
    IActiveJvm jvm = section.getJvm();
    if (jvm == null) {
        return;
    }
    String title = chart.getSection().getText();
    IMonitoredMXBeanGroup group = chart.getAttributeGroup();
    AxisUnit unit = group.getAxisUnit();
    List<MBeanAttribute> attributes = getAttributes();
    ConfigureChartDialog dialog = new ConfigureChartDialog(chart.getShell(), title, unit, attributes, jvm, true);
    if (dialog.open() == Window.OK) {
        performConfiguration(dialog.getChartTitle(), dialog.getAxisUnit(), dialog.getAttributes(), dialog.getRemovedAttributes());
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) AxisUnit(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit)

Example 4 with IMonitoredMXBeanGroup

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

the class ConfigureChartDialog method validate.

/**
     * Validates the entered title name.
     * 
     * @param text The entered text
     */
void validate(String text) {
    //$NON-NLS-1$
    String errorMessage = "";
    for (IMonitoredMXBeanGroup group : jvm.getMBeanServer().getMonitoredAttributeGroups()) {
        if (group.getName().equals(text) && !originalChartTitle.equals(text)) {
            errorMessage = Messages.chartTitleDuplicatedMsg;
            break;
        }
    }
    if (text.isEmpty()) {
        errorMessage = Messages.chartTitleEmptyMsg;
    }
    errorImageLabel.setVisible(!errorMessage.isEmpty());
    errorMessageLabel.setText(errorMessage);
    setOkButtonVisible(errorMessage.isEmpty());
}
Also used : IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)

Example 5 with IMonitoredMXBeanGroup

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

the class LoadChartSetAction method loadChartSet.

/**
     * Loads the given memento of chart set.
     * 
     * @param memento The memento
     * @throws JvmCoreException
     */
private void loadChartSet(IMemento memento) throws JvmCoreException {
    IMBeanServer server = section.getJvm().getMBeanServer();
    server.getMonitoredAttributeGroups().clear();
    StringBuffer buffer = new StringBuffer();
    for (IMemento groupMemento : memento.getChildren(GROUP)) {
        IMonitoredMXBeanGroup group = server.addMonitoredAttributeGroup(groupMemento.getID(), AxisUnit.valueOf(groupMemento.getString(UNIT)));
        for (IMemento attributeMemento : groupMemento.getChildren(ATTRIBUTE)) {
            String objectName = attributeMemento.getString(OBJECT_NAME);
            String attributeName = attributeMemento.getID();
            if (attributeExist(objectName, attributeName)) {
                group.addAttribute(objectName, attributeName, getRGB(attributeMemento.getString(COLOR)));
            } else {
                buffer.append('\n');
                buffer.append(objectName + ':' + attributeName);
            }
        }
    }
    if (buffer.length() > 0) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.errorDialogTitle, NLS.bind(Messages.attributeNotSupportedMsg, buffer.toString()));
    }
}
Also used : IMBeanServer(org.talend.designer.runtime.visualization.MBean.IMBeanServer) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) IMemento(org.eclipse.ui.IMemento)

Aggregations

IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)22 IMBeanServer (org.talend.designer.runtime.visualization.MBean.IMBeanServer)7 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)6 IMonitoredMXBeanAttribute (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute)6 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)5 ObjectName (javax.management.ObjectName)4 RGB (org.eclipse.swt.graphics.RGB)4 Date (java.util.Date)3 IMemento (org.eclipse.ui.IMemento)3 AxisUnit (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit)2 MBeanServerEvent (org.talend.designer.runtime.visualization.MBean.MBeanServerEvent)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1