1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.common; 26 27 import java.util.Collection ; 28 import java.util.List ; 29 import java.util.ResourceBundle ; 30 31 import javax.swing.JLabel ; 32 import javax.swing.JPanel ; 33 34 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 35 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion; 36 37 42 43 public class GenericTablePanel extends BeanTablePanel { 44 45 private ResourceBundle resourceBundle; 47 private String resourceBase; 48 49 private String dialogTitle; 51 52 private String panelHeading; 54 55 private JLabel jLblTableHeading; 57 58 private List entryList; 65 66 private Class entryPanelClass; 70 71 private Object extraData; 76 77 private String entryPanelHelpId; 80 81 95 public GenericTablePanel(GenericTableModel model, ResourceBundle bundle, String resourceBase, String helpId) { 96 this(model, bundle, resourceBase, GenericTableDialogPanel.class, helpId); 97 } 98 99 100 public GenericTablePanel(GenericTableModel model, ResourceBundle bundle, String resourceBase, 101 Class entryPanelClass, String helpId) { 102 this(model, bundle, resourceBase, entryPanelClass, helpId, null); 103 } 104 105 106 public GenericTablePanel(GenericTableModel model, ResourceBundle bundle, String resourceBase, 107 Class entryPanelClass, String helpId, Object extraData) { 108 super(model); 109 110 this.resourceBundle = bundle; 111 this.resourceBase = resourceBase; 112 this.dialogTitle = bundle.getString("TITLE_" + resourceBase); this.panelHeading = bundle.getString("HEADING_" + resourceBase); this.entryPanelClass = entryPanelClass; 115 this.extraData = extraData; 116 this.entryPanelHelpId = helpId; 117 118 table.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_TABLE_" + resourceBase)); table.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TABLE_" + resourceBase)); getAccessibleContext().setAccessibleName(bundle.getString("ACSN_TABLE_" + resourceBase)); getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TABLE_" + resourceBase)); 123 initUserComponents(); 124 } 125 126 protected void initUserComponents() { 127 jLblTableHeading = new JLabel (panelHeading); 128 jLblTableHeading.setLabelFor(table); 129 add(jLblTableHeading, java.awt.BorderLayout.NORTH); 130 } 131 132 public void setHeadingMnemonic(char mnemonic) { 133 jLblTableHeading.setDisplayedMnemonic(mnemonic); 134 } 135 136 public void setModel(CommonDDBean parent, ASDDVersion asVersion) { 137 getTableModel().setData(parent, asVersion); 138 139 153 } 154 155 public void setModel(List rows, ASDDVersion asVersion) { 156 getTableModel().setData(rows, asVersion); 157 } 158 159 public void setModel(CommonDDBean [] rows, ASDDVersion asVersion) { 160 getTableModel().setData(rows, asVersion); 161 } 162 163 164 public void setModelBaseBean(CommonDDBean parent, ASDDVersion asVersion) { 165 getTableModel().setDataBaseBean(parent, asVersion); 166 } 167 168 public BeanInputDialog getInputDialog(Object [] values) { 169 entryList = getTableModel().getPropertyDefinitions(); 171 return new GenericTableDialog(this, dialogTitle, values); 172 } 173 174 public BeanInputDialog getInputDialog() { 175 entryList = getTableModel().getPropertyDefinitions(); 177 return new GenericTableDialog(this, dialogTitle); 178 } 179 180 private GenericTableModel getTableModel() { 181 return (GenericTableModel) model; 182 } 183 184 private String getHelpId() { 185 return entryPanelHelpId; 186 } 187 188 194 public class GenericTableDialog extends BeanInputDialog { 195 private GenericTablePanel parentPanel; 196 private GenericTableDialogPanelAccessor entryPanel; 197 198 public GenericTableDialog(GenericTablePanel parent, String title){ 199 super(parent, title, true); 200 parentPanel = parent; 201 initAccessibility(); 202 } 203 204 public GenericTableDialog(GenericTablePanel parent, String title, Object [] values) { 205 super(parent, title, true, values); 206 parentPanel = parent; 207 initAccessibility(); 208 } 209 210 protected void initAccessibility() { 211 getAccessibleContext().setAccessibleName( 212 resourceBundle.getString("ACSN_POPUP_" + resourceBase)); getAccessibleContext().setAccessibleDescription( 214 resourceBundle.getString("ACSD_POPUP_" + resourceBase)); } 216 217 protected JPanel getDialogPanel(Object [] values) { 218 entryPanel = internalGetDialogPanel(); 223 entryPanel.setValues(values); 224 return (JPanel ) entryPanel; 225 } 226 227 protected JPanel getDialogPanel() { 228 entryPanel = internalGetDialogPanel(); 233 entryPanel.setValues(null); 234 return (JPanel ) entryPanel; 235 } 236 237 private GenericTableDialogPanelAccessor internalGetDialogPanel() { 238 GenericTableDialogPanelAccessor subPanel = null; 239 240 try { 241 subPanel = (GenericTableDialogPanelAccessor) entryPanelClass.newInstance(); 242 subPanel.init(getTableModel().getAppServerVersion(), 243 GenericTablePanel.this.getWidth()*3/4, entryList, extraData); 244 245 ((JPanel ) subPanel).getAccessibleContext().setAccessibleName( 246 resourceBundle.getString("ACSN_POPUP_" + resourceBase)); ((JPanel ) subPanel).getAccessibleContext().setAccessibleDescription( 248 resourceBundle.getString("ACSD_POPUP_" + resourceBase)); } catch(InstantiationException ex) { 250 } catch(IllegalAccessException ex) { 253 } 256 257 return subPanel; 258 } 259 260 protected Object [] getValues() { 261 return entryPanel.getValues(); 262 } 263 264 protected Collection getErrors() { 265 return entryPanel.getErrors(validationSupport); 266 } 267 268 protected String getHelpId() { 269 return GenericTablePanel.this.getHelpId(); 270 } 271 } 272 } 273 | Popular Tags |