Search in sources :

Example 1 with ProfilerState

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();
}
Also used : RefreshJob(org.talend.designer.runtime.visualization.internal.ui.RefreshJob) IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IHost(org.talend.designer.runtime.visualization.IHost) ProfilerState(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuProfiler.ProfilerState)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)1 IHost (org.talend.designer.runtime.visualization.IHost)1 ProfilerState (org.talend.designer.runtime.visualization.internal.core.cpu.ICpuProfiler.ProfilerState)1 RefreshJob (org.talend.designer.runtime.visualization.internal.ui.RefreshJob)1