textArea.getCaret().setSelectionVisible(true);
public void focusGained(java.awt.event.FocusEvent e) { // DEBUG System.out.printf("disasm: focusGained()\n"); editorPane.getCaret().setVisible(true); } public void focusLost(java.awt.event.FocusEvent e) {
private void issuesInfoPaneFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_issuesInfoPaneFocusGained issuesInfoPane.getCaret().setVisible(false); }//GEN-LAST:event_issuesInfoPaneFocusGained
private void commChannelsDisplayerFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_commChannelsDisplayerFocusGained commChannelsDisplayer.getCaret().setVisible(false); //MacOSX hack }//GEN-LAST:event_commChannelsDisplayerFocusGained
/** * Return the contents of the line under the cursor. */ private String getCurrentLine() { Caret caret = editorPane.getCaret(); int pos = caret.getDot(); return getLineAt(pos); }
public void actionPerformed(java.awt.event.ActionEvent e) { if (lastCaretOffset == -1 && pane != null) { Caret caret = pane.getCaret(); if (caret != null) lastCaretOffset = caret.getDot(); } selectElementsAtOffset(lastCaretOffset); } });
@Override public void mouseClicked(MouseEvent e) { getEditor().getCaret().setVisible(true); }
/** * Returns number of line currently selected in editor or <code>-1</code>. * * @return number of line currently selected in editor or <code>-1</code> */ public int getCurrentOffset() { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return -1; } Caret caret = ep.getCaret(); if (caret == null) { return -1; } return caret.getDot(); }
private int getOffset(Node[] activatedNodes) { EditorCookie c = activatedNodes[0].getLookup().lookup(EditorCookie.class); if (c != null) { JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c); if (pane != null ) { return pane.getCaret().getDot(); } } return 0; }
/** * Returns number of line currently selected in editor or <code>-1</code>. * * @return number of line currently selected in editor or <code>-1</code> */ public int getCurrentOffset () { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return -1; } Caret caret = ep.getCaret (); if (caret == null) { return -1; } return caret.getDot(); }
/** * Returns number of line currently selected in editor or <code>-1</code>. * * @return number of line currently selected in editor or <code>-1</code> */ public int getCurrentOffset () { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return -1; } Caret caret = ep.getCaret (); if (caret == null) { return -1; } return caret.getDot(); }
public static CsmScope findScope(Node activatedNode) { EditorCookie c = activatedNode.getLookup().lookup(EditorCookie.class); if (c != null) { JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c); if (pane != null ) { int offset = pane.getCaret().getDot(); CsmFile file = CsmUtilities.getCsmFile(activatedNode,false); if (file != null){ return findInnerFileScope(file, offset); } } } return null; }
public static CsmDeclaration findDeclaration(Node activatedNode) { EditorCookie c = activatedNode.getLookup().lookup(EditorCookie.class); if (c != null) { JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c); if (pane != null ) { int offset = pane.getCaret().getDot(); CsmFile file = CsmUtilities.getCsmFile(activatedNode,false); if (file != null){ return findInnerFileDeclaration(file, offset); } } } return null; }
public static boolean isScriptlet() { JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); if (ep == null) { return false; } return isScriptlet( (StyledDocument) ep.getDocument (), ep, ep.getCaret ().getDot () ); }
public static String getJavaIdentifier () { JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); if (ep == null) { return null; } return getJavaIdentifier ( (StyledDocument) ep.getDocument (), ep, ep.getCaret ().getDot () ); }
public void run() { AbstractDocument doc = getCurrentDocument (); TokenSequence ts = null; if (doc != null) try { doc.readLock (); TokenHierarchy tokenHierarchy = TokenHierarchy.get (doc); if (tokenHierarchy == null) return; ts = tokenHierarchy.tokenSequence (); } finally { doc.readUnlock (); } if (ts == null) tree.setModel (new DefaultTreeModel (new DefaultMutableTreeNode ())); else tree.setModel (new DefaultTreeModel (new TSNode (null, ts, null, 0, 0))); JEditorPane editor = getCurrentEditor (); if (editor != null) { int position = getCurrentEditor ().getCaret ().getDot (); selectPath (position); } } });
private static CsmOffsetableDeclaration findDeclaration(Node activatedNode) { EditorCookie c = activatedNode.getCookie(EditorCookie.class); if (c != null) { JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c); if (pane != null ) { int offset = pane.getCaret().getDot(); CsmFile file = CsmUtilities.getCsmFile(activatedNode,false); if (file != null){ return findInnerFileDeclaration(file, offset); } } } return null; }
static boolean canHandle(Node activatedNode) { FileObject fo = getFileObjectFromNode(activatedNode); if (fo != null) { if (!isGroovyFile(fo)) { return false; } EditorCookie ec = activatedNode.getLookup().lookup(EditorCookie.class); if (ec != null) { JEditorPane pane = NbDocument.findRecentEditorPane(ec); if (pane != null) { SingleMethod sm = getTestMethod(pane.getDocument(), pane.getCaret().getDot()); if(sm != null) { return true; } } } } return false; }
public static Line getCurrentLine() { EditorCookie e = getCurrentEditorCookie(); if (e == null) return null; JEditorPane ep = getCurrentEditor(e); if (ep == null) return null; StyledDocument d = e.getDocument(); if (d == null) return null; int lineNo = NbDocument.findLineNumber(d, ep.getCaret().getDot()); // Editor numbers lines from 0! Line l = null; try { l = e.getLineSet().getCurrent(lineNo + 1); } catch (IndexOutOfBoundsException x) { // 6494346 } return l; }