/** Get the document to work on. Either component's document or printed document * is returned. It can return null in case the component's document is not instance * of BaseDocument. */ public final BaseDocument getDocument() { return (component != null) ? Utilities.getDocument(component) : printDoc; }
/** * Get the document to work on. Either component's document or printed * document is returned. It can return null in case the component's document * is not instance of BaseDocument. */ public final BaseDocument getDocument() { return (component != null) ? Utilities.getDocument(component) : printDoc; }
@Override public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target == null) { return; } Document doc = Utilities.getDocument(target); DatabaseConnectionSupport.selectDatabaseConnection(doc); }
public static String getLine(final JTextComponent component, final int offset) { final BaseDocument workingDocument = org.netbeans.editor.Utilities.getDocument(component); try { final int lineStartOffset = org.netbeans.editor.Utilities.getRowStart(workingDocument, offset); final int lineEndOffset = org.netbeans.editor.Utilities.getRowEnd(workingDocument, offset); return String.valueOf(workingDocument.getChars(lineStartOffset, lineEndOffset - lineStartOffset)); } catch (BadLocationException ble) { return ""; } }
public static String getLine(final JTextComponent component, final int offset) { final BaseDocument workingDocument=org.netbeans.editor.Utilities.getDocument(component); try { final int lineStartOffset = org.netbeans.editor.Utilities.getRowStart(workingDocument, offset); final int lineEndOffset = org.netbeans.editor.Utilities.getRowEnd(workingDocument, offset); return String.valueOf(workingDocument.getChars(lineStartOffset, lineEndOffset - lineStartOffset)); } catch (BadLocationException ble) { return ""; } } }
protected boolean hasTextBefore(JTextComponent target, String typedText) { BaseDocument doc = Utilities.getDocument(target); int dotPos = target.getCaret().getDot(); try { int fnw = Utilities.getRowFirstNonWhite(doc, dotPos); return dotPos != fnw+typedText.length(); } catch (BadLocationException e) { return false; } }
protected boolean hasTextBefore(JTextComponent target, String typedText) { BaseDocument doc = Utilities.getDocument(target); int dotPos = target.getCaret().getDot(); try { int fnw = Utilities.getRowFirstNonWhite(doc, dotPos); return dotPos != fnw + typedText.length(); } catch (BadLocationException e) { return false; } }
/** * Execute complegtion query subtask */ private void performQuery(final JTextComponent target) { BaseDocument doc = Utilities.getDocument(target); long start = System.currentTimeMillis(); try { lastResult = getQuery().query( target, caretPos, doc.getSyntaxSupport()); } finally { trace("performQuery took " + (System.currentTimeMillis() - start) + "ms"); // NOI18N setKeyPressed(false); } }
/** * Execute complegtion query subtask */ private void performQuery(final JTextComponent target) { BaseDocument doc = Utilities.getDocument(target); long start = System.currentTimeMillis(); try { lastResult = getQuery().query( target, caretPos, doc.getSyntaxSupport()); } finally { trace("performQuery took " + (System.currentTimeMillis() - start) + "ms"); // NOI18N setKeyPressed(false); } }
public void run() { JTextComponent c2 = component; if (c2 != null) { BaseDocument doc = Utilities.getDocument(c2); if (doc != null) { doc.readLock(); try { update(scrollRect, scrollPolicy); } finally { doc.readUnlock(); } } } } });
public void run() { JTextComponent c2 = component; if (c2 != null) { BaseDocument doc = Utilities.getDocument(c2); if (doc != null) { doc.readLock(); try { update(scrollRect, scrollPolicy); } finally { doc.readUnlock(); } } } } }
@Override public void defaultAction(JTextComponent component) { DatabaseConnection newDBConn = DatabaseConnectionSupport.selectDatabaseConnection(Utilities.getDocument(component)); if (newDBConn != null && newDBConn.getJDBCConnection() != null) { Completion.get().showCompletion(); } }
/** * Checks whether class is already imported * @param cls JCClass **/ protected boolean isAlreadyImported(JCClass cls){ BaseDocument doc = Utilities.getDocument(target); if (doc == null) return false; JavaSyntaxSupport sup = (JavaSyntaxSupport)doc.getSyntaxSupport().get(JavaSyntaxSupport.class); if (sup == null) return false; sup.refreshJavaImport(); return sup.isImported(cls); }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { try { Caret caret = target.getCaret(); BaseDocument doc = Utilities.getDocument(target); int caretLine = Utilities.getLineOffset(doc, caret.getDot()); AnnotationDesc aDesc = doc.getAnnotations().activateNextAnnotation(caretLine); } catch (BadLocationException e) { e.printStackTrace(); } } } }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { try { Caret caret = target.getCaret(); BaseDocument doc = Utilities.getDocument(target); int caretLine = Utilities.getLineOffset(doc, caret.getDot()); AnnotationDesc aDesc = doc.getAnnotations().activateNextAnnotation(caretLine); } catch (BadLocationException e) { e.printStackTrace(); } } } }
public void actionPerformed(ActionEvent evt) { Caret c = caret; JTextComponent component = editorUI.getComponent(); if (component != null) { if (c != null) { BaseDocument doc = Utilities.getDocument(editorUI.getComponent()); if (doc != null) { int pos = c.getDot(); String s = Utilities.debugPosition(doc, pos); setText(CELL_POSITION, s); } } Boolean b = (Boolean) editorUI.getProperty(EditorUI.OVERWRITE_MODE_PROPERTY); boolean om = (b != null && b.booleanValue()); if (om != overwriteModeDisplayed) { overwriteModeDisplayed = om; setText(CELL_TYPING_MODE, overwriteModeDisplayed ? ovrText : insText); } } }
public void actionPerformed(ActionEvent evt) { Caret c = caret; JTextComponent component = editorUI.getComponent(); if (component != null) { if (c != null) { BaseDocument doc = Utilities.getDocument(editorUI.getComponent()); if (doc != null) { int pos = c.getDot(); String s = Utilities.debugPosition(doc, pos); setText(CELL_POSITION, s); } } Boolean b = (Boolean)editorUI.getProperty(EditorUI.OVERWRITE_MODE_PROPERTY); boolean om = (b != null && b.booleanValue()); if (om != overwriteModeDisplayed) { overwriteModeDisplayed = om; setText(CELL_TYPING_MODE, overwriteModeDisplayed ? ovrText : insText); } } }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { try { Caret caret = target.getCaret(); BaseDocument doc = Utilities.getDocument(target); int dotPos = caret.getDot(); ExtSyntaxSupport sup = (ExtSyntaxSupport) doc.getSyntaxSupport(); if (dotPos > 0) { int[] matchBlk = sup.findMatchingBlock(dotPos - 1, false); if (matchBlk != null) { if (select) { caret.moveDot(matchBlk[1]); } else { caret.setDot(matchBlk[1]); } } } } catch (BadLocationException e) { target.getToolkit().beep(); } } } }
/** Check the characters that should cause reindenting the line. */ protected void checkIndentHotChars(JTextComponent target, String typedText) { BaseDocument doc = Utilities.getDocument(target); if (doc != null) { Caret caret = target.getCaret(); Formatter f = doc.getFormatter(); if (f instanceof ExtFormatter) { ExtFormatter ef = (ExtFormatter)f; int[] fmtBlk = ef.getReformatBlock(target, typedText); if (fmtBlk != null) { try { fmtBlk[0] = Utilities.getRowStart(doc, fmtBlk[0]); fmtBlk[1] = Utilities.getRowEnd(doc, fmtBlk[1]); //this was the of #18922, that causes the bug #20198 //ef.reformat(doc, fmtBlk[0], fmtBlk[1]); //bugfix of the bug #20198. Bug #18922 is fixed too as well as #6968 ef.reformat(doc, fmtBlk[0], fmtBlk[1], true); } catch (BadLocationException e) { } catch (IOException e) { } } } } }
/** Deinstalls the UI for a component */ public void uninstallUI(JComponent c) { super.uninstallUI(c); Settings.removeSettingsChangeListener(this); //c.removePropertyChangeListener(this); if (c instanceof JTextComponent){ JTextComponent comp = (JTextComponent)c; BaseDocument doc = Utilities.getDocument(comp); if (doc != null) { doc.removeDocumentListener(this); } comp.setKeymap(null); comp.setCaret(null); getEditorUI().uninstallUI(comp); Registry.removeComponent(comp); } // Clear the editorUI so it will be recreated according to the kit // of the component for which the installUI() is called editorUI = null; }