KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > util > tree > nodes > BehaviorNode


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.util.tree.nodes;
24
25 import java.util.Hashtable JavaDoc;
26 import java.util.Vector JavaDoc;
27
28 import org.objectweb.clif.scenario.util.isac.plugin.gui.ParametersWidgetsNode;
29 import org.objectweb.clif.scenario.util.isac.plugin.gui.WidgetDescription;
30 import org.objectweb.clif.scenario.util.isac.util.tree.Node;
31 import org.objectweb.clif.scenario.util.isac.util.tree.NodeDescription;
32 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager;
33
34 /**
35  * Some methods use for the 'behavior' nodes
36  *
37  * @author JC Meillaud
38  * @author A Peyrard
39  */

40 public class BehaviorNode {
41
42     /**
43      * Help behavior node getter
44      * @return The help lines
45      */

46     public static Vector JavaDoc getHelp() {
47         
48         return null ;
49     }
50     
51     /**
52      * Create a 'behavior' node description
53      * @return The node description created
54      */

55     public static NodeDescription createNodeDescription() {
56         NodeDescription desc = new NodeDescription(Node.BEHAVIOR) ;
57         Hashtable JavaDoc params = new Hashtable JavaDoc() ;
58         params.put("id", idGenerator()) ;
59         desc.setParams(params) ;
60         return desc ;
61     }
62     
63     /**
64      * Create the parameters widgets tree
65      * @return The tree created
66      */

67     public static ParametersWidgetsNode createParametersWidgetsNode() {
68         ParametersWidgetsNode pwn = new ParametersWidgetsNode(null) ;
69         // add the id parameter field
70
ParametersWidgetsNode child = new ParametersWidgetsNode(new WidgetDescription(WidgetDescription.TEXT_FIELD, "id",null, null)) ;
71         pwn.addChild(child) ;
72         return pwn ;
73     }
74     
75     /**
76      * Generate a new unique key
77      * @return The new created key
78      */

79     public static String JavaDoc idGenerator() {
80         String JavaDoc result = "b" ;
81         
82         Vector JavaDoc ids = TreeManager.getTreeManager(null).getBehaviorsIds() ;
83         // create a new key
84
int intKeyPart = 0 ;
85         while (ids.contains(result.concat(new Integer JavaDoc(intKeyPart).toString()))) intKeyPart ++ ;
86         
87         return result.concat(Integer.toString(intKeyPart)) ;
88     }
89     
90 }
91
Popular Tags