Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv1806/app/src/net/sourceforge/squirrel_sql/client/session
Modified Files:
ISyntaxHighlightTokenMatcherFactory.java
ISyntaxHighlightTokenMatcher.java BaseSQLEntryPanel.java
ISQLEntryPanel.java
Added Files:
SQLEntryPanelUtil.java
Log Message:
RSyntax editor integration
Index: BaseSQLEntryPanel.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/BaseSQLEntryPanel.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** BaseSQLEntryPanel.java 31 Jul 2007 01:01:24 -0000 1.20
--- BaseSQLEntryPanel.java 29 Nov 2009 21:17:54 -0000 1.21
***************
*** 6,16 ****
import java.awt.event.MouseListener;
! import javax.swing.Action;
! import javax.swing.JMenu;
! import javax.swing.JMenuItem;
! import javax.swing.SwingUtilities;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.session.action.ViewObjectAtCursorInObjectTreeAction;
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
import net.sourceforge.squirrel_sql.fw.gui.TextPopupMenu;
--- 6,15 ----
import java.awt.event.MouseListener;
! import javax.swing.*;
! import javax.swing.text.JTextComponent;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.session.action.ViewObjectAtCursorInObjectTreeAction;
+ import net.sourceforge.squirrel_sql.client.session.mainpanel.IUndoHandler;
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
import net.sourceforge.squirrel_sql.fw.gui.TextPopupMenu;
***************
*** 317,324 ****
}
! /**
! * @see ISQLEntryPanel#setUndoActions(javax.swing.Action, javax.swing.Action)
*/
! public void setUndoActions(Action undo, Action redo)
{
_textPopupMenu.addSeparator();
--- 316,323 ----
}
! /**
! * @see ISQLEntryPanel#addRedoUndoActionsToSQLEntryAreaMenu(javax.swing.Action, javax.swing.Action)
*/
! public void addRedoUndoActionsToSQLEntryAreaMenu(Action undo, Action redo)
{
_textPopupMenu.addSeparator();
***************
*** 335,338 ****
--- 334,350 ----
}
+ @Override
+ public boolean hasOwnUndoableManager()
+ {
+ return false;
+ }
+
+ @Override
+ public IUndoHandler createUndoHandler()
+ {
+ return null;
+ }
+
+
public void dispose()
{
***************
*** 340,344 ****
}
! private final class MyMouseListener extends MouseAdapter
{
public void mousePressed(MouseEvent evt)
--- 352,372 ----
}
! @Override
! public String getWordAtCursor()
! {
! int[] beginAndEndPos = SQLEntryPanelUtil.getWordBoundsAtCursor(getTextComponent(), true);
! return getTextComponent().getText().substring(beginAndEndPos[0], beginAndEndPos[1]).trim();
! }
!
! @Override
! public JScrollPane createScrollPane(JTextComponent textComponent)
! {
! JScrollPane sqlEntryScroller = new JScrollPane(textComponent);
! sqlEntryScroller.setBorder(BorderFactory.createEmptyBorder());
! return sqlEntryScroller;
! }
!
!
! private final class MyMouseListener extends MouseAdapter
{
public void mousePressed(MouseEvent evt)
--- NEW FILE: SQLEntryPanelUtil.java ---
package net.sourceforge.squirrel_sql.client.session;
import javax.swing.text.JTextComponent;
public class SQLEntryPanelUtil
{
public static int[] getWordBoundsAtCursor(JTextComponent textComponent, boolean qualified)
{
String text = textComponent.getText();
int caretPos = textComponent.getCaretPosition();
int[] beginAndEndPos = new int[2];
int lastIndexOfText = Math.max(0,text.length()-1);
beginAndEndPos[0] = Math.min(caretPos, lastIndexOfText); // The Math.min is for the Caret at the end of the text
while(0 < beginAndEndPos[0])
{
if(isParseStop(text.charAt(beginAndEndPos[0] - 1), false == qualified))
{
break;
}
--beginAndEndPos[0];
}
beginAndEndPos[1] = caretPos;
while(beginAndEndPos[1] < text.length() && false == isParseStop(text.charAt(beginAndEndPos[1]), true))
{
++beginAndEndPos[1];
}
return beginAndEndPos;
}
static boolean isParseStop(char c, boolean treatDotAsStop)
{
return
'(' == c ||
')' == c ||
',' == c ||
';' == c ||
'\'' == c ||
Character.isWhitespace(c) ||
(treatDotAsStop && '.' == c);
}
}
Index: ISQLEntryPanel.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/ISQLEntryPanel.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ISQLEntryPanel.java 13 Sep 2007 22:14:47 -0000 1.13
--- ISQLEntryPanel.java 29 Nov 2009 21:17:54 -0000 1.14
***************
*** 21,28 ****
import java.awt.event.MouseListener;
! import javax.swing.Action;
! import javax.swing.JComponent;
! import javax.swing.JMenu;
! import javax.swing.JMenuItem;
import javax.swing.text.JTextComponent;
import javax.swing.event.CaretListener;
--- 21,25 ----
import java.awt.event.MouseListener;
! import javax.swing.*;
import javax.swing.text.JTextComponent;
import javax.swing.event.CaretListener;
***************
*** 31,34 ****
--- 28,32 ----
import net.sourceforge.squirrel_sql.fw.id.IHasIdentifier;
+ import net.sourceforge.squirrel_sql.client.session.mainpanel.IUndoHandler;
public interface ISQLEntryPanel extends IHasIdentifier
***************
*** 154,157 ****
--- 152,163 ----
boolean hasOwnUndoableManager();
+ /**
+ * Will only be called if hasOwnUndoableManager() returns true
+ */
+ IUndoHandler createUndoHandler();
+
+ /**
+ * Will only be called if hasOwnUndoableManager() returns false
+ */
void setUndoManager(UndoManager manager);
***************
*** 160,164 ****
void removeUndoableEditListener(UndoableEditListener listener);
! void setUndoActions(Action undo, Action redo);
void addCaretListener(CaretListener lis);
--- 166,170 ----
void removeUndoableEditListener(UndoableEditListener listener);
! void addRedoUndoActionsToSQLEntryAreaMenu(Action undo, Action redo);
void addCaretListener(CaretListener lis);
***************
*** 171,173 ****
--- 177,183 ----
ISession getSession();
+
+ String getWordAtCursor();
+
+ JScrollPane createScrollPane(JTextComponent textComponent);
}
Index: ISyntaxHighlightTokenMatcher.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/ISyntaxHighlightTokenMatcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ISyntaxHighlightTokenMatcher.java 25 Jul 2007 23:33:41 -0000 1.1
--- ISyntaxHighlightTokenMatcher.java 29 Nov 2009 21:17:54 -0000 1.2
***************
*** 3,6 ****
--- 3,8 ----
public interface ISyntaxHighlightTokenMatcher
{
+ boolean isError(int offset, int len);
+
boolean isTable(char[] buffer, int offset, int len);
Index: ISyntaxHighlightTokenMatcherFactory.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/ISyntaxHighlightTokenMatcherFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ISyntaxHighlightTokenMatcherFactory.java 25 Jul 2007 23:33:41 -0000 1.1
--- ISyntaxHighlightTokenMatcherFactory.java 29 Nov 2009 21:17:54 -0000 1.2
***************
*** 2,8 ****
import javax.swing.*;
public interface ISyntaxHighlightTokenMatcherFactory
{
! public ISyntaxHighlightTokenMatcher getSyntaxHighlightTokenMatcher(ISession sess, JEditorPane editorPane);
}
--- 2,9 ----
import javax.swing.*;
+ import javax.swing.text.JTextComponent;
public interface ISyntaxHighlightTokenMatcherFactory
{
! public ISyntaxHighlightTokenMatcher getSyntaxHighlightTokenMatcher(ISession sess, JTextComponent editorPane);
}
|