boolean (Editor editor) { if (!editor.getSelectionModel().hasSelection()) { return false; } Document document = editor.getDocument(); int selectionStart = editor.getSelectionModel().getSelectionStart(); int selectionEnd = editor.getSelectionModel().getSelectionEnd(); return !CharArrayUtil.containsOnlyWhiteSpaces(document.getCharsSequence().subSequence(selectionStart, selectionEnd)); }