1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.ui
.handler
;
12 import java
.util
.List
;
13 import java
.util
.stream
.Collectors
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jdt
.annotation
.Nullable
;
19 import org
.eclipse
.jface
.viewers
.ISelection
;
20 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
21 import org
.eclipse
.swt
.widgets
.Display
;
22 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.module
.LamiAnalysisReport
;
23 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.ui
.views
.LamiReportViewFactory
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.ondemand
.IOnDemandAnalysisReport
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfReportElement
;
26 import org
.eclipse
.ui
.PartInitException
;
27 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
30 * The command handler for the "Open Report" menu option for Report project
33 * Double-clicking should also call this handler.
35 * @author Alexandre Montplaisir
37 public class OpenReportHandler
extends AbstractHandler
{
40 public @Nullable Object
execute(@Nullable ExecutionEvent event
) throws ExecutionException
{
42 /* Types should have been checked by the plugin.xml already */
43 ISelection selection
= HandlerUtil
.getCurrentSelectionChecked(event
);
44 List
<?
> elements
= ((IStructuredSelection
) selection
).toList();
45 List
<TmfReportElement
> reportElements
= elements
.stream()
46 .filter(elem
-> elem
instanceof TmfReportElement
)
47 .map(elem
-> (TmfReportElement
) elem
)
48 .collect(Collectors
.toList());
50 for (TmfReportElement reportElem
: reportElements
) {
51 IOnDemandAnalysisReport report
= reportElem
.getReport();
52 if (!(report
instanceof LamiAnalysisReport
)) {
53 /* This handler deals with LAMI reports only */
56 LamiAnalysisReport lamiReport
= (LamiAnalysisReport
) report
;
58 Display
.getDefault().syncExec(() -> {
60 LamiReportViewFactory
.createNewViews(lamiReport
);
61 } catch (PartInitException e
) {