Search in sources :

Example 1 with TmfOnDemandAnalysesElement

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;
}
Also used : Path(java.nio.file.Path) LamiAnalysisFactoryException(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisFactoryException) Shell(org.eclipse.swt.widgets.Shell) IOException(java.io.IOException) LamiAnalysis(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysis) TmfOnDemandAnalysesElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysesElement) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Shell (org.eclipse.swt.widgets.Shell)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 TmfOnDemandAnalysesElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfOnDemandAnalysesElement)1