1 /*******************************************************************************
2 * Copyright (c) 2009 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
;
15 import java
.lang
.reflect
.Array
;
17 import org
.eclipse
.core
.resources
.IFolder
;
18 import org
.eclipse
.core
.resources
.IResource
;
19 import org
.eclipse
.core
.runtime
.CoreException
;
22 * <b><u>LTTngExperimentNode</u></b>
24 * TODO: Implement me. Please.
26 public class LTTngExperimentNode
extends LTTngProjectTreeNode
{
28 private final IFolder fExperiment
;
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 public LTTngExperimentNode(IFolder resource
) {
38 public LTTngExperimentNode(ILTTngProjectTreeNode parent
, IFolder folder
) {
43 // ------------------------------------------------------------------------
44 // LTTngProjectTreeNode
45 // ------------------------------------------------------------------------
48 public String
getName() {
49 return fExperiment
.getName();
53 public void refreshChildren() {
55 IResource
[] resources
= fExperiment
.members(0);
56 for (IResource resource
: resources
) {
57 LTTngTraceNode node
= find(resource
.getName());
59 node
= new LTTngTraceNode(this, (IFolder
) resource
);
63 for (ILTTngProjectTreeNode node
: fChildren
) {
64 if (!exists(node
.getName(), resources
)) {
65 fChildren
.remove(node
);
68 } catch (CoreException e
) {
72 private LTTngTraceNode
find(String name
) {
73 for (ILTTngProjectTreeNode node
: fChildren
) {
74 if (node
instanceof LTTngTraceNode
&& node
.getName().equals(name
)) {
75 return (LTTngTraceNode
) node
;
81 private boolean exists(String name
, IResource
[] resources
) {
82 for (IResource resource
: resources
) {
83 if (resource
.getName().equals(name
))
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
93 // No longer needed: handled by the IResourceChangeListener in the View
94 public void addTrace(IFolder trace
) {
95 // LTTngTraceNode node = new LTTngTraceNode(this, trace);
96 // fChildren.add(node);
100 // ------------------------------------------------------------------------
102 // ------------------------------------------------------------------------
107 public IFolder
getFolder() {
114 public LTTngTraceNode
[] getTraces() {
115 LTTngTraceNode
[] result
= (LTTngTraceNode
[]) Array
.newInstance(LTTngTraceNode
.class, fChildren
.size());
116 return fChildren
.toArray(result
);
122 public LTTngProjectNode
getProject() {
123 return (LTTngProjectNode
) getParent().getParent();