1 package com.nqadmin.swingSet.datasources; 2 3 import java.beans.PropertyEditorSupport ; 4 import java.beans.beancontext.BeanContext ; 5 import java.beans.beancontext.BeanContextProxy ; 6 import java.beans.beancontext.BeanContextChild ; 7 import java.beans.beancontext.BeanContextChildSupport ; 8 import java.util.Vector ; 9 import java.util.Iterator ; 10 11 public class SSConnectionEditor extends PropertyEditorSupport implements BeanContextProxy { 12 13 private BeanContextChildSupport beanContextChildSupport = new BeanContextChildSupport (); 14 Vector vecSSConn = new Vector (); 15 16 public BeanContextChild getBeanContextProxy(){ 17 System.out.println("getBeanContextProxy Called"); 18 return beanContextChildSupport; 19 } 20 21 public String getAsText(){ 22 Object curValue = getValue(); 23 if(curValue == null) 24 return "<none>"; 25 return curValue.toString(); 26 } 27 28 public void setAsText(String 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 [] getTags(){ 42 vecSSConn.removeAllElements(); 43 BeanContext beanContext = beanContextChildSupport.getBeanContext(); 44 if(beanContext == null){ 45 return new String []{"Bean Context Null"}; 46 } 47 Iterator iterator = beanContext.iterator(); 48 while(iterator.hasNext()){ 49 Object sibling = iterator.next(); 50 if(sibling instanceof SSConnection){ 51 vecSSConn.add(sibling); 52 } 53 } 54 String [] names = new String [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 |