Search in sources :

Example 1 with TmfReportElement

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;
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) LamiAnalysisReport(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisReport) ExecutionException(org.eclipse.core.commands.ExecutionException) Display(org.eclipse.swt.widgets.Display) TmfReportElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) List(java.util.List) Nullable(org.eclipse.jdt.annotation.Nullable) PartInitException(org.eclipse.ui.PartInitException) ISelection(org.eclipse.jface.viewers.ISelection) LamiReportViewFactory(org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewFactory) AbstractHandler(org.eclipse.core.commands.AbstractHandler) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TmfReportElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement) ISelection(org.eclipse.jface.viewers.ISelection) LamiAnalysisReport(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisReport) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with TmfReportElement

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;
}
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 3 with TmfReportElement

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

Aggregations

TmfReportElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfReportElement)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TmfAnalysisElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisElement)2 TmfAnalysisOutputElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfAnalysisOutputElement)2 TmfExperimentElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement)2 TmfOnDemandAnalysisElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysisElement)2 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)2 List (java.util.List)1 AbstractHandler (org.eclipse.core.commands.AbstractHandler)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 NotEnabledException (org.eclipse.core.commands.NotEnabledException)1 NotHandledException (org.eclipse.core.commands.NotHandledException)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Display (org.eclipse.swt.widgets.Display)1 LamiAnalysisReport (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisReport)1 LamiReportViewFactory (org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewFactory)1 PartInitException (org.eclipse.ui.PartInitException)1