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 // ------------------------------------------------------------------------
51 public String
getName() {
56 public void refreshChildren() {
57 IWorkspaceRoot root
= ResourcesPlugin
.getWorkspace().getRoot();
58 IProject
[] projects
= root
.getProjects();
59 for (IProject project
: projects
) {
60 LTTngProjectNode node
= find(project
.getName());
62 node
= new LTTngProjectNode(this, project
);
68 List
<ILTTngProjectTreeNode
> toRemove
= new ArrayList
<ILTTngProjectTreeNode
>();
69 for (ILTTngProjectTreeNode node
: fChildren
) {
70 if (exists(node
.getName(), projects
)) {
71 node
.refreshChildren();
77 for (ILTTngProjectTreeNode node
: toRemove
) {
78 fChildren
.remove(node
);
82 private LTTngProjectNode
find(String name
) {
83 for (ILTTngProjectTreeNode node
: fChildren
) {
84 if (node
instanceof LTTngProjectNode
&& node
.getName().equals(name
)) {
85 return (LTTngProjectNode
) node
;
91 private boolean exists(String name
, IProject
[] projects
) {
92 for (IProject project
: projects
) {
93 if (project
.getName().equals(name
))