1 19 20 package org.netbeans.modules.editor.lib2.highlighting; 21 22 import java.util.ArrayList ; 23 import org.netbeans.api.lexer.TokenHierarchy; 24 import org.netbeans.spi.editor.highlighting.HighlightsLayer; 25 import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory; 26 import org.netbeans.spi.editor.highlighting.ZOrder; 27 28 33 public class Factory implements HighlightsLayerFactory { 34 35 36 public static final String BLOCK_SEARCH_LAYER = "org.netbeans.modules.editor.lib2.highlighting.BlockHighlighting/BLOCK_SEARCH"; 38 39 public static final String INC_SEARCH_LAYER = "org.netbeans.modules.editor.lib2.highlighting.BlockHighlighting/INC_SEARCH"; 41 42 public Factory() { 43 } 44 45 public HighlightsLayer[] createLayers(HighlightsLayerFactory.Context context) { 46 ArrayList <HighlightsLayer> layers = new ArrayList <HighlightsLayer>(); 47 48 layers.add(HighlightsLayer.create( 49 CaretBasedBlockHighlighting.CaretRowHighlighting.LAYER_TYPE_ID, 50 ZOrder.CARET_RACK, 51 true, 52 new CaretBasedBlockHighlighting.CaretRowHighlighting(context.getComponent())) 53 ); 54 55 layers.add(HighlightsLayer.create( 56 CaretBasedBlockHighlighting.TextSelectionHighlighting.LAYER_TYPE_ID, 57 ZOrder.SHOW_OFF_RACK.aboveLayers(CaretBasedBlockHighlighting.CaretRowHighlighting.LAYER_TYPE_ID), 58 true, 59 new CaretBasedBlockHighlighting.TextSelectionHighlighting(context.getComponent())) 60 ); 61 62 layers.add(HighlightsLayer.create( 63 BLOCK_SEARCH_LAYER, 64 ZOrder.SHOW_OFF_RACK.aboveLayers(CaretBasedBlockHighlighting.CaretRowHighlighting.LAYER_TYPE_ID), 65 true, 66 new BlockHighlighting(BLOCK_SEARCH_LAYER, context.getComponent())) 67 ); 68 69 layers.add(HighlightsLayer.create( 70 TextSearchHighlighting.LAYER_TYPE_ID, 71 ZOrder.SHOW_OFF_RACK.aboveLayers(BLOCK_SEARCH_LAYER), 72 true, 73 new TextSearchHighlighting(context.getComponent())) 74 ); 75 76 layers.add(HighlightsLayer.create( 77 INC_SEARCH_LAYER, 78 ZOrder.SHOW_OFF_RACK.aboveLayers(TextSearchHighlighting.LAYER_TYPE_ID).belowLayers(CaretBasedBlockHighlighting.TextSelectionHighlighting.LAYER_TYPE_ID), 79 true, 80 new BlockHighlighting(INC_SEARCH_LAYER, context.getComponent())) 81 ); 82 83 if (TokenHierarchy.get(context.getDocument()) != null) { 85 layers.add(HighlightsLayer.create( 86 SyntaxHighlighting.LAYER_TYPE_ID, 87 ZOrder.SYNTAX_RACK, 88 true, 89 new SyntaxHighlighting(context.getDocument())) 90 ); 91 } 92 93 return layers.toArray(new HighlightsLayer [layers.size()]); 94 } 95 96 } 97 | Popular Tags |