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.Component;
27 import java.awt.event.ActionEvent;
28
29 import javax.swing.AbstractAction;
30
31 import com.mindtree.techworks.insight.Controller;
32 import com.mindtree.techworks.insight.InsightConstants;
33 import com.mindtree.techworks.insight.eventsearch.SearchResults;
34 import com.mindtree.techworks.insight.gui.widgets.StatusBar;
35
36 /**
37 *
38 * The <code>SearchEventAction</code> class is an AbstractAction derivative that
39 * lets the user navigate to the next or previous match after a search
40 * for matching events has been performed.
41 *
42 * @see com.mindtree.techworks.insight.gui.search.SearchEventsFrame
43 *
44 * @author Regunath B, Bindul Bhowmik
45 * @version $Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
46 */
47
48 public class SearchEventAction extends AbstractAction {
49
50 /**
51 * Used for object serialization
52 */
53 private static final long serialVersionUID = -5522452616976339844L;
54
55 /**
56 * The Controller instance
57 */
58 private Controller controller;
59
60 /**
61 * Private instance for the class
62 */
63 private static SearchEventAction instance;
64
65 /**
66 * Constructor for this class
67 * @param controller the Insight that created an instance of this class
68 */
69 private SearchEventAction(Controller controller) {
70 this.controller = controller;
71 }
72
73 /**
74 * Returns an instance for the class
75 * @param controller controller the Insight that created an instance of this class
76 * @return The instance
77 */
78 public static synchronized SearchEventAction getInstance(Controller controller) {
79 if (null == instance) {
80 instance = new SearchEventAction(controller);
81 }
82 return instance;
83 }
84
85 /**
86 * Overriden super class method. Resets the display widgets.
87 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
88 */
89 public void actionPerformed(ActionEvent e) {
90 String direction = ((Component)e.getSource()).getName();
91 SearchResults searchResults = controller.getCurrentLogEventModel().getSearchResults();
92 if (null != searchResults) {
93 searchResults.navigate(direction);
94 } else {
95 StatusBar.getInstance().setDisplayText(0, InsightConstants.getLiteral("NO_SEARCH_RESULTS"), false);
96 }
97 }
98 }