use of org.talend.designer.runtime.visualization.IActiveJvm in project tdi-studio-se by Talend.
the class MBeanLabelProvider method getStyledText.
/*
* @see DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText( Object)
*/
@Override
public StyledString getStyledText(Object element) {
StyledString text = new StyledString();
boolean appendSuffix = false;
ObjectName objectName = null;
IActiveJvm jvm = null;
if (element instanceof IMBeanNode) {
text.append(((IMBeanNode) element).getName());
if (element instanceof MBean && ((MBean) element).isNotificationSubsctibed()) {
appendSuffix = true;
jvm = ((MBean) element).getJvm();
}
}
if (appendSuffix && jvm != null) {
int notificationCount = jvm.getMBeanServer().getMBeanNotification().getNotifications(objectName).length;
//$NON-NLS-1$ //$NON-NLS-2$
String suffix = " [notifications: " + notificationCount + "]";
int offset = text.length();
text.append(suffix);
text.setStyle(offset, suffix.length(), StyledString.DECORATIONS_STYLER);
}
return text;
}
use of org.talend.designer.runtime.visualization.IActiveJvm in project tdi-studio-se by Talend.
the class ConfigureCpuProfilerAction method run.
/*
* @see Action#run()
*/
@Override
public void run() {
// get the profiled packages
final Job getProfiledPackagesJob = new Job(Messages.getProfiledPackagesJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IActiveJvm jvm = cpuSection.getJvm();
if (jvm == null) {
return Status.CANCEL_STATUS;
}
try {
packages = jvm.getCpuProfiler().getProfiledPackages();
} catch (JvmCoreException e) {
Activator.log(Messages.getProfiledPackagesFailedMsg, e);
}
return Status.OK_STATUS;
}
};
getProfiledPackagesJob.schedule();
// open CPU profiler configuration dialog
Job openDialogJob = new Job(Messages.openDialogJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
getProfiledPackagesJob.join();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
openDialog();
}
});
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
openDialogJob.schedule();
}
use of org.talend.designer.runtime.visualization.IActiveJvm in project tdi-studio-se by Talend.
the class ConfigureCpuProfilerAction method openDialog.
/**
* Opens the dialog.
*/
void openDialog() {
IActiveJvm jvm = cpuSection.getJvm();
if (jvm == null) {
return;
}
final ConfigurationDialog dialog = new ConfigurationDialog(cpuSection.getPart().getSite().getShell(), jvm.getCpuProfiler().getProfilerType(), jvm.getCpuProfiler().getSamplingPeriod(), jvm.getCpuProfiler().getState(ProfilerType.BCI), packages);
if (dialog.open() != Window.OK) {
return;
}
new Job(Messages.configureProfilerJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
return doConfigure(monitor, dialog);
}
}.schedule();
}
use of org.talend.designer.runtime.visualization.IActiveJvm in project tdi-studio-se by Talend.
the class ConfigureCpuProfilerAction method setPackages.
/**
* Sets the packages.
*
* @param packages The packages
* @param monitor The progress monitor
* @return The packages string with delimiter ','
*/
String setPackages(Set<String> packages, IProgressMonitor monitor) {
IActiveJvm jvm = cpuSection.getJvm();
if (jvm != null) {
try {
jvm.getCpuProfiler().setProfiledPackages(packages);
if (jvm.getCpuProfiler().getProfilerType() == ProfilerType.BCI && jvm.getCpuProfiler().getState() == ProfilerState.RUNNING) {
jvm.getCpuProfiler().transformClasses(monitor);
}
} catch (JvmCoreException e) {
Activator.log(Messages.setProfiledPackagesFailedMsg, e);
} catch (InterruptedException e) {
// do nothing
}
}
StringBuffer buffer = new StringBuffer();
for (String item : packages) {
if (buffer.length() > 0) {
buffer.append(',');
}
buffer.append(item);
}
return buffer.toString();
}
use of org.talend.designer.runtime.visualization.IActiveJvm in project tdi-studio-se by Talend.
the class ConfigureCpuProfilerAction method doConfigure.
/**
* Configures the profiler.
*
* @param monitor The progress monitor
* @param dialog The configuration dialog
* @return The status
*/
IStatus doConfigure(IProgressMonitor monitor, ConfigurationDialog dialog) {
IActiveJvm jvm = cpuSection.getJvm();
if (jvm == null) {
return Status.CANCEL_STATUS;
}
IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings(CpuSection.class.getName());
ProfilerType type = dialog.getProfilerType();
if (jvm.getCpuProfiler().getProfilerType() != type) {
if (jvm.getCpuProfiler().getState() == ProfilerState.RUNNING) {
new SuspendCpuProfilingAction(cpuSection).run();
}
new ClearCpuProfilingDataAction(cpuSection).run();
jvm.getCpuProfiler().setProfilerType(type);
}
if (type == ProfilerType.SAMPLING) {
int samplingPeriod = dialog.getSamplingPeriod();
jvm.getCpuProfiler().setSamplingPeriod(samplingPeriod);
dialogSettings.put(IConstants.PROFILER_SAMPLING_PERIOD_KEY, samplingPeriod);
}
String packageString = setPackages(dialog.getPackages(), monitor);
dialogSettings.put(IConstants.PACKAGES_KEY, packageString);
dialogSettings.put(IConstants.PROFILER_TYPE_KEY, type.name());
return Status.OK_STATUS;
}
Aggregations