null
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public DrawLayerFactory.AnnotationLayer getLayer() {
- return null;
- }
-
/** Add annotation */
public void addAnnotation(AnnotationDesc anno) {
@@ -241,7 +234,7 @@
+ ", docLen=" + doc.getLength()); // NOI18N
}
// attach created mark to annotation
- MarkFactory.ChainDrawMark annoMark = chain.getAddedMark();
+ ChainDrawMark annoMark = chain.getAddedMark();
if (annoMark == null) {
throw new NullPointerException();
}
@@ -320,7 +313,7 @@
int line;
synchronized (lineAnnotationsArray) {
// find LineAnnotations for the mark
- MarkFactory.ChainDrawMark annoMark = (MarkFactory.ChainDrawMark)anno.getMark();
+ ChainDrawMark annoMark = (ChainDrawMark)anno.getMark();
if (annoMark == null) {
// Already removed? See #116955
return;
diff --git a/editor.lib/src/org/netbeans/editor/BaseDocument.java b/editor.lib/src/org/netbeans/editor/BaseDocument.java
--- a/editor.lib/src/org/netbeans/editor/BaseDocument.java
+++ b/editor.lib/src/org/netbeans/editor/BaseDocument.java
@@ -97,6 +97,10 @@
import org.netbeans.modules.editor.lib.FormatterOverride;
import org.netbeans.modules.editor.lib.TrailingWhitespaceRemove;
import org.netbeans.modules.editor.lib.SettingsConversions;
+import org.netbeans.modules.editor.lib.drawing.DrawEngine;
+import org.netbeans.modules.editor.lib.drawing.DrawGraphics;
+import org.netbeans.modules.editor.lib.impl.MarkVector;
+import org.netbeans.modules.editor.lib.impl.MultiMark;
import org.openide.util.Lookup;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
@@ -257,9 +261,6 @@
private SyntaxSupport syntaxSupport;
- /** Layer list for document level layers */
- private DrawLayerList drawLayerList = new DrawLayerList();
-
/** Reset merging next created undoable edit to the last one. */
boolean undoMergeReset;
@@ -2014,38 +2015,6 @@
return modified;
}
- /**
- * Get the layer with the specified name. Using of DrawLayer
s
- * has been deprecated.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public DrawLayer findLayer(String layerName) {
- return drawLayerList.findLayer(layerName);
- }
-
- /**
- * Using of DrawLayer
s has been deprecated.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public boolean addLayer(DrawLayer layer, int visibility) {
- if (drawLayerList.add(layer, visibility)) {
- BaseDocumentEvent evt = getDocumentEvent(0, 0, DocumentEvent.EventType.CHANGE, null);
- evt.addEdit(new BaseDocumentEvent.DrawLayerChange(layer.getName(), visibility));
- fireChangedUpdate(evt);
- return true;
- } else {
- return false;
- }
- }
-
- final DrawLayerList getDrawLayerList() {
- return drawLayerList;
- }
-
private LineRootElement getLineRootElement() {
return lineRootElement;
}
@@ -2445,10 +2414,24 @@
private static final class Accessor extends EditorPackageAccessor {
@Override
- public CompoundEdit markAtomicEditsNonSignificant(BaseDocument doc) {
+ public CompoundEdit BaseDocument_markAtomicEditsNonSignificant(BaseDocument doc) {
return doc.markAtomicEditsNonSignificant();
}
+ @Override
+ public MarkVector BaseDocument_getMarksStorage(BaseDocument doc) {
+ return doc.marksStorage;
+ }
+
+ @Override
+ public Mark BaseDocument_getMark(BaseDocument doc, MultiMark multiMark) {
+ return doc.marks.get(multiMark);
+ }
+
+ @Override
+ public void Mark_insert(Mark mark, BaseDocument doc, int pos) throws InvalidMarkException, BadLocationException {
+ mark.insert(doc, pos);
+ }
}
// XXX: the same as the one in CloneableEditorSupport
diff --git a/editor.lib/src/org/netbeans/editor/BaseDocumentEvent.java b/editor.lib/src/org/netbeans/editor/BaseDocumentEvent.java
--- a/editor.lib/src/org/netbeans/editor/BaseDocumentEvent.java
+++ b/editor.lib/src/org/netbeans/editor/BaseDocumentEvent.java
@@ -50,7 +50,6 @@
import javax.swing.event.DocumentEvent;
import javax.swing.text.AttributeSet;
import javax.swing.undo.UndoableEdit;
-import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotUndoException;
import javax.swing.undo.CannotRedoException;
@@ -238,26 +237,6 @@
return getFixLineSyntaxState().getSyntaxUpdateTokenList();
}
- public String getDrawLayerName() {
- if (getType() != DocumentEvent.EventType.CHANGE) {
- throw new IllegalStateException("Can be called for CHANGE events only."); // NOI18N
- }
-
- DrawLayerChange dlc = (DrawLayerChange)findEdit(DrawLayerChange.class);
-
- return (dlc != null) ? dlc.getDrawLayerName() : null;
- }
-
- public int getDrawLayerVisibility() {
- if (getType() != DocumentEvent.EventType.CHANGE) {
- throw new IllegalStateException("Can be called for CHANGE events only."); // NOI18N
- }
-
- DrawLayerChange dlc = (DrawLayerChange)findEdit(DrawLayerChange.class);
-
- return (dlc != null) ? dlc.getDrawLayerVisibility() : -1;
- }
-
/** Whether this event is being fired because it's being undone. */
public boolean isInUndo() {
return inUndo;
@@ -268,7 +247,7 @@
return inRedo;
}
- public void undo() throws CannotUndoException {
+ public @Override void undo() throws CannotUndoException {
BaseDocument doc = (BaseDocument)getDocument();
doc.incrementDocVersion();
@@ -328,7 +307,7 @@
inUndo = false;
}
- public void redo() throws CannotRedoException {
+ public @Override void redo() throws CannotRedoException {
BaseDocument doc = (BaseDocument)getDocument();
doc.incrementDocVersion();
@@ -386,7 +365,7 @@
inRedo = false;
}
- public boolean addEdit(UndoableEdit anEdit) {
+ public @Override boolean addEdit(UndoableEdit anEdit) {
// Super of addEdit()
// if the number of changes gets too great, start using
@@ -458,7 +437,7 @@
}
}
- public boolean canUndo() {
+ public @Override boolean canUndo() {
// Super of canUndo
return !inProgress2 && alive2 && hasBeenDone2
// End super of canUndo
@@ -470,24 +449,24 @@
*
* @see #isInProgress
*/
- public boolean canRedo() {
+ public @Override boolean canRedo() {
// Super of canRedo
return !inProgress2 && alive2 && !hasBeenDone2;
// End super of canRedo
}
- public boolean isInProgress() {
+ public @Override boolean isInProgress() {
// Super of isInProgress()
return inProgress2;
// End super of isInProgress()
}
- public String getUndoPresentationName() {
- return "";
+ public @Override String getUndoPresentationName() {
+ return ""; //NOI18N
}
- public String getRedoPresentationName() {
- return "";
+ public @Override String getRedoPresentationName() {
+ return ""; //NOI18N
}
/** Returns true if this event can be merged by the previous
@@ -532,7 +511,7 @@
* parts (words) and undoing/redoing them at once.
* This method returns true whether
*/
- public boolean replaceEdit(UndoableEdit anEdit) {
+ public @Override boolean replaceEdit(UndoableEdit anEdit) {
BaseDocument doc = (BaseDocument)getDocument();
if (anEdit instanceof BaseDocument.AtomicCompoundEdit) {
BaseDocument.AtomicCompoundEdit compEdit
@@ -557,7 +536,7 @@
return false;
}
- public void die() {
+ public @Override void die() {
// Super of die()
int size = edits.size();
for (int i = size-1; i >= 0; i--)
@@ -575,13 +554,13 @@
}
}
- public void end() {
+ public @Override void end() {
// Super of end()
inProgress2 = false;
// End super of end()
}
- public DocumentEvent.ElementChange getChange(Element elem) {
+ public @Override DocumentEvent.ElementChange getChange(Element elem) {
// Super of getChange()
if (changeLookup2 != null) {
return (DocumentEvent.ElementChange) changeLookup2.get(elem);
@@ -601,33 +580,11 @@
}
- public String toString() {
+ public @Override String toString() {
return System.identityHashCode(this) + " " + super.toString() // NOI18N
+ ", type=" + getType() // NOI18N
+ ((getType() != DocumentEvent.EventType.CHANGE)
? ("text='" + getText() + "'") : ""); // NOI18N
}
- /** Edit describing the change of the document draw-layers */
- static class DrawLayerChange extends AbstractUndoableEdit {
-
- String drawLayerName;
-
- int drawLayerVisibility;
-
- DrawLayerChange(String drawLayerName, int drawLayerVisibility) {
- this.drawLayerName = drawLayerName;
- this.drawLayerVisibility = drawLayerVisibility;
- }
-
- public String getDrawLayerName() {
- return drawLayerName;
- }
-
- public int getDrawLayerVisibility() {
- return drawLayerVisibility;
- }
-
- }
-
}
diff --git a/editor.lib/src/org/netbeans/editor/BaseTextUI.java b/editor.lib/src/org/netbeans/editor/BaseTextUI.java
--- a/editor.lib/src/org/netbeans/editor/BaseTextUI.java
+++ b/editor.lib/src/org/netbeans/editor/BaseTextUI.java
@@ -43,7 +43,6 @@
import java.awt.*;
import java.awt.event.ActionEvent;
-import java.beans.Customizer;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
@@ -67,9 +66,12 @@
import org.netbeans.api.editor.settings.SimpleValueNames;
import org.netbeans.modules.editor.lib2.EditorApiPackageAccessor;
import org.netbeans.editor.view.spi.LockView;
+import org.netbeans.lib.editor.view.GapDocumentView;
import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.modules.editor.lib.SettingsConversions;
+import org.netbeans.modules.editor.lib.drawing.DrawEngineDocView;
+import org.netbeans.modules.editor.lib.drawing.DrawEngineLineView;
import org.openide.util.WeakListeners;
/**
@@ -341,7 +343,7 @@
LockView lockView = (LockView) view;
lockView.lock();
try {
- DrawEngineDocView docView = (DrawEngineDocView)view.getView(0);
+ GapDocumentView docView = (GapDocumentView)view.getView(0);
doDamageRange = docView.checkDamageRange(p0, p1, p0Bias, p1Bias);
} finally {
lockView.unlock();
@@ -472,21 +474,13 @@
*/
public void changedUpdate(DocumentEvent evt) {
if (evt instanceof BaseDocumentEvent) {
- BaseDocumentEvent bdevt = (BaseDocumentEvent)evt;
- BaseDocument doc = (BaseDocument)bdevt.getDocument();
- String layerName = bdevt.getDrawLayerName();
- if (layerName != null) {
- getEditorUI().addLayer(doc.findLayer(layerName),
- bdevt.getDrawLayerVisibility());
- }else{ //temp
- try {
- JTextComponent comp = getComponent();
- if (comp!=null && comp.isShowing()) {
- getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
- }
- } catch (BadLocationException ex) {
- Utilities.annotateLoggable(ex);
+ try {
+ JTextComponent comp = getComponent();
+ if (comp!=null && comp.isShowing()) {
+ getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
}
+ } catch (BadLocationException ex) {
+ Utilities.annotateLoggable(ex);
}
}
}
diff --git a/editor.lib/src/org/netbeans/editor/BaseView.java b/editor.lib/src/org/netbeans/editor/BaseView.java
--- a/editor.lib/src/org/netbeans/editor/BaseView.java
+++ b/editor.lib/src/org/netbeans/editor/BaseView.java
@@ -49,6 +49,7 @@
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import javax.swing.text.BadLocationException;
+import org.netbeans.modules.editor.lib.drawing.DrawGraphics;
/**
* Base abstract view serves as parent for both
@@ -105,12 +106,11 @@
}
/** Get aligment along an X_AXIS or Y_AXIS */
- public float getAlignment(int axis) {
+ public @Override float getAlignment(int axis) {
return 0f;
}
- abstract void modelToViewDG(int pos, DrawGraphics dg)
- throws BadLocationException;
+ /* package */ abstract void modelToViewDG(int pos, DrawGraphics dg) throws BadLocationException;
/** Get y-coord value from position */
protected abstract int getYFromPos(int pos) throws BadLocationException;
@@ -267,7 +267,7 @@
}
- public String toString() {
+ public @Override String toString() {
return "BaseView=" + System.identityHashCode(this) // NOI18N
+ ", elem=" + getElement() + ", parent=" // NOI18N
+ System.identityHashCode(getParent());
diff --git a/editor.lib/src/org/netbeans/editor/Coloring.java b/editor.lib/src/org/netbeans/editor/Coloring.java
--- a/editor.lib/src/org/netbeans/editor/Coloring.java
+++ b/editor.lib/src/org/netbeans/editor/Coloring.java
@@ -49,6 +49,8 @@
import javax.swing.text.AttributeSet;
import javax.swing.text.StyleConstants;
import org.netbeans.api.editor.settings.EditorStyleConstants;
+import org.netbeans.modules.editor.lib.drawing.ColoringAccessor;
+import org.netbeans.modules.editor.lib.drawing.DrawContext;
/**
* Immutable class that stores font and foreground and background colors.
@@ -137,7 +139,9 @@
private Color rightBorderLineColor;
private Color bottomBorderLineColor;
private Color leftBorderLineColor;
-
+
+ private final String cacheLock = new String("Coloring.cacheLock"); //NOI18N
+
/** Cache holding the [original-font, derived-font] pairs
* and also original [fore-color, derived-fore-color] pairs.
* This helps to avoid the repetitive computations of the
@@ -334,7 +338,7 @@
}
/** Apply this coloring to draw context. */
- public void apply(DrawContext ctx) {
+ private void apply(DrawContext ctx) {
// Possibly change font
if (font != null) {
if (fontMode == FONT_MODE_DEFAULT) {
@@ -343,7 +347,7 @@
} else { // non-default font-mode
Font origFont = ctx.getFont();
if (origFont != null) {
- synchronized (fontAndForeColorCache) {
+ synchronized (cacheLock) {
Font f = (Font)fontAndForeColorCache.get(origFont);
if (f == null) {
f = modifyFont(origFont);
@@ -363,7 +367,7 @@
} else { // has alpha
Color origForeColor = ctx.getForeColor();
if (origForeColor != null) {
- synchronized (fontAndForeColorCache) {
+ synchronized (cacheLock) {
Color fc = (Color)fontAndForeColorCache.get(origForeColor);
if (fc == null) {
fc = modifyForeColor(origForeColor);
@@ -383,7 +387,7 @@
} else { // non-default back color-mode
Color origBackColor = ctx.getBackColor();
if (origBackColor != null) {
- synchronized (backColorCache) {
+ synchronized (cacheLock) {
Color bc = (Color)backColorCache.get(origBackColor);
if (bc == null) {
bc = modifyBackColor(origBackColor);
@@ -436,7 +440,7 @@
} else { // non-default font-mode
Font origFont = c.getFont();
if (origFont != null) {
- synchronized (fontAndForeColorCache) {
+ synchronized (cacheLock) {
Font f = (Font)fontAndForeColorCache.get(origFont);
if (f == null) {
f = modifyFont(origFont);
@@ -456,7 +460,7 @@
} else { // non-default fore color-mode
Color origForeColor = c.getForeground();
if (origForeColor != null) {
- synchronized (fontAndForeColorCache) {
+ synchronized (cacheLock) {
Color fc = (Color)fontAndForeColorCache.get(origForeColor);
if (fc == null) {
fc = modifyForeColor(origForeColor);
@@ -476,7 +480,7 @@
} else { // non-default back color-mode
Color origBackColor = c.getBackground();
if (origBackColor != null) {
- synchronized (backColorCache) {
+ synchronized (cacheLock) {
Color bc = (Color)backColorCache.get(origBackColor);
if (bc == null) {
bc = modifyBackColor(origBackColor);
@@ -518,7 +522,7 @@
} else { // non-default font-mode
if (newFont != null) {
- synchronized (fontAndForeColorCache) {
+ synchronized (cacheLock) {
Font f = (Font)fontAndForeColorCache.get(newFont);
if (f == null) {
f = modifyFont(newFont);
@@ -541,7 +545,7 @@
} else { // non-default fore color-mode
if (newForeColor != null) {
- synchronized (fontAndForeColorCache) {
+ synchronized (cacheLock) {
Color fc = (Color)fontAndForeColorCache.get(newForeColor);
if (fc == null) {
fc = modifyForeColor(newForeColor);
@@ -561,7 +565,7 @@
} else { // non-default back color-mode
newBackColor = backColor;
if (newBackColor != null) {
- synchronized (backColorCache) {
+ synchronized (cacheLock) {
Color bc = (Color)backColorCache.get(newBackColor);
if (bc == null) {
bc = modifyBackColor(newBackColor);
@@ -851,5 +855,15 @@
new Integer(applyMode)
};
}
-
+
+ static {
+ ColoringAccessor.register(new Accessor());
+ }
+
+ private static final class Accessor extends ColoringAccessor {
+ @Override
+ public void apply(Coloring c, DrawContext ctx) {
+ c.apply(ctx);
+ }
+ } // End of Accessor class
}
diff --git a/editor.lib/src/org/netbeans/editor/DocumentContent.java b/editor.lib/src/org/netbeans/editor/DocumentContent.java
--- a/editor.lib/src/org/netbeans/editor/DocumentContent.java
+++ b/editor.lib/src/org/netbeans/editor/DocumentContent.java
@@ -50,6 +50,9 @@
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.UndoableEdit;
import org.netbeans.lib.editor.util.AbstractCharSequence;
+import org.netbeans.modules.editor.lib.impl.BasePosition;
+import org.netbeans.modules.editor.lib.impl.MarkVector;
+import org.netbeans.modules.editor.lib.impl.MultiMark;
/**
* Content of the document.
diff --git a/editor.lib/src/org/netbeans/editor/DrawLayerFactory.java b/editor.lib/src/org/netbeans/editor/DrawLayerFactory.java
deleted file mode 100644
--- a/editor.lib/src/org/netbeans/editor/DrawLayerFactory.java
+++ /dev/null
@@ -1,877 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.editor;
-
-import java.awt.Color;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.text.Style;
-import javax.swing.text.StyleConstants;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.View;
-import org.netbeans.api.editor.settings.FontColorNames;
-
-/**
- * Various draw layers are located here
- *
- * @author Miloslav Metelka
- * @version 1.00
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
-public class DrawLayerFactory {
-
- private static final Logger LOG = Logger.getLogger(DrawLayerFactory.class.getName());
-
- /** Syntax draw layer name */
- public static final String SYNTAX_LAYER_NAME = "syntax-layer"; // NOI18N
-
- /** Syntax draw layer visibility */
- public static final int SYNTAX_LAYER_VISIBILITY = 1000;
-
- /** Annotation draw layer name */
- public static final String ANNOTATION_LAYER_NAME = "annotation-layer"; // NOI18N
-
- /** Annotation draw layer visibility */
- public static final int ANNOTATION_LAYER_VISIBILITY = 2100;
-
- /** Highlight search layer name */
- public static final String HIGHLIGHT_SEARCH_LAYER_NAME = "highlight-search-layer"; // NOI18N
-
- /** Highlight search layer visibility */
- public static final int HIGHLIGHT_SEARCH_LAYER_VISIBILITY = 9000;
-
- /** Incremental search layer name */
- public static final String INC_SEARCH_LAYER_NAME = "inc-search-layer"; // NOI18N
-
- /** Incremental search layer visibility */
- public static final int INC_SEARCH_LAYER_VISIBILITY = 9500;
-
- /** Search block layer name */
- public static final String BLOCK_SEARCH_LAYER_NAME = "block-search-layer"; // NOI18N
-
- /** Search block layer visibility */
- public static final int BLOCK_SEARCH_LAYER_VISIBILITY = 8500;
-
- /** Selection draw layer name */
- public static final String CARET_LAYER_NAME = "caret-layer"; // NOI18N
-
- /** Selection draw layer visibility */
- public static final int CARET_LAYER_VISIBILITY = 10000;
-
-
- /** Guarded layer name */
- public static final String GUARDED_LAYER_NAME = "guarded-layer"; // NOI18N
-
- /** Guarded layer visibility */
- public static final int GUARDED_LAYER_VISIBILITY = 1400;
-
-
- /**
- * Layer that colors the text according to the tokens that were parsed.
- * It's active all the time.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class SyntaxLayer extends DrawLayer.AbstractLayer {
-
- public SyntaxLayer() {
- super(SYNTAX_LAYER_NAME);
- }
-
- public void init(DrawContext ctx) {
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- return true;
- }
-
- public void updateContext(DrawContext ctx) {
- // Get the token type and docColorings
- TokenID tokenID = ctx.getTokenID();
- TokenContextPath tcp = ctx.getTokenContextPath();
- if (tokenID != null && tcp != null) {
- // Get the coloring according the name of the token
- String fullName = tcp.getFullTokenName(tokenID);
- Coloring c = ctx.getEditorUI().getColoring(fullName);
- if (c != null) {
- c.apply(ctx);
-
- } else { // Token coloring null, try category
- TokenCategory cat = tokenID.getCategory();
- if (cat != null) {
- fullName = tcp.getFullTokenName(cat);
- c = ctx.getEditorUI().getColoring(fullName);
- if (c != null) {
- c.apply(ctx);
- }
- }
- }
- }
- }
-
- }
-
-
- /**
- * This layer colors the line by a color specified in constructor
- * It requires only activation mark since it deactivates automatically
- * at the end of line.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static abstract class ColorLineLayer extends DrawLayer.AbstractLayer {
-
- /** Coloring to use for highlighting */
- Coloring coloring;
-
- public ColorLineLayer(String name) {
- super(name);
- }
-
- public boolean extendsEOL() {
- return true;
- }
-
- public void init(DrawContext ctx) {
- coloring = null;
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- boolean active;
- if (mark == null) {
- View view = ctx instanceof DrawEngine.DrawInfo ? ((DrawEngine.DrawInfo)ctx).view.getParent() : null;
- if (view instanceof DrawEngineLineView) {
- DrawEngineLineView delv = (DrawEngineLineView)view;
- mark = getFoldedMark(delv, getName());
- if (mark == null) {
- view = delv.getView(delv.getViewCount() -1);
- if (view instanceof DrawEngineLineView) {
- delv = (DrawEngineLineView) view;
- mark = getFoldedMark(delv, getName());
- }
- }
- }
- }
- 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 void updateContext(DrawContext ctx) {
- if (coloring == null) {
- coloring = getColoring(ctx);
- }
- if (coloring != null) {
- coloring.apply(ctx);
- }
- }
-
- protected abstract Coloring getColoring(DrawContext ctx);
-
- }
-
-
- /** Layer that covers selection services provided by caret.
- * This layer assumes that both caretMark and selectionMark in
- * BaseCaret are properly served so that their active flags
- * are properly set.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class CaretLayer extends DrawLayer.AbstractLayer {
-
- Coloring coloring;
-
- public CaretLayer() {
- super(CARET_LAYER_NAME);
- }
-
- public boolean extendsEmptyLine() {
- return true;
- }
-
- public void init(DrawContext ctx) {
- coloring = null;
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- boolean active;
- if (mark != null) {
- active = mark.activateLayer;
- } else {
- JTextComponent c = ctx.getEditorUI().getComponent();
- active = (c != null) && Utilities.isSelectionShowing(c)
- && ctx.getFragmentOffset() >= c.getSelectionStart()
- && ctx.getFragmentOffset() < c.getSelectionEnd();
- }
-
- return active;
- }
-
- public void updateContext(DrawContext ctx) {
- if (coloring == null) {
- coloring = ctx.getEditorUI().getColoring(FontColorNames.SELECTION_COLORING);
- }
- if (coloring != null) {
- coloring.apply(ctx);
- }
- }
-
- }
-
-
- /** Highlight search layer highlights all occurences
- * of the searched string in text.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class HighlightSearchLayer extends DrawLayer.AbstractLayer {
-
- /** Pairs of start and end position of the found string */
- int blocks[] = new int[] { -1, -1 };
-
- /** Coloring to use for highlighting */
- Coloring coloring;
-
- /** Current index for painting */
- int curInd;
-
- /** Enabled flag */
- boolean enabled;
-
- public HighlightSearchLayer() {
- super(HIGHLIGHT_SEARCH_LAYER_NAME);
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- 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 boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- boolean active;
- if (enabled) {
- int pos = ctx.getFragmentOffset();
- if (pos == blocks[curInd]) {
- active = true;
- setNextActivityChangeOffset(blocks[curInd + 1]);
-
- } else if (pos == blocks[curInd + 1]) {
- active = false;
- curInd += 2;
- setNextActivityChangeOffset(blocks[curInd]);
- if (pos == blocks[curInd]) { // just follows
- setNextActivityChangeOffset(blocks[curInd + 1]);
- active = true;
- }
-
- } else {
- setNextActivityChangeOffset(blocks[curInd]);
- active = false;
- }
- } else {
- active = false;
- }
-
- return active;
- }
-
- public void updateContext(DrawContext ctx) {
- int pos = ctx.getFragmentOffset();
- if (pos >= blocks[curInd] && pos < blocks[curInd + 1]) {
- if (coloring == null) {
- coloring = ctx.getEditorUI().getColoring(FontColorNames.HIGHLIGHT_SEARCH_COLORING);
- }
- if (coloring != null) {
- coloring.apply(ctx);
- }
- }
- }
-
- }
-
- /** Layer covering incremental search. There are just two positions
- * begining and end of the searched string
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class IncSearchLayer extends DrawLayer.AbstractLayer {
-
- /** Position where the searched string begins */
- int pos;
-
- /** Length of area to highlight */
- int len;
-
- /** Whether this layer is enabled */
- boolean enabled;
-
- boolean invert;
-
- public IncSearchLayer() {
- super(INC_SEARCH_LAYER_NAME);
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- void setArea(int pos, int len) {
- this.pos = pos;
- this.len = len;
- }
-
- public int getOffset() {
- return pos;
- }
-
- public int getLength() {
- return len;
- }
-
- public void init(DrawContext ctx) {
- setNextActivityChangeOffset(enabled ? pos : Integer.MAX_VALUE);
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- boolean active = false;
- if (enabled) {
- if (ctx.getFragmentOffset() == pos) {
- active = true;
- setNextActivityChangeOffset(pos + len);
- }
- }
-
- return active;
- }
-
- /** current INC_SEARCH_COLORING is used only in block search.
- * if there is no search, use selection
- * @param invert if true - selection coloring is used
- */
- void setInversion(boolean invert){
- this.invert = invert;
- }
-
- public void updateContext(DrawContext ctx) {
- if (!invert) {
- Coloring coloring = ctx.getEditorUI().getColoring(FontColorNames.INC_SEARCH_COLORING);
- if (coloring != null) {
- coloring.apply(ctx);
- }
- } else {
- Coloring invertedColoring = ctx.getEditorUI().getColoring(FontColorNames.SELECTION_COLORING);
- if (invertedColoring != null) {
- invertedColoring.apply(ctx);
- }
- }
- }
- } // End of IncSearchLayer class
-
- /**
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class BlockSearchLayer extends DrawLayer.AbstractLayer {
-
- /** Position where the searched string begins */
- int pos;
-
- /** Length of area to highlight */
- int len;
-
- /** Whether this layer is enabled */
- boolean enabled;
-
- public BlockSearchLayer() {
- super(BLOCK_SEARCH_LAYER_NAME);
- }
-
- public boolean extendsEmptyLine(){
- return true;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- void setArea(int pos, int len) {
- this.pos = pos;
- this.len = len;
- }
-
- int getOffset() {
- return pos;
- }
-
- int getLength() {
- return len;
- }
-
- public void init(DrawContext ctx) {
- setNextActivityChangeOffset(enabled ? pos : Integer.MAX_VALUE);
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- boolean active = false;
- if (enabled) {
- int fragOffset = ctx.getFragmentOffset();
- if (fragOffset >= pos && fragOffset<(pos+len)) {
- active = true;
- try {
- BaseDocument doc = ctx.getEditorUI().getDocument();
- int nextRowStartPos = Utilities.getRowStart(
- doc, fragOffset, 1);
- if (nextRowStartPos < 0) { // end of doc
- nextRowStartPos = Integer.MAX_VALUE;
- }
- setNextActivityChangeOffset(Math.min(nextRowStartPos,(pos+len)));
-
- } catch (BadLocationException e) {
- active = false;
- }
-
- }
- }
-
- return active;
- }
-
- public void updateContext(DrawContext ctx) {
- Coloring coloring = ctx.getEditorUI().getColoring(FontColorNames.BLOCK_SEARCH_COLORING);
- if (coloring != null) {
- coloring.apply(ctx);
- }
- }
- } // End of BlockSearchLayer class
-
-//
-// XXX: Deprecated and not used anymore. Can be removed.
-//
-// /** Layer for guarded blocks
-// *
-// * @deprecated Please use Highlighting SPI instead, for details see
-// * Editor Library 2.
-// */
-// static class GuardedLayer extends ColorLineLayer {
-//
-// GuardedDocument doc;
-//
-// GuardedLayer() {
-// super(GUARDED_LAYER_NAME);
-// }
-//
-// public void init(DrawContext ctx) {
-// super.init(ctx);
-// doc = (GuardedDocument)ctx.getEditorUI().getDocument();
-// }
-//
-// public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
-// boolean active;
-// if (mark != null) {
-// active = mark.activateLayer;
-// } else {
-// active = doc.isPosGuarded(ctx.getFragmentOffset());
-// }
-//
-// return active;
-// }
-//
-// protected Coloring getColoring(DrawContext ctx) {
-// return ctx.getEditorUI().getColoring(SettingsNames.GUARDED_COLORING);
-// }
-//
-// }
-
-
-
- /**
- * Style layer getting color settings from particular style
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class StyleLayer extends DrawLayer.AbstractLayer {
-
- protected Style style;
-
- protected MarkChain markChain;
-
- protected Color backColor;
-
- protected Color foreColor;
-
- public StyleLayer(String layerName, BaseDocument doc, Style style) {
- super(layerName);
- this.style = style;
- markChain = new MarkChain(doc, layerName);
- }
-
- public boolean extendsEOL() {
- return true;
- }
-
- public final MarkChain getMarkChain() {
- return markChain;
- }
-
- public void init(DrawContext ctx) {
- foreColor = StyleConstants.getForeground(style);
- backColor = StyleConstants.getBackground(style);
- }
-
- 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 updateContext(DrawContext ctx) {
- if (foreColor != null) {
- ctx.setForeColor(foreColor);
- }
- if (backColor != null) {
- ctx.setBackColor(backColor);
- }
- }
-
- public String toString() {
- return super.toString() + ((markChain != null) ? (", " + markChain) : ""); // NOI18N
- }
-
- }
-
- /**
- * Test layer for coloring the specific words
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class WordColoringLayer extends DrawLayer.AbstractLayer {
-
- protected StringMap stringMap = new StringMap();
-
- public WordColoringLayer(String name) {
- super(name);
- }
-
- public void put(String s, Coloring c) {
- stringMap.put(s, c);
- }
-
- public void put(String[] strings, Coloring c) {
- for (int i = 0; i < strings.length; i++) {
- put(strings[i], c);
- }
- }
-
- public void put(List stringList, Coloring c) {
- String strings[] = new String[stringList.size()];
- stringList.toArray(strings);
- put(strings, c);
- }
-
- public void init(DrawContext ctx) {
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- return true;
- }
-
- public void updateContext(DrawContext ctx) {
- Coloring c = (Coloring)stringMap.get(ctx.getBuffer(),
- ctx.getTokenOffset(), ctx.getTokenLength());
- if (c != null) {
- c.apply(ctx);
- }
- }
-
- }
-
- /**
- * Annotation layer for drawing of annotations. Each mark which is stored in markChain has
- * corresponding Annotation. More than one Annotation can share one mark. In this case
- * the only one annotation is active and this must be drawn.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static class AnnotationLayer extends DrawLayer.AbstractLayer {
-
- /** Current coloring */
- private Coloring coloring;
-
- /** Chain of marks attached to this layer */
- private MarkChain markChain;
-
- public AnnotationLayer(BaseDocument doc) {
- super(ANNOTATION_LAYER_NAME);
- coloring = null;
- markChain = new MarkChain(doc, ANNOTATION_LAYER_NAME);
- }
-
- /** Get chain of marks attached to this draw layer
- * @return mark chain */
- public final MarkChain getMarkChain() {
- return markChain;
- }
-
- public boolean extendsEOL() {
- return true;
- }
-
- public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
- int nextActivityOffset;
- coloring = null;
-// LOG.setLevel(Level.FINE);
-// if (LOG.isLoggable(Level.FINE)) {
-// LOG.fine(" ctx-offset=" + ctx.getFragmentOffset() + ", mark=" + mark + '\n');
-// }
-
- if (mark == null) {
- View view = ctx instanceof DrawEngine.DrawInfo ? ((DrawEngine.DrawInfo)ctx).view : null;
- if (view instanceof DrawEngineLineView) {
- mark = getFoldedMark((DrawEngineLineView)view, getName());
- }
- }
-
- if (mark == null) {
- return false;
- }
-
- if (ctx.getEditorUI().getComponent() == null || !mark.activateLayer) {
- return false;
- }
-
- BaseDocument doc = ctx.getEditorUI().getDocument();
-
- // Gets the active annotation attached to this mark. It is possible that
- // no active annotation might exist for the mark, e.g. there can be
- // mark at the beginning of the line for a whole line annotation
- // and there can be mark in the middle of the line for a line-part annotation
- AnnotationDesc anno = doc.getAnnotations().getActiveAnnotation(mark);
- if (anno == null) {
- // if no active annotation was found for the given mark, check
- // whether we are not already drawing some other annotation. If that's
- // true we have to continue drawing it (means return true here)
- AnnotationDesc activeAnno = doc.getAnnotations().getLineActiveAnnotation(mark);
- if (activeAnno == null) {
- return false;
- }
- if (ctx.getFragmentOffset() >= activeAnno.getOffset()) {
- if (ctx.getFragmentOffset() < activeAnno.getOffset() + activeAnno.getLength() || activeAnno.isWholeLine()) {
- coloring = activeAnno.getColoring();
- return true;
- }
- }
- return false;
- }
-
-// if (LOG.isLoggable(Level.FINE)) {
-// LOG.log(Level.FINE, "anno: o=" + anno.getOffset() + ", l=" + anno.getLength() + ", wl=" + anno.isWholeLine()
-// + ", m=" + mark + ", ctx-offset=" + ctx.getFragmentOffset() + '\n');
-// }
- if (anno.isWholeLine()) {
- try {
- nextActivityOffset = Utilities.getRowEnd(doc, ctx.getFragmentOffset());
- } catch (BadLocationException ble) {
- LOG.log(Level.FINE, null, ble);
- return false;
- }
- } else {
- if (ctx.getFragmentOffset() < anno.getOffset()) { // Queried below annotation start
- setNextActivityChangeOffset(anno.getOffset());
- return false;
- }
- nextActivityOffset = anno.getOffset() + anno.getLength();
- if (ctx.getFragmentOffset() >= nextActivityOffset) { // Queried above annotation end
- try {
- setNextActivityChangeOffset(Utilities.getRowEnd(doc, ctx.getFragmentOffset()));
- } catch (BadLocationException ble) {
- LOG.log(Level.FINE, null, ble);
- return false;
- }
- return false;
- }
- }
-
- setNextActivityChangeOffset(nextActivityOffset);
- coloring = anno.getColoring();
-
-// The following code ensures that if active annotation does not
-// have highlight the color of next one will be used.
-// It was decided that it will not be used
-//
-// if (coloring.getBackColor() == null) {
-// AnnotationDesc[] annos = doc.getAnnotations().getPasiveAnnotations(anno.getLine());
-// if (annos != null) {
-// for (int i=0; iUsing of DrawLayer
s has been deprecated.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public DrawLayer findLayer(String layerName) {
- return drawLayerList.findLayer(layerName);
- }
-
- /**
- * Add new layer and use its priority to position it in the chain.
- * If there's the layer with same visibility then the inserted layer
- * will be placed after it.
- *
- *
Using of DrawLayer
s has been deprecated.
- *
- * @param layer layer to insert into the chain
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public boolean addLayer(DrawLayer layer, int visibility) {
- return drawLayerList.add(layer, visibility);
- }
-
- /**
- * Using of DrawLayer
s has been deprecated.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public DrawLayer removeLayer(String layerName) {
- return drawLayerList.remove(layerName);
- }
-
public void repaint(int startY) {
repaint(startY, component.getHeight());
}
@@ -1767,4 +1715,103 @@
public void setPopupMenu(JPopupMenu popupMenu) {
this.popupMenu = popupMenu;
}
+
+ static {
+ EditorUiAccessor.register(new Accessor());
+ }
+
+ private static final class Accessor extends EditorUiAccessor {
+
+ @Override
+ public boolean isLineNumberVisible(EditorUI eui) {
+ return eui.lineNumberVisible;
+ }
+
+ @Override
+ public Coloring getColoring(EditorUI eui, String coloringName) {
+ return eui.getColoring(coloringName);
+ }
+
+ @Override
+ public int getLineNumberMaxDigitCount(EditorUI eui) {
+ return eui.lineNumberMaxDigitCount;
+ }
+
+ @Override
+ public int getLineNumberWidth(EditorUI eui) {
+ return eui.lineNumberWidth;
+ }
+
+ @Override
+ public int getLineNumberDigitWidth(EditorUI eui) {
+ return eui.lineNumberDigitWidth;
+ }
+
+ @Override
+ public Insets getLineNumberMargin(EditorUI eui) {
+ return eui.getLineNumberMargin();
+ }
+
+ @Override
+ public int getLineHeight(EditorUI eui) {
+ return eui.getLineHeight();
+ }
+
+ @Override
+ public Coloring getDefaultColoring(EditorUI eui) {
+ return eui.getDefaultColoring();
+ }
+
+ @Override
+ public int getDefaultSpaceWidth(EditorUI eui) {
+ return eui.defaultSpaceWidth;
+ }
+
+ @Override
+ public Map, ?> getRenderingHints(EditorUI eui) {
+ return eui.renderingHints;
+ }
+
+ @Override
+ public Rectangle getExtentBounds(EditorUI eui) {
+ return eui.getExtentBounds();
+ }
+
+ @Override
+ public Insets getTextMargin(EditorUI eui) {
+ return eui.getTextMargin();
+ }
+
+ @Override
+ public int getTextLeftMarginWidth(EditorUI eui) {
+ return eui.textLeftMarginWidth;
+ }
+
+ @Override
+ public boolean getTextLimitLineVisible(EditorUI eui) {
+ return eui.textLimitLineVisible;
+ }
+
+ @Override
+ public Color getTextLimitLineColor(EditorUI eui) {
+ return eui.getTextLimitLineColor();
+ }
+
+ @Override
+ public int getTextLimitWidth(EditorUI eui) {
+ return eui.textLimitWidth;
+ }
+
+ @Override
+ public int getLineAscent(EditorUI eui) {
+ return eui.getLineAscent();
+ }
+
+ @Override
+ public void paint(EditorUI eui, Graphics g) {
+ eui.paint(g);
+ }
+
+ } // End of Accessor class
+
}
diff --git a/editor.lib/src/org/netbeans/editor/GuardedDocument.java b/editor.lib/src/org/netbeans/editor/GuardedDocument.java
--- a/editor.lib/src/org/netbeans/editor/GuardedDocument.java
+++ b/editor.lib/src/org/netbeans/editor/GuardedDocument.java
@@ -42,7 +42,6 @@
package org.netbeans.editor;
import java.text.MessageFormat;
-import java.util.Hashtable;
import java.util.Enumeration;
import java.awt.Color;
import java.awt.Font;
@@ -105,9 +104,6 @@
/** Style context to hold the styles */
protected StyleContext styles;
- /** Style to layer name mapping */
- protected Hashtable stylesToLayers;
-
/** Name of the normal style. The normal style is used to reset the effect
* of all styles applied to the line.
*/
@@ -169,7 +165,6 @@
private void init(StyleContext styles) {
this.styles = styles;
- stylesToLayers = new Hashtable(5);
guardedBlockChain = new MarkBlockChain(this) {
protected @Override Mark createBlockStartMark() {
MarkFactory.ContextMark startMark = new MarkFactory.ContextMark(Position.Bias.Forward, false);
@@ -300,17 +295,6 @@
}
}
- public void setCharacterAttributes(int offset, int length, AttributeSet attribs, boolean replace) {
- if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == true) {
- guardedBlockChain.addBlock(offset, offset + length, false); // no concat
- fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
- }
- if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == false) {
- guardedBlockChain.removeBlock(offset, offset + length);
- fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
- }
- }
-
public @Override void runAtomic(Runnable r) {
if (debugAtomic) {
System.out.println("GuardedDocument.runAtomic() called"); // NOI18N
@@ -376,30 +360,28 @@
return new GuardedDocumentEvent(this, offset, length, type);
}
+ /** Set the name for normal style. Normal style is used to reset the effect
+ * of all aplied styles.
+ */
+ public void setNormalStyleName(String normalStyleName) {
+ this.normalStyleName = normalStyleName;
+ }
+
+ /** Fetches the list of style names */
+ public Enumeration getStyleNames() {
+ return styles.getStyleNames();
+ }
+
+ // ------------------------------------------------------------------------
+ // StyleDocument implementation
+ // ------------------------------------------------------------------------
+
/** Adds style to the document */
public Style addStyle(String styleName, Style parent) {
- String layerName = (String)stylesToLayers.get(styleName);
- if (layerName == null) {
- layerName = styleName; // same layer name as style name
- addStyleToLayerMapping(styleName, layerName);
- }
-
Style style = styles.addStyle(styleName, parent);
- if (findLayer(layerName) == null) { // not created by default
- readLock();
- try {
- addStyledLayer(layerName, style);
- } finally {
- readUnlock();
- }
- }
return style;
}
- public void addStyleToLayerMapping(String styleName, String layerName) {
- stylesToLayers.put(styleName, layerName);
- }
-
/** Removes style from document */
public void removeStyle(String styleName) {
styles.removeStyle(styleName);
@@ -410,16 +392,15 @@
return styles.getStyle(styleName);
}
- /** Set the name for normal style. Normal style is used to reset the effect
- * of all aplied styles.
- */
- public void setNormalStyleName(String normalStyleName) {
- this.normalStyleName = normalStyleName;
- }
-
- /** Fetches the list of style names */
- public Enumeration getStyleNames() {
- return styles.getStyleNames();
+ public void setCharacterAttributes(int offset, int length, AttributeSet attribs, boolean replace) {
+ if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == true) {
+ guardedBlockChain.addBlock(offset, offset + length, false); // no concat
+ fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
+ }
+ if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == false) {
+ guardedBlockChain.removeBlock(offset, offset + length);
+ fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
+ }
}
/** Change attributes for part of the text. */
@@ -440,49 +421,11 @@
* @param s the style to set
*/
public void setLogicalStyle(int pos, Style s) {
- readLock();
- try {
- pos = Utilities.getRowStart(this, pos);
- String layerName = (String)stylesToLayers.get(s.getName());
- // remove all applied styles
- DrawLayer[] layerArray = getDrawLayerList().currentLayers();
- for (int i = 0; i < layerArray.length; i++) {
- if (layerArray[i] instanceof DrawLayerFactory.StyleLayer) {
- ((DrawLayerFactory.StyleLayer)layerArray[i]).markChain.removeMark(pos);
- }
- }
- // now set the requested style
- DrawLayerFactory.StyleLayer styleLayer
- = (DrawLayerFactory.StyleLayer)findLayer(layerName);
- if (styleLayer != null) {
- styleLayer.markChain.addMark(pos);
- }
- fireChangedUpdate(getDocumentEvent(
- pos, 0, DocumentEvent.EventType.CHANGE, null)); // enough to say length 0
- } catch (BadLocationException e) {
- // do nothing for invalid positions
- } finally {
- readUnlock();
- }
}
/** Get logical style for position in paragraph */
public Style getLogicalStyle(int pos) {
- try {
- pos = Utilities.getRowStart(this, pos);
- DrawLayer[] layerArray = getDrawLayerList().currentLayers();
- for (int i = 0; i < layerArray.length; i++) {
- DrawLayer layer = layerArray[i];
- if (layer instanceof DrawLayerFactory.StyleLayer) {
- if (((DrawLayerFactory.StyleLayer)layer).markChain.isMark(pos)) {
- return ((DrawLayerFactory.StyleLayer)layer).style;
- }
- }
- }
- return getStyle(normalStyleName); // no style found
- } catch (BadLocationException e) {
- return null;
- }
+ return null;
}
/**
@@ -534,32 +477,8 @@
return new Font("Default",Font.BOLD,12); // NOI18N
}
- /**
- * Using of DrawLayer
s has been deprecated.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- protected DrawLayer addStyledLayer(String layerName, Style style) {
- if (layerName != null) {
- try {
- int indColon = layerName.indexOf(':'); //NOI18N
- int layerVisibility = Integer.parseInt(layerName.substring(indColon + 1));
- DrawLayer layer = new DrawLayerFactory.StyleLayer(layerName, this, style);
-
- addLayer(layer, layerVisibility);
- return layer;
-
- } catch (NumberFormatException e) {
- // wrong name, let it pass
- }
- }
- return null;
- }
-
public @Override String toStringDetail() {
return super.toStringDetail()
- + getDrawLayerList()
+ ",\nGUARDED blocks:\n" + guardedBlockChain; // NOI18N
}
diff --git a/editor.lib/src/org/netbeans/editor/LeafView.java b/editor.lib/src/org/netbeans/editor/LeafView.java
--- a/editor.lib/src/org/netbeans/editor/LeafView.java
+++ b/editor.lib/src/org/netbeans/editor/LeafView.java
@@ -51,6 +51,9 @@
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.event.DocumentEvent;
+import org.netbeans.modules.editor.lib.drawing.DrawContext;
+import org.netbeans.modules.editor.lib.drawing.DrawEngine;
+import org.netbeans.modules.editor.lib.drawing.DrawGraphics;
/**
* Leaf view implementation. This corresponds and requires leaf element
@@ -103,17 +106,17 @@
protected int mainHeight;
/** Draw graphics for converting position to coords */
- ModelToViewDG modelToViewDG = new ModelToViewDG();
+ final ModelToViewDG modelToViewDG = new ModelToViewDG();
/** Draw graphics for converting coords to position */
- ViewToModelDG viewToModelDG = new ViewToModelDG();
+ final ViewToModelDG viewToModelDG = new ViewToModelDG();
/** Construct new base view */
public LeafView(Element elem) {
super(elem);
}
- public void setParent(View parent) {
+ public @Override void setParent(View parent) {
super.setParent(parent);
if (getParent() != null) {
@@ -173,7 +176,8 @@
int pos = getPosFromY(clipY + clipHeight - 1);
int endPos = Utilities.getRowEnd(doc, pos);
int baseY = getYFromPos(startPos);
- DrawEngine.getDrawEngine().draw(new DrawGraphics.GraphicsDG(g),
+ DrawEngine.getDrawEngine().draw(
+ new DrawGraphics.GraphicsDG(g),
editorUI, startPos, endPos,
getBaseX(baseY), baseY, Integer.MAX_VALUE
);
@@ -249,17 +253,17 @@
}
/** Returns the number of child views in this view. */
- public final int getViewCount() {
+ public @Override final int getViewCount() {
return 0;
}
/** Gets the n-th child view. */
- public final View getView(int n) {
+ public @Override final View getView(int n) {
return null;
}
/** !!! osetrit konec view -> jump na dalsi v branchview */
- public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
+ public @Override int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
int direction, Position.Bias[] biasRet)
throws BadLocationException {
if (biasRet != null) {
@@ -342,7 +346,7 @@
return ret;
}
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1,
+ public @Override Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1,
Shape a) throws BadLocationException {
Rectangle r0 = (Rectangle)modelToView(p0, a, b0);
Rectangle r1 = (Rectangle)modelToView(p1, a, b1);
@@ -413,7 +417,7 @@
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
*/
- public void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
+ public @Override void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
try {
BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
EditorUI editorUI = getEditorUI();
@@ -449,7 +453,7 @@
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
*/
- public void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
+ public @Override void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
try {
BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
EditorUI editorUI = getEditorUI();
@@ -482,7 +486,7 @@
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
*/
- public void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
+ public @Override void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
try {
if (getComponent().isShowing()) {
getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
@@ -501,7 +505,7 @@
Rectangle r;
- public boolean targetOffsetReached(int pos, char ch, int x,
+ public @Override boolean targetOffsetReached(int pos, char ch, int x,
int charWidth, DrawContext ctx) {
r.x = x;
r.y = getY();
@@ -533,7 +537,7 @@
return offset;
}
- public boolean targetOffsetReached(int offset, char ch, int x,
+ public @Override boolean targetOffsetReached(int offset, char ch, int x,
int charWidth, DrawContext ctx) {
if (offset <= eolOffset) {
if (x + charWidth < targetX) {
diff --git a/editor.lib/src/org/netbeans/editor/Mark.java b/editor.lib/src/org/netbeans/editor/Mark.java
--- a/editor.lib/src/org/netbeans/editor/Mark.java
+++ b/editor.lib/src/org/netbeans/editor/Mark.java
@@ -48,6 +48,7 @@
import javax.swing.text.Element;
import javax.swing.text.Position;
import javax.swing.text.Position.Bias;
+import org.netbeans.modules.editor.lib.impl.MultiMark;
/**
* Marks hold the relative position in the document.
diff --git a/editor.lib/src/org/netbeans/editor/MarkBlockChain.java b/editor.lib/src/org/netbeans/editor/MarkBlockChain.java
--- a/editor.lib/src/org/netbeans/editor/MarkBlockChain.java
+++ b/editor.lib/src/org/netbeans/editor/MarkBlockChain.java
@@ -44,7 +44,6 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import javax.swing.text.BadLocationException;
-import javax.swing.text.Position;
/**
* Support class for chain of MarkBlocks
@@ -354,33 +353,7 @@
return pos;
}
- public static class LayerChain extends MarkBlockChain {
-
- private String layerName;
-
- public LayerChain(BaseDocument doc, String layerName) {
- super(doc);
- this.layerName = layerName;
- }
-
- public final String getLayerName() {
- return layerName;
- }
-
- protected Mark createBlockStartMark() {
- MarkFactory.DrawMark startMark = new MarkFactory.DrawMark(layerName, null);
- startMark.activateLayer = true;
- return startMark;
- }
-
- protected Mark createBlockEndMark() {
- MarkFactory.DrawMark endMark = new MarkFactory.DrawMark(layerName, null, Position.Bias.Backward);
- return endMark;
- }
-
- }
-
- public String toString() {
+ public @Override String toString() {
return "MarkBlockChain: currentBlock=" + currentBlock + "\nblock chain: " // NOI18N
+ (chain != null ? ("\n" + chain.toStringChain()) : " Empty"); // NOI18N
}
diff --git a/editor.lib/src/org/netbeans/editor/MarkFactory.java b/editor.lib/src/org/netbeans/editor/MarkFactory.java
--- a/editor.lib/src/org/netbeans/editor/MarkFactory.java
+++ b/editor.lib/src/org/netbeans/editor/MarkFactory.java
@@ -41,7 +41,6 @@
package org.netbeans.editor;
-import java.lang.ref.WeakReference;
import javax.swing.text.Position;
/**
@@ -97,7 +96,7 @@
}
/** When removal occurs */
- protected void removeUpdateAction(int pos, int len) {
+ protected @Override void removeUpdateAction(int pos, int len) {
try {
remove();
} catch (InvalidMarkException e) {
@@ -124,176 +123,4 @@
}
- /** Activation mark for particular layer. When layer is not active
- * its updateContext() method is not called.
- */
- public static class DrawMark extends ContextMark {
-
- /** Activation flag means either activate layer or deactivate it */
- protected boolean activateLayer;
-
- /** Reference to draw layer this mark belogns to */
- String layerName;
-
- /** Reference to extended UI if this draw mark is info-specific or
- * null if it's document-wide.
- */
- WeakReference editorUIRef;
-
- public DrawMark(String layerName, EditorUI editorUI) {
- this(layerName, editorUI, Position.Bias.Forward);
- }
-
- public DrawMark(String layerName, EditorUI editorUI, Position.Bias bias) {
- super(bias, false);
- this.layerName = layerName;
- setEditorUI(editorUI);
- }
-
- public boolean isDocumentMark() {
- return (editorUIRef == null);
- }
-
- public EditorUI getEditorUI() {
- if (editorUIRef != null) {
- return (EditorUI)editorUIRef.get();
- }
- return null;
- }
-
- public void setEditorUI(EditorUI editorUI) {
- this.editorUIRef = (editorUI != null) ? new WeakReference(editorUI) : null;
- }
-
- public boolean isValidUI() {
- return !(editorUIRef != null && editorUIRef.get() == null);
- }
-
- public void setActivateLayer(boolean activateLayer) {
- this.activateLayer = activateLayer;
- }
-
- public boolean getActivateLayer() {
- return activateLayer;
- }
-
- public boolean removeInvalid() {
- if (!isValidUI() && isValid()) {
- try {
- this.remove();
- } catch (InvalidMarkException e) {
- throw new IllegalStateException(e.toString());
- }
- return true; // invalid and removed
- }
- return false; // valid
- }
-
- public String toString() {
- try {
- return "pos=" + getOffset() + ", line=" + getLine(); // NOI18N
- } catch (InvalidMarkException e) {
- return "mark not valid"; // NOI18N
- }
- }
-
- }
-
- /** Support for draw marks chained in double linked list */
- public static class ChainDrawMark extends DrawMark {
-
- /** Next mark in chain */
- protected ChainDrawMark next;
-
- /** Previous mark in chain */
- protected ChainDrawMark prev;
-
- public ChainDrawMark(String layerName, EditorUI editorUI) {
- this(layerName, editorUI, Position.Bias.Forward);
- }
-
- public ChainDrawMark(String layerName, EditorUI editorUI, Position.Bias bias) {
- super(layerName, editorUI, bias);
- }
-
- public final ChainDrawMark getNext() {
- return next;
- }
-
- public final void setNext(ChainDrawMark mark) {
- next = mark;
- }
-
- /** Set next mark in chain */
- public void setNextChain(ChainDrawMark mark) {
- this.next = mark;
- if (mark != null) {
- mark.prev = this;
- }
- }
-
- public final ChainDrawMark getPrev() {
- return prev;
- }
-
- public final void setPrev(ChainDrawMark mark) {
- prev = mark;
- }
-
- /** Set previous mark in chain */
- public void setPrevChain(ChainDrawMark mark) {
- this.prev = mark;
- if (mark != null) {
- mark.next = this;
- }
- }
-
- /** Insert mark before this one in chain
- * @return inserted mark
- */
- public ChainDrawMark insertChain(ChainDrawMark mark) {
- ChainDrawMark thisPrev = this.prev;
- mark.prev = thisPrev;
- mark.next = this;
- if (thisPrev != null) {
- thisPrev.next = mark;
- }
- this.prev = mark;
- return mark;
- }
-
- /** Remove this mark from the chain
- * @return next chain member or null for end of chain
- */
- public ChainDrawMark removeChain() {
- ChainDrawMark thisNext = this.next;
- ChainDrawMark thisPrev = this.prev;
- if (thisPrev != null) { // not the first
- thisPrev.next = thisNext;
- this.prev = null;
- }
- if (thisNext != null) { // not the last
- thisNext.prev = thisPrev;
- this.next = null;
- }
- try {
- this.remove(); // remove the mark from DocMarks
- } catch (InvalidMarkException e) {
- // already removed
- }
- return thisNext;
- }
-
- public String toStringChain() {
- return toString() + (next != null ? "\n" + next.toStringChain() : ""); // NOI18N
- }
-
- public String toString() {
- return super.toString() + ", " // NOI18N
- + ((prev != null) ? ((next != null) ? "chain member" // NOI18N
- : "last member") : ((next != null) ? "first member" // NOI18N
- : "standalone member")); // NOI18N
- }
-
- }
}
diff --git a/editor.lib/src/org/netbeans/editor/Utilities.java b/editor.lib/src/org/netbeans/editor/Utilities.java
--- a/editor.lib/src/org/netbeans/editor/Utilities.java
+++ b/editor.lib/src/org/netbeans/editor/Utilities.java
@@ -62,6 +62,7 @@
import org.netbeans.api.editor.EditorRegistry;
import org.netbeans.lib.editor.util.CharSequenceUtilities;
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
+import org.netbeans.modules.editor.lib.drawing.DrawEngineDocView;
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.openide.util.NbBundle;
diff --git a/editor.lib/src/org/netbeans/editor/ext/ExtCaret.java b/editor.lib/src/org/netbeans/editor/ext/ExtCaret.java
--- a/editor.lib/src/org/netbeans/editor/ext/ExtCaret.java
+++ b/editor.lib/src/org/netbeans/editor/ext/ExtCaret.java
@@ -52,216 +52,8 @@
public class ExtCaret extends BaseCaret {
- /**
- * Highlight row draw layer name.
- *
- *
Using DrawLayer
s has been deprecated and this constant
- * has no longer any meaning.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static final String HIGHLIGHT_ROW_LAYER_NAME = "highlight-row-layer"; // NOI18N
-
- /**
- * Highlight row draw layer visibility.
- *
- *
Using DrawLayer
s has been deprecated and this constant
- * has no longer any meaning.
- *
- * @deprecated Please use Highlighting SPI instead, for details see
- * Editor Library 2.
- */
- public static final int HIGHLIGHT_ROW_LAYER_VISIBILITY = 2050;
-
- /**
- * Highlight matching brace draw layer name
- *
- * @deprecated Please use Braces Matching SPI instead, for details see
- * Editor Braces Matching.
- */
- public static final String HIGHLIGHT_BRACE_LAYER_NAME = "highlight-brace-layer"; // NOI18N
-
- /**
- * Highlight matching brace draw layer visibility
- *
- * @deprecated Please use Braces Matching SPI instead, for details see
- * Editor Braces Matching.
- */
- public static final int HIGHLIGHT_BRACE_LAYER_VISIBILITY = 11000;
-
-// XXX: remove
-// /** Highlight a brace matching character before the caret */
-// public static final int MATCH_BRACE_BEFORE = -1;
-//
-// /** Highlight a brace matching character after (at) the caret */
-// public static final int MATCH_BRACE_AFTER = 0;
-//
-// /** Highlight a brace matching character either before or after caret;
-// the character before takes precedence. */
-// public static final int MATCH_BRACE_EITHER = java.lang.Integer.MAX_VALUE;
-//
-// /** Whether to hightlight the matching brace */
-// boolean highlightBrace;
-//
-// /** Coloring used for highlighting the matching brace */
-// Coloring highlightBraceColoring;
-//
-// /** Mark holding the starting position of the matching brace. */
-// MarkFactory.DrawMark highlightBraceStartMark;
-//
-// /** Mark holding the ending position of the matching brace. */
-// MarkFactory.DrawMark highlightBraceEndMark;
-//
-// /** Timer that fires when the matching brace should be displayed */
-// private Timer braceTimer;
-// private ActionListener braceTimerListener; // because of unwanted GC
-//
-// /** Signal that the next matching brace update
-// * will be immediate without waiting for the brace
-// * timer to fire the action.
-// */
-// private boolean matchBraceUpdateSync;
-//
-// /** Whether the brace starting and ending marks are currently valid or not.
-// * If they are not valid the block they delimit is not highlighted.
-// */
-// boolean braceMarksValid;
-//
-// boolean simpleMatchBrace;
-//
-// private int matchBraceOffset = MATCH_BRACE_EITHER;
-
static final long serialVersionUID =-4292670043122577690L;
-// XXX: remove
-// protected void modelChanged(BaseDocument oldDoc, BaseDocument newDoc) {
-// // Fix for #7108
-// braceMarksValid = false; // brace marks are out of date - new document
-// if (highlightBraceStartMark != null) {
-// try {
-// highlightBraceStartMark.remove();
-// } catch (InvalidMarkException e) {
-// }
-// highlightBraceStartMark = null;
-// }
-//
-// if (highlightBraceEndMark != null) {
-// try {
-// highlightBraceEndMark.remove();
-// } catch (InvalidMarkException e) {
-// }
-// highlightBraceEndMark = null;
-// }
-//
-// super.modelChanged( oldDoc, newDoc );
-// }
-
-// XXX: remove
-// /** Called when settings were changed. The method is called
-// * also in constructor, so the code must count with the evt being null.
-// */
-// public void settingsChange(SettingsChangeEvent evt) {
-// super.settingsChange(evt);
-// JTextComponent c = component;
-// if (c != null) {
-// Class kitClass = Utilities.getKitClass(c);
-//// XXX: remove
-//// EditorUI editorUI = Utilities.getEditorUI(c);
-//// highlightBraceColoring = editorUI.getColoring(
-//// ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_COLORING);
-////
-//// highlightBrace = SettingsUtil.getBoolean(kitClass,
-//// ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
-//// ExtSettingsDefaults.defaultHighlightMatchBrace);
-//// int highlightBraceDelay = SettingsUtil.getInteger(kitClass,
-//// ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_DELAY,
-//// ExtSettingsDefaults.defaultHighlightMatchBraceDelay);
-////
-//// if (highlightBrace) {
-//// if (highlightBraceDelay > 0) {
-//// // jdk12 compiler doesn't allow inside run()
-//// final JTextComponent c2 = component;
-////
-//// braceTimer = new Timer(highlightBraceDelay, null);
-//// braceTimerListener =
-//// new ActionListener() {
-//// public void actionPerformed(ActionEvent evt2) {
-//// SwingUtilities.invokeLater(
-//// new Runnable() {
-//// public void run() {
-//// if (c2 != null) {
-//// BaseDocument doc = Utilities.getDocument(c2);
-//// if( doc != null ) {
-//// doc.readLock();
-//// try {
-//// updateMatchBrace();
-//// } finally {
-//// doc.readUnlock();
-//// }
-//// }
-//// }
-//// }
-//// }
-//// );
-//// }
-//// };
-////
-//// braceTimer.addActionListener(new WeakTimerListener(braceTimerListener));
-//// braceTimer.setRepeats(false);
-//// } else {
-//// braceTimer = null; // signal no delay
-//// }
-//// c.repaint();
-//// }
-////
-//// simpleMatchBrace = SettingsUtil.getBoolean(kitClass,
-//// ExtSettingsNames.CARET_SIMPLE_MATCH_BRACE,
-//// ExtSettingsDefaults.defaultCaretSimpleMatchBrace);
-////
-// popupMenuEnabled = SettingsUtil.getBoolean(kitClass,
-// ExtSettingsNames.POPUP_MENU_ENABLED, true);
-// }
-// }
-// XXX: remove
-// public void install(JTextComponent c) {
-// EditorUI editorUI = Utilities.getEditorUI(c);
-// editorUI.addLayer(new HighlightBraceLayer(), HIGHLIGHT_BRACE_LAYER_VISIBILITY);
-// super.install(c);
-// }
-//
-// public void deinstall(JTextComponent c) {
-// EditorUI editorUI = Utilities.getEditorUI(c);
-// editorUI.removeLayer(HIGHLIGHT_BRACE_LAYER_NAME);
-// super.deinstall(c);
-// }
-//
-// /** Set the match brace offset.
-// * @param offset One of MATCH_BRACE_BEFORE
,
-// * MATCH_BRACE_AFTER
* or MATCH_BRACE_EITHER
.
-// */
-// public void setMatchBraceOffset(int offset) {
-// if(offset != MATCH_BRACE_BEFORE && offset != MATCH_BRACE_AFTER
-// && offset != MATCH_BRACE_EITHER) {
-// throw new IllegalArgumentException("Offset "+ offset + " not allowed\n");
-// }
-// matchBraceOffset = offset;
-// BaseDocument doc = Utilities.getDocument(component);
-// if( doc != null ) {
-// doc.readLock();
-// try {
-// updateMatchBrace();
-// } finally {
-// doc.readUnlock();
-// }
-// }
-// }
-//
-// /** Fetch the match brace offset. */
-// public int getMatchBraceOffset() {
-// return matchBraceOffset;
-// }
-
/**
* Update the matching brace of the caret. The document is read-locked
* while this method is called.
@@ -270,82 +62,7 @@
* Editor Braces Matching.
*/
protected void updateMatchBrace() {
-// XXX: remove
-// JTextComponent c = component;
-// if (c != null && highlightBrace) {
-// try {
-// EditorUI editorUI = Utilities.getEditorUI(c);
-// BaseDocument doc = (BaseDocument)c.getDocument();
-// int dotPos = getDot();
-// ExtSyntaxSupport sup = (ExtSyntaxSupport)doc.getSyntaxSupport();
-// boolean madeValid = false; // whether brace marks display were validated
-// int[] matchBlk = null;
-// if(dotPos > 0 && (matchBraceOffset == MATCH_BRACE_BEFORE
-// || matchBraceOffset == MATCH_BRACE_EITHER)) {
-// matchBlk = sup.findMatchingBlock(dotPos - 1, simpleMatchBrace);
-// }
-// if(matchBlk == null && (matchBraceOffset == MATCH_BRACE_AFTER
-// || matchBraceOffset == MATCH_BRACE_EITHER)) {
-// matchBlk = sup.findMatchingBlock(dotPos, simpleMatchBrace);
-// }
-// if (matchBlk != null) {
-// if (highlightBraceStartMark != null) {
-// int markStartPos = highlightBraceStartMark.getOffset();
-// int markEndPos = highlightBraceEndMark.getOffset();
-// if (markStartPos != matchBlk[0] || markEndPos != matchBlk[1]) {
-// editorUI.repaintBlock(markStartPos, markEndPos);
-// Utilities.moveMark(doc, highlightBraceStartMark, matchBlk[0]);
-// Utilities.moveMark(doc, highlightBraceEndMark, matchBlk[1]);
-// editorUI.repaintBlock(matchBlk[0], matchBlk[1]);
-// } else { // on the same position
-// if (!braceMarksValid) { // was not valid, must repaint
-// editorUI.repaintBlock(matchBlk[0], matchBlk[1]);
-// }
-// }
-// } else { // highlight mark is null
-// highlightBraceStartMark = new MarkFactory.DrawMark(
-// HIGHLIGHT_BRACE_LAYER_NAME, editorUI);
-// highlightBraceEndMark = new MarkFactory.DrawMark(
-// HIGHLIGHT_BRACE_LAYER_NAME, editorUI);
-// highlightBraceStartMark.setActivateLayer(true);
-// Utilities.insertMark(doc, highlightBraceStartMark, matchBlk[0]);
-// Utilities.insertMark(doc, highlightBraceEndMark, matchBlk[1]);
-// editorUI.repaintBlock(matchBlk[0], matchBlk[1]);
-// }
-// braceMarksValid = true;
-// madeValid = true;
-// }
-//
-// if (!madeValid) {
-// if (braceMarksValid) {
-// braceMarksValid = false;
-// editorUI.repaintBlock(highlightBraceStartMark.getOffset(),
-// highlightBraceEndMark.getOffset());
-// }
-// }
-// } catch (BadLocationException e) {
-// Utilities.annotateLoggable(e);
-// highlightBrace = false;
-// } catch (InvalidMarkException e) {
-// Utilities.annotateLoggable(e);
-// highlightBrace = false;
-// }
-// }
}
-// XXX: remove
-// protected void update(boolean scrollViewToCaret) {
-// if (highlightBrace) {
-// if (matchBraceUpdateSync || braceTimer == null) {
-// updateMatchBrace();
-// matchBraceUpdateSync = false;
-//
-// } else { // delay the brace update
-// braceTimer.restart();
-// }
-// }
-//
-// super.update(scrollViewToCaret);
-// }
/**
* Signal that the next matching brace update
@@ -357,49 +74,6 @@
* Editor Braces Matching.
*/
public void requestMatchBraceUpdateSync() {
-// XXX: remove
-// matchBraceUpdateSync = true;
}
-// XXX: remove
-// /* package */ static boolean NO_HIGHLIGHT_BRACE_LAYER = Boolean.getBoolean("nbeditor-no-HighlightBraceLayer");
-//
-// /**
-// * Draw layer to highlight the matching brace.
-// *
-// * XXX: The HighlightBraceLayer needs to be rewritten using the new Highlighting SPI.
-// */
-// class HighlightBraceLayer extends DrawLayer.AbstractLayer {
-//
-// public HighlightBraceLayer() {
-// super(HIGHLIGHT_BRACE_LAYER_NAME);
-// }
-//
-// public void init(DrawContext ctx) {
-// }
-//
-// public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
-// if (!NO_HIGHLIGHT_BRACE_LAYER && braceMarksValid) {
-// if (mark != null)
-// return mark.getActivateLayer();
-// try {
-// if (ctx.getStartOffset() > highlightBraceEndMark.getOffset())
-// return highlightBraceEndMark.getActivateLayer();
-// if (ctx.getStartOffset() > highlightBraceStartMark.getOffset())
-// return highlightBraceStartMark.getActivateLayer();
-// } catch (InvalidMarkException ex) {
-// }
-// }
-//
-// return false;
-// }
-//
-// public void updateContext(DrawContext ctx) {
-// if (!NO_HIGHLIGHT_BRACE_LAYER && highlightBraceColoring != null) {
-// highlightBraceColoring.apply(ctx);
-// }
-// }
-//
-// }
-
}
diff --git a/editor.lib/src/org/netbeans/modules/editor/lib/BeforeSaveTasks.java b/editor.lib/src/org/netbeans/modules/editor/lib/BeforeSaveTasks.java
--- a/editor.lib/src/org/netbeans/modules/editor/lib/BeforeSaveTasks.java
+++ b/editor.lib/src/org/netbeans/modules/editor/lib/BeforeSaveTasks.java
@@ -113,7 +113,7 @@
private void runTasks() {
doc.runAtomicAsUser (new Runnable () {
public void run () {
- CompoundEdit atomicEdit = EditorPackageAccessor.get().markAtomicEditsNonSignificant(doc);
+ CompoundEdit atomicEdit = EditorPackageAccessor.get().BaseDocument_markAtomicEditsNonSignificant(doc);
// Since these are before-save actions they should generally not prevent
// the save operation to succeed. Thus the possible exceptions thrown
// by the tasks will be notified but they will not prevent the save to succeed.
diff --git a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPackageAccessor.java b/editor.lib/src/org/netbeans/modules/editor/lib/EditorPackageAccessor.java
--- a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPackageAccessor.java
+++ b/editor.lib/src/org/netbeans/modules/editor/lib/EditorPackageAccessor.java
@@ -41,8 +41,13 @@
package org.netbeans.modules.editor.lib;
+import javax.swing.text.BadLocationException;
import javax.swing.undo.CompoundEdit;
import org.netbeans.editor.BaseDocument;
+import org.netbeans.editor.InvalidMarkException;
+import org.netbeans.editor.Mark;
+import org.netbeans.modules.editor.lib.impl.MarkVector;
+import org.netbeans.modules.editor.lib.impl.MultiMark;
/**
@@ -54,24 +59,31 @@
public abstract class EditorPackageAccessor {
- private static EditorPackageAccessor INSTANCE;
+ private static EditorPackageAccessor ACCESSOR = null;
- public static EditorPackageAccessor get() {
- if (INSTANCE == null) {
- // Cause api accessor impl to get initialized
- try {
- Class.forName(BaseDocument.class.getName(), true, EditorPackageAccessor.class.getClassLoader());
- } catch (ClassNotFoundException e) {
- // Should never happen
- }
- }
- return INSTANCE;
+ public static synchronized void register(EditorPackageAccessor accessor) {
+ assert ACCESSOR == null : "Can't register two package accessors!"; //NOI18N
+ ACCESSOR = accessor;
}
- public static void register(EditorPackageAccessor accessor) {
- INSTANCE = accessor;
+ public static synchronized EditorPackageAccessor get() {
+ // Trying to wake up BaseDocument ...
+ try {
+ Class clazz = Class.forName(BaseDocument.class.getName());
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+
+ assert ACCESSOR != null : "There is no package accessor available!"; //NOI18N
+ return ACCESSOR;
}
- public abstract CompoundEdit markAtomicEditsNonSignificant(BaseDocument doc);
+ protected EditorPackageAccessor() {
+ }
+
+ public abstract CompoundEdit BaseDocument_markAtomicEditsNonSignificant(BaseDocument doc);
+ public abstract MarkVector BaseDocument_getMarksStorage(BaseDocument doc);
+ public abstract Mark BaseDocument_getMark(BaseDocument doc, MultiMark multiMark);
+ public abstract void Mark_insert(Mark mark, BaseDocument doc, int pos) throws InvalidMarkException, BadLocationException;
}
diff --git a/editor.lib/src/org/netbeans/editor/CollapsedView.java b/editor.lib/src/org/netbeans/modules/editor/lib/drawing/CollapsedView.java
rename from editor.lib/src/org/netbeans/editor/CollapsedView.java
rename to editor.lib/src/org/netbeans/modules/editor/lib/drawing/CollapsedView.java
--- a/editor.lib/src/org/netbeans/editor/CollapsedView.java
+++ b/editor.lib/src/org/netbeans/modules/editor/lib/drawing/CollapsedView.java
@@ -39,7 +39,7 @@
* made subject to such option by the copyright holder.
*/
-package org.netbeans.editor;
+package org.netbeans.modules.editor.lib.drawing;
import java.awt.Container;
import java.awt.FontMetrics;
@@ -63,6 +63,14 @@
import org.netbeans.api.editor.settings.AttributesUtilities;
import org.netbeans.api.editor.settings.FontColorNames;
import org.netbeans.api.editor.settings.FontColorSettings;
+import org.netbeans.editor.BaseKit;
+import org.netbeans.editor.BaseTextUI;
+import org.netbeans.editor.Coloring;
+import org.netbeans.editor.EditorUI;
+import org.netbeans.editor.FoldingToolTip;
+import org.netbeans.editor.FontMetricsCache;
+import org.netbeans.editor.PopupManager;
+import org.netbeans.editor.Utilities;
import org.netbeans.editor.ext.ToolTipSupport;
import org.netbeans.editor.view.spi.LockView;
import org.openide.util.Lookup;
diff --git a/editor.lib/src/org/netbeans/editor/DrawContext.java b/editor.lib/src/org/netbeans/modules/editor/lib/drawing/DrawContext.java
rename from editor.lib/src/org/netbeans/editor/DrawContext.java
rename to editor.lib/src/org/netbeans/modules/editor/lib/drawing/DrawContext.java
--- a/editor.lib/src/org/netbeans/editor/DrawContext.java
+++ b/editor.lib/src/org/netbeans/modules/editor/lib/drawing/DrawContext.java
@@ -39,10 +39,13 @@
* made subject to such option by the copyright holder.
*/
-package org.netbeans.editor;
+package org.netbeans.modules.editor.lib.drawing;
import java.awt.Color;
import java.awt.Font;
+import org.netbeans.editor.EditorUI;
+import org.netbeans.editor.TokenContextPath;
+import org.netbeans.editor.TokenID;
/** This interface provides methods for
* getting and setting various drawing attributes.
diff --git a/editor.lib/src/org/netbeans/editor/DrawEngine.java b/editor.lib/src/org/netbeans/modules/editor/lib/drawing/DrawEngine.java
rename from editor.lib/src/org/netbeans/editor/DrawEngine.java
rename to editor.lib/src/org/netbeans/modules/editor/lib/drawing/DrawEngine.java
--- a/editor.lib/src/org/netbeans/editor/DrawEngine.java
+++ b/editor.lib/src/org/netbeans/modules/editor/lib/drawing/DrawEngine.java
@@ -39,7 +39,7 @@
* made subject to such option by the copyright holder.
*/
-package org.netbeans.editor;
+package org.netbeans.modules.editor.lib.drawing;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -50,6 +50,7 @@
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.BadLocationException;
@@ -59,6 +60,20 @@
import javax.swing.text.Segment;
import javax.swing.text.View;
import org.netbeans.api.editor.settings.FontColorNames;
+import org.netbeans.editor.Analyzer;
+import org.netbeans.editor.BaseDocument;
+import org.netbeans.editor.Coloring;
+import org.netbeans.editor.EditorDebug;
+import org.netbeans.editor.EditorUI;
+import org.netbeans.editor.FontMetricsCache;
+import org.netbeans.editor.InvalidMarkException;
+import org.netbeans.editor.Mark;
+import org.netbeans.editor.TokenContextPath;
+import org.netbeans.editor.TokenID;
+import org.netbeans.editor.Utilities;
+import org.netbeans.modules.editor.lib.EditorPackageAccessor;
+import org.netbeans.modules.editor.lib.impl.MarkVector;
+import org.netbeans.modules.editor.lib.impl.MultiMark;
/**
* This class is responsible for drawing editor components. It's a singleton.
@@ -67,7 +82,7 @@
*
* @author Miloslav Metelka
*/
-/* package */ final class DrawEngine {
+public final class DrawEngine {
private static final Logger LOG = Logger.getLogger(DrawEngine.class.getName());
@@ -92,9 +107,10 @@
return drawEngine;
}
- private void initLineNumbering(DrawInfo ctx) {
+ private void initLineNumbering(DrawInfo ctx, EditorUI eui) {
+ EditorUiAccessor accessor = EditorUiAccessor.get();
// Resolve whether line numbers will be painted
- ctx.lineNumbering = ctx.editorUI.lineNumberVisible
+ ctx.lineNumbering = accessor.isLineNumberVisible(eui)
&& ctx.drawGraphics.supportsLineNumbers();
// create buffer for showing line numbers
@@ -105,7 +121,7 @@
LOG.log(Level.WARNING, null, e);
}
- ctx.lineNumberColoring = ctx.editorUI.getColoring(FontColorNames.LINE_NUMBER_COLORING);
+ ctx.lineNumberColoring = accessor.getColoring(eui, FontColorNames.LINE_NUMBER_COLORING);
if (ctx.lineNumberColoring == null) {
ctx.lineNumberColoring = ctx.defaultColoring; // no number coloring found
@@ -128,7 +144,10 @@
lnForeColor = ctx.defaultColoring.getForeColor();
}
- ctx.lineNumberChars = new char[Math.max(ctx.editorUI.lineNumberMaxDigitCount, 1)];
+ ctx.lineNumberChars = new char[Math.max(accessor.getLineNumberMaxDigitCount(eui), 1)];
+ ctx.lineNumberWidth = accessor.getLineNumberWidth(eui);
+ ctx.lineNumberDigitWidth = accessor.getLineNumberDigitWidth(eui);
+ ctx.lineNumberMargin = accessor.getLineNumberMargin(eui);
if (ctx.graphics == null) {
ctx.syncedLineNumbering = true;
@@ -143,29 +162,39 @@
}
}
- private void initInfo(DrawInfo ctx) throws BadLocationException {
+ private void initInfo(DrawInfo ctx, EditorUI eui) throws BadLocationException {
if (ctx.startOffset < ctx.lineStartOffset) {
throw new BadLocationException("Invalid startOffset: " + ctx.startOffset + " < line start offset = " + ctx.lineStartOffset, ctx.startOffset); //NOI18N
}
if (ctx.endOffset > ctx.lineEndOffset) {
throw new BadLocationException("Invalid endOffset: " + ctx.endOffset + " > line end offset = " + ctx.lineEndOffset, ctx.endOffset); //NOI18N
}
-
+
+ EditorUiAccessor accessor = EditorUiAccessor.get();
+
ctx.x = ctx.startX;
ctx.y = ctx.startY;
- ctx.lineHeight = ctx.editorUI.getLineHeight();
- ctx.defaultColoring = ctx.editorUI.getDefaultColoring();
+ ctx.lineHeight = accessor.getLineHeight(eui);
+ ctx.defaultColoring = accessor.getDefaultColoring(eui);
ctx.tabSize = ctx.doc.getTabSize();
+ ctx.defaultSpaceWidth = accessor.getDefaultSpaceWidth(eui);
ctx.fragmentOffset = ctx.startOffset; // actual painting position
ctx.graphics = ctx.drawGraphics.getGraphics();
if (ctx.graphics != null) {
- if (ctx.editorUI.renderingHints != null) {
- ((Graphics2D)ctx.graphics).setRenderingHints(ctx.editorUI.renderingHints);
+ Map, ?> hints = accessor.getRenderingHints(eui);
+ if (hints != null) {
+ ((Graphics2D)ctx.graphics).setRenderingHints(hints);
}
}
- initLineNumbering(ctx);
+ ctx.extentBounds = accessor.getExtentBounds(eui);
+ ctx.textMargin = accessor.getTextMargin(eui);
+ ctx.textLeftMarginWidth = accessor.getTextLeftMarginWidth(eui);
+ ctx.textLimitLineVisible = accessor.getTextLimitLineVisible(eui);
+ ctx.textLimitLineColor = accessor.getTextLimitLineColor(eui);
+ ctx.textLimitWidth = accessor.getTextLimitWidth(eui);
+ initLineNumbering(ctx, eui);
// Initialize draw context
ctx.foreColor = ctx.defaultColoring.getForeColor();
@@ -177,12 +206,12 @@
ctx.drawGraphics.init(ctx);
ctx.drawGraphics.setDefaultBackColor(ctx.defaultColoring.getBackColor());
ctx.drawGraphics.setLineHeight(ctx.lineHeight);
- ctx.drawGraphics.setLineAscent(ctx.editorUI.getLineAscent());
+ ctx.drawGraphics.setLineAscent(accessor.getLineAscent(eui));
ctx.drawGraphics.setX(ctx.x);
ctx.drawGraphics.setY(ctx.y);
// Init all draw-layers
- ctx.layers = ctx.editorUI.getDrawLayerList().currentLayers();
+ ctx.layers = DrawLayerList.forComponent(ctx.component).currentLayers();
int layersLength = ctx.layers.length;
ctx.layerActives = new boolean[layersLength];
ctx.layerActivityChangeOffsets = new int[layersLength];
@@ -191,8 +220,8 @@
ctx.layers[i].init(ctx); // init all layers
}
- ctx.drawMarkList = new ArrayList