Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 97517 | Differences between
and this patch

Collapse All | Expand All

(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/WatchPanel.java (-4 / +4 lines)
 Lines 42-48    Link Here 
42
42
43
import java.awt.AWTKeyStroke;
43
import java.awt.AWTKeyStroke;
44
import java.awt.Dimension;
44
import java.awt.Dimension;
45
import java.awt.FontMetrics;
46
import java.awt.KeyboardFocusManager;
45
import java.awt.KeyboardFocusManager;
47
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionEvent;
48
import java.lang.reflect.InvocationTargetException;
47
import java.lang.reflect.InvocationTargetException;
 Lines 71-83    Link Here 
71
import java.awt.EventQueue;
70
import java.awt.EventQueue;
72
import java.awt.GridBagConstraints;
71
import java.awt.GridBagConstraints;
73
import java.awt.GridBagLayout;
72
import java.awt.GridBagLayout;
74
import java.awt.Insets;
75
import java.awt.event.ActionListener;
73
import java.awt.event.ActionListener;
76
import java.io.IOException;
74
import java.io.IOException;
77
import javax.swing.text.StyledDocument;
75
import javax.swing.text.StyledDocument;
78
import org.netbeans.api.debugger.Session;
76
import org.netbeans.api.debugger.Session;
79
import org.netbeans.editor.EditorUI;
77
import org.netbeans.editor.EditorUI;
80
import org.netbeans.editor.ext.ExtCaret;
81
import org.netbeans.spi.debugger.jpda.EditorContext;
78
import org.netbeans.spi.debugger.jpda.EditorContext;
82
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
79
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
83
import org.openide.ErrorManager;
80
import org.openide.ErrorManager;
 Lines 254-260    Link Here 
254
                if (eui == null) {
251
                if (eui == null) {
255
                    return ;
252
                    return ;
256
                }
253
                }
257
                eui.removeLayer(ExtCaret.HIGHLIGHT_ROW_LAYER_NAME);
254
                editorPane.putClientProperty(
255
                    "HighlightsLayerExcludes", //NOI18N
256
                    "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.CaretRowHighlighting$" //NOI18N
257
                );
258
                // Do not draw text limit line
258
                // Do not draw text limit line
259
                try {
259
                try {
260
                    java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N
260
                    java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N
(-)a/editor.lib/src/org/netbeans/editor/ActionFactory.java (-1 / +2 lines)
 Lines 85-90    Link Here 
85
import org.netbeans.api.progress.ProgressUtils;
85
import org.netbeans.api.progress.ProgressUtils;
86
import org.netbeans.modules.editor.lib2.search.EditorFindSupport;
86
import org.netbeans.modules.editor.lib2.search.EditorFindSupport;
87
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
87
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
88
import org.netbeans.lib.editor.view.GapBoxView;
88
import org.openide.util.NbBundle;
89
import org.openide.util.NbBundle;
89
import org.openide.util.WeakListeners;
90
import org.openide.util.WeakListeners;
90
import org.openide.util.actions.Presenter;
91
import org.openide.util.actions.Presenter;
 Lines 2281-2287    Link Here 
2281
        }
2282
        }
2282
        
2283
        
2283
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2284
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2284
            DrawEngineDocView rootView = (DrawEngineDocView)Utilities.getDocumentView(target);
2285
            GapBoxView rootView = (GapBoxView)Utilities.getDocumentView(target);
2285
            AbstractDocument adoc = (AbstractDocument)target.getDocument();
2286
            AbstractDocument adoc = (AbstractDocument)target.getDocument();
2286
2287
2287
            // Dump fold hierarchy
2288
            // Dump fold hierarchy
(-)a/editor.lib/src/org/netbeans/editor/Annotations.java (-11 / +4 lines)
 Lines 64-69    Link Here 
64
import javax.swing.JMenuItem;
64
import javax.swing.JMenuItem;
65
import javax.swing.SwingUtilities;
65
import javax.swing.SwingUtilities;
66
import org.netbeans.editor.ext.ExtKit;
66
import org.netbeans.editor.ext.ExtKit;
67
import org.netbeans.modules.editor.lib.drawing.ChainDrawMark;
68
import org.netbeans.modules.editor.lib.drawing.MarkChain;
67
import org.openide.awt.Actions;
69
import org.openide.awt.Actions;
68
import org.openide.awt.DynamicMenuContent;
70
import org.openide.awt.DynamicMenuContent;
69
import org.openide.util.ContextAwareAction;
71
import org.openide.util.ContextAwareAction;
 Lines 178-192    Link Here 
178
        
180
        
179
    }
181
    }
180
182
181
    /** Finds the drawing layer for annotations.
182
     * @return <code>null</code>
183
     * @deprecated Please use Highlighting SPI instead, for details see
184
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
185
     */
186
    public DrawLayerFactory.AnnotationLayer getLayer() {
187
        return null;
188
    }
189
190
    /** Add annotation */
183
    /** Add annotation */
191
    public void addAnnotation(AnnotationDesc anno) {
184
    public void addAnnotation(AnnotationDesc anno) {
192
185
 Lines 241-247    Link Here 
241
                    + ", docLen=" + doc.getLength()); // NOI18N
234
                    + ", docLen=" + doc.getLength()); // NOI18N
242
            }
235
            }
243
            // attach created mark to annotation
236
            // attach created mark to annotation
244
            MarkFactory.ChainDrawMark annoMark = chain.getAddedMark();
237
            ChainDrawMark annoMark = chain.getAddedMark();
245
            if (annoMark == null) {
238
            if (annoMark == null) {
246
                throw new NullPointerException();
239
                throw new NullPointerException();
247
            }
240
            }
 Lines 320-326    Link Here 
320
        int line;
313
        int line;
321
        synchronized (lineAnnotationsArray) {
314
        synchronized (lineAnnotationsArray) {
322
            // find LineAnnotations for the mark
315
            // find LineAnnotations for the mark
323
            MarkFactory.ChainDrawMark annoMark = (MarkFactory.ChainDrawMark)anno.getMark();
316
            ChainDrawMark annoMark = (ChainDrawMark)anno.getMark();
324
            if (annoMark == null) {
317
            if (annoMark == null) {
325
                // Already removed? See #116955
318
                // Already removed? See #116955
326
                return;
319
                return;
(-)a/editor.lib/src/org/netbeans/editor/BaseDocument.java (-36 / +19 lines)
 Lines 97-102    Link Here 
97
import org.netbeans.modules.editor.lib.FormatterOverride;
97
import org.netbeans.modules.editor.lib.FormatterOverride;
98
import org.netbeans.modules.editor.lib.TrailingWhitespaceRemove;
98
import org.netbeans.modules.editor.lib.TrailingWhitespaceRemove;
99
import org.netbeans.modules.editor.lib.SettingsConversions;
99
import org.netbeans.modules.editor.lib.SettingsConversions;
100
import org.netbeans.modules.editor.lib.drawing.DrawEngine;
101
import org.netbeans.modules.editor.lib.drawing.DrawGraphics;
102
import org.netbeans.modules.editor.lib.impl.MarkVector;
103
import org.netbeans.modules.editor.lib.impl.MultiMark;
100
import org.openide.util.Lookup;
104
import org.openide.util.Lookup;
101
import org.openide.util.RequestProcessor;
105
import org.openide.util.RequestProcessor;
102
import org.openide.util.RequestProcessor.Task;
106
import org.openide.util.RequestProcessor.Task;
 Lines 257-265    Link Here 
257
261
258
    private SyntaxSupport syntaxSupport;
262
    private SyntaxSupport syntaxSupport;
259
263
260
    /** Layer list for document level layers */
261
    private DrawLayerList drawLayerList = new DrawLayerList();
262
263
    /** Reset merging next created undoable edit to the last one. */
264
    /** Reset merging next created undoable edit to the last one. */
264
    boolean undoMergeReset;
265
    boolean undoMergeReset;
265
266
 Lines 2014-2051    Link Here 
2014
        return modified;
2015
        return modified;
2015
    }
2016
    }
2016
2017
2017
    /**
2018
     * Get the layer with the specified name. Using of <code>DrawLayer</code>s
2019
     * has been deprecated.
2020
     *
2021
     * @deprecated Please use Highlighting SPI instead, for details see
2022
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
2023
     */
2024
    public DrawLayer findLayer(String layerName) {
2025
        return drawLayerList.findLayer(layerName);
2026
    }
2027
2028
    /**
2029
     * Using of <code>DrawLayer</code>s has been deprecated.
2030
     *
2031
     * @deprecated Please use Highlighting SPI instead, for details see
2032
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
2033
     */
2034
    public boolean addLayer(DrawLayer layer, int visibility) {
2035
        if (drawLayerList.add(layer, visibility)) {
2036
            BaseDocumentEvent evt = getDocumentEvent(0, 0, DocumentEvent.EventType.CHANGE, null);
2037
            evt.addEdit(new BaseDocumentEvent.DrawLayerChange(layer.getName(), visibility));
2038
            fireChangedUpdate(evt);
2039
            return true;
2040
        } else {
2041
            return false;
2042
        }
2043
    }
2044
2045
    final DrawLayerList getDrawLayerList() {
2046
        return drawLayerList;
2047
    }
2048
2049
    private LineRootElement getLineRootElement() {
2018
    private LineRootElement getLineRootElement() {
2050
        return lineRootElement;
2019
        return lineRootElement;
2051
    }
2020
    }
 Lines 2445-2454    Link Here 
2445
    private static final class Accessor extends EditorPackageAccessor {
2414
    private static final class Accessor extends EditorPackageAccessor {
2446
2415
2447
        @Override
2416
        @Override
2448
        public CompoundEdit markAtomicEditsNonSignificant(BaseDocument doc) {
2417
        public CompoundEdit BaseDocument_markAtomicEditsNonSignificant(BaseDocument doc) {
2449
            return doc.markAtomicEditsNonSignificant();
2418
            return doc.markAtomicEditsNonSignificant();
2450
        }
2419
        }
2451
2420
2421
        @Override
2422
        public MarkVector BaseDocument_getMarksStorage(BaseDocument doc) {
2423
            return doc.marksStorage;
2424
        }
2425
2426
        @Override
2427
        public Mark BaseDocument_getMark(BaseDocument doc, MultiMark multiMark) {
2428
            return doc.marks.get(multiMark);
2429
        }
2430
2431
        @Override
2432
        public void Mark_insert(Mark mark, BaseDocument doc, int pos) throws InvalidMarkException, BadLocationException {
2433
            mark.insert(doc, pos);
2434
        }
2452
    }
2435
    }
2453
2436
2454
    // XXX: the same as the one in CloneableEditorSupport
2437
    // XXX: the same as the one in CloneableEditorSupport
(-)a/editor.lib/src/org/netbeans/editor/BaseDocumentEvent.java (-58 / +15 lines)
 Lines 50-56    Link Here 
50
import javax.swing.event.DocumentEvent;
50
import javax.swing.event.DocumentEvent;
51
import javax.swing.text.AttributeSet;
51
import javax.swing.text.AttributeSet;
52
import javax.swing.undo.UndoableEdit;
52
import javax.swing.undo.UndoableEdit;
53
import javax.swing.undo.AbstractUndoableEdit;
54
import javax.swing.undo.CannotUndoException;
53
import javax.swing.undo.CannotUndoException;
55
import javax.swing.undo.CannotRedoException;
54
import javax.swing.undo.CannotRedoException;
56
55
 Lines 238-263    Link Here 
238
        return getFixLineSyntaxState().getSyntaxUpdateTokenList();
237
        return getFixLineSyntaxState().getSyntaxUpdateTokenList();
239
    }
238
    }
240
    
239
    
241
    public String getDrawLayerName() {
242
        if (getType() != DocumentEvent.EventType.CHANGE) {
243
            throw new IllegalStateException("Can be called for CHANGE events only."); // NOI18N
244
        }
245
246
        DrawLayerChange dlc = (DrawLayerChange)findEdit(DrawLayerChange.class);
247
248
        return (dlc != null) ? dlc.getDrawLayerName() : null;
249
    }
250
251
    public int getDrawLayerVisibility() {
252
        if (getType() != DocumentEvent.EventType.CHANGE) {
253
            throw new IllegalStateException("Can be called for CHANGE events only."); // NOI18N
254
        }
255
256
        DrawLayerChange dlc = (DrawLayerChange)findEdit(DrawLayerChange.class);
257
258
        return (dlc != null) ? dlc.getDrawLayerVisibility() : -1;
259
    }
260
261
    /** Whether this event is being fired because it's being undone. */
240
    /** Whether this event is being fired because it's being undone. */
262
    public boolean isInUndo() {
241
    public boolean isInUndo() {
263
        return inUndo;
242
        return inUndo;
 Lines 268-274    Link Here 
268
        return inRedo;
247
        return inRedo;
269
    }
248
    }
270
249
271
    public void undo() throws CannotUndoException {
250
    public @Override void undo() throws CannotUndoException {
272
        BaseDocument doc = (BaseDocument)getDocument();
251
        BaseDocument doc = (BaseDocument)getDocument();
273
        doc.incrementDocVersion();
252
        doc.incrementDocVersion();
274
253
 Lines 328-334    Link Here 
328
        inUndo = false;
307
        inUndo = false;
329
    }
308
    }
330
309
331
    public void redo() throws CannotRedoException {
310
    public @Override void redo() throws CannotRedoException {
332
        BaseDocument doc = (BaseDocument)getDocument();
311
        BaseDocument doc = (BaseDocument)getDocument();
333
        doc.incrementDocVersion();
312
        doc.incrementDocVersion();
334
        
313
        
 Lines 386-392    Link Here 
386
        inRedo = false;
365
        inRedo = false;
387
    }
366
    }
388
367
389
    public boolean addEdit(UndoableEdit anEdit) {
368
    public @Override boolean addEdit(UndoableEdit anEdit) {
390
        // Super of addEdit()
369
        // Super of addEdit()
391
370
392
        // if the number of changes gets too great, start using
371
        // if the number of changes gets too great, start using
 Lines 458-464    Link Here 
458
        }
437
        }
459
    }
438
    }
460
439
461
    public boolean canUndo() {
440
    public @Override boolean canUndo() {
462
        // Super of canUndo
441
        // Super of canUndo
463
	return !inProgress2 && alive2 && hasBeenDone2
442
	return !inProgress2 && alive2 && hasBeenDone2
464
        // End super of canUndo
443
        // End super of canUndo
 Lines 470-493    Link Here 
470
     * 
449
     * 
471
     * @see	#isInProgress
450
     * @see	#isInProgress
472
     */
451
     */
473
    public boolean canRedo() {
452
    public @Override boolean canRedo() {
474
        // Super of canRedo
453
        // Super of canRedo
475
	return !inProgress2 && alive2 && !hasBeenDone2;
454
	return !inProgress2 && alive2 && !hasBeenDone2;
476
        // End super of canRedo
455
        // End super of canRedo
477
    }
456
    }
478
457
479
    public boolean isInProgress() {
458
    public @Override boolean isInProgress() {
480
        // Super of isInProgress()
459
        // Super of isInProgress()
481
        return inProgress2;
460
        return inProgress2;
482
        // End super of isInProgress()
461
        // End super of isInProgress()
483
    }
462
    }
484
463
485
    public String getUndoPresentationName() {
464
    public @Override String getUndoPresentationName() {
486
        return "";
465
        return ""; //NOI18N
487
    }
466
    }
488
467
489
    public String getRedoPresentationName() {
468
    public @Override String getRedoPresentationName() {
490
        return "";
469
        return ""; //NOI18N
491
    }
470
    }
492
471
493
    /** Returns true if this event can be merged by the previous
472
    /** Returns true if this event can be merged by the previous
 Lines 532-538    Link Here 
532
    * parts (words) and undoing/redoing them at once.
511
    * parts (words) and undoing/redoing them at once.
533
    * This method returns true whether 
512
    * This method returns true whether 
534
    */
513
    */
535
    public boolean replaceEdit(UndoableEdit anEdit) {
514
    public @Override boolean replaceEdit(UndoableEdit anEdit) {
536
        BaseDocument doc = (BaseDocument)getDocument();
515
        BaseDocument doc = (BaseDocument)getDocument();
537
        if (anEdit instanceof BaseDocument.AtomicCompoundEdit) {
516
        if (anEdit instanceof BaseDocument.AtomicCompoundEdit) {
538
            BaseDocument.AtomicCompoundEdit compEdit
517
            BaseDocument.AtomicCompoundEdit compEdit
 Lines 557-563    Link Here 
557
        return false;
536
        return false;
558
    }
537
    }
559
538
560
    public void die() {
539
    public @Override void die() {
561
        // Super of die()
540
        // Super of die()
562
	int size = edits.size();
541
	int size = edits.size();
563
	for (int i = size-1; i >= 0; i--)
542
	for (int i = size-1; i >= 0; i--)
 Lines 575-587    Link Here 
575
        }
554
        }
576
    }
555
    }
577
556
578
    public void end() {
557
    public @Override void end() {
579
        // Super of end()
558
        // Super of end()
580
	inProgress2 = false;
559
	inProgress2 = false;
581
        // End super of end()
560
        // End super of end()
582
    }
561
    }
583
562
584
    public DocumentEvent.ElementChange getChange(Element elem) {
563
    public @Override DocumentEvent.ElementChange getChange(Element elem) {
585
        // Super of getChange()
564
        // Super of getChange()
586
        if (changeLookup2 != null) {
565
        if (changeLookup2 != null) {
587
            return (DocumentEvent.ElementChange) changeLookup2.get(elem);
566
            return (DocumentEvent.ElementChange) changeLookup2.get(elem);
 Lines 601-633    Link Here 
601
    }
580
    }
602
581
603
582
604
    public String toString() {
583
    public @Override String toString() {
605
        return System.identityHashCode(this) + " " + super.toString() // NOI18N
584
        return System.identityHashCode(this) + " " + super.toString() // NOI18N
606
               + ", type=" + getType() // NOI18N
585
               + ", type=" + getType() // NOI18N
607
               + ((getType() != DocumentEvent.EventType.CHANGE)
586
               + ((getType() != DocumentEvent.EventType.CHANGE)
608
                  ? ("text='" + getText() + "'") : ""); // NOI18N
587
                  ? ("text='" + getText() + "'") : ""); // NOI18N
609
    }
588
    }
610
589
611
    /** Edit describing the change of the document draw-layers */
612
    static class DrawLayerChange extends AbstractUndoableEdit {
613
614
        String drawLayerName;
615
616
        int drawLayerVisibility;
617
618
        DrawLayerChange(String drawLayerName, int drawLayerVisibility) {
619
            this.drawLayerName = drawLayerName;
620
            this.drawLayerVisibility = drawLayerVisibility;
621
        }
622
623
        public String getDrawLayerName() {
624
            return drawLayerName;
625
        }
626
627
        public int getDrawLayerVisibility() {
628
            return drawLayerVisibility;
629
        }
630
631
    }
632
    
633
}
590
}
(-)a/editor.lib/src/org/netbeans/editor/BaseTextUI.java (-16 / +10 lines)
 Lines 43-49    Link Here 
43
43
44
import java.awt.*;
44
import java.awt.*;
45
import java.awt.event.ActionEvent;
45
import java.awt.event.ActionEvent;
46
import java.beans.Customizer;
47
import java.beans.PropertyChangeListener;
46
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeEvent;
49
import java.util.ArrayList;
48
import java.util.ArrayList;
 Lines 67-75    Link Here 
67
import org.netbeans.api.editor.settings.SimpleValueNames;
66
import org.netbeans.api.editor.settings.SimpleValueNames;
68
import org.netbeans.modules.editor.lib2.EditorApiPackageAccessor;
67
import org.netbeans.modules.editor.lib2.EditorApiPackageAccessor;
69
import org.netbeans.editor.view.spi.LockView;
68
import org.netbeans.editor.view.spi.LockView;
69
import org.netbeans.lib.editor.view.GapDocumentView;
70
import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
70
import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
71
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
71
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
72
import org.netbeans.modules.editor.lib.SettingsConversions;
72
import org.netbeans.modules.editor.lib.SettingsConversions;
73
import org.netbeans.modules.editor.lib.drawing.DrawEngineDocView;
74
import org.netbeans.modules.editor.lib.drawing.DrawEngineLineView;
73
import org.openide.util.WeakListeners;
75
import org.openide.util.WeakListeners;
74
76
75
/**
77
/**
 Lines 341-347    Link Here 
341
                LockView lockView = (LockView) view;
343
                LockView lockView = (LockView) view;
342
                lockView.lock();
344
                lockView.lock();
343
                try {
345
                try {
344
                    DrawEngineDocView docView = (DrawEngineDocView)view.getView(0);
346
                    GapDocumentView docView = (GapDocumentView)view.getView(0);
345
                    doDamageRange = docView.checkDamageRange(p0, p1, p0Bias, p1Bias);
347
                    doDamageRange = docView.checkDamageRange(p0, p1, p0Bias, p1Bias);
346
                } finally {
348
                } finally {
347
                    lockView.unlock();
349
                    lockView.unlock();
 Lines 472-492    Link Here 
472
    */
474
    */
473
    public void changedUpdate(DocumentEvent evt) {
475
    public void changedUpdate(DocumentEvent evt) {
474
        if (evt instanceof BaseDocumentEvent) {
476
        if (evt instanceof BaseDocumentEvent) {
475
            BaseDocumentEvent bdevt = (BaseDocumentEvent)evt;
477
            try {
476
            BaseDocument doc = (BaseDocument)bdevt.getDocument();
478
                JTextComponent comp = getComponent();
477
            String layerName = bdevt.getDrawLayerName();
479
                if (comp!=null && comp.isShowing()) {
478
            if (layerName != null) {
480
                    getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
479
                getEditorUI().addLayer(doc.findLayer(layerName),
480
                        bdevt.getDrawLayerVisibility());
481
            }else{ //temp
482
                try {
483
                    JTextComponent comp = getComponent();
484
                    if (comp!=null && comp.isShowing()) {
485
                        getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
486
                    }
487
                } catch (BadLocationException ex) {
488
                    Utilities.annotateLoggable(ex);
489
                }
481
                }
482
            } catch (BadLocationException ex) {
483
                Utilities.annotateLoggable(ex);
490
            }
484
            }
491
        }
485
        }
492
    }
486
    }
(-)a/editor.lib/src/org/netbeans/editor/BaseView.java (-4 / +4 lines)
 Lines 49-54    Link Here 
49
import javax.swing.text.Element;
49
import javax.swing.text.Element;
50
import javax.swing.text.JTextComponent;
50
import javax.swing.text.JTextComponent;
51
import javax.swing.text.BadLocationException;
51
import javax.swing.text.BadLocationException;
52
import org.netbeans.modules.editor.lib.drawing.DrawGraphics;
52
53
53
/**
54
/**
54
* Base abstract view serves as parent for both
55
* Base abstract view serves as parent for both
 Lines 105-116    Link Here 
105
    }
106
    }
106
107
107
    /** Get aligment along an X_AXIS or Y_AXIS */
108
    /** Get aligment along an X_AXIS or Y_AXIS */
108
    public float getAlignment(int axis) {
109
    public @Override float getAlignment(int axis) {
109
        return 0f;
110
        return 0f;
110
    }
111
    }
111
112
112
    abstract void modelToViewDG(int pos, DrawGraphics dg)
113
    /* package */ abstract void modelToViewDG(int pos, DrawGraphics dg) throws BadLocationException;
113
    throws BadLocationException;
114
114
115
    /** Get y-coord value from position */
115
    /** Get y-coord value from position */
116
    protected abstract int getYFromPos(int pos) throws BadLocationException;
116
    protected abstract int getYFromPos(int pos) throws BadLocationException;
 Lines 267-273    Link Here 
267
267
268
    }
268
    }
269
269
270
    public String toString() {
270
    public @Override String toString() {
271
        return "BaseView=" + System.identityHashCode(this) // NOI18N
271
        return "BaseView=" + System.identityHashCode(this) // NOI18N
272
               + ", elem=" + getElement() + ", parent=" // NOI18N
272
               + ", elem=" + getElement() + ", parent=" // NOI18N
273
               + System.identityHashCode(getParent());
273
               + System.identityHashCode(getParent());
(-)a/editor.lib/src/org/netbeans/editor/Coloring.java (-12 / +26 lines)
 Lines 49-54    Link Here 
49
import javax.swing.text.AttributeSet;
49
import javax.swing.text.AttributeSet;
50
import javax.swing.text.StyleConstants;
50
import javax.swing.text.StyleConstants;
51
import org.netbeans.api.editor.settings.EditorStyleConstants;
51
import org.netbeans.api.editor.settings.EditorStyleConstants;
52
import org.netbeans.modules.editor.lib.drawing.ColoringAccessor;
53
import org.netbeans.modules.editor.lib.drawing.DrawContext;
52
54
53
/**
55
/**
54
* Immutable class that stores font and foreground and background colors.
56
* Immutable class that stores font and foreground and background colors.
 Lines 137-143    Link Here 
137
    private Color rightBorderLineColor;
139
    private Color rightBorderLineColor;
138
    private Color bottomBorderLineColor;
140
    private Color bottomBorderLineColor;
139
    private Color leftBorderLineColor;
141
    private Color leftBorderLineColor;
140
    
142
143
    private final String cacheLock = new String("Coloring.cacheLock"); //NOI18N
144
141
    /** Cache holding the [original-font, derived-font] pairs
145
    /** Cache holding the [original-font, derived-font] pairs
142
    * and also original [fore-color, derived-fore-color] pairs.
146
    * and also original [fore-color, derived-fore-color] pairs.
143
    * This helps to avoid the repetitive computations of the
147
    * This helps to avoid the repetitive computations of the
 Lines 334-340    Link Here 
334
    }
338
    }
335
339
336
    /** Apply this coloring to draw context. */
340
    /** Apply this coloring to draw context. */
337
    public void apply(DrawContext ctx) {
341
    private void apply(DrawContext ctx) {
338
        // Possibly change font
342
        // Possibly change font
339
        if (font != null) {
343
        if (font != null) {
340
            if (fontMode == FONT_MODE_DEFAULT) {
344
            if (fontMode == FONT_MODE_DEFAULT) {
 Lines 343-349    Link Here 
343
            } else { // non-default font-mode
347
            } else { // non-default font-mode
344
                Font origFont = ctx.getFont();
348
                Font origFont = ctx.getFont();
345
                if (origFont != null) {
349
                if (origFont != null) {
346
                    synchronized (fontAndForeColorCache) {
350
                    synchronized (cacheLock) {
347
                        Font f = (Font)fontAndForeColorCache.get(origFont);
351
                        Font f = (Font)fontAndForeColorCache.get(origFont);
348
                        if (f == null) {
352
                        if (f == null) {
349
                            f = modifyFont(origFont);
353
                            f = modifyFont(origFont);
 Lines 363-369    Link Here 
363
            } else { // has alpha
367
            } else { // has alpha
364
                Color origForeColor = ctx.getForeColor();
368
                Color origForeColor = ctx.getForeColor();
365
                if (origForeColor != null) {
369
                if (origForeColor != null) {
366
                    synchronized (fontAndForeColorCache) {
370
                    synchronized (cacheLock) {
367
                        Color fc = (Color)fontAndForeColorCache.get(origForeColor);
371
                        Color fc = (Color)fontAndForeColorCache.get(origForeColor);
368
                        if (fc == null) {
372
                        if (fc == null) {
369
                            fc = modifyForeColor(origForeColor);
373
                            fc = modifyForeColor(origForeColor);
 Lines 383-389    Link Here 
383
            } else { // non-default back color-mode
387
            } else { // non-default back color-mode
384
                Color origBackColor = ctx.getBackColor();
388
                Color origBackColor = ctx.getBackColor();
385
                if (origBackColor != null) {
389
                if (origBackColor != null) {
386
                    synchronized (backColorCache) {
390
                    synchronized (cacheLock) {
387
                        Color bc = (Color)backColorCache.get(origBackColor);
391
                        Color bc = (Color)backColorCache.get(origBackColor);
388
                        if (bc == null) {
392
                        if (bc == null) {
389
                            bc = modifyBackColor(origBackColor);
393
                            bc = modifyBackColor(origBackColor);
 Lines 436-442    Link Here 
436
            } else { // non-default font-mode
440
            } else { // non-default font-mode
437
                Font origFont = c.getFont();
441
                Font origFont = c.getFont();
438
                if (origFont != null) {
442
                if (origFont != null) {
439
                    synchronized (fontAndForeColorCache) {
443
                    synchronized (cacheLock) {
440
                        Font f = (Font)fontAndForeColorCache.get(origFont);
444
                        Font f = (Font)fontAndForeColorCache.get(origFont);
441
                        if (f == null) {
445
                        if (f == null) {
442
                            f = modifyFont(origFont);
446
                            f = modifyFont(origFont);
 Lines 456-462    Link Here 
456
            } else { // non-default fore color-mode
460
            } else { // non-default fore color-mode
457
                Color origForeColor = c.getForeground();
461
                Color origForeColor = c.getForeground();
458
                if (origForeColor != null) {
462
                if (origForeColor != null) {
459
                    synchronized (fontAndForeColorCache) {
463
                    synchronized (cacheLock) {
460
                        Color fc = (Color)fontAndForeColorCache.get(origForeColor);
464
                        Color fc = (Color)fontAndForeColorCache.get(origForeColor);
461
                        if (fc == null) {
465
                        if (fc == null) {
462
                            fc = modifyForeColor(origForeColor);
466
                            fc = modifyForeColor(origForeColor);
 Lines 476-482    Link Here 
476
            } else { // non-default back color-mode
480
            } else { // non-default back color-mode
477
                Color origBackColor = c.getBackground();
481
                Color origBackColor = c.getBackground();
478
                if (origBackColor != null) {
482
                if (origBackColor != null) {
479
                    synchronized (backColorCache) {
483
                    synchronized (cacheLock) {
480
                        Color bc = (Color)backColorCache.get(origBackColor);
484
                        Color bc = (Color)backColorCache.get(origBackColor);
481
                        if (bc == null) {
485
                        if (bc == null) {
482
                            bc = modifyBackColor(origBackColor);
486
                            bc = modifyBackColor(origBackColor);
 Lines 518-524    Link Here 
518
522
519
            } else { // non-default font-mode
523
            } else { // non-default font-mode
520
                if (newFont != null) {
524
                if (newFont != null) {
521
                    synchronized (fontAndForeColorCache) {
525
                    synchronized (cacheLock) {
522
                        Font f = (Font)fontAndForeColorCache.get(newFont);
526
                        Font f = (Font)fontAndForeColorCache.get(newFont);
523
                        if (f == null) {
527
                        if (f == null) {
524
                            f = modifyFont(newFont);
528
                            f = modifyFont(newFont);
 Lines 541-547    Link Here 
541
545
542
            } else { // non-default fore color-mode
546
            } else { // non-default fore color-mode
543
                if (newForeColor != null) {
547
                if (newForeColor != null) {
544
                    synchronized (fontAndForeColorCache) {
548
                    synchronized (cacheLock) {
545
                        Color fc = (Color)fontAndForeColorCache.get(newForeColor);
549
                        Color fc = (Color)fontAndForeColorCache.get(newForeColor);
546
                        if (fc == null) {
550
                        if (fc == null) {
547
                            fc = modifyForeColor(newForeColor);
551
                            fc = modifyForeColor(newForeColor);
 Lines 561-567    Link Here 
561
            } else { // non-default back color-mode
565
            } else { // non-default back color-mode
562
                newBackColor = backColor;
566
                newBackColor = backColor;
563
                if (newBackColor != null) {
567
                if (newBackColor != null) {
564
                    synchronized (backColorCache) {
568
                    synchronized (cacheLock) {
565
                        Color bc = (Color)backColorCache.get(newBackColor);
569
                        Color bc = (Color)backColorCache.get(newBackColor);
566
                        if (bc == null) {
570
                        if (bc == null) {
567
                            bc = modifyBackColor(newBackColor);
571
                            bc = modifyBackColor(newBackColor);
 Lines 851-855    Link Here 
851
            new Integer(applyMode)
855
            new Integer(applyMode)
852
        };
856
        };
853
    }
857
    }
854
    
858
859
    static {
860
        ColoringAccessor.register(new Accessor());
861
    }
862
863
    private static final class Accessor extends ColoringAccessor {
864
        @Override
865
        public void apply(Coloring c, DrawContext ctx) {
866
            c.apply(ctx);
867
        }
868
    } // End of Accessor class
855
}
869
}
(-)a/editor.lib/src/org/netbeans/editor/DocumentContent.java (+3 lines)
 Lines 50-55    Link Here 
50
import javax.swing.undo.CannotRedoException;
50
import javax.swing.undo.CannotRedoException;
51
import javax.swing.undo.UndoableEdit;
51
import javax.swing.undo.UndoableEdit;
52
import org.netbeans.lib.editor.util.AbstractCharSequence;
52
import org.netbeans.lib.editor.util.AbstractCharSequence;
53
import org.netbeans.modules.editor.lib.impl.BasePosition;
54
import org.netbeans.modules.editor.lib.impl.MarkVector;
55
import org.netbeans.modules.editor.lib.impl.MultiMark;
53
56
54
/**
57
/**
55
 * Content of the document.
58
 * Content of the document.
(-)a/editor.lib/src/org/netbeans/editor/DrawLayerFactory.java (-877 lines)
 Lines 1-877    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.editor;
43
44
import java.awt.Color;
45
import java.util.List;
46
import java.util.logging.Level;
47
import java.util.logging.Logger;
48
import javax.swing.text.Style;
49
import javax.swing.text.StyleConstants;
50
import javax.swing.text.BadLocationException;
51
import javax.swing.text.JTextComponent;
52
import javax.swing.text.View;
53
import org.netbeans.api.editor.settings.FontColorNames;
54
55
/**
56
 * Various draw layers are located here
57
 *
58
 * @author Miloslav Metelka
59
 * @version 1.00
60
 * 
61
 * @deprecated Please use Highlighting SPI instead, for details see
62
 *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
63
 */
64
public class DrawLayerFactory {
65
66
    private static final Logger LOG = Logger.getLogger(DrawLayerFactory.class.getName());
67
    
68
    /** Syntax draw layer name */
69
    public static final String SYNTAX_LAYER_NAME = "syntax-layer"; // NOI18N
70
71
    /** Syntax draw layer visibility */
72
    public static final int SYNTAX_LAYER_VISIBILITY = 1000;
73
74
    /** Annotation draw layer name */
75
    public static final String ANNOTATION_LAYER_NAME = "annotation-layer"; // NOI18N
76
77
    /** Annotation draw layer visibility */
78
    public static final int ANNOTATION_LAYER_VISIBILITY = 2100;
79
    
80
    /** Highlight search layer name */
81
    public static final String HIGHLIGHT_SEARCH_LAYER_NAME = "highlight-search-layer"; // NOI18N
82
83
    /** Highlight search layer visibility */
84
    public static final int HIGHLIGHT_SEARCH_LAYER_VISIBILITY = 9000;
85
86
    /** Incremental search layer name */
87
    public static final String INC_SEARCH_LAYER_NAME = "inc-search-layer"; // NOI18N
88
89
    /** Incremental search layer visibility */
90
    public static final int INC_SEARCH_LAYER_VISIBILITY = 9500;
91
    
92
    /** Search block layer name */
93
    public static final String BLOCK_SEARCH_LAYER_NAME = "block-search-layer"; // NOI18N
94
95
    /** Search block layer visibility */
96
    public static final int BLOCK_SEARCH_LAYER_VISIBILITY = 8500;
97
98
    /** Selection draw layer name */
99
    public static final String CARET_LAYER_NAME = "caret-layer"; // NOI18N
100
101
    /** Selection draw layer visibility */
102
    public static final int CARET_LAYER_VISIBILITY = 10000;
103
104
105
    /** Guarded layer name */
106
    public static final String GUARDED_LAYER_NAME = "guarded-layer"; // NOI18N
107
108
    /** Guarded layer visibility */
109
    public static final int GUARDED_LAYER_VISIBILITY = 1400;
110
111
112
    /** 
113
     * Layer that colors the text according to the tokens that were parsed.
114
     * It's active all the time.
115
     * 
116
     * @deprecated Please use Highlighting SPI instead, for details see
117
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
118
     */
119
    public static class SyntaxLayer extends DrawLayer.AbstractLayer {
120
121
        public SyntaxLayer() {
122
            super(SYNTAX_LAYER_NAME);
123
        }
124
125
        public void init(DrawContext ctx) {
126
        }
127
128
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
129
            return true;
130
        }
131
132
        public void updateContext(DrawContext ctx) {
133
            // Get the token type and docColorings
134
            TokenID tokenID = ctx.getTokenID();
135
            TokenContextPath tcp = ctx.getTokenContextPath();
136
            if (tokenID != null && tcp != null) {
137
                // Get the coloring according the name of the token
138
                String fullName = tcp.getFullTokenName(tokenID);
139
                Coloring c = ctx.getEditorUI().getColoring(fullName);
140
                if (c != null) {
141
                    c.apply(ctx);
142
143
                } else { // Token coloring null, try category
144
                    TokenCategory cat = tokenID.getCategory();
145
                    if (cat != null) {
146
                        fullName = tcp.getFullTokenName(cat);
147
                        c = ctx.getEditorUI().getColoring(fullName);
148
                        if (c !=  null) {
149
                            c.apply(ctx);
150
                        }
151
                    }
152
                }
153
            }
154
        }
155
156
    }
157
158
159
    /** 
160
     * This layer colors the line by a color specified in constructor
161
     * It requires only activation mark since it deactivates automatically
162
     * at the end of line.
163
     * 
164
     * @deprecated Please use Highlighting SPI instead, for details see
165
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
166
     */
167
    public static abstract class ColorLineLayer extends DrawLayer.AbstractLayer {
168
169
        /** Coloring to use for highlighting */
170
        Coloring coloring;
171
172
        public ColorLineLayer(String name) {
173
            super(name);
174
        }
175
176
        public boolean extendsEOL() {
177
            return true;
178
        }
179
180
        public void init(DrawContext ctx) {
181
            coloring = null;
182
        }
183
184
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
185
            boolean active;
186
            if (mark == null) {
187
                View view = ctx instanceof DrawEngine.DrawInfo ? ((DrawEngine.DrawInfo)ctx).view.getParent() : null;
188
                if (view instanceof DrawEngineLineView) {
189
                    DrawEngineLineView delv = (DrawEngineLineView)view;
190
                    mark = getFoldedMark(delv, getName());
191
                    if (mark == null) {
192
                        view = delv.getView(delv.getViewCount() -1);
193
                        if (view instanceof DrawEngineLineView) {
194
                            delv = (DrawEngineLineView) view;
195
                            mark = getFoldedMark(delv, getName());
196
                        }
197
                    }
198
                }
199
            }
200
            if (mark != null) {
201
                active = (ctx.getEditorUI().getComponent() != null)
202
                    && mark.activateLayer;
203
                if (active) {
204
                    try {
205
                        BaseDocument doc = ctx.getEditorUI().getDocument();
206
                        int nextRowStartPos = Utilities.getRowStart(
207
                                doc, ctx.getFragmentOffset(), 1);
208
                        if (nextRowStartPos < 0) { // end of doc
209
                            nextRowStartPos = Integer.MAX_VALUE;
210
                        }
211
                        setNextActivityChangeOffset(nextRowStartPos);
212
213
                    } catch (BadLocationException e) {
214
                        active = false;
215
                    }
216
                }
217
            } else {
218
                active = false;
219
            }
220
            return active;
221
        }
222
223
        public void updateContext(DrawContext ctx) {
224
            if (coloring == null) {
225
                coloring = getColoring(ctx);
226
            }
227
            if (coloring != null) {
228
                coloring.apply(ctx);
229
            }
230
        }
231
232
        protected abstract Coloring getColoring(DrawContext ctx);
233
        
234
    }
235
236
237
    /** Layer that covers selection services provided by caret.
238
     * This layer assumes that both caretMark and selectionMark in
239
     * BaseCaret are properly served so that their active flags
240
     * are properly set.
241
     * 
242
     * @deprecated Please use Highlighting SPI instead, for details see
243
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
244
     */
245
    public static class CaretLayer extends DrawLayer.AbstractLayer {
246
247
        Coloring coloring;
248
249
        public CaretLayer() {
250
            super(CARET_LAYER_NAME);
251
        }
252
253
        public boolean extendsEmptyLine() {
254
            return true;
255
        }
256
257
        public void init(DrawContext ctx) {
258
            coloring = null;
259
        }
260
261
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
262
            boolean active;
263
            if (mark != null) {
264
                active = mark.activateLayer;
265
            } else {
266
                JTextComponent c = ctx.getEditorUI().getComponent();
267
                active = (c != null) && Utilities.isSelectionShowing(c)
268
                         && ctx.getFragmentOffset() >= c.getSelectionStart()
269
                         && ctx.getFragmentOffset() < c.getSelectionEnd();
270
            }
271
272
            return active;
273
        }
274
275
        public void updateContext(DrawContext ctx) {
276
            if (coloring == null) {
277
                coloring = ctx.getEditorUI().getColoring(FontColorNames.SELECTION_COLORING);
278
            }
279
            if (coloring != null) {
280
                coloring.apply(ctx);
281
            }
282
        }
283
284
    }
285
286
287
    /** Highlight search layer highlights all occurences
288
     * of the searched string in text.
289
     * 
290
     * @deprecated Please use Highlighting SPI instead, for details see
291
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
292
     */
293
    public static class HighlightSearchLayer extends DrawLayer.AbstractLayer {
294
295
        /** Pairs of start and end position of the found string */
296
        int blocks[] = new int[] { -1, -1 };
297
298
        /** Coloring to use for highlighting */
299
        Coloring coloring;
300
301
        /** Current index for painting */
302
        int curInd;
303
304
        /** Enabled flag */
305
        boolean enabled;
306
307
        public HighlightSearchLayer() {
308
            super(HIGHLIGHT_SEARCH_LAYER_NAME);
309
        }
310
311
        public boolean isEnabled() {
312
            return enabled;
313
        }
314
315
        public void setEnabled(boolean enabled) {
316
            this.enabled = enabled;
317
        }
318
319
        public void init(DrawContext ctx) {
320
            if (enabled) {
321
                try {
322
                    BaseDocument doc = ctx.getEditorUI().getDocument();
323
                    blocks = FindSupport.getFindSupport().getBlocks(blocks,
324
                             doc, ctx.getStartOffset(), ctx.getEndOffset());
325
                } catch (BadLocationException e) {
326
                    blocks = new int[] { -1, -1 };
327
                }
328
                coloring = null; // reset so it will be re-read
329
                curInd = 0;
330
            }
331
        }
332
333
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
334
            boolean active;
335
            if (enabled) {
336
                int pos = ctx.getFragmentOffset();
337
                if (pos == blocks[curInd]) {
338
                    active = true;
339
                    setNextActivityChangeOffset(blocks[curInd + 1]);
340
341
                } else if (pos == blocks[curInd + 1]) {
342
                    active = false;
343
                    curInd += 2;
344
                    setNextActivityChangeOffset(blocks[curInd]);
345
                    if (pos == blocks[curInd]) { // just follows
346
                        setNextActivityChangeOffset(blocks[curInd + 1]);
347
                        active = true;
348
                    }
349
350
                } else {
351
                    setNextActivityChangeOffset(blocks[curInd]);
352
                    active = false;
353
                }
354
            } else {
355
                active = false;
356
            }
357
358
            return active;
359
        }
360
361
        public void updateContext(DrawContext ctx) {
362
            int pos = ctx.getFragmentOffset();
363
            if (pos >= blocks[curInd] && pos < blocks[curInd + 1]) {
364
                if (coloring == null) {
365
                    coloring = ctx.getEditorUI().getColoring(FontColorNames.HIGHLIGHT_SEARCH_COLORING);
366
                }
367
                if (coloring != null) {
368
                    coloring.apply(ctx);
369
                }
370
            }
371
        }
372
373
    }
374
375
    /** Layer covering incremental search. There are just two positions
376
     * begining and end of the searched string
377
     * 
378
     * @deprecated Please use Highlighting SPI instead, for details see
379
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
380
     */
381
    public static class IncSearchLayer extends DrawLayer.AbstractLayer {
382
383
        /** Position where the searched string begins */
384
        int pos;
385
386
        /** Length of area to highlight */
387
        int len;
388
389
        /** Whether this layer is enabled */
390
        boolean enabled;
391
        
392
        boolean invert;
393
394
        public IncSearchLayer() {
395
            super(INC_SEARCH_LAYER_NAME);
396
        }
397
398
        public boolean isEnabled() {
399
            return enabled;
400
        }
401
402
        public void setEnabled(boolean enabled) {
403
            this.enabled = enabled;
404
        }
405
406
        void setArea(int pos, int len) {
407
            this.pos = pos;
408
            this.len = len;
409
        }
410
411
        public int getOffset() {
412
            return pos;
413
        }
414
415
        public int getLength() {
416
            return len;
417
        }
418
419
        public void init(DrawContext ctx) {
420
            setNextActivityChangeOffset(enabled ? pos : Integer.MAX_VALUE);
421
        }
422
423
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
424
            boolean active = false;
425
            if (enabled) {
426
                if (ctx.getFragmentOffset() == pos) {
427
                    active = true;
428
                    setNextActivityChangeOffset(pos + len);
429
                }
430
            }
431
432
            return active;
433
        }
434
435
        /** current INC_SEARCH_COLORING is used only in block search.
436
         *  if there is no search, use selection
437
         *  @param invert if true - selection  coloring is used
438
         */
439
        void setInversion(boolean invert){
440
            this.invert = invert;
441
        }
442
        
443
        public void updateContext(DrawContext ctx) {
444
            if (!invert) {
445
                Coloring coloring = ctx.getEditorUI().getColoring(FontColorNames.INC_SEARCH_COLORING);
446
                if (coloring != null) {
447
                    coloring.apply(ctx);
448
                }
449
            } else {
450
                Coloring invertedColoring = ctx.getEditorUI().getColoring(FontColorNames.SELECTION_COLORING);
451
                if (invertedColoring != null) {
452
                    invertedColoring.apply(ctx);
453
                }
454
            }
455
        }
456
    } // End of IncSearchLayer class
457
458
    /**
459
     * @deprecated Please use Highlighting SPI instead, for details see
460
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
461
     */
462
    public static class BlockSearchLayer extends DrawLayer.AbstractLayer {
463
464
        /** Position where the searched string begins */
465
        int pos;
466
467
        /** Length of area to highlight */
468
        int len;
469
470
        /** Whether this layer is enabled */
471
        boolean enabled;
472
473
        public BlockSearchLayer() {
474
            super(BLOCK_SEARCH_LAYER_NAME);
475
        }
476
477
        public boolean extendsEmptyLine(){
478
            return true;
479
        }
480
        
481
        public boolean isEnabled() {
482
            return enabled;
483
        }
484
485
        public void setEnabled(boolean enabled) {
486
            this.enabled = enabled;
487
        }
488
489
        void setArea(int pos, int len) {
490
            this.pos = pos;
491
            this.len = len;
492
        }
493
494
        int getOffset() {
495
            return pos;
496
        }
497
498
        int getLength() {
499
            return len;
500
        }
501
502
        public void init(DrawContext ctx) {
503
            setNextActivityChangeOffset(enabled ? pos : Integer.MAX_VALUE);
504
        }
505
506
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
507
            boolean active = false;
508
            if (enabled) {
509
                int fragOffset = ctx.getFragmentOffset();
510
                if (fragOffset >= pos && fragOffset<(pos+len))  {
511
                    active = true;
512
                    try {
513
                        BaseDocument doc = ctx.getEditorUI().getDocument();
514
                        int nextRowStartPos = Utilities.getRowStart(
515
                                doc, fragOffset, 1);
516
                        if (nextRowStartPos < 0) { // end of doc
517
                            nextRowStartPos = Integer.MAX_VALUE;
518
                        }
519
                        setNextActivityChangeOffset(Math.min(nextRowStartPos,(pos+len)));
520
521
                    } catch (BadLocationException e) {
522
                        active = false;
523
                    }
524
                
525
                }
526
           }
527
528
            return active;
529
        }
530
531
        public void updateContext(DrawContext ctx) {
532
            Coloring coloring = ctx.getEditorUI().getColoring(FontColorNames.BLOCK_SEARCH_COLORING);
533
            if (coloring != null) {
534
                coloring.apply(ctx);
535
            }
536
        }
537
    } // End of BlockSearchLayer class
538
539
//
540
//  XXX: Deprecated and not used anymore. Can be removed.
541
//
542
//    /** Layer for guarded blocks 
543
//     *
544
//     * @deprecated Please use Highlighting SPI instead, for details see
545
//     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
546
//     */
547
//    static class GuardedLayer extends ColorLineLayer {
548
//
549
//        GuardedDocument doc;
550
//
551
//        GuardedLayer() {
552
//            super(GUARDED_LAYER_NAME);
553
//        }
554
//
555
//        public void init(DrawContext ctx) {
556
//            super.init(ctx);
557
//            doc = (GuardedDocument)ctx.getEditorUI().getDocument();
558
//        }
559
//
560
//        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
561
//            boolean active;
562
//            if (mark != null) {
563
//                active = mark.activateLayer;
564
//            } else {
565
//                active = doc.isPosGuarded(ctx.getFragmentOffset());
566
//            }
567
//
568
//            return active;
569
//        }
570
//
571
//        protected Coloring getColoring(DrawContext ctx) {
572
//            return ctx.getEditorUI().getColoring(SettingsNames.GUARDED_COLORING);
573
//        }
574
//
575
//    }
576
577
    
578
    
579
    /** 
580
     * Style layer getting color settings from particular style 
581
     * 
582
     * @deprecated Please use Highlighting SPI instead, for details see
583
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
584
     */
585
    public static class StyleLayer extends DrawLayer.AbstractLayer {
586
587
        protected Style style;
588
589
        protected MarkChain markChain;
590
591
        protected Color backColor;
592
593
        protected Color foreColor;
594
595
        public StyleLayer(String layerName, BaseDocument doc, Style style) {
596
            super(layerName);
597
            this.style = style;
598
            markChain = new MarkChain(doc, layerName);
599
        }
600
601
        public boolean extendsEOL() {
602
            return true;
603
        }
604
605
        public final MarkChain getMarkChain() {
606
            return markChain;
607
        }
608
609
        public void init(DrawContext ctx) {
610
            foreColor = StyleConstants.getForeground(style);
611
            backColor = StyleConstants.getBackground(style);
612
        }
613
614
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
615
            boolean active = false;
616
            if (mark != null) {
617
                active = (ctx.getEditorUI().getComponent() != null)
618
                    && mark.activateLayer;
619
                if (active) {
620
                    try {
621
                        BaseDocument doc = ctx.getEditorUI().getDocument();
622
                        int nextRowStartPos = Utilities.getRowStart(
623
                                doc, ctx.getFragmentOffset(), 1);
624
                        if (nextRowStartPos < 0) { // end of doc
625
                            nextRowStartPos = Integer.MAX_VALUE;
626
                        }
627
628
                        setNextActivityChangeOffset(nextRowStartPos);
629
630
                    } catch (BadLocationException e) {
631
                        active = false;
632
                    }
633
                }
634
635
            }
636
637
            return active;
638
        }
639
640
        public void updateContext(DrawContext ctx) {
641
            if (foreColor != null) {
642
                ctx.setForeColor(foreColor);
643
            }
644
            if (backColor != null) {
645
                ctx.setBackColor(backColor);
646
            }
647
        }
648
649
        public String toString() {
650
            return super.toString() + ((markChain != null) ? (", " + markChain) : ""); // NOI18N
651
        }
652
653
    }
654
655
    /** 
656
     * Test layer for coloring the specific words
657
     * 
658
     * @deprecated Please use Highlighting SPI instead, for details see
659
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
660
     */
661
    public static class WordColoringLayer extends DrawLayer.AbstractLayer {
662
663
        protected StringMap stringMap = new StringMap();
664
665
        public WordColoringLayer(String name) {
666
            super(name);
667
        }
668
669
        public void put(String s, Coloring c) {
670
            stringMap.put(s, c);
671
        }
672
673
        public void put(String[] strings, Coloring c) {
674
            for (int i = 0; i < strings.length; i++) {
675
                put(strings[i], c);
676
            }
677
        }
678
679
        public void put(List stringList, Coloring c) {
680
            String strings[] = new String[stringList.size()];
681
            stringList.toArray(strings);
682
            put(strings, c);
683
        }
684
685
        public void init(DrawContext ctx) {
686
        }
687
688
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
689
            return true;
690
        }
691
692
        public void updateContext(DrawContext ctx) {
693
            Coloring c = (Coloring)stringMap.get(ctx.getBuffer(),
694
                                 ctx.getTokenOffset(), ctx.getTokenLength());
695
            if (c != null) {
696
                c.apply(ctx);
697
            }
698
        }
699
700
    }
701
702
    /** 
703
     * Annotation layer for drawing of annotations. Each mark which is stored in markChain has
704
     * corresponding Annotation. More than one Annotation can share one mark. In this case
705
     * the only one annotation is active and this must be drawn. 
706
     * 
707
     * @deprecated Please use Highlighting SPI instead, for details see
708
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
709
     */
710
    public static class AnnotationLayer extends DrawLayer.AbstractLayer {
711
712
        /** Current coloring */
713
        private Coloring coloring;
714
        
715
        /** Chain of marks attached to this layer */
716
        private MarkChain markChain;
717
                
718
        public AnnotationLayer(BaseDocument doc) {
719
            super(ANNOTATION_LAYER_NAME);
720
            coloring = null;
721
            markChain = new MarkChain(doc, ANNOTATION_LAYER_NAME);
722
        }
723
724
        /** Get chain of marks attached to this draw layer
725
         * @return mark chain */        
726
        public final MarkChain getMarkChain() {
727
            return markChain;
728
        }
729
        
730
        public boolean extendsEOL() {
731
            return true;
732
        }
733
734
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
735
            int nextActivityOffset;
736
            coloring = null;
737
//            LOG.setLevel(Level.FINE);
738
//            if (LOG.isLoggable(Level.FINE)) {
739
//                LOG.fine("  ctx-offset=" + ctx.getFragmentOffset() + ", mark=" + mark + '\n');
740
//            }
741
742
            if (mark == null) {
743
                View view = ctx instanceof DrawEngine.DrawInfo ? ((DrawEngine.DrawInfo)ctx).view : null;
744
                if (view instanceof DrawEngineLineView) {
745
                    mark = getFoldedMark((DrawEngineLineView)view, getName());
746
                }
747
            }
748
            
749
            if (mark == null) {
750
                return false;
751
            }
752
753
            if (ctx.getEditorUI().getComponent() == null || !mark.activateLayer) {
754
                return false;
755
            }
756
            
757
            BaseDocument doc = ctx.getEditorUI().getDocument();
758
            
759
            // Gets the active annotation attached to this mark. It is possible that
760
            // no active annotation might exist for the mark, e.g. there can be
761
            // mark at the beginning of the line for a whole line annotation
762
            // and there can be mark in the middle of the line for a line-part annotation
763
            AnnotationDesc anno = doc.getAnnotations().getActiveAnnotation(mark);
764
            if (anno == null) {
765
                // if no active annotation was found for the given mark, check
766
                // whether we are not already drawing some other annotation. If that's
767
                // true we have to continue drawing it (means return true here)
768
                AnnotationDesc activeAnno = doc.getAnnotations().getLineActiveAnnotation(mark);
769
                if (activeAnno == null) {
770
                    return false;
771
                }
772
                if (ctx.getFragmentOffset() >= activeAnno.getOffset()) {
773
                    if (ctx.getFragmentOffset() < activeAnno.getOffset() + activeAnno.getLength() || activeAnno.isWholeLine()) {
774
                        coloring = activeAnno.getColoring();
775
                        return true;
776
                    }
777
                }
778
                return false;
779
            }
780
781
//            if (LOG.isLoggable(Level.FINE)) {
782
//                LOG.log(Level.FINE, "anno: o=" + anno.getOffset() + ", l=" + anno.getLength() + ", wl=" + anno.isWholeLine()
783
//                    + ", m=" + mark + ", ctx-offset=" + ctx.getFragmentOffset() + '\n');
784
//            }
785
            if (anno.isWholeLine()) {
786
                try {
787
                    nextActivityOffset = Utilities.getRowEnd(doc, ctx.getFragmentOffset());
788
                } catch (BadLocationException ble) {
789
                    LOG.log(Level.FINE, null, ble);
790
                    return false;
791
                }
792
            } else {
793
                if (ctx.getFragmentOffset() < anno.getOffset()) { // Queried below annotation start
794
                    setNextActivityChangeOffset(anno.getOffset());
795
                    return false;
796
                }
797
                nextActivityOffset = anno.getOffset() + anno.getLength();
798
                if (ctx.getFragmentOffset() >= nextActivityOffset) { // Queried above annotation end
799
                    try {
800
                        setNextActivityChangeOffset(Utilities.getRowEnd(doc, ctx.getFragmentOffset()));
801
                    } catch (BadLocationException ble) {
802
                        LOG.log(Level.FINE, null, ble);
803
                        return false;
804
                    }
805
                    return false;
806
                }
807
            }
808
            
809
            setNextActivityChangeOffset(nextActivityOffset);
810
            coloring = anno.getColoring();
811
            
812
//      The following code ensures that if active annotation does not 
813
//      have highlight the color of next one will be used.
814
//      It was decided that it will not be used
815
//            
816
//            if (coloring.getBackColor() == null) {
817
//                AnnotationDesc[] annos = doc.getAnnotations().getPasiveAnnotations(anno.getLine());
818
//                if (annos != null) {
819
//                    for (int i=0; i<annos.length; i++) {
820
//                        if (annos[i].getColoring().getBackColor() != null) {
821
//                            coloring = annos[i].getColoring();
822
//                            break;
823
//                        }
824
//                    }
825
//                }
826
//            }
827
            
828
            return true;
829
        }
830
831
        public void updateContext(DrawContext ctx) {
832
            if (coloring != null) {
833
                coloring.apply(ctx);
834
            }
835
        }
836
837
    }
838
839
    private static MarkFactory.DrawMark getFoldedMark(DrawEngineLineView view, String layerName) {
840
        BaseDocument doc = (BaseDocument)view.getDocument();
841
        int startPos = view.getStartOffset();
842
        int endPos = view.getEndOffset() - 1;
843
        MarkVector docMarksStorage = doc.marksStorage;
844
        synchronized (docMarksStorage) {
845
            int low = 0;
846
            int high = docMarksStorage.getMarkCount() - 1;
847
848
            while (low < high) { // Unlike regular binary search only iterate (low < high) - code below handles that correctly
849
                int mid = (low + high) >> 1;
850
                int cmp = docMarksStorage.getMarkOffsetInternal(mid) - endPos;
851
                if (cmp < 0)
852
                    low = mid + 1;
853
                else if (cmp > 0)
854
                    high = mid - 1;
855
                else { // found
856
                    while (++mid <= high && docMarksStorage.getMarkOffsetInternal(mid) == endPos) { }
857
                    low = high = mid - 1;
858
                }
859
            }
860
861
            while (low >= 0 && low < docMarksStorage.getMarkCount()) {
862
                MultiMark mm = (MultiMark)docMarksStorage.getMark(low--);
863
                if (mm.isValid() && mm.getOffset() <= endPos) {
864
                    if (mm.getOffset() < startPos) {
865
                        break;
866
                    }
867
                    Mark mrk = doc.marks.get(mm);
868
                    if (mrk instanceof MarkFactory.DrawMark && layerName.equals(((MarkFactory.DrawMark)mrk).layerName)) {
869
                        return (MarkFactory.DrawMark)mrk;
870
                    }
871
                }
872
            }
873
        }
874
875
        return null;
876
    }
877
}
(-)a/editor.lib/src/org/netbeans/editor/EditorUI.java (-58 / +105 lines)
 Lines 90-95    Link Here 
90
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
90
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
91
import org.netbeans.modules.editor.lib.KitsTracker;
91
import org.netbeans.modules.editor.lib.KitsTracker;
92
import org.netbeans.modules.editor.lib.SettingsConversions;
92
import org.netbeans.modules.editor.lib.SettingsConversions;
93
import org.netbeans.modules.editor.lib.drawing.EditorUiAccessor;
94
import org.netbeans.modules.editor.lib.drawing.HighlightingDrawLayer;
93
import org.openide.util.WeakListeners;
95
import org.openide.util.WeakListeners;
94
96
95
/**
97
/**
 Lines 156-164    Link Here 
156
    /** Document for the case ext ui is constructed without the component */
158
    /** Document for the case ext ui is constructed without the component */
157
    private BaseDocument printDoc;
159
    private BaseDocument printDoc;
158
160
159
    /** Draw layer chain */
160
    private DrawLayerList drawLayerList = new DrawLayerList();
161
162
    /** Map holding the [name, coloring] pairs */
161
    /** Map holding the [name, coloring] pairs */
163
    private ColoringMap coloringMap;
162
    private ColoringMap coloringMap;
164
163
 Lines 289-295    Link Here 
289
                     }
288
                     }
290
                 };
289
                 };
291
290
292
        HighlightingDrawLayer.hookUp(this);
293
        getToolTipSupport();
291
        getToolTipSupport();
294
    }
292
    }
295
293
 Lines 316-324    Link Here 
316
        setLineNumberEnabled(lineNumberEnabled);
314
        setLineNumberEnabled(lineNumberEnabled);
317
315
318
        updateLineNumberWidth(0);
316
        updateLineNumberWidth(0);
319
320
        drawLayerList.add(printDoc.getDrawLayerList());
321
        HighlightingDrawLayer.hookUp(this);
322
    }
317
    }
323
    
318
    
324
    /**
319
    /**
 Lines 366-372    Link Here 
366
        // initialize rendering hints
361
        // initialize rendering hints
367
        FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
362
        FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
368
        renderingHints = (Map<?, ?>) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints);
363
        renderingHints = (Map<?, ?>) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints);
369
        
364
365
        // Initialize draw layers
366
        HighlightingDrawLayer.hookUp(c);
367
370
        synchronized (getComponentLock()) {
368
        synchronized (getComponentLock()) {
371
            this.component = c;
369
            this.component = c;
372
            
370
            
 Lines 562-578    Link Here 
562
    }
560
    }
563
561
564
    protected void modelChanged(BaseDocument oldDoc, BaseDocument newDoc) {
562
    protected void modelChanged(BaseDocument oldDoc, BaseDocument newDoc) {
565
        if (oldDoc != null) {
566
            // remove all document layers
567
            drawLayerList.remove(oldDoc.getDrawLayerList());
568
        }
569
570
        if (newDoc != null) {
563
        if (newDoc != null) {
571
            coloringMap = ColoringMap.get(Utilities.getMimeType(newDoc));
564
            coloringMap = ColoringMap.get(Utilities.getMimeType(newDoc));
572
            listener.preferenceChange(null);
565
            listener.preferenceChange(null);
573
566
574
            // add all document layers
575
            drawLayerList.add(newDoc.getDrawLayerList());
576
            checkUndoManager(newDoc);
567
            checkUndoManager(newDoc);
577
        }
568
        }
578
    }
569
    }
 Lines 963-1011    Link Here 
963
        return statusBar;
954
        return statusBar;
964
    }
955
    }
965
    
956
    
966
967
    final DrawLayerList getDrawLayerList() {
968
        return drawLayerList;
969
    }
970
971
    /** 
972
     * Find the layer with some layer name in the layer hierarchy.
973
     * 
974
     * <p>Using of <code>DrawLayer</code>s has been deprecated.
975
     * 
976
     * @deprecated Please use Highlighting SPI instead, for details see
977
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
978
     */
979
    public DrawLayer findLayer(String layerName) {
980
        return drawLayerList.findLayer(layerName);
981
    }
982
983
    /** 
984
     * Add new layer and use its priority to position it in the chain.
985
     * If there's the layer with same visibility then the inserted layer
986
     * will be placed after it.
987
     *
988
     * <p>Using of <code>DrawLayer</code>s has been deprecated.
989
     * 
990
     * @param layer layer to insert into the chain
991
     * 
992
     * @deprecated Please use Highlighting SPI instead, for details see
993
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
994
     */
995
    public boolean addLayer(DrawLayer layer, int visibility) {
996
        return drawLayerList.add(layer, visibility);
997
    }
998
999
    /**
1000
     * Using of <code>DrawLayer</code>s has been deprecated.
1001
     * 
1002
     * @deprecated Please use Highlighting SPI instead, for details see
1003
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
1004
     */
1005
    public DrawLayer removeLayer(String layerName) {
1006
        return drawLayerList.remove(layerName);
1007
    }
1008
1009
    public void repaint(int startY) {
957
    public void repaint(int startY) {
1010
        repaint(startY, component.getHeight());
958
        repaint(startY, component.getHeight());
1011
    }
959
    }
 Lines 1767-1770    Link Here 
1767
    public void setPopupMenu(JPopupMenu popupMenu) {
1715
    public void setPopupMenu(JPopupMenu popupMenu) {
1768
        this.popupMenu = popupMenu;
1716
        this.popupMenu = popupMenu;
1769
    }
1717
    }
1718
1719
    static {
1720
        EditorUiAccessor.register(new Accessor());
1721
    }
1722
1723
    private static final class Accessor extends EditorUiAccessor {
1724
1725
        @Override
1726
        public boolean isLineNumberVisible(EditorUI eui) {
1727
            return eui.lineNumberVisible;
1728
        }
1729
1730
        @Override
1731
        public Coloring getColoring(EditorUI eui, String coloringName) {
1732
            return eui.getColoring(coloringName);
1733
        }
1734
1735
        @Override
1736
        public int getLineNumberMaxDigitCount(EditorUI eui) {
1737
            return eui.lineNumberMaxDigitCount;
1738
        }
1739
1740
        @Override
1741
        public int getLineNumberWidth(EditorUI eui) {
1742
            return eui.lineNumberWidth;
1743
        }
1744
1745
        @Override
1746
        public int getLineNumberDigitWidth(EditorUI eui) {
1747
            return eui.lineNumberDigitWidth;
1748
        }
1749
1750
        @Override
1751
        public Insets getLineNumberMargin(EditorUI eui) {
1752
            return eui.getLineNumberMargin();
1753
        }
1754
1755
        @Override
1756
        public int getLineHeight(EditorUI eui) {
1757
            return eui.getLineHeight();
1758
        }
1759
1760
        @Override
1761
        public Coloring getDefaultColoring(EditorUI eui) {
1762
            return eui.getDefaultColoring();
1763
        }
1764
1765
        @Override
1766
        public int getDefaultSpaceWidth(EditorUI eui) {
1767
            return eui.defaultSpaceWidth;
1768
        }
1769
1770
        @Override
1771
        public Map<?, ?> getRenderingHints(EditorUI eui) {
1772
            return eui.renderingHints;
1773
        }
1774
1775
        @Override
1776
        public Rectangle getExtentBounds(EditorUI eui) {
1777
            return eui.getExtentBounds();
1778
        }
1779
1780
        @Override
1781
        public Insets getTextMargin(EditorUI eui) {
1782
            return eui.getTextMargin();
1783
        }
1784
1785
        @Override
1786
        public int getTextLeftMarginWidth(EditorUI eui) {
1787
            return eui.textLeftMarginWidth;
1788
        }
1789
1790
        @Override
1791
        public boolean getTextLimitLineVisible(EditorUI eui) {
1792
            return eui.textLimitLineVisible;
1793
        }
1794
1795
        @Override
1796
        public Color getTextLimitLineColor(EditorUI eui) {
1797
            return eui.getTextLimitLineColor();
1798
        }
1799
1800
        @Override
1801
        public int getTextLimitWidth(EditorUI eui) {
1802
            return eui.textLimitWidth;
1803
        }
1804
1805
        @Override
1806
        public int getLineAscent(EditorUI eui) {
1807
            return eui.getLineAscent();
1808
        }
1809
1810
        @Override
1811
        public void paint(EditorUI eui, Graphics g) {
1812
            eui.paint(g);
1813
        }
1814
1815
    } // End of Accessor class
1816
    
1770
}
1817
}
(-)a/editor.lib/src/org/netbeans/editor/GuardedDocument.java (-107 / +26 lines)
 Lines 42-48    Link Here 
42
package org.netbeans.editor;
42
package org.netbeans.editor;
43
43
44
import java.text.MessageFormat;
44
import java.text.MessageFormat;
45
import java.util.Hashtable;
46
import java.util.Enumeration;
45
import java.util.Enumeration;
47
import java.awt.Color;
46
import java.awt.Color;
48
import java.awt.Font;
47
import java.awt.Font;
 Lines 105-113    Link Here 
105
    /** Style context to hold the styles */
104
    /** Style context to hold the styles */
106
    protected StyleContext styles;
105
    protected StyleContext styles;
107
106
108
    /** Style to layer name mapping */
109
    protected Hashtable stylesToLayers;
110
111
    /** Name of the normal style. The normal style is used to reset the effect
107
    /** Name of the normal style. The normal style is used to reset the effect
112
    * of all styles applied to the line.
108
    * of all styles applied to the line.
113
    */
109
    */
 Lines 169-175    Link Here 
169
    
165
    
170
    private void init(StyleContext styles) {
166
    private void init(StyleContext styles) {
171
        this.styles = styles;
167
        this.styles = styles;
172
        stylesToLayers = new Hashtable(5);
173
        guardedBlockChain = new MarkBlockChain(this) {
168
        guardedBlockChain = new MarkBlockChain(this) {
174
            protected @Override Mark createBlockStartMark() {
169
            protected @Override Mark createBlockStartMark() {
175
                MarkFactory.ContextMark startMark = new MarkFactory.ContextMark(Position.Bias.Forward, false);
170
                MarkFactory.ContextMark startMark = new MarkFactory.ContextMark(Position.Bias.Forward, false);
 Lines 300-316    Link Here 
300
        }
295
        }
301
    }
296
    }
302
297
303
    public void setCharacterAttributes(int offset, int length, AttributeSet attribs, boolean replace) {
304
        if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == true) {
305
            guardedBlockChain.addBlock(offset, offset + length, false); // no concat
306
            fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
307
        }
308
        if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == false) {
309
            guardedBlockChain.removeBlock(offset, offset + length);
310
            fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
311
        }
312
    }
313
314
    public @Override void runAtomic(Runnable r) {
298
    public @Override void runAtomic(Runnable r) {
315
        if (debugAtomic) {
299
        if (debugAtomic) {
316
            System.out.println("GuardedDocument.runAtomic() called"); // NOI18N
300
            System.out.println("GuardedDocument.runAtomic() called"); // NOI18N
 Lines 376-405    Link Here 
376
        return new GuardedDocumentEvent(this, offset, length, type);
360
        return new GuardedDocumentEvent(this, offset, length, type);
377
    }
361
    }
378
362
363
    /** Set the name for normal style. Normal style is used to reset the effect
364
    * of all aplied styles.
365
    */
366
    public void setNormalStyleName(String normalStyleName) {
367
        this.normalStyleName = normalStyleName;
368
    }
369
370
    /** Fetches the list of style names */
371
    public Enumeration getStyleNames() {
372
        return styles.getStyleNames();
373
    }
374
375
    // ------------------------------------------------------------------------
376
    // StyleDocument implementation
377
    // ------------------------------------------------------------------------
378
379
    /** Adds style to the document */
379
    /** Adds style to the document */
380
    public Style addStyle(String styleName, Style parent) {
380
    public Style addStyle(String styleName, Style parent) {
381
        String layerName = (String)stylesToLayers.get(styleName);
382
        if (layerName == null) {
383
            layerName = styleName; // same layer name as style name
384
            addStyleToLayerMapping(styleName, layerName);
385
        }
386
387
        Style style =  styles.addStyle(styleName, parent);
381
        Style style =  styles.addStyle(styleName, parent);
388
        if (findLayer(layerName) == null) { // not created by default
389
            readLock();
390
            try {
391
                addStyledLayer(layerName, style);
392
            } finally {
393
                readUnlock();
394
            }
395
        }
396
        return style;
382
        return style;
397
    }
383
    }
398
384
399
    public void addStyleToLayerMapping(String styleName, String layerName) {
400
        stylesToLayers.put(styleName, layerName);
401
    }
402
403
    /** Removes style from document */
385
    /** Removes style from document */
404
    public void removeStyle(String styleName) {
386
    public void removeStyle(String styleName) {
405
        styles.removeStyle(styleName);
387
        styles.removeStyle(styleName);
 Lines 410-425    Link Here 
410
        return styles.getStyle(styleName);
392
        return styles.getStyle(styleName);
411
    }
393
    }
412
394
413
    /** Set the name for normal style. Normal style is used to reset the effect
395
    public void setCharacterAttributes(int offset, int length, AttributeSet attribs, boolean replace) {
414
    * of all aplied styles.
396
        if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == true) {
415
    */
397
            guardedBlockChain.addBlock(offset, offset + length, false); // no concat
416
    public void setNormalStyleName(String normalStyleName) {
398
            fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
417
        this.normalStyleName = normalStyleName;
399
        }
418
    }
400
        if (((Boolean)attribs.getAttribute(GUARDED_ATTRIBUTE)).booleanValue() == false) {
419
401
            guardedBlockChain.removeBlock(offset, offset + length);
420
    /** Fetches the list of style names */
402
            fireChangedUpdate(getDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE, attribs));
421
    public Enumeration getStyleNames() {
403
        }
422
        return styles.getStyleNames();
423
    }
404
    }
424
405
425
    /** Change attributes for part of the text.  */
406
    /** Change attributes for part of the text.  */
 Lines 440-488    Link Here 
440
     * @param s the style to set
421
     * @param s the style to set
441
     */
422
     */
442
    public void setLogicalStyle(int pos, Style s) {
423
    public void setLogicalStyle(int pos, Style s) {
443
        readLock();
444
        try {
445
            pos = Utilities.getRowStart(this, pos);
446
            String layerName = (String)stylesToLayers.get(s.getName());
447
            // remove all applied styles
448
            DrawLayer[] layerArray = getDrawLayerList().currentLayers();
449
            for (int i = 0; i < layerArray.length; i++) {
450
                if (layerArray[i] instanceof DrawLayerFactory.StyleLayer) {
451
                    ((DrawLayerFactory.StyleLayer)layerArray[i]).markChain.removeMark(pos);
452
                }
453
            }
454
            // now set the requested style
455
            DrawLayerFactory.StyleLayer styleLayer
456
            = (DrawLayerFactory.StyleLayer)findLayer(layerName);
457
            if (styleLayer != null) {
458
                styleLayer.markChain.addMark(pos);
459
            }
460
            fireChangedUpdate(getDocumentEvent(
461
                pos, 0, DocumentEvent.EventType.CHANGE, null)); // enough to say length 0
462
        } catch (BadLocationException e) {
463
            // do nothing for invalid positions
464
        } finally {
465
            readUnlock();
466
        }
467
    }
424
    }
468
425
469
    /** Get logical style for position in paragraph */
426
    /** Get logical style for position in paragraph */
470
    public Style getLogicalStyle(int pos) {
427
    public Style getLogicalStyle(int pos) {
471
        try {
428
        return null;
472
            pos = Utilities.getRowStart(this, pos);
473
            DrawLayer[] layerArray = getDrawLayerList().currentLayers();
474
            for (int i = 0; i < layerArray.length; i++) {
475
                DrawLayer layer = layerArray[i];
476
                if (layer instanceof DrawLayerFactory.StyleLayer) {
477
                    if (((DrawLayerFactory.StyleLayer)layer).markChain.isMark(pos)) {
478
                        return ((DrawLayerFactory.StyleLayer)layer).style;
479
                    }
480
                }
481
            }
482
            return getStyle(normalStyleName); // no style found
483
        } catch (BadLocationException e) {
484
            return null;
485
        }
486
    }
429
    }
487
430
488
    /**
431
    /**
 Lines 534-565    Link Here 
534
        return new Font("Default",Font.BOLD,12); // NOI18N
477
        return new Font("Default",Font.BOLD,12); // NOI18N
535
    }
478
    }
536
479
537
    /**
538
     * Using of <code>DrawLayer</code>s has been deprecated.
539
     * 
540
     * @deprecated Please use Highlighting SPI instead, for details see
541
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
542
     */
543
    protected DrawLayer addStyledLayer(String layerName, Style style) {
544
        if (layerName != null) {
545
            try {
546
                int indColon = layerName.indexOf(':'); //NOI18N
547
                int layerVisibility = Integer.parseInt(layerName.substring(indColon + 1));
548
                DrawLayer layer = new DrawLayerFactory.StyleLayer(layerName, this, style);
549
550
                addLayer(layer, layerVisibility);
551
                return layer;
552
553
            } catch (NumberFormatException e) {
554
                // wrong name, let it pass
555
            }
556
        }
557
        return null;
558
    }
559
560
    public @Override String toStringDetail() {
480
    public @Override String toStringDetail() {
561
        return super.toStringDetail()
481
        return super.toStringDetail()
562
               + getDrawLayerList()
563
               + ",\nGUARDED blocks:\n" + guardedBlockChain; // NOI18N
482
               + ",\nGUARDED blocks:\n" + guardedBlockChain; // NOI18N
564
    }
483
    }
565
484
(-)a/editor.lib/src/org/netbeans/editor/LeafView.java (-13 / +17 lines)
 Lines 51-56    Link Here 
51
import javax.swing.text.BadLocationException;
51
import javax.swing.text.BadLocationException;
52
import javax.swing.text.Document;
52
import javax.swing.text.Document;
53
import javax.swing.event.DocumentEvent;
53
import javax.swing.event.DocumentEvent;
54
import org.netbeans.modules.editor.lib.drawing.DrawContext;
55
import org.netbeans.modules.editor.lib.drawing.DrawEngine;
56
import org.netbeans.modules.editor.lib.drawing.DrawGraphics;
54
57
55
/**
58
/**
56
* Leaf view implementation. This corresponds and requires leaf element
59
* Leaf view implementation. This corresponds and requires leaf element
 Lines 103-119    Link Here 
103
    protected int mainHeight;
106
    protected int mainHeight;
104
107
105
    /** Draw graphics for converting position to coords */
108
    /** Draw graphics for converting position to coords */
106
    ModelToViewDG modelToViewDG = new ModelToViewDG();
109
    final ModelToViewDG modelToViewDG = new ModelToViewDG();
107
110
108
    /** Draw graphics for converting coords to position */
111
    /** Draw graphics for converting coords to position */
109
    ViewToModelDG viewToModelDG = new ViewToModelDG();
112
    final ViewToModelDG viewToModelDG = new ViewToModelDG();
110
113
111
    /** Construct new base view */
114
    /** Construct new base view */
112
    public LeafView(Element elem) {
115
    public LeafView(Element elem) {
113
        super(elem);
116
        super(elem);
114
    }
117
    }
115
118
116
    public void setParent(View parent) {
119
    public @Override void setParent(View parent) {
117
        super.setParent(parent);
120
        super.setParent(parent);
118
        
121
        
119
        if (getParent() != null) {
122
        if (getParent() != null) {
 Lines 173-179    Link Here 
173
                    int pos = getPosFromY(clipY + clipHeight - 1);
176
                    int pos = getPosFromY(clipY + clipHeight - 1);
174
                    int endPos = Utilities.getRowEnd(doc, pos);
177
                    int endPos = Utilities.getRowEnd(doc, pos);
175
                    int baseY = getYFromPos(startPos);
178
                    int baseY = getYFromPos(startPos);
176
                    DrawEngine.getDrawEngine().draw(new DrawGraphics.GraphicsDG(g),
179
                    DrawEngine.getDrawEngine().draw(
180
                        new DrawGraphics.GraphicsDG(g),
177
                        editorUI, startPos, endPos,
181
                        editorUI, startPos, endPos,
178
                        getBaseX(baseY), baseY, Integer.MAX_VALUE
182
                        getBaseX(baseY), baseY, Integer.MAX_VALUE
179
                    );
183
                    );
 Lines 249-265    Link Here 
249
    }
253
    }
250
254
251
    /** Returns the number of child views in this view. */
255
    /** Returns the number of child views in this view. */
252
    public final int getViewCount() {
256
    public @Override final int getViewCount() {
253
        return 0;
257
        return 0;
254
    }
258
    }
255
259
256
    /** Gets the n-th child view.  */
260
    /** Gets the n-th child view.  */
257
    public final View getView(int n) {
261
    public @Override final View getView(int n) {
258
        return null;
262
        return null;
259
    }
263
    }
260
264
261
    /** !!! osetrit konec view -> jump na dalsi v branchview */
265
    /** !!! osetrit konec view -> jump na dalsi v branchview */
262
    public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
266
    public @Override int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
263
                                         int direction, Position.Bias[] biasRet)
267
                                         int direction, Position.Bias[] biasRet)
264
    throws BadLocationException {
268
    throws BadLocationException {
265
        if (biasRet != null) {
269
        if (biasRet != null) {
 Lines 342-348    Link Here 
342
        return ret;
346
        return ret;
343
    }
347
    }
344
348
345
    public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1,
349
    public @Override Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1,
346
                             Shape a) throws BadLocationException {
350
                             Shape a) throws BadLocationException {
347
        Rectangle r0 = (Rectangle)modelToView(p0, a, b0);
351
        Rectangle r0 = (Rectangle)modelToView(p0, a, b0);
348
        Rectangle r1 = (Rectangle)modelToView(p1, a, b1);
352
        Rectangle r1 = (Rectangle)modelToView(p1, a, b1);
 Lines 413-419    Link Here 
413
    * @param a the current allocation of the view
417
    * @param a the current allocation of the view
414
    * @param f the factory to use to rebuild if the view has children
418
    * @param f the factory to use to rebuild if the view has children
415
    */
419
    */
416
    public void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
420
    public @Override void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
417
        try {
421
        try {
418
            BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
422
            BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
419
            EditorUI editorUI = getEditorUI();
423
            EditorUI editorUI = getEditorUI();
 Lines 449-455    Link Here 
449
    * @param a the current allocation of the view
453
    * @param a the current allocation of the view
450
    * @param f the factory to use to rebuild if the view has children
454
    * @param f the factory to use to rebuild if the view has children
451
    */
455
    */
452
    public void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
456
    public @Override void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
453
        try {
457
        try {
454
            BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
458
            BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
455
            EditorUI editorUI = getEditorUI();
459
            EditorUI editorUI = getEditorUI();
 Lines 482-488    Link Here 
482
    * @param a the current allocation of the view
486
    * @param a the current allocation of the view
483
    * @param f the factory to use to rebuild if the view has children
487
    * @param f the factory to use to rebuild if the view has children
484
    */
488
    */
485
    public void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
489
    public @Override void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
486
        try {
490
        try {
487
            if (getComponent().isShowing()) {
491
            if (getComponent().isShowing()) {
488
                getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
492
                getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
 Lines 501-507    Link Here 
501
505
502
        Rectangle r;
506
        Rectangle r;
503
507
504
        public boolean targetOffsetReached(int pos, char ch, int x,
508
        public @Override boolean targetOffsetReached(int pos, char ch, int x,
505
                                           int charWidth, DrawContext ctx) {
509
                                           int charWidth, DrawContext ctx) {
506
            r.x = x;
510
            r.x = x;
507
            r.y = getY();
511
            r.y = getY();
 Lines 533-539    Link Here 
533
            return offset;
537
            return offset;
534
        }
538
        }
535
539
536
        public boolean targetOffsetReached(int offset, char ch, int x,
540
        public @Override boolean targetOffsetReached(int offset, char ch, int x,
537
        int charWidth, DrawContext ctx) {
541
        int charWidth, DrawContext ctx) {
538
            if (offset <= eolOffset) {
542
            if (offset <= eolOffset) {
539
                if (x + charWidth < targetX) {
543
                if (x + charWidth < targetX) {
(-)a/editor.lib/src/org/netbeans/editor/Mark.java (+1 lines)
 Lines 48-53    Link Here 
48
import javax.swing.text.Element;
48
import javax.swing.text.Element;
49
import javax.swing.text.Position;
49
import javax.swing.text.Position;
50
import javax.swing.text.Position.Bias;
50
import javax.swing.text.Position.Bias;
51
import org.netbeans.modules.editor.lib.impl.MultiMark;
51
52
52
/**
53
/**
53
* Marks hold the relative position in the document.
54
* Marks hold the relative position in the document.
(-)a/editor.lib/src/org/netbeans/editor/MarkBlockChain.java (-28 / +1 lines)
 Lines 44-50    Link Here 
44
import java.beans.PropertyChangeListener;
44
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeSupport;
45
import java.beans.PropertyChangeSupport;
46
import javax.swing.text.BadLocationException;
46
import javax.swing.text.BadLocationException;
47
import javax.swing.text.Position;
48
47
49
/**
48
/**
50
* Support class for chain of MarkBlocks
49
* Support class for chain of MarkBlocks
 Lines 354-386    Link Here 
354
        return pos;
353
        return pos;
355
    }
354
    }
356
355
357
    public static class LayerChain extends MarkBlockChain {
356
    public @Override String toString() {
358
359
        private String layerName;
360
361
        public LayerChain(BaseDocument doc, String layerName) {
362
            super(doc);
363
            this.layerName = layerName;
364
        }
365
366
        public final String getLayerName() {
367
            return layerName;
368
        }
369
370
        protected Mark createBlockStartMark() {
371
            MarkFactory.DrawMark startMark = new MarkFactory.DrawMark(layerName, null);
372
            startMark.activateLayer = true;
373
            return startMark;
374
        }
375
376
        protected Mark createBlockEndMark() {
377
            MarkFactory.DrawMark endMark = new MarkFactory.DrawMark(layerName, null, Position.Bias.Backward);
378
            return endMark;
379
        }
380
381
    }
382
383
    public String toString() {
384
        return "MarkBlockChain: currentBlock=" + currentBlock + "\nblock chain: " // NOI18N
357
        return "MarkBlockChain: currentBlock=" + currentBlock + "\nblock chain: " // NOI18N
385
               + (chain != null ? ("\n" + chain.toStringChain()) : " Empty"); // NOI18N
358
               + (chain != null ? ("\n" + chain.toStringChain()) : " Empty"); // NOI18N
386
    }
359
    }
(-)a/editor.lib/src/org/netbeans/editor/MarkFactory.java (-174 / +1 lines)
 Lines 41-47    Link Here 
41
41
42
package org.netbeans.editor;
42
package org.netbeans.editor;
43
43
44
import java.lang.ref.WeakReference;
45
import javax.swing.text.Position;
44
import javax.swing.text.Position;
46
45
47
/**
46
/**
 Lines 97-103    Link Here 
97
        }
96
        }
98
97
99
        /** When removal occurs */
98
        /** When removal occurs */
100
        protected void removeUpdateAction(int pos, int len) {
99
        protected @Override void removeUpdateAction(int pos, int len) {
101
            try {
100
            try {
102
                remove();
101
                remove();
103
            } catch (InvalidMarkException e) {
102
            } catch (InvalidMarkException e) {
 Lines 124-299    Link Here 
124
123
125
    }
124
    }
126
125
127
    /** Activation mark for particular layer. When layer is not active
128
    * its updateContext() method is not called.
129
    */
130
    public static class DrawMark extends ContextMark {
131
132
        /** Activation flag means either activate layer or deactivate it */
133
        protected boolean activateLayer;
134
135
        /** Reference to draw layer this mark belogns to */
136
        String layerName;
137
138
        /** Reference to extended UI if this draw mark is info-specific or
139
        * null if it's document-wide.
140
        */
141
        WeakReference editorUIRef;
142
143
        public DrawMark(String layerName, EditorUI editorUI) {
144
            this(layerName, editorUI, Position.Bias.Forward);
145
        }
146
        
147
        public DrawMark(String layerName, EditorUI editorUI, Position.Bias bias) {
148
            super(bias, false);
149
            this.layerName = layerName;
150
            setEditorUI(editorUI);
151
        }
152
153
        public boolean isDocumentMark() {
154
            return (editorUIRef == null);
155
        }
156
157
        public EditorUI getEditorUI() {
158
            if (editorUIRef != null) {
159
                return (EditorUI)editorUIRef.get();
160
            }
161
            return null;
162
        }
163
164
        public void setEditorUI(EditorUI editorUI) {
165
            this.editorUIRef = (editorUI != null) ? new WeakReference(editorUI) : null;
166
        }
167
168
        public boolean isValidUI() {
169
            return !(editorUIRef != null && editorUIRef.get() == null);
170
        }
171
172
        public void setActivateLayer(boolean activateLayer) {
173
            this.activateLayer = activateLayer;
174
        }
175
176
        public boolean getActivateLayer() {
177
            return activateLayer;
178
        }
179
180
        public boolean removeInvalid() {
181
            if (!isValidUI() && isValid()) {
182
                try {
183
                    this.remove();
184
                } catch (InvalidMarkException e) {
185
                    throw new IllegalStateException(e.toString());
186
                }
187
                return true; // invalid and removed
188
            }
189
            return false; // valid
190
        }
191
192
        public String toString() {
193
            try {
194
                return "pos=" + getOffset() + ", line=" + getLine(); // NOI18N
195
            } catch (InvalidMarkException e) {
196
                return "mark not valid"; // NOI18N
197
            }
198
        }
199
200
    }
201
202
    /** Support for draw marks chained in double linked list */
203
    public static class ChainDrawMark extends DrawMark {
204
205
        /** Next mark in chain */
206
        protected ChainDrawMark next;
207
208
        /** Previous mark in chain */
209
        protected ChainDrawMark prev;
210
211
        public ChainDrawMark(String layerName, EditorUI editorUI) {
212
            this(layerName, editorUI, Position.Bias.Forward);
213
        }
214
        
215
        public ChainDrawMark(String layerName, EditorUI editorUI, Position.Bias bias) {
216
            super(layerName, editorUI, bias);
217
        }
218
219
        public final ChainDrawMark getNext() {
220
            return next;
221
        }
222
223
        public final void setNext(ChainDrawMark mark) {
224
            next = mark;
225
        }
226
227
        /** Set next mark in chain */
228
        public void setNextChain(ChainDrawMark mark) {
229
            this.next = mark;
230
            if (mark != null) {
231
                mark.prev = this;
232
            }
233
        }
234
235
        public final ChainDrawMark getPrev() {
236
            return prev;
237
        }
238
239
        public final void setPrev(ChainDrawMark mark) {
240
            prev = mark;
241
        }
242
243
        /** Set previous mark in chain */
244
        public void setPrevChain(ChainDrawMark mark) {
245
            this.prev = mark;
246
            if (mark != null) {
247
                mark.next = this;
248
            }
249
        }
250
251
        /** Insert mark before this one in chain
252
        * @return inserted mark
253
        */
254
        public ChainDrawMark insertChain(ChainDrawMark mark) {
255
            ChainDrawMark thisPrev = this.prev;
256
            mark.prev = thisPrev;
257
            mark.next = this;
258
            if (thisPrev != null) {
259
                thisPrev.next = mark;
260
            }
261
            this.prev = mark;
262
            return mark;
263
        }
264
265
        /** Remove this mark from the chain
266
        * @return next chain member or null for end of chain
267
        */
268
        public ChainDrawMark removeChain() {
269
            ChainDrawMark thisNext = this.next;
270
            ChainDrawMark thisPrev = this.prev;
271
            if (thisPrev != null) { // not the first
272
                thisPrev.next = thisNext;
273
                this.prev = null;
274
            }
275
            if (thisNext != null) { // not the last
276
                thisNext.prev = thisPrev;
277
                this.next = null;
278
            }
279
            try {
280
                this.remove(); // remove the mark from DocMarks
281
            } catch (InvalidMarkException e) {
282
                // already removed
283
            }
284
            return thisNext;
285
        }
286
287
        public String toStringChain() {
288
            return toString() + (next != null ? "\n" + next.toStringChain() : ""); // NOI18N
289
        }
290
291
        public String toString() {
292
            return super.toString() + ", " // NOI18N
293
                   + ((prev != null) ? ((next != null) ? "chain member" // NOI18N
294
                            : "last member") : ((next != null) ? "first member" // NOI18N
295
                                                            : "standalone member")); // NOI18N
296
        }
297
298
    }
299
}
126
}
(-)a/editor.lib/src/org/netbeans/editor/Utilities.java (+1 lines)
 Lines 62-67    Link Here 
62
import org.netbeans.api.editor.EditorRegistry;
62
import org.netbeans.api.editor.EditorRegistry;
63
import org.netbeans.lib.editor.util.CharSequenceUtilities;
63
import org.netbeans.lib.editor.util.CharSequenceUtilities;
64
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
64
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
65
import org.netbeans.modules.editor.lib.drawing.DrawEngineDocView;
65
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
66
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
66
import org.openide.util.NbBundle;
67
import org.openide.util.NbBundle;
67
68
(-)a/editor.lib/src/org/netbeans/editor/ext/ExtCaret.java (-326 lines)
 Lines 52-267    Link Here 
52
52
53
public class ExtCaret extends BaseCaret {
53
public class ExtCaret extends BaseCaret {
54
54
55
    /** 
56
     * Highlight row draw layer name.
57
     * 
58
     * <p>Using <code>DrawLayer</code>s has been deprecated and this constant
59
     * has no longer any meaning.
60
     * 
61
     * @deprecated Please use Highlighting SPI instead, for details see
62
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
63
     */
64
    public static final String HIGHLIGHT_ROW_LAYER_NAME = "highlight-row-layer"; // NOI18N
65
66
    /**
67
     * Highlight row draw layer visibility.
68
     * 
69
     * <p>Using <code>DrawLayer</code>s has been deprecated and this constant
70
     * has no longer any meaning.
71
     * 
72
     * @deprecated Please use Highlighting SPI instead, for details see
73
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
74
     */
75
    public static final int HIGHLIGHT_ROW_LAYER_VISIBILITY = 2050;
76
77
    /** 
78
     * Highlight matching brace draw layer name
79
     * 
80
     * @deprecated Please use Braces Matching SPI instead, for details see
81
     *   <a href="@org-netbeans-modules-editor-bracesmatching@/overview-summary.html">Editor Braces Matching</a>.
82
     */
83
    public static final String HIGHLIGHT_BRACE_LAYER_NAME = "highlight-brace-layer"; // NOI18N
84
85
    /** 
86
     * Highlight matching brace draw layer visibility 
87
     * 
88
     * @deprecated Please use Braces Matching SPI instead, for details see
89
     *   <a href="@org-netbeans-modules-editor-bracesmatching@/overview-summary.html">Editor Braces Matching</a>.
90
     */
91
    public static final int HIGHLIGHT_BRACE_LAYER_VISIBILITY = 11000;
92
93
// XXX: remove
94
//    /** Highlight a brace matching character before the caret */
95
//    public static final int MATCH_BRACE_BEFORE = -1;
96
//    
97
//    /** Highlight a brace matching character after (at) the caret */
98
//    public static final int MATCH_BRACE_AFTER = 0;
99
//    
100
//    /** Highlight a brace matching character either before or after caret;
101
//        the character before takes precedence. */
102
//    public static final int MATCH_BRACE_EITHER = java.lang.Integer.MAX_VALUE;
103
//
104
//    /** Whether to hightlight the matching brace */
105
//    boolean highlightBrace;
106
//
107
//    /** Coloring used for highlighting the matching brace */
108
//    Coloring highlightBraceColoring;
109
//
110
//    /** Mark holding the starting position of the matching brace. */
111
//    MarkFactory.DrawMark highlightBraceStartMark;
112
//
113
//    /** Mark holding the ending position of the matching brace. */
114
//    MarkFactory.DrawMark highlightBraceEndMark;
115
//
116
//    /** Timer that fires when the matching brace should be displayed */
117
//    private Timer braceTimer;
118
//    private ActionListener braceTimerListener; // because of unwanted GC
119
//
120
//    /** Signal that the next matching brace update
121
//    * will be immediate without waiting for the brace
122
//    * timer to fire the action.
123
//    */
124
//    private boolean matchBraceUpdateSync;
125
//
126
//    /** Whether the brace starting and ending marks are currently valid or not.
127
//     * If they are not valid the block they delimit is not highlighted.
128
//     */
129
//    boolean braceMarksValid;
130
//
131
//    boolean simpleMatchBrace;
132
//
133
//    private int matchBraceOffset = MATCH_BRACE_EITHER;
134
    
135
    static final long serialVersionUID =-4292670043122577690L;
55
    static final long serialVersionUID =-4292670043122577690L;
136
56
137
// XXX: remove    
138
//    protected void modelChanged(BaseDocument oldDoc, BaseDocument newDoc) {
139
//        // Fix for #7108
140
//        braceMarksValid = false; // brace marks are out of date - new document
141
//        if (highlightBraceStartMark != null) {
142
//            try {
143
//                highlightBraceStartMark.remove();
144
//            } catch (InvalidMarkException e) {
145
//            }
146
//            highlightBraceStartMark = null;
147
//        }
148
//
149
//        if (highlightBraceEndMark != null) {
150
//            try {
151
//                highlightBraceEndMark.remove();
152
//            } catch (InvalidMarkException e) {
153
//            }
154
//            highlightBraceEndMark = null;
155
//        }
156
//
157
//        super.modelChanged( oldDoc, newDoc );
158
//    }
159
160
// XXX: remove
161
//    /** Called when settings were changed. The method is called
162
//    * also in constructor, so the code must count with the evt being null.
163
//    */
164
//    public void settingsChange(SettingsChangeEvent evt) {
165
//        super.settingsChange(evt);
166
//        JTextComponent c = component;
167
//        if (c != null) {
168
//            Class kitClass = Utilities.getKitClass(c);
169
//// XXX: remove
170
////            EditorUI editorUI = Utilities.getEditorUI(c);
171
////            highlightBraceColoring = editorUI.getColoring(
172
////                                           ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_COLORING);
173
////
174
////            highlightBrace = SettingsUtil.getBoolean(kitClass,
175
////                               ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
176
////                               ExtSettingsDefaults.defaultHighlightMatchBrace);
177
////            int highlightBraceDelay = SettingsUtil.getInteger(kitClass,
178
////                                        ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_DELAY,
179
////                                        ExtSettingsDefaults.defaultHighlightMatchBraceDelay);
180
////
181
////            if (highlightBrace) {
182
////                if (highlightBraceDelay > 0) {
183
////                    // jdk12 compiler doesn't allow inside run()
184
////                    final JTextComponent c2 = component;
185
////
186
////                    braceTimer = new Timer(highlightBraceDelay, null);
187
////                    braceTimerListener = 
188
////                         new ActionListener() {
189
////                             public void actionPerformed(ActionEvent evt2) {
190
////                                 SwingUtilities.invokeLater(
191
////                                     new Runnable() {
192
////                                         public void run() {
193
////                                             if (c2 != null) {
194
////                                                 BaseDocument doc = Utilities.getDocument(c2);
195
////                                                 if( doc != null ) {
196
////                                                     doc.readLock();
197
////                                                     try {
198
////                                                         updateMatchBrace();
199
////                                                     } finally {
200
////                                                         doc.readUnlock();
201
////                                                     }
202
////                                                 }
203
////                                             }
204
////                                         }
205
////                                     }
206
////                                 );
207
////                             }
208
////                         };
209
////                         
210
////                    braceTimer.addActionListener(new WeakTimerListener(braceTimerListener));
211
////                    braceTimer.setRepeats(false);
212
////                } else {
213
////                    braceTimer = null; // signal no delay
214
////                }
215
////                c.repaint();
216
////            }
217
////
218
////            simpleMatchBrace = SettingsUtil.getBoolean(kitClass,
219
////                                    ExtSettingsNames.CARET_SIMPLE_MATCH_BRACE,
220
////                                    ExtSettingsDefaults.defaultCaretSimpleMatchBrace);
221
////            
222
//            popupMenuEnabled = SettingsUtil.getBoolean(kitClass,
223
//                ExtSettingsNames.POPUP_MENU_ENABLED, true);
224
//        }
225
//    }
226
// XXX: remove
227
//    public void install(JTextComponent c) {
228
//        EditorUI editorUI = Utilities.getEditorUI(c);
229
//        editorUI.addLayer(new HighlightBraceLayer(), HIGHLIGHT_BRACE_LAYER_VISIBILITY);
230
//        super.install(c);
231
//    }
232
//
233
//    public void deinstall(JTextComponent c) {
234
//        EditorUI editorUI = Utilities.getEditorUI(c);
235
//        editorUI.removeLayer(HIGHLIGHT_BRACE_LAYER_NAME);
236
//        super.deinstall(c);
237
//    }
238
//    
239
//    /** Set the match brace offset.
240
//     * @param offset One of <code>MATCH_BRACE_BEFORE</code>,
241
//     * <code>MATCH_BRACE_AFTER</code> * or <code>MATCH_BRACE_EITHER</code>.
242
//     */
243
//    public void setMatchBraceOffset(int offset) {
244
//        if(offset != MATCH_BRACE_BEFORE && offset != MATCH_BRACE_AFTER
245
//           && offset != MATCH_BRACE_EITHER) {
246
//            throw new IllegalArgumentException("Offset "+ offset + " not allowed\n");
247
//        }
248
//        matchBraceOffset = offset;
249
//        BaseDocument doc = Utilities.getDocument(component);
250
//        if( doc != null ) {
251
//            doc.readLock();
252
//            try {
253
//                updateMatchBrace();
254
//            } finally {
255
//                doc.readUnlock();
256
//            }
257
//        }
258
//    }
259
//    
260
//    /** Fetch the match brace offset. */
261
//    public int getMatchBraceOffset() {
262
//        return matchBraceOffset;
263
//    }
264
265
    /** 
57
    /** 
266
     * Update the matching brace of the caret. The document is read-locked
58
     * Update the matching brace of the caret. The document is read-locked
267
     * while this method is called.
59
     * while this method is called.
 Lines 270-351    Link Here 
270
     *   <a href="@org-netbeans-modules-editor-bracesmatching@/overview-summary.html">Editor Braces Matching</a>.
62
     *   <a href="@org-netbeans-modules-editor-bracesmatching@/overview-summary.html">Editor Braces Matching</a>.
271
     */
63
     */
272
    protected void updateMatchBrace() {
64
    protected void updateMatchBrace() {
273
// XXX: remove
274
//        JTextComponent c = component;
275
//        if (c != null && highlightBrace) {
276
//            try {
277
//                EditorUI editorUI = Utilities.getEditorUI(c);
278
//                BaseDocument doc = (BaseDocument)c.getDocument();
279
//                int dotPos = getDot();
280
//                ExtSyntaxSupport sup = (ExtSyntaxSupport)doc.getSyntaxSupport();
281
//                boolean madeValid = false; // whether brace marks display were validated
282
//                int[] matchBlk = null;
283
//                if(dotPos > 0 && (matchBraceOffset == MATCH_BRACE_BEFORE
284
//                                  || matchBraceOffset == MATCH_BRACE_EITHER)) {
285
//                    matchBlk = sup.findMatchingBlock(dotPos - 1, simpleMatchBrace);
286
//                }
287
//                if(matchBlk == null && (matchBraceOffset == MATCH_BRACE_AFTER
288
//                                        || matchBraceOffset == MATCH_BRACE_EITHER)) {
289
//                    matchBlk = sup.findMatchingBlock(dotPos, simpleMatchBrace);
290
//                }
291
//                if (matchBlk != null) {
292
//                    if (highlightBraceStartMark != null) {
293
//                        int markStartPos = highlightBraceStartMark.getOffset();
294
//                        int markEndPos = highlightBraceEndMark.getOffset();
295
//                        if (markStartPos != matchBlk[0] || markEndPos != matchBlk[1]) {
296
//                            editorUI.repaintBlock(markStartPos, markEndPos);
297
//                            Utilities.moveMark(doc, highlightBraceStartMark, matchBlk[0]);
298
//                            Utilities.moveMark(doc, highlightBraceEndMark, matchBlk[1]);
299
//                            editorUI.repaintBlock(matchBlk[0], matchBlk[1]);
300
//                        } else { // on the same position
301
//                            if (!braceMarksValid) { // was not valid, must repaint
302
//                                editorUI.repaintBlock(matchBlk[0], matchBlk[1]);
303
//                            }
304
//                        }
305
//                    } else { // highlight mark is null
306
//                        highlightBraceStartMark = new MarkFactory.DrawMark(
307
//                                                    HIGHLIGHT_BRACE_LAYER_NAME, editorUI);
308
//                        highlightBraceEndMark = new MarkFactory.DrawMark(
309
//                                                    HIGHLIGHT_BRACE_LAYER_NAME, editorUI);
310
//                        highlightBraceStartMark.setActivateLayer(true);
311
//                        Utilities.insertMark(doc, highlightBraceStartMark, matchBlk[0]);
312
//                        Utilities.insertMark(doc, highlightBraceEndMark, matchBlk[1]);
313
//                        editorUI.repaintBlock(matchBlk[0], matchBlk[1]);
314
//                    }
315
//                    braceMarksValid = true;
316
//                    madeValid = true;
317
//                }
318
//
319
//                if (!madeValid) {
320
//                    if (braceMarksValid) {
321
//                        braceMarksValid = false;
322
//                        editorUI.repaintBlock(highlightBraceStartMark.getOffset(),
323
//                                highlightBraceEndMark.getOffset());
324
//                    }
325
//                }
326
//            } catch (BadLocationException e) {
327
//                Utilities.annotateLoggable(e);
328
//                highlightBrace = false;
329
//            } catch (InvalidMarkException e) {
330
//                Utilities.annotateLoggable(e);
331
//                highlightBrace = false;
332
//            }
333
//        }
334
    }
65
    }
335
// XXX: remove
336
//    protected void update(boolean scrollViewToCaret) {
337
//        if (highlightBrace) {
338
//            if (matchBraceUpdateSync || braceTimer == null) {
339
//                updateMatchBrace();
340
//                matchBraceUpdateSync = false;
341
//
342
//            } else { // delay the brace update
343
//                braceTimer.restart();
344
//            }
345
//        }
346
//
347
//        super.update(scrollViewToCaret);
348
//    }
349
66
350
    /** 
67
    /** 
351
     * Signal that the next matching brace update
68
     * Signal that the next matching brace update
 Lines 357-405    Link Here 
357
     *   <a href="@org-netbeans-modules-editor-bracesmatching@/overview-summary.html">Editor Braces Matching</a>.
74
     *   <a href="@org-netbeans-modules-editor-bracesmatching@/overview-summary.html">Editor Braces Matching</a>.
358
     */
75
     */
359
    public void requestMatchBraceUpdateSync() {
76
    public void requestMatchBraceUpdateSync() {
360
// XXX: remove
361
//        matchBraceUpdateSync = true;
362
    }
77
    }
363
    
78
    
364
// XXX: remove
365
//    /* package */ static boolean NO_HIGHLIGHT_BRACE_LAYER = Boolean.getBoolean("nbeditor-no-HighlightBraceLayer");
366
//    
367
//    /** 
368
//     * Draw layer to highlight the matching brace.
369
//     * 
370
//     * XXX: The HighlightBraceLayer needs to be rewritten using the new Highlighting SPI.
371
//     */
372
//    class HighlightBraceLayer extends DrawLayer.AbstractLayer {
373
//
374
//        public HighlightBraceLayer() {
375
//            super(HIGHLIGHT_BRACE_LAYER_NAME);
376
//        }
377
//
378
//        public void init(DrawContext ctx) {
379
//        }
380
//
381
//        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
382
//            if (!NO_HIGHLIGHT_BRACE_LAYER && braceMarksValid) {
383
//                if (mark != null)
384
//                    return mark.getActivateLayer();
385
//                try {
386
//                    if (ctx.getStartOffset() > highlightBraceEndMark.getOffset())
387
//                        return highlightBraceEndMark.getActivateLayer();
388
//                    if (ctx.getStartOffset() > highlightBraceStartMark.getOffset())
389
//                        return highlightBraceStartMark.getActivateLayer();
390
//                } catch (InvalidMarkException ex) {                    
391
//                }
392
//            }
393
//
394
//            return false;
395
//        }
396
//
397
//        public void updateContext(DrawContext ctx) {
398
//            if (!NO_HIGHLIGHT_BRACE_LAYER && highlightBraceColoring != null) {
399
//                highlightBraceColoring.apply(ctx);
400
//            }
401
//        }
402
//
403
//    }
404
405
}
79
}
(-)a/editor.lib/src/org/netbeans/modules/editor/lib/BeforeSaveTasks.java (-1 / +1 lines)
 Lines 113-119    Link Here 
113
    private void runTasks() {
113
    private void runTasks() {
114
        doc.runAtomicAsUser (new Runnable () {
114
        doc.runAtomicAsUser (new Runnable () {
115
            public void run () {
115
            public void run () {
116
                CompoundEdit atomicEdit = EditorPackageAccessor.get().markAtomicEditsNonSignificant(doc);
116
                CompoundEdit atomicEdit = EditorPackageAccessor.get().BaseDocument_markAtomicEditsNonSignificant(doc);
117
                // Since these are before-save actions they should generally not prevent
117
                // Since these are before-save actions they should generally not prevent
118
                // the save operation to succeed. Thus the possible exceptions thrown
118
                // the save operation to succeed. Thus the possible exceptions thrown
119
                // by the tasks will be notified but they will not prevent the save to succeed.
119
                // by the tasks will be notified but they will not prevent the save to succeed.
(-)a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPackageAccessor.java (-14 / +26 lines)
 Lines 41-48    Link Here 
41
41
42
package org.netbeans.modules.editor.lib;
42
package org.netbeans.modules.editor.lib;
43
43
44
import javax.swing.text.BadLocationException;
44
import javax.swing.undo.CompoundEdit;
45
import javax.swing.undo.CompoundEdit;
45
import org.netbeans.editor.BaseDocument;
46
import org.netbeans.editor.BaseDocument;
47
import org.netbeans.editor.InvalidMarkException;
48
import org.netbeans.editor.Mark;
49
import org.netbeans.modules.editor.lib.impl.MarkVector;
50
import org.netbeans.modules.editor.lib.impl.MultiMark;
46
51
47
52
48
/**
53
/**
 Lines 54-77    Link Here 
54
59
55
public abstract class EditorPackageAccessor {
60
public abstract class EditorPackageAccessor {
56
61
57
    private static EditorPackageAccessor INSTANCE;
62
    private static EditorPackageAccessor ACCESSOR = null;
58
63
59
    public static EditorPackageAccessor get() {
64
    public static synchronized void register(EditorPackageAccessor accessor) {
60
        if (INSTANCE == null) {
65
        assert ACCESSOR == null : "Can't register two package accessors!"; //NOI18N
61
            // Cause api accessor impl to get initialized
66
        ACCESSOR = accessor;
62
            try {
63
                Class.forName(BaseDocument.class.getName(), true, EditorPackageAccessor.class.getClassLoader());
64
            } catch (ClassNotFoundException e) {
65
                // Should never happen
66
            }
67
        }
68
        return INSTANCE;
69
    }
67
    }
70
68
71
    public static void register(EditorPackageAccessor accessor) {
69
    public static synchronized EditorPackageAccessor get() {
72
        INSTANCE = accessor;
70
        // Trying to wake up BaseDocument ...
71
        try {
72
            Class clazz = Class.forName(BaseDocument.class.getName());
73
        } catch (ClassNotFoundException e) {
74
            // ignore
75
        }
76
77
        assert ACCESSOR != null : "There is no package accessor available!"; //NOI18N
78
        return ACCESSOR;
73
    }
79
    }
74
80
75
    public abstract CompoundEdit markAtomicEditsNonSignificant(BaseDocument doc);
81
    protected EditorPackageAccessor() {
82
    }
83
84
    public abstract CompoundEdit BaseDocument_markAtomicEditsNonSignificant(BaseDocument doc);
85
    public abstract MarkVector BaseDocument_getMarksStorage(BaseDocument doc);
86
    public abstract Mark BaseDocument_getMark(BaseDocument doc, MultiMark multiMark);
87
    public abstract void Mark_insert(Mark mark, BaseDocument doc, int pos) throws InvalidMarkException, BadLocationException;
76
88
77
}
89
}
(-)a/editor.lib/src/org/netbeans/editor/CollapsedView.java (-1 / +9 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.awt.Container;
44
import java.awt.Container;
45
import java.awt.FontMetrics;
45
import java.awt.FontMetrics;
 Lines 63-68    Link Here 
63
import org.netbeans.api.editor.settings.AttributesUtilities;
63
import org.netbeans.api.editor.settings.AttributesUtilities;
64
import org.netbeans.api.editor.settings.FontColorNames;
64
import org.netbeans.api.editor.settings.FontColorNames;
65
import org.netbeans.api.editor.settings.FontColorSettings;
65
import org.netbeans.api.editor.settings.FontColorSettings;
66
import org.netbeans.editor.BaseKit;
67
import org.netbeans.editor.BaseTextUI;
68
import org.netbeans.editor.Coloring;
69
import org.netbeans.editor.EditorUI;
70
import org.netbeans.editor.FoldingToolTip;
71
import org.netbeans.editor.FontMetricsCache;
72
import org.netbeans.editor.PopupManager;
73
import org.netbeans.editor.Utilities;
66
import org.netbeans.editor.ext.ToolTipSupport;
74
import org.netbeans.editor.ext.ToolTipSupport;
67
import org.netbeans.editor.view.spi.LockView;
75
import org.netbeans.editor.view.spi.LockView;
68
import org.openide.util.Lookup;
76
import org.openide.util.Lookup;
(-)a/editor.lib/src/org/netbeans/editor/DrawContext.java (-1 / +4 lines)
 Lines 39-48    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.awt.Color;
44
import java.awt.Color;
45
import java.awt.Font;
45
import java.awt.Font;
46
import org.netbeans.editor.EditorUI;
47
import org.netbeans.editor.TokenContextPath;
48
import org.netbeans.editor.TokenID;
46
49
47
/** This interface provides methods for
50
/** This interface provides methods for
48
* getting and setting various drawing attributes.
51
* getting and setting various drawing attributes.
(-)a/editor.lib/src/org/netbeans/editor/DrawEngine.java (-45 / +85 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.awt.Graphics;
44
import java.awt.Graphics;
45
import java.awt.Graphics2D;
45
import java.awt.Graphics2D;
 Lines 50-55    Link Here 
50
import java.awt.Insets;
50
import java.awt.Insets;
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.List;
52
import java.util.List;
53
import java.util.Map;
53
import java.util.logging.Level;
54
import java.util.logging.Level;
54
import java.util.logging.Logger;
55
import java.util.logging.Logger;
55
import javax.swing.text.BadLocationException;
56
import javax.swing.text.BadLocationException;
 Lines 59-64    Link Here 
59
import javax.swing.text.Segment;
60
import javax.swing.text.Segment;
60
import javax.swing.text.View;
61
import javax.swing.text.View;
61
import org.netbeans.api.editor.settings.FontColorNames;
62
import org.netbeans.api.editor.settings.FontColorNames;
63
import org.netbeans.editor.Analyzer;
64
import org.netbeans.editor.BaseDocument;
65
import org.netbeans.editor.Coloring;
66
import org.netbeans.editor.EditorDebug;
67
import org.netbeans.editor.EditorUI;
68
import org.netbeans.editor.FontMetricsCache;
69
import org.netbeans.editor.InvalidMarkException;
70
import org.netbeans.editor.Mark;
71
import org.netbeans.editor.TokenContextPath;
72
import org.netbeans.editor.TokenID;
73
import org.netbeans.editor.Utilities;
74
import org.netbeans.modules.editor.lib.EditorPackageAccessor;
75
import org.netbeans.modules.editor.lib.impl.MarkVector;
76
import org.netbeans.modules.editor.lib.impl.MultiMark;
62
77
63
/**
78
/**
64
 * This class is responsible for drawing editor components. It's a singleton.
79
 * This class is responsible for drawing editor components. It's a singleton.
 Lines 67-73    Link Here 
67
 * 
82
 * 
68
 * @author Miloslav Metelka
83
 * @author Miloslav Metelka
69
 */
84
 */
70
/* package */ final class DrawEngine {
85
public final class DrawEngine {
71
86
72
    private static final Logger LOG = Logger.getLogger(DrawEngine.class.getName());
87
    private static final Logger LOG = Logger.getLogger(DrawEngine.class.getName());
73
    
88
    
 Lines 92-100    Link Here 
92
        return drawEngine;
107
        return drawEngine;
93
    }
108
    }
94
    
109
    
95
    private void initLineNumbering(DrawInfo ctx) {
110
    private void initLineNumbering(DrawInfo ctx, EditorUI eui) {
111
        EditorUiAccessor accessor = EditorUiAccessor.get();
96
        // Resolve whether line numbers will be painted
112
        // Resolve whether line numbers will be painted
97
        ctx.lineNumbering = ctx.editorUI.lineNumberVisible
113
        ctx.lineNumbering = accessor.isLineNumberVisible(eui)
98
                            && ctx.drawGraphics.supportsLineNumbers();
114
                            && ctx.drawGraphics.supportsLineNumbers();
99
115
100
        // create buffer for showing line numbers
116
        // create buffer for showing line numbers
 Lines 105-111    Link Here 
105
                LOG.log(Level.WARNING, null, e);
121
                LOG.log(Level.WARNING, null, e);
106
            }
122
            }
107
123
108
            ctx.lineNumberColoring = ctx.editorUI.getColoring(FontColorNames.LINE_NUMBER_COLORING);
124
            ctx.lineNumberColoring = accessor.getColoring(eui, FontColorNames.LINE_NUMBER_COLORING);
109
            if (ctx.lineNumberColoring == null) {
125
            if (ctx.lineNumberColoring == null) {
110
                ctx.lineNumberColoring = ctx.defaultColoring; // no number coloring found
126
                ctx.lineNumberColoring = ctx.defaultColoring; // no number coloring found
111
127
 Lines 128-134    Link Here 
128
                lnForeColor = ctx.defaultColoring.getForeColor();
144
                lnForeColor = ctx.defaultColoring.getForeColor();
129
            }
145
            }
130
146
131
            ctx.lineNumberChars = new char[Math.max(ctx.editorUI.lineNumberMaxDigitCount, 1)];
147
            ctx.lineNumberChars = new char[Math.max(accessor.getLineNumberMaxDigitCount(eui), 1)];
148
            ctx.lineNumberWidth = accessor.getLineNumberWidth(eui);
149
            ctx.lineNumberDigitWidth = accessor.getLineNumberDigitWidth(eui);
150
            ctx.lineNumberMargin = accessor.getLineNumberMargin(eui);
132
            if (ctx.graphics == null) {
151
            if (ctx.graphics == null) {
133
                ctx.syncedLineNumbering = true;
152
                ctx.syncedLineNumbering = true;
134
153
 Lines 143-171    Link Here 
143
        }
162
        }
144
    }
163
    }
145
164
146
    private void initInfo(DrawInfo ctx) throws BadLocationException {
165
    private void initInfo(DrawInfo ctx, EditorUI eui) throws BadLocationException {
147
        if (ctx.startOffset < ctx.lineStartOffset) {
166
        if (ctx.startOffset < ctx.lineStartOffset) {
148
            throw new BadLocationException("Invalid startOffset: " + ctx.startOffset + " < line start offset = " + ctx.lineStartOffset, ctx.startOffset); //NOI18N
167
            throw new BadLocationException("Invalid startOffset: " + ctx.startOffset + " < line start offset = " + ctx.lineStartOffset, ctx.startOffset); //NOI18N
149
        }
168
        }
150
        if (ctx.endOffset > ctx.lineEndOffset) {
169
        if (ctx.endOffset > ctx.lineEndOffset) {
151
            throw new BadLocationException("Invalid endOffset: " + ctx.endOffset + " > line end offset = " + ctx.lineEndOffset, ctx.endOffset); //NOI18N
170
            throw new BadLocationException("Invalid endOffset: " + ctx.endOffset + " > line end offset = " + ctx.lineEndOffset, ctx.endOffset); //NOI18N
152
        }
171
        }
153
        
172
173
        EditorUiAccessor accessor = EditorUiAccessor.get();
174
154
        ctx.x = ctx.startX;
175
        ctx.x = ctx.startX;
155
        ctx.y = ctx.startY;
176
        ctx.y = ctx.startY;
156
        ctx.lineHeight = ctx.editorUI.getLineHeight();
177
        ctx.lineHeight = accessor.getLineHeight(eui);
157
        ctx.defaultColoring = ctx.editorUI.getDefaultColoring();
178
        ctx.defaultColoring = accessor.getDefaultColoring(eui);
158
        ctx.tabSize = ctx.doc.getTabSize();
179
        ctx.tabSize = ctx.doc.getTabSize();
180
        ctx.defaultSpaceWidth = accessor.getDefaultSpaceWidth(eui);
159
        ctx.fragmentOffset = ctx.startOffset; // actual painting position
181
        ctx.fragmentOffset = ctx.startOffset; // actual painting position
160
        ctx.graphics = ctx.drawGraphics.getGraphics();
182
        ctx.graphics = ctx.drawGraphics.getGraphics();
161
183
162
        if (ctx.graphics != null) {
184
        if (ctx.graphics != null) {
163
            if (ctx.editorUI.renderingHints != null) {
185
            Map<?, ?> hints = accessor.getRenderingHints(eui);
164
                ((Graphics2D)ctx.graphics).setRenderingHints(ctx.editorUI.renderingHints);
186
            if (hints != null) {
187
                ((Graphics2D)ctx.graphics).setRenderingHints(hints);
165
            }
188
            }
166
        }
189
        }
167
190
168
        initLineNumbering(ctx);
191
        ctx.extentBounds = accessor.getExtentBounds(eui);
192
        ctx.textMargin = accessor.getTextMargin(eui);
193
        ctx.textLeftMarginWidth = accessor.getTextLeftMarginWidth(eui);
194
        ctx.textLimitLineVisible = accessor.getTextLimitLineVisible(eui);
195
        ctx.textLimitLineColor = accessor.getTextLimitLineColor(eui);
196
        ctx.textLimitWidth = accessor.getTextLimitWidth(eui);
197
        initLineNumbering(ctx, eui);
169
198
170
        // Initialize draw context
199
        // Initialize draw context
171
        ctx.foreColor = ctx.defaultColoring.getForeColor();
200
        ctx.foreColor = ctx.defaultColoring.getForeColor();
 Lines 177-188    Link Here 
177
        ctx.drawGraphics.init(ctx);
206
        ctx.drawGraphics.init(ctx);
178
        ctx.drawGraphics.setDefaultBackColor(ctx.defaultColoring.getBackColor());
207
        ctx.drawGraphics.setDefaultBackColor(ctx.defaultColoring.getBackColor());
179
        ctx.drawGraphics.setLineHeight(ctx.lineHeight);
208
        ctx.drawGraphics.setLineHeight(ctx.lineHeight);
180
        ctx.drawGraphics.setLineAscent(ctx.editorUI.getLineAscent());
209
        ctx.drawGraphics.setLineAscent(accessor.getLineAscent(eui));
181
        ctx.drawGraphics.setX(ctx.x);
210
        ctx.drawGraphics.setX(ctx.x);
182
        ctx.drawGraphics.setY(ctx.y);
211
        ctx.drawGraphics.setY(ctx.y);
183
212
184
        // Init all draw-layers
213
        // Init all draw-layers
185
        ctx.layers = ctx.editorUI.getDrawLayerList().currentLayers();
214
        ctx.layers = DrawLayerList.forComponent(ctx.component).currentLayers();
186
        int layersLength = ctx.layers.length;
215
        int layersLength = ctx.layers.length;
187
        ctx.layerActives = new boolean[layersLength];
216
        ctx.layerActives = new boolean[layersLength];
188
        ctx.layerActivityChangeOffsets = new int[layersLength];
217
        ctx.layerActivityChangeOffsets = new int[layersLength];
 Lines 191-198    Link Here 
191
            ctx.layers[i].init(ctx); // init all layers
220
            ctx.layers[i].init(ctx); // init all layers
192
        }
221
        }
193
222
194
        ctx.drawMarkList = new ArrayList<MarkFactory.DrawMark>();
223
        ctx.drawMarkList = new ArrayList<DrawMark>();
195
        MarkVector docMarksStorage = ctx.doc.marksStorage;
224
        MarkVector docMarksStorage = EditorPackageAccessor.get().BaseDocument_getMarksStorage(ctx.doc);
196
        synchronized (docMarksStorage) {
225
        synchronized (docMarksStorage) {
197
            int offset = ctx.startOffset;
226
            int offset = ctx.startOffset;
198
            int low = 0;
227
            int low = 0;
 Lines 226-237    Link Here 
226
                        break;
255
                        break;
227
                    }
256
                    }
228
257
229
                    Mark mark = ctx.doc.marks.get(m);
258
                    Mark mark = EditorPackageAccessor.get().BaseDocument_getMark(ctx.doc, m);
230
                    if (mark == null) {
259
                    if (mark == null) {
231
                        throw new IllegalStateException("No mark for m=" + m); // NOI18N
260
                        throw new IllegalStateException("No mark for m=" + m); // NOI18N
232
                    }
261
                    }
233
                    if (mark instanceof MarkFactory.DrawMark) {
262
                    if (mark instanceof DrawMark) {
234
                        ctx.drawMarkList.add((MarkFactory.DrawMark)mark);
263
                        ctx.drawMarkList.add((DrawMark)mark);
235
                    }
264
                    }
236
                }
265
                }
237
266
 Lines 326-334    Link Here 
326
                }
355
                }
327
356
328
                // Fill the DG's attributes and draw
357
                // Fill the DG's attributes and draw
329
                int numX = ctx.x - ctx.editorUI.lineNumberWidth;
358
                int numX = ctx.x - ctx.lineNumberWidth;
330
                if (ctx.editorUI.getLineNumberMargin() != null) {
359
                if (ctx.lineNumberMargin != null) {
331
                    numX += ctx.editorUI.getLineNumberMargin().left;
360
                    numX += ctx.lineNumberMargin.left;
332
                }
361
                }
333
                ctx.drawGraphics.setX(numX);
362
                ctx.drawGraphics.setX(numX);
334
363
 Lines 343-357    Link Here 
343
                ctx.drawGraphics.setBottomBorderLineColor(ctx.bottomBorderLineColor);
372
                ctx.drawGraphics.setBottomBorderLineColor(ctx.bottomBorderLineColor);
344
                ctx.drawGraphics.setLeftBorderLineColor(ctx.leftBorderLineColor);
373
                ctx.drawGraphics.setLeftBorderLineColor(ctx.leftBorderLineColor);
345
                ctx.drawGraphics.setFont(ctx.font);
374
                ctx.drawGraphics.setFont(ctx.font);
346
                ctx.drawGraphics.drawChars(0, ctx.lineNumberChars.length,
375
                ctx.drawGraphics.drawChars(0, ctx.lineNumberChars.length, ctx.lineNumberWidth);
347
                    ctx.editorUI.lineNumberWidth);
348
376
349
                // When printing there should be an additional space between
377
                // When printing there should be an additional space between
350
                // line number and the text
378
                // line number and the text
351
                if (ctx.drawGraphics.getGraphics() == null) {
379
                if (ctx.drawGraphics.getGraphics() == null) {
352
                    ctx.drawGraphics.setBuffer(SPACE);
380
                    ctx.drawGraphics.setBuffer(SPACE);
353
                    ctx.drawGraphics.drawChars(0, 1,
381
                    ctx.drawGraphics.drawChars(0, 1, ctx.lineNumberDigitWidth);
354
                        ctx.editorUI.lineNumberDigitWidth);
355
                }
382
                }
356
383
357
                ctx.drawGraphics.setX(ctx.x);
384
                ctx.drawGraphics.setX(ctx.x);
 Lines 507-513    Link Here 
507
        // Handle possible white space expansion and compute display width
534
        // Handle possible white space expansion and compute display width
508
        FontMetricsCache.Info fmcInfo = FontMetricsCache.getInfo(ctx.font);
535
        FontMetricsCache.Info fmcInfo = FontMetricsCache.getInfo(ctx.font);
509
        ctx.spaceWidth = (ctx.component != null)
536
        ctx.spaceWidth = (ctx.component != null)
510
            ? fmcInfo.getSpaceWidth(ctx.component) : ctx.editorUI.defaultSpaceWidth;
537
            ? fmcInfo.getSpaceWidth(ctx.component) : ctx.defaultSpaceWidth;
511
538
512
        // Compute real count of chars in fragment - can differ if tabs
539
        // Compute real count of chars in fragment - can differ if tabs
513
        ctx.fragmentCharCount = ctx.fragmentLength;
540
        ctx.fragmentCharCount = ctx.fragmentLength;
 Lines 615-621    Link Here 
615
                    
642
                    
616
                    ctx.drawGraphics.setBackColor(ctx.backColor);
643
                    ctx.drawGraphics.setBackColor(ctx.backColor);
617
                    ctx.drawGraphics.fillRect(blankWidth);
644
                    ctx.drawGraphics.fillRect(blankWidth);
618
                    if (emptyLine && ctx.x <= ctx.editorUI.getTextMargin().left) { //#58652
645
                    if (emptyLine && ctx.x <= ctx.textMargin.left) { //#58652
619
                        ctx.x += blankWidth;
646
                        ctx.x += blankWidth;
620
                    }
647
                    }
621
                }
648
                }
 Lines 912-923    Link Here 
912
    private void drawTheRestOfTextLine(DrawInfo ctx) {
939
    private void drawTheRestOfTextLine(DrawInfo ctx) {
913
        handleEOL(ctx);
940
        handleEOL(ctx);
914
941
915
        if (ctx.editorUI.textLimitLineVisible) { // draw limit line
942
        if (ctx.textLimitLineVisible) { // draw limit line
916
            int lineX = ctx.editorUI.getTextMargin().left + ctx.getEditorUI().textLimitWidth() * ctx.editorUI.defaultSpaceWidth;
943
            int lineX = ctx.textMargin.left + ctx.textLimitWidth * ctx.defaultSpaceWidth;
917
            if (ctx.graphics !=null){
944
            if (ctx.graphics !=null){
918
                ctx.graphics.setColor(ctx.editorUI.getTextLimitLineColor());
945
                ctx.graphics.setColor(ctx.textLimitLineColor);
919
                Rectangle clip = ctx.graphics.getClipBounds();
946
                Rectangle clip = ctx.graphics.getClipBounds();
920
                if (clip.height>ctx.editorUI.getLineHeight()){
947
                if (clip.height>ctx.lineHeight){
921
                    ctx.graphics.drawLine(lineX, ctx.y, lineX, ctx.y+clip.height);
948
                    ctx.graphics.drawLine(lineX, ctx.y, lineX, ctx.y+clip.height);
922
                }
949
                }
923
            }
950
            }
 Lines 925-935    Link Here 
925
    }
952
    }
926
    
953
    
927
    private void graphicsSpecificUpdates(DrawInfo ctx) {
954
    private void graphicsSpecificUpdates(DrawInfo ctx) {
928
        Rectangle bounds = ctx.editorUI.getExtentBounds();
955
        Rectangle bounds = ctx.extentBounds;
929
        Rectangle clip = ctx.graphics.getClipBounds();
956
        Rectangle clip = ctx.graphics.getClipBounds();
930
        Insets textMargin = ctx.editorUI.getTextMargin();
957
        Insets textMargin = ctx.textMargin;
931
        int leftMarginWidth = textMargin.left - ctx.editorUI.lineNumberWidth
958
        int leftMarginWidth = textMargin.left - ctx.lineNumberWidth - ctx.textLeftMarginWidth;
932
                              - ctx.editorUI.textLeftMarginWidth;
933
959
934
        // Draw line numbers bar and all the line nummbers
960
        // Draw line numbers bar and all the line nummbers
935
        if (ctx.lineNumbering && !ctx.syncedLineNumbering) {
961
        if (ctx.lineNumbering && !ctx.syncedLineNumbering) {
 Lines 938-944    Link Here 
938
            int lnBarX = bounds.x + leftMarginWidth;
964
            int lnBarX = bounds.x + leftMarginWidth;
939
            if (!lnBackColor.equals(ctx.defaultColoring.getBackColor()) || bounds.x > 0) {
965
            if (!lnBackColor.equals(ctx.defaultColoring.getBackColor()) || bounds.x > 0) {
940
                ctx.graphics.setColor(lnBackColor);
966
                ctx.graphics.setColor(lnBackColor);
941
                ctx.graphics.fillRect(lnBarX, numY, ctx.editorUI.lineNumberWidth,
967
                ctx.graphics.fillRect(lnBarX, numY, ctx.lineNumberWidth,
942
                                      ctx.lineIndex * ctx.lineHeight); // can't use dg because of height
968
                                      ctx.lineIndex * ctx.lineHeight); // can't use dg because of height
943
            }
969
            }
944
970
 Lines 946-953    Link Here 
946
972
947
            int lastDigitInd = Math.max(ctx.lineNumberChars.length - 1, 0);
973
            int lastDigitInd = Math.max(ctx.lineNumberChars.length - 1, 0);
948
            int numX = lnBarX;
974
            int numX = lnBarX;
949
            if (ctx.editorUI.getLineNumberMargin() != null) {
975
            if (ctx.lineNumberMargin != null) {
950
                numX += ctx.editorUI.getLineNumberMargin().left;
976
                numX += ctx.lineNumberMargin.left;
951
            }
977
            }
952
978
953
            ctx.bol = true; //
979
            ctx.bol = true; //
 Lines 998-1008    Link Here 
998
                ctx.drawGraphics.setFont(ctx.font);
1024
                ctx.drawGraphics.setFont(ctx.font);
999
1025
1000
                ctx.drawGraphics.setX(lnBarX);
1026
                ctx.drawGraphics.setX(lnBarX);
1001
                ctx.drawGraphics.fillRect(ctx.editorUI.lineNumberWidth);
1027
                ctx.drawGraphics.fillRect(ctx.lineNumberWidth);
1002
                ctx.drawGraphics.setX(numX);
1028
                ctx.drawGraphics.setX(numX);
1003
1029
1004
                ctx.drawGraphics.drawChars(0, ctx.lineNumberChars.length,
1030
                ctx.drawGraphics.drawChars(0, ctx.lineNumberChars.length,
1005
                    ctx.lineNumberChars.length * ctx.editorUI.lineNumberDigitWidth);
1031
                    ctx.lineNumberChars.length * ctx.lineNumberDigitWidth);
1006
                
1032
                
1007
                ctx.drawGraphics.setBuffer(null); // will do changes in buffer
1033
                ctx.drawGraphics.setBuffer(null); // will do changes in buffer
1008
1034
 Lines 1162-1168    Link Here 
1162
                }
1188
                }
1163
1189
1164
                // Initialize the draw-info
1190
                // Initialize the draw-info
1165
                initInfo(ctx);
1191
                initInfo(ctx, editorUI);
1166
1192
1167
                // Draw the area
1193
                // Draw the area
1168
                drawArea(ctx);
1194
                drawArea(ctx);
 Lines 1323-1328    Link Here 
1323
        /** Coloring for the line-number. */
1349
        /** Coloring for the line-number. */
1324
        Coloring lineNumberColoring;
1350
        Coloring lineNumberColoring;
1325
1351
1352
        int lineNumberWidth;
1353
        int lineNumberDigitWidth;
1354
        Insets lineNumberMargin;
1355
1326
        /** Graphics object. It can be null when not drawing to the component. */
1356
        /** Graphics object. It can be null when not drawing to the component. */
1327
        Graphics graphics;
1357
        Graphics graphics;
1328
1358
 Lines 1361-1373    Link Here 
1361
        boolean drawMarkUpdate;
1391
        boolean drawMarkUpdate;
1362
1392
1363
        /** List of draw marks in the painted area. */
1393
        /** List of draw marks in the painted area. */
1364
        List<MarkFactory.DrawMark> drawMarkList;
1394
        List<DrawMark> drawMarkList;
1365
        
1395
        
1366
        /** Current index in the drawMarkList */
1396
        /** Current index in the drawMarkList */
1367
        int drawMarkIndex;
1397
        int drawMarkIndex;
1368
1398
1369
        /** Current draw-mark */
1399
        /** Current draw-mark */
1370
        MarkFactory.DrawMark drawMark;
1400
        DrawMark drawMark;
1371
1401
1372
        /** Position of the current draw-mark */
1402
        /** Position of the current draw-mark */
1373
        int drawMarkOffset;
1403
        int drawMarkOffset;
 Lines 1383-1388    Link Here 
1383
1413
1384
        /** Width of one space character for the current context font. */
1414
        /** Width of one space character for the current context font. */
1385
        int spaceWidth;
1415
        int spaceWidth;
1416
        int defaultSpaceWidth;
1386
1417
1387
        /** Display width of the fragment */
1418
        /** Display width of the fragment */
1388
        int fragmentWidth;
1419
        int fragmentWidth;
 Lines 1392-1397    Link Here 
1392
        */
1423
        */
1393
        int fragmentCharCount;
1424
        int fragmentCharCount;
1394
1425
1426
        Rectangle extentBounds;
1427
        Insets textMargin;
1428
        int textLeftMarginWidth;
1429
1430
        boolean textLimitLineVisible;
1431
        Color textLimitLineColor;
1432
        int textLimitWidth;
1433
        
1395
        public Color getForeColor() {
1434
        public Color getForeColor() {
1396
            return foreColor;
1435
            return foreColor;
1397
        }
1436
        }
 Lines 1525-1528    Link Here 
1525
        }
1564
        }
1526
1565
1527
    } // End of DrawInfo class
1566
    } // End of DrawInfo class
1567
    
1528
}
1568
}
(-)a/editor.lib/src/org/netbeans/editor/DrawEngineDocView.java (-13 / +15 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.awt.Graphics;
44
import java.awt.Graphics;
45
import java.awt.Rectangle;
45
import java.awt.Rectangle;
 Lines 59-64    Link Here 
59
import org.netbeans.api.editor.fold.FoldUtilities;
59
import org.netbeans.api.editor.fold.FoldUtilities;
60
import org.netbeans.api.editor.fold.FoldHierarchyEvent;
60
import org.netbeans.api.editor.fold.FoldHierarchyEvent;
61
import org.netbeans.api.editor.fold.FoldHierarchyListener;
61
import org.netbeans.api.editor.fold.FoldHierarchyListener;
62
import org.netbeans.editor.BaseTextUI;
63
import org.netbeans.editor.EditorUI;
62
import org.netbeans.lib.editor.view.GapDocumentView;
64
import org.netbeans.lib.editor.view.GapDocumentView;
63
import org.netbeans.editor.view.spi.LockView;
65
import org.netbeans.editor.view.spi.LockView;
64
66
 Lines 67-73    Link Here 
67
 *
69
 *
68
 * @author Miloslav Metelka
70
 * @author Miloslav Metelka
69
 */
71
 */
70
/* package */ class DrawEngineDocView extends GapDocumentView
72
public class DrawEngineDocView extends GapDocumentView
71
implements FoldHierarchyListener, PropertyChangeListener {
73
implements FoldHierarchyListener, PropertyChangeListener {
72
    
74
    
73
    private static final boolean debugRebuild
75
    private static final boolean debugRebuild
 Lines 86-98    Link Here 
86
    
88
    
87
    private boolean estimatedSpanResetInitiated;
89
    private boolean estimatedSpanResetInitiated;
88
    
90
    
89
    DrawEngineDocView(Element elem) {
91
    public DrawEngineDocView(Element elem) {
90
        super(elem);
92
        super(elem);
91
        
93
        
92
        setEstimatedSpan(true);
94
        setEstimatedSpan(true);
93
    }
95
    }
94
    
96
    
95
    public void setParent(View parent) {
97
    public @Override void setParent(View parent) {
96
        if (parent != null) { // start listening
98
        if (parent != null) { // start listening
97
            JTextComponent component = (JTextComponent)parent.getContainer();
99
            JTextComponent component = (JTextComponent)parent.getContainer();
98
            foldHierarchy = FoldHierarchy.get(component);
100
            foldHierarchy = FoldHierarchy.get(component);
 Lines 127-133    Link Here 
127
        return foldHierarchy;
129
        return foldHierarchy;
128
    }
130
    }
129
    
131
    
130
    protected boolean useCustomReloadChildren() {
132
    protected @Override boolean useCustomReloadChildren() {
131
        return true;
133
        return true;
132
    }
134
    }
133
135
 Lines 201-207    Link Here 
201
        collapsedFold = null;
203
        collapsedFold = null;
202
    }
204
    }
203
205
204
    protected void customReloadChildren(int index, int removeLength, int startOffset, int endOffset) {
206
    protected @Override void customReloadChildren(int index, int removeLength, int startOffset, int endOffset) {
205
        // if removing all the views reset the flag
207
        // if removing all the views reset the flag
206
        if (index == 0 && removeLength == getViewCount()) {
208
        if (index == 0 && removeLength == getViewCount()) {
207
            collapsedFoldsInPresentViews = false; // suppose there will be no folds in line views
209
            collapsedFoldsInPresentViews = false; // suppose there will be no folds in line views
 Lines 224-230    Link Here 
224
        }
226
        }
225
    }
227
    }
226
        
228
        
227
    protected View createCustomView(ViewFactory f,
229
    protected @Override View createCustomView(ViewFactory f,
228
    int startOffset, int maxEndOffset, int elementIndex) {
230
    int startOffset, int maxEndOffset, int elementIndex) {
229
        if (elementIndex == -1) {
231
        if (elementIndex == -1) {
230
            throw new IllegalStateException("Need underlying line element structure"); // NOI18N
232
            throw new IllegalStateException("Need underlying line element structure"); // NOI18N
 Lines 244-252    Link Here 
244
                List foldAndEndLineElemList = new ArrayList();
246
                List foldAndEndLineElemList = new ArrayList();
245
247
246
                while (true) {
248
                while (true) {
247
                    int collapsedFoldEndOffset = collapsedFold.getEndOffset();
249
                    int _collapsedFoldEndOffset = collapsedFold.getEndOffset();
248
                    // Find line element index of the line in which the collapsed fold ends
250
                    // Find line element index of the line in which the collapsed fold ends
249
                    while (collapsedFoldEndOffset > lineElemEndOffset) {
251
                    while (_collapsedFoldEndOffset > lineElemEndOffset) {
250
                        elementIndex++;
252
                        elementIndex++;
251
                        lineElem = elem.getElement(elementIndex);
253
                        lineElem = elem.getElement(elementIndex);
252
                        lineElemEndOffset = lineElem.getEndOffset();
254
                        lineElemEndOffset = lineElem.getEndOffset();
 Lines 322-333    Link Here 
322
        }
324
        }
323
    }
325
    }
324
326
325
    public void paint(Graphics g, Shape allocation) {
327
    public @Override void paint(Graphics g, Shape allocation) {
326
        java.awt.Component c = getContainer();
328
        java.awt.Component c = getContainer();
327
        if (c instanceof javax.swing.text.JTextComponent){
329
        if (c instanceof javax.swing.text.JTextComponent){
328
            TextUI textUI = ((javax.swing.text.JTextComponent)c).getUI();
330
            TextUI textUI = ((javax.swing.text.JTextComponent)c).getUI();
329
            if (textUI instanceof BaseTextUI){
331
            if (textUI instanceof BaseTextUI){
330
                ((BaseTextUI) textUI).getEditorUI().paint(g);
332
                EditorUiAccessor.get().paint(((BaseTextUI) textUI).getEditorUI(), g);
331
            }
333
            }
332
        }
334
        }
333
335
 Lines 340-346    Link Here 
340
        }
342
        }
341
    }
343
    }
342
    
344
    
343
    public void setSize(float width, float height) {
345
    public @Override void setSize(float width, float height) {
344
        super.setSize(width, height);
346
        super.setSize(width, height);
345
347
346
        /* #69446 - disabled estimated span reset
348
        /* #69446 - disabled estimated span reset
 Lines 375-381    Link Here 
375
         */
377
         */
376
    }
378
    }
377
379
378
    protected boolean isChildrenResizeDisabled() {
380
    protected @Override boolean isChildrenResizeDisabled() {
379
        return true;
381
        return true;
380
    }
382
    }
381
    
383
    
(-)a/editor.lib/src/org/netbeans/editor/DrawEngineFakeDocView.java (-2 / +2 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import javax.swing.text.Element;
44
import javax.swing.text.Element;
45
import org.netbeans.api.editor.fold.Fold;
45
import org.netbeans.api.editor.fold.Fold;
 Lines 50-56    Link Here 
50
 *
50
 *
51
 * @author Martin Roskanin
51
 * @author Martin Roskanin
52
 */
52
 */
53
class DrawEngineFakeDocView extends DrawEngineDocView{
53
/* package */ class DrawEngineFakeDocView extends DrawEngineDocView{
54
54
55
        private boolean useCollapsing = true;
55
        private boolean useCollapsing = true;
56
        private int fakeStartOffset;
56
        private int fakeStartOffset;
(-)a/editor.lib/src/org/netbeans/editor/DrawEngineLineView.java (-2 / +5 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.awt.Graphics;
44
import java.awt.Graphics;
45
import java.awt.Rectangle;
45
import java.awt.Rectangle;
 Lines 55-60    Link Here 
55
import javax.swing.text.Position.Bias;
55
import javax.swing.text.Position.Bias;
56
import javax.swing.text.View;
56
import javax.swing.text.View;
57
import javax.swing.text.ViewFactory;
57
import javax.swing.text.ViewFactory;
58
import org.netbeans.editor.BaseDocument;
59
import org.netbeans.editor.BaseTextUI;
60
import org.netbeans.editor.EditorUI;
58
import org.netbeans.editor.view.spi.EstimatedSpanView;
61
import org.netbeans.editor.view.spi.EstimatedSpanView;
59
import org.netbeans.editor.view.spi.LockView;
62
import org.netbeans.editor.view.spi.LockView;
60
import org.netbeans.editor.view.spi.ViewLayoutState;
63
import org.netbeans.editor.view.spi.ViewLayoutState;
 Lines 67-73    Link Here 
67
 *
70
 *
68
 * @author  Martin Roskanin
71
 * @author  Martin Roskanin
69
 */
72
 */
70
/* package */ class DrawEngineLineView extends View implements ViewLayoutState, EstimatedSpanView {
73
public class DrawEngineLineView extends View implements ViewLayoutState, EstimatedSpanView {
71
74
72
    private static final Logger LOG = Logger.getLogger(DrawEngineLineView.class.getName());
75
    private static final Logger LOG = Logger.getLogger(DrawEngineLineView.class.getName());
73
    private static final boolean loggable = LOG.isLoggable(Level.FINEST);
76
    private static final boolean loggable = LOG.isLoggable(Level.FINEST);
(-)a/editor.lib/src/org/netbeans/editor/DrawGraphics.java (-11 / +18 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.awt.Graphics;
44
import java.awt.Graphics;
45
import java.awt.Font;
45
import java.awt.Font;
 Lines 53-58    Link Here 
53
import java.awt.font.TextLayout;
53
import java.awt.font.TextLayout;
54
import javax.swing.JComponent;
54
import javax.swing.JComponent;
55
import javax.swing.text.View;
55
import javax.swing.text.View;
56
import org.netbeans.editor.Analyzer;
57
import org.netbeans.editor.AnnotationDesc;
58
import org.netbeans.editor.AnnotationTypes;
59
import org.netbeans.editor.Annotations;
60
import org.netbeans.editor.FontMetricsCache;
61
import org.netbeans.editor.PrintContainer;
56
62
57
/** Draw graphics functions as abstraction over various kinds of drawing. It's used
63
/** Draw graphics functions as abstraction over various kinds of drawing. It's used
58
* for drawing into classic graphics, printing and measuring.
64
* for drawing into classic graphics, printing and measuring.
 Lines 63-69    Link Here 
63
* @author Miloslav Metelka
69
* @author Miloslav Metelka
64
* @version 1.00
70
* @version 1.00
65
*/
71
*/
66
interface DrawGraphics {
72
public interface DrawGraphics {
67
    
73
    
68
    /** Set foreground color */
74
    /** Set foreground color */
69
    public void setForeColor(Color foreColor);
75
    public void setForeColor(Color foreColor);
 Lines 191-197    Link Here 
191
    /** Abstract draw-graphics that maintains a fg and bg color, font,
197
    /** Abstract draw-graphics that maintains a fg and bg color, font,
192
    * current x and y coordinates.
198
    * current x and y coordinates.
193
    */
199
    */
194
    static abstract class AbstractDG implements DrawGraphics {
200
    public static abstract class AbstractDG implements DrawGraphics {
195
201
196
        /** Current foreground color */
202
        /** Current foreground color */
197
        Color foreColor;
203
        Color foreColor;
 Lines 326-332    Link Here 
326
332
327
    } // End of AbstractDG class
333
    } // End of AbstractDG class
328
334
329
    static class SimpleDG extends AbstractDG {
335
    public static class SimpleDG extends AbstractDG {
330
336
331
        public Graphics getGraphics() {
337
        public Graphics getGraphics() {
332
            return null;
338
            return null;
 Lines 359-365    Link Here 
359
    * It optimizes the drawing by joining together the pieces of
365
    * It optimizes the drawing by joining together the pieces of
360
    * the text drawn with the same font and fg/bg color.
366
    * the text drawn with the same font and fg/bg color.
361
    */
367
    */
362
    static final class GraphicsDG extends SimpleDG {
368
    public static final class GraphicsDG extends SimpleDG {
363
369
364
        /** Whether debug messages should be displayed */
370
        /** Whether debug messages should be displayed */
365
        private static final boolean debug
371
        private static final boolean debug
 Lines 420-426    Link Here 
420
426
421
        private JComponent component;
427
        private JComponent component;
422
428
423
        GraphicsDG(Graphics graphics) {
429
        public GraphicsDG(Graphics graphics) {
424
            this.graphics = graphics;
430
            this.graphics = graphics;
425
            // #33165 - set invalid y initially
431
            // #33165 - set invalid y initially
426
            this.y = -1;
432
            this.y = -1;
 Lines 532-542    Link Here 
532
        }
538
        }
533
539
534
        public @Override void init(DrawContext ctx) {
540
        public @Override void init(DrawContext ctx) {
541
            EditorUiAccessor accessor = EditorUiAccessor.get();
535
            annos = ctx.getEditorUI().getDocument().getAnnotations();
542
            annos = ctx.getEditorUI().getDocument().getAnnotations();
536
            drawTextLimitLine = ctx.getEditorUI().textLimitLineVisible;
543
            drawTextLimitLine = accessor.getTextLimitLineVisible(ctx.getEditorUI());
537
            textLimitWidth = ctx.getEditorUI().textLimitWidth();
544
            textLimitWidth = accessor.getTextLimitWidth(ctx.getEditorUI());
538
            defaultSpaceWidth = ctx.getEditorUI().defaultSpaceWidth;
545
            defaultSpaceWidth = accessor.getDefaultSpaceWidth(ctx.getEditorUI());
539
            textLimitLineColor = ctx.getEditorUI().getTextLimitLineColor();
546
            textLimitLineColor = accessor.getTextLimitLineColor(ctx.getEditorUI());
540
            absoluteX = ctx.getEditorUI().getTextMargin().left;
547
            absoluteX = ctx.getEditorUI().getTextMargin().left;
541
            maxWidth = ctx.getEditorUI().getExtentBounds().width;
548
            maxWidth = ctx.getEditorUI().getExtentBounds().width;
542
            component = ctx.getEditorUI().getComponent();
549
            component = ctx.getEditorUI().getComponent();
 Lines 822-828    Link Here 
822
829
823
    } // End of GraphicsDG class
830
    } // End of GraphicsDG class
824
831
825
    static final class PrintDG extends SimpleDG {
832
    public static final class PrintDG extends SimpleDG {
826
833
827
        PrintContainer container;
834
        PrintContainer container;
828
835
(-)a/editor.lib/src/org/netbeans/editor/DrawLayer.java (-4 / +4 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
/** Draw layer applies changes to draw context during painting process.
44
/** Draw layer applies changes to draw context during painting process.
45
* Each extended UI has its own set of layers.
45
* Each extended UI has its own set of layers.
 Lines 61-67    Link Here 
61
*/
61
*/
62
62
63
63
64
public interface DrawLayer {
64
/* package */ interface DrawLayer {
65
65
66
    /**
66
    /**
67
     * Start of the next region with the frame.
67
     * Start of the next region with the frame.
 Lines 122-128    Link Here 
122
    * @param mark draw-mark at the fragment-offset or null if called
122
    * @param mark draw-mark at the fragment-offset or null if called
123
    * because of the next-activity-change-offset.
123
    * because of the next-activity-change-offset.
124
    */
124
    */
125
    public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark);
125
    public boolean isActive(DrawContext ctx, DrawMark mark);
126
126
127
    /** Update draw context by setting colors, fonts and possibly other draw
127
    /** Update draw context by setting colors, fonts and possibly other draw
128
    * properties.
128
    * properties.
 Lines 200-206    Link Here 
200
            return lineNumber;
200
            return lineNumber;
201
        }
201
        }
202
202
203
        public String toString() {
203
        public @Override String toString() {
204
            return "Layer " + getClass() + ", name='" + name; // NOI18N
204
            return "Layer " + getClass() + ", name='" + name; // NOI18N
205
        }
205
        }
206
206
(-)a/editor.lib/src/org/netbeans/editor/DrawLayerList.java (-3 / +14 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.util.ArrayList;
44
import java.util.ArrayList;
45
import java.util.Arrays;
45
import java.util.Arrays;
 Lines 48-53    Link Here 
48
import java.util.Set;
48
import java.util.Set;
49
import java.util.logging.Level;
49
import java.util.logging.Level;
50
import java.util.logging.Logger;
50
import java.util.logging.Logger;
51
import javax.swing.text.JTextComponent;
52
import org.netbeans.editor.EditorDebug;
51
53
52
/** Draw layer list stores multiple draw-layers sorted
54
/** Draw layer list stores multiple draw-layers sorted
53
* according to their visibility which is the integer giving the z-order
55
* according to their visibility which is the integer giving the z-order
 Lines 59-65    Link Here 
59
*/
61
*/
60
62
61
63
62
class DrawLayerList {
64
/* package */ class DrawLayerList {
63
65
64
    private static final Logger LOG = Logger.getLogger(DrawLayerList.class.getName());
66
    private static final Logger LOG = Logger.getLogger(DrawLayerList.class.getName());
65
67
 Lines 71-76    Link Here 
71
    
73
    
72
    private final ArrayList visibilityList = new ArrayList();
74
    private final ArrayList visibilityList = new ArrayList();
73
75
76
    public static synchronized DrawLayerList forComponent(JTextComponent jtc) {
77
        DrawLayerList dll = (DrawLayerList) jtc.getClientProperty(DrawLayerList.class);
78
        if (dll == null) {
79
            dll = new DrawLayerList();
80
            jtc.putClientProperty(DrawLayerList.class, dll);
81
        }
82
        return dll;
83
    }
84
74
    /** Add the new layer to the list depending on visibility.
85
    /** Add the new layer to the list depending on visibility.
75
    * @param layer layer to add to the layer list
86
    * @param layer layer to add to the layer list
76
    * @return true when new layer was added false otherwise. The layer
87
    * @return true when new layer was added false otherwise. The layer
 Lines 168-174    Link Here 
168
        return -1;
179
        return -1;
169
    }
180
    }
170
181
171
    public String toString() {
182
    public @Override String toString() {
172
        switch (layers.length) {
183
        switch (layers.length) {
173
        case 0:
184
        case 0:
174
            return "No layers"; // NOI18N
185
            return "No layers"; // NOI18N
(-)a/editor.lib/src/org/netbeans/editor/FoldMultiLineView.java (-3 / +4 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.util.ArrayList;
44
import java.util.ArrayList;
45
import java.util.List;
45
import java.util.List;
 Lines 50-55    Link Here 
50
import javax.swing.text.View;
50
import javax.swing.text.View;
51
import javax.swing.text.ViewFactory;
51
import javax.swing.text.ViewFactory;
52
import org.netbeans.api.editor.fold.Fold;
52
import org.netbeans.api.editor.fold.Fold;
53
import org.netbeans.editor.BaseDocument;
53
import org.netbeans.lib.editor.view.GapMultiLineView;
54
import org.netbeans.lib.editor.view.GapMultiLineView;
54
55
55
/**
56
/**
 Lines 84-94    Link Here 
84
        return (JTextComponent)getContainer();
85
        return (JTextComponent)getContainer();
85
    }
86
    }
86
    
87
    
87
    protected boolean useCustomReloadChildren() {
88
    protected @Override boolean useCustomReloadChildren() {
88
        return true;
89
        return true;
89
    }
90
    }
90
    
91
    
91
    protected void reloadChildren(int index, int removeLength, int startOffset, int endOffset) {
92
    protected @Override void reloadChildren(int index, int removeLength, int startOffset, int endOffset) {
92
        // TODO uncomment assert (index == 0 && removeLength == 0
93
        // TODO uncomment assert (index == 0 && removeLength == 0
93
            // && startOffset == getStartOffset() && endOffset == getEndOffset());
94
            // && startOffset == getStartOffset() && endOffset == getEndOffset());
94
95
(-)a/editor.lib/src/org/netbeans/editor/HighlightingDrawLayer.java (-28 / +33 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import java.lang.ref.WeakReference;
44
import java.lang.ref.WeakReference;
45
import java.util.ArrayList;
45
import java.util.ArrayList;
 Lines 61-67    Link Here 
61
import javax.swing.text.SimpleAttributeSet;
61
import javax.swing.text.SimpleAttributeSet;
62
import javax.swing.text.View;
62
import javax.swing.text.View;
63
import org.netbeans.api.editor.settings.AttributesUtilities;
63
import org.netbeans.api.editor.settings.AttributesUtilities;
64
import org.netbeans.editor.ext.ExtCaret;
64
import org.netbeans.editor.AtomicLockEvent;
65
import org.netbeans.editor.AtomicLockListener;
66
import org.netbeans.editor.BaseCaret;
67
import org.netbeans.editor.BaseDocument;
68
import org.netbeans.editor.Coloring;
65
import org.netbeans.editor.view.spi.LockView;
69
import org.netbeans.editor.view.spi.LockView;
66
import org.netbeans.modules.editor.lib2.highlighting.CaretBasedBlockHighlighting.CaretRowHighlighting;
70
import org.netbeans.modules.editor.lib2.highlighting.CaretBasedBlockHighlighting.CaretRowHighlighting;
67
import org.netbeans.modules.editor.lib2.highlighting.HighlightingManager;
71
import org.netbeans.modules.editor.lib2.highlighting.HighlightingManager;
 Lines 80-86    Link Here 
80
 *
84
 *
81
 * @author vita
85
 * @author vita
82
 */
86
 */
83
/* package */ final class HighlightingDrawLayer extends DrawLayer.AbstractLayer 
87
public final class HighlightingDrawLayer extends DrawLayer.AbstractLayer
84
    implements HighlightsChangeListener, AtomicLockListener
88
    implements HighlightsChangeListener, AtomicLockListener
85
{
89
{
86
    // -J-Dorg.netbeans.editor.HighlightingDrawLayer.level=FINE
90
    // -J-Dorg.netbeans.editor.HighlightingDrawLayer.level=FINE
 Lines 89-96    Link Here 
89
    // Above CaretRowHighlighting.LAYER_TYPE_ID
93
    // Above CaretRowHighlighting.LAYER_TYPE_ID
90
    private static final String LAYER_A_NAME = "org-netbeans-lib-editor-nview-HighlightingDrawLayer/A"; //NOI18N
94
    private static final String LAYER_A_NAME = "org-netbeans-lib-editor-nview-HighlightingDrawLayer/A"; //NOI18N
91
    // above ZOrder.SYNTAX_RACK and below (including) CaretRowHighlighting.LAYER_TYPE_ID
95
    // above ZOrder.SYNTAX_RACK and below (including) CaretRowHighlighting.LAYER_TYPE_ID
92
    // Using the original name for the caret row highlighting, some clients use it to remove the layer.
96
    private static final String LAYER_B_NAME = "org-netbeans-lib-editor-nview-HighlightingDrawLayer/B"; //NOI18N
93
    private static final String LAYER_B_NAME = ExtCaret.HIGHLIGHT_ROW_LAYER_NAME; 
94
    // Only ZOrder.SYNTAX_RACK
97
    // Only ZOrder.SYNTAX_RACK
95
    private static final String LAYER_C_NAME = "org-netbeans-lib-editor-nview-HighlightingDrawLayer/C"; //NOI18N
98
    private static final String LAYER_C_NAME = "org-netbeans-lib-editor-nview-HighlightingDrawLayer/C"; //NOI18N
96
    // ZOrder.BOTTOM_RACK
99
    // ZOrder.BOTTOM_RACK
 Lines 188-247    Link Here 
188
        }
191
        }
189
    }; // End of FILTER_D constant
192
    }; // End of FILTER_D constant
190
    
193
    
191
    public static void hookUp(EditorUI eui) {
194
    public static void hookUp(JTextComponent jtc) {
192
        DrawLayer layerA = eui.findLayer(LAYER_A_NAME);
195
        DrawLayerList dll = DrawLayerList.forComponent(jtc);
196
        DrawLayer layerA = dll.findLayer(LAYER_A_NAME);
193
        if (layerA == null) {
197
        if (layerA == null) {
194
            layerA = new HighlightingDrawLayer(LAYER_A_NAME, FILTER_A);
198
            layerA = new HighlightingDrawLayer(LAYER_A_NAME, FILTER_A);
195
            eui.addLayer(layerA, 10000); // the old text selection layer's z-order (DrawLayerFactory.CaretLayer)
199
            dll.add(layerA, 10000); // the old text selection layer's z-order (DrawLayerFactory.CaretLayer)
196
200
197
            if (LOG.isLoggable(Level.FINE)) {
201
            if (LOG.isLoggable(Level.FINE)) {
198
                LOG.fine("Successfully registered layerA in " + simpleToString(eui)); //NOI18N
202
                LOG.fine("Successfully registered layerA in " + simpleToString(jtc)); //NOI18N
199
            }
203
            }
200
        } else {
204
        } else {
201
            if (LOG.isLoggable(Level.FINE)) {
205
            if (LOG.isLoggable(Level.FINE)) {
202
                LOG.fine("LayerA is already registered in " + simpleToString(eui)); //NOI18N
206
                LOG.fine("LayerA is already registered in " + simpleToString(jtc)); //NOI18N
203
            }
207
            }
204
        }
208
        }
205
209
206
        DrawLayer layerB = eui.findLayer(LAYER_B_NAME);
210
        DrawLayer layerB = dll.findLayer(LAYER_B_NAME);
207
        if (layerB == null) {
211
        if (layerB == null) {
208
            layerB = new HighlightingDrawLayer(LAYER_B_NAME, FILTER_B);
212
            layerB = new HighlightingDrawLayer(LAYER_B_NAME, FILTER_B);
209
            eui.addLayer(layerB, 2050); // the old caret row highlight layer's z-order
213
            dll.add(layerB, 2050); // the old caret row highlight layer's z-order
210
214
211
            if (LOG.isLoggable(Level.FINE)) {
215
            if (LOG.isLoggable(Level.FINE)) {
212
                LOG.fine("Successfully registered layerB in " + simpleToString(eui)); //NOI18N
216
                LOG.fine("Successfully registered layerB in " + simpleToString(jtc)); //NOI18N
213
            }
217
            }
214
        } else {
218
        } else {
215
            if (LOG.isLoggable(Level.FINE)) {
219
            if (LOG.isLoggable(Level.FINE)) {
216
                LOG.fine("LayerB is already registered in " + simpleToString(eui)); //NOI18N
220
                LOG.fine("LayerB is already registered in " + simpleToString(jtc)); //NOI18N
217
            }
221
            }
218
        }
222
        }
219
223
220
        DrawLayer layerC = eui.findLayer(LAYER_C_NAME);
224
        DrawLayer layerC = dll.findLayer(LAYER_C_NAME);
221
        if (layerC == null) {
225
        if (layerC == null) {
222
            layerC = new HighlightingDrawLayer(LAYER_C_NAME, FILTER_C);
226
            layerC = new HighlightingDrawLayer(LAYER_C_NAME, FILTER_C);
223
            eui.addLayer(layerC, 1000); // the old syntax draw layer's z-order (DrawLayerFactory.SyntaxLayer)
227
            dll.add(layerC, 1000); // the old syntax draw layer's z-order (DrawLayerFactory.SyntaxLayer)
224
228
225
            if (LOG.isLoggable(Level.FINE)) {
229
            if (LOG.isLoggable(Level.FINE)) {
226
                LOG.fine("Successfully registered layerC in " + simpleToString(eui)); //NOI18N
230
                LOG.fine("Successfully registered layerC in " + simpleToString(jtc)); //NOI18N
227
            }
231
            }
228
        } else {
232
        } else {
229
            if (LOG.isLoggable(Level.FINE)) {
233
            if (LOG.isLoggable(Level.FINE)) {
230
                LOG.fine("LayerC is already registered in " + simpleToString(eui)); //NOI18N
234
                LOG.fine("LayerC is already registered in " + simpleToString(jtc)); //NOI18N
231
            }
235
            }
232
        }
236
        }
233
237
234
        DrawLayer layerD = eui.findLayer(LAYER_D_NAME);
238
        DrawLayer layerD = dll.findLayer(LAYER_D_NAME);
235
        if (layerD == null) {
239
        if (layerD == null) {
236
            layerD = new HighlightingDrawLayer(LAYER_D_NAME, FILTER_D);
240
            layerD = new HighlightingDrawLayer(LAYER_D_NAME, FILTER_D);
237
            eui.addLayer(layerD, 500);
241
            dll.add(layerD, 500);
238
242
239
            if (LOG.isLoggable(Level.FINE)) {
243
            if (LOG.isLoggable(Level.FINE)) {
240
                LOG.fine("Successfully registered layerD in " + simpleToString(eui)); //NOI18N
244
                LOG.fine("Successfully registered layerD in " + simpleToString(jtc)); //NOI18N
241
            }
245
            }
242
        } else {
246
        } else {
243
            if (LOG.isLoggable(Level.FINE)) {
247
            if (LOG.isLoggable(Level.FINE)) {
244
                LOG.fine("LayerD is already registered in " + simpleToString(eui)); //NOI18N
248
                LOG.fine("LayerD is already registered in " + simpleToString(jtc)); //NOI18N
245
            }
249
            }
246
        }
250
        }
247
    }
251
    }
 Lines 341-347    Link Here 
341
        }
345
        }
342
    }
346
    }
343
    
347
    
344
    public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
348
    public boolean isActive(DrawContext ctx, DrawMark mark) {
345
        if (highlights != null) {
349
        if (highlights != null) {
346
            return processOffset(ctx, false);
350
            return processOffset(ctx, false);
347
        } else {
351
        } else {
 Lines 351-371    Link Here 
351
355
352
    public void updateContext(DrawContext ctx) {
356
    public void updateContext(DrawContext ctx) {
353
        if (highlights != null) {
357
        if (highlights != null) {
358
            ColoringAccessor accessor = ColoringAccessor.get();
354
            if (ctx.isEOL() && ctx.isBOL()) {
359
            if (ctx.isEOL() && ctx.isBOL()) {
355
                if (extendsEmptyLine() && !theLittleSpitAtTheBeginningOfAnEmptyLineDrawn) {
360
                if (extendsEmptyLine() && !theLittleSpitAtTheBeginningOfAnEmptyLineDrawn) {
356
                    theLittleSpitAtTheBeginningOfAnEmptyLineDrawn = true;
361
                    theLittleSpitAtTheBeginningOfAnEmptyLineDrawn = true;
357
                    Coloring coloring = Coloring.fromAttributeSet(lastELAttribs);
362
                    Coloring coloring = Coloring.fromAttributeSet(lastELAttribs);
358
                    coloring.apply(ctx);
363
                    accessor.apply(coloring, ctx);
359
                } else {
364
                } else {
360
                    if (extendsEOL()) {
365
                    if (extendsEOL()) {
361
                        Coloring coloring = Coloring.fromAttributeSet(lastEOLAttribs);
366
                        Coloring coloring = Coloring.fromAttributeSet(lastEOLAttribs);
362
                        coloring.apply(ctx);
367
                        accessor.apply(coloring, ctx);
363
                    }
368
                    }
364
                }
369
                }
365
            } else if (ctx.isEOL()) {
370
            } else if (ctx.isEOL()) {
366
                if (extendsEOL()) {
371
                if (extendsEOL()) {
367
                    Coloring coloring = Coloring.fromAttributeSet(lastEOLAttribs);
372
                    Coloring coloring = Coloring.fromAttributeSet(lastEOLAttribs);
368
                    coloring.apply(ctx);
373
                    accessor.apply(coloring, ctx);
369
                }
374
                }
370
            } else {
375
            } else {
371
                processOffset(ctx, true);
376
                processOffset(ctx, true);
 Lines 624-630    Link Here 
624
            if (hs.getStartOffset() <= currentOffset) {
629
            if (hs.getStartOffset() <= currentOffset) {
625
                if (applyAttributes) {
630
                if (applyAttributes) {
626
                    Coloring coloring = Coloring.fromAttributeSet(hs.getAttributes());
631
                    Coloring coloring = Coloring.fromAttributeSet(hs.getAttributes());
627
                    coloring.apply(ctx);
632
                    ColoringAccessor.get().apply(coloring, ctx);
628
                }
633
                }
629
                
634
                
630
                lastAttributeSet = hs.getAttributes();
635
                lastAttributeSet = hs.getAttributes();
 Lines 676-682    Link Here 
676
681
677
        return new AttributeSet [] { eolAttribs, elAttribs };
682
        return new AttributeSet [] { eolAttribs, elAttribs };
678
    }
683
    }
679
    
684
680
    private static String simpleToString(Object o) {
685
    private static String simpleToString(Object o) {
681
        return o == null ? "null" : o.getClass() + "@" + Integer.toHexString(System.identityHashCode(o)); //NOI18N
686
        return o == null ? "null" : o.getClass() + "@" + Integer.toHexString(System.identityHashCode(o)); //NOI18N
682
    }
687
    }
(-)a/editor.lib/src/org/netbeans/editor/MarkChain.java (-17 / +21 lines)
 Lines 39-48    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.drawing;
43
43
44
import javax.swing.text.BadLocationException;
44
import javax.swing.text.BadLocationException;
45
import javax.swing.text.Position;
45
import javax.swing.text.Position;
46
import org.netbeans.editor.BaseDocument;
47
import org.netbeans.editor.InvalidMarkException;
48
import org.netbeans.editor.Utilities;
49
import org.netbeans.modules.editor.lib.EditorPackageAccessor;
46
50
47
/**
51
/**
48
* Support class for chain of MarkBlocks
52
* Support class for chain of MarkBlocks
 Lines 51-63    Link Here 
51
* @version 1.00
55
* @version 1.00
52
*/
56
*/
53
57
54
public class MarkChain {
58
public final class MarkChain {
55
59
56
    /** Chain of all marks */
60
    /** Chain of all marks */
57
    protected MarkFactory.ChainDrawMark chain;
61
    protected ChainDrawMark chain;
58
62
59
    /** Current mark to make checks faster */
63
    /** Current mark to make checks faster */
60
    protected MarkFactory.ChainDrawMark curMark;
64
    protected ChainDrawMark curMark;
61
65
62
    /** Document for this mark */
66
    /** Document for this mark */
63
    protected BaseDocument doc;
67
    protected BaseDocument doc;
 Lines 70-76    Link Here 
70
    /** The mark created by addMark() method is stored in this variable. In case
74
    /** The mark created by addMark() method is stored in this variable. In case
71
     * the mark was not created, because there already was some on this position,
75
     * the mark was not created, because there already was some on this position,
72
     * the already existing mark is returned. */
76
     * the already existing mark is returned. */
73
    private MarkFactory.ChainDrawMark recentlyAddedMark;
77
    private ChainDrawMark recentlyAddedMark;
74
    
78
    
75
    /** Construct chain using draw marks */
79
    /** Construct chain using draw marks */
76
    public MarkChain(BaseDocument doc, String layerName) {
80
    public MarkChain(BaseDocument doc, String layerName) {
 Lines 78-88    Link Here 
78
        this.layerName = layerName;
82
        this.layerName = layerName;
79
    }
83
    }
80
84
81
    public final MarkFactory.ChainDrawMark getChain() {
85
    public final ChainDrawMark getChain() {
82
        return chain;
86
        return chain;
83
    }
87
    }
84
88
85
    public final MarkFactory.ChainDrawMark getCurMark() {
89
    public final ChainDrawMark getCurMark() {
86
        return curMark;
90
        return curMark;
87
    }
91
    }
88
92
 Lines 133-151    Link Here 
133
        }
137
        }
134
    }
138
    }
135
139
136
    protected MarkFactory.ChainDrawMark createAndInsertNewMark(int pos)
140
    protected ChainDrawMark createAndInsertNewMark(int pos)
137
    throws BadLocationException {
141
    throws BadLocationException {
138
        MarkFactory.ChainDrawMark mark = createMark();
142
        ChainDrawMark mark = createMark();
139
        try {
143
        try {
140
            mark.insert(doc, pos);
144
            EditorPackageAccessor.get().Mark_insert(mark, doc, pos);
141
        } catch (InvalidMarkException e) {
145
        } catch (InvalidMarkException e) {
142
            Utilities.annotateLoggable(e);
146
            Utilities.annotateLoggable(e);
143
        }
147
        }
144
        return mark;
148
        return mark;
145
    }
149
    }
146
150
147
    protected MarkFactory.ChainDrawMark createMark() {
151
    protected ChainDrawMark createMark() {
148
        MarkFactory.ChainDrawMark mark = new MarkFactory.ChainDrawMark(layerName, null, Position.Bias.Backward);
152
        ChainDrawMark mark = new ChainDrawMark(layerName, null, Position.Bias.Backward);
149
        mark.activateLayer = true;
153
        mark.activateLayer = true;
150
        return mark;
154
        return mark;
151
    }
155
    }
 Lines 165-171    Link Here 
165
        int rel = compareMark(pos);
169
        int rel = compareMark(pos);
166
        if (rel == 0) {
170
        if (rel == 0) {
167
            if (forceAdd) { // create fresh
171
            if (forceAdd) { // create fresh
168
                MarkFactory.ChainDrawMark mark = createAndInsertNewMark(pos);
172
                ChainDrawMark mark = createAndInsertNewMark(pos);
169
                recentlyAddedMark = mark;
173
                recentlyAddedMark = mark;
170
                if (curMark == chain) { // curMark is first mark
174
                if (curMark == chain) { // curMark is first mark
171
                    chain = curMark.insertChain(mark);
175
                    chain = curMark.insertChain(mark);
 Lines 179-185    Link Here 
179
            }
183
            }
180
184
181
        } else if (rel > 0) { // curMark after pos
185
        } else if (rel > 0) { // curMark after pos
182
            MarkFactory.ChainDrawMark mark = createAndInsertNewMark(pos);
186
            ChainDrawMark mark = createAndInsertNewMark(pos);
183
            recentlyAddedMark = mark;
187
            recentlyAddedMark = mark;
184
            if (curMark != null) {
188
            if (curMark != null) {
185
                if (curMark == chain) { // curMark is first mark
189
                if (curMark == chain) { // curMark is first mark
 Lines 191-197    Link Here 
191
                chain = mark;
195
                chain = mark;
192
            }
196
            }
193
        } else { // curMark before pos
197
        } else { // curMark before pos
194
            MarkFactory.ChainDrawMark mark = createAndInsertNewMark(pos);
198
            ChainDrawMark mark = createAndInsertNewMark(pos);
195
            recentlyAddedMark = mark;
199
            recentlyAddedMark = mark;
196
            if (curMark != null) {
200
            if (curMark != null) {
197
                if (curMark.next != null) {
201
                if (curMark.next != null) {
 Lines 209-215    Link Here 
209
    /** The mark created by addMark() method is returned by this method. In case
213
    /** The mark created by addMark() method is returned by this method. In case
210
     * the mark was not created, because there already was some on requested position,
214
     * the mark was not created, because there already was some on requested position,
211
     * the already existing mark is returned. */
215
     * the already existing mark is returned. */
212
    public MarkFactory.ChainDrawMark getAddedMark() {
216
    public ChainDrawMark getAddedMark() {
213
        return recentlyAddedMark;
217
        return recentlyAddedMark;
214
    }
218
    }
215
    
219
    
 Lines 228-234    Link Here 
228
        }
232
        }
229
    }
233
    }
230
    
234
    
231
    public boolean removeMark(MarkFactory.ChainDrawMark mark) {
235
    public boolean removeMark(ChainDrawMark mark) {
232
        if (mark == null) {
236
        if (mark == null) {
233
            throw new NullPointerException();
237
            throw new NullPointerException();
234
        }
238
        }
(-)a/editor.lib/src/org/netbeans/editor/BasePosition.java (-3 / +3 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.impl;
43
43
44
import javax.swing.text.BadLocationException;
44
import javax.swing.text.BadLocationException;
45
import javax.swing.text.Position;
45
import javax.swing.text.Position;
 Lines 55-66    Link Here 
55
* @version 1.00
55
* @version 1.00
56
*/
56
*/
57
57
58
class BasePosition implements Position {
58
public final class BasePosition implements Position {
59
59
60
    /** The mark that serves this position */
60
    /** The mark that serves this position */
61
    private MultiMark mark;
61
    private MultiMark mark;
62
62
63
    BasePosition() throws BadLocationException {
63
    public BasePosition() throws BadLocationException {
64
    }
64
    }
65
65
66
    /** Get offset in document for this position */
66
    /** Get offset in document for this position */
(-)a/editor.lib/src/org/netbeans/editor/MarkVector.java (-14 / +14 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.impl;
43
43
44
import java.util.List;
44
import java.util.List;
45
import javax.swing.text.Position;
45
import javax.swing.text.Position;
 Lines 53-59    Link Here 
53
 * @version 1.00
53
 * @version 1.00
54
 */
54
 */
55
55
56
final class MarkVector {
56
public final class MarkVector {
57
57
58
    /** Empty array of marks used initially as markArray. */
58
    /** Empty array of marks used initially as markArray. */
59
    private static final MultiMark[] EMPTY = new MultiMark[0];
59
    private static final MultiMark[] EMPTY = new MultiMark[0];
 Lines 83-89    Link Here 
83
     */
83
     */
84
    private int disposedMarkCount;
84
    private int disposedMarkCount;
85
    
85
    
86
    MarkVector() {
86
    public MarkVector() {
87
        markArray = EMPTY;
87
        markArray = EMPTY;
88
        offsetGapLength = INITIAL_OFFSET_GAP_SIZE;
88
        offsetGapLength = INITIAL_OFFSET_GAP_SIZE;
89
    }
89
    }
 Lines 93-99    Link Here 
93
     * @param offset offset of the mark.
93
     * @param offset offset of the mark.
94
     * @param bias bias of the mark.
94
     * @param bias bias of the mark.
95
     */
95
     */
96
    MultiMark createBiasMark(int offset, Position.Bias bias) {
96
    public MultiMark createBiasMark(int offset, Position.Bias bias) {
97
        return new MultiMark(null, this, offset, bias);
97
        return new MultiMark(null, this, offset, bias);
98
    }
98
    }
99
    
99
    
 Lines 103-109    Link Here 
103
     * @param offset offset of the mark.
103
     * @param offset offset of the mark.
104
     * @param bias bias of the mark.
104
     * @param bias bias of the mark.
105
     */
105
     */
106
    MultiMark createBiasMark(BasePosition pos, int offset, Position.Bias bias) {
106
    public MultiMark createBiasMark(BasePosition pos, int offset, Position.Bias bias) {
107
        return new MultiMark(pos, this, offset, bias);
107
        return new MultiMark(pos, this, offset, bias);
108
    }
108
    }
109
    
109
    
 Lines 111-117    Link Here 
111
     * inserted into the vector.
111
     * inserted into the vector.
112
     * @param offset offset of the mark.
112
     * @param offset offset of the mark.
113
     */
113
     */
114
    MultiMark createMark(int offset) {
114
    public MultiMark createMark(int offset) {
115
        return new MultiMark(null, this, offset);
115
        return new MultiMark(null, this, offset);
116
    }
116
    }
117
    
117
    
 Lines 120-140    Link Here 
120
     * @param pos position that will delegate to this mark.
120
     * @param pos position that will delegate to this mark.
121
     * @param offset offset of the mark.
121
     * @param offset offset of the mark.
122
     */
122
     */
123
    MultiMark createMark(BasePosition pos, int offset) {
123
    public MultiMark createMark(BasePosition pos, int offset) {
124
        return new MultiMark(pos, this, offset);
124
        return new MultiMark(pos, this, offset);
125
    }
125
    }
126
    
126
    
127
    /** @return total count of marks in the vector.
127
    /** @return total count of marks in the vector.
128
     */
128
     */
129
    synchronized int getMarkCount() {
129
    public synchronized int getMarkCount() {
130
        return markArray.length - gapLength;
130
        return markArray.length - gapLength;
131
    }
131
    }
132
    
132
    
133
    synchronized MultiMark getMark(int index) {
133
    public synchronized MultiMark getMark(int index) {
134
        return markArray[getRawIndex(index)];
134
        return markArray[getRawIndex(index)];
135
    }
135
    }
136
    
136
    
137
    synchronized int getMarkOffsetInternal(int index) {
137
    public synchronized int getMarkOffsetInternal(int index) {
138
        return getOffset(getMark(index).rawOffset);
138
        return getOffset(getMark(index).rawOffset);
139
    }
139
    }
140
140
 Lines 143-149    Link Here 
143
     * @param mark mark to insert. The mark must have the valid
143
     * @param mark mark to insert. The mark must have the valid
144
     *  offset and flags filled in.
144
     *  offset and flags filled in.
145
     */
145
     */
146
    synchronized MultiMark insert(MultiMark mark) {
146
    public synchronized MultiMark insert(MultiMark mark) {
147
        int flags = mark.flags;
147
        int flags = mark.flags;
148
        if ((flags & MultiMark.VALID) != 0) { // trying to re-insert valid mark
148
        if ((flags & MultiMark.VALID) != 0) { // trying to re-insert valid mark
149
            throw new IllegalStateException();
149
            throw new IllegalStateException();
 Lines 245-251    Link Here 
245
        }
245
        }
246
    }
246
    }
247
247
248
    synchronized void compact() {
248
    public synchronized void compact() {
249
        if (gapLength > 0) {
249
        if (gapLength > 0) {
250
            int newLength = markArray.length - gapLength;
250
            int newLength = markArray.length - gapLength;
251
            MultiMark[] newMarkArray = new MultiMark[newLength];
251
            MultiMark[] newMarkArray = new MultiMark[newLength];
 Lines 272-278    Link Here 
272
     * @return non-null undo record or null in case an insert was done
272
     * @return non-null undo record or null in case an insert was done
273
     *  or there are no marks to be undone.
273
     *  or there are no marks to be undone.
274
     */
274
     */
275
    synchronized Undo update(int offset, int length, Undo undo) {
275
    public synchronized Undo update(int offset, int length, Undo undo) {
276
        if (length < 0) { // removal occured - temporarily increase offset var
276
        if (length < 0) { // removal occured - temporarily increase offset var
277
            offset -= length; // move offset after end of removal (length < 0)
277
            offset -= length; // move offset after end of removal (length < 0)
278
        }
278
        }
 Lines 754-760    Link Here 
754
    
754
    
755
    /** Undo record holding the info about undo items.
755
    /** Undo record holding the info about undo items.
756
     */
756
     */
757
    static final class Undo {
757
    public static final class Undo {
758
        
758
        
759
        Undo(UndoItem firstItem, UndoItem fbItem, UndoItem bbItem,
759
        Undo(UndoItem firstItem, UndoItem fbItem, UndoItem bbItem,
760
        ZeroUndoItem zeroItem) {
760
        ZeroUndoItem zeroItem) {
(-)a/editor.lib/src/org/netbeans/editor/MultiMark.java (-2 / +2 lines)
 Lines 39-45    Link Here 
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.editor;
42
package org.netbeans.modules.editor.lib.impl;
43
43
44
import java.lang.ref.WeakReference;
44
import java.lang.ref.WeakReference;
45
import javax.swing.text.Position;
45
import javax.swing.text.Position;
 Lines 54-60    Link Here 
54
 * @version 1.00
54
 * @version 1.00
55
 */
55
 */
56
56
57
final class MultiMark extends WeakReference<BasePosition> implements Runnable {
57
public final class MultiMark extends WeakReference<BasePosition> implements Runnable {
58
58
59
    /** Whether mark has a backward (or forward) bias */
59
    /** Whether mark has a backward (or forward) bias */
60
    static final int BACKWARD_BIAS = 1;
60
    static final int BACKWARD_BIAS = 1;
(-)a/editor.lib/test/unit/src/org/netbeans/editor/DrawEngineTest.java (+2 lines)
 Lines 39-44    Link Here 
39
import javax.swing.text.Position;
39
import javax.swing.text.Position;
40
import javax.swing.text.View;
40
import javax.swing.text.View;
41
import org.netbeans.junit.NbTestCase;
41
import org.netbeans.junit.NbTestCase;
42
import org.netbeans.modules.editor.lib.drawing.DrawEngineDocView;
43
import org.netbeans.modules.editor.lib.drawing.DrawEngineLineView;
42
44
43
/**
45
/**
44
 *
46
 *
(-)a/editor/src/org/netbeans/modules/editor/NbEditorDocument.java (-6 lines)
 Lines 117-128    Link Here 
117
    }
117
    }
118
    
118
    
119
    private void init() {
119
    private void init() {
120
        addStyleToLayerMapping(NbDocument.BREAKPOINT_STYLE_NAME,
121
                               NbDocument.BREAKPOINT_STYLE_NAME + "Layer:10"); // NOI18N
122
        addStyleToLayerMapping(NbDocument.ERROR_STYLE_NAME,
123
                               NbDocument.ERROR_STYLE_NAME + "Layer:20"); // NOI18N
124
        addStyleToLayerMapping(NbDocument.CURRENT_STYLE_NAME,
125
                               NbDocument.CURRENT_STYLE_NAME + "Layer:30"); // NOI18N
126
        setNormalStyleName(NbDocument.NORMAL_STYLE_NAME);
120
        setNormalStyleName(NbDocument.NORMAL_STYLE_NAME);
127
        
121
        
128
        annoMap = new HashMap(20);
122
        annoMap = new HashMap(20);
(-)a/form/src/org/netbeans/modules/form/FormUtils.java (-6 / +4 lines)
 Lines 59-66    Link Here 
59
import javax.swing.text.Document;
59
import javax.swing.text.Document;
60
import javax.swing.tree.DefaultTreeModel;
60
import javax.swing.tree.DefaultTreeModel;
61
import org.netbeans.api.editor.DialogBinding;
61
import org.netbeans.api.editor.DialogBinding;
62
import org.netbeans.editor.EditorUI;
63
import org.netbeans.editor.ext.ExtCaret;
64
62
65
import org.openide.ErrorManager;
63
import org.openide.ErrorManager;
66
import org.openide.util.*;
64
import org.openide.util.*;
 Lines 942-951    Link Here 
942
        DialogBinding.bindComponentToDocument(document, ccPosition, 0, editor);
940
        DialogBinding.bindComponentToDocument(document, ccPosition, 0, editor);
943
941
944
        // do not highlight current row
942
        // do not highlight current row
945
        EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editor);
943
        editor.putClientProperty(
946
        if (eui != null) { // Issue 142686
944
            "HighlightsLayerExcludes", //NOI18N
947
            eui.removeLayer(ExtCaret.HIGHLIGHT_ROW_LAYER_NAME);
945
            "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.CaretRowHighlighting$" //NOI18N
948
        }
946
        );
949
947
950
        setupTextUndoRedo(editor);
948
        setupTextUndoRedo(editor);
951
    }
949
    }
(-)a/java.editor.lib/src/org/netbeans/editor/ext/java/JavaDrawLayerFactory.java (-205 lines)
 Lines 1-205    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.editor.ext.java;
43
44
import javax.swing.text.BadLocationException;
45
46
import org.netbeans.editor.*;
47
import org.netbeans.editor.ext.ExtSyntaxSupport;
48
49
/**
50
 * Various java-layers
51
 *
52
 * @author Miloslav Metelka
53
 * @version 1.00
54
 * @deprecated Please use Highlighting SPI instead, for details see
55
 *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
56
 */
57
58
public class JavaDrawLayerFactory {
59
60
    public static final String JAVA_LAYER_NAME = "java-layer"; // NOI18N
61
62
    public static final int JAVA_LAYER_VISIBILITY = 1010;
63
64
    /** Layer that colors extra java information like the methods or special
65
     * characters in the character and string literals.
66
     * 
67
     * @deprecated Please use Highlighting SPI instead, for details see
68
     *   <a href="@org-netbeans-modules-editor-lib2@/overview-summary.html">Editor Library 2</a>.
69
     */
70
    public static class JavaLayer extends DrawLayer.AbstractLayer {
71
72
        /** End of the area that is resolved right now. It saves
73
         * repetitive searches for '(' for multiple fragments
74
         * inside one identifier token.
75
         */
76
        private int resolvedEndOffset;
77
78
        private boolean resolvedValue;
79
80
        private NonWhitespaceFwdFinder nwFinder = new NonWhitespaceFwdFinder();
81
82
        public JavaLayer() {
83
            super(JAVA_LAYER_NAME);
84
        }
85
86
        public void init(DrawContext ctx) {
87
            resolvedEndOffset = 0; // nothing resolved
88
        }
89
90
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
91
            int nextOffset = ctx.getTokenOffset() + ctx.getTokenLength();
92
93
            setNextActivityChangeOffset(nextOffset);
94
            return true;
95
        }
96
97
        protected Coloring getMethodColoring(DrawContext ctx) {
98
            TokenContextPath path = ctx.getTokenContextPath().replaceStart(
99
                JavaLayerTokenContext.contextPath);
100
            return ctx.getEditorUI().getColoring(
101
                path.getFullTokenName(JavaLayerTokenContext.METHOD));
102
        }
103
104
        private boolean isMethod(DrawContext ctx) {
105
            int idEndOffset = ctx.getTokenOffset() + ctx.getTokenLength();
106
            if (idEndOffset > resolvedEndOffset) { // beyond the resolved area
107
                resolvedEndOffset = idEndOffset; // will resolve now
108
                int endOffset = ctx.getEndOffset();
109
                int bufferStartOffset = ctx.getBufferStartOffset();
110
                char[] buffer = ctx.getBuffer();
111
                ExtSyntaxSupport sup = (ExtSyntaxSupport) ctx.getEditorUI().getDocument().getSyntaxSupport().get(ExtSyntaxSupport.class);
112
                int nwOffset = Analyzer.findFirstNonWhite(buffer,
113
                        idEndOffset - bufferStartOffset,
114
                        endOffset - idEndOffset);
115
                if (nwOffset >= 0) { // found non-white
116
                    resolvedValue = (buffer[nwOffset] == '(');
117
                    if (!resolvedValue && buffer[nwOffset] == '<') {
118
                        try {
119
                            int[] block = sup.findMatchingBlock(ctx.getBufferStartOffset() + nwOffset, true);
120
                            if (block != null) {
121
                                int off = Utilities.getFirstNonWhiteFwd(ctx.getEditorUI().getDocument(), block[1]);
122
                                if (off > -1) {
123
                                    if (bufferStartOffset + buffer.length > off) {
124
                                        resolvedValue = (buffer[off - bufferStartOffset] == '(');
125
                                    } else {
126
                                        resolvedValue = (ctx.getEditorUI().getDocument().getChars(off, 1)[0] == '(');
127
                                    }
128
                                }
129
                            }
130
                        } catch (BadLocationException e) {
131
                            resolvedValue = false;
132
                        }
133
                    }
134
                } else { // must resolve after buffer end
135
                    try {
136
                        int off = ctx.getEditorUI().getDocument().find(nwFinder, endOffset, -1);
137
                        resolvedValue = off >= 0 && (nwFinder.getFoundChar() == '(');
138
                        if (!resolvedValue && nwFinder.getFoundChar() == '<') {
139
                            int[] block = sup.findMatchingBlock(off, true);
140
                            if (block != null) {
141
                                off = Utilities.getFirstNonWhiteFwd(ctx.getEditorUI().getDocument(), block[1]);
142
                                if (off > -1)
143
                                    resolvedValue = (ctx.getEditorUI().getDocument().getChars(off, 1)[0] == '(');
144
                            }
145
                        }
146
                    } catch (BadLocationException e) {
147
                        resolvedValue = false;
148
                    }
149
                }
150
            }
151
152
            return resolvedValue;
153
        }
154
155
        public void updateContext(DrawContext ctx) {
156
            if (ctx.getTokenID() == JavaTokenContext.IDENTIFIER && isMethod(ctx)) {
157
                Coloring mc = getMethodColoring(ctx);
158
                if (mc != null) {
159
                    mc.apply(ctx);
160
                }
161
            }
162
        }
163
164
    }
165
166
    /** Find first non-white character forward */
167
    static class NonWhitespaceFwdFinder extends FinderFactory.GenericFwdFinder {
168
169
        private char foundChar;
170
171
        public char getFoundChar() {
172
            return foundChar;
173
        }
174
175
        protected int scan(char ch, boolean lastChar) {
176
            if (!Character.isWhitespace(ch)) {
177
                found = true;
178
                foundChar = ch;
179
                return 0;
180
            }
181
            return 1;
182
        }
183
    }
184
185
    /** Find first non-white character backward */
186
    public static class NonWhitespaceBwdFinder extends FinderFactory.GenericBwdFinder {
187
188
        private char foundChar;
189
190
        public char getFoundChar() {
191
            return foundChar;
192
        }
193
194
        protected int scan(char ch, boolean lastChar) {
195
            if (!Character.isWhitespace(ch)) {
196
                found = true;
197
                foundChar = ch;
198
                return 0;
199
            }
200
            return -1;
201
        }
202
    }
203
204
}
205
(-)a/nbbuild/cluster.properties (-3 lines)
 Lines 304-310    Link Here 
304
        editor.errorstripe.api,\
304
        editor.errorstripe.api,\
305
        editor.fold,\
305
        editor.fold,\
306
        editor.guards,\
306
        editor.guards,\
307
        editor.highlights,\
308
        editor.indent,\
307
        editor.indent,\
309
        editor.kit,\
308
        editor.kit,\
310
        editor.lib,\
309
        editor.lib,\
 Lines 350-356    Link Here 
350
        languages.manifest,\
349
        languages.manifest,\
351
        languages.yaml,\
350
        languages.yaml,\
352
        lexer,\
351
        lexer,\
353
        lexer.editorbridge,\
354
        lexer.nbbridge,\
352
        lexer.nbbridge,\
355
        lib.cvsclient,\
353
        lib.cvsclient,\
356
        libs.bugtracking,\
354
        libs.bugtracking,\
 Lines 1242-1248    Link Here 
1242
        contrib/glassfish.v3enable,\
1240
        contrib/glassfish.v3enable,\
1243
        contrib/graphicclassview,\
1241
        contrib/graphicclassview,\
1244
        contrib/group,\
1242
        contrib/group,\
1245
        contrib/gsf.tools,\
1246
        contrib/hexeditor,\
1243
        contrib/hexeditor,\
1247
        contrib/htmlprojects,\
1244
        contrib/htmlprojects,\
1248
        contrib/hudsonfindbugs,\
1245
        contrib/hudsonfindbugs,\
(-)a/python.debugger/src/org/netbeans/modules/python/debugger/gui/WatchPanel.java (-3 / +7 lines)
 Lines 72-81    Link Here 
72
import java.awt.Insets;
72
import java.awt.Insets;
73
import java.awt.event.ActionListener;
73
import java.awt.event.ActionListener;
74
import java.io.IOException;
74
import java.io.IOException;
75
import javax.naming.event.EventDirContext;
76
import javax.swing.text.StyledDocument;
75
import javax.swing.text.StyledDocument;
77
import org.netbeans.editor.EditorUI;
76
import org.netbeans.editor.EditorUI;
78
import org.netbeans.editor.ext.ExtCaret;
79
import org.openide.ErrorManager;
77
import org.openide.ErrorManager;
80
import org.openide.cookies.EditorCookie;
78
import org.openide.cookies.EditorCookie;
81
import org.openide.text.NbDocument;
79
import org.openide.text.NbDocument;
 Lines 180-186    Link Here 
180
        final Runnable runnable = new Runnable() {
178
        final Runnable runnable = new Runnable() {
181
            public void run() {
179
            public void run() {
182
                EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane);
180
                EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane);
183
                eui.removeLayer(ExtCaret.HIGHLIGHT_ROW_LAYER_NAME);
181
                if (eui == null) {
182
                    return ;
183
                }
184
                editorPane.putClientProperty(
185
                    "HighlightsLayerExcludes", //NOI18N
186
                    "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.CaretRowHighlighting$" //NOI18N
187
                );
184
                // Do not draw text limit line
188
                // Do not draw text limit line
185
                try {
189
                try {
186
                    java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N
190
                    java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/WatchPanel.java (-3 / +6 lines)
 Lines 57-63    Link Here 
57
import javax.swing.text.StyledDocument;
57
import javax.swing.text.StyledDocument;
58
import org.netbeans.api.editor.DialogBinding;
58
import org.netbeans.api.editor.DialogBinding;
59
import org.netbeans.editor.EditorUI;
59
import org.netbeans.editor.EditorUI;
60
import org.netbeans.editor.ext.ExtCaret;
61
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
60
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
62
import org.openide.ErrorManager;
61
import org.openide.ErrorManager;
63
import org.openide.cookies.EditorCookie;
62
import org.openide.cookies.EditorCookie;
 Lines 133-141    Link Here 
133
        Runnable runnable = new Runnable() {
132
        Runnable runnable = new Runnable() {
134
            public void run() {
133
            public void run() {
135
                EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane);
134
                EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(editorPane);
136
                if (eui != null) {
135
                if (eui == null) {
137
                    eui.removeLayer(ExtCaret.HIGHLIGHT_ROW_LAYER_NAME);
136
                    return;
138
                }
137
                }
138
                editorPane.putClientProperty(
139
                    "HighlightsLayerExcludes", //NOI18N
140
                    "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.CaretRowHighlighting$" //NOI18N
141
                );
139
                // Do not draw text limit line
142
                // Do not draw text limit line
140
                try {
143
                try {
141
                    java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N
144
                    java.lang.reflect.Field textLimitLineField = EditorUI.class.getDeclaredField("textLimitLineVisible"); // NOI18N
(-)a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/deprecated/ELDrawLayerFactory.java (-192 lines)
 Lines 1-192    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.web.core.syntax.deprecated;
43
44
import org.netbeans.modules.web.core.syntax.deprecated.ELLayerTokenContext;
45
import org.netbeans.modules.web.core.syntax.*;
46
import javax.swing.text.BadLocationException;
47
import javax.swing.event.DocumentListener;
48
import javax.swing.event.DocumentEvent;
49
import org.netbeans.editor.BaseDocument;
50
import org.netbeans.editor.BaseDocumentEvent;
51
import org.netbeans.editor.Coloring;
52
import org.netbeans.editor.DrawContext;
53
import org.netbeans.editor.DrawLayer;
54
import org.netbeans.editor.MarkFactory;
55
import org.netbeans.editor.FinderFactory;
56
import org.netbeans.editor.Analyzer;
57
58
/**
59
* Various EL-layers
60
*
61
* @author Petr Pisl
62
* @deprecated Will be replaced by Semantic Coloring
63
*/
64
65
public class ELDrawLayerFactory {
66
67
    public static final String EL_LAYER_NAME = "jsp-el-layer"; // NOI18N
68
69
    public static final int EL_LAYER_VISIBILITY = 1010;
70
71
    /** Layer that colors extra EL information like the methods or special
72
     * characters in the character and string literals.
73
     */
74
    public static class ELLayer extends DrawLayer.AbstractLayer {
75
76
        /** End of the area that is resolved right now. It saves
77
         * repetitive searches for '(' for multiple fragments
78
         * inside one identifier token.
79
         */
80
        private int resolvedEndOffset;
81
82
        private boolean resolvedValue;
83
84
        private NonWhitespaceFwdFinder nwFinder = new NonWhitespaceFwdFinder();
85
86
        public ELLayer() {
87
            super(EL_LAYER_NAME);
88
        }
89
90
        public void init(DrawContext ctx) {
91
            resolvedEndOffset = 0; // nothing resolved
92
        }
93
94
        public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
95
            int nextOffset = ctx.getTokenOffset() + ctx.getTokenLength();
96
97
            setNextActivityChangeOffset(nextOffset);
98
            return true;
99
        }
100
101
        protected Coloring getMethodColoring(DrawContext ctx) {
102
	    
103
	    /*TokenContextPath path = ctx.getTokenContextPath().replaceStart(
104
		    ELLayerTokenContext.contextPath);
105
		return ctx.getEditorUI().getColoring(
106
		    path.getFullTokenName(ELLayerTokenContext.METHOD));
107
	    */
108
	   
109
	   return ctx.getEditorUI().getColoring(ELLayerTokenContext.contextPath.getFullTokenName(ELLayerTokenContext.METHOD));
110
        }
111
112
        private boolean isMethod(DrawContext ctx) {
113
	    
114
            int idEndOffset = ctx.getTokenOffset() + ctx.getTokenLength();
115
            if (idEndOffset > resolvedEndOffset) { // beyond the resolved area
116
                resolvedEndOffset = idEndOffset; // will resolve now
117
                int endOffset = ctx.getEndOffset();		
118
                int bufferStartOffset = ctx.getBufferStartOffset();
119
                char[] buffer = ctx.getBuffer();
120
                int nwOffset = Analyzer.findFirstNonWhite(buffer,
121
                        idEndOffset - bufferStartOffset,
122
                        endOffset - idEndOffset);
123
                if (nwOffset >= 0) { // found non-white
124
                    resolvedValue = (buffer[nwOffset] == '(');
125
                } else { // must resolve after buffer end
126
                    try {
127
                        resolvedValue = (ctx.getEditorUI().getDocument().find(
128
                            nwFinder, endOffset, -1) >= 0)
129
                                && (nwFinder.getFoundChar() == '(');
130
                    } catch (BadLocationException e) {
131
                        resolvedValue = false;
132
                    }
133
                }
134
            }
135
            return resolvedValue;
136
        }
137
	/** Update draw context by setting colors, fonts and possibly other draw
138
	* properties.
139
	* The method can use information from the context to find where the painting
140
	* process is currently located. It is called only if the layer is active.
141
	*/
142
        public void updateContext(DrawContext ctx) {
143
            if (ctx.getTokenID() == ELTokenContext.IDENTIFIER && isMethod(ctx)) {
144
                Coloring mc = getMethodColoring(ctx);
145
                if (mc != null) {
146
                    mc.apply(ctx);
147
                }
148
            }
149
        }
150
151
    }
152
153
    /** Find first non-white character forward */
154
    static class NonWhitespaceFwdFinder extends FinderFactory.GenericFwdFinder {
155
156
        private char foundChar;
157
158
        public char getFoundChar() {
159
            return foundChar;
160
        }
161
162
        protected int scan(char ch, boolean lastChar) {
163
            if (!Character.isWhitespace(ch)) {
164
                found = true;
165
                foundChar = ch;
166
                return 0;
167
            }
168
            return 1;
169
        }
170
    }
171
172
    /** Find first non-white character backward */
173
    public static class NonWhitespaceBwdFinder extends FinderFactory.GenericBwdFinder {
174
175
        private char foundChar;
176
177
        public char getFoundChar() {
178
            return foundChar;
179
        }
180
181
        protected int scan(char ch, boolean lastChar) {
182
            if (!Character.isWhitespace(ch)) {
183
                found = true;
184
                foundChar = ch;
185
                return 0;
186
            }
187
            return -1;
188
        }
189
    }
190
191
}
192
(-)a/xml.text/src/org/netbeans/modules/xml/text/syntax/XMLKit.java (-9 lines)
 Lines 348-361    Link Here 
348
        public XMLEditorDocument(String mimeType) {
348
        public XMLEditorDocument(String mimeType) {
349
            super(mimeType);
349
            super(mimeType);
350
        }
350
        }
351
        
352
        public @Override boolean addLayer(DrawLayer layer, int visibility) {
353
            //filter out the syntax layer adding
354
            if(!(layer instanceof DrawLayerFactory.SyntaxLayer)) {
355
                return super.addLayer(layer, visibility);
356
            } else {
357
                return false;
358
            }
359
        }
360
    }
351
    }
361
}
352
}

Return to bug 97517
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo