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 */
31 private final @NonNull List
<@NonNull ITmfTreeViewerEntry
> fChildren
= new CopyOnWriteArrayList
<>();
33 /** Name of this entry (default text to show in first column) */
40 * The name of this entry
42 public TmfTreeViewerEntry(String name
) {
46 // ---------------------------------------------
47 // Getters and setters
48 // ---------------------------------------------
51 public ITmfTreeViewerEntry
getParent() {
56 * Sets the entry's parent
58 * @param entry The new parent entry
60 protected void setParent(ITmfTreeViewerEntry entry
) {
65 public boolean hasChildren() {
66 return fChildren
.size() > 0;
70 public List
<@NonNull ITmfTreeViewerEntry
> getChildren() {
75 public String
getName() {
80 * Update the entry name
83 * the updated entry name
85 public void setName(String name
) {
90 * Add a child entry to this one
95 public void addChild(TmfTreeViewerEntry child
) {
101 public String
toString() {
102 return getClass().getSimpleName() + '[' + fName
+ ']';