@Override protected JPopupMenu createPopupMenu(Component component) { JPopupMenu menu = super.createPopupMenu(component); JMenu formatMenu = new JMenu(TextUtils.getText("simplyhtml.formatLabel")); menu.add(formatMenu); if (textfield.getSelectionStart() == textfield.getSelectionEnd()){ formatMenu.setEnabled(false); return menu; } formatMenu.add(boldAction); formatMenu.add(italicAction); formatMenu.add(underlineAction); formatMenu.add(redAction); formatMenu.add(greenAction); formatMenu.add(blueAction); formatMenu.add(blackAction); formatMenu.add(defaultColorAction); formatMenu.add(removeFormattingAction); return menu; }
private static String getSelectedExpr(JEditorPane ep, int offset) { if ((ep.getSelectionStart() <= offset) && (offset <= ep.getSelectionEnd())) { return ep.getSelectedText(); } return null; }
private boolean isSelected() { int selectionStart = Math.min(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); int selectionEnd = Math.max(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); return selectionStart != selectionEnd; }
public void findNext() { EditWindow currentWindow = editor.getActiveWindow(); if (currentWindow == null || getFindTextField().getText().length() == 0) { // launch error dialog? return; } Pattern p = getCurrentPattern(); JEditorPane editorPane = currentWindow.getEditorPane(); // for some reason, getText() trims off \r but the indexes in // the editor pane don't. String text = editorPane.getText().replaceAll("\\r", ""); Matcher m = p.matcher(text); int index = editorPane.getSelectionEnd(); if (!(m.find(index) || m.find())) { return; } editorPane.setSelectionStart(m.start()); editorPane.setSelectionEnd(m.end()); }
/** * Copies from the description text area, if it is visible and there is * a selection. * * @return Whether a copy occurred. */ public boolean copy() { if (isVisible() && descArea.getSelectionStart()!=descArea.getSelectionEnd()) { descArea.copy(); return true; } return false; }
private void removeSelection() { try { int selectionStart = Math.min(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); int selectionEnd = Math.max(getEditor().getSelectionStart(), getEditor().getSelectionEnd()); getEditor().getDocument().remove(selectionStart, selectionEnd); } catch (BadLocationException ex) { // Logger.getLogger(ShellView.class.getName()). // log(Level.SEVERE, null, ex); } }
public void actionPerformed(ActionEvent e) { final JEditorPane editor = getEditor(e); if(editor == null){ return; } final int selectionStart = editor.getSelectionStart(); final int selectionEnd = editor.getSelectionEnd(); if(selectionStart == selectionEnd){ return; } SHTMLEditorKit.removeCharacterAttributes((StyledDocument) editor.getDocument(), attribute, selectionStart, selectionEnd - selectionStart); } }
(offset <= ep.getSelectionEnd ()) ) { t = ep.getSelectedText ();
public static String getELIdentifier(StyledDocument doc, JEditorPane ep, int offset) { String t = null; if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) t = ep.getSelectedText (); if (t != null) {
@Override public CsmReference findReference(Node activatedNode) { assert activatedNode != null : "activatedNode must be not null"; EditorCookie cookie = activatedNode.getCookie(EditorCookie.class); if (cookie != null) { JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(cookie); if (pane != null) { //System.err.printf("caret: %d, %d, %d\n",panes[0].getCaretPosition(), panes[0].getSelectionStart(), panes[0].getSelectionEnd()); int offset = pane.getSelectionEnd(); StyledDocument doc = CsmUtilities.openDocument(cookie); return findReferenceInDoc(doc, offset); } } return null; }
(offset <= ep.getSelectionEnd ()) ) { t = ep.getSelectedText ();
public static String getJavaIdentifier(StyledDocument doc, JEditorPane ep, int offset) { String t = null; if ( (ep.getSelectionStart() <= offset) && (offset <= ep.getSelectionEnd())) { t = ep.getSelectedText();
String t = null; if ( (ep.getSelectionStart () <= offset) && (offset <= ep.getSelectionEnd ()) ) t = ep.getSelectedText (); if (t != null) return t;
(offset <= ep.getSelectionEnd ()) ) { t = ep.getSelectedText ();
getEditor().getSelectionEnd()); getEditor().getSelectionEnd());
(offset <= ep.getSelectionEnd ()) ) { t = ep.getSelectedText ();
HTMLDocument htmlDoc = (HTMLDocument)(jepEditor.getDocument()); int iStart = jepEditor.getSelectionStart(); int iEnd = jepEditor.getSelectionEnd(); String selText = htmlDoc.getText(iStart, iEnd - iStart); StringBuffer sbNew = new StringBuffer();
if( !editor.hasFocus() || editor.getSelectionStart() != editor.getSelectionEnd() )
if( !editor.hasFocus() || editor.getSelectionStart() != editor.getSelectionEnd() )
s = ep.getSelectedText (); currentOffset = ep.getCaretPosition(); if (ep.getSelectionStart() > currentOffset || ep.getSelectionEnd() < currentOffset) {