1 19 20 package org.openharmonise.him.displaycomponents.search; 21 22 import java.awt.*; 23 import java.awt.event.*; 24 import java.net.MalformedURLException ; 25 import java.net.URI ; 26 import java.net.URL ; 27 import java.rmi.RemoteException ; 28 import java.text.*; 29 import java.util.*; 30 import java.util.List ; 31 32 import javax.swing.*; 33 import javax.xml.rpc.ServiceException ; 34 35 import org.openharmonise.commons.xml.namespace.*; 36 import org.openharmonise.him.*; 37 import org.openharmonise.him.configuration.*; 38 import org.openharmonise.him.displaycomponents.*; 39 import org.openharmonise.him.editors.report.swing.*; 40 import org.openharmonise.him.harmonise.*; 41 import org.openharmonise.him.window.messages.MessageHandler; 42 import org.openharmonise.him.window.swing.ResourcePathCellRenderer; 43 import org.openharmonise.swing.FontManager; 44 import org.openharmonise.swing.datefield.*; 45 import org.openharmonise.vfs.context.*; 46 import org.openharmonise.vfs.gui.*; 47 import org.openharmonise.vfs.search.*; 48 import org.openharmonise.vfs.servers.*; 49 import org.openharmonise.webdav.client.webservice.SearchDetailsService; 50 51 52 59 public class SearchTabPanel 60 extends JPanel 61 implements ActionListener, LayoutManager, KeyListener, ContextListener { 62 63 66 private SearchDisplayComponent m_display = null; 67 68 71 private Color m_selectedColor = new Color(173, 169, 143); 72 73 76 private JLabel m_textLabel = null; 77 78 81 private JTextField m_textTextField = null; 82 83 86 private JComboBox m_textComboBox = null; 87 88 91 private JLabel m_inLabel = null; 92 93 96 private JComboBox m_inCombo = null; 97 98 101 private JButton m_searchButton = null; 102 103 106 private JLabel m_optionsLabel = null; 107 108 111 private JCheckBox m_publicationDateCheck = null; 112 113 116 private JDateField m_publicationDateField = null; 117 118 121 private JComboBox m_publicationDateCombo = null; 122 123 126 private JCheckBox m_authorCheck = null; 127 128 131 private JTextField m_authorTextField = null; 132 private JComboTree m_authorTree = null; 133 134 137 private static String TEXT_OPTION_TITLE = "Title"; 138 139 142 private static String TEXT_OPTION_CONTENTS = "Contents"; 143 144 private List m_aStopWords = null; 145 146 151 public SearchTabPanel(SearchDisplayComponent display) { 152 super(); 153 this.m_display = display; 154 this.setup(); 155 } 156 157 161 private void setup() { 162 ContextHandler.getInstance().addListener(ContextType.CONTEXT_SYSTEM_PROP_CHANGED, this); 163 164 this.setLayout(this); 165 166 171 m_textLabel = new JLabel("Containing the text:"); 172 m_textLabel.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 173 this.add(m_textLabel); 174 175 m_textTextField = new JTextField(); 176 m_textTextField.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 177 m_textTextField.addKeyListener(this); 178 this.add(m_textTextField); 179 180 String [] aTextOptions = new String []{"Title", "Contents"}; 181 this.m_textComboBox = new JComboBox(aTextOptions); 182 this.m_textComboBox.setActionCommand("TEXT_OPTIONS"); 183 this.add(m_textComboBox); 184 185 186 m_inLabel = new JLabel("Search in..."); 187 m_inLabel.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 188 this.add(m_inLabel); 189 190 Object [] sPaths = this.getComboData(); 191 m_inCombo = new JComboBox(sPaths); 192 m_inCombo.addActionListener(this); 193 m_inCombo.setActionCommand("COMBO"); 194 m_inCombo.setRenderer( 195 new ResourcePathCellRenderer( 196 ServerList.getInstance().getHarmoniseServer().getVFS())); 197 m_inCombo.setFont( FontManager.getInstance().getFont( FontManager.FONT_RESOURCE_TITLE ) ); 198 this.add(m_inCombo); 199 200 m_searchButton = new JButton("Search"); 201 m_searchButton.setActionCommand("SEARCH"); 202 m_searchButton.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 203 m_searchButton.setIcon( 204 IconManager.getInstance().getIcon("16-command-search.gif")); 205 m_searchButton.addActionListener(this); 206 this.add(m_searchButton); 207 208 this.m_optionsLabel = new JLabel(" Options"); 209 this.m_optionsLabel.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD_BOLD ) ); 210 this.add(this.m_optionsLabel); 211 212 this.m_publicationDateCheck = new JCheckBox("Publication date"); 213 this.m_publicationDateCheck.setActionCommand("PUBDATE"); 214 this.m_publicationDateCheck.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 215 this.m_publicationDateCheck.addActionListener(this); 216 this.add(this.m_publicationDateCheck); 217 218 Date dt = new Date(); 219 this.m_publicationDateField = new JDateField("yyyy-MM-dd"); 220 this.m_publicationDateField.setBorder( BorderFactory.createLineBorder(Color.BLACK) ); 221 this.m_publicationDateField.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 222 this.m_publicationDateField.setVisible(false); 223 this.add(this.m_publicationDateField); 224 225 String [] pubDateOperators = new String [] { "=", ">", "<" }; 226 this.m_publicationDateCombo = new JComboBox(pubDateOperators); 227 this.m_publicationDateCombo.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD_BOLD ) ); 228 this.m_publicationDateCombo.setVisible(false); 229 this.add(this.m_publicationDateCombo); 230 231 this.m_authorCheck = new JCheckBox("Author"); 232 this.m_authorCheck.setActionCommand("CREAT"); 233 this.m_authorCheck.setFont( FontManager.getInstance().getFont( FontManager.FONT_STANDARD ) ); 234 this.m_authorCheck.addActionListener(this); 235 this.add(this.m_authorCheck); 236 237 this.m_authorTree = new JComboTree(); 238 this.m_authorTree.addCollectionPath(HarmonisePaths.PATH_VALUES + "/admin/content_workers/authors"); 239 this.m_authorTree.setVisible(false); 240 this.add(this.m_authorTree); 241 242 } 243 244 247 public void layoutContainer(Container arg0) { 248 int nHeight = 5; 249 250 this.m_textComboBox.setSize(this.getParent().getWidth() - 20, 20); 251 this.m_textComboBox.setLocation(10, nHeight); 252 nHeight = nHeight + this.m_textComboBox.getSize().height + 5; 253 254 this.m_textLabel.setSize(this.getParent().getWidth() - 20, 20); 255 this.m_textLabel.setLocation(10, nHeight); 256 nHeight = nHeight + this.m_textLabel.getSize().height + 5; 257 258 this.m_textTextField.setSize(this.getParent().getWidth() - 20, 20); 259 this.m_textTextField.setLocation(10, nHeight); 260 nHeight = nHeight + this.m_textTextField.getSize().height + 5; 261 262 this.m_inLabel.setSize(this.getParent().getWidth() - 20, 20); 263 this.m_inLabel.setLocation(10, nHeight); 264 nHeight = nHeight + this.m_inLabel.getSize().height + 5; 265 266 this.m_inCombo.setSize(this.getParent().getWidth() - 20, 20); 267 this.m_inCombo.setLocation(10, nHeight); 268 nHeight = nHeight + this.m_inCombo.getSize().height + 5; 269 270 this.m_optionsLabel.setSize(this.getParent().getWidth() - 20, 20); 271 this.m_optionsLabel.setLocation(10, nHeight); 272 nHeight = nHeight + this.m_optionsLabel.getSize().height + 5; 273 274 this.m_publicationDateCheck.setSize( 275 this.getParent().getWidth() - 20, 276 20); 277 this.m_publicationDateCheck.setLocation(10, nHeight); 278 nHeight = nHeight + this.m_publicationDateCheck.getSize().height + 5; 279 280 if (this.m_publicationDateCheck.isSelected()) { 281 this.m_publicationDateField.setSize( 282 this.getParent().getWidth() - 70, 283 20); 284 this.m_publicationDateField.setLocation(10, nHeight); 285 286 this.m_publicationDateCombo.setSize(40, 20); 287 this.m_publicationDateCombo.setLocation( 288 this.getParent().getWidth() - 50, 289 nHeight); 290 nHeight = 291 nHeight + this.m_publicationDateField.getSize().height + 5; 292 } 293 294 this.m_authorCheck.setSize( 295 this.getParent().getWidth() - 20, 296 20); 297 this.m_authorCheck.setLocation(10, nHeight); 298 nHeight = nHeight + this.m_authorCheck.getSize().height + 5; 299 300 if(this.m_authorCheck.isSelected()) { 301 this.m_authorTree.setSize( 302 this.getParent().getWidth() - 20, 303 20); 304 305 this.m_authorTree.setLocation(10, nHeight); 306 nHeight = 307 nHeight + this.m_authorTree.getSize().height + 5; 308 } 309 310 nHeight = nHeight + 5; 311 this.m_searchButton.setSize(90, 25); 312 this.m_searchButton.setLocation( 313 this.getParent().getWidth() 314 - this.m_searchButton.getSize().width 315 - 10, 316 nHeight); 317 nHeight = nHeight + this.m_searchButton.getSize().height + 5; 318 } 319 320 323 public void actionPerformed(Acti
|