View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/RegistryEntryPanel.java,v 1.4 2003/08/24 22:14:58 farrukh_najmi Exp $ 3 */ 4 package com.sun.xml.registry.client.browser; 5 6 import java.awt.*; 7 import java.awt.event.*; 8 import java.util.*; 9 import javax.swing.*; 10 import javax.xml.registry.*; 11 import javax.xml.registry.infomodel.*; 12 13 /*** 14 * Panel used in a popup dialog that holds the information 15 * about an RegistryEntry such as its registry object and 16 * registry entry information 17 * 18 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 19 */ 20 public class RegistryEntryPanel extends RegistryObjectPanel { 21 22 JTextField expirationText = null; 23 JComboBox stabilityCombo = null; 24 JComboBox statusCombo = null; 25 26 JTextField majorVersionText = null; 27 JTextField minorVersionText = null; 28 JTextField userVersionText = null; 29 30 String[] stabilityTypes = { 31 "Dynamic", 32 "DynamicCompatible", 33 "Static" 34 }; 35 36 String[] statusTypes = { 37 "Submitted", 38 "Approved", 39 "Deprecated", 40 "Withdrawn" 41 }; 42 43 44 /*** 45 * Creates new RegistryEntryPanel 46 */ 47 public RegistryEntryPanel() { 48 super(); 49 50 setBorder(BorderFactory.createTitledBorder("RegistryEntry Details")); 51 52 JLabel statusLabel = new JLabel("Status:", SwingConstants.LEFT); 53 c.gridx = 0; 54 c.gridy = row+0; 55 c.gridwidth = 1; 56 c.gridheight = 1; 57 c.weightx = 0.0; 58 c.weighty = 0.0; 59 c.fill = GridBagConstraints.NONE; 60 c.anchor = GridBagConstraints.WEST; 61 c.insets = new Insets(4, 4, 0, 4); 62 gbl.setConstraints(statusLabel, c); 63 add(statusLabel); 64 65 statusCombo = new JComboBox(statusTypes); 66 statusCombo.setEnabled(false); 67 c.gridx = 0; 68 c.gridy = row+1; 69 c.gridwidth = 1; 70 c.gridheight = 1; 71 c.weightx = 0.5; 72 c.weighty = 0.0; 73 c.fill = GridBagConstraints.HORIZONTAL; 74 c.anchor = GridBagConstraints.WEST; 75 c.insets = new Insets(4, 4, 0, 4); 76 gbl.setConstraints(statusCombo, c); 77 add(statusCombo); 78 79 JLabel expirationLabel = new JLabel("expiration:", SwingConstants.LEFT); 80 c.gridx = 1; 81 c.gridy = row+0; 82 c.gridwidth = 1; 83 c.gridheight = 1; 84 c.weightx = 0.0; 85 c.weighty = 0.0; 86 c.fill = GridBagConstraints.NONE; 87 c.anchor = GridBagConstraints.WEST; 88 c.insets = new Insets(4, 4, 0, 4); 89 gbl.setConstraints(expirationLabel, c); 90 add(expirationLabel); 91 92 expirationText = new JTextField(); 93 expirationText.setEditable(editable); 94 c.gridx = 1; 95 c.gridy = row+1; 96 c.gridwidth = 1; 97 c.gridheight = 1; 98 c.weightx = 0.5; 99 c.weighty = 0.0; 100 c.fill = GridBagConstraints.HORIZONTAL; 101 c.anchor = GridBagConstraints.CENTER; 102 c.insets = new Insets(4, 4, 0, 4); 103 gbl.setConstraints(expirationText, c); 104 add(expirationText); 105 106 107 JLabel stabilityLabel = new JLabel("Stability:", SwingConstants.LEFT); 108 c.gridx = 0; 109 c.gridy = row+2; 110 c.gridwidth = 1; 111 c.gridheight = 1; 112 c.weightx = 0.0; 113 c.weighty = 0.0; 114 c.fill = GridBagConstraints.NONE; 115 c.anchor = GridBagConstraints.WEST; 116 c.insets = new Insets(4, 4, 0, 4); 117 gbl.setConstraints(stabilityLabel, c); 118 add(stabilityLabel); 119 120 stabilityCombo = new JComboBox(stabilityTypes); 121 stabilityCombo.setEditable(editable); 122 stabilityCombo.setEnabled(editable); 123 c.gridx = 0; 124 c.gridy = row+3; 125 c.gridwidth = 1; 126 c.gridheight = 1; 127 c.weightx = 0.5; 128 c.weighty = 0.0; 129 c.fill = GridBagConstraints.HORIZONTAL; 130 c.anchor = GridBagConstraints.WEST; 131 c.insets = new Insets(4, 4, 0, 4); 132 gbl.setConstraints(stabilityCombo, c); 133 add(stabilityCombo); 134 135 JLabel majorVersionLabel = new JLabel("Major Version:", SwingConstants.LEFT); 136 c.gridx = 0; 137 c.gridy = row+4; 138 c.gridwidth = 1; 139 c.gridheight = 1; 140 c.weightx = 0.0; 141 c.weighty = 0.0; 142 c.fill = GridBagConstraints.NONE; 143 c.anchor = GridBagConstraints.WEST; 144 c.insets = new Insets(4, 4, 0, 4); 145 gbl.setConstraints(majorVersionLabel, c); 146 //add(majorVersionLabel); 147 148 majorVersionText = new JTextField(); 149 majorVersionText.setEditable(editable); 150 c.gridx = 0; 151 c.gridy = row+5; 152 c.gridwidth = 1; 153 c.gridheight = 1; 154 c.weightx = 0.5; 155 c.weighty = 0.0; 156 c.fill = GridBagConstraints.HORIZONTAL; 157 c.anchor = GridBagConstraints.CENTER; 158 c.insets = new Insets(4, 4, 0, 4); 159 gbl.setConstraints(majorVersionText, c); 160 //add(majorVersionText); 161 162 JLabel minorVersionLabel = new JLabel("Minor Version:", SwingConstants.LEFT); 163 c.gridx = 1; 164 c.gridy = row+4; 165 c.gridwidth = 1; 166 c.gridheight = 1; 167 c.weightx = 0.0; 168 c.weighty = 0.0; 169 c.fill = GridBagConstraints.NONE; 170 c.anchor = GridBagConstraints.WEST; 171 c.insets = new Insets(4, 4, 0, 4); 172 gbl.setConstraints(minorVersionLabel, c); 173 //add(minorVersionLabel); 174 175 minorVersionText = new JTextField(); 176 minorVersionText.setEditable(editable); 177 c.gridx = 1; 178 c.gridy = row+5; 179 c.gridwidth = 1; 180 c.gridheight = 1; 181 c.weightx = 0.5; 182 c.weighty = 0.0; 183 c.fill = GridBagConstraints.HORIZONTAL; 184 c.anchor = GridBagConstraints.CENTER; 185 c.insets = new Insets(4, 4, 0, 4); 186 gbl.setConstraints(minorVersionText, c); 187 //add(minorVersionText); 188 189 JLabel userVersionLabel = new JLabel("User Version:", SwingConstants.LEFT); 190 c.gridx = 0; 191 c.gridy = row+6; 192 c.gridwidth = 1; 193 c.gridheight = 1; 194 c.weightx = 0.0; 195 c.weighty = 0.0; 196 c.fill = GridBagConstraints.NONE; 197 c.anchor = GridBagConstraints.WEST; 198 c.insets = new Insets(4, 4, 0, 4); 199 gbl.setConstraints(userVersionLabel, c); 200 add(userVersionLabel); 201 202 userVersionText = new JTextField(); 203 userVersionText.setEditable(editable); 204 c.gridx = 0; 205 c.gridy = row+7; 206 c.gridwidth = 1; 207 c.gridheight = 1; 208 c.weightx = 0.5; 209 c.weighty = 0.0; 210 c.fill = GridBagConstraints.HORIZONTAL; 211 c.anchor = GridBagConstraints.CENTER; 212 c.insets = new Insets(4, 4, 0, 4); 213 gbl.setConstraints(userVersionText, c); 214 add(userVersionText); 215 216 row += 8; 217 218 } 219 220 RegistryEntry getRegistryEntry() { 221 return (RegistryEntry)model; 222 } 223 224 public void setModel(Object obj) throws JAXRException { 225 if (!(obj instanceof RegistryEntry)) { 226 throw new InvalidRequestException("Expecting a RegistryEntry. Got a " + obj.getClass().getName()); 227 } 228 super.setModel(obj); 229 230 RegistryEntry re = (RegistryEntry)obj; 231 232 try { 233 Date expiration = re.getExpiration(); 234 String userVersion = re.getUserVersion(); 235 int stability = re.getStability(); 236 int status = re.getStatus(); 237 238 if (expiration !=null) { 239 expirationText.setText(expiration.toLocaleString()); 240 } 241 242 if (userVersion !=null) { 243 userVersionText.setText(userVersion); 244 } 245 246 if (stability < stabilityTypes.length) { 247 stabilityCombo.setSelectedIndex(stability); 248 } 249 else { 250 RegistryBrowser.displayError("Stability out of bounds: index = " + stability); 251 } 252 253 if (status < statusTypes.length) { 254 statusCombo.setSelectedIndex(status); 255 } 256 else { 257 RegistryBrowser.displayError("Status out of bounds: index = " + status); 258 } 259 } 260 catch (JAXRException e) { 261 RegistryBrowser.displayError(e); 262 } 263 } 264 265 public Object getModel() throws JAXRException { 266 super.getModel(); 267 268 if (model != null) { 269 RegistryEntry re = (RegistryEntry)model; 270 271 JAXRClient client = RegistryBrowser.getInstance().getClient(); 272 re.setUserVersion(userVersionText.getText()); 273 RegistryBrowser.getInstance().getRootPane().updateUI(); 274 } 275 276 return model; 277 } 278 279 protected void validateInput() throws JAXRException { 280 super.validateInput(); 281 RegistryEntry re = (RegistryEntry)model; 282 } 283 284 public void clear() throws JAXRException { 285 super.clear(); 286 majorVersionText.setText(""); 287 minorVersionText.setText(""); 288 expirationText.setText(""); 289 userVersionText.setText(""); 290 } 291 292 /*** 293 * Sets whether this dialog is read-only or editable. 294 */ 295 public void setEditable(boolean editable) { 296 super.setEditable(editable); 297 298 majorVersionText.setEditable(editable); 299 minorVersionText.setEditable(editable); 300 expirationText.setEditable(editable); 301 userVersionText.setEditable(editable); 302 stabilityCombo.setEditable(editable); 303 stabilityCombo.setEnabled(editable); 304 } 305 306 307 308 } 309

This page was automatically generated by Maven