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
26 public class TmfTreeViewerEntry
implements ITmfTreeViewerEntry
{
29 private ITmfTreeViewerEntry fParent
= null;
31 /** List of child entries */
33 private final List
<ITmfTreeViewerEntry
> fChildren
= new CopyOnWriteArrayList
<>();
35 /** Name of this entry (default text to show in first column) */
42 * The name of this entry
44 public TmfTreeViewerEntry(String name
) {
48 // ---------------------------------------------
49 // Getters and setters
50 // ---------------------------------------------
53 public ITmfTreeViewerEntry
getParent() {
58 * Sets the entry's parent
60 * @param entry The new parent entry
62 protected void setParent(ITmfTreeViewerEntry entry
) {
67 public boolean hasChildren() {
68 return fChildren
.size() > 0;
72 public List
<ITmfTreeViewerEntry
> getChildren() {
77 public String
getName() {
82 * Update the entry name
85 * the updated entry name
87 public void setName(String name
) {
92 * Add a child entry to this one
97 public void addChild(TmfTreeViewerEntry child
) {
103 public String
toString() {
104 return getClass().getSimpleName() + '[' + fName
+ ']';