View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/AssociationPanel.java,v 1.7 2003/07/30 23:39:11 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 AssociationPanel extends RegistryObjectPanel { 19 20 JTextField sourceObjectText = null; 21 JTextField targetObjectText = null; 22 JCheckBox confirmedBySourceCheckBox = null; 23 JCheckBox confirmedByTargetCheckBox = null; 24 JCheckBox isExtramuralCheckBox = null; 25 JComboBox assocTypeCombo = null; 26 27 String[] assocTypes = { 28 "PartnerOf" 29 }; 30 31 32 /*** 33 * Creates new ServicePanel 34 */ 35 public AssociationPanel() { 36 super(); 37 38 setBorder(BorderFactory.createTitledBorder("Association Details")); 39 40 //Source Object 41 JLabel sourceObjectLabel = new JLabel("Source Object Id:", SwingConstants.LEFT); 42 c.gridx = 0; 43 c.gridy = row+0; 44 c.gridwidth = 1; 45 c.gridheight = 1; 46 c.weightx = 0.0; 47 c.weighty = 0.0; 48 c.fill = GridBagConstraints.NONE; 49 c.anchor = GridBagConstraints.WEST; 50 c.insets = new Insets(4, 4, 0, 4); 51 gbl.setConstraints(sourceObjectLabel, c); 52 add(sourceObjectLabel); 53 54 sourceObjectText = new JTextField(); 55 sourceObjectText.setEditable(false); 56 c.gridx = 0; 57 c.gridy = row+1; 58 c.gridwidth = 1; 59 c.gridheight = 1; 60 c.weightx = 0.5; 61 c.weighty = 0.0; 62 c.fill = GridBagConstraints.HORIZONTAL; 63 c.anchor = GridBagConstraints.CENTER; 64 c.insets = new Insets(4, 4, 0, 4); 65 gbl.setConstraints(sourceObjectText, c); 66 add(sourceObjectText); 67 68 //targetObject 69 JLabel targetObjectLabel = new JLabel("Target Object Id:", SwingConstants.LEFT); 70 c.gridx = 1; 71 c.gridy = row+0; 72 c.gridwidth = 1; 73 c.gridheight = 1; 74 c.weightx = 0.0; 75 c.weighty = 0.0; 76 c.fill = GridBagConstraints.NONE; 77 c.anchor = GridBagConstraints.WEST; 78 c.insets = new Insets(4, 4, 0, 4); 79 gbl.setConstraints(targetObjectLabel, c); 80 add(targetObjectLabel); 81 82 targetObjectText = new JTextField(); 83 targetObjectText.setEditable(false); 84 c.gridx = 1; 85 c.gridy = row+1; 86 c.gridwidth = 1; 87 c.gridheight = 1; 88 c.weightx = 0.5; 89 c.weighty = 0.0; 90 c.fill = GridBagConstraints.HORIZONTAL; 91 c.anchor = GridBagConstraints.CENTER; 92 c.insets = new Insets(4, 4, 0, 4); 93 gbl.setConstraints(targetObjectText, c); 94 add(targetObjectText); 95 96 confirmedBySourceCheckBox = new JCheckBox("Confiirmed by Source Owner"); 97 confirmedBySourceCheckBox.setSelected(false); 98 confirmedBySourceCheckBox.setEnabled(false); 99 c.gridx = 0; 100 c.gridy = row+2; 101 c.gridwidth = 1; 102 c.gridheight = 1; 103 c.weightx = 0.0; 104 c.weighty = 0.0; 105 c.fill = GridBagConstraints.NONE; 106 c.anchor = GridBagConstraints.WEST; 107 c.insets = new Insets(4, 4, 0, 4); 108 gbl.setConstraints(confirmedBySourceCheckBox, c); 109 add(confirmedBySourceCheckBox); 110 111 confirmedByTargetCheckBox = new JCheckBox("Confiirmed by Target Owner"); 112 confirmedByTargetCheckBox.setSelected(false); 113 confirmedByTargetCheckBox.setEnabled(false); 114 c.gridx = 1; 115 c.gridy = row+2; 116 c.gridwidth = 1; 117 c.gridheight = 1; 118 c.weightx = 0.0; 119 c.weighty = 0.0; 120 c.fill = GridBagConstraints.NONE; 121 c.anchor = GridBagConstraints.WEST; 122 c.insets = new Insets(4, 4, 0, 4); 123 gbl.setConstraints(confirmedByTargetCheckBox, c); 124 add(confirmedByTargetCheckBox); 125 126 JLabel assocTypeLabel = new JLabel("Association Type:", SwingConstants.LEFT); 127 c.gridx = 0; 128 c.gridy = row+3; 129 c.gridwidth = 1; 130 c.gridheight = 1; 131 c.weightx = 0.0; 132 c.weighty = 0.0; 133 c.fill = GridBagConstraints.NONE; 134 c.anchor = GridBagConstraints.WEST; 135 c.insets = new Insets(4, 4, 0, 4); 136 gbl.setConstraints(assocTypeLabel, c); 137 add(assocTypeLabel); 138 139 assocTypeCombo = new JComboBox(getAssociationTypes()); 140 assocTypeCombo.setEditable(true); 141 c.gridx = 0; 142 c.gridy = row+4; 143 c.gridwidth = 1; 144 c.gridheight = 1; 145 c.weightx = 0.5; 146 c.weighty = 0.0; 147 c.fill = GridBagConstraints.HORIZONTAL; 148 c.anchor = GridBagConstraints.WEST; 149 c.insets = new Insets(4, 4, 0, 4); 150 gbl.setConstraints(assocTypeCombo, c); 151 add(assocTypeCombo); 152 153 isExtramuralCheckBox = new JCheckBox("Is Extramural"); 154 isExtramuralCheckBox.setSelected(false); 155 isExtramuralCheckBox.setEnabled(false); 156 c.gridx = 1; 157 c.gridy = row+4; 158 c.gridwidth = 1; 159 c.gridheight = 1; 160 c.weightx = 0.0; 161 c.weighty = 0.0; 162 c.fill = GridBagConstraints.NONE; 163 c.anchor = GridBagConstraints.WEST; 164 c.insets = new Insets(4, 4, 0, 4); 165 gbl.setConstraints(isExtramuralCheckBox, c); 166 add(isExtramuralCheckBox); 167 168 } 169 170 public static String[] getAssociationTypes() { 171 String[] assocTypes = null; 172 173 try { 174 JAXRClient client = RegistryBrowser.getInstance().getClient(); 175 com.sun.xml.registry.ebxml.BusinessQueryManagerImpl bqm = (com.sun.xml.registry.ebxml.BusinessQueryManagerImpl)(client.getBusinessQueryManager()); 176 Collection concepts = bqm.findConceptsByPath("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/%"); 177 178 int size = concepts.size(); 179 assocTypes = new String[size]; 180 Iterator iter = concepts.iterator(); 181 int i=0; 182 while (iter.hasNext()) { 183 Concept concept = (Concept)iter.next(); 184 assocTypes[i++] = concept.getValue(); 185 } 186 } 187 catch (JAXRException e) { 188 RegistryBrowser.displayError(e); 189 } 190 191 return assocTypes; 192 } 193 194 public void setModel(Object obj) throws JAXRException { 195 if (!(obj instanceof Association)) { 196 throw new InvalidRequestException("Expecting a Association. Got a " + obj.getClass().getName()); 197 } 198 super.setModel(obj); 199 200 Association ass = (Association)obj; 201 202 try { 203 if (ass != null) { 204 205 RegistryObject src = ass.getSourceObject(); 206 RegistryObject target= ass.getTargetObject(); 207 boolean srcConfirmed = ass.isConfirmedBySourceOwner(); 208 boolean targetConfirmed = ass.isConfirmedByTargetOwner(); 209 boolean isExtramural = ass.isExtramural(); 210 Concept assType = ass.getAssociationType(); 211 212 if (src != null) { 213 sourceObjectText.setText(src.getKey().getId()); 214 } 215 216 if (target != null) { 217 targetObjectText.setText(target.getKey().getId()); 218 } 219 220 confirmedBySourceCheckBox.setSelected(srcConfirmed); 221 confirmedByTargetCheckBox.setSelected(targetConfirmed); 222 isExtramuralCheckBox.setSelected(isExtramural); 223 224 if (assType != null) { 225 String path = assType.getPath(); 226 /* //??new concepts do not have path set 227 if (!(path.startsWith("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/"))) { 228 RegistryBrowser.displayError("Association type must be a Concept under the canonical AssociationType ClassificationScheme"); 229 } 230 */ 231 assocTypeCombo.setSelectedItem(assType.getValue()); 232 } 233 } 234 } 235 catch (JAXRException e) { 236 RegistryBrowser.displayError(e); 237 } 238 } 239 240 public Object getModel() throws JAXRException { 241 super.getModel(); 242 243 if (model != null) { 244 Association ass = (Association)model; 245 246 JAXRClient client = RegistryBrowser.getInstance().getClient(); 247 com.sun.xml.registry.ebxml.BusinessQueryManagerImpl bqm = (com.sun.xml.registry.ebxml.BusinessQueryManagerImpl)(client.getBusinessQueryManager()); 248 249 Concept assocType = bqm.findConceptByPath("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/" + (String)(assocTypeCombo.getSelectedItem())); 250 ass.setAssociationType(assocType); 251 252 //??need to get source/targetObjects etc. 253 RegistryBrowser.getInstance().getRootPane().updateUI(); 254 } 255 256 return model; 257 } 258 259 protected void validateInput() throws JAXRException { 260 super.validateInput(); 261 262 Association ass = (Association)model; 263 } 264 265 public void clear() throws JAXRException { 266 super.clear(); 267 sourceObjectText.setText(""); 268 targetObjectText.setText(""); 269 confirmedBySourceCheckBox.setSelected(false); 270 confirmedByTargetCheckBox.setSelected(false); 271 isExtramuralCheckBox.setSelected(false); 272 //assocTypeCombo = null; 273 } 274 275 276 } 277

This page was automatically generated by Maven