View Javadoc

1   /*
2    * $HeadURL: $
3    * $Date: $
4    * $Revision: $
5    * $Author: $
6    * 
7    * Copyright (c) 2005 MindTree Consulting Ltd. 
8    * 
9    * This file is part of Insight.
10   * 
11   * Insight is free software: you can redistribute it and/or modify it under the 
12   * terms of the GNU General Public License as published by the Free Software 
13   * Foundation, either version 3 of the License, or (at your option) any later 
14   * version.
15   * 
16   * Insight is distributed in the hope that it will be useful, but 
17   * WITHOUT ANY WARRANTY; without even the implied warranty of 
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
19   * Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public License along with 
22   * Insight.  If not, see <http://www.gnu.org/licenses/>.
23   */
24  package com.mindtree.techworks.insight.gui.action;
25  
26  import java.awt.event.ActionEvent;
27  
28  import javax.swing.AbstractAction;
29  
30  import com.mindtree.techworks.insight.gui.EventDetailsPresentation;
31  import com.mindtree.techworks.insight.gui.Insight;
32  import com.mindtree.techworks.insight.gui.search.SearchTextFrame;
33  
34  /**
35  *
36  * The <code>FindAction</code> class is an AbstractAction derivative that
37  * permits searching for text in the Event Details presentation
38  *
39  * @author  Regunath B
40  * @version 1.0, 05/02/04
41  * @see     com.mindtree.techworks.insight.gui.Insight
42  */
43  
44  public class FindAction extends AbstractAction {
45  
46  	/**
47  	 * Used for object serialization
48  	 */
49  	private static final long serialVersionUID = -5547331394914513885L;
50  
51  	/**
52  	 * The Insight instance that created this Action instance
53  	 */
54  	private Insight insight;
55  	
56  	/**
57  	 * Singleton instance of this class
58  	 */
59  	private static FindAction instance;
60  	
61  	/**
62  	 * The SearchTextFrame for text search on the Event Details presentation
63  	 */
64  	private SearchTextFrame searchTextFrame;
65  	
66  	/**
67  	 * Private constructor for this class to prevent multiple instances
68  	 * @param insight the Insight that created an instance of this class
69  	 * @see #getInstance() to get instance of this class
70  	 */
71  	private FindAction(Insight insight) {
72  		this.insight = insight;		
73  	}
74  
75  	/**
76  	 * Accessor method for getting the singleton instance of this class
77  	 * @param insight the Insight that created an instance of this class
78  	 * @return the singleton instance of this class
79  	 */
80  	public static synchronized FindAction getInstance(Insight insight) {
81  		if (instance == null) {
82  			instance = new FindAction(insight);
83  		}
84  		return instance;
85  	}
86  	
87  	/**
88  	 * Overriden super class method. Resets the display widgets.
89  	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
90  	 */
91  	public void actionPerformed(ActionEvent e) {
92  		showSearchTextFrame();
93  	}
94  	
95  	/**
96  	 * Method to programmatically bring up the search text frame
97  	 */
98  	public void showSearchTextFrame() {
99  		if (this.searchTextFrame == null) {
100 			this.searchTextFrame = new SearchTextFrame(this.insight,
101 					(EventDetailsPresentation)this.insight.getController().getPresentation(EventDetailsPresentation.class.getName()));
102 		}
103 		this.searchTextFrame.showFrame();		
104 	}
105 	
106 }