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
.ui
.viewers
.tree
;
15 import java
.util
.List
;
16 import java
.util
.concurrent
.CopyOnWriteArrayList
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
21 * Basic implementation of an entry for the TMF tree viewer. A name is all that is needed for this entry.
23 * @author Geneviève Bastien
25 public class TmfTreeViewerEntry
implements ITmfTreeViewerEntry
{
28 private ITmfTreeViewerEntry fParent
= null;
30 /** List of child entries */
32 private final List
<ITmfTreeViewerEntry
> fChildren
= new CopyOnWriteArrayList
<>();
34 /** Name of this entry (default text to show in first column) */
41 * The name of this entry
43 public TmfTreeViewerEntry(String name
) {
47 // ---------------------------------------------
48 // Getters and setters
49 // ---------------------------------------------
52 public ITmfTreeViewerEntry
getParent() {
57 * Sets the entry's parent
59 * @param entry The new parent entry
61 protected void setParent(ITmfTreeViewerEntry entry
) {
66 public boolean hasChildren() {
67 return fChildren
.size() > 0;
71 public List
<ITmfTreeViewerEntry
> getChildren() {
76 public String
getName() {
81 * Update the entry name
84 * the updated entry name
86 public void setName(String name
) {
91 * Add a child entry to this one
96 public void addChild(TmfTreeViewerEntry child
) {
102 public String
toString() {
103 return getClass().getSimpleName() + '[' + fName
+ ']';