1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
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 * Marc-Andre Laperle - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.wizards
.tracepkg
;
15 import org
.eclipse
.core
.runtime
.IPath
;
16 import org
.eclipse
.core
.runtime
.Path
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfCommonProjectElement
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfNavigatorLabelProvider
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
20 import org
.eclipse
.swt
.graphics
.Image
;
23 * An ExportTraceElement associated to a TmfTraceElement. This will be the
24 * parent of other elements (events, supplementary files, bookmarks, etc).
26 * @author Marc-Andre Laperle
28 public class TracePackageTraceElement
extends TracePackageElement
{
30 private final TmfTraceElement fTraceElement
;
31 private final String fImportName
;
32 private final String fTraceType
;
35 * Construct an instance associated to a TmfTraceElement. For exporting.
38 * the parent of this element, can be set to null
40 * the associated TmfTraceElement
42 public TracePackageTraceElement(TracePackageElement parent
, TmfTraceElement traceElement
) {
44 fTraceElement
= traceElement
;
50 * Construct an instance associated to a TmfTraceElement. For importing.
53 * the parent of this element, can be set to null
55 * the name to use to identify this trace
57 * the trace type to set for this trace
59 public TracePackageTraceElement(TracePackageElement parent
, String importName
, String traceType
) {
61 fImportName
= importName
;
63 fTraceType
= traceType
;
67 public String
getText() {
68 return fTraceElement
!= null ? fTraceElement
.getElementPath() : getDestinationElementPath();
72 * Return the target TmfCommonProjectElement element path for a given trace
73 * package element. {@link TmfCommonProjectElement#getElementPath()}
75 * @return the element path
77 public String
getDestinationElementPath() {
78 String traceName
= getImportName();
79 for (TracePackageElement element
: getChildren()) {
80 if (element
instanceof TracePackageFilesElement
) {
81 TracePackageFilesElement tracePackageFilesElement
= (TracePackageFilesElement
) element
;
82 IPath filePath
= new Path(tracePackageFilesElement
.getFileName());
83 return filePath
.removeLastSegments(1).append(traceName
).toString();
91 * @return the associated TmfTraceElement
93 public TmfTraceElement
getTraceElement() {
98 * @return the import name
100 public String
getImportName() {
105 * @return the trace type of this trace
107 public String
getTraceType() {
112 public Image
getImage() {
113 TmfNavigatorLabelProvider tmfNavigatorLabelProvider
= new TmfNavigatorLabelProvider();
114 return tmfNavigatorLabelProvider
.getImage(fTraceElement
);