/** * 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()); } } }
sqlEntryPanel.setSelectionEnd(bounds[1]); sqlEntryPanel.replaceSelection(uncommentedLines.toString());
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); }
private void onEscapeDate() { String str = EditExtrasAccessor.escapeDate(getEntryPanel(), getSession()); if(null != str) { getEntryPanel().replaceSelection(str); } }
pnl.replaceSelection(sqlScript); if (select)
pnl.replaceSelection(sqlScript); if (select)
private void performCompletionSelected(CompletionInfo completion, int replaceBegin, int keyCode, int modifiers) { if(KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK) { // Code Completion has been done within Code Completion. Now just replace what all candidates have in common. CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret()); _hqlEntryPanel.setSelectionStart(replaceBegin); _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition()); _hqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(true)); SwingUtilities.invokeLater(new Runnable() { public void run() { _cc.show(); } }); } else if(KeyEvent.VK_TAB == keyCode) { _hqlEntryPanel.setSelectionStart(replaceBegin); _hqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_hqlEntryPanel.getCaretPosition())); _hqlEntryPanel.replaceSelection(completion.getCompletionString()); } else { _hqlEntryPanel.setSelectionStart(replaceBegin); _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition()); _hqlEntryPanel.replaceSelection(completion.getCompletionString()); } }
_sqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(false)); _sqlEntryPanel.replaceSelection(completion.getCompletionString()); adjustCaret(completion); _sqlEntryPanel.replaceSelection(completion.getCompletionString()); adjustCaret(completion);
_panel.getSQLEntryPanel().replaceSelection(reformatedText);
_panel.getSQLEntryPanel().replaceSelection(reformatedText);