1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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>LTTngTraceFolderNode</u></b>
24 * TODO: Implement me. Please.
26 public class LTTngTraceFolderNode
extends LTTngProjectTreeNode
{
28 private final IFolder fTraceFolder
;
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 public LTTngTraceFolderNode(IFolder folder
) {
38 public LTTngTraceFolderNode(ILTTngProjectTreeNode parent
, IFolder folder
) {
40 fTraceFolder
= folder
;
43 // ------------------------------------------------------------------------
44 // LTTngProjectTreeNode
45 // ------------------------------------------------------------------------
47 public String
getName() {
48 return fTraceFolder
.getName();
52 public void refreshChildren() {
54 IResource
[] resources
= fTraceFolder
.members();
55 for (IResource resource
: resources
) {
56 if (resource
instanceof IFolder
) {
57 LTTngTraceNode node
= find(resource
.getName());
59 node
= new LTTngTraceNode(this, (IFolder
) resource
);
64 for (ILTTngProjectTreeNode node
: fChildren
) {
65 if (!exists(node
.getName(), resources
)) {
66 fChildren
.remove(node
);
69 } catch (CoreException e
) {
73 private LTTngTraceNode
find(String name
) {
74 for (ILTTngProjectTreeNode node
: fChildren
) {
75 if (node
instanceof LTTngTraceNode
&& node
.getName().equals(name
)) {
76 return (LTTngTraceNode
) node
;
82 private boolean exists(String name
, IResource
[] resources
) {
83 for (IResource resource
: resources
) {
84 if (resource
.getName().equals(name
))
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
97 public LTTngProjectNode
getProject() {
98 return (LTTngProjectNode
) getParent();
104 public IFolder
getFolder() {
111 public LTTngTraceNode
[] getTraces() {
112 LTTngTraceNode
[] result
= (LTTngTraceNode
[]) Array
.newInstance(LTTngTraceNode
.class, fChildren
.size());
113 return fChildren
.toArray(result
);
116 // ------------------------------------------------------------------------
118 // ------------------------------------------------------------------------
120 // No longer needed: handled by the IResourceChangeListener in the View
121 public void addTrace(IFolder trace
) {
122 // LTTngTraceNode node = new LTTngTraceNode(this, trace);
123 // fChildren.add(node);