KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nqadmin > swingSet > datasources > SSConnectionEditor


1 package com.nqadmin.swingSet.datasources;
2
3 import java.beans.PropertyEditorSupport JavaDoc;
4 import java.beans.beancontext.BeanContext JavaDoc;
5 import java.beans.beancontext.BeanContextProxy JavaDoc;
6 import java.beans.beancontext.BeanContextChild JavaDoc;
7 import java.beans.beancontext.BeanContextChildSupport JavaDoc;
8 import java.util.Vector JavaDoc;
9 import java.util.Iterator JavaDoc;
10
11 public class SSConnectionEditor extends PropertyEditorSupport JavaDoc implements BeanContextProxy JavaDoc {
12     
13     private BeanContextChildSupport JavaDoc beanContextChildSupport = new BeanContextChildSupport JavaDoc();
14     Vector JavaDoc vecSSConn = new Vector JavaDoc();
15     
16     public BeanContextChild JavaDoc getBeanContextProxy(){
17         System.out.println("getBeanContextProxy Called");
18         return beanContextChildSupport;
19     }
20     
21     public String JavaDoc getAsText(){
22         Object JavaDoc curValue = getValue();
23         if(curValue == null)
24             return "<none>";
25         return curValue.toString();
26     }
27
28     public void setAsText(String JavaDoc value){
29         if(value.trim().equals("<none>"))
30             setValue(null);
31         else{
32             for(int i=0; i<vecSSConn.size(); i++){
33                 if(vecSSConn.elementAt(i).toString().equals(value)){
34                     setValue(vecSSConn.elementAt(i));
35                     break;
36                 }
37             }
38         }
39     }
40     
41     public String JavaDoc[] getTags(){
42         vecSSConn.removeAllElements();
43         BeanContext JavaDoc beanContext = beanContextChildSupport.getBeanContext();
44         if(beanContext == null){
45             return new String JavaDoc[]{"Bean Context Null"};
46         }
47         Iterator JavaDoc iterator = beanContext.iterator();
48         while(iterator.hasNext()){
49             Object JavaDoc sibling = iterator.next();
50             if(sibling instanceof SSConnection){
51                 vecSSConn.add(sibling);
52             }
53         }
54         String JavaDoc[] names = new String JavaDoc[vecSSConn.size() + 1];
55         if(vecSSConn.size() > 0){
56             
57             for(int i=0; i<vecSSConn.size(); i++){
58                 names[i] = vecSSConn.elementAt(i).toString();
59             }
60             return names;
61         }
62         names[vecSSConn.size()] = String.valueOf(vecSSConn.size());
63         return names;
64
65     }
66 }
Popular Tags