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();
}
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();
}
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;
}
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);
}
}
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);
}
Aggregations