use of org.talend.designer.runtime.visualization.internal.core.cpu.ICpuProfiler.ProfilerState in project tdi-studio-se by Talend.
the class JvmTreeViewer method updateStatusLine.
/**
* Updates the status line.
*
* @param selection the selection
*/
void updateStatusLine(final IStructuredSelection selection) {
RefreshJob refreshJob = new RefreshJob(Messages.refreshStatusLineJobLabel, JvmTreeViewer.class.getName()) {
private ProfilerState state;
private Object element;
@Override
protected void refreshModel(IProgressMonitor monitor) {
element = selection.getFirstElement();
if (element instanceof IActiveJvm) {
IActiveJvm activeJvm = (IActiveJvm) element;
state = activeJvm.getCpuProfiler().getState();
}
}
@Override
protected void refreshUI() {
StringBuffer text = new StringBuffer();
StringBuffer errorText = new StringBuffer();
errorImage = null;
if (element instanceof IActiveJvm) {
IActiveJvm activeJvm = (IActiveJvm) element;
if (activeJvm.isConnected()) {
text.append(Messages.connectedMsg);
if (state == ProfilerState.RUNNING) {
//$NON-NLS-1$
text.append(" ").append(Messages.cpuProfilerRunningMsg);
}
} else if (!activeJvm.isConnectionSupported()) {
String errorMessage = activeJvm.getErrorStateMessage();
if (errorMessage != null) {
errorText.append(errorMessage);
}
} else {
text.append(Messages.disconnectedMsg);
}
} else if (element instanceof IHost) {
IHost host = (IHost) element;
if (host.getName().equals(IHost.LOCALHOST)) {
if (!JvmModel.getInstance().hasValidJdk()) {
errorText.append(Messages.invalidJdkLocationMsg);
errorImage = getErrorImage();
} else if (host.getActiveJvms().isEmpty()) {
errorText.append(Messages.cannnotDetectJvmMsg);
errorImage = getErrorImage();
}
}
}
statusLineManager.setErrorMessage(errorImage, errorText.toString());
statusLineItem.setText(text.toString());
}
};
refreshJob.schedule();
}
Aggregations