(no commit message)
[sfa.git] / gui / JavaApplication1 / src / javaapplication1 / DisplayHandle.java
1 /*
2  * DisplayHandle.java
3  *
4  * Created on March 29, 2008, 2:42 AM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */
9
10 package javaapplication1;
11
12 import java.io.*;
13 import javax.swing.JPanel;
14 import java.awt.*;
15 import javax.swing.*;
16
17 /**
18  *
19  * @author soners
20  */
21 public class DisplayHandle {
22     
23     /** Creates a new instance of DisplayHandle */
24     public DisplayHandle(BufferedWriter outCommand) {
25         this.outCommand = outCommand;
26         createCompListUser();
27         createCompListSlice();
28         createCompListNode();
29         createCompListSite();
30     }
31     
32     private void createCompListNode(){
33         compList_node = new GuiComponent[33];
34         GuiComponent[] compList = compList_node;
35         String[] tmplist1 = {"readable","pl"};
36         String[] tmplist2 = {"writable","pl"};
37         String[] tmplist3 = {"readable","geni"};
38         String[] tmplist4 = {"writable","geni"};
39         compList[0] = new GuiComponent("node_id", tmplist1, "text", "Node Id", "");
40         compList[1] = new GuiComponent("last_updated", tmplist1, "text", "Last Updated", "");
41         compList[2] = new GuiComponent("boot_state", tmplist2, "combo", "Boot state", "boot, dbg, inst, new, rcnf, rins");
42         compList[3] = new GuiComponent("site_id", tmplist1, "num", "Site Id", "");
43         compList[4] = new GuiComponent("pcu_ids", tmplist2, "num", "PCU Ids", "");
44         compList[5] = new GuiComponent("session", tmplist1, "text", "Session", "");
45         compList[6] = new GuiComponent("key", tmplist2, "key", "Key", "");
46         compList[7] = new GuiComponent("conf_file_ids", tmplist2, "text", "Conf file Ids", "");
47         compList[8] = new GuiComponent("ssh_rsa_key", tmplist1, "text", "SSH RSA Key", "");
48         compList[9] = new GuiComponent("ssh_rsa_key_write", tmplist2, "key", "SSH RSA Key", "");
49         compList[10] = new GuiComponent("uuid", tmplist1, "text", "UUID", "");
50         compList[11] = new GuiComponent("nodegroup_ids", tmplist2, "num", "Node Group Ids", "");
51         compList[12] = new GuiComponent("slice_ids_whitelist", tmplist2, "text", "Slice Ids Whitelist", "");
52         compList[13] = new GuiComponent("last_contact", tmplist2, "text", "Last Contact", "");
53         compList[14] = new GuiComponent("nodenetwork_ids", tmplist2, "text", "Node Network Ids", "");
54         compList[15] = new GuiComponent("peer_node_id", tmplist2, "num", "Peer Node Id", "");
55         compList[16] = new GuiComponent("hostname", tmplist2, "text", "Hostname", "randomsite.edu");
56         compList[17] = new GuiComponent("slice_ids", tmplist1, "num", "Slice Ids", "");
57         compList[18] = new GuiComponent("boot_nonce", tmplist2, "text", "Boot Nonce", "");
58         compList[19] = new GuiComponent("version", tmplist2, "text", "Version", "PlanetLab BootCD 3.1");
59         compList[20] = new GuiComponent("date_created", tmplist1, "text", "Date Created", "");
60         compList[21] = new GuiComponent("model", tmplist2, "text", "Model", "Dell OptiPlex GX280");
61         compList[22] = new GuiComponent("peer_id", tmplist1, "num", "Peer Id", "");
62         compList[23] = new GuiComponent("ports", tmplist2, "text", "Ports", "");
63         compList[24] = new GuiComponent("description", tmplist4, "text", "Description", "New node for testing purposes");
64         compList[25] = new GuiComponent("rights", tmplist4, "text", "Rights", "");
65         compList[26] = new GuiComponent("pubkey", tmplist3, "text", "GENI Public key", "");
66         compList[27] = new GuiComponent("pubkey_write", tmplist4, "key", "GENI Public key", "");
67         compList[28] = new GuiComponent("wrapperurl", tmplist4, "text", "Wrapper URL", "local");
68         compList[29] = new GuiComponent("disabled", tmplist3, "bool", "Disabled", "Yes, No");
69         compList[30] = new GuiComponent("userlist", tmplist4, "text", "User List", "");            
70         compList[31] = new GuiComponent("pointer", tmplist3, "num", "PL Pointer", "");
71         compList[32] = new GuiComponent("g_uuid", tmplist3, "text", "GENI UUID", "");
72     
73     }
74     
75     private void createCompListUser(){        
76         compList_user = new GuiComponent[28];
77         GuiComponent[] compList = compList_user;
78         String[] tmplist1 = {"readable","pl"};
79         String[] tmplist2 = {"writable","pl"};
80         String[] tmplist3 = {"readable","geni"};
81         String[] tmplist4 = {"writable","geni"};
82         compList[0] = new GuiComponent("person_id", tmplist1, "num", "Person Id", "");        
83         compList[1] = new GuiComponent("bio", tmplist2, "text", "Bio", "");
84         compList[2] = new GuiComponent("first_name", tmplist2, "text", "First Name", "");
85         compList[3] = new GuiComponent("last_name", tmplist2, "text", "Last Name", "");
86         compList[4] = new GuiComponent("last_updated", tmplist1, "text", "Last Updated", "");
87         compList[5] = new GuiComponent("key_ids", tmplist2, "num", "Key Ids", "");
88         compList[6] = new GuiComponent("phone", tmplist2, "text", "Phone", "");
89         compList[7] = new GuiComponent("peer_person_id", tmplist2, "num", "Peer Person Id", "");
90         compList[8] = new GuiComponent("role_ids", tmplist2, "num", "Role Ids", "");
91         compList[9] = new GuiComponent("site_ids", tmplist1, "num", "Site Ids", "");        
92         compList[10] = new GuiComponent("uuid", tmplist1, "text", "UUID", "");
93         compList[11] = new GuiComponent("roles", tmplist2, "num", "Roles", "");
94         compList[12] = new GuiComponent("title", tmplist2, "text", "Title", "");
95         compList[13] = new GuiComponent("url", tmplist2, "text", "Url", "someuser.dom.edu");
96         compList[14] = new GuiComponent("enabled", tmplist2, "bool", "Enabled", "Yes, No");
97         compList[15] = new GuiComponent("slice_ids", tmplist2, "num", "Slice Ids", "");
98         compList[16] = new GuiComponent("date_created", tmplist1, "text", "Date Created", "");
99         compList[17] = new GuiComponent("peer_id", tmplist2, "num", "Peer Id", "");
100         compList[18] = new GuiComponent("email", tmplist2, "text", "Email", "someuser@domain.edu");
101         compList[19] = new GuiComponent("description", tmplist4, "text", "Description", "test user");
102         compList[20] = new GuiComponent("rights", tmplist2, "text", "Rights", "");
103         compList[21] = new GuiComponent("pubkey", tmplist3, "text", "GENI Public key", "");
104         compList[22] = new GuiComponent("pubkey_write", tmplist4, "key", "GENI Public key", "");
105         compList[23] = new GuiComponent("wrapperurl", tmplist4, "text", "Wrapper URL", "local");
106         compList[24] = new GuiComponent("disabled", tmplist3, "bool", "Disabled", "Yes, No");
107         compList[25] = new GuiComponent("userlist", tmplist4, "text", "User List", "");            
108         compList[26] = new GuiComponent("pointer", tmplist3, "text", "PL Pointer", "");
109         compList[27] = new GuiComponent("g_uuid", tmplist3, "text", "GENI UUID", "");
110         
111     }
112     
113     private void createCompListSlice(){
114         compList_slice = new GuiComponent[24];
115         GuiComponent[] compList = compList_slice;
116         String[] tmplist1 = {"readable","pl"};
117         String[] tmplist2 = {"writable","pl"};
118         String[] tmplist3 = {"readable","geni"};
119         String[] tmplist4 = {"writable","geni"};
120         compList[0] = new GuiComponent("slice_id", tmplist1, "num", "Slice Id", "");        
121         compList[1] = new GuiComponent("description", tmplist2, "text", "Description", ""); 
122         compList[2] = new GuiComponent("node_ids", tmplist1, "num", "Node Ids", "");
123         compList[3] = new GuiComponent("expires", tmplist2, "text", "Expires", "");
124         compList[4] = new GuiComponent("site_id", tmplist1, "num", "Site Id", "");
125         compList[5] = new GuiComponent("uuid", tmplist1, "text", "UUID", "");
126         compList[6] = new GuiComponent("creator_person_id", tmplist2, "text", "Creator Person Id", "");
127         compList[7] = new GuiComponent("instantiation", tmplist2, "combo", "Instantiation", "delegated, not-instantiated, plc-instantiated");
128         compList[8] = new GuiComponent("name", tmplist2, "text", "Name", "");
129         compList[9] = new GuiComponent("created", tmplist1, "text", "Created", "");
130         compList[10] = new GuiComponent("url", tmplist2, "text", "Url", "");
131         compList[11] = new GuiComponent("max_nodes", tmplist2, "num", "Max Nodes", "10");
132         compList[12] = new GuiComponent("person_ids", tmplist2, "num", "Person Ids", "");
133         compList[13] = new GuiComponent("slice_attribute_ids", tmplist2, "text", "Slice Attribute Ids", "");
134         compList[14] = new GuiComponent("peer_id", tmplist1, "num", "Peer Id", "");
135         compList[15] = new GuiComponent("description", tmplist4, "text", "Description", "test slice");
136         compList[16] = new GuiComponent("rights", tmplist2, "text", "Rights", "");
137         compList[17] = new GuiComponent("pubkey", tmplist3, "text", "GENI Public key", "");
138         compList[18] = new GuiComponent("pubkey_write", tmplist4, "key", "GENI Public key", "");
139         compList[19] = new GuiComponent("wrapperurl", tmplist4, "text", "Wrapper URL", "local");
140         compList[20] = new GuiComponent("disabled", tmplist3, "bool", "Disabled", "Yes, No");
141         compList[21] = new GuiComponent("userlist", tmplist4, "text", "User List", "");            
142         compList[22] = new GuiComponent("pointer", tmplist3, "num", "PL Pointer", "");
143         compList[23] = new GuiComponent("g_uuid", tmplist3, "text", "GENI UUID", "");               
144         
145     }
146     
147     private void createCompListSite(){
148         compList_site = new GuiComponent[31];
149         GuiComponent[] compList = compList_site;
150         String[] tmplist1 = {"readable","pl"};
151         String[] tmplist2 = {"writable","pl"};
152         String[] tmplist3 = {"readable","geni"};
153         String[] tmplist4 = {"writable","geni"};
154         
155         compList[0] = new GuiComponent("last_updated", tmplist1, "text", "Last Updated", "");
156         compList[1] = new GuiComponent("node_ids", tmplist2, "num", "Node Ids", "");
157         compList[2] = new GuiComponent("site_id", tmplist1, "num", "Site Id", "");
158         compList[3] = new GuiComponent("pcu_ids", tmplist2, "num", "PCU Ids", "");
159         compList[4] = new GuiComponent("max_slices", tmplist2, "num", "Max Slices", "");
160         compList[5] = new GuiComponent("ext_consortium_id", tmplist2, "text", "Ext Consortium Id", "");
161         compList[6] = new GuiComponent("max_slivers", tmplist2, "num", "Max Slivers", "5");
162         compList[7] = new GuiComponent("is_public", tmplist2, "bool", "Public", "Yes, No");
163         compList[8] = new GuiComponent("peer_site_id", tmplist1, "num", "Peer Site Id", "");
164         compList[9] = new GuiComponent("abbreviated_name", tmplist2, "text", "Abbreviated Name", "");
165         compList[10] = new GuiComponent("name", tmplist2, "text", "Name", "");
166         compList[11] = new GuiComponent("address_ids", tmplist2, "num", "Address Ids", "");
167         compList[12] = new GuiComponent("uuid", tmplist1, "text", "UUID", "");
168         compList[13] = new GuiComponent("url", tmplist2, "text", "Url", "");
169         compList[14] = new GuiComponent("person_ids", tmplist2, "num", "Person Ids", "");
170         compList[15] = new GuiComponent("enabled", tmplist2, "bool", "Enabled", "Yes, No");
171         compList[16] = new GuiComponent("longitude", tmplist2, "num", "Longitude", "34.3");
172         compList[17] = new GuiComponent("latitude", tmplist2, "num", "Latitude", "45.4");
173         compList[18] = new GuiComponent("slice_ids", tmplist2, "num", "Slice Ids", "");
174         compList[19] = new GuiComponent("login_base", tmplist2, "text", "Login Base", "");
175         compList[20] = new GuiComponent("date_created", tmplist1, "text", "Date Created", "");
176         compList[21] = new GuiComponent("peer_id", tmplist1, "num", "Peer Id", "");
177         compList[22] = new GuiComponent("description", tmplist4, "text", "Description", "test slice");
178         compList[23] = new GuiComponent("rights", tmplist2, "text", "Rights", "");
179         compList[24] = new GuiComponent("pubkey", tmplist3, "text", "GENI Public key", "");
180         compList[25] = new GuiComponent("pubkey_write", tmplist4, "key", "GENI Public key", "");
181         compList[26] = new GuiComponent("wrapperurl", tmplist4, "text", "Wrapper URL", "local");
182         compList[27] = new GuiComponent("disabled", tmplist3, "bool", "Disabled", "Yes, No");
183         compList[28] = new GuiComponent("userlist", tmplist4, "text", "User List", "");            
184         compList[29] = new GuiComponent("pointer", tmplist3, "num", "PL Pointer", "");
185         compList[30] = new GuiComponent("g_uuid", tmplist3, "text", "GENI UUID", "");                     
186     }
187     
188     //input is in format: {"'field1_name':value1", "'field2_name':value2", ...}
189     public void FillComponentList(String recordType, String[] dict){
190         GuiComponent[] complist = null;
191         if (recordType.equals("user")){
192             complist = compList_user;
193         }
194         else if (recordType.equals("slice")){
195             complist = compList_slice;
196         }
197         else if (recordType.equals("node")){
198             complist = compList_node;
199         }
200         else if (recordType.equals("SA/MA")){
201             complist = compList_site;
202         }
203         
204         for (int i=0; i<dict.length; i++){
205             String[] line = dict[i].split("':");
206             String comp_name = line[0].split("'")[1];
207             String comp_value = "";
208             if (line.length > 1)
209                 comp_value = line[1];
210             if (comp_value.equals("None"))
211                     comp_value = "";
212             int j;
213             for(j = 0; j<complist.length; j++){
214                 if (complist[j].getName().equals(comp_name)){
215                     break;
216                 }
217             }
218             if (j == complist.length)
219                 continue;
220             else{
221                 String type = complist[j].getType();
222                 if (type.equals("text") || type.equals("num"))
223                     complist[j].setValue(comp_value);
224                 else if (type.equals("bool"))
225                     if (comp_value.equals("True"))
226                         complist[j].setValue("Yes, No");
227                     else
228                         complist[j].setValue("No, Yes");
229                 else if (type.equals("combo")){
230                     String[] curVal = complist[j].getValue().split(", ");
231                     String nextVal = comp_value;
232                     for(int k=0; k<curVal.length; k++)
233                         if (curVal[k] != comp_value)
234                             nextVal += (", "+curVal[k]);
235                     complist[j].setValue(nextVal);
236                 }
237                 else if (type.equals("key")){
238                     complist[j].setValue(comp_value);                
239                 }
240             }
241         }    
242     }
243     
244     private void keyChooserActionPerformed(JTextField t, java.awt.event.ActionEvent evt) {                                              
245 // TODO add your handling code here:
246         
247         javax.swing.JFileChooser fc =  (javax.swing.JFileChooser)evt.getSource();
248         java.io.File f = fc.getSelectedFile();
249         
250         if(keySelectFrame!=null)
251                 keySelectFrame.dispose();
252         
253         if (f != null){
254             String fname = f.getAbsolutePath();            
255
256             try{
257                 //extract the pubkey from the specified file into temp file
258                 outCommand.write("./certutil.py "+fname+" > tmp_key_file.txt\n");            
259                 outCommand.flush();
260
261                 //get key from temp file 
262                 String result = "";
263                 File file = new File("tmp_key_file.txt");
264                 int i = 0;
265                 while(!file.exists() && i<5){
266                     i++;
267                     try {
268                         Thread.currentThread().sleep(200);
269                     } catch (InterruptedException ex) {
270                         ex.printStackTrace();
271                     }
272                 }
273                 try {
274                     Thread.currentThread().sleep(100);
275                 } catch (InterruptedException ex) {
276                     ex.printStackTrace();
277                 }        
278                 if (file.exists()){                
279                     BufferedReader in = new BufferedReader(new FileReader("tmp_key_file.txt")); 
280                     String tmp = in.readLine();
281                     while(tmp!=null && tmp.length() > 0){
282                         result += tmp+"\n";
283                         tmp = in.readLine();
284                     }                
285                     in.close();
286
287                     outCommand.write("rm tmp_key_file.txt\n");            
288                     outCommand.flush();                               
289                 }
290                 //write the result in the textfield
291                 t.setText(result);
292               }catch (Exception ex) {
293                         ex.printStackTrace();
294                 } 
295         }
296             
297     }        
298     
299     public void displayComponentList(String recordType, JPanel panel1, JPanel panel2){
300         
301         GuiComponent[] complist = null;
302         if (recordType.equals("user")){
303             complist = compList_user;
304         }
305         else if (recordType.equals("slice")){
306             complist = compList_slice;
307         }
308         else if (recordType.equals("node")){
309             complist = compList_node;
310         }
311         else if (recordType.equals("SA/MA")){
312             complist = compList_site;
313         }        
314             
315         panel1.removeAll();
316         panel1.setLayout(new SpringLayout());      
317
318         int count1 = 0;
319         for (int i=0;i<complist.length;i++){
320             if (complist[i].getProperty()[0].equals("readable") && complist[i].getProperty()[1].equals("geni")){
321                 String type = complist[i].getType();
322                 if (type.equals("text") || type.equals("num")){
323                     JLabel l = new JLabel(complist[i].getLabel(), JLabel.TRAILING);
324                     l.setName(complist[i].getName());
325                     panel1.add(l);
326                     JTextField t = new JTextField();
327                     t.setText(complist[i].getValue());
328                     t.setEditable(false);
329                     l.setLabelFor(t);
330                     panel1.add(t);
331                     count1++;
332                 }
333             }
334         }
335         int count2 = 0;
336         for (int i=0;i<complist.length;i++){
337             if (complist[i].getProperty()[0].equals("readable") && complist[i].getProperty()[1].equals("pl")){
338                 String type = complist[i].getType();
339                 if (type.equals("text") || type.equals("num")){
340                     JLabel l = new JLabel(complist[i].getLabel(), JLabel.TRAILING);
341                     l.setName(complist[i].getName());
342                     panel1.add(l);
343                     JTextField t = new JTextField();
344                     t.setText(complist[i].getValue());
345                     t.setEditable(false);
346                     l.setLabelFor(t);
347                     panel1.add(t);
348                     count2++;
349                 }
350             }
351         }
352         int parts = 2*(count1+count2);
353         while(parts != (parts/6)*6){
354             JLabel l = new JLabel("", JLabel.TRAILING);
355             panel1.add(l);
356             parts++;
357         }
358          //Lay out the panel.
359         SpringUtilities.makeCompactGrid(panel1,
360                                         parts/6, 6, //rows, cols
361                                         6, 6,        //initX, initY
362                                         6, 6);       //xPad, yPad
363         panel1.revalidate();
364         panel1.repaint();
365
366     
367         //fill the second(writable) panel
368         panel2.removeAll();
369         panel2.setLayout(new SpringLayout());      
370
371         count1 = 0;
372         for (int i=0;i<complist.length;i++){
373             if (complist[i].getProperty()[0].equals("writable") && complist[i].getProperty()[1].equals("geni")){
374                 JLabel l = new JLabel(complist[i].getLabel(), JLabel.TRAILING);
375                 final String name = complist[i].getName();
376                 l.setName(name);
377                 panel2.add(l);
378                 String type = complist[i].getType();
379                 if (type.equals("text") || type.equals("num")){                    
380                     JTextField t = new JTextField();
381                     t.setText(complist[i].getValue());                   
382                     l.setLabelFor(t);
383                     panel2.add(t);
384                     count1++;
385                 }
386                 else if (type.equals("combo") || type.equals("bool")){
387                     JComboBox cb = new JComboBox(complist[i].getValue().split(", "));
388                     l.setLabelFor(cb);
389                     panel2.add(cb);
390                     count1++;
391                 }
392                 else if (type.equals("key")){ 
393                     final JTextField t = new JTextField();
394                     t.setText(complist[i].getValue());    
395                     t.setEditable(false);
396                     l.setLabelFor(t);
397                     panel2.add(t);                    
398                     
399                     t.addMouseListener(new java.awt.event.MouseAdapter() {
400                         public void mousePressed(java.awt.event.MouseEvent evt) {
401                             //Create and set up the window.
402                             if(keySelectFrame!=null)
403                                   keySelectFrame.dispose();
404                             keySelectFrame = new JFrame("Key Select");
405                             keySelectFrame.setSize(600,400);
406                             keySelectFrame.setLocation(200,100);
407
408                             //Set up the content pane.
409                             Container contentPane = keySelectFrame.getContentPane();
410                             SpringLayout layout = new SpringLayout();
411                             contentPane.setLayout(layout);        
412
413                             JFileChooser fc = new JFileChooser();
414                             fc.addActionListener(new java.awt.event.ActionListener() {
415                                 public void actionPerformed(java.awt.event.ActionEvent evt) {
416                                     keyChooserActionPerformed(t, evt);
417                                 }
418                             });
419
420                             contentPane.add(fc);
421
422                             //Display the window.
423                             keySelectFrame.pack();
424                             keySelectFrame.setVisible(true); 
425                         }
426                     });
427                     count1++;
428                 } 
429             }
430         }
431         count2 = 0;
432         for (int i=0;i<complist.length;i++){
433             if (complist[i].getProperty()[0].equals("writable") && complist[i].getProperty()[1].equals("pl")){
434                 JLabel l = new JLabel(complist[i].getLabel(), JLabel.TRAILING);
435                 l.setName(complist[i].getName());
436                 panel2.add(l);
437                 String type = complist[i].getType();
438                 if (type.equals("text") || type.equals("num")){                    
439                     JTextField t = new JTextField();
440                     t.setText(complist[i].getValue());
441                     l.setLabelFor(t);
442                     panel2.add(t);
443                     count2++;
444                 }
445                 else if (type.equals("combo") || type.equals("bool")){
446                     JComboBox cb = new JComboBox(complist[i].getValue().split(", "));
447                     l.setLabelFor(cb);
448                     panel2.add(cb);
449                     count1++;
450                 }
451                 else if (type.equals("key")){                    
452                     JTextField t = new JTextField();
453                     t.setText(complist[i].getValue());                   
454                     l.setLabelFor(t);
455                     panel2.add(t);
456                     count1++;
457                 } 
458             }
459         }
460         parts = 2*(count1+count2);
461         while(parts != (parts/6)*6){
462             JLabel l = new JLabel("", JLabel.TRAILING);
463             panel2.add(l);
464             parts++;
465         }
466          //Lay out the panel.
467         SpringUtilities.makeCompactGrid(panel2,
468                                         parts/6, 6, //rows, cols
469                                         6, 6,        //initX, initY
470                                         6, 6);       //xPad, yPad
471
472         panel2.revalidate();
473         panel2.repaint();
474
475     }
476     
477     //construct a clientstub message out of the given panel
478     public String PanelToString(String type, JPanel panel){
479         GuiComponent[] targetCompList = null;
480         String g_params = "";
481         String p_params = "";
482         
483         if (type.equals("user"))
484             targetCompList = compList_user;
485         else if (type.equals("slice"))
486             targetCompList = compList_slice;
487         else if (type.equals("node"))
488             targetCompList = compList_node;
489         else if (type.equals("SA/MA"))
490             targetCompList = compList_site;
491         
492         //serialize the components on the component list
493         Component carr[] = panel.getComponents();
494         for(int i = 0; i<carr.length; i++){
495             Component nextcomp = carr[i];                     
496             String comp_name = nextcomp.getName();            
497             int j;
498             for(j = 0; j<targetCompList.length; j++){
499                 String cur_name = targetCompList[j].getName();
500                 if (cur_name.equals(comp_name)){
501                     break;
502                 }
503             }
504             if (j == targetCompList.length)
505                 continue;
506             else{
507                 String comp_type = targetCompList[j].getType();
508                 String comp_content = "";
509                 if (comp_type.equals("text") || comp_type.equals("num")){
510                     JTextField tf = (JTextField)carr[i+1];
511                     String tf_content = tf.getText();
512                     if (tf_content.length() == 0)
513                         continue;
514                     else if(comp_type.equals("text"))
515                         comp_content = "'"+tf_content+"'";
516                     else
517                         comp_content = tf_content;
518                 }
519                 else if (comp_type.equals("bool")){
520                     JComboBox cb = (JComboBox)carr[i+1];
521                     String cb_content = (String) cb.getSelectedItem();
522                     if (cb_content.equals("Yes"))
523                         comp_content = "True";
524                     else
525                         comp_content = "False";                
526                 }
527                 else if (comp_type.equals("combo")){
528                     JComboBox cb = (JComboBox)carr[i+1];
529                     String cb_content = (String) cb.getSelectedItem();
530                     comp_content = "'"+cb_content+"'";                
531                 }
532                 else if (comp_type.equals("key")){
533                     JTextField tf = (JTextField)carr[i+1];
534                     String tf_content = tf.getText();                    
535                     
536                     if (tf_content.length() == 0)
537                         continue;
538                     else
539                         comp_content = "'"+tf_content+"'";                                        
540                 }
541                 //add to dictionary string
542                 if (comp_name.equals("key_write"))
543                     comp_name = "key";
544                 else if (comp_name.equals("pubkey_write"))
545                     comp_name = "pubkey";
546                 if (targetCompList[j].getProperty()[1].equals("geni")){
547                     if (g_params.length() == 0)
548                         g_params += ("'"+comp_name+"':"+comp_content);
549                     else
550                         g_params += (", '"+comp_name+"':"+comp_content);
551                 }
552                 else{
553                     if (p_params.length() == 0)
554                         p_params += ("'"+comp_name+"':"+comp_content);
555                     else
556                         p_params += (", '"+comp_name+"':"+comp_content);                
557                 }                    
558             }
559         }        
560         return "'g_params':{"+g_params+"}, 'p_params':{"+p_params+"}";
561     }
562     
563     private BufferedWriter outCommand = null;
564     private JFrame keySelectFrame = null;
565     private GuiComponent[] compList_slice;
566     private GuiComponent[] compList_user;
567     private GuiComponent[] compList_node;
568     private GuiComponent[] compList_site;
569     
570 }