/** * Returns the document model underlying the view. * * @return the model */ public Document getDocument() { EditorUI editorUI = getEditorUI(); return (editorUI==null) ? null : editorUI.getDocument(); }
public void init(DrawContext ctx) { super.init(ctx); doc = (GuardedDocument)ctx.getEditorUI().getDocument(); }
public void init(DrawContext ctx) { super.init(ctx); doc = (GuardedDocument) ctx.getEditorUI().getDocument(); }
public PreinitializedDrawEngine getDrawEngine(View view, DrawGraphics drawGraphics, EditorUI editorUI, int startOffset, int endOffset, int startX, int startY, int targetOffset) throws BadLocationException { // Some correctness tests at the begining if (startOffset < 0 || endOffset < 0 || startOffset > endOffset || startX < 0 || startY < 0 ) { return null; } BaseDocument doc = (BaseDocument)((view != null) ? view.getDocument() : editorUI.getDocument()); PreinitializedDrawEngine preinitializedDrawEngine = new PreinitializedDrawEngine(drawGraphics); preinitializedDrawEngine.preinitialize(doc, editorUI, startOffset, endOffset, startX, startY, targetOffset); return preinitializedDrawEngine; }
void checkLineLimit() { BaseDocument doc = getDocument(); if (doc != null) { Integer lineLimit = (Integer) doc.getProperty(BaseDocument.LINE_LIMIT_PROP); if (lineLimit != null) { if (component != null) { // Not using FM cache - could be called too early FontMetrics fm = component.getFontMetrics(getDefaultColoring().getFont()); if (fm != null) { int charWidth = fm.stringWidth("A"); updateVirtualWidth(charWidth * lineLimit.intValue() + lineNumberWidth); } } } } }
public JMenuItem getPopupMenuItem(JTextComponent target) { EditorUI ui = Utilities.getEditorUI(target); try { return ui.getDocument().getAnnotations().createMenu(Utilities.getKit(target), Utilities.getLineOffset(ui.getDocument(),target.getCaret().getDot())); } catch (BadLocationException ex) { return null; } }
public JMenuItem getPopupMenuItem(JTextComponent target) { EditorUI ui = Utilities.getEditorUI(target); try { return ui.getDocument().getAnnotations().createMenu(Utilities.getKit(target), Utilities.getLineOffset(ui.getDocument(), target.getCaret().getDot())); } catch (BadLocationException ex) { return null; } }
void checkLineLimit() { BaseDocument doc = getDocument(); if (doc != null) { Integer lineLimit = (Integer)doc.getProperty(BaseDocument.LINE_LIMIT_PROP); if (lineLimit != null) { if (component != null) { // Not using FM cache - could be called too early FontMetrics fm = component.getFontMetrics(getDefaultColoring().getFont()); if (fm != null) { int charWidth = fm.stringWidth("A"); // NOI18N updateVirtualWidth(charWidth * lineLimit.intValue() + lineNumberWidth); } } } } }
public void init(DrawContext ctx) { JTextComponent c = ctx.getEditorUI().getComponent(); gColor = graphics.getColor(); gFont = graphics.getFont(); // initialize reference to annotations annos = ctx.getEditorUI().getDocument().getAnnotations(); }
public boolean expandString(char typedChar, String expandStr, ActionEvent evt) throws BadLocationException { if (expandString(expandStr, evt)) { if (addTypedAcceptor.accept(typedChar)) { int dotPos = editorUI.getComponent().getCaret().getDot(); editorUI.getDocument().insertString(dotPos, String.valueOf(typedChar), null); } return true; } return false; }
public boolean expandString(char typedChar, String expandStr, ActionEvent evt) throws BadLocationException { if (expandString(expandStr, evt)) { if (addTypedAcceptor.accept(typedChar)) { int dotPos = editorUI.getComponent().getCaret().getDot(); editorUI.getDocument().insertString(dotPos, String.valueOf(typedChar), null); } return true; } return false; }
public GlyphGutter(EditorUI editorUI) { super(); this.editorUI = editorUI; init = false; doc = editorUI.getDocument(); annos = doc.getAnnotations(); // Annotations class is model for this view, so the listener on changes // in // Annotations must be added here annos.addAnnotationsListener(this); // do initialization init(); update(); }
public void init(DrawContext ctx) { if (enabled) { try { BaseDocument doc = ctx.getEditorUI().getDocument(); blocks = FindSupport.getFindSupport().getBlocks(blocks, doc, ctx.getStartOffset(), ctx.getEndOffset()); } catch (BadLocationException e) { blocks = new int[] { -1, -1 }; } coloring = null; // reset so it will be re-read curInd = 0; } }
public void init(DrawContext ctx) { if (enabled) { try { BaseDocument doc = ctx.getEditorUI().getDocument(); blocks = FindSupport.getFindSupport().getBlocks(blocks, doc, ctx.getStartOffset(), ctx.getEndOffset()); } catch (BadLocationException e) { blocks = new int[] { -1, -1 }; } coloring = null; // reset so it will be re-read curInd = 0; } }
public String getExpandString() { BaseDocument doc = (BaseDocument) editorUI.getDocument(); String abbrevStr = getAbbrevString(); int abbrevStrLen = abbrevStr.length(); Object expansion = translateAbbrev(abbrevStr); Caret caret = editorUI.getComponent().getCaret(); int dotPos = caret.getDot(); if (abbrevStr != null && expansion != null && dotPos >= abbrevStrLen) { if (checkDocText) { try { String prevChars = doc.getText(dotPos - abbrevStrLen, abbrevStrLen); if (prevChars.equals(abbrevStr)) { // abbrev chars really // match text if (!checkTextDelimiter || dotPos == abbrevStrLen || resetAcceptor.accept(doc.getChars(dotPos - abbrevStrLen - 1, 1)[0])) { return abbrevStr; } } } catch (BadLocationException e) { } } } return null; }
/** * Creates new instance initializing final fields. */ public AnnotationBar(JTextComponent target) { this.textComponent = target; this.editorUI = Utilities.getEditorUI(target); this.foldHierarchy = FoldHierarchy.get(editorUI.getComponent()); this.doc = editorUI.getDocument(); this.caret = textComponent.getCaret(); setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); elementAnnotationsSubstitute = ""; //NOI18N if (textComponent instanceof JEditorPane) { String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(textComponent); FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class); renderingHints = (Map) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints); } else { renderingHints = null; } }
public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) { boolean active; if (mark != null) { active = (ctx.getEditorUI().getComponent() != null) && mark.activateLayer; if (active) { try { BaseDocument doc = ctx.getEditorUI().getDocument(); int nextRowStartPos = Utilities.getRowStart(doc, ctx.getFragmentOffset(), 1); if (nextRowStartPos < 0) { // end of doc nextRowStartPos = Integer.MAX_VALUE; } setNextActivityChangeOffset(nextRowStartPos); } catch (BadLocationException e) { active = false; } } } else { active = false; } return active; }
public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) { boolean active; if (mark != null) { active = (ctx.getEditorUI().getComponent() != null) && mark.activateLayer; if (active) { try { BaseDocument doc = ctx.getEditorUI().getDocument(); int nextRowStartPos = Utilities.getRowStart( doc, ctx.getFragmentOffset(), 1); if (nextRowStartPos < 0) { // end of doc nextRowStartPos = Integer.MAX_VALUE; } setNextActivityChangeOffset(nextRowStartPos); } catch (BadLocationException e) { active = false; } } } else { active = false; } return active; }
public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) { boolean active = false; if (mark != null) { active = (ctx.getEditorUI().getComponent() != null) && mark.activateLayer; if (active) { try { BaseDocument doc = ctx.getEditorUI().getDocument(); int nextRowStartPos = Utilities.getRowStart(doc, ctx.getFragmentOffset(), 1); if (nextRowStartPos < 0) { // end of doc nextRowStartPos = Integer.MAX_VALUE; } setNextActivityChangeOffset(nextRowStartPos); } catch (BadLocationException e) { active = false; } } } return active; }
public void init(DrawContext ctx) { JTextComponent c = ctx.getEditorUI().getComponent(); // initialize reference to annotations annos = ctx.getEditorUI().getDocument().getAnnotations(); drawTextLimitLine = ctx.getEditorUI().textLimitLineVisible; textLimitWidth = ctx.getEditorUI().textLimitWidth; defaultSpaceWidth = ctx.getEditorUI().defaultSpaceWidth; textLimitLineColor = ctx.getEditorUI().textLimitLineColor; absoluteX = ctx.getEditorUI().getTextMargin().left; maxWidth = ctx.getEditorUI().getExtentBounds().width; }