View Javadoc
1 /* 2 * ==================================================================== 3 * 4 * This code is subject to the freebxml License, Version 1.1 5 * 6 * Copyright (c) 2003 freebxml.org. All rights reserved. 7 * 8 * ==================================================================== 9 * 10 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/FindParamsPanel.java,v 1.31 2003/08/13 15:34:40 farrukh_najmi Exp $ 11 * 12 */ 13 package com.sun.xml.registry.client.browser; 14 15 import java.beans.*; 16 17 import com.sun.xml.registry.ebxml.BusinessQueryManagerImpl; 18 import java.awt.GridBagConstraints; 19 import java.awt.Insets; 20 import java.awt.event.ActionEvent; 21 import java.awt.event.ActionListener; 22 import java.util.ArrayList; 23 import javax.swing.JLabel; 24 import javax.swing.JPanel; 25 import javax.swing.JScrollPane; 26 import javax.swing.SwingConstants; 27 import javax.xml.registry.JAXRException; 28 29 import com.sun.xml.registry.client.browser.conf.bindings.*; 30 31 /*** 32 * A form to allow user enter all parameters for a find or search in 33 * the registry. Parent of BusinesQueryPanel and AdhocQueryPanel. 34 * 35 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 36 */ 37 public class FindParamsPanel extends JPanel { 38 39 private GridBagConstraints c = new GridBagConstraints(); 40 41 //parent for eparam entry panel for both Business and Adhoc queries 42 private JPanel paramEntryParentPanel = null; 43 private BusinessQueryPanel businessPanel = null; 44 private AdhocQueryPanel adhocPanel = null; 45 private java.awt.CardLayout cardLayout = null; 46 47 private boolean businessQuery = true; 48 49 private DiscoveryPanel discoveryPanel; 50 51 private org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(this.getClass()); 52 53 /*** 54 * Class Constructor. 55 */ 56 public FindParamsPanel(DiscoveryPanel discoveryPanel) throws javax.xml.registry.JAXRException { 57 this.discoveryPanel = discoveryPanel; 58 59 java.awt.GridBagLayout gbl = new java.awt.GridBagLayout(); 60 setLayout(gbl); 61 62 //The searchTypeSelectionPanel at the top of the panel 63 JPanel searchTypePanel = createSearchTypePanel(); 64 c.gridx = 0; 65 c.gridy = 0; 66 c.gridwidth = 1; 67 c.gridheight = 1; 68 c.weightx = 0.0; 69 c.weighty = 0.0; 70 c.fill = GridBagConstraints.NONE; 71 c.anchor = GridBagConstraints.NORTH; 72 c.insets = new Insets(4, 4, 0, 4); 73 gbl.setConstraints(searchTypePanel, c); 74 add(searchTypePanel); 75 76 //The actionPanel 77 JPanel actionPanel = createActionPanel(); 78 c.gridx = 0; 79 c.gridy = 1; 80 c.gridwidth = 1; 81 c.gridheight = 1; 82 c.weightx = 0.0; 83 c.weighty = 0.0; 84 c.fill = GridBagConstraints.NONE; 85 c.anchor = GridBagConstraints.NORTH; 86 c.insets = new Insets(4, 4, 0, 4); 87 gbl.setConstraints(searchTypePanel, c); 88 add(actionPanel); 89 90 //Next is the panel that is the parent of both adhocQueryPanel and 91 //businessQueryPanel 92 paramEntryParentPanel = createParamEntryParentPanel(); 93 c.gridx = 0; 94 c.gridy = 2; 95 c.gridwidth = 1; 96 c.gridheight = 1; 97 c.weightx = 0.5; 98 c.weighty = 0.5; 99 c.fill = GridBagConstraints.BOTH; 100 c.anchor = GridBagConstraints.NORTH; 101 c.insets = new Insets(4, 4, 0, 4); 102 gbl.setConstraints(paramEntryParentPanel, c); 103 add(paramEntryParentPanel); 104 105 //RegistryBrowser.getInstance().getConceptsTreeDialog().addPropertyChangeListener(this); 106 107 } 108 109 private JPanel createActionPanel() { 110 JPanel actionPanel = new JPanel(); 111 112 //The Clear Form button 113 javax.swing.JButton findButton = new javax.swing.JButton("Search"); 114 actionPanel.add(findButton); 115 findButton.addActionListener(new ActionListener() { 116 public void actionPerformed(ActionEvent ev) { 117 discoveryPanel.find(); 118 } 119 }); 120 121 //The Clear Form button 122 javax.swing.JButton clearButton = new javax.swing.JButton("Clear Form"); 123 actionPanel.add(clearButton); 124 clearButton.addActionListener(new ActionListener() { 125 public void actionPerformed(ActionEvent ev) { 126 try { 127 discoveryPanel.clear(); 128 } 129 catch (javax.xml.registry.JAXRException e) { 130 RegistryBrowser.displayError(e); 131 } 132 } 133 }); 134 135 return actionPanel; 136 } 137 138 private JPanel createSearchTypePanel() { 139 //It just has two radio buttons that Selects from Business and Adhoc Query 140 JPanel searchTypePanel = new JPanel(); 141 142 javax.swing.JRadioButton businessButton = new javax.swing.JRadioButton("Business Query"); 143 businessButton.setMnemonic(java.awt.event.KeyEvent.VK_B); 144 businessButton.setSelected(true); 145 businessButton.addActionListener(new ActionListener() { 146 public void actionPerformed(ActionEvent e) { 147 cardLayout.show(paramEntryParentPanel, "businessPanel"); 148 businessQuery = true; 149 } 150 }); 151 152 javax.swing.JRadioButton adhocButton = new javax.swing.JRadioButton("Adhoc Query"); 153 adhocButton.setMnemonic(java.awt.event.KeyEvent.VK_A); 154 adhocButton.setSelected(false); 155 adhocButton.addActionListener(new ActionListener() { 156 public void actionPerformed(ActionEvent e) { 157 cardLayout.show(paramEntryParentPanel, "adhocPanel"); 158 businessQuery = false; 159 } 160 }); 161 162 javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup(); 163 buttonGroup.add(businessButton); 164 buttonGroup.add(adhocButton); 165 166 searchTypePanel.add(businessButton); 167 searchTypePanel.add(adhocButton); 168 169 return searchTypePanel; 170 } 171 172 private JPanel createParamEntryParentPanel() throws javax.xml.registry.JAXRException { 173 JPanel paramEntryParentPanel = new JPanel(); 174 cardLayout = new java.awt.CardLayout(); 175 paramEntryParentPanel.setLayout(cardLayout); 176 177 Configuration cfg = RegistryBrowser.getInstance().getConfiguration(); 178 179 //The panel used for business query based searches 180 businessPanel = new BusinessQueryPanel(this, cfg); 181 paramEntryParentPanel.add(businessPanel, "businessPanel"); 182 183 //The panel used for ad hoc query based searches 184 adhocPanel = new AdhocQueryPanel(this, cfg); 185 paramEntryParentPanel.add(adhocPanel, "adhocPanel"); 186 187 return paramEntryParentPanel; 188 } 189 190 /*** 191 * Execute the query using parameters defined by the fields in 192 * currently selected QueryPanel. 193 */ 194 javax.xml.registry.BulkResponse executeQuery() { 195 javax.xml.registry.BulkResponse resp = null; 196 197 if (businessQuery) { 198 resp = businessPanel.executeQuery(); 199 } 200 else { 201 resp = adhocPanel.executeQuery(); 202 } 203 204 return resp; 205 } 206 207 /*** 208 * Invoke the find action. Delegates to parent. 209 */ 210 void find() { 211 discoveryPanel.find(); 212 } 213 214 215 /*** 216 * Clears or resets the UI. Delegates to childern. 217 */ 218 public void clear() throws JAXRException { 219 businessPanel.clear(); 220 adhocPanel.clear(); 221 } 222 223 } 224 225 226 227

This page was automatically generated by Maven