use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfTraceTest method testGetModules.
// ------------------------------------------------------------------------
// State system, statistics and modules methods
// ------------------------------------------------------------------------
@Test
public void testGetModules() {
/* There should not be any modules at this point */
Iterable<IAnalysisModule> modules = fTrace.getAnalysisModules();
assertFalse(modules.iterator().hasNext());
/* Open the trace, the modules should be populated */
fTrace.traceOpened(new TmfTraceOpenedSignal(this, fTrace, null));
modules = fTrace.getAnalysisModules();
assertTrue(modules.iterator().hasNext());
/*
* Make sure all modules of type TestAnalysis are returned in the second
* call
*/
int count = 0;
for (IAnalysisModule module : modules) {
if (module instanceof TestAnalysis) {
count++;
IAnalysisModule otherModule = fTrace.getAnalysisModule(module.getId());
assertNotNull(otherModule);
assertEquals(otherModule, module);
}
}
/*
* FIXME: The exact count depends on the context the test is run (full
* test suite or this file only), but there must be at least 2 modules
*/
assertTrue(count >= 2);
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfTrace method executeAnalysis.
/**
* Instantiate the applicable analysis modules and executes the analysis
* modules that are meant to be automatically executed
*
* @return An IStatus indicating whether the analysis could be run
* successfully or not
*/
protected IStatus executeAnalysis() {
MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
/* First modules are initialized */
Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(this.getClass());
for (IAnalysisModuleHelper helper : modules.values()) {
try {
IAnalysisModule module = helper.newModule(this);
if (module == null) {
continue;
}
fAnalysisModules.put(module.getId(), module);
} catch (TmfAnalysisException e) {
status.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage()));
}
}
/* Once all modules are initialized, automatic modules are executed */
for (IAnalysisModule module : getAnalysisModules()) {
if (module.isAutomatic()) {
status.add(module.schedule());
}
}
return status;
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfAnalysisElement method getAnalysisProperties.
/**
* Get the analysis properties of this analysisElement if the corresponding
* analysis exists for the current trace
*
* @return a map with the names and values of the trace properties
* respectively as keys and values
*/
private Map<String, String> getAnalysisProperties() {
ITmfProjectModelElement parent = getParent();
if (!(parent instanceof TmfViewsElement)) {
return Collections.emptyMap();
}
parent = parent.getParent();
if (parent instanceof TmfCommonProjectElement) {
ITmfTrace trace = ((TmfCommonProjectElement) parent).getTrace();
if (trace == null) {
return Collections.emptyMap();
}
IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
if (module instanceof ITmfPropertiesProvider) {
return ((ITmfPropertiesProvider) module).getProperties();
}
}
return Collections.emptyMap();
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfAnalysisElement method getHelpMessage.
/**
* Gets the help message for this analysis
*
* @return The help message
*/
public String getHelpMessage() {
TmfCommonProjectElement parentTrace = getParent().getParent();
ITmfTrace trace = null;
if (parentTrace instanceof TmfTraceElement) {
TmfTraceElement traceElement = (TmfTraceElement) parentTrace;
trace = traceElement.getTrace();
if (trace != null) {
IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
if (module != null) {
return module.getHelpText(trace);
}
}
}
if (trace != null) {
return fAnalysisHelper.getHelpText(trace);
}
return fAnalysisHelper.getHelpText();
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.
the class TmfAnalysisElement method getAnalysisModule.
private IAnalysisModule getAnalysisModule() {
/*
* We can get a list of available outputs once the analysis is
* instantiated when the trace is opened
*/
IResource parentTraceResource = getParent().getParent().getResource();
/*
* Find any trace instantiated with the same resource as the parent trace
*/
ITmfTrace trace = null;
for (ITmfTrace openedTrace : TmfTraceManager.getInstance().getOpenedTraces()) {
for (ITmfTrace t : TmfTraceManager.getTraceSetWithExperiment(openedTrace)) {
if (parentTraceResource.equals(t.getResource())) {
trace = t;
break;
}
}
}
if (trace == null) {
deleteOutputs();
return null;
}
IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
if (module == null) {
deleteOutputs();
/*
* Trace is opened, but the analysis is null, so it does not
* apply
*/
fCanExecute = false;
return null;
}
return module;
}
Aggregations