(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / project / model / LTTngProjectTreeNode.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.ui.views.project.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 /**
19 * <b><u>LTTngProjectTreeNode</u></b>
20 * <p>
21 * TODO: Implement me. Please.
22 */
23 public abstract class LTTngProjectTreeNode implements ILTTngProjectTreeNode {
24
25 protected ILTTngProjectTreeNode fParent = null;
26 protected List<ILTTngProjectTreeNode> fChildren = null;
27
28 // ------------------------------------------------------------------------
29 // Constructor
30 // ------------------------------------------------------------------------
31
32 public LTTngProjectTreeNode(ILTTngProjectTreeNode parent) {
33 fParent = parent;
34 fChildren = new ArrayList<ILTTngProjectTreeNode>();
35 }
36
37 @Override
38 public String toString() {
39 return getName();
40 }
41
42 // ------------------------------------------------------------------------
43 // ILTTngProjectTreeNode
44 // ------------------------------------------------------------------------
45
46 public ILTTngProjectTreeNode getParent() {
47 return fParent;
48 }
49
50 public boolean hasChildren() {
51 return fChildren.size() > 0;
52 }
53
54 public List<ILTTngProjectTreeNode> getChildren() {
55 return fChildren;
56 }
57
58 public abstract void refreshChildren();
59
60 public void refresh() {
61 fParent.refresh();
62 }
63
64 public void removeChild(ILTTngProjectTreeNode child) {
65 for (ILTTngProjectTreeNode node : fChildren) {
66 if (node == child) {
67 node.removeChildren();
68 // We can do it since we are returning right away
69 fChildren.remove(node);
70 return;
71 }
72 }
73 }
74
75 public void removeChildren() {
76 for (ILTTngProjectTreeNode node : fChildren) {
77 node.removeChildren();
78 }
79 fChildren.clear();
80 }
81
82 }
This page took 0.031698 seconds and 5 git commands to generate.