use of org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement in project tracecompass by tracecompass.
the class OpenReportHandler method execute.
@Override
@Nullable
public Object execute(@Nullable ExecutionEvent event) throws ExecutionException {
/* Types should have been checked by the plugin.xml already */
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
List<?> elements = ((IStructuredSelection) selection).toList();
Display.getDefault().syncExec(() -> elements.stream().filter(TmfReportElement.class::isInstance).map(TmfReportElement.class::cast).map(TmfReportElement::getReport).filter(LamiAnalysisReport.class::isInstance).map(LamiAnalysisReport.class::cast).forEach(lamiReport -> {
try {
LamiReportViewFactory.createNewView(lamiReport);
} catch (PartInitException e) {
}
}));
return null;
}
use of org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement 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.TmfReportElement 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);
}
}
Aggregations