public int[] getBoundsOfSQLToBeExecuted() { int[] bounds = new int[2]; bounds[0] = getSelectionStart(); bounds[1] = getSelectionEnd(); if(bounds[0] == bounds[1]) { bounds = getSqlBoundsBySeparatorRule(getCaretPosition()); } return bounds; }
/** * The non selection separator is two new lines. Two new lines with white spaces in between * is counted as separator too. * @return */ private int[] getSqlBoundsBySeparatorRule(int iCaretPos) { int[] bounds = new int[2]; String sql = getText(); bounds[0] = lastIndexOfStateSep(sql, iCaretPos); bounds[1] = indexOfStateSep(sql, iCaretPos); return bounds; }
public void selectCurrentSql() { int[] boundsOfSQLToBeExecuted = getSqlBoundsBySeparatorRule(getCaretPosition()); if(boundsOfSQLToBeExecuted[0] != boundsOfSQLToBeExecuted[1]) { setSelectionStart(boundsOfSQLToBeExecuted[0]); setSelectionEnd(boundsOfSQLToBeExecuted[1]); } }
public void moveCaretToPreviousSQLBegin() { String sql = getText(); int iCaretPos = getCaretPosition() - 1; int iLastIndex = sql.lastIndexOf(SQL_STMT_SEP, iCaretPos); if(-1 == iLastIndex) { return; } iLastIndex = sql.lastIndexOf(SQL_STMT_SEP, iLastIndex - getWhiteSpaceCountBackwards(iLastIndex, sql)); if(-1 == iLastIndex) { iLastIndex = 0; } char c = sql.charAt(iLastIndex); while(Character.isWhitespace(c) && iLastIndex < sql.length()) { ++iLastIndex; c = sql.charAt(iLastIndex); } setCaretPosition(iLastIndex); }
public String getSQLToBeExecuted() { String sql = getSelectedText(); if (sql == null || sql.trim().length() == 0) { sql = getText(); int[] bounds = getBoundsOfSQLToBeExecuted(); if(bounds[0] >= bounds[1]) { sql = ""; } else { sql = sql.substring(bounds[0], bounds[1]).trim(); } } return sql != null ? sql : ""; }
public void moveCaretToNextSQLBegin() { String sql = getText(); int iCaretPos = getCaretPosition(); int iNextIndex = sql.indexOf(SQL_STMT_SEP, iCaretPos); if(-1 == iNextIndex) { return; } while(iNextIndex < sql.length() && Character.isWhitespace(sql.charAt(iNextIndex))) { ++iNextIndex; } if(iNextIndex < sql.length()) { setCaretPosition(iNextIndex); } }
@Override public String getWordAtCursor() { int[] beginAndEndPos = SQLEntryPanelUtil.getWordBoundsAtCursor(getTextComponent(), true); return getTextComponent().getText().substring(beginAndEndPos[0], beginAndEndPos[1]).trim(); }
/** * @see ISQLEntryPanel#addRedoUndoActionsToSQLEntryAreaMenu(javax.swing.Action, javax.swing.Action) */ public void addRedoUndoActionsToSQLEntryAreaMenu(Action undo, Action redo) { _textPopupMenu.addSeparator(); JMenuItem buf; buf = addToSQLEntryAreaMenu(undo); _app.getResources().configureMenuItem(undo, buf); buf = addToSQLEntryAreaMenu(redo); _app.getResources().configureMenuItem(redo, buf); _textPopupMenu.addSeparator(); }
public void selectCurrentSql() { int[] boundsOfSQLToBeExecuted = getSqlBoundsBySeparatorRule(getCaretPosition()); if(boundsOfSQLToBeExecuted[0] != boundsOfSQLToBeExecuted[1]) { setSelectionStart(boundsOfSQLToBeExecuted[0]); setSelectionEnd(boundsOfSQLToBeExecuted[1]); } }
public void moveCaretToPreviousSQLBegin() { String sql = getText(); int iCaretPos = getCaretPosition() - 1; int iLastIndex = sql.lastIndexOf(SQL_STMT_SEP, iCaretPos); if(-1 == iLastIndex) { return; } iLastIndex = sql.lastIndexOf(SQL_STMT_SEP, iLastIndex - getWhiteSpaceCountBackwards(iLastIndex, sql)); if(-1 == iLastIndex) { iLastIndex = 0; } char c = sql.charAt(iLastIndex); while(Character.isWhitespace(c) && iLastIndex < sql.length()) { ++iLastIndex; c = sql.charAt(iLastIndex); } setCaretPosition(iLastIndex); }
public String getSQLToBeExecuted() { String sql = getSelectedText(); if (sql == null || sql.trim().length() == 0) { sql = getText(); int[] bounds = getBoundsOfSQLToBeExecuted(); if(bounds[0] >= bounds[1]) { sql = ""; } else { sql = sql.substring(bounds[0], bounds[1]).trim(); } } return sql != null ? sql : ""; }
public void moveCaretToNextSQLBegin() { String sql = getText(); int iCaretPos = getCaretPosition(); int iNextIndex = sql.indexOf(SQL_STMT_SEP, iCaretPos); if(-1 == iNextIndex) { return; } while(iNextIndex < sql.length() && Character.isWhitespace(sql.charAt(iNextIndex))) { ++iNextIndex; } if(iNextIndex < sql.length()) { setCaretPosition(iNextIndex); } }
@Override public String getWordAtCursor() { int[] beginAndEndPos = SQLEntryPanelUtil.getWordBoundsAtCursor(getTextComponent(), true); return getTextComponent().getText().substring(beginAndEndPos[0], beginAndEndPos[1]).trim(); }
/** * @see ISQLEntryPanel#addRedoUndoActionsToSQLEntryAreaMenu(javax.swing.Action, javax.swing.Action) */ public void addRedoUndoActionsToSQLEntryAreaMenu(Action undo, Action redo) { _textPopupMenu.addSeparator(); JMenuItem buf; buf = addToSQLEntryAreaMenu(undo); _app.getResources().configureMenuItem(undo, buf); buf = addToSQLEntryAreaMenu(redo); _app.getResources().configureMenuItem(redo, buf); _textPopupMenu.addSeparator(); }
public int[] getBoundsOfSQLToBeExecuted() { int[] bounds = new int[2]; bounds[0] = getSelectionStart(); bounds[1] = getSelectionEnd(); if(bounds[0] == bounds[1]) { bounds = getSqlBoundsBySeparatorRule(getCaretPosition()); } return bounds; }
/** * The non selection separator is two new lines. Two new lines with white spaces in between * is counted as separator too. * @return */ private int[] getSqlBoundsBySeparatorRule(int iCaretPos) { int[] bounds = new int[2]; String sql = getText(); bounds[0] = lastIndexOfStateSep(sql, iCaretPos); bounds[1] = indexOfStateSep(sql, iCaretPos); return bounds; }
public void run() { getTextComponent().addMouseListener(_sqlEntryMouseListener); } });
public void run() { getTextComponent().addMouseListener(_sqlEntryMouseListener); } });
private void displayPopupMenu(MouseEvent evt) { _textPopupMenu.setTextComponent(getTextComponent()); _textPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
private void displayPopupMenu(MouseEvent evt) { _textPopupMenu.setTextComponent(getTextComponent()); _textPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }