Search in sources :

Example 1 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class CliExecutor method processInfoOutput.

/**
 * Tries to parse in mctr_cli's answer to the info command.
 *
 * @param stdout the output of the process to be parsed.
 */
private void processInfoOutput(final BufferedReader stdout) {
    Matcher matcher;
    MainControllerElement tempRoot = new MainControllerElement("Temporal root", this);
    readFullLineOnly(stdout);
    if (fastLine == null) {
        return;
    }
    matcher = MC_STATE_PATTERN.matcher(fastLine);
    if (matcher.matches()) {
        String mcStateName = matcher.group(1);
        tempRoot.setStateInfo(new InformationElement("State: " + mcStateName));
        readFullLineOnly(stdout);
        suspectedLastState = getMCStateFromName(mcStateName);
    } else {
        fastLine = null;
        return;
    }
    if (fastLine != null && " host information:".equals(fastLine)) {
        readFullLineOnly(stdout);
    } else {
        fastLine = null;
        return;
    }
    if (fastLine != null) {
        if (fastLine.startsWith("  -")) {
            // host list
            while (fastLine != null && fastLine.startsWith("  -")) {
                processInfoOutputHC(stdout, tempRoot);
            }
        } else if ("  no HCs are connected".equals(fastLine)) {
            readFullLineOnly(stdout);
        }
    } else {
        fastLine = null;
        return;
    }
    if (fastLine != null && PAUSE_PATTERN.matcher(fastLine).matches()) {
        tempRoot.setPauseInfo(new InformationElement(fastLine.trim()));
        readFullLineOnly(stdout);
    } else {
        fastLine = null;
        return;
    }
    if (fastLine != null && CONSOLE_LOGGING_PATTERN.matcher(fastLine).matches()) {
        tempRoot.setConsoleLoggingInfo(new InformationElement(fastLine.trim()));
    } else {
        fastLine = null;
        return;
    }
    if (mainControllerRoot != null) {
        mainControllerRoot.children().clear();
        mainControllerRoot.transferData(tempRoot);
    }
}
Also used : Matcher(java.util.regex.Matcher) MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement) InformationElement(org.eclipse.titan.executor.views.executormonitor.InformationElement)

Example 2 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class JniExecutor method updateInfoDisplay.

/**
 * Updates the information displayed about the MainController's and HostControllers actual states.
 */
private void updateInfoDisplay() {
    JNIMiddleWare middleware = jnimw;
    McStateEnum mcState = middleware.get_state();
    MainControllerElement tempRoot = new MainControllerElement("Temporal root", this);
    String mcStateName = middleware.get_mc_state_name(mcState);
    tempRoot.setStateInfo(new InformationElement("state: " + mcStateName));
    HostControllerElement tempHost;
    ComponentStruct comp;
    QualifiedName qualifiedName;
    ComponentElement tempComponent;
    StringBuilder builder;
    int nofHosts = middleware.get_nof_hosts();
    HostStruct host;
    for (int i = 0; i < nofHosts; i++) {
        host = middleware.get_host_data(i);
        tempHost = new HostControllerElement("Host Controller: ");
        tempRoot.addHostController(tempHost);
        tempHost.setIPAddressInfo(new InformationElement("IP address: " + host.hostname));
        tempHost.setIPNumberInfo(new InformationElement("IP number: " + host.ip_addr));
        tempHost.setHostNameInfo(new InformationElement("Local host name:" + host.hostname_local));
        tempHost.setOperatingSystemInfo(new InformationElement(host.system_name + " " + host.system_release + " " + host.system_version));
        tempHost.setStateInfo(new InformationElement("State: " + middleware.get_hc_state_name(host.hc_state)));
        int activeComponents = host.n_active_components;
        int[] components = host.components.clone();
        middleware.release_data();
        for (int component_index = 0; component_index < activeComponents; component_index++) {
            comp = middleware.get_component_data(components[component_index]);
            tempComponent = new ComponentElement("Component: " + comp.comp_name, new InformationElement("Component reference: " + comp.comp_ref));
            tempHost.addComponent(tempComponent);
            qualifiedName = comp.comp_type;
            if (qualifiedName != null && qualifiedName.definition_name != null) {
                builder = new StringBuilder("Component type: ");
                if (qualifiedName.module_name != null) {
                    builder.append(qualifiedName.module_name).append('.');
                }
                builder.append(qualifiedName.definition_name);
                tempComponent.setTypeInfo(new InformationElement(builder.toString()));
            }
            tempComponent.setStateInfo(new InformationElement(middleware.get_tc_state_name(comp.tc_state)));
            qualifiedName = comp.tc_fn_name;
            if (qualifiedName.definition_name != null) {
                builder = new StringBuilder(comp.comp_ref == 1 ? "test case" : "function");
                if (qualifiedName.module_name != null) {
                    builder.append(qualifiedName.module_name).append('.');
                }
                builder.append(qualifiedName.definition_name);
                tempComponent.setExecutedInfo(new InformationElement(builder.toString()));
            }
            VerdictTypeEnum localVerdict = comp.local_verdict;
            if (localVerdict != null) {
                builder = new StringBuilder("local verdict: ");
                builder.append(localVerdict.getName());
            }
        }
    }
    middleware.release_data();
    if (mainControllerRoot != null) {
        mainControllerRoot.children().clear();
        mainControllerRoot.transferData(tempRoot);
    }
    if (Activator.getMainView() != null) {
        Activator.getMainView().refreshAll();
    }
}
Also used : QualifiedName(org.eclipse.titan.executor.jni.QualifiedName) ComponentStruct(org.eclipse.titan.executor.jni.ComponentStruct) InformationElement(org.eclipse.titan.executor.views.executormonitor.InformationElement) HostControllerElement(org.eclipse.titan.executor.views.executormonitor.HostControllerElement) HostStruct(org.eclipse.titan.executor.jni.HostStruct) VerdictTypeEnum(org.eclipse.titan.executor.jni.VerdictTypeEnum) McStateEnum(org.eclipse.titan.executor.jni.McStateEnum) ComponentElement(org.eclipse.titan.executor.views.executormonitor.ComponentElement) JNIMiddleWare(org.eclipse.titan.executor.jni.JNIMiddleWare) MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement)

Example 3 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class TestExecutionView method createTooltip.

private void createTooltip(final ITreeLeaf element) {
    if (null == element) {
        setTitleToolTip(null);
        return;
    }
    final List<ExecutedTestcase> executedTestCases = new ArrayList<ExecutedTestcase>();
    final List<ITreeLeaf> children = ((LaunchElement) actualInput).children();
    ITreeLeaf executorElement;
    for (ITreeLeaf aChildren : children) {
        executorElement = aChildren;
        if (executorElement instanceof MainControllerElement) {
            BaseExecutor executor = ((MainControllerElement) executorElement).executor();
            if (null != executor) {
                executedTestCases.addAll(executor.executedTests());
            }
        }
    }
    if (executedTestCases.isEmpty()) {
        setTitleToolTip(element.name());
        return;
    }
    String statistics = createStatistics(element, executedTestCases);
    setTitleToolTip(statistics);
}
Also used : BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) ArrayList(java.util.ArrayList) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) LaunchElement(org.eclipse.titan.executor.views.executormonitor.LaunchElement) MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement)

Example 4 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class TestExecutionView method selectionChanged.

@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
    if (this.equals(part) || !(selection instanceof IStructuredSelection) || null == viewer.getContentProvider()) {
        return;
    }
    ITreeLeaf selectedElement;
    if (selection.isEmpty()) {
        selectedElement = null;
    } else {
        selectedElement = (ITreeLeaf) ((IStructuredSelection) selection).getFirstElement();
    }
    if (null != selectedElement) {
        while (!(selectedElement instanceof LaunchElement)) {
            selectedElement = selectedElement.parent();
        }
    }
    if (null != actualInput && actualInput.equals(selectedElement)) {
        viewer.refresh(false);
    } else {
        viewer.setInput(selectedElement);
        actualInput = selectedElement;
    }
    if (isFollowing && null != actualInput && actualInput instanceof LaunchElement) {
        final List<ITreeLeaf> children = ((LaunchElement) actualInput).children();
        for (ITreeLeaf aChildren : children) {
            final BaseExecutor executor = ((MainControllerElement) aChildren).executor();
            if (null != executor && !executor.executedTests().isEmpty()) {
                viewer.reveal(executor.executedTests().get(executor.executedTests().size() - 1));
            }
        }
    }
    createTooltip(selectedElement);
    if (null == selectedElement) {
        saveAsAction.setEnabled(false);
    } else {
        saveAsAction.setEnabled(true);
    }
}
Also used : BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) LaunchElement(org.eclipse.titan.executor.views.executormonitor.LaunchElement) MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement)

Example 5 with MainControllerElement

use of org.eclipse.titan.executor.views.executormonitor.MainControllerElement in project titan.EclipsePlug-ins by eclipse.

the class NotificationView method selectionChanged.

@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
    if (this.equals(part) || !(selection instanceof IStructuredSelection) || null == viewer.getContentProvider()) {
        return;
    }
    ITreeLeaf selectedElement;
    if (selection.isEmpty()) {
        selectedElement = null;
    } else {
        selectedElement = (ITreeLeaf) ((IStructuredSelection) selection).getFirstElement();
    }
    if (null != selectedElement) {
        while (!(selectedElement instanceof LaunchElement)) {
            selectedElement = selectedElement.parent();
        }
    }
    if (null != actualInput && actualInput.equals(selectedElement)) {
        viewer.refresh(false);
    } else {
        viewer.setInput(selectedElement);
        actualInput = selectedElement;
    }
    if (null == selectedElement) {
        setTitleToolTip(null);
        clearAction.setEnabled(false);
        saveAsAction.setEnabled(false);
    } else {
        setTitleToolTip(selectedElement.name());
        clearAction.setEnabled(true);
        saveAsAction.setEnabled(true);
    }
    if (isFollowing && null != actualInput && actualInput instanceof LaunchElement) {
        final List<ITreeLeaf> children = ((LaunchElement) actualInput).children();
        for (ITreeLeaf aChildren : children) {
            final BaseExecutor executor = ((MainControllerElement) aChildren).executor();
            if (null != executor && !executor.notifications().isEmpty()) {
                viewer.reveal(executor.notifications().get(executor.notifications().size() - 1));
            }
        }
    }
}
Also used : BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) LaunchElement(org.eclipse.titan.executor.views.executormonitor.LaunchElement) MainControllerElement(org.eclipse.titan.executor.views.executormonitor.MainControllerElement)

Aggregations

MainControllerElement (org.eclipse.titan.executor.views.executormonitor.MainControllerElement)7 BaseExecutor (org.eclipse.titan.executor.executors.BaseExecutor)4 ITreeLeaf (org.eclipse.titan.executor.executors.ITreeLeaf)4 LaunchElement (org.eclipse.titan.executor.views.executormonitor.LaunchElement)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 InformationElement (org.eclipse.titan.executor.views.executormonitor.InformationElement)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 IFile (org.eclipse.core.resources.IFile)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 ComponentStruct (org.eclipse.titan.executor.jni.ComponentStruct)1 HostStruct (org.eclipse.titan.executor.jni.HostStruct)1 JNIMiddleWare (org.eclipse.titan.executor.jni.JNIMiddleWare)1 McStateEnum (org.eclipse.titan.executor.jni.McStateEnum)1 QualifiedName (org.eclipse.titan.executor.jni.QualifiedName)1