KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > gui > tree > ScenarioTreeContentProvider


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2004 France Telecom R&D
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * CLIF
20 *
21 * Contact: clif@objectweb.org
22 */

23 package org.objectweb.clif.scenario.util.isac.gui.tree;
24
25 import org.objectweb.clif.scenario.util.isac.util.tree.ScenarioNode;
26 import org.apache.log4j.Category;
27 import org.eclipse.jface.viewers.ITreeContentProvider;
28 import java.util.Vector JavaDoc;
29 import org.eclipse.jface.viewers.Viewer;
30
31 /**
32  * This class is an extension to ContentProvider class, which permit to build the tree
33  * showed by the TreeViewer with ScenarioNode elements
34  *
35  * @author JC Meillaud
36  * @author A Peyrard
37  */

38 public class ScenarioTreeContentProvider implements ITreeContentProvider {
39     static Category cat = Category.getInstance(ScenarioTreeContentProvider.class.getName());
40     
41     /**
42      * Method which return a table object containing all the children nodes
43      * @param element The parent node
44      * @return The children nodes
45      */

46     public Object JavaDoc[] getChildren(Object JavaDoc element) {
47         cat.debug("-> getChildren") ;
48         Vector JavaDoc children = ((ScenarioNode) element).getChildren();
49         return (Object JavaDoc[]) children.toArray(new Object JavaDoc[children.size()]);
50         //Object[] kids = new Object[children.size()];
51
//for (int i = 0; i < children.size(); i++)
52
// kids[i] = children.elementAt(i);
53

54         //return kids;
55
}
56
57     /**
58      * Method which return a table of object, in this case the children nodes
59      * @param element The parent node
60      * @return The children nodes
61      */

62     public Object JavaDoc[] getElements(Object JavaDoc element) {
63         cat.debug("-> getElements") ;
64         return getChildren(element);
65     }
66
67     /**
68      * Method which analyse if a node have got children
69      * @param element The parent node
70      * @return True if the node have got children
71      */

72     public boolean hasChildren(Object JavaDoc element) {
73         cat.debug("-> hasChildren") ;
74         return getChildren(element).length > 0;
75     }
76
77     /**
78      * Method returning the parent of a node
79      * @param element The child node
80      * @return The parent node
81      */

82     public Object JavaDoc getParent(Object JavaDoc element) {
83         cat.debug("-> getParent") ;
84         return ((ScenarioNode) element).getParent();
85     }
86
87     /**
88      * Do nothing
89      */

90     public void dispose() {
91         cat.debug("-> dispose") ;
92     }
93
94     /**
95      * Do nothing
96      * @param viewer
97      * @param old_input
98      * @param new_input
99      */

100     public void inputChanged(
101         Viewer viewer,
102         Object JavaDoc old_input,
103         Object JavaDoc new_input) {
104     }
105
106 }
107
Popular Tags