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
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.core
.resources
.IProject
;
19 import org
.eclipse
.core
.resources
.IWorkspaceRoot
;
20 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.ProjectView
;
24 * <b><u>LTTngProjectRoot</u></b>
26 * TODO: Implement me. Please.
28 public class LTTngProjectRoot
extends LTTngProjectTreeNode
{
30 private final ProjectView fView
;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 public LTTngProjectRoot(ProjectView view
) {
43 public void refresh() {
47 // ------------------------------------------------------------------------
48 // LTTngProjectTreeNode
49 // ------------------------------------------------------------------------
52 public String
getName() {
57 public void refreshChildren() {
58 IWorkspaceRoot root
= ResourcesPlugin
.getWorkspace().getRoot();
59 IProject
[] projects
= root
.getProjects();
60 for (IProject project
: projects
) {
61 LTTngProjectNode node
= find(project
.getName());
63 node
= new LTTngProjectNode(this, project
);
69 List
<ILTTngProjectTreeNode
> toRemove
= new ArrayList
<ILTTngProjectTreeNode
>();
70 for (ILTTngProjectTreeNode node
: fChildren
) {
71 if (exists(node
.getName(), projects
)) {
72 node
.refreshChildren();
78 for (ILTTngProjectTreeNode node
: toRemove
) {
79 fChildren
.remove(node
);
83 private LTTngProjectNode
find(String name
) {
84 for (ILTTngProjectTreeNode node
: fChildren
) {
85 if (node
instanceof LTTngProjectNode
&& node
.getName().equals(name
)) {
86 return (LTTngProjectNode
) node
;
92 private boolean exists(String name
, IProject
[] projects
) {
93 for (IProject project
: projects
) {
94 if (project
.getName().equals(name
))