1 19 20 package org.netbeans.modules.j2ee.ddloaders.web.multiview; 21 22 27 import org.netbeans.modules.j2ee.dd.api.common.MessageDestinationRef; 28 import org.netbeans.modules.j2ee.dd.api.web.WebApp; 29 import org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException; 30 import org.netbeans.modules.j2ee.dd.api.common.CommonDDBean; 31 import org.openide.util.NbBundle; 32 33 public class MessageDestRefTableModel extends DDBeanTableModel 34 { 35 private static final String [] columnNames = { 36 NbBundle.getMessage(MessageDestRefTableModel.class,"TTL_MessageDestRefName"), 37 NbBundle.getMessage(MessageDestRefTableModel.class,"TTL_MessageDestRefType"), 38 NbBundle.getMessage(MessageDestRefTableModel.class,"TTL_MessageDestRefUsage"), 39 NbBundle.getMessage(MessageDestRefTableModel.class,"TTL_MessageDestRefLink"), 40 NbBundle.getMessage(MessageDestRefTableModel.class,"TTL_Description") 41 }; 42 43 protected String [] getColumnNames() { 44 return columnNames; 45 } 46 47 public void setValueAt(Object value, int row, int column) 48 { 49 MessageDestinationRef param = getMessageDestRef(row); 50 51 if (column == 0) param.setMessageDestinationRefName((String )value); 52 else if (column == 1) param.setMessageDestinationType((String )value); 53 else if (column == 2) param.setMessageDestinationUsage((String )value); 54 else if (column == 3) param.setMessageDestinationLink((String )value); 55 else param.setDescription((String )value); 56 } 57 58 59 public Object getValueAt(int row, int column) 60 { 61 MessageDestinationRef param = getMessageDestRef(row); 62 63 if (column == 0) return param.getMessageDestinationRefName(); 64 else if (column == 1) return param.getMessageDestinationType(); 65 else if (column == 2) return param.getMessageDestinationUsage(); 66 else if (column == 3) return param.getMessageDestinationLink(); 67 else { 68 String desc = param.getDefaultDescription(); 69 return desc==null?null:desc.trim(); 70 } 71 } 72 73 public CommonDDBean addRow(Object [] values) 74 { 75 try { 76 WebApp webApp = (WebApp)getParent(); 77 MessageDestinationRef param=(MessageDestinationRef)webApp.createBean("MessageDestinationRef"); param.setMessageDestinationRefName((String )values[0]); 79 param.setMessageDestinationType((String )values[1]); 80 param.setMessageDestinationUsage((String )values[2]); 81 String link = (String )values[3]; 82 param.setMessageDestinationLink(link.length()>0?link:null); 83 String desc = (String )values[4]; 84 param.setDescription(desc.length()>0?desc:null); 85 webApp.addMessageDestinationRef(param); 86 getChildren().add(param); 87 fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1); 88 return param; 89 } catch (ClassNotFoundException ex) {} 90 catch (VersionNotSupportedException ex) {} 91 return null; 92 } 93 94 public void editRow(int row, Object [] values) 95 { 96 MessageDestinationRef param = getMessageDestRef(row); 97 param.setMessageDestinationRefName((String )values[0]); 98 param.setMessageDestinationType((String )values[1]); 99 param.setMessageDestinationUsage((String )values[2]); 100 String link = (String )values[3]; 101 param.setMessageDestinationLink(link.length()>0?link:null); 102 String desc = (String )values[4]; 103 param.setDescription(desc.length()>0?desc:null); 104 fireTableRowsUpdated(row,row); 105 } 106 107 public void removeRow(int row) 108 { 109 try { 110 WebApp webApp = (WebApp)getParent(); 111 webApp.removeMessageDestinationRef(getMessageDestRef(row)); 112 getChildren().remove(row); 113 fireTableRowsDeleted(row, row); 114 } catch (VersionNotSupportedException ex) {} 115 116 } 117 118 MessageDestinationRef getMessageDestRef(int row) { 119 return (MessageDestinationRef)getChildren().get(row); 120 } 121 } | Popular Tags |