Search in sources :

Example 1 with TmfAnalysisOutputElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement in project tracecompass by tracecompass.

the class ProjectModelOutputTest method testListOutputs.

/**
 * Test the getAvailableOutputs() method
 */
@Test
public void testListOutputs() {
    TmfAnalysisElement analysis = getTestAnalysisUi();
    TmfCommonProjectElement traceElement = analysis.getParent().getParent();
    /* To get the list of outputs the trace needs to be opened */
    analysis.activateParentTrace();
    try {
        ProjectModelTestData.delayUntilTraceOpened(traceElement);
    } catch (WaitTimeoutException e) {
        fail("The analysis parent did not open in a reasonable time");
    }
    /* Make sure the output list is not empty */
    WaitUtils.waitUntil(new ConditionTraceChildrenElements(analysis, 1));
    List<TmfAnalysisOutputElement> outputList = analysis.getAvailableOutputs();
    assertFalse(outputList.isEmpty());
    boolean found = false;
    for (ITmfProjectModelElement element : outputList) {
        if (element instanceof TmfAnalysisOutputElement) {
            TmfAnalysisOutputElement outputElement = (TmfAnalysisOutputElement) element;
            if (outputElement.getName().equals("Test Analysis View")) {
                found = true;
            }
        }
    }
    assertTrue(found);
    traceElement.closeEditors();
}
Also used : TmfAnalysisOutputElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement) ITmfProjectModelElement(org.eclipse.tracecompass.tmf.ui.project.model.ITmfProjectModelElement) TmfAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement) TmfCommonProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement) WaitTimeoutException(org.eclipse.tracecompass.tmf.ui.tests.shared.WaitTimeoutException) Test(org.junit.Test)

Example 2 with TmfAnalysisOutputElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement in project tracecompass by tracecompass.

the class ProjectModelOutputTest method testOpenView.

/**
 * Test the outputAnalysis method for a view
 */
@Test
public void testOpenView() {
    TmfAnalysisElement analysis = getTestAnalysisUi();
    TmfCommonProjectElement traceElement = analysis.getParent().getParent();
    analysis.activateParentTrace();
    try {
        ProjectModelTestData.delayUntilTraceOpened(traceElement);
    } catch (WaitTimeoutException e) {
        fail("The analysis parent did not open in a reasonable time");
    }
    WaitUtils.waitUntil(new ConditionTraceChildrenElements(analysis, 1));
    List<TmfAnalysisOutputElement> outputList = analysis.getAvailableOutputs();
    assertFalse(outputList.isEmpty());
    final IWorkbench wb = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
    IViewPart view = activePage.findView(TestAnalysisUi.VIEW_ID);
    if (view != null) {
        activePage.hideView(view);
    }
    TmfAnalysisOutputElement outputElement = null;
    for (ITmfProjectModelElement element : outputList) {
        if (element instanceof TmfAnalysisOutputElement) {
            TmfAnalysisOutputElement el = (TmfAnalysisOutputElement) element;
            if (el.getName().equals("Test Analysis View")) {
                outputElement = el;
            }
        }
    }
    assertNotNull(outputElement);
    outputElement.outputAnalysis();
    WaitUtils.waitUntil(workbenchPage -> workbenchPage.findView(TestAnalysisUi.VIEW_ID) != null, activePage, "Test Analysis View did not open");
    traceElement.closeEditors();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IViewPart(org.eclipse.ui.IViewPart) TmfAnalysisOutputElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement) ITmfProjectModelElement(org.eclipse.tracecompass.tmf.ui.project.model.ITmfProjectModelElement) TmfAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) TmfCommonProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement) WaitTimeoutException(org.eclipse.tracecompass.tmf.ui.tests.shared.WaitTimeoutException) Test(org.junit.Test)

Example 3 with TmfAnalysisOutputElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement in project tracecompass by tracecompass.

the class OpenAction method isEnabled.

@Override
public boolean isEnabled() {
    ISelection selection = selectionProvider.getSelection();
    if (!selection.isEmpty()) {
        IStructuredSelection sSelection = (IStructuredSelection) selection;
        Object firstElement = sSelection.getFirstElement();
        if ((sSelection.size() == 1) && (firstElement instanceof TmfTraceElement || firstElement instanceof TmfExperimentElement || firstElement instanceof TmfOnDemandAnalysisElement || firstElement instanceof TmfAnalysisOutputElement || firstElement instanceof TmfReportElement || firstElement instanceof TmfAnalysisElement)) {
            element = (TmfProjectModelElement) firstElement;
            return true;
        }
    }
    return false;
}
Also used : TmfReportElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement) TmfAnalysisOutputElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement) TmfOnDemandAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysisElement) TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TmfExperimentElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)

Example 4 with TmfAnalysisOutputElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement in project tracecompass by tracecompass.

the class OpenAction method run.

@Override
public void run() {
    try {
        Object service = page.getActivePart().getSite().getService(IHandlerService.class);
        IHandlerService handlerService = (IHandlerService) service;
        boolean executeCommand = (element instanceof TmfTraceElement || element instanceof TmfOnDemandAnalysisElement || element instanceof TmfAnalysisOutputElement || element instanceof TmfReportElement || element instanceof TmfAnalysisElement);
        if (!executeCommand && element instanceof TmfExperimentElement) {
            TmfExperimentElement experiment = (TmfExperimentElement) element;
            executeCommand = (!experiment.getTraces().isEmpty());
        }
        if (executeCommand) {
            handlerService.executeCommand(OPEN_COMMAND_ID, null);
        }
    } catch (ExecutionException e) {
        // $NON-NLS-1$
        Activator.getDefault().logError("Error opening resource " + element.getName(), e);
    } catch (NotDefinedException e) {
        // $NON-NLS-1$
        Activator.getDefault().logError("Error opening resource " + element.getName(), e);
    } catch (NotEnabledException e) {
        // $NON-NLS-1$
        Activator.getDefault().logError("Error opening resource " + element.getName(), e);
    } catch (NotHandledException e) {
        // $NON-NLS-1$
        Activator.getDefault().logError("Error opening resource " + element.getName(), e);
    }
}
Also used : NotHandledException(org.eclipse.core.commands.NotHandledException) TmfReportElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement) TmfOnDemandAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysisElement) TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) NotEnabledException(org.eclipse.core.commands.NotEnabledException) TmfAnalysisOutputElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement) IHandlerService(org.eclipse.ui.handlers.IHandlerService) TmfExperimentElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 5 with TmfAnalysisOutputElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement in project tracecompass by tracecompass.

the class OpenAnalysisOutputHandler method isEnabled.

@Override
public boolean isEnabled() {
    /* Check if we are closing down */
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    /* Get the selection */
    final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final IWorkbenchPart part = page.getActivePart();
    if (part == null) {
        return false;
    }
    final ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
    if (selectionProvider == null) {
        return false;
    }
    final ISelection selection = selectionProvider.getSelection();
    /* Make sure there is only one selection and that it is an analysis output */
    fOutputElement = null;
    if (selection instanceof TreeSelection) {
        final TreeSelection sel = (TreeSelection) selection;
        // There should be only one item selected as per the plugin.xml
        final Object element = sel.getFirstElement();
        if (element instanceof TmfAnalysisOutputElement) {
            fOutputElement = (TmfAnalysisOutputElement) element;
        }
    }
    return (fOutputElement != null);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TmfAnalysisOutputElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Aggregations

TmfAnalysisOutputElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement)5 TmfAnalysisElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement)4 ISelection (org.eclipse.jface.viewers.ISelection)2 ITmfProjectModelElement (org.eclipse.tracecompass.tmf.ui.project.model.ITmfProjectModelElement)2 TmfCommonProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement)2 TmfExperimentElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)2 TmfOnDemandAnalysisElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysisElement)2 TmfReportElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement)2 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)2 WaitTimeoutException (org.eclipse.tracecompass.tmf.ui.tests.shared.WaitTimeoutException)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 Test (org.junit.Test)2 ExecutionException (org.eclipse.core.commands.ExecutionException)1 NotEnabledException (org.eclipse.core.commands.NotEnabledException)1 NotHandledException (org.eclipse.core.commands.NotHandledException)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 IViewPart (org.eclipse.ui.IViewPart)1