Search in sources :

Example 1 with OnDemandAnalysisManager

use of org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager in project tracecompass by tracecompass.

the class RemoveAnalysisHandler method execute.

@Override
@Nullable
public Object execute(@Nullable ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    // Selection type should have been validated by the plugin.xml
    if (!(selection instanceof IStructuredSelection)) {
        // $NON-NLS-1$
        throw new IllegalStateException("Handler called on invalid selection");
    }
    IStructuredSelection sel = (IStructuredSelection) selection;
    List<?> elements = sel.toList();
    OnDemandAnalysisManager mgr = OnDemandAnalysisManager.getInstance();
    Optional<TmfUserDefinedOnDemandAnalysisElement> optionalParent = elements.stream().filter(TmfUserDefinedOnDemandAnalysisElement.class::isInstance).map(TmfUserDefinedOnDemandAnalysisElement.class::cast).findFirst();
    elements.stream().filter(TmfUserDefinedOnDemandAnalysisElement.class::isInstance).map(TmfUserDefinedOnDemandAnalysisElement.class::cast).map(TmfUserDefinedOnDemandAnalysisElement::getAnalysis).forEach(analysis -> {
        /* Unregister from the manager */
        mgr.unregisterAnalysis(analysis);
        /* Remove the corresponding configuration file */
        try {
            LamiConfigUtils.removeConfigFile(analysis.getName());
        } catch (IOException e) {
        // Ignore this: not the end of the world
        }
    });
    /* Refresh the project explorer */
    optionalParent.ifPresent(TmfUserDefinedOnDemandAnalysisElement::refresh);
    return null;
}
Also used : OnDemandAnalysisManager(org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager) TmfUserDefinedOnDemandAnalysisElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfUserDefinedOnDemandAnalysisElement) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with OnDemandAnalysisManager

use of org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager in project tracecompass by tracecompass.

the class Activator method loadUserDefinedAnalyses.

private void loadUserDefinedAnalyses() {
    final Path configDirPath = LamiConfigUtils.getConfigDirPath();
    try {
        final List<LamiAnalysis> analyses = LamiAnalysisFactoryFromConfigFile.buildFromConfigDir(configDirPath, true, trace -> true);
        OnDemandAnalysisManager manager = OnDemandAnalysisManager.getInstance();
        analyses.forEach(manager::registerAnalysis);
    } catch (LamiAnalysisFactoryException e) {
        // $NON-NLS-1$
        logWarning("Cannot load user-defined external analyses", e);
    }
}
Also used : Path(java.nio.file.Path) LamiAnalysisFactoryException(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisFactoryException) OnDemandAnalysisManager(org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager) LamiAnalysis(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysis)

Aggregations

OnDemandAnalysisManager (org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LamiAnalysis (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysis)1 LamiAnalysisFactoryException (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisFactoryException)1 TmfUserDefinedOnDemandAnalysisElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfUserDefinedOnDemandAnalysisElement)1