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 ReplaceAction extends SquirrelAction implements
20: ISQLPanelAction {
21: private static final StringManager s_stringMgr = StringManagerFactory
22: .getStringManager(ReplaceAction.class);
23:
24: private ISession _session;
25: private ISQLEntryPanel _isqlEntryPanel;
26:
27: public ReplaceAction(IApplication app, SyntaxPluginResources rsrc)
28: throws IllegalArgumentException {
29: super (app, rsrc);
30: }
31:
32: public ReplaceAction(IApplication app, SyntaxPluginResources rsrc,
33: ISQLEntryPanel isqlEntryPanel) {
34: this (app, rsrc);
35: _isqlEntryPanel = isqlEntryPanel;
36: }
37:
38: public void actionPerformed(ActionEvent evt) {
39: if (null != _isqlEntryPanel) {
40: doActionPerformed(_isqlEntryPanel, evt);
41: }
42: if (null != _session) {
43: ISQLEntryPanel sqlEntryPanel = _session
44: .getSQLPanelAPIOfActiveSessionWindow()
45: .getSQLEntryPanel();
46: doActionPerformed(sqlEntryPanel, evt);
47: }
48: }
49:
50: private void doActionPerformed(ISQLEntryPanel sqlEntryPanel,
51: ActionEvent evt) {
52: if (false == sqlEntryPanel instanceof NetbeansSQLEntryPanel) {
53: String msg =
54: //i18n[syntax.replaceNetbeansOnly=Replace is only available when the Netbeans editor is used.\nSee menu File --> New Session Properties --> Tab Syntax]
55: s_stringMgr.getString("syntax.replaceNetbeansOnly");
56: JOptionPane.showMessageDialog(_session.getApplication()
57: .getMainFrame(), msg);
58: return;
59: }
60:
61: NetbeansSQLEntryPanel nsep = (NetbeansSQLEntryPanel) sqlEntryPanel;
62: nsep.showReplaceDialog(evt);
63: }
64:
65: public void setSQLPanel(ISQLPanelAPI panel) {
66: if (null != panel) {
67: _session = panel.getSession();
68: } else {
69: _session = null;
70: }
71: setEnabled(null != _session);
72: }
73: }
|