public void doReplacement() { EditWindow currentWindow = editor.getActiveWindow(); if (currentWindow == null || getFindTextField().getText().length() == 0) { // launch error dialog? return; } JEditorPane editorPane = currentWindow.getEditorPane(); String text = editorPane.getSelectedText(); if (text == null) { // no selection return; } Matcher m = getCurrentPattern().matcher(text); if (m.matches()) { String replacement = getReplaceTextField().getText(); if (getRegexButton().isSelected()) { replacement = m.replaceFirst(replacement); } editorPane.replaceSelection(replacement); } }
@Override public Object getData(@NonNls String dataId) { if (DocumentationManager.SELECTED_QUICK_DOC_TEXT.getName().equals(dataId)) { return myEditorPane.getSelectedText(); } return null; }
@Override public Object getData(@NonNls String dataId) { if (DocumentationManager.SELECTED_QUICK_DOC_TEXT.getName().equals(dataId)) { // Javadocs often contain symbols (non-breakable white space). We don't want to copy // them as is and replace // with raw white spaces. See IDEA-86633 for more details. String selectedText = myEditorPane.getSelectedText(); return selectedText == null ? null : selectedText.replace((char) 160, ' '); } return null; }
public boolean canDoClipBoardAction(Action action) { if (action == GUIPrism.getClipboardPlugin().getPasteAction()) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); return (clipboard.getContents(null) != null); } else if (action == GUIPrism.getClipboardPlugin().getCutAction() || action == GUIPrism.getClipboardPlugin().getCopyAction() || action == GUIPrism.getClipboardPlugin().getDeleteAction()) { return (editor.getSelectedText() != null); } else if (action == GUIPrism.getClipboardPlugin().getSelectAllAction()) { return true; } return handler.canDoClipBoardAction(action); }