about.html,\
plugin.xml
src.includes = about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
\ No newline at end of file
--- /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.internal.tmf.analysis.xml.ui;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * This file defines all names in the XML Structure for UI elements
+ *
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings({ "javadoc", "nls" })
+@NonNullByDefault
+public interface TmfXmlUiStrings {
+
+ /* XML generic Element attribute names */
+ static final String STATE_PROVIDER_VIEW = "stateSystemView";
+
+ /* View elements and attributes */
+ static final String SSV_LINE = "line";
+ static final String ENTRY_ELEMENT = "entry";
+
+ /* Elements and attributes of view entries */
+ static final String PATH = "path";
+ static final String DISPLAY_ELEMENT = "display";
+ static final String PARENT_ELEMENT = "parent";
+ static final String NAME_ELEMENT = "name";
+ static final String ID_ELEMENT = "id";
+
+ /* Generic strings for the XML module */
+ static final String XML_OUTPUT_DATA = "xmlOutputData";
+
+}
\ No newline at end of file
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.IAnalysisModuleHelper;
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.ui.analysis.TmfAnalysisViewOutput;
import org.osgi.framework.Bundle;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/* 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
+ */
+ ssModule.setAutomatic(true);
- module.registerOutput(new TmfAnalysisViewOutput("org.eclipse.linuxtools.tmf.ui.views.ssvisualizer")); //$NON-NLS-1$
break;
default:
break;
}
if (module != null) {
module.setTrace(trace);
+ TmfAnalysisManager.analysisModuleCreated(module);
}
return module;
--- /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.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.IPath;
+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.core.analysis.IAnalysisModule;
+import org.eclipse.linuxtools.tmf.core.analysis.ITmfNewAnalysisModuleListener;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * This class searches all XML files to find outputs applicable to the newly
+ * created analysis
+ *
+ * @author Geneviève Bastien
+ */
+public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener {
+
+ /** String separating data elements for the output properties */
+ public static final String DATA_SEPARATOR = ";;;"; //$NON-NLS-1$
+
+ @Override
+ public void moduleCreated(IAnalysisModule module) {
+ IPath pathToFiles = XmlUtils.getXmlFilesPath();
+ File fFolder = pathToFiles.toFile();
+ if (!(fFolder.isDirectory() && fFolder.exists())) {
+ return;
+ }
+ for (File xmlFile : fFolder.listFiles()) {
+ if (!XmlUtils.xmlValidate(xmlFile).isOK()) {
+ continue;
+ }
+
+ try {
+ /* Load the XML File */
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(xmlFile);
+ doc.getDocumentElement().normalize();
+
+ /* get state provider views if the analysis has state systems */
+ /* TODO: Code here will come in later patch */
+
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ Activator.logError("Error opening XML file", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+}
--- /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.jdt.annotation.NonNull;
+import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
+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.ui.analysis.TmfAnalysisViewOutput;
+import org.w3c.dom.Element;
+
+/**
+ * Class overriding the default analysis view output for XML views. These views
+ * may have labels defined in the XML element and those label will be used as
+ * the name of the view
+ *
+ * @author Geneviève Bastien
+ *
+ * TODO: We shouldn't have to do a new class here, we should be able to
+ * set the name in the parent instead
+ */
+public class TmfXmlViewOutput extends TmfAnalysisViewOutput {
+
+ private String fLabel = null;
+
+ /**
+ * Constructor
+ *
+ * @param viewid
+ * id of the view to display as output
+ */
+ public TmfXmlViewOutput(String viewid) {
+ super(viewid);
+ }
+
+ @Override
+ public String getName() {
+ if (fLabel == null) {
+ return super.getName();
+ }
+ return fLabel;
+ }
+
+ @Override
+ public void setOutputProperty(@NonNull String key, String value, boolean immediate) {
+ super.setOutputProperty(key, value, immediate);
+ /* Find the label of the view */
+ if (key.equals(TmfXmlUiStrings.XML_OUTPUT_DATA)) {
+ String[] idFile = value.split(TmfXmlAnalysisOutputSource.DATA_SEPARATOR);
+ String viewId = (idFile.length > 0) ? idFile[0] : null;
+ String filePath = (idFile.length > 1) ? idFile[1] : null;
+ if ((viewId == null) || (filePath == null)) {
+ return;
+ }
+ Element viewElement = XmlUtils.getElementInFile(filePath, TmfXmlUiStrings.STATE_PROVIDER_VIEW, viewId);
+ if (viewElement == null) {
+ return;
+ }
+ List<Element> heads = XmlUtils.getChildElements(viewElement, TmfXmlStrings.HEAD);
+ if (heads.size() != 1) {
+ return;
+ }
+ Element headElement = heads.get(0);
+ List<Element> label = XmlUtils.getChildElements(headElement, TmfXmlStrings.LABEL);
+ if (label.isEmpty()) {
+ return;
+ }
+ Element labelElement = label.get(0);
+ fLabel = labelElement.getAttribute(TmfXmlStrings.VALUE);
+ }
+ }
+}
private static List<IAnalysisModuleHelper> fModules = null;
+ /**
+ * Constructor. It adds the new module listener to the analysis manager.
+ */
+ public XmlAnalysisModuleSource() {
+ TmfAnalysisManager.addNewModuleListener(new TmfXmlAnalysisOutputSource());
+ }
+
@Override
public synchronized Iterable<IAnalysisModuleHelper> getAnalysisModules() {
if (fModules == null) {