private void adjustCaret(CodeCompletionInfo completion) { if(0 < completion.getMoveCarretBackCount()) { _sqlEntryPanel.setCaretPosition(_sqlEntryPanel.getCaretPosition() - completion.getMoveCarretBackCount()); } }
public void run() { _entryPanelManager.getEntryPanel().getTextComponent().scrollRectToVisible(new Rectangle(0,0)); _entryPanelManager.getEntryPanel().setCaretPosition(0); } };
int start = bounds[0]; int newPosition = start + offsetNum - 1; sqlEntryPanel.setCaretPosition(newPosition);
sqlEntryPanel.setCaretPosition(caretPosition);
/** * Load the Bookmark into the SQL Edit buffer. */ public void execute() { if (session != null) { String sql = parseAndLoadSql(bookmark.getSql()); if (null != sql) { int caretPosition = _sqlEntryPanel.getCaretPosition(); _sqlEntryPanel.replaceSelection(sql); _sqlEntryPanel.setCaretPosition(caretPosition + sql.length()); } } }
private void comment(ISQLEntryPanel sqlEntryPanel) { int[] bounds = sqlEntryPanel.getBoundsOfSQLToBeExecuted(); if (bounds[0] == bounds[1]) { return; } int caretPosition = sqlEntryPanel.getCaretPosition(); String textToComment = sqlEntryPanel.getText().substring(bounds[0], bounds[1]); String[] lines = textToComment.split("\n"); StringBuffer commentedLines = new StringBuffer(); String startOfLineComment = sqlEntryPanel.getSession().getProperties().getStartOfLineComment(); for (int i = 0; i < lines.length; i++) { if(bounds[0] + commentedLines.length() <= caretPosition) { caretPosition += startOfLineComment.length(); } commentedLines.append(startOfLineComment).append(lines[i]); if(i < lines.length - 1 || textToComment.endsWith("\n")) { commentedLines.append("\n"); } } sqlEntryPanel.setSelectionStart(bounds[0]); sqlEntryPanel.setSelectionEnd(bounds[1]); sqlEntryPanel.replaceSelection(commentedLines.toString()); sqlEntryPanel.setCaretPosition(caretPosition); }