Lines 7-13
Link Here
|
7 |
* http://www.sun.com/ |
7 |
* http://www.sun.com/ |
8 |
* |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
12 |
*/ |
12 |
*/ |
13 |
|
13 |
|
Lines 36-63
Link Here
|
36 |
/** reference to one position on the line */ |
36 |
/** reference to one position on the line */ |
37 |
protected PositionRef pos; |
37 |
protected PositionRef pos; |
38 |
|
38 |
|
39 |
/** is breakpoint there - presistent state |
|
|
40 |
@deprecated since 1.20 */ |
41 |
private boolean breakpoint; |
42 |
|
43 |
/** error line - transient state |
44 |
@deprecated since 1.20 */ |
45 |
private transient boolean error; |
46 |
|
47 |
/** current line - transient state |
48 |
@deprecated since 1.20 */ |
49 |
private transient boolean current; |
50 |
|
51 |
/** listener for changes of state of the document */ |
39 |
/** listener for changes of state of the document */ |
52 |
private transient LR listener; |
40 |
private transient LR listener; |
53 |
|
41 |
|
54 |
/** weak document listener assigned to the document or null */ |
|
|
55 |
private transient DocumentListener docL; |
56 |
|
57 |
/** weak map that assignes to editor supports whether they have current or error line |
58 |
* selected. (EditorSupport, DocumentLine[2]), where Line[0] is current and Line[1] is error */ |
59 |
private static WeakHashMap assigned = new WeakHashMap (5); |
60 |
|
61 |
/** List of Line.Part which exist for this line*/ |
42 |
/** List of Line.Part which exist for this line*/ |
62 |
private List lineParts = new ArrayList(3); |
43 |
private List lineParts = new ArrayList(3); |
63 |
|
44 |
|
Lines 103-208
Link Here
|
103 |
*/ |
84 |
*/ |
104 |
public abstract void show(int kind, int column); |
85 |
public abstract void show(int kind, int column); |
105 |
|
86 |
|
106 |
/* Sets the breakpoint. */ |
87 |
// Long-deprecated stuff. |
107 |
public void setBreakpoint(boolean b) { |
88 |
public void setBreakpoint(boolean b) {} |
108 |
if (breakpoint != b) { |
89 |
public boolean isBreakpoint() { |
109 |
breakpoint = b; |
90 |
return false; |
110 |
refreshState (); |
|
|
111 |
} |
112 |
} |
113 |
|
114 |
/* Tests if the breakpoint is set. */ |
115 |
public boolean isBreakpoint () { |
116 |
return breakpoint; |
117 |
} |
118 |
|
119 |
/* Marks the error. */ |
120 |
public void markError () { |
121 |
DocumentLine previous = registerLine (1, this); |
122 |
if (previous != null) { |
123 |
previous.error = false; |
124 |
previous.refreshState (); |
125 |
} |
126 |
|
127 |
error = true; |
128 |
|
129 |
refreshState (); |
130 |
} |
131 |
|
132 |
/* Unmarks error at this line. */ |
133 |
public void unmarkError () { |
134 |
error = false; |
135 |
registerLine (1, null); |
136 |
|
137 |
refreshState (); |
138 |
} |
139 |
|
140 |
/* Marks this line as current. */ |
141 |
public void markCurrentLine () { |
142 |
DocumentLine previous = registerLine (0, this); |
143 |
if (previous != null) { |
144 |
previous.current = false; |
145 |
previous.refreshState (); |
146 |
} |
147 |
|
148 |
current = true; |
149 |
refreshState (); |
150 |
} |
151 |
|
152 |
/* Unmarks this line as current. */ |
153 |
public void unmarkCurrentLine () { |
154 |
current = false; |
155 |
registerLine (0, null); |
156 |
|
157 |
refreshState (); |
158 |
} |
159 |
|
160 |
/** Refreshes the current line. |
161 |
* |
162 |
* @deprecated since 1.20. */ |
163 |
synchronized void refreshState () { |
164 |
StyledDocument doc = pos.getCloneableEditorSupport ().getDocument (); |
165 |
|
166 |
if (doc != null) { |
167 |
// the document is in memory, mark the state |
168 |
|
169 |
if (docL != null) { |
170 |
doc.removeDocumentListener (docL); |
171 |
} |
172 |
|
173 |
// error line |
174 |
if (error) { |
175 |
NbDocument.markError (doc, pos.getOffset ()); |
176 |
|
177 |
doc.addDocumentListener (docL = org.openide.util.WeakListeners.document (listener, doc)); |
178 |
|
179 |
return; |
180 |
} |
181 |
|
182 |
// current line |
183 |
if (current) { |
184 |
NbDocument.markCurrent (doc, pos.getOffset ()); |
185 |
return; |
186 |
} |
187 |
|
188 |
// breakpoint line |
189 |
if (breakpoint) { |
190 |
NbDocument.markBreakpoint (doc, pos.getOffset ()); |
191 |
return; |
192 |
} |
193 |
|
194 |
NbDocument.markNormal (doc, pos.getOffset ()); |
195 |
return; |
196 |
} |
197 |
} |
91 |
} |
|
|
92 |
public void markError() {} |
93 |
public void unmarkError() {} |
94 |
public void markCurrentLine() {} |
95 |
public void unmarkCurrentLine() {} |
198 |
|
96 |
|
199 |
public int hashCode () { |
97 |
public int hashCode () { |
200 |
return pos.getCloneableEditorSupport ().hashCode (); |
98 |
return pos.getCloneableEditorSupport ().hashCode () ^ getLineNumber(); |
201 |
} |
99 |
} |
202 |
|
100 |
|
203 |
public boolean equals (Object o) { |
101 |
public boolean equals (Object o) { |
204 |
if (o instanceof DocumentLine) { |
102 |
if (o instanceof DocumentLine) { |
205 |
DocumentLine dl = (DocumentLine)o; |
103 |
DocumentLine dl = (DocumentLine)o; |
|
|
104 |
if (dl.pos == pos) { |
105 |
// No need to check anything else. |
106 |
return true; |
107 |
} |
206 |
if (dl.pos.getCloneableEditorSupport () == pos.getCloneableEditorSupport ()) { |
108 |
if (dl.pos.getCloneableEditorSupport () == pos.getCloneableEditorSupport ()) { |
207 |
return dl.getLineNumber () == getLineNumber (); |
109 |
return dl.getLineNumber () == getLineNumber (); |
208 |
} |
110 |
} |
Lines 212-251
Link Here
|
212 |
|
114 |
|
213 |
|
115 |
|
214 |
// |
116 |
// |
215 |
// Work with global hash table |
|
|
216 |
// |
217 |
|
218 |
/** Register this line as the one stored |
219 |
* under indx-index (0 = current, 1 = error). |
220 |
* |
221 |
* @param indx index to register |
222 |
* @param line value to add (this or null) |
223 |
* @return the previous value |
224 |
* |
225 |
* @deprecated since 1.20 */ |
226 |
private DocumentLine registerLine (int indx, DocumentLine line) { |
227 |
DocumentLine prev; |
228 |
|
229 |
CloneableEditorSupport es = pos.getCloneableEditorSupport (); |
230 |
|
231 |
DocumentLine[] arr = (DocumentLine[])assigned.get (es); |
232 |
|
233 |
if (arr != null) { |
234 |
// remember the previous |
235 |
prev = arr[indx]; |
236 |
} else { |
237 |
// create new array |
238 |
arr = new DocumentLine[2]; |
239 |
assigned.put (es, arr); |
240 |
prev = null; |
241 |
} |
242 |
arr[indx] = line; |
243 |
return prev; |
244 |
|
245 |
} |
246 |
|
247 |
|
248 |
// |
249 |
// Serialization |
117 |
// Serialization |
250 |
// |
118 |
// |
251 |
|
119 |
|
Lines 254-260
Link Here
|
254 |
private void writeObject (ObjectOutputStream oos) throws IOException { |
122 |
private void writeObject (ObjectOutputStream oos) throws IOException { |
255 |
// do not do default read/write object |
123 |
// do not do default read/write object |
256 |
oos.writeObject (pos); |
124 |
oos.writeObject (pos); |
257 |
oos.writeBoolean (breakpoint); |
125 |
oos.writeBoolean (false); // was breakpoint |
258 |
} |
126 |
} |
259 |
|
127 |
|
260 |
/** Read important fields. |
128 |
/** Read important fields. |
Lines 262-268
Link Here
|
262 |
private void readObject (ObjectInputStream ois) |
130 |
private void readObject (ObjectInputStream ois) |
263 |
throws IOException, ClassNotFoundException { |
131 |
throws IOException, ClassNotFoundException { |
264 |
pos = (PositionRef)ois.readObject (); |
132 |
pos = (PositionRef)ois.readObject (); |
265 |
setBreakpoint (ois.readBoolean ()); |
|
|
266 |
lineParts = new ArrayList(3); |
133 |
lineParts = new ArrayList(3); |
267 |
} |
134 |
} |
268 |
|
135 |
|
Lines 717-776
Link Here
|
717 |
|
584 |
|
718 |
|
585 |
|
719 |
/** Definition of actions performed in Listener */ |
586 |
/** Definition of actions performed in Listener */ |
720 |
private final class LR implements Runnable, ChangeListener, DocumentListener { |
587 |
private final class LR implements Runnable, ChangeListener { |
721 |
private static final int REFRESH = 0; |
|
|
722 |
private static final int UNMARK = 1; |
723 |
private static final int ATTACH_DETACH = 2; |
724 |
|
588 |
|
725 |
private int actionId; |
|
|
726 |
private EnhancedChangeEvent ev; |
589 |
private EnhancedChangeEvent ev; |
727 |
|
590 |
|
728 |
public LR() {} |
591 |
public LR() {} |
729 |
|
592 |
|
730 |
public LR (int actionId) { |
|
|
731 |
this.actionId = actionId; |
732 |
} |
733 |
|
734 |
public LR (EnhancedChangeEvent ev) { |
593 |
public LR (EnhancedChangeEvent ev) { |
735 |
this.actionId = ATTACH_DETACH; |
|
|
736 |
this.ev = ev; |
594 |
this.ev = ev; |
737 |
} |
595 |
} |
738 |
|
596 |
|
739 |
public void run () { |
597 |
public void run () { |
740 |
switch (actionId) { |
598 |
attachDetachAnnotations(ev.getDocument(), ev.isClosingDocument()); |
741 |
case REFRESH: refreshState (); break; |
599 |
ev = null; |
742 |
case UNMARK: unmarkError (); break; |
|
|
743 |
case ATTACH_DETACH: attachDetachAnnotations(ev.getDocument(), ev.isClosingDocument()); ev = null; break; |
744 |
} |
745 |
} |
600 |
} |
746 |
|
601 |
|
747 |
private void invoke(int op) { |
|
|
748 |
// part of #33165 - done synchronously not invoking into EQ |
749 |
//SwingUtilities.invokeLater(new LR(op)); |
750 |
new LR(op).run(); |
751 |
} |
752 |
|
753 |
private void invoke(EnhancedChangeEvent ev) { |
754 |
// part of #33165 - done synchronously not invoking into EQ |
755 |
//SwingUtilities.invokeLater(new LR(ev)); |
756 |
new LR(ev).run(); |
757 |
} |
758 |
|
759 |
public void stateChanged (ChangeEvent ev) { |
602 |
public void stateChanged (ChangeEvent ev) { |
760 |
invoke(REFRESH); |
603 |
// part of #33165 - done synchronously not invoking into EQ |
761 |
invoke((EnhancedChangeEvent)ev); |
604 |
//SwingUtilities.invokeLater(new LR((EnhancedChangeEvent)ev)); |
762 |
} |
605 |
new LR((EnhancedChangeEvent)ev).run(); |
763 |
|
|
|
764 |
public void removeUpdate(final javax.swing.event.DocumentEvent p0) { |
765 |
invoke(UNMARK); |
766 |
} |
767 |
|
768 |
public void insertUpdate(final javax.swing.event.DocumentEvent p0) { |
769 |
invoke(UNMARK); |
770 |
} |
606 |
} |
771 |
|
607 |
|
772 |
public void changedUpdate(final javax.swing.event.DocumentEvent p0) { |
|
|
773 |
} |
774 |
} |
608 |
} |
775 |
|
609 |
|
776 |
/** Abstract implementation of {@link Line.Set}. |
610 |
/** Abstract implementation of {@link Line.Set}. |