Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv1806/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel
Modified Files:
SQLPanel.java
Added Files:
UndoHandlerImpl.java IUndoHandler.java
Log Message:
RSyntax editor integration
Index: SQLPanel.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLPanel.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** SQLPanel.java 25 Dec 2008 19:09:30 -0000 1.50
--- SQLPanel.java 29 Nov 2009 21:17:53 -0000 1.51
***************
*** 37,40 ****
--- 37,41 ----
import javax.swing.*;
+ import javax.swing.text.JTextComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
***************
*** 42,46 ****
import javax.swing.event.DocumentListener;
import javax.swing.event.EventListenerList;
- import javax.swing.undo.UndoManager;
import net.sourceforge.squirrel_sql.client.IApplication;
--- 43,46 ----
***************
*** 52,57 ****
import net.sourceforge.squirrel_sql.client.session.SQLPanelAPI;
import net.sourceforge.squirrel_sql.client.session.action.OpenSqlHistoryAction;
- import net.sourceforge.squirrel_sql.client.session.action.RedoAction;
- import net.sourceforge.squirrel_sql.client.session.action.UndoAction;
import net.sourceforge.squirrel_sql.client.session.event.IResultTabListener;
import net.sourceforge.squirrel_sql.client.session.event.ISQLExecutionListener;
--- 52,55 ----
***************
*** 67,71 ****
import net.sourceforge.squirrel_sql.fw.gui.MemoryComboBox;
import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
- import net.sourceforge.squirrel_sql.fw.util.Resources;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
--- 65,68 ----
***************
*** 105,109 ****
private IntegerField _nbrRows = new IntegerField();
- private JScrollPane _sqlEntryScroller;
transient private SqlComboListener _sqlComboListener = new SqlComboListener();
--- 102,105 ----
***************
*** 149,155 ****
private EventListenerList _listeners = new EventListenerList();
! private UndoManager _undoManager = new SquirrelDefaultUndoManager();
!
! /** Factory for generating unique IDs for new <TT>ResultTab</TT> objects. */
// private IntegerIdentifierFactory _idFactory = new IntegerIdentifierFactory();
--- 145,149 ----
private EventListenerList _listeners = new EventListenerList();
! /** Factory for generating unique IDs for new <TT>ResultTab</TT> objects. */
// private IntegerIdentifierFactory _idFactory = new IntegerIdentifierFactory();
***************
*** 162,167 ****
private static final String PREFS_KEY_SPLIT_DIVIDER_LOC = "squirrelSql_sqlPanel_divider_loc";
- private UndoAction _undoAction;
- private RedoAction _redoAction;
/**
--- 156,159 ----
***************
*** 172,175 ****
--- 164,168 ----
transient private SQLPanel.SQLExecutorHistoryListener _sqlExecutorHistoryListener = new SQLExecutorHistoryListener();
private ArrayList<SqlPanelListener> _sqlPanelListeners = new ArrayList<SqlPanelListener>();
+ private IUndoHandler _undoHandler;
***************
*** 444,480 ****
final int pos = _splitPane.getDividerLocation();
- if (!_sqlEntry.getDoesTextComponentHaveScroller())
- {
- _sqlEntryScroller = new JScrollPane(_sqlEntry.getTextComponent());
- _sqlEntryScroller.setBorder(BorderFactory.createEmptyBorder());
- _splitPane.add(_sqlEntryScroller);
- }
- else
- {
- _splitPane.add(_sqlEntry.getTextComponent(), JSplitPane.LEFT);
- }
- _splitPane.setDividerLocation(pos);
! if (!_sqlEntry.hasOwnUndoableManager())
! {
! IApplication app = _session.getApplication();
! Resources res = app.getResources();
! _undoAction = new UndoAction(app, _undoManager);
! _redoAction = new RedoAction(app, _undoManager);
- JComponent comp = _sqlEntry.getTextComponent();
- comp.registerKeyboardAction(_undoAction, res.getKeyStroke(_undoAction),
- WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- comp.registerKeyboardAction(_redoAction, res.getKeyStroke(_redoAction),
- WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- _sqlEntry.setUndoActions(_undoAction, _redoAction);
! _sqlEntry.setUndoManager(_undoManager);
! }
fireSQLEntryAreaInstalled();
}
-
public void setVisible(boolean value)
{
--- 437,462 ----
final int pos = _splitPane.getDividerLocation();
! JScrollPane scrollPane = _sqlEntry.createScrollPane(_sqlEntry.getTextComponent());
! _splitPane.add(scrollPane);
!
! // if (!_sqlEntry.getDoesTextComponentHaveScroller())
! // {
! // JScrollPane sqlEntryScroller = createScrollPane(_sqlEntry.getTextComponent());
! // _splitPane.add(sqlEntryScroller);
! // }
! // else
! // {
! // _splitPane.add(_sqlEntry.getTextComponent(), JSplitPane.LEFT);
! // }
! _splitPane.setDividerLocation(pos);
!
! _undoHandler = new UndoHandlerImpl(_session.getApplication(), _sqlEntry);
fireSQLEntryAreaInstalled();
}
public void setVisible(boolean value)
{
***************
*** 947,956 ****
public Action getUndoAction()
{
! return _undoAction;
}
public Action getRedoAction()
{
! return _redoAction;
}
--- 929,938 ----
public Action getUndoAction()
{
! return _undoHandler.getUndoAction();
}
public Action getRedoAction()
{
! return _undoHandler.getRedoAction();
}
--- NEW FILE: IUndoHandler.java ---
package net.sourceforge.squirrel_sql.client.session.mainpanel;
import javax.swing.*;
/**
* Created by IntelliJ IDEA.
* User: gerd
* Date: 20.10.2009
* Time: 13:37:21
* To change this template use File | Settings | File Templates.
*/
public interface IUndoHandler
{
Action getUndoAction();
Action getRedoAction();
}
--- NEW FILE: UndoHandlerImpl.java ---
package net.sourceforge.squirrel_sql.client.session.mainpanel;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanel;
import net.sourceforge.squirrel_sql.client.session.action.UndoAction;
import net.sourceforge.squirrel_sql.client.session.action.RedoAction;
import net.sourceforge.squirrel_sql.fw.util.Resources;
import javax.swing.*;
public class UndoHandlerImpl implements IUndoHandler
{
private UndoAction _undoAction;
private RedoAction _redoAction;
public UndoHandlerImpl(IApplication application, ISQLEntryPanel entry)
{
if (!entry.hasOwnUndoableManager())
{
SquirrelDefaultUndoManager undoManager = new SquirrelDefaultUndoManager();
Resources res = application.getResources();
_undoAction = new UndoAction(application, undoManager);
_redoAction = new RedoAction(application, undoManager);
JComponent comp = entry.getTextComponent();
comp.registerKeyboardAction(_undoAction, res.getKeyStroke(_undoAction),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
comp.registerKeyboardAction(_redoAction, res.getKeyStroke(_redoAction),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
entry.setUndoManager(undoManager);
}
else
{
IUndoHandler undoHandler = entry.createUndoHandler();
_undoAction = new UndoAction(application, undoHandler.getUndoAction());
_redoAction = new RedoAction(application, undoHandler.getRedoAction());
}
entry.addRedoUndoActionsToSQLEntryAreaMenu(_undoAction, _redoAction);
}
public Action getUndoAction()
{
return _undoAction;
}
public Action getRedoAction()
{
return _redoAction;
}
}
|