private String getTrimmedSelectedTextInMainWindow() { String selection = null; Component component = mainWindow.getMostRecentFocusOwner(); if (component instanceof JTextComponent) { selection = ((JTextComponent) component).getSelectedText(); if (!StringUtil.isEmpty(selection)) { selection = EditorUtils.removeDirectionChars(selection); selection = selection.trim(); } } return selection; }