Search in sources :

Example 11 with ITreeLeaf

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

the class TestcasesLabelProvider method getImage.

@Override
public Image getImage(final Object element) {
    if (element instanceof TestsetTreeElement) {
        final List<ITreeLeaf> temp = ((TestsetTreeElement) element).children();
        String name;
        for (ITreeLeaf aTemp : temp) {
            name = aTemp.name();
            if (availableTestcases.contains(name) || availableControlparts.contains(name)) {
                return ImageCache.getImage("testset.gif");
            }
        }
        return ImageCache.getImage("erroneous.gif");
    } else if (element instanceof TestCaseTreeElement) {
        final String name = ((TestCaseTreeElement) element).name();
        if (availableTestcases.contains(name) || availableControlparts.contains(name)) {
            return ImageCache.getImage("testcase.gif");
        }
        return ImageCache.getImage("erroneous.gif");
    }
    return super.getImage(element);
}
Also used : ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf)

Example 12 with ITreeLeaf

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

the class ExecutorMonitorView method createPartControl.

@Override
public void createPartControl(final Composite parent) {
    viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    contentProvider = new ExecutorMonitorContentProvider();
    viewer.setContentProvider(contentProvider);
    labelProvider = new ExecutorMonitorLabelProvider();
    viewer.setLabelProvider(labelProvider);
    createActions();
    manager = new MenuManager("menuManager");
    createEmptyContextMenu();
    createToolBar();
    Activator.setMainView(this);
    viewer.setInput(getInitialInput());
    viewer.expandToLevel(2);
    updateActions();
    getSite().setSelectionProvider(viewer);
    launchListener = new LaunchesListener(this);
    DebugPlugin.getDefault().getLaunchManager().addLaunchListener(launchListener);
    selectionChangedListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ITreeLeaf element = (ITreeLeaf) selection.getFirstElement();
            updateActions();
            if (null == element) {
                return;
            }
            if (element instanceof LaunchElement) {
                createLauncherContextMenu();
            } else if (element instanceof MainControllerElement) {
                createExecutorContextMenu((MainControllerElement) element);
                BaseExecutor executor = ((MainControllerElement) element).executor();
                IProcess process = executor.getProcess();
                if (null == process) {
                    return;
                }
                IConsole console = DebugUITools.getConsole(process);
                if (null == console) {
                    return;
                }
                IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
                boolean exists = false;
                for (IConsole console2 : consoles) {
                    if (console2.equals(console)) {
                        exists = true;
                    }
                }
                if (!exists) {
                    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
                }
                ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
                ConsolePlugin.getDefault().getConsoleManager().refresh(console);
            } else {
                createEmptyContextMenu();
            }
        }
    };
    viewer.addSelectionChangedListener(selectionChangedListener);
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IConsole(org.eclipse.ui.console.IConsole) BaseExecutor(org.eclipse.titan.executor.executors.BaseExecutor) MenuManager(org.eclipse.jface.action.MenuManager) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) IProcess(org.eclipse.debug.core.model.IProcess)

Example 13 with ITreeLeaf

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

the class ExecutorMonitorView method terminateSelected.

private void terminateSelected() {
    if (null == viewer || viewer.getSelection().isEmpty()) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    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()) {
                executor.terminate(false);
            }
        }
    }
    updateActions();
}
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 14 with ITreeLeaf

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

the class LaunchesListener method launchesTerminated.

@Override
public void launchesTerminated(final ILaunch[] launches) {
    for (ILaunch launched : launches) {
        for (ITreeLeaf element : executorMonitorView.getRoot().children()) {
            final LaunchElement launchElement = (LaunchElement) element;
            if (launched.equals(launchElement.launch())) {
                launchElement.changed();
                MainControllerElement mainController;
                if (1 == ((LaunchElement) element).children().size()) {
                    mainController = (MainControllerElement) ((LaunchElement) element).children().get(0);
                } else {
                    mainController = null;
                }
                if (null != mainController) {
                    mainController.executor().terminate(true);
                }
                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        executorMonitorView.getTreeViewer().refresh(launchElement);
                    }
                });
            }
        }
    }
    executorMonitorView.updateActions();
}
Also used : ILaunch(org.eclipse.debug.core.ILaunch) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf)

Example 15 with ITreeLeaf

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

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