use of org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysesElement in project tracecompass by tracecompass.
the class AddAnalysisHandler method execute.
@Override
@Nullable
public Object execute(@Nullable ExecutionEvent event) throws ExecutionException {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final AddAnalysisDialog dialog = new AddAnalysisDialog(shell, Messages.AddAnalysisDialog_Title, NAME_INPUT_VALIDATOR, COMMAND_INPUT_VALIDATOR);
if (dialog.open() != Window.OK) {
// User clicked Cancel, cancel the add operation
return null;
}
Path configFilePath;
try {
configFilePath = LamiConfigUtils.createConfigFile(checkNotNull(dialog.getName().trim()), checkNotNull(dialog.getCommand().trim()));
} catch (IOException e) {
showErrorBox(shell, e);
return null;
}
try {
final LamiAnalysis analysis = LamiAnalysisFactoryFromConfigFile.buildFromConfigFile(configFilePath, true, trace -> true);
OnDemandAnalysisManager.getInstance().registerAnalysis(analysis);
} catch (LamiAnalysisFactoryException e) {
showErrorBox(shell, e);
return null;
}
final Object elem = HandlerUtils.getSelectedModelElement();
if (elem != null && elem instanceof TmfOnDemandAnalysesElement) {
final TmfOnDemandAnalysesElement analysesElem = (TmfOnDemandAnalysesElement) elem;
analysesElem.refresh();
}
return null;
}
Aggregations