KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > ate > folding > ATEFoldingManager


1 package org.antlr.works.ate.folding;
2
3 import org.antlr.works.ate.ATEPanel;
4
5 import java.util.ArrayList JavaDoc;
6 import java.util.HashSet JavaDoc;
7 import java.util.List JavaDoc;
8 import java.util.Set JavaDoc;
9 /*
10
11 [The "BSD licence"]
12 Copyright (c) 2005 Jean Bovet
13 All rights reserved.
14
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions
17 are met:
18
19 1. Redistributions of source code must retain the above copyright
20 notice, this list of conditions and the following disclaimer.
21 2. Redistributions in binary form must reproduce the above copyright
22 notice, this list of conditions and the following disclaimer in the
23 documentation and/or other materials provided with the distribution.
24 3. The name of the author may not be used to endorse or promote products
25 derived from this software without specific prior written permission.
26
27 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
38 */

39
40 public abstract class ATEFoldingManager {
41
42     protected ATEPanel textEditor;
43     protected Set JavaDoc<Integer JavaDoc> usedEntityLines = new HashSet JavaDoc<Integer JavaDoc>();
44     protected List JavaDoc<ATEFoldingEntity> entities = new ArrayList JavaDoc<ATEFoldingEntity>();
45
46     public ATEFoldingManager(ATEPanel textEditor) {
47         this.textEditor = textEditor;
48     }
49
50     public void textPaneWillFold() {
51         
52     }
53
54     public void textPaneDidFold() {
55         textEditor.refresh();
56     }
57
58     public abstract ATEFoldingEntityProxy createEntityProxy(ATEFoldingEntity entity);
59     public abstract ATEFoldingEntity getEntityForKey(Object JavaDoc key, int tag);
60
61     public void addEntity(ATEFoldingEntity entity) {
62         Integer JavaDoc start = entity.foldingEntityGetStartLine();
63         Integer JavaDoc end = entity.foldingEntityGetEndLine();
64         if(usedEntityLines.contains(start) || usedEntityLines.contains(end))
65             return;
66
67         usedEntityLines.add(start);
68         usedEntityLines.add(end);
69
70         entities.add(entity);
71     }
72
73     public List JavaDoc<ATEFoldingEntity> getFoldingEntities() {
74         usedEntityLines.clear();
75         entities.clear();
76         provideFoldingEntities();
77         return entities;
78     }
79
80     public abstract void provideFoldingEntities();
81     
82     public void toggleFolding(ATEFoldingEntity entity) {
83         //textEditor.getTextPane().toggleFolding(createEntityProxy(entity));
84
}
85
86 }
87
Popular Tags