01: package net.sourceforge.squirrel_sql.plugins.syntax.netbeans;
02:
03: import net.sourceforge.squirrel_sql.client.IApplication;
04: import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
05: import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
06: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
07: import net.sourceforge.squirrel_sql.client.session.ISession;
08: import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanel;
09: import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
10: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
11: import net.sourceforge.squirrel_sql.client.session.action.ISQLPanelAction;
12: import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxPluginResources;
13: import net.sourceforge.squirrel_sql.fw.util.StringManager;
14: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
15:
16: import javax.swing.*;
17: import java.awt.event.ActionEvent;
18:
19: public class FindAction extends SquirrelAction implements
20: ISQLPanelAction {
21: private static final StringManager s_stringMgr = StringManagerFactory
22: .getStringManager(FindAction.class);
23:
24: private ISession _session;
25: private ISQLEntryPanel _sqlEntryPanel;
26:
27: public FindAction(IApplication app, SyntaxPluginResources rsrc,
28: ISQLEntryPanel sqlEntryPanel) {
29: this (app, rsrc);
30: _sqlEntryPanel = sqlEntryPanel;
31: }
32:
33: public FindAction(IApplication app, SyntaxPluginResources rsrc) {
34: super (app, rsrc);
35: }
36:
37: public void actionPerformed(ActionEvent evt) {
38: if (null != _sqlEntryPanel) {
39: doActionPerformed(_sqlEntryPanel, evt);
40: } else if (null != _session) {
41: ISQLEntryPanel sqlEntryPanel = _session
42: .getSQLPanelAPIOfActiveSessionWindow()
43: .getSQLEntryPanel();
44: doActionPerformed(sqlEntryPanel, evt);
45: }
46:
47: }
48:
49: private void doActionPerformed(ISQLEntryPanel sqlEntryPanel,
50: ActionEvent evt) {
51: if (false == sqlEntryPanel instanceof NetbeansSQLEntryPanel) {
52: String msg =
53: //i18n[syntax.findNetbeansOnly=Find is only available when the Netbeans editor is used.\nSee menu File --> New Session Properties --> Tab Syntax]
54: s_stringMgr.getString("syntax.findNetbeansOnly");
55: JOptionPane.showMessageDialog(_session.getApplication()
56: .getMainFrame(), msg);
57: return;
58: }
59:
60: NetbeansSQLEntryPanel nsep = (NetbeansSQLEntryPanel) sqlEntryPanel;
61: nsep.showFindDialog(evt);
62: }
63:
64: public void setSQLPanel(ISQLPanelAPI panel) {
65: if (null != panel) {
66: _session = panel.getSession();
67: } else {
68: _session = null;
69: }
70: setEnabled(null != _session);
71: }
72: }
|