1 19 20 package org.netbeans.modules.websvc.registry.ui; 21 22 26 27 import javax.swing.DefaultCellEditor ; 28 import javax.swing.table.TableCellEditor ; 29 import javax.swing.tree.DefaultMutableTreeNode ; 30 import javax.swing.JTextField ; 31 32 import org.netbeans.swing.outline.NodeRowModel; 33 import org.netbeans.swing.outline.OutlineModel; 34 35 import org.openide.DialogDescriptor; 36 import org.openide.NotifyDescriptor; 37 import org.openide.DialogDisplayer; 38 39 import java.awt.Dialog ; 40 import java.util.EventObject ; 41 42 import com.sun.xml.rpc.processor.model.java.JavaType; 43 import com.sun.xml.rpc.processor.model.java.JavaSimpleType; 44 import com.sun.xml.rpc.processor.model.java.JavaEnumerationType; 45 46 47 51 public class ResultCellEditor extends DefaultCellEditor implements TableCellEditor { 52 53 private Dialog dialog; 54 private DialogDescriptor dlg; 55 private ResultViewerDialog viewerDialog; 56 private Object saveValue; 57 58 59 public ResultCellEditor() { 60 super(new JTextField ()); 61 this.setClickCountToStart(1); 62 } 63 66 public Object getCellEditorValue() { 67 return saveValue; 68 } 69 70 public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value, boolean isSelected, int row, int column) { 71 saveValue = value; 72 NodeRowModel rowModel = ((OutlineModel)table.getModel()).getRowNodeModel(); 73 DefaultMutableTreeNode node = (DefaultMutableTreeNode )rowModel.getNodeForRow(row); 74 77 viewerDialog = new ResultViewerDialog(); 78 if(null == node.getUserObject()) { 79 viewerDialog.setText((String )value); 80 81 } else { 82 ResultNodeData data = (ResultNodeData)node.getUserObject(); 83 JavaType type = data.getResultType(); 84 85 if(type instanceof JavaSimpleType) { 86 87 viewerDialog.setText(value != null ? value.toString() : ""); 88 } else if(type instanceof JavaEnumerationType) { 89 viewerDialog.setText(value != null ? value.toString() : ""); 90 } else { 91 return null; 92 } 93 94 dlg = new DialogDescriptor(viewerDialog, data.getResultType().getRealName(), 95 true, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION, 96 DialogDescriptor.DEFAULT_ALIGN, viewerDialog.getHelpCtx(), null); 97 dlg.setOptions(new Object [] { viewerDialog.getOkButton() }); 98 99 dialog = DialogDisplayer.getDefault().createDialog(dlg); 100 dialog.setSize(300,300); 101 dialog.show(); 102 } 103 104 105 return null; 106 } 107 108 } 109 | Popular Tags |