1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.ui
.module
;
15 import java
.util
.List
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.internal
.tmf
.analysis
.xml
.ui
.TmfXmlUiStrings
;
19 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.module
.XmlUtils
;
20 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.stateprovider
.TmfXmlStrings
;
21 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.ui
.module
.TmfXmlAnalysisOutputSource
.ViewType
;
22 import org
.eclipse
.tracecompass
.tmf
.ui
.analysis
.TmfAnalysisViewOutput
;
23 import org
.w3c
.dom
.Element
;
26 * Class overriding the default analysis view output for XML views. These views
27 * may have labels defined in the XML element and those label will be used as
28 * the name of the view
30 * @author Geneviève Bastien
32 * TODO: We shouldn't have to do a new class here, we should be able to
33 * set the name in the parent instead
35 public class TmfXmlViewOutput
extends TmfAnalysisViewOutput
{
37 private String fLabel
= null;
38 private final @NonNull ViewType fViewType
;
44 * id of the view to display as output
46 public TmfXmlViewOutput(String viewid
) {
47 this(viewid
, ViewType
.TIME_GRAPH_VIEW
);
54 * id of the view to display as output
56 * type of view this output is for
58 public TmfXmlViewOutput(String viewid
, @NonNull ViewType viewType
) {
64 public String
getName() {
66 return super.getName();
72 public void setOutputProperty(@NonNull String key
, String value
, boolean immediate
) {
73 super.setOutputProperty(key
, value
, immediate
);
74 /* Find the label of the view */
75 if (key
.equals(TmfXmlUiStrings
.XML_OUTPUT_DATA
)) {
76 String
[] idFile
= value
.split(TmfXmlAnalysisOutputSource
.DATA_SEPARATOR
);
77 String viewId
= (idFile
.length
> 0) ? idFile
[0] : null;
78 String filePath
= (idFile
.length
> 1) ? idFile
[1] : null;
79 if ((viewId
== null) || (filePath
== null)) {
82 Element viewElement
= XmlUtils
.getElementInFile(filePath
, fViewType
.getXmlElem(), viewId
);
83 if (viewElement
== null) {
86 List
<Element
> heads
= XmlUtils
.getChildElements(viewElement
, TmfXmlStrings
.HEAD
);
87 if (heads
.size() != 1) {
90 Element headElement
= heads
.get(0);
91 List
<Element
> label
= XmlUtils
.getChildElements(headElement
, TmfXmlStrings
.LABEL
);
92 if (label
.isEmpty()) {
95 Element labelElement
= label
.get(0);
96 fLabel
= labelElement
.getAttribute(TmfXmlStrings
.VALUE
);