Search in sources :

Example 1 with BaseExecutor

use of org.eclipse.titan.executor.executors.BaseExecutor in project titan.EclipsePlug-ins by eclipse.

the class ExecutorMonitorContentProvider method getChildren.

@Override
public ITreeLeaf[] getChildren(final Object parentElement) {
    if (parentElement instanceof MainControllerElement) {
        final BaseExecutor executor = ((MainControllerElement) parentElement).executor();
        final List<ITreeLeaf> children = executor.mainControllerRoot().children();
        return children.toArray(new ITreeLeaf[children.size()]);
    } else if (parentElement instanceof ITreeBranch) {
        final List<ITreeLeaf> children = ((ITreeBranch) parentElement).children();
        return children.toArray(new ITreeLeaf[children.size()]);
    }
    return new ITreeBranch[] {};
}
Also used : ITreeBranch(org.eclipse.titan.executor.executors.ITreeBranch) BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) List(java.util.List) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf)

Example 2 with BaseExecutor

use of org.eclipse.titan.executor.executors.BaseExecutor in project titan.EclipsePlug-ins by eclipse.

the class ExecutorMonitorView method removeAllTerminated.

private void removeAllTerminated() {
    if (null == viewer) {
        return;
    }
    for (int i = root.children().size() - 1; i >= 0; i--) {
        LaunchElement element = (LaunchElement) root.children().get(i);
        ILaunch launched = element.launch();
        if (null == launched) {
            // DebugPlugin.getDefault().getLaunchManager().removeLaunch(launched);
            continue;
        }
        ILaunchConfiguration launchConfiguration = launched.getLaunchConfiguration();
        MainControllerElement mainController;
        if (1 == element.children().size()) {
            mainController = (MainControllerElement) element.children().get(0);
        } else {
            mainController = null;
        }
        if (isSupportedConfiguration(launchConfiguration) && null != mainController) {
            BaseExecutor executor = mainController.executor();
            if (executor.isTerminated()) {
                DebugPlugin.getDefault().getLaunchManager().removeLaunch(launched);
            }
        }
    }
    viewer.setSelection(null);
    updateActions();
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

        @Override
        public void run() {
            viewer.refresh(root);
        }
    });
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) ILaunch(org.eclipse.debug.core.ILaunch)

Example 3 with BaseExecutor

use of org.eclipse.titan.executor.executors.BaseExecutor in project titan.EclipsePlug-ins by eclipse.

the class ExecutorMonitorView method terminateAll.

private void terminateAll() {
    if (null == viewer) {
        return;
    }
    for (int i = root.children().size() - 1; i >= 0; i--) {
        LaunchElement element = (LaunchElement) root.children().get(i);
        ILaunch launched = element.launch();
        ILaunchConfiguration launchConfiguration = launched.getLaunchConfiguration();
        MainControllerElement mainController;
        if (1 == (element).children().size()) {
            mainController = (MainControllerElement) (element).children().get(0);
        } else {
            mainController = null;
        }
        if (isSupportedConfiguration(launchConfiguration) && null != mainController) {
            BaseExecutor executor = mainController.executor();
            if (!executor.isTerminated()) {
                executor.terminate(false);
            }
        }
    }
    updateActions();
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

        @Override
        public void run() {
            viewer.refresh(root);
        }
    });
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) ILaunch(org.eclipse.debug.core.ILaunch)

Example 4 with BaseExecutor

use of org.eclipse.titan.executor.executors.BaseExecutor in project titan.EclipsePlug-ins by eclipse.

the class ExecutorMonitorView method removeSelected.

private void removeSelected() {
    if (null == viewer || viewer.getSelection().isEmpty()) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    viewer.getTree().setRedraw(false);
    for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
        ITreeLeaf element = (ITreeLeaf) iterator.next();
        while (!(element instanceof LaunchElement)) {
            element = element.parent();
        }
        ILaunch launched = ((LaunchElement) element).launch();
        ILaunchConfiguration launchConfiguration = launched.getLaunchConfiguration();
        MainControllerElement mainController;
        if (1 == ((LaunchElement) element).children().size()) {
            mainController = (MainControllerElement) ((LaunchElement) element).children().get(0);
        } else {
            mainController = null;
        }
        if (isSupportedConfiguration(launchConfiguration) && null != mainController) {
            BaseExecutor executor = mainController.executor();
            if (executor.isTerminated()) {
                DebugPlugin.getDefault().getLaunchManager().removeLaunch(launched);
            }
        }
    }
    viewer.setSelection(null);
    updateActions();
    viewer.getTree().setRedraw(true);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) ILaunch(org.eclipse.debug.core.ILaunch) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf)

Example 5 with BaseExecutor

use of org.eclipse.titan.executor.executors.BaseExecutor in project titan.EclipsePlug-ins by eclipse.

the class ExecutorStorage method registerExecutorStorage.

/**
 * Register the provided launch element.
 * Only done if the launch is already registered.
 *
 * @param element the element to be registered
 */
public static void registerExecutorStorage(final LaunchElement element) {
    ILaunch launch = element.launch();
    if (ExecutorStorage.getExecutorMap().containsKey(launch)) {
        final BaseExecutor executor = ExecutorStorage.getExecutorMap().get(launch);
        if (null == executor.mainControllerRoot()) {
            executor.mainControllerRoot(new MainControllerElement(BaseExecutor.MAIN_CONTROLLER, executor));
        }
        element.addChildToEnd(executor.mainControllerRoot());
    }
}
Also used : BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) ILaunch(org.eclipse.debug.core.ILaunch)

Aggregations

BaseExecutor (org.eclipse.titan.executor.executors.BaseExecutor)15 ITreeLeaf (org.eclipse.titan.executor.executors.ITreeLeaf)9 ILaunch (org.eclipse.debug.core.ILaunch)7 LaunchElement (org.eclipse.titan.executor.views.executormonitor.LaunchElement)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)4 MainControllerElement (org.eclipse.titan.executor.views.executormonitor.MainControllerElement)4 List (java.util.List)2 Map (java.util.Map)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 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 DebugException (org.eclipse.debug.core.DebugException)1 IProcess (org.eclipse.debug.core.model.IProcess)1 Action (org.eclipse.jface.action.Action)1