001/* 002 * Copyright (c) 2004-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: crawl $' 006 * '$Date: 2014-08-07 00:22:57 +0000 (Thu, 07 Aug 2014) $' 007 * '$Revision: 32862 $' 008 * 009 * Permission is hereby granted, without written agreement and without 010 * license or royalty fees, to use, copy, modify, and distribute this 011 * software and its documentation for any purpose, provided that the above 012 * copyright notice and the following two paragraphs appear in all copies 013 * of this software. 014 * 015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 019 * SUCH DAMAGE. 020 * 021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 026 * ENHANCEMENTS, OR MODIFICATIONS. 027 * 028 */ 029 030package org.kepler.gui; 031 032import java.awt.Component; 033import java.awt.Window; 034import java.awt.event.ActionEvent; 035import java.awt.event.ActionListener; 036 037import javax.swing.AbstractAction; 038import javax.swing.BoxLayout; 039 040import org.kepler.gui.component.SearchConfigurationFrame; 041import org.kepler.util.StaticResources; 042 043/** 044 * Class to build the search gui pane that allows the user to enter a single 045 * search term to search by. 046 * 047 *@author berkley 048 *@since February 17, 2005 049 */ 050public class SimpleSearchUIPane extends LibrarySearchPane { 051 052 private SearchUIJPanel _searchUIJPanel; 053 054 /** 055 * constructor 056 * 057 *@param searchButtonHandler 058 * Description of the Parameter 059 */ 060 public SimpleSearchUIPane(ActionListener searchButtonHandler) { 061 super(searchButtonHandler); 062 init(); 063 } 064 065 /** 066 * Clear the search term. 067 */ 068 public void clearSearch() { 069 _searchUIJPanel.setSearchTerm(""); 070 } 071 072 /** 073 *@return the search term 074 */ 075 public String getSearchTerm() { 076 return _searchUIJPanel.getSearchTerm(); 077 } 078 079 /* 080 * Initialize the search panel 081 */ 082 private void init() { 083 084 this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 085 086 _searchUIJPanel = new SearchUIJPanel(); 087 _searchUIJPanel.setBorderTitle( 088 StaticResources.getDisplayString("components.search", "Search Components")); 089 _searchUIJPanel.setSearchAction(new AbstractAction() { 090 public void actionPerformed(ActionEvent e) { 091 searchButtonHandler.actionPerformed(e); 092 _searchUIJPanel.setCancelButtonEnabled(true); 093 } 094 }); 095 /* 096 * _searchUIJPanel.setResetAction(new AbstractAction() { public void 097 * actionPerformed(ActionEvent e) { _searchUIJPanel.setSearchTerm(""); 098 * searchButtonHandler.actionPerformed(e); 099 * _searchUIJPanel.setCancelButtonEnabled(false); } }); 100 */ 101 _searchUIJPanel.setCancelAction(new AbstractAction() { 102 public void actionPerformed(ActionEvent e) { 103 _searchUIJPanel.setSearchTerm(""); 104 searchButtonHandler.actionPerformed(e); 105 _searchUIJPanel.setCancelButtonEnabled(false); 106 } 107 }); 108 // TODO: look up the initial tab from configuration (i18n) 109 _searchUIJPanel.setSourceAction(new PreferencesAction("Components")); 110 111 _searchUIJPanel.setAdvancedAction(new AbstractAction() { 112 public void actionPerformed(ActionEvent e) { 113 Object o = e.getSource(); 114 if (o instanceof Component) { 115 Window w = GUIUtil.getParentWindow((Component) o); 116 SearchConfigurationFrame scf = new SearchConfigurationFrame( 117 StaticResources.getDisplayString( 118 "components.search.configuration", 119 "Component Search Configuration")); 120 scf.setLocationRelativeTo(null); 121 scf.setVisible(true); 122 } 123 } 124 }); 125 126 _searchUIJPanel.init(); 127 128 this.add(_searchUIJPanel); 129 } 130 131 /** 132 * get the preferred/minimum width of this panel - calculated to allow 133 * enough space for all buttons and spacers etc 134 * 135 * @return the minimum allowable width of this panel 136 */ 137 public final int getMinimumWidth() { 138 return _searchUIJPanel.getMinimumWidth(); 139 } 140 141 public void closing() { 142 //System.out.println("SimpleSearchUIPane.closing()"); 143 _searchUIJPanel.closing(); 144 } 145}