View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/ExternalLinkPanel.java,v 1.11 2003/08/25 15:43:03 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 /*** 15 * Panel to edit/inspect a Service. 16 * 17 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 18 */ 19 public class ExternalLinkPanel extends RegistryObjectPanel { 20 21 HyperLinkLabel externalURILabel = null; 22 JTextField externalURIText = null; 23 24 /*** 25 * Creates new ExternalLinkPanel 26 */ 27 public ExternalLinkPanel() { 28 setBorder(BorderFactory.createTitledBorder("External Link")); 29 30 HyperLinkLabel externalURILabel = new HyperLinkLabel("External URI:", SwingConstants.LEFT); 31 c.gridx = 0; 32 c.gridy = row+0; 33 c.gridwidth = 1; 34 c.gridheight = 1; 35 c.weightx = 0.0; 36 c.weighty = 0.0; 37 c.fill = GridBagConstraints.NONE; 38 c.anchor = GridBagConstraints.WEST; 39 c.insets = new Insets(4, 4, 0, 4); 40 gbl.setConstraints(externalURILabel, c); 41 add(externalURILabel); 42 43 externalURIText = new JTextField(); 44 externalURIText.setEditable(editable); 45 c.gridx = 0; 46 c.gridy = row+1; 47 c.gridwidth = 1; 48 c.gridheight = 1; 49 c.weightx = 0.5; 50 c.weighty = 0.0; 51 c.fill = GridBagConstraints.HORIZONTAL; 52 c.anchor = GridBagConstraints.CENTER; 53 c.insets = new Insets(4, 4, 0, 4); 54 gbl.setConstraints(externalURIText, c); 55 add(externalURIText); 56 57 externalURILabel.setHyperLinkContainer(new HyperLinkContainer() { 58 public String getURL() { 59 return (externalURIText.getText()); 60 } 61 62 public void setURL(String url) { 63 externalURIText.setText(url); 64 } 65 }); 66 } 67 68 public void setModel(Object obj) throws JAXRException { 69 if (!(obj instanceof ExternalLink)) { 70 throw new InvalidRequestException("Expecting a ExternalLink. Got a " + obj.getClass().getName()); 71 } 72 super.setModel(obj); 73 74 ExternalLink externalLink = (ExternalLink)obj; 75 76 try { 77 if (externalLink != null) { 78 String externalURIStr = externalLink.getExternalURI(); 79 if (externalURIStr != null) { 80 externalURIText.setText(externalURIStr); 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 ExternalLink externalLink = (ExternalLink)model; 93 94 String externalURIStr = externalURIText.getText().trim(); 95 externalLink.setExternalURI(externalURIStr); 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 externalURIStr = externalURIText.getText().trim(); 107 if (externalURIStr.length() == 0) { 108 throw new JAXRException("Error. externalURI attribute must not be empty."); 109 } 110 } 111 112 public void clear() throws JAXRException { 113 super.clear(); 114 externalURIText.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 externalURIText.setEditable(editable); 124 externalURIText.setEditable(editable); 125 } 126 127 128 } 129

This page was automatically generated by Maven