Package net.sourceforge.squirrel_sql.plugins.syntax

Source Code of net.sourceforge.squirrel_sql.plugins.syntax.RepeatLastFindAction

package net.sourceforge.squirrel_sql.plugins.syntax;

import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanel;
import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.action.ISQLPanelAction;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.RSyntaxSQLEntryPanel;
import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.SquirrelRSyntaxTextArea;

import javax.swing.*;
import java.awt.event.ActionEvent;

public class RepeatLastFindAction extends SquirrelAction implements ISQLPanelAction
{
  private static final StringManager s_stringMgr =
    StringManagerFactory.getStringManager(RepeatLastFindAction.class);


   private ISession _session;
   private ISQLEntryPanel _sqlEntryPanel;

   public RepeatLastFindAction(IApplication app, SyntaxPluginResources rsrc, ISQLEntryPanel sqlEntryPanel)
  {
    this(app, rsrc);
      _sqlEntryPanel = sqlEntryPanel;
   }

   public RepeatLastFindAction(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(sqlEntryPanel instanceof RSyntaxSQLEntryPanel)
      {
         SquirrelRSyntaxTextArea rsep = (SquirrelRSyntaxTextArea) sqlEntryPanel.getTextComponent();
         rsep.repeatLastFind(evt);
      }
      else
      {
         String msg = s_stringMgr.getString("syntax.repeatLastfindOnlyOnRecommendedEditors");
         JOptionPane.showMessageDialog(_session.getApplication().getMainFrame(), msg);
      }

   }

   public void setSQLPanel(ISQLPanelAPI panel)
   {
      if(null != panel)
      {
         _session = panel.getSession();
      }
      else
      {
         _session = null;
      }
      setEnabled(null != _session);
   }
}
TOP

Related Classes of net.sourceforge.squirrel_sql.plugins.syntax.RepeatLastFindAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.