org.eclipse.linuxtools.tmf.core,
org.eclipse.linuxtools.tmf.core.tests,
org.eclipse.linuxtools.tmf.ctf.core,
- org.eclipse.linuxtools.tmf.ctf.core.tests
+ org.eclipse.linuxtools.tmf.ctf.core.tests,
+ org.eclipse.linuxtools.statesystem.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Import-Package: org.junit.runners
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlHeadInfo;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.XmlStateSystemModule;
import org.eclipse.linuxtools.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
assertEquals(ANALYSIS_ID, fModule.getId());
fModule.setXmlFile(new Path(TmfXmlTestFiles.VALID_FILE.getFile().getAbsolutePath()));
- NodeList head = node.getElementsByTagName(TmfXmlStrings.HEAD);
- XmlHeadInfo headInfo = null;
- if (head.getLength() == 1) {
- headInfo = new XmlHeadInfo(head.item(0));
- }
- fModule.setHeadInfo(headInfo);
assertEquals(ANALYSIS_NAME, fModule.getName());
}
fModule.setId(moduleId);
fModule.setXmlFile(new Path(TmfXmlTestFiles.VALID_FILE.getFile().getAbsolutePath()));
- NodeList head = node.getElementsByTagName(TmfXmlStrings.HEAD);
- XmlHeadInfo headInfo = null;
- if (head.getLength() == 1) {
- headInfo = new XmlHeadInfo(head.item(0));
- }
- fModule.setHeadInfo(headInfo);
try {
ITmfTrace trace = CtfTmfTestTrace.KERNEL.getTrace();
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlHeadInfo;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.XmlStateSystemModule;
import org.eclipse.linuxtools.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
fModule.setId(moduleId);
fModule.setXmlFile(new Path(TmfXmlTestFiles.VALID_FILE.getFile().getAbsolutePath()));
- NodeList head = node.getElementsByTagName(TmfXmlStrings.HEAD);
- XmlHeadInfo headInfo = null;
- if (head.getLength() == 1) {
- headInfo = new XmlHeadInfo(head.item(0));
- }
- fModule.setHeadInfo(headInfo);
+
try {
fModule.setTrace(fTrace);
fModule.schedule();
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.analysis.xml.core.module;
-
-/**
- * Interface that XML analysis modules may implement to interpret the extra
- * metadata they may get for example from the header element in the XML file.
- *
- * @author Geneviève Bastien
- */
-public interface IXmlModuleMetadata {
-
- /**
- * Set the header information node associated with this module
- *
- * @param headInfo
- * The header information
- */
- void setHeadInfo(XmlHeadInfo headInfo);
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.analysis.xml.core.module;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Class to store and interpret the header information of XML-defined components
- *
- * @author Geneviève Bastien
- */
-public class XmlHeadInfo {
-
- private final Node fHeadInfo;
-
- /**
- * Constructor
- *
- * @param item
- * The XML node corresponding to this header
- */
- public XmlHeadInfo(Node item) {
- fHeadInfo = item;
- }
-
- /**
- * Get a list of child elements with the requested name
- *
- * @param nodeName
- * The name of the nodes to get
- * @return List of child elements
- */
- public List<Element> getElements(String nodeName) {
- List<Element> list = new ArrayList<>();
- NodeList nodes = fHeadInfo.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- if (node instanceof Element) {
- Element element = (Element) node;
- if (element.getNodeName().equals(nodeName)) {
- list.add(element);
- }
- }
- }
- return list;
- }
-
- /**
- * Check whether, if this header information has trace types defined, this
- * component applies to a given trace type.
- *
- * @param traceClass
- * The trace type to check for
- * @return True if there is no trace type information in header or if the
- * trace type applies
- */
- public boolean checkTraceType(Class<? extends ITmfTrace> traceClass) {
- /*
- * By default this returns true, child implementation who have access to
- * trace types will override this
- *
- * TODO: actually check the trace type here when trace types are moved
- * to o.e.l.tmf.core instead of o.e.l.tmf.ui
- */
- return true;
- }
-
- /**
- * Get the name of this component from the header information
- *
- * @return The name of the component
- */
- public String getName() {
- List<Element> elements = getElements(TmfXmlStrings.LABEL);
- if (elements.isEmpty()) {
- return null;
- }
-
- Element element = elements.get(0);
- return element.getAttribute(TmfXmlStrings.VALUE);
- }
-
-}
package org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider;
+import java.util.List;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.tmf.analysis.xml.core.module.IXmlModuleMetadata;
-import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlHeadInfo;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlUtils;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.w3c.dom.Element;
/**
* Analysis module for the data-driven state systems, defined in XML.
* @author Geneviève Bastien
* @since 3.0
*/
-public class XmlStateSystemModule extends TmfStateSystemAnalysisModule
- implements IXmlModuleMetadata {
+public class XmlStateSystemModule extends TmfStateSystemAnalysisModule {
private IPath fXmlFile;
- private XmlHeadInfo fHeadInfo = null;
@Override
protected StateSystemBackendType getBackendType() {
@Override
public String getName() {
- String name = fHeadInfo.getName();
- if (name == null) {
- name = getId();
+ String name = getId();
+ Element doc = XmlUtils.getElementInFile(fXmlFile.makeAbsolute().toString(), TmfXmlStrings.STATE_PROVIDER, getId());
+ /* Label may be available in XML header */
+ List<Element> head = XmlUtils.getChildElements(doc, TmfXmlStrings.HEAD);
+ if (head.size() == 1) {
+ List<Element> labels = XmlUtils.getChildElements(head.get(0), TmfXmlStrings.LABEL);
+ if (!labels.isEmpty()) {
+ name = labels.get(0).getAttribute(TmfXmlStrings.VALUE);
+ }
}
+
return name;
}
fXmlFile = file;
}
- @Override
- public void setHeadInfo(XmlHeadInfo headInfo) {
- fHeadInfo = headInfo;
- }
-
/**
* Get the path to the XML file containing this state provider definition.
*
import java.io.File;
import java.util.Collections;
+import java.util.List;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.Activator;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlUtils;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.XmlStateSystemModule;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
+import org.eclipse.linuxtools.tmf.core.project.model.TraceTypeHelper;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.osgi.framework.Bundle;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
/**
* Analysis module helpers for modules provided by XML files
private final File fSourceFile;
private final Element fSourceElement;
private final XmlAnalysisModuleType fType;
- private final XmlHeadInfoUi fHeadInfo;
/**
* Constructor
fSourceFile = xmlFile;
fSourceElement = node;
fType = type;
-
- NodeList head = fSourceElement.getElementsByTagName(TmfXmlStrings.HEAD);
- if (head.getLength() == 1) {
- fHeadInfo = new XmlHeadInfoUi(head.item(0));
- } else {
- fHeadInfo = null;
- }
}
@Override
@Override
public String getName() {
- String name = fHeadInfo.getName();
+ String name = null;
+ /* Label may be available in XML header */
+ List<Element> head = XmlUtils.getChildElements(fSourceElement, TmfXmlStrings.HEAD);
+ if (head.size() == 1) {
+ List<Element> labels = XmlUtils.getChildElements(head.get(0), TmfXmlStrings.LABEL);
+ if (!labels.isEmpty()) {
+ name = labels.get(0).getAttribute(TmfXmlStrings.VALUE);
+ }
+ }
+
if (name == null) {
name = getId();
}
}
@Override
- public boolean appliesToTraceType(Class<? extends ITmfTrace> traceclass) {
+ public boolean appliesToTraceType(Class<? extends ITmfTrace> traceClass) {
/* Trace types may be available in XML header */
- if (fHeadInfo == null) {
+ List<Element> head = XmlUtils.getChildElements(fSourceElement, TmfXmlStrings.HEAD);
+ if (head.size() != 1) {
+ return true;
+ }
+ /*
+ * TODO: Test with custom trace types
+ */
+ List<Element> elements = XmlUtils.getChildElements(head.get(0), TmfXmlStrings.TRACETYPE);
+ if (elements.isEmpty()) {
return true;
}
- return fHeadInfo.checkTraceType(traceclass);
+ for (Element element : elements) {
+ String traceTypeId = element.getAttribute(TmfXmlStrings.ID);
+ TraceTypeHelper helper = TmfTraceType.getInstance().getTraceType(traceTypeId);
+ if ((helper != null) && helper.getTrace().getClass().isAssignableFrom(traceClass)) {
+ return true;
+ }
+ }
+ return false;
}
@Override
module.setId(analysisid);
ssModule.setXmlFile(new Path(fSourceFile.getAbsolutePath()));
- /* Set header information if available */
- ssModule.setHeadInfo(fHeadInfo);
/*
* FIXME: There is no way to know if a module is automatic, so we
* default to true
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.analysis.xml.ui.module;
-
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlHeadInfo;
-import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
-import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
-import org.eclipse.linuxtools.tmf.core.project.model.TraceTypeHelper;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Class to store and interpret the header information of XML-defined components
- *
- * TODO: When trace types are moved to the o.e.l.tmf.core plug-in, there will be
- * no need for this class anymore, move to o.e.l.tmf.analysis.xml.core plug-in.
- *
- * @author Geneviève Bastien
- */
-public class XmlHeadInfoUi extends XmlHeadInfo {
-
- /**
- * Constructor
- *
- * @param item
- * The XML node corresponding to this header
- */
- public XmlHeadInfoUi(Node item) {
- super(item);
- }
-
- @Override
- public boolean checkTraceType(Class<? extends ITmfTrace> traceClass) {
- /*
- * TODO: This wouldn't work for custom traces since {@link
- * TmfTraceType#getTraceType(String)} has no helper for those traces
- */
- List<Element> elements = getElements(TmfXmlStrings.TRACETYPE);
- if (elements.isEmpty()) {
- return true;
- }
-
- for (Element element : elements) {
- String traceTypeId = element.getAttribute(TmfXmlStrings.ID);
- TraceTypeHelper helper = TmfTraceType.getInstance().getTraceType(traceTypeId);
- if ((helper != null) && helper.getTrace().getClass().isAssignableFrom(traceClass)) {
- return true;
- }
- }
- return false;
- }
-
-}