use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper in project tracecompass by tracecompass.
the class XmlSchemaParserStub method getModuleHelpers.
@Override
@NonNull
public Collection<? extends @NonNull IAnalysisModuleHelper> getModuleHelpers(File xmlFile, Document doc) {
List<@NonNull IAnalysisModuleHelper> modules = new ArrayList<>();
/* get the "my" modules */
NodeList xmlNodes = doc.getElementsByTagName(MY_MODULE);
for (int i = 0; i < xmlNodes.getLength(); i++) {
Element node = (Element) xmlNodes.item(i);
IAnalysisModuleHelper helper = new OtherModuleHelperStub(xmlFile, node);
modules.add(helper);
}
/* get the "abc" modules */
xmlNodes = doc.getElementsByTagName(ABC_MODULE);
for (int i = 0; i < xmlNodes.getLength(); i++) {
Element node = (Element) xmlNodes.item(i);
IAnalysisModuleHelper helper = new OtherModuleHelperStub(xmlFile, node);
modules.add(helper);
}
return modules;
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper in project tracecompass by tracecompass.
the class XmlAnalysisModuleSource method processFile.
private static void processFile(@NonNull File xmlFile) {
if (!XmlUtils.xmlValidate(xmlFile).isOK()) {
return;
}
try {
Document doc = XmlUtils.getDocumentFromFile(xmlFile);
/* get State Providers modules */
NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER);
for (int i = 0; i < stateproviderNodes.getLength(); i++) {
Element node = (Element) stateproviderNodes.item(i);
IAnalysisModuleHelper helper = new TmfAnalysisModuleHelperXml(xmlFile, node, XmlAnalysisModuleType.STATE_SYSTEM);
fModules.add(helper);
}
/* get pattern modules */
NodeList patternNodes = doc.getElementsByTagName(TmfXmlStrings.PATTERN);
for (int i = 0; i < patternNodes.getLength(); i++) {
Element node = (Element) patternNodes.item(i);
IAnalysisModuleHelper helper = new TmfAnalysisModuleHelperXml(xmlFile, node, XmlAnalysisModuleType.PATTERN);
fModules.add(helper);
}
Iterable<ITmfXmlSchemaParser> extraSchemaParsers = XmlUtils.getExtraSchemaParsers();
for (ITmfXmlSchemaParser parser : extraSchemaParsers) {
fModules.addAll(parser.getModuleHelpers(xmlFile, doc));
}
} catch (ParserConfigurationException | SAXException | IOException e) {
// $NON-NLS-1$
Activator.logError("Error opening XML file", e);
}
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper in project tracecompass by tracecompass.
the class AnalysisModuleSourceStub method getAnalysisModules.
@Override
public Iterable<IAnalysisModuleHelper> getAnalysisModules() {
List<IAnalysisModuleHelper> list = new ArrayList<>();
IAnalysisModuleHelper helper = new AnalysisModuleTestHelper(moduleStubEnum.TEST);
list.add(helper);
helper = new AnalysisModuleTestHelper(moduleStubEnum.TEST2);
list.add(helper);
return list;
}
use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper 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.IAnalysisModuleHelper in project tracecompass by tracecompass.
the class TmfExperimentElement method refreshChildren.
/**
* @since 2.0
*/
@Override
protected synchronized void refreshChildren() {
/* Update the trace children of this experiment */
// Get the children from the model
Map<String, ITmfProjectModelElement> childrenMap = new HashMap<>();
for (TmfTraceElement trace : getTraces()) {
childrenMap.put(trace.getElementPath(), trace);
}
List<IResource> members = getTraceResources();
for (IResource resource : members) {
String name = resource.getName();
String elementPath = resource.getFullPath().makeRelativeTo(getResource().getFullPath()).toString();
ITmfProjectModelElement element = childrenMap.get(elementPath);
if (element instanceof TmfTraceElement) {
childrenMap.remove(elementPath);
} else {
element = new TmfTraceElement(name, resource, this);
addChild(element);
}
}
// Cleanup dangling children from the model
for (ITmfProjectModelElement danglingChild : childrenMap.values()) {
removeChild(danglingChild);
}
/* Update the analysis under this experiment */
super.refreshChildren();
/*
* If the experiment is opened, add any analysis that was not added by
* the parent if it is available with the experiment
*/
ITmfTrace experiment = getTrace();
if (experiment == null) {
return;
}
/* super.refreshChildren() above should have set this */
TmfViewsElement viewsElement = getChildElementViews();
if (viewsElement == null) {
return;
}
Map<String, TmfAnalysisElement> analysisMap = new HashMap<>();
for (TmfAnalysisElement analysis : getAvailableAnalysis()) {
analysisMap.put(analysis.getAnalysisId(), analysis);
analysis.refreshChildren();
}
for (IAnalysisModuleHelper module : TmfAnalysisManager.getAnalysisModules().values()) {
if (!analysisMap.containsKey(module.getId()) && module.appliesToExperiment() && (experiment.getAnalysisModule(module.getId()) != null)) {
IFolder newresource = ResourcesPlugin.getWorkspace().getRoot().getFolder(getResource().getFullPath().append(module.getId()));
TmfAnalysisElement analysis = new TmfAnalysisElement(module.getName(), newresource, viewsElement, module);
viewsElement.addChild(analysis);
analysis.refreshChildren();
analysisMap.put(module.getId(), analysis);
}
}
}
Aggregations