1 19 20 package org.netbeans.modules.websvc.registry.ui; 21 22 import org.netbeans.swing.outline.RowModel; 23 import org.openide.ErrorManager; 24 25 26 import com.sun.xml.rpc.processor.model.java.JavaType; 27 import com.sun.xml.rpc.processor.model.java.JavaSimpleType; 28 import com.sun.xml.rpc.processor.model.java.JavaEnumerationType; 29 30 import org.openide.util.NbBundle; 31 import javax.swing.tree.DefaultMutableTreeNode ; 32 33 import java.net.URLClassLoader ; 34 35 39 public class TypeRowModel implements RowModel { 40 41 private URLClassLoader urlClassLoader; 42 private String packageName; 43 44 45 public TypeRowModel(URLClassLoader inClassLoader, String inPackageName) { 46 urlClassLoader = inClassLoader; 47 packageName = inPackageName; 48 49 } 50 51 public Class getColumnClass(int column) { 52 switch(column) { 53 case 0: return String .class; 55 case 1: return Object .class; 56 default: return String .class; 57 } 58 } 59 60 public int getColumnCount() { 61 return 2; 62 } 63 64 public String getColumnName(int column) { 65 switch(column) { 66 case 0: return NbBundle.getMessage(this.getClass(), "PARAM_NAME"); 68 case 1: return NbBundle.getMessage(this.getClass(), "PARAM_VALUE"); 69 default: return ""; 70 } 71 72 } 73 74 public Object getValueFor(Object inNode, int column) { 75 if(null == inNode) return null; 76 DefaultMutableTreeNode node = (DefaultMutableTreeNode )inNode; 77 if(null == node.getUserObject()) return null; 78 TypeNodeData data = (TypeNodeData)node.getUserObject(); 79 switch(column) { 80 case 0: return data.getParameterName(); 82 case 1: { 83 Object val = data.getParameterValue(); 84 if (val instanceof java.util.Calendar ) 85 return java.text.DateFormat.getDateTimeInstance().format(((java.util.Calendar )val).getTime()); 86 return val; 87 } 88 default: return ""; 89 } 90 91 } 92 93 public boolean isCellEditable(Object inNode, int column) { 94 if(null == inNode) return false; 95 DefaultMutableTreeNode node = (DefaultMutableTreeNode )inNode; 96 if(null == node.getUserObject()) return false; 97 98 TypeNodeData data = (TypeNodeData)node.getUserObject(); 99 switch(column) { 100 case 0: return false; 102 case 1: if(data.getParameterType() instanceof JavaSimpleType || 103 data.getParameterType() instanceof JavaEnumerationType) return true; 104 else return false; 105 default: return false; 106 } 107 108 } 109 110 public void setValueFor(Object inNode, int column, Object value) { 111 if(null == inNode) return; 112 DefaultMutableTreeNode node = (DefaultMutableTreeNode )inNode; 113 if(null == node.getUserObject()) return; 114 115 TypeNodeData data = (TypeNodeData)node.getUserObject(); 116 119 if(column != 1) { 120 return; 121 } 122 JavaType type = data.getParameterType(); 123 Object newValue = null; 124 if(type instanceof JavaEnumerationType) { 125 try { 126 newValue = ReflectionHelper.makeEnumerationType((JavaEnumerationType)type,urlClassLoader,packageName,value); 127 } catch(WebServiceReflectionException wsfe) { 128 Throwable cause = wsfe.getCause(); 129 ErrorManager.getDefault().notify(cause); 130 ErrorManager.getDefault().log(this.getClass().getName() + 131 ": Error trying to create an Enumeration Type: " + 132 type.getFormalName() + "ClassNWebServiceReflectionExceptionotFoundException=" + cause); 133 return; 134 } 135 136 137 } else { 138 newValue = value; 139 140 } 141 142 data.setParameterValue(newValue); 143 147 148 DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode ) node.getParent(); 149 if(null != parentNode && parentNode instanceof ArrayTypeTreeNode) { 150 ((ArrayTypeTreeNode)parentNode).updateValueOfChildren(); 151 } else if(null != parentNode && parentNode instanceof StructureTypeTreeNode) { 152 155 ((StructureTypeTreeNode)parentNode).updateValueOfChild(data); 156 } 157 158 159 160 161 } 162 163 } 164 | Popular Tags |