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