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.InsightConstants;
31 import com.mindtree.techworks.insight.gui.EventDetailsPresentation;
32 import com.mindtree.techworks.insight.gui.Insight;
33 import com.mindtree.techworks.insight.gui.search.SearchEventsFrame;
34 import com.mindtree.techworks.insight.gui.widgets.StatusBar;
35 import com.mindtree.techworks.insight.model.LogEventModel;
36
37 /**
38 *
39 * The <code>SearchAction</code> class is an AbstractAction derivative that
40 * permits searching for events that match a search criteria
41 *
42 * @author Regunath B
43 * @version 1.0, 05/02/04
44 * @see com.mindtree.techworks.insight.gui.Insight
45 */
46
47 public class SearchAction extends AbstractAction {
48
49 /**
50 * Used for object serialization
51 */
52 private static final long serialVersionUID = 4584447553037887774L;
53
54 /**
55 * The Insight instance that created this Action instance
56 */
57 private Insight insight;
58
59 /**
60 * Singleton instance of this class
61 */
62 private static SearchAction instance;
63
64 /**
65 * The SearchEventsFrame for text search on the Event attributes across the entire
66 * active pageset
67 */
68 private SearchEventsFrame searchEventsFrame;
69
70 /**
71 * Private constructor for this class to prevent multiple instances
72 * @param insight the Insight that created an instance of this class
73 * @see #getInstance(Insight) to get instance of this class
74 */
75 private SearchAction(Insight insight) {
76 this.insight = insight;
77 }
78
79 /**
80 * Accessor method for getting the singleton instance of this class
81 * @param insight the Insight that created an instance of this class
82 * @return the singleton instance of this class
83 */
84 public static synchronized SearchAction getInstance(Insight insight) {
85 if (instance == null) {
86 instance = new SearchAction(insight);
87 }
88 return instance;
89 }
90
91 /**
92 * Overriden super class method. Resets the display widgets.
93 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
94 */
95 public void actionPerformed(ActionEvent e) {
96 LogEventModel logEventModel = insight.getController().getCurrentLogEventModel();
97 if(logEventModel != null) {
98 if (this.searchEventsFrame == null) {
99 this.searchEventsFrame = new SearchEventsFrame(this.insight,
100 (EventDetailsPresentation)this.insight.getController().getPresentation(EventDetailsPresentation.class.getName()));
101 }
102 this.searchEventsFrame.showFrame();
103 } else {
104 StatusBar.getInstance().setDisplayText(0,InsightConstants.getLiteral("ERROR_NO_MODEL_LOADED"), false);
105 }
106 }
107
108 }