Search in sources :

Example 1 with ITreeLeaf

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

the class TestSetTab method createActions.

private void createActions() {
    newTestset = new Action("create new testset") {

        @Override
        public void run() {
            if (null == testsetViewer) {
                return;
            }
            TestsetDialog dialog = new TestsetDialog(getShell(), "Create new testset");
            if (dialog.open() != Window.OK) {
                return;
            }
            String testsetName = dialog.getTestsetName();
            List<ITreeLeaf> children = treeRoot.children();
            for (ITreeLeaf aChildren : children) {
                if (aChildren.name().equals(testsetName)) {
                    return;
                }
            }
            treeRoot.addChildToEnd(new TestsetTreeElement(testsetName));
            testsetViewer.refresh();
            updateLaunchConfigurationDialog();
            super.run();
        }
    };
    newTestset.setToolTipText("creates a new testset");
    newTestset.setEnabled(true);
    rename = new Action("rename testset") {

        @Override
        public void run() {
            if (null == testsetViewer || testsetViewer.getSelection().isEmpty()) {
                return;
            }
            IStructuredSelection selection = (IStructuredSelection) testsetViewer.getSelection();
            TestsetDialog dialog = new TestsetDialog(getShell(), "Rename testset");
            dialog.setTestsetName(((TestsetTreeElement) selection.getFirstElement()).name());
            if (dialog.open() != Window.OK) {
                return;
            }
            String testsetName = dialog.getTestsetName();
            List<ITreeLeaf> children = treeRoot.children();
            for (ITreeLeaf aChildren : children) {
                if (aChildren.name().equals(testsetName)) {
                    return;
                }
            }
            ((TestsetTreeElement) selection.getFirstElement()).name(testsetName);
            testsetViewer.refresh();
            updateLaunchConfigurationDialog();
            super.run();
        }
    };
    rename.setToolTipText("rename selected testset");
    rename.setEnabled(false);
    remove = new Action("remove") {

        @Override
        public void run() {
            if (null == testsetViewer || testsetViewer.getSelection().isEmpty()) {
                return;
            }
            testsetViewer.getTree().setRedraw(false);
            IStructuredSelection selection = (IStructuredSelection) testsetViewer.getSelection();
            for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
                TreeLeaf element = (TreeLeaf) iterator.next();
                if (null != element.parent()) {
                    ((TestsetTreeElement) element.parent()).remove(element);
                    element.dispose();
                }
            }
            testsetViewer.getTree().setRedraw(true);
            testsetViewer.refresh();
            updateLaunchConfigurationDialog();
            super.run();
        }
    };
    remove.setToolTipText("removes the selected elements");
    remove.setEnabled(false);
}
Also used : Action(org.eclipse.jface.action.Action) Iterator(java.util.Iterator) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) TreeLeaf(org.eclipse.titan.executor.executors.TreeLeaf) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf)

Example 2 with ITreeLeaf

use of org.eclipse.titan.executor.executors.ITreeLeaf 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 3 with ITreeLeaf

use of org.eclipse.titan.executor.executors.ITreeLeaf 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 4 with ITreeLeaf

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

the class TestExecutionView method getInitialInput.

private ITreeLeaf getInitialInput() {
    final ISelection selection = getSite().getPage().getSelection(EXECUTORMONITOR_VIEW_ID);
    if (null == selection || selection.isEmpty()) {
        return null;
    }
    final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    ITreeLeaf element = (ITreeLeaf) structuredSelection.getFirstElement();
    if (null != element) {
        while (!(element instanceof LaunchElement)) {
            element = element.parent();
        }
    }
    return element;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) LaunchElement(org.eclipse.titan.executor.views.executormonitor.LaunchElement)

Example 5 with ITreeLeaf

use of org.eclipse.titan.executor.executors.ITreeLeaf 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)

Aggregations

ITreeLeaf (org.eclipse.titan.executor.executors.ITreeLeaf)16 BaseExecutor (org.eclipse.titan.executor.executors.BaseExecutor)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 LaunchElement (org.eclipse.titan.executor.views.executormonitor.LaunchElement)7 List (java.util.List)4 ILaunch (org.eclipse.debug.core.ILaunch)4 MainControllerElement (org.eclipse.titan.executor.views.executormonitor.MainControllerElement)4 ArrayList (java.util.ArrayList)3 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2 Action (org.eclipse.jface.action.Action)2 ISelection (org.eclipse.jface.viewers.ISelection)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Iterator (java.util.Iterator)1 IFile (org.eclipse.core.resources.IFile)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 IProcess (org.eclipse.debug.core.model.IProcess)1 MenuManager (org.eclipse.jface.action.MenuManager)1