public class FindAction extends SquirrelAction implements ISQLPanelAction { private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(FindAction.class); private ISession _session; private ISQLEntryPanel _sqlEntryPanel; public FindAction(IApplication app, SyntaxPluginResources rsrc, ISQLEntryPanel sqlEntryPanel) { this(app, rsrc); _sqlEntryPanel = sqlEntryPanel; } public FindAction(IApplication app, SyntaxPluginResources rsrc) { super(app, rsrc); } public void actionPerformed(ActionEvent evt) { if(null != _sqlEntryPanel) { doActionPerformed(_sqlEntryPanel, evt); } else if(null != _session) { ISQLEntryPanel sqlEntryPanel = _session.getSQLPanelAPIOfActiveSessionWindow().getSQLEntryPanel(); doActionPerformed(sqlEntryPanel, evt); } } private void doActionPerformed(ISQLEntryPanel sqlEntryPanel, ActionEvent evt) { if(false == sqlEntryPanel instanceof NetbeansSQLEntryPanel) { String msg = //i18n[syntax.findNetbeansOnly=Find is only available when the Netbeans editor is used.\nSee menu File --> New Session Properties --> Tab Syntax] s_stringMgr.getString("syntax.findNetbeansOnly"); JOptionPane.showMessageDialog(_session.getApplication().getMainFrame(), msg); return; } NetbeansSQLEntryPanel nsep = (NetbeansSQLEntryPanel) sqlEntryPanel; nsep.showFindDialog(evt); } public void setSQLPanel(ISQLPanelAPI panel) { if(null != panel) { _session = panel.getSession(); } else { _session = null; } setEnabled(null != _session)
public class ReplaceAction extends SquirrelAction implements ISQLPanelAction { private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(ReplaceAction.class); private ISession _session; private ISQLEntryPanel _isqlEntryPanel; public ReplaceAction(IApplication app, SyntaxPluginResources rsrc) throws IllegalArgumentException { super(app, rsrc); } public ReplaceAction(IApplication app, SyntaxPluginResources rsrc, ISQLEntryPanel isqlEntryPanel) { this(app, rsrc); _isqlEntryPanel = isqlEntryPanel; } public void actionPerformed(ActionEvent evt) { if(null != _isqlEntryPanel) { doActionPerformed(_isqlEntryPanel, evt); } if(null != _session) { ISQLEntryPanel sqlEntryPanel = _session.getSQLPanelAPIOfActiveSessionWindow().getSQLEntryPanel(); doActionPerformed(sqlEntryPanel, evt); } } private void doActionPerformed(ISQLEntryPanel sqlEntryPanel, ActionEvent evt) { if(false == sqlEntryPanel instanceof NetbeansSQLEntryPanel) { String msg = //i18n[syntax.replaceNetbeansOnly=Replace is only available when the Netbeans editor is used.\nSee menu File --> New Session Properties --> Tab Syntax] s_stringMgr.getString("syntax.replaceNetbeansOnly"); JOptionPane.showMessageDialog(_session.getApplication().getMainFrame(), msg); return; } NetbeansSQLEntryPanel nsep = (NetbeansSQLEntryPanel) sqlEntryPanel; nsep.showReplaceDialog(evt); } public void setSQLPanel(ISQLPanelAPI panel) { if(null != panel) { _session = panel.getSession(); } else { _session = null; } setEnabled(null != _session)
Clone fragments detected by clone detection tool
File path: /sql12/plugins/syntax/src/net/sourceforge/squirrel_sql/plugins/syntax/netbeans/FindAction.java File path: /sql12/plugins/syntax/src/net/sourceforge/squirrel_sql/plugins/syntax/netbeans/ReplaceAction.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class FindAction extends SquirrelAction implements ISQLPanelAction
1
public class ReplaceAction extends SquirrelAction implements ISQLPanelAction
2
{
2
{
3
	private static final StringManager s_stringMgr =
3
	private static final StringManager s_stringMgr =
4
		StringManagerFactory.getStringManager(FindAction.class);
4
		StringManagerFactory.getStringManager(ReplaceAction.class);
5
   private ISession _session;
5
   private ISession _session;
6
   private ISQLEntryPanel _sqlEntryPanel;
6
   private ISQLEntryPanel _isqlEntryPanel;
7
   public FindAction(IApplication app, SyntaxPluginResources rsrc, ISQLEntryPanel sqlEntryPanel)
7
   public ReplaceAction(IApplication app, SyntaxPluginResources rsrc)
8
			throws IllegalArgumentException
8
	{
9
	{
9
		this(app, rsrc);
10
		super(app, rsrc);
10
      _sqlEntryPanel = sqlEntryPanel;
11
   }
11
	}
12
   public FindAction(IApplication app, SyntaxPluginResources rsrc)
12
   public ReplaceAction(IApplication app, SyntaxPluginResources rsrc
13
	{
14
		super(app, rsrc);
15
	}
16
   
13
, ISQLEntryPanel isqlEntryPanel)
14
   {
15
      this(app, rsrc);
16
      _isqlEntryPanel = isqlEntryPanel;
17
   }
17
   public void actionPerformed(ActionEvent evt)
18
   public void actionPerformed(ActionEvent evt)
18
	{
19
	{
19
      if(null != _sqlEntryPanel)
20
      if(null != _isqlEntryPanel)
20
      {
21
      {
21
         doActionPerformed(_sqlEntryPanel, evt);
22
         doActionPerformed(_isqlEntryPanel, evt);
22
      }
23
      }
23
      else if(null != _session)
24
      if(null != _session)
24
      {
25
      {
25
         ISQLEntryPanel sqlEntryPanel = _session.getSQLPanelAPIOfActiveSessionWindow().getSQLEntryPanel();
26
         ISQLEntryPanel sqlEntryPanel = _session.getSQLPanelAPIOfActiveSessionWindow().getSQLEntryPanel();
26
         doActionPerformed(sqlEntryPanel, evt);
27
         doActionPerformed(sqlEntryPanel, evt);
27
      }
28
      }
28
	}
29
	}
29
   private void doActionPerformed(ISQLEntryPanel sqlEntryPanel, ActionEvent evt)
30
   private void doActionPerformed(ISQLEntryPanel sqlEntryPanel, ActionEvent evt)
30
   {
31
   {
31
      if(false == sqlEntryPanel instanceof NetbeansSQLEntryPanel)
32
      if(false == sqlEntryPanel instanceof NetbeansSQLEntryPanel)
32
      {
33
      {
33
         String msg =
34
         String msg =
34
            //i18n[syntax.findNetbeansOnly=Find is only available when the Netbeans editor is used.\nSee menu File --> New Session Properties --> Tab Syntax]
35
            //i18n[syntax.replaceNetbeansOnly=Replace is only available when the Netbeans editor is used.\nSee menu File --> New Session Properties --> Tab Syntax]
35
            s_stringMgr.getString("syntax.findNetbeansOnly");
36
            s_stringMgr.getString("syntax.replaceNetbeansOnly");
36
         JOptionPane.showMessageDialog(_session.getApplication().getMainFrame(), msg);
37
         JOptionPane.showMessageDialog(_session.getApplication().getMainFrame(), msg);
37
         return;
38
         return;
38
      }
39
      }
39
      NetbeansSQLEntryPanel nsep = (NetbeansSQLEntryPanel) sqlEntryPanel;
40
      NetbeansSQLEntryPanel nsep = (NetbeansSQLEntryPanel) sqlEntryPanel;
40
      nsep.showFindDialog(evt);
41
      nsep.showReplaceDialog(evt);
41
   }
42
   }
42
   public void setSQLPanel(ISQLPanelAPI panel)
43
   public void setSQLPanel(ISQLPanelAPI panel)
43
   {
44
   {
44
      if(null != panel)
45
      if(null != panel)
45
      {
46
      {
46
         _session = panel.getSession();
47
         _session = panel.getSession();
47
      }
48
      }
48
      else
49
      else
49
      {
50
      {
50
         _session = null;
51
         _session = null;
51
      }
52
      }
52
      setEnabled(null != _session)
53
      setEnabled(null != _session)
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0