Search in sources :

Example 1 with TmfAnalysisElement

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

the class ProjectModelAnalysisTest method testListAnalysis.

/**
 * Test the getAvailableAnalysis() method
 */
@Test
public void testListAnalysis() {
    TmfTraceElement trace = getTraceElement();
    /* Make sure the analysis list is not empty */
    List<TmfAnalysisElement> analysisList = trace.getAvailableAnalysis();
    assertFalse(analysisList.isEmpty());
    /* Make sure TestAnalysisUi is there */
    TmfAnalysisElement analysis = null;
    for (TmfAnalysisElement analysisElement : analysisList) {
        if (analysisElement.getAnalysisId().equals(MODULE_UI)) {
            analysis = analysisElement;
        }
    }
    assertNotNull(analysis);
    assertEquals("Test analysis in UI", analysis.getName());
}
Also used : TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement) Test(org.junit.Test)

Example 2 with TmfAnalysisElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement 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 3 with TmfAnalysisElement

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

the class ProjectModelOutputTest method getTestAnalysisUi.

private TmfAnalysisElement getTestAnalysisUi() {
    TmfTraceElement trace = getTraceElement();
    /* Make sure the analysis list is not empty */
    List<TmfAnalysisElement> analysisList = trace.getAvailableAnalysis();
    assertFalse(analysisList.isEmpty());
    /* Make sure TestAnalysisUi is there */
    TmfAnalysisElement analysis = null;
    for (TmfAnalysisElement analysisElement : analysisList) {
        if (analysisElement.getAnalysisId().equals(ProjectModelAnalysisTest.MODULE_UI)) {
            analysis = analysisElement;
        }
    }
    assertNotNull(analysis);
    return analysis;
}
Also used : TmfTraceElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement) TmfAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement)

Example 4 with TmfAnalysisElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement 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 5 with TmfAnalysisElement

use of org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement 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)

Aggregations

TmfAnalysisElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement)10 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)6 Test (org.junit.Test)5 TmfAnalysisOutputElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement)4 WaitTimeoutException (org.eclipse.tracecompass.tmf.ui.tests.shared.WaitTimeoutException)4 ISelection (org.eclipse.jface.viewers.ISelection)3 ITmfProjectModelElement (org.eclipse.tracecompass.tmf.ui.project.model.ITmfProjectModelElement)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)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 TestAnalysisUi (org.eclipse.tracecompass.tmf.ui.tests.stubs.analysis.TestAnalysisUi)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 List (java.util.List)1 Optional (java.util.Optional)1