View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/ServiceBindingPanel.java,v 1.10 2003/08/25 15:46:51 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 to edit/inspect a Service. 15 * 16 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 17 */ 18 public class ServiceBindingPanel extends RegistryObjectPanel { 19 20 JTextField accessURIText = null; 21 22 /*** 23 * Creates new ServiceBindingPanel 24 */ 25 public ServiceBindingPanel() { 26 super(); 27 setBorder(BorderFactory.createTitledBorder("Service Binding")); 28 29 HyperLinkLabel accessURILabel = new HyperLinkLabel("Access URI:", SwingConstants.LEFT); 30 c.gridx = 0; 31 c.gridy = row+0; 32 c.gridwidth = 1; 33 c.gridheight = 1; 34 c.weightx = 0.0; 35 c.weighty = 0.0; 36 c.fill = GridBagConstraints.NONE; 37 c.anchor = GridBagConstraints.WEST; 38 c.insets = new Insets(4, 4, 0, 4); 39 gbl.setConstraints(accessURILabel, c); 40 add(accessURILabel); 41 42 accessURIText = new JTextField(); 43 accessURIText.setEditable(editable); 44 c.gridx = 0; 45 c.gridy = row+1; 46 c.gridwidth = 1; 47 c.gridheight = 1; 48 c.weightx = 0.5; 49 c.weighty = 0.0; 50 c.fill = GridBagConstraints.HORIZONTAL; 51 c.anchor = GridBagConstraints.CENTER; 52 c.insets = new Insets(4, 4, 0, 4); 53 gbl.setConstraints(accessURIText, c); 54 add(accessURIText); 55 56 accessURILabel.setHyperLinkContainer(new HyperLinkContainer() { 57 public String getURL() { 58 return (accessURIText.getText()); 59 } 60 61 public void setURL(String url) { 62 accessURIText.setText(url); 63 } 64 }); 65 66 } 67 68 public void setModel(Object obj) throws JAXRException { 69 if (!(obj instanceof ServiceBinding)) { 70 throw new InvalidRequestException("Expecting a ServiceBinding. Got a " + obj.getClass().getName()); 71 } 72 super.setModel(obj); 73 74 ServiceBinding binding = (ServiceBinding)obj; 75 76 try { 77 if (binding != null) { 78 String accessURIStr = binding.getAccessURI(); 79 if (accessURIStr != null) { 80 accessURIText.setText(accessURIStr); 81 } 82 } 83 } 84 catch (JAXRException e) { 85 RegistryBrowser.displayError(e); 86 } 87 } 88 89 public Object getModel() throws JAXRException { 90 super.getModel(); 91 if (model != null) { 92 ServiceBinding serviceBinding = (ServiceBinding)model; 93 94 String accessURITextStr = accessURIText.getText(); 95 serviceBinding.setAccessURI(accessURITextStr); 96 97 RegistryBrowser.getInstance().getRootPane().updateUI(); 98 } 99 100 return model; 101 } 102 103 protected void validateInput() throws JAXRException { 104 super.validateInput(); 105 106 String accessURITextStr = accessURIText.getText(); 107 if ((accessURITextStr.length() <= 0) || (accessURITextStr.length() > 256)) { 108 throw new JAXRException("Error. ServiceBinding.accessURI length must be between 1 and 256"); 109 } 110 } 111 112 public void clear() throws JAXRException { 113 super.clear(); 114 accessURIText.setText(""); 115 } 116 117 /*** 118 * Sets whether this dialog is read-only or editable. 119 */ 120 public void setEditable(boolean editable) { 121 super.setEditable(editable); 122 123 accessURIText.setEditable(editable); 124 } 125 126 127 } 128

This page was automatically generated by Maven