Search in sources :

Example 1 with IAnalysisModuleHelper

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;
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 2 with IAnalysisModuleHelper

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);
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) TmfAnalysisModuleHelperXml(org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfAnalysisModuleHelperXml) ITmfXmlSchemaParser(org.eclipse.tracecompass.tmf.analysis.xml.core.module.ITmfXmlSchemaParser) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException)

Example 3 with IAnalysisModuleHelper

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;
}
Also used : ArrayList(java.util.ArrayList) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)

Example 4 with IAnalysisModuleHelper

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;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) MultiStatus(org.eclipse.core.runtime.MultiStatus) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)

Example 5 with IAnalysisModuleHelper

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);
        }
    }
}
Also used : HashMap(java.util.HashMap) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IAnalysisModuleHelper (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)16 Test (org.junit.Test)10 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)6 File (java.io.File)4 XmlAnalysisModuleSource (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlAnalysisModuleSource)4 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)4 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 IFolder (org.eclipse.core.resources.IFolder)2 Element (org.w3c.dom.Element)2 NodeList (org.w3c.dom.NodeList)2 IOException (java.io.IOException)1 Map (java.util.Map)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1