Commit | Line | Data |
---|---|---|
38fad53e JCK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 Ericsson | |
3 | * | |
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 | |
8 | *******************************************************************************/ | |
9 | package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views; | |
10 | ||
11 | import org.eclipse.jdt.annotation.Nullable; | |
12 | import org.eclipse.jface.dialogs.IDialogSettings; | |
13 | import org.eclipse.tracecompass.tmf.analysis.xml.ui.module.TmfXmlAnalysisOutputSource; | |
14 | ||
15 | /** | |
16 | * Class that manages information about a latency view for pattern analysis: its | |
17 | * title, the analysis ID, etc. | |
18 | * | |
19 | * @author Jean-Christian Kouame | |
20 | * | |
21 | */ | |
22 | public class XmlLatencyViewInfo extends AbstractXmlViewInfo { | |
23 | ||
24 | private static final String XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY = "XmlLatencyAnalysisId"; //$NON-NLS-1$ | |
25 | private static final String XML_LATENCY_VIEW_LABEL_PROPERTY = "XmlLatencyViewLabel"; //$NON-NLS-1$ | |
26 | ||
27 | private @Nullable String fAnalysisId = null; | |
28 | private @Nullable String fLabel = null; | |
29 | ||
30 | /** | |
31 | * Constructor | |
32 | * | |
33 | * @param viewId | |
34 | * The ID of the view | |
35 | */ | |
36 | public XmlLatencyViewInfo(String viewId) { | |
37 | super(viewId); | |
38 | ||
39 | IDialogSettings settings = getPersistentPropertyStore(); | |
40 | fAnalysisId = settings.get(XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY); | |
41 | fLabel = settings.get(XML_LATENCY_VIEW_LABEL_PROPERTY); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Get the analysis ID this view is for | |
46 | * | |
47 | * @return The analysis ID this view | |
48 | */ | |
49 | public String getViewAnalysisId() { | |
50 | return fAnalysisId; | |
51 | } | |
52 | ||
53 | /** | |
54 | * Set the data for this view and retrieves from it the analysis ID of the | |
55 | * pattern analysis this view belongs to and the view label. | |
56 | * | |
57 | * @param data | |
58 | * A string of the form "XML analysis ID" + | |
59 | * {@link TmfXmlAnalysisOutputSource#DATA_SEPARATOR} + | |
60 | * "latency view label" | |
61 | */ | |
62 | @Override | |
63 | public void setViewData(String data) { | |
64 | String[] idFile = data.split(TmfXmlAnalysisOutputSource.DATA_SEPARATOR); | |
65 | fAnalysisId = (idFile.length > 0) ? idFile[0] : null; | |
66 | fLabel = (idFile.length > 1) ? idFile[1] : null; | |
67 | savePersistentData(); | |
68 | } | |
69 | ||
70 | @Override | |
71 | protected void savePersistentData() { | |
72 | IDialogSettings settings = getPersistentPropertyStore(); | |
73 | ||
74 | settings.put(XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY, fAnalysisId); | |
75 | settings.put(XML_LATENCY_VIEW_LABEL_PROPERTY, fLabel); | |
76 | } | |
77 | } |