use of org.eclipse.tracecompass.tmf.ui.project.model.TmfUserDefinedOnDemandAnalysisElement 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;
}
Aggregations