This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 179368
Collapse All | Expand All

(-)a/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java (-3 lines)
Lines 277-286 Link Here
277
277
278
    public CompletionTask createDocumentationTask() {
278
    public CompletionTask createDocumentationTask() {
279
        CompletionDocumentationProvider p = Lookup.getDefault().lookup(CompletionDocumentationProvider.class);
279
        CompletionDocumentationProvider p = Lookup.getDefault().lookup(CompletionDocumentationProvider.class);
280
281
        return p != null ? p.createDocumentationTask(this) : null;
280
        return p != null ? p.createDocumentationTask(this) : null;
282
//        return new AsyncCompletionTask(new JavaCompletionProvider.DocQuery(this),
283
//            org.netbeans.editor.Registry.getMostActiveComponent());
284
    }
281
    }
285
282
286
    public CompletionTask createToolTipTask() {
283
    public CompletionTask createToolTipTask() {
(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextImpl.java (-2 lines)
Lines 938-944 Link Here
938
        JavaSource js = JavaSource.forFileObject(fo);
938
        JavaSource js = JavaSource.forFileObject(fo);
939
        if (js == null) return null;
939
        if (js == null) return null;
940
        final int currentOffset = (ep == null) ? 0 : ep.getCaretPosition();
940
        final int currentOffset = (ep == null) ? 0 : ep.getCaretPosition();
941
        //final int currentOffset = org.netbeans.editor.Registry.getMostActiveComponent().getCaretPosition();
942
        final String[] currentMethodPtr = new String[] { null, null, null };
941
        final String[] currentMethodPtr = new String[] { null, null, null };
943
        final Future<Void> scanFinished;
942
        final Future<Void> scanFinished;
944
        try {
943
        try {
Lines 1806-1812 Link Here
1806
            currentOffset = 0;
1805
            currentOffset = 0;
1807
        }
1806
        }
1808
1807
1809
        //final int currentOffset = org.netbeans.editor.Registry.getMostActiveComponent().getCaretPosition();
1810
        final String[] currentElementPtr = new String[] { null };
1808
        final String[] currentElementPtr = new String[] { null };
1811
        final Future<Void> scanFinished;
1809
        final Future<Void> scanFinished;
1812
        try {
1810
        try {
(-)a/editor.lib/apichanges.xml (+17 lines)
Lines 104-109 Link Here
104
    <!-- ACTUAL CHANGES BEGIN HERE: -->
104
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
105
106
    <changes>
106
    <changes>
107
        <change id="Registry-cleanup">
108
            <summary>Cleaning up o.n.editor.Registry</summary>
109
            <version major="2" minor="2"/>
110
            <date day="11" month="1" year="2010"/>
111
            <author login="vstejskal"/>
112
            <compatibility binary="compatible" source="incompatible" semantic="compatible" addition="no" deprecation="no" deletion="yes" modification="no" />
113
            <description>
114
                <p>
115
                    <code>o.n.editor.Registry</code> was internally bridged to <code>o.n.api.editor.EditorRegistry</code>
116
                    and some of its methods were removed from API. <code>@PatchedPublic</code> was used to preserve binary compatibility.
117
                    The whole class has been deprecated for a long time
118
                    and its usage is discouraged in favor of <code>EditorRegistry</code>.
119
                </p>
120
            </description>
121
            <issue number="179368"/>
122
        </change>
123
107
        <change id="removing-DrawLayer">
124
        <change id="removing-DrawLayer">
108
            <summary>Removing DrawLayer and related API</summary>
125
            <summary>Removing DrawLayer and related API</summary>
109
            <version major="2" minor="1"/>
126
            <version major="2" minor="1"/>
(-)a/editor.lib/nbproject/project.properties (-1 / +1 lines)
Lines 39-45 Link Here
39
39
40
javac.compilerargs=-Xlint:unchecked
40
javac.compilerargs=-Xlint:unchecked
41
javac.source=1.5
41
javac.source=1.5
42
spec.version.base=2.1.0
42
spec.version.base=2.2
43
is.autoload=true
43
is.autoload=true
44
44
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
(-)a/editor.lib/src/org/netbeans/editor/BaseDocument.java (-5 lines)
Lines 528-538 Link Here
528
            ((BaseKit) kit).initDocument(this);
528
            ((BaseKit) kit).initDocument(this);
529
        }
529
        }
530
530
531
        // Possibly add the document to registry
532
        if (addToRegistry) {
533
            Registry.addDocument(this); // add if created thru the kit
534
        }
535
536
        // Start listen on find-support
531
        // Start listen on find-support
537
        findSupportListener = new PropertyChangeListener() {
532
        findSupportListener = new PropertyChangeListener() {
538
                                  public void propertyChange(PropertyChangeEvent evt) {
533
                                  public void propertyChange(PropertyChangeEvent evt) {
(-)a/editor.lib/src/org/netbeans/editor/BaseTextUI.java (-4 lines)
Lines 251-258 Link Here
251
251
252
        SwingUtilities.replaceUIInputMap(c, JComponent.WHEN_FOCUSED, null);
252
        SwingUtilities.replaceUIInputMap(c, JComponent.WHEN_FOCUSED, null);
253
        
253
        
254
        Registry.addComponent(component);
255
        Registry.activate(component);
256
        EditorApiPackageAccessor.get().register(component);
254
        EditorApiPackageAccessor.get().register(component);
257
        component.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
255
        component.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
258
    }
256
    }
Lines 281-287 Link Here
281
            comp.setCaret(null);
279
            comp.setCaret(null);
282
280
283
            getEditorUI().uninstallUI(comp);
281
            getEditorUI().uninstallUI(comp);
284
            Registry.removeComponent(comp);
285
        }
282
        }
286
    }
283
    }
287
    
284
    
Lines 412-418 Link Here
412
                                  
409
                                  
413
            if (newDoc != null) {
410
            if (newDoc != null) {
414
                newDoc.addDocumentListener(this);
411
                newDoc.addDocumentListener(this);
415
                Registry.activate(newDoc); // Activate the new document
416
            }
412
            }
417
        } else if ("ancestor".equals(propName)) { // NOI18N
413
        } else if ("ancestor".equals(propName)) { // NOI18N
418
            JTextComponent comp = (JTextComponent)evt.getSource();
414
            JTextComponent comp = (JTextComponent)evt.getSource();
(-)a/editor.lib/src/org/netbeans/editor/EditorUI.java (-1 lines)
Lines 279-285 Link Here
279
    public EditorUI() {
279
    public EditorUI() {
280
        focusL = new FocusAdapter() {
280
        focusL = new FocusAdapter() {
281
                     public @Override void focusGained(FocusEvent evt) {
281
                     public @Override void focusGained(FocusEvent evt) {
282
                         Registry.activate(getComponent());
283
                         /* Fix of #25475 - copyAction's enabled flag
282
                         /* Fix of #25475 - copyAction's enabled flag
284
                          * must be updated on focus change
283
                          * must be updated on focus change
285
                          */
284
                          */
(-)a/editor.lib/src/org/netbeans/editor/JumpList.java (-1 lines)
Lines 266-272 Link Here
266
            if (Utilities.getLastActiveComponent() != c) {
266
            if (Utilities.getLastActiveComponent() != c) {
267
267
268
                Utilities.requestFocus(c); // possibly request for the component
268
                Utilities.requestFocus(c); // possibly request for the component
269
                Registry.activate(c);
270
            }
269
            }
271
270
272
            int offset = wpt.getOffset();
271
            int offset = wpt.getOffset();
(-)a/editor.lib/src/org/netbeans/editor/Registry.java (-366 / +124 lines)
Lines 41-52 Link Here
41
41
42
package org.netbeans.editor;
42
package org.netbeans.editor;
43
43
44
import java.lang.ref.WeakReference;
44
import java.beans.PropertyChangeEvent;
45
import java.util.ArrayList;
45
import java.beans.PropertyChangeListener;
46
import java.lang.reflect.Method;
46
import java.util.Iterator;
47
import java.util.Iterator;
48
import java.util.List;
47
import javax.swing.text.JTextComponent;
49
import javax.swing.text.JTextComponent;
48
import javax.swing.event.ChangeListener;
50
import javax.swing.event.ChangeListener;
49
import javax.swing.event.ChangeEvent;
51
import javax.swing.event.ChangeEvent;
52
import javax.swing.text.Document;
53
import org.netbeans.api.editor.EditorRegistry;
54
import org.openide.modules.PatchedPublic;
50
55
51
/**
56
/**
52
 * All the documents and components register here so that
57
 * All the documents and components register here so that
Lines 61-92 Link Here
61
 */
66
 */
62
public class Registry {
67
public class Registry {
63
68
64
    private static final WeakReference[] EMPTY = new WeakReference[0];
65
66
    /** Array of weak references to documents */
67
    private static WeakReference[] docRefs = EMPTY;
68
    
69
    /** Number of the document references */
70
    private static int docRefsCount;
71
72
    /** Array of activated document numbers */
73
    private static final ArrayList docAct = new ArrayList();
74
75
    /** Array list of weak references to components */
76
    private static WeakReference[] compRefs = EMPTY;
77
78
    /** Number of the document references */
79
    private static int compRefsCount;
80
81
    /** Array of activated component numbers */
82
    private static final ArrayList<Integer> compAct = new ArrayList<Integer>();
83
    
84
    /** List of the registered changes listeners */
69
    /** List of the registered changes listeners */
85
    private static final WeakEventListenerList listenerList
70
    private static final WeakEventListenerList listenerList
86
	= new WeakEventListenerList();
71
	= new WeakEventListenerList();
72
73
    private static PropertyChangeListener editorRegistryListener = null;
87
    
74
    
88
    private static int consolidateCounter;
89
90
    /** Add weak listener to listen to change of activity of documents or components.
75
    /** Add weak listener to listen to change of activity of documents or components.
91
     * The caller must
76
     * The caller must
92
     * hold the listener object in some instance variable to prevent it
77
     * hold the listener object in some instance variable to prevent it
Lines 94-99 Link Here
94
     * @param l listener to add
79
     * @param l listener to add
95
     */
80
     */
96
    public static void addChangeListener(ChangeListener l) {
81
    public static void addChangeListener(ChangeListener l) {
82
        registerListener();
97
        listenerList.add(ChangeListener.class, l);
83
        listenerList.add(ChangeListener.class, l);
98
    }
84
    }
99
85
Lines 103-108 Link Here
103
     * @param l listener to remove
89
     * @param l listener to remove
104
     */
90
     */
105
    public static void removeChangeListener(ChangeListener l) {
91
    public static void removeChangeListener(ChangeListener l) {
92
        registerListener();
106
        listenerList.remove(ChangeListener.class, l);
93
        listenerList.remove(ChangeListener.class, l);
107
    }
94
    }
108
95
Lines 110-126 Link Here
110
     * @return document id or -1 if document was not yet added to the registry
97
     * @return document id or -1 if document was not yet added to the registry
111
     *  by <code>addDocument()</code>.
98
     *  by <code>addDocument()</code>.
112
     */
99
     */
113
    public static synchronized int getID(BaseDocument doc) {
100
    @PatchedPublic
114
	Integer i = getIDInteger(doc);
101
    private static int getID(BaseDocument doc) {
115
	return (i != null) ? i.intValue() : -1;
102
        registerListener();
103
        return -1;
116
    }
104
    }
117
	
105
	
118
    /** Get component ID from the component.
106
    /** Get component ID from the component.
119
     * @return component id or -1 if component was not yet added to the registry
107
     * @return component id or -1 if component was not yet added to the registry
120
     *  by <code>addComponent()</code>.
108
     *  by <code>addComponent()</code>.
121
     */
109
     */
122
    public static synchronized int getID(JTextComponent c) {
110
    @PatchedPublic
123
	return getIDImpl(c);
111
    private static int getID(JTextComponent c) {
112
        registerListener();
113
        return -1;
124
    }
114
    }
125
115
126
    /** Get document when its ID is known.
116
    /** Get document when its ID is known.
Lines 129-141 Link Here
129
     *  by <code>getID(doc)</code>.
119
     *  by <code>getID(doc)</code>.
130
     * @return document instance or null when document no longer exists
120
     * @return document instance or null when document no longer exists
131
     */
121
     */
132
    public static synchronized BaseDocument getDocument(int docID) {
122
    @PatchedPublic
133
        if (docID < 0 || docID >= docRefsCount) {
123
    private static BaseDocument getDocument(int docID) {
134
            return null;
124
        registerListener();
135
        }
125
        return null;
136
137
	WeakReference wr = docRefs[docID];
138
        return (wr != null) ? (BaseDocument)wr.get() : null;
139
    }
126
    }
140
127
141
    /** Get component when its ID is known.
128
    /** Get component when its ID is known.
Lines 144-175 Link Here
144
     *  by <code>getID(c)</code>.
131
     *  by <code>getID(c)</code>.
145
     * @return component instance or null when document no longer exists
132
     * @return component instance or null when document no longer exists
146
     */
133
     */
147
    public static synchronized JTextComponent getComponent(int compID) {
134
    @PatchedPublic
148
        if (compID < 0 || compID >= compRefsCount) {
135
    private static JTextComponent getComponent(int compID) {
149
            return null;
136
        registerListener();
150
        }
137
        return null;
151
152
	WeakReference wr = compRefs[compID];
153
        return (wr != null) ? (JTextComponent)wr.get() : null;
154
    }
138
    }
155
139
156
    /** Add document to registry. Doesn't search for repetitive
140
    /** Add document to registry. Doesn't search for repetitive
157
     * adding.
141
     * adding.
158
     * @return registry unique ID of the document
142
     * @return registry unique ID of the document
159
     */
143
     */
160
    public static synchronized int addDocument(BaseDocument doc) {
144
    @PatchedPublic
161
        Integer docID = getIDInteger(doc);
145
    private static int addDocument(BaseDocument doc) {
162
        if (docID != null) { // already added
146
        registerListener();
163
            return docID.intValue();
147
        return -1;
164
        }
165
166
	if (docRefsCount >= docRefs.length) {
167
	    docRefs = realloc(docRefs);
168
	}
169
	
170
        docRefs[docRefsCount] = new WeakReference(doc);
171
        doc.putProperty(BaseDocument.ID_PROP, new Integer(docRefsCount));
172
	return docRefsCount++;
173
    }
148
    }
174
149
175
    /** Add component to registry. If the component is already registered
150
    /** Add component to registry. If the component is already registered
Lines 177-198 Link Here
177
     * to the component is _not_ registered automatically.
152
     * to the component is _not_ registered automatically.
178
     * @return ID of the component
153
     * @return ID of the component
179
     */
154
     */
180
    public static synchronized int addComponent(JTextComponent c) {
155
    @PatchedPublic
181
        int compID = getIDImpl(c);
156
    private static int addComponent(JTextComponent c) {
182
        if (compID != -1) {
157
        registerListener();
183
            if (compRefs[compID] == null) { // unregistered previously by removeComponent()
158
        return -1;
184
                compRefs[compID] = new WeakReference<JTextComponent>(c);
185
            }
186
            return compID; // already registered
187
        }
188
	
189
	if (compRefsCount >= compRefs.length) {
190
	    compRefs = realloc(compRefs);
191
	}
192
193
        compRefs[compRefsCount] = new WeakReference(c);
194
        ((BaseTextUI)c.getUI()).componentID = compRefsCount;
195
        return compRefsCount++;
196
    }
159
    }
197
160
198
    /** Remove component from registry. It's usually done when
161
    /** Remove component from registry. It's usually done when
Lines 201-278 Link Here
201
     *  new ID will be different from this one. -1 will be returned
164
     *  new ID will be different from this one. -1 will be returned
202
     *  if the component was not yet added to the registry.
165
     *  if the component was not yet added to the registry.
203
     */
166
     */
204
    public static int removeComponent(JTextComponent c) {
167
    @PatchedPublic
205
        int compID;
168
    private static int removeComponent(JTextComponent c) {
206
        boolean lastComponent = false;
169
        registerListener();
207
                
170
        return -1;
208
        synchronized (Registry.class) {
209
            compID = getIDImpl(c);
210
            
211
            if (compID != -1) {
212
                compRefs[compID] = null;
213
                // Search whether was activated
214
                for (int i = compAct.size() - 1; i >= 0; i--) {
215
                    if (compAct.get(i) == compID) {
216
                        compAct.remove(i);
217
                        break;
218
                    }
219
                }
220
                
221
                lastComponent = compAct.isEmpty();
222
            }
223
        }
224
	
225
        if (lastComponent) {
226
            fireChange();
227
        }
228
        
229
        return compID;
230
    }
171
    }
231
172
232
    /** Put the component to the first position in the array of last accessed
173
    /** Put the component to the first position in the array of last accessed
233
    * components. The activate of document is also called automatically.
174
    * components. The activate of document is also called automatically.
234
    */
175
    */
235
    public static void activate(JTextComponent c) {
176
    @PatchedPublic
236
        boolean activated = true;
177
    private static void activate(JTextComponent c) {
237
        synchronized (Registry.class) {
178
        registerListener();
238
            int compID = getIDImpl(c);
239
            if (compID == -1) { // c not registered
240
                return;
241
            }
242
            
243
            int actSize = compAct.size();
244
            int ind = 0;
245
            while (ind < actSize) {
246
                int id = compAct.get(ind);
247
                if (id == compID) { // found
248
                    if (ind == 0) {
249
                        break;
250
                    }
251
                    compAct.add(0, compAct.remove(ind));
252
                    activated = true;
253
                    break;
254
                }
255
                
256
                ind++;
257
            }
258
            
259
            if (ind == actSize) {
260
                compAct.add(0, compID);
261
                activated = true;
262
            }
263
264
            // Try to activate component's document too
265
            Object doc = c.getDocument();
266
            if (doc instanceof BaseDocument) {
267
                if (doActivate((BaseDocument)doc)) {
268
                    activated = true;
269
                }
270
            }
271
        }
272
        
273
        if (activated) {
274
            fireChange();
275
        }
276
    }
179
    }
277
180
278
    /** Put the document to the first position in the array of last accessed
181
    /** Put the document to the first position in the array of last accessed
Lines 280-319 Link Here
280
     * is done.
183
     * is done.
281
     * @param doc document to be activated
184
     * @param doc document to be activated
282
     */
185
     */
283
    public static void activate(BaseDocument doc) {
186
    @PatchedPublic
284
        boolean activated;
187
    private static void activate(BaseDocument doc) {
285
        synchronized (Registry.class) {
188
        registerListener();
286
            activated = doActivate(doc);
287
	}
288
289
        if (activated) {
290
	    fireChange();
291
        }
292
    }
189
    }
293
    
190
    
294
    public static synchronized BaseDocument getMostActiveDocument() {
191
    public static BaseDocument getMostActiveDocument() {
295
        return getValidDoc(0, true);
192
        registerListener();
193
        JTextComponent jtc = getMostActiveComponent();
194
        return jtc == null ? null : Utilities.getDocument(jtc);
296
    }
195
    }
297
196
298
    public static synchronized BaseDocument getLeastActiveDocument() {
197
    public static BaseDocument getLeastActiveDocument() {
299
        int lastInd = docAct.size() - 1;
198
        registerListener();
300
        return getValidDoc(lastInd, false);
199
        JTextComponent jtc = getLeastActiveComponent();
200
        return jtc == null ? null : Utilities.getDocument(jtc);
301
    }
201
    }
302
202
303
    public static BaseDocument getLessActiveDocument(BaseDocument doc) {
203
    @PatchedPublic
304
        return getLessActiveDocument(getID(doc));
204
    private static BaseDocument getLessActiveDocument(BaseDocument doc) {
205
        registerListener();
206
        return null;
305
    }
207
    }
306
208
307
    public static synchronized BaseDocument getLessActiveDocument(int docID) {
209
    @PatchedPublic
308
        return getNextActiveDoc(docID, true);
210
    private static BaseDocument getLessActiveDocument(int docID) {
211
        registerListener();
212
        return null;
309
    }
213
    }
310
214
311
    public static BaseDocument getMoreActiveDocument(BaseDocument doc) {
215
    @PatchedPublic
312
        return getMoreActiveDocument(getID(doc));
216
    private static BaseDocument getMoreActiveDocument(BaseDocument doc) {
217
        registerListener();
218
        return null;
313
    }
219
    }
314
220
315
    public static synchronized BaseDocument getMoreActiveDocument(int docID) {
221
    @PatchedPublic
316
        return getNextActiveDoc(docID, false);
222
    private static BaseDocument getMoreActiveDocument(int docID) {
223
        registerListener();
224
        return null;
317
    }
225
    }
318
226
319
    /** Get the iterator over the active documents. It starts with
227
    /** Get the iterator over the active documents. It starts with
Lines 321-527 Link Here
321
     * It's just the current snapshot so the iterator will
229
     * It's just the current snapshot so the iterator will
322
     * not reflect future changes.
230
     * not reflect future changes.
323
     */
231
     */
324
    public static synchronized Iterator getDocumentIterator() {
232
    public static Iterator<? extends Document> getDocumentIterator() {
325
        consolidate();
233
        registerListener();
234
        final Iterator<? extends JTextComponent> cIt = getComponentIterator();
235
        return new Iterator<Document>() {
236
            public boolean hasNext() {
237
                return cIt.hasNext();
238
            }
326
239
327
        ArrayList docList = new ArrayList();
240
            public Document next() {
328
        int actSize = docAct.size();
241
                return cIt.next().getDocument();
329
        for (int i = 0; i < actSize; i++) {
330
            int ind = ((Integer)docAct.get(i)).intValue();
331
            WeakReference wr = docRefs[ind];
332
            if (wr != null) {
333
                Object doc = wr.get();
334
                if (doc != null) {
335
                    docList.add(doc);
336
                }
337
            }
242
            }
338
        }
339
243
340
        return docList.iterator();
244
            public void remove() {
245
                cIt.remove();
246
            }
247
        };
341
    }
248
    }
342
249
343
    public static synchronized JTextComponent getMostActiveComponent() {
250
    public static JTextComponent getMostActiveComponent() {
344
        return getValidComp(0, true);
251
        registerListener();
252
        return EditorRegistry.focusedComponent();
345
    }
253
    }
346
254
347
    public static synchronized JTextComponent getLeastActiveComponent() {
255
    public static JTextComponent getLeastActiveComponent() {
348
        int lastInd = compAct.size() - 1;
256
        registerListener();
349
        return getValidComp(lastInd, false);
257
        List<? extends JTextComponent> l = EditorRegistry.componentList();
258
        return l.size() > 0 ? l.get(l.size() - 1) : null;
350
    }
259
    }
351
260
352
    public static JTextComponent getLessActiveComponent(JTextComponent c) {
261
    @PatchedPublic
353
        return getLessActiveComponent(getID(c));
262
    private static JTextComponent getLessActiveComponent(JTextComponent c) {
263
        registerListener();
264
        return null;
354
    }
265
    }
355
266
356
    public static synchronized JTextComponent getLessActiveComponent(int compID) {
267
    @PatchedPublic
357
        return getNextActiveComp(compID, true);
268
    private static JTextComponent getLessActiveComponent(int compID) {
269
        registerListener();
270
        return null;
358
    }
271
    }
359
272
360
    public static JTextComponent getMoreActiveComponent(JTextComponent c) {
273
    @PatchedPublic
361
        return getMoreActiveComponent(getID(c));
274
    private static JTextComponent getMoreActiveComponent(JTextComponent c) {
275
        registerListener();
276
        return null;
362
    }
277
    }
363
278
364
    public static synchronized JTextComponent getMoreActiveComponent(int compID) {
279
    @PatchedPublic
365
        return getNextActiveComp(compID, false);
280
    private static JTextComponent getMoreActiveComponent(int compID) {
281
        registerListener();
282
        return null;
366
    }
283
    }
367
284
368
    /** Get the iterator over the active components. It starts with
285
    /** Get the iterator over the active components. It starts with
369
    * the most active component till the least active component.
286
    * the most active component till the least active component.
370
    */
287
    */
371
    public static synchronized Iterator getComponentIterator() {
288
    public static Iterator<? extends JTextComponent> getComponentIterator() {
372
	consolidate();
289
        registerListener();
373
290
        return EditorRegistry.componentList().iterator();
374
        ArrayList compList = new ArrayList();
375
        int actSize = compAct.size();
376
        for (int i = 0; i < actSize; i++) {
377
            int ind = compAct.get(i);
378
            WeakReference wr = compRefs[ind];
379
            if (wr != null) {
380
                Object comp = wr.get();
381
                if (comp != null) {
382
                    compList.add(comp);
383
                }
384
            }
385
        }
386
387
        return compList.iterator();
388
    }
291
    }
389
292
390
    private static WeakReference[] realloc(WeakReference[] refs) {
293
    private static synchronized void registerListener() {
391
	WeakReference[] tmp = new WeakReference[refs.length * 2 + 4];
294
        if (editorRegistryListener == null) {
392
	System.arraycopy(refs, 0, tmp, 0, refs.length);
295
            editorRegistryListener = new PropertyChangeListener() {
393
	return tmp;
296
                public void propertyChange(PropertyChangeEvent evt) {
394
    }
297
                    fireChange();
395
    
298
                }
396
    private static void consolidate() {
299
            };
397
	while (++consolidateCounter >= 20) { // after every 20th call
300
            EditorRegistry.addPropertyChangeListener(editorRegistryListener);
398
	    consolidateCounter = 0;
399
	    
400
	    // Remove empty document references
401
	    for (int i = docAct.size() - 1; i >= 0; i--) {
402
		int ind = ((Integer)docAct.get(i)).intValue();
403
		WeakReference wr = docRefs[ind];
404
		if (wr != null) {
405
		    if (wr.get() == null) { // empty reference
406
			docAct.remove(i);
407
			docRefs[ind] = null;
408
		    }
409
		}
410
	    }
411
412
	    // Remove empty component references
413
	    for (int i = compAct.size() - 1; i >= 0; i--) {
414
		int ind = compAct.get(i);
415
		WeakReference wr = compRefs[ind];
416
		if (wr != null) {
417
		    if (wr.get() == null) { // empty reference
418
			compAct.remove(i);
419
			compRefs[ind] = null;
420
		    }
421
		}
422
	    }
423
	}
424
    }
425
426
    private static int getIDImpl(JTextComponent c) {
427
        if (c == null) {
428
            return -1;
429
        }
301
        }
430
        return ((BaseTextUI)c.getUI()).componentID;
431
    }
432
433
    private static Integer getIDInteger(BaseDocument doc) {
434
	if (doc == null) {
435
            return null;
436
        }
437
438
        return (Integer)doc.getProperty(BaseDocument.ID_PROP);
439
    }
440
441
    private static boolean doActivate(BaseDocument doc) {
442
	Integer docIDInteger = getIDInteger(doc);
443
	
444
	if (docIDInteger == null) {
445
	    return false; // document not added to registry
446
	}
447
448
        int docID = (docIDInteger != null) ? docIDInteger.intValue() : -1;
449
450
	int size = docAct.size();
451
	for (int ind = 0; ind < size; ind++) {
452
	    int id = ((Integer)docAct.get(ind)).intValue();
453
	    if (id == docID) {
454
		if (ind == 0) { // no change
455
		    return false;
456
		}
457
458
		docAct.add(0, docAct.remove(ind));
459
		return true;
460
	    }
461
	}
462
	
463
        docAct.add(0, docIDInteger);
464
	return true;
465
    }
466
467
    private static BaseDocument getValidDoc(int ind, boolean forward) {
468
	consolidate();
469
470
	int actSize = docAct.size();
471
        while (ind >= 0 && ind < actSize) {
472
            int docID = ((Integer)docAct.get(ind)).intValue();
473
	    WeakReference wr = docRefs[docID];
474
            BaseDocument doc = (wr != null) ? (BaseDocument)wr.get() : null;
475
            if (doc != null) {
476
                return doc;
477
            }
478
            ind += forward ? +1 : -1;
479
        }
480
        return null;
481
    }
482
483
    private static BaseDocument getNextActiveDoc(int docID, boolean forward) {
484
	consolidate();
485
486
        int actSize = docAct.size();
487
        int ind = forward ? 0 : (actSize - 1);
488
        while (ind >= 0 && ind < actSize) {
489
            if (((Integer)docAct.get(ind)).intValue() == docID) {
490
                ind += forward ? +1 : -1; // get next one
491
                return getValidDoc(ind, forward);
492
            }
493
            ind += forward ? +1 : -1;
494
        }
495
        return null;
496
    }
497
498
    private static JTextComponent getValidComp(int ind, boolean forward) {
499
	consolidate();
500
501
	int actSize = compAct.size();
502
        while (ind >= 0 && ind < actSize) {
503
            int compID = compAct.get(ind);
504
	    WeakReference wr = compRefs[compID];
505
            JTextComponent c = (wr != null) ? (JTextComponent)wr.get() : null;
506
            if (c != null) {
507
                return c;
508
            }
509
            ind += forward ? +1 : -1;
510
        }
511
        return null;
512
    }
513
514
    private static JTextComponent getNextActiveComp(int compID, boolean forward) {
515
        int actSize = compAct.size();
516
        int ind = forward ? 0 : (actSize - 1);
517
        while (ind >= 0 && ind < actSize) {
518
            if (compAct.get(ind) == compID) {
519
                ind += forward ? +1 : -1;
520
                return getValidComp(ind, forward);
521
            }
522
            ind += forward ? +1 : -1;
523
        }
524
        return null;
525
    }
302
    }
526
303
527
    private static void fireChange() {
304
    private static void fireChange() {
Lines 534-567 Link Here
534
    }
311
    }
535
312
536
    /** Debug the registry into string. */
313
    /** Debug the registry into string. */
537
    public static synchronized String registryToString() {
314
    public static String registryToString() {
538
        StringBuffer sb = new StringBuffer();
315
        registerListener();
539
        sb.append("Document References:\n"); // NOI18N
316
        try {
540
        for (int i = 0; i < docRefsCount; i++) {
317
            Method m = EditorRegistry.class.getDeclaredMethod("dumpItemList"); //NOI18N
541
            WeakReference wr = docRefs[i];
318
            return (String) m.invoke(null);
542
            sb.append("docRefs[" + i + "]=" + ((wr != null) ? wr.get() : "null") + "\n"); // NOI18N
319
        } catch (Exception e) {
320
            // ignore;
321
            return ""; //NOI18N
543
        }
322
        }
544
        sb.append("Component References:\n"); // NOI18N
545
        for (int i = 0; i < compRefsCount; i++) {
546
            WeakReference wr = (WeakReference)compRefs[i];
547
            sb.append("compRefs[" + i + "]=" + ((wr != null) ? wr.get() : "null") + "\n"); // NOI18N
548
        }
549
        sb.append("\nActive Document Indexes:\n"); // NOI18N
550
        for (int i = 0; i < docAct.size(); i++) {
551
            sb.append(docAct.get(i));
552
            if (i != docAct.size() - 1) {
553
                sb.append(", "); // NOI18N
554
            }
555
        }
556
        sb.append("\nActive Component Indexes:\n"); // NOI18N
557
        for (int i = 0; i < compAct.size(); i++) {
558
            sb.append(compAct.get(i));
559
            if (i != compAct.size() - 1) {
560
                sb.append(", "); // NOI18N
561
            }
562
        }
563
564
        return sb.toString();
565
    }
323
    }
566
324
567
}
325
}
(-)a/editor.lib/src/org/netbeans/editor/WordMatch.java (-2 / +13 lines)
Lines 45-56 Link Here
45
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeListener;
46
import java.util.HashMap;
46
import java.util.HashMap;
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.List;
48
import java.util.prefs.PreferenceChangeEvent;
49
import java.util.prefs.PreferenceChangeEvent;
49
import java.util.prefs.PreferenceChangeListener;
50
import java.util.prefs.PreferenceChangeListener;
50
import java.util.prefs.Preferences;
51
import java.util.prefs.Preferences;
51
import javax.swing.text.Position;
52
import javax.swing.text.Position;
52
import javax.swing.text.BadLocationException;
53
import javax.swing.text.BadLocationException;
53
import javax.swing.text.JTextComponent;
54
import javax.swing.text.JTextComponent;
55
import org.netbeans.api.editor.EditorRegistry;
54
import org.netbeans.api.editor.mimelookup.MimeLookup;
56
import org.netbeans.api.editor.mimelookup.MimeLookup;
55
import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
57
import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
56
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
58
import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
Lines 450-456 Link Here
450
        if (doc == getStaticWordsDoc()) {
452
        if (doc == getStaticWordsDoc()) {
451
            return null;
453
            return null;
452
        }
454
        }
453
        BaseDocument nextDoc = Registry.getLessActiveDocument(doc);
455
        BaseDocument nextDoc = null;
456
        List<? extends JTextComponent> list = EditorRegistry.componentList();
457
        for(int i = 0; i < list.size(); i++) {
458
            if (doc == list.get(i).getDocument()) {
459
                if (i + 1 < list.size()) {
460
                    nextDoc = Utilities.getDocument(list.get(i + 1));
461
                }
462
                break;
463
            }
464
        }
454
        if (nextDoc == null) {
465
        if (nextDoc == null) {
455
            nextDoc = getStaticWordsDoc();
466
            nextDoc = getStaticWordsDoc();
456
        }
467
        }
Lines 527-533 Link Here
527
538
528
        public @Override String toString() {
539
        public @Override String toString() {
529
            return "{word='" + word + "', pos=" + pos.getOffset() // NOI18N
540
            return "{word='" + word + "', pos=" + pos.getOffset() // NOI18N
530
                   + ", doc=" + Registry.getID(doc) + "}"; // NOI18N
541
                   + ", doc=" + doc + "}"; // NOI18N
531
        }
542
        }
532
543
533
    } // End of WordInfo class
544
    } // End of WordInfo class
(-)a/editor/src/org/netbeans/modules/editor/MainMenuAction.java (-2 / +7 lines)
Lines 41-46 Link Here
41
41
42
package org.netbeans.modules.editor;
42
package org.netbeans.modules.editor;
43
43
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
44
import java.util.Collection;
46
import java.util.Collection;
45
import java.util.prefs.Preferences;
47
import java.util.prefs.Preferences;
46
import javax.swing.Action;
48
import javax.swing.Action;
Lines 60-66 Link Here
60
import org.netbeans.api.editor.settings.KeyBindingSettings;
62
import org.netbeans.api.editor.settings.KeyBindingSettings;
61
import org.netbeans.api.editor.settings.SimpleValueNames;
63
import org.netbeans.api.editor.settings.SimpleValueNames;
62
import org.netbeans.editor.BaseKit;
64
import org.netbeans.editor.BaseKit;
63
import org.netbeans.editor.Registry;
64
import org.netbeans.editor.Utilities;
65
import org.netbeans.editor.Utilities;
65
import org.netbeans.editor.ext.ExtKit;
66
import org.netbeans.editor.ext.ExtKit;
66
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
67
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
Lines 197-203 Link Here
197
        if (kbs == null) {
198
        if (kbs == null) {
198
            // needs to listen on Registry - resultChanged event is fired before
199
            // needs to listen on Registry - resultChanged event is fired before
199
            // TopComponent is really focused - this causes problems in getComponent method
200
            // TopComponent is really focused - this causes problems in getComponent method
200
            Registry.addChangeListener(this);
201
            EditorRegistry.addPropertyChangeListener(new PropertyChangeListener() {
202
                public void propertyChange(PropertyChangeEvent evt) {
203
                    setMenu();
204
                }
205
            });
201
            kbs = MimeLookup.getLookup(MimePath.EMPTY).lookupResult(KeyBindingSettings.class);
206
            kbs = MimeLookup.getLookup(MimePath.EMPTY).lookupResult(KeyBindingSettings.class);
202
            kbs.addLookupListener(WeakListeners.create(LookupListener.class, this, kbs));
207
            kbs.addLookupListener(WeakListeners.create(LookupListener.class, this, kbs));
203
            kbs.allInstances();
208
            kbs.allInstances();
(-)a/java.editor/src/org/netbeans/modules/java/editor/semantic/OccurrencesMarkProviderCreator.java (-2 lines)
Lines 40-48 Link Here
40
 */
40
 */
41
package org.netbeans.modules.java.editor.semantic;
41
package org.netbeans.modules.java.editor.semantic;
42
42
43
import javax.swing.text.Document;
44
import javax.swing.text.JTextComponent;
43
import javax.swing.text.JTextComponent;
45
import org.netbeans.editor.Registry;
46
import org.netbeans.modules.editor.errorstripe.privatespi.MarkProvider;
44
import org.netbeans.modules.editor.errorstripe.privatespi.MarkProvider;
47
import org.netbeans.modules.editor.errorstripe.privatespi.MarkProviderCreator;
45
import org.netbeans.modules.editor.errorstripe.privatespi.MarkProviderCreator;
48
46
(-)a/jellytools.ide/src/org/netbeans/jellytools/modules/editor/CompletionJListOperator.java (-9 / +8 lines)
Lines 48-75 Link Here
48
import java.util.List;
48
import java.util.List;
49
import java.util.logging.Logger;
49
import java.util.logging.Logger;
50
import javax.swing.JList;
50
import javax.swing.JList;
51
import javax.swing.JScrollPane;
52
import javax.swing.ListModel;
53
import javax.swing.SwingUtilities;
51
import javax.swing.SwingUtilities;
54
import javax.swing.event.DocumentEvent;
52
import javax.swing.event.DocumentEvent;
55
import javax.swing.event.DocumentListener;
53
import javax.swing.event.DocumentListener;
54
import javax.swing.text.JTextComponent;
55
import org.netbeans.api.editor.EditorRegistry;
56
import org.netbeans.api.editor.completion.Completion;
56
import org.netbeans.api.editor.completion.Completion;
57
import org.netbeans.editor.BaseDocument;
57
import org.netbeans.editor.BaseDocument;
58
import org.netbeans.editor.Registry;
58
import org.netbeans.editor.Utilities;
59
import org.netbeans.jellytools.Bundle;
59
import org.netbeans.jellytools.Bundle;
60
import org.netbeans.jemmy.ComponentSearcher;
61
import org.netbeans.jemmy.JemmyException;
60
import org.netbeans.jemmy.JemmyException;
62
import org.netbeans.jemmy.QueueTool;
61
import org.netbeans.jemmy.QueueTool;
63
import org.netbeans.jemmy.TimeoutExpiredException;
64
import org.netbeans.jemmy.Timeouts;
62
import org.netbeans.jemmy.Timeouts;
65
import org.netbeans.jemmy.Waitable;
63
import org.netbeans.jemmy.Waitable;
66
import org.netbeans.jemmy.Waiter;
64
import org.netbeans.jemmy.Waiter;
67
import org.netbeans.jemmy.operators.JListOperator;
65
import org.netbeans.jemmy.operators.JListOperator;
68
import org.netbeans.jemmy.operators.JScrollPaneOperator;
69
import org.netbeans.modules.editor.completion.CompletionImpl;
66
import org.netbeans.modules.editor.completion.CompletionImpl;
70
import org.netbeans.modules.editor.completion.CompletionJList;
67
import org.netbeans.modules.editor.completion.CompletionJList;
71
import org.netbeans.jemmy.operators.Operator;
68
import org.netbeans.jemmy.operators.Operator;
72
import org.netbeans.jemmy.util.EmptyVisualizer;
73
69
74
70
75
/**
71
/**
Lines 312-319 Link Here
312
        };
308
        };
313
        
309
        
314
        public static void start() {
310
        public static void start() {
315
            doc = Registry.getMostActiveDocument();
311
            JTextComponent jtc = EditorRegistry.focusedComponent();
316
            doc.addDocumentListener(listener);
312
            doc = jtc != null ? Utilities.getDocument(jtc) : null;
313
            if (doc != null) {
314
                doc.addDocumentListener(listener);
315
            }
317
            modified = false;
316
            modified = false;
318
            active = true;
317
            active = true;
319
        }
318
        }
(-)a/profiler.projectsupport/nbproject/project.xml (+9 lines)
Lines 59-64 Link Here
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
62
                    <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
63
                    <build-prerequisite/>
64
                    <compile-dependency/>
65
                    <run-dependency>
66
                        <release-version>1</release-version>
67
                        <specification-version>1.0</specification-version>
68
                    </run-dependency>
69
                </dependency>
70
                <dependency>
62
                    <code-name-base>org.netbeans.modules.java.platform</code-name-base>
71
                    <code-name-base>org.netbeans.modules.java.platform</code-name-base>
63
                    <build-prerequisite/>
72
                    <build-prerequisite/>
64
                    <compile-dependency/>
73
                    <compile-dependency/>
(-)a/profiler.projectsupport/src/org/netbeans/modules/profiler/projectsupport/utilities/SourceUtils.java (-5 / +2 lines)
Lines 76-82 Link Here
76
import org.openide.util.NbBundle;
76
import org.openide.util.NbBundle;
77
import org.openide.windows.TopComponent;
77
import org.openide.windows.TopComponent;
78
import java.io.IOException;
78
import java.io.IOException;
79
import java.text.MessageFormat;
80
import java.util.ArrayList;
79
import java.util.ArrayList;
81
import java.util.Arrays;
80
import java.util.Arrays;
82
import java.util.Collection;
81
import java.util.Collection;
Lines 110-119 Link Here
110
import javax.lang.model.util.Elements;
109
import javax.lang.model.util.Elements;
111
import javax.lang.model.util.Types;
110
import javax.lang.model.util.Types;
112
import javax.swing.JEditorPane;
111
import javax.swing.JEditorPane;
113
import javax.swing.SwingUtilities;
114
import javax.swing.text.JTextComponent;
112
import javax.swing.text.JTextComponent;
115
import org.netbeans.api.java.source.ui.ElementOpen;
113
import org.netbeans.api.editor.EditorRegistry;
116
import org.netbeans.lib.profiler.common.Profiler;
117
import org.netbeans.modules.profiler.utilities.OutputParameter;
114
import org.netbeans.modules.profiler.utilities.OutputParameter;
118
115
119
/**
116
/**
Lines 328-334 Link Here
328
     * @return The caret offset or -1
325
     * @return The caret offset or -1
329
     */
326
     */
330
    public static int getCurrentOffsetInEditor() {
327
    public static int getCurrentOffsetInEditor() {
331
        JTextComponent mostActiveEditor = org.netbeans.editor.Registry.getMostActiveComponent();
328
        JTextComponent mostActiveEditor = EditorRegistry.focusedComponent();
332
329
333
        if ((mostActiveEditor != null) && (mostActiveEditor.getCaret() != null)) {
330
        if ((mostActiveEditor != null) && (mostActiveEditor.getCaret() != null)) {
334
            return mostActiveEditor.getCaretPosition();
331
            return mostActiveEditor.getCaretPosition();
(-)a/profiler/nbproject/project.xml (+9 lines)
Lines 145-150 Link Here
145
                    </run-dependency>
145
                    </run-dependency>
146
                </dependency>
146
                </dependency>
147
                <dependency>
147
                <dependency>
148
                    <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
149
                    <build-prerequisite/>
150
                    <compile-dependency/>
151
                    <run-dependency>
152
                        <release-version>1</release-version>
153
                        <specification-version>1.0</specification-version>
154
                    </run-dependency>
155
                </dependency>
156
                <dependency>
148
                    <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
157
                    <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
149
                    <build-prerequisite/>
158
                    <build-prerequisite/>
150
                    <compile-dependency/>
159
                    <compile-dependency/>
(-)a/profiler/src/org/netbeans/modules/profiler/ppoints/Utils.java (-5 / +2 lines)
Lines 45-51 Link Here
45
import org.netbeans.api.project.Project;
45
import org.netbeans.api.project.Project;
46
import org.netbeans.api.project.ProjectInformation;
46
import org.netbeans.api.project.ProjectInformation;
47
import org.netbeans.api.project.ProjectUtils;
47
import org.netbeans.api.project.ProjectUtils;
48
import org.netbeans.editor.Registry;
49
import org.netbeans.lib.profiler.common.Profiler;
48
import org.netbeans.lib.profiler.common.Profiler;
50
import org.netbeans.lib.profiler.global.ProfilingSessionStatus;
49
import org.netbeans.lib.profiler.global.ProfilingSessionStatus;
51
import org.netbeans.lib.profiler.ui.components.table.EnhancedTableCellRenderer;
50
import org.netbeans.lib.profiler.ui.components.table.EnhancedTableCellRenderer;
Lines 87-92 Link Here
87
import javax.swing.text.Document;
86
import javax.swing.text.Document;
88
import javax.swing.text.JTextComponent;
87
import javax.swing.text.JTextComponent;
89
import javax.swing.text.StyledDocument;
88
import javax.swing.text.StyledDocument;
89
import org.netbeans.api.editor.EditorRegistry;
90
import org.netbeans.modules.profiler.NetBeansProfiler;
90
import org.netbeans.modules.profiler.NetBeansProfiler;
91
import org.netbeans.modules.profiler.projectsupport.utilities.ProjectUtilities;
91
import org.netbeans.modules.profiler.projectsupport.utilities.ProjectUtilities;
92
import org.netbeans.modules.profiler.projectsupport.utilities.SourceUtils;
92
import org.netbeans.modules.profiler.projectsupport.utilities.SourceUtils;
Lines 891-900 Link Here
891
    }
891
    }
892
892
893
    private static JavaEditorContext getMostActiveJavaEditorContext() {
893
    private static JavaEditorContext getMostActiveJavaEditorContext() {
894
        Iterator componentIterator = Registry.getComponentIterator();
894
        for (JTextComponent component : EditorRegistry.componentList()) {
895
896
        while (componentIterator.hasNext()) {
897
            JTextComponent component = (JTextComponent) componentIterator.next();
898
            Document document = component.getDocument();
895
            Document document = component.getDocument();
899
            FileObject fileObject = NbEditorUtilities.getFileObject(document);
896
            FileObject fileObject = NbEditorUtilities.getFileObject(document);
900
897
(-)a/profiler/src/org/netbeans/modules/profiler/ppoints/ui/ToggleProfilingPointAction.java (-2 / +2 lines)
Lines 41-47 Link Here
41
package org.netbeans.modules.profiler.ppoints.ui;
41
package org.netbeans.modules.profiler.ppoints.ui;
42
42
43
import org.netbeans.api.project.Project;
43
import org.netbeans.api.project.Project;
44
import org.netbeans.editor.Registry;
45
import org.netbeans.lib.profiler.ui.components.ThinBevelBorder;
44
import org.netbeans.lib.profiler.ui.components.ThinBevelBorder;
46
import org.netbeans.modules.editor.NbEditorUtilities;
45
import org.netbeans.modules.editor.NbEditorUtilities;
47
import org.netbeans.modules.profiler.NetBeansProfiler;
46
import org.netbeans.modules.profiler.NetBeansProfiler;
Lines 85-90 Link Here
85
import javax.swing.border.Border;
84
import javax.swing.border.Border;
86
import javax.swing.text.Document;
85
import javax.swing.text.Document;
87
import javax.swing.text.JTextComponent;
86
import javax.swing.text.JTextComponent;
87
import org.netbeans.api.editor.EditorRegistry;
88
import org.openide.util.Utilities;
88
import org.openide.util.Utilities;
89
89
90
90
Lines 338-344 Link Here
338
        }
338
        }
339
339
340
        // Get most active editor
340
        // Get most active editor
341
        JTextComponent editor = Registry.getMostActiveComponent();
341
        JTextComponent editor = EditorRegistry.focusedComponent();
342
342
343
        if (editor == null) {
343
        if (editor == null) {
344
            return false;
344
            return false;
(-)a/python.debugger/src/org/netbeans/modules/python/debugger/config/NetBeansFrontend.java (-6 / +10 lines)
Lines 38-45 Link Here
38
 */
38
 */
39
package org.netbeans.modules.python.debugger.config;
39
package org.netbeans.modules.python.debugger.config;
40
40
41
import org.netbeans.editor.Registry;
42
43
import org.openide.ErrorManager;
41
import org.openide.ErrorManager;
44
42
45
import org.openide.filesystems.*;
43
import org.openide.filesystems.*;
Lines 48-53 Link Here
48
import java.io.*;
46
import java.io.*;
49
import javax.swing.JOptionPane;
47
import javax.swing.JOptionPane;
50
import javax.swing.text.Document;
48
import javax.swing.text.Document;
49
import javax.swing.text.JTextComponent;
50
import org.netbeans.api.editor.EditorRegistry;
51
import org.netbeans.modules.python.debugger.PythonDebugException;
51
import org.netbeans.modules.python.debugger.PythonDebugException;
52
import org.netbeans.modules.python.debugger.PythonDebugParameters;
52
import org.netbeans.modules.python.debugger.PythonDebugParameters;
53
import org.netbeans.modules.python.debugger.Utils;
53
import org.netbeans.modules.python.debugger.Utils;
Lines 284-293 Link Here
284
   * send back the current selected focussed source full path info
284
   * send back the current selected focussed source full path info
285
   */
285
   */
286
  public String getCurrentSource() {
286
  public String getCurrentSource() {
287
    Document doc = Registry.getMostActiveDocument();
287
    JTextComponent jtc = EditorRegistry.focusedComponent();
288
288
    if (jtc != null) {
289
    System.out.println("NB currentSource =" + Utils.getDocumentSource(doc));
289
      Document doc = jtc.getDocument();
290
    return Utils.getDocumentSource(doc);
290
      System.out.println("NB currentSource =" + Utils.getDocumentSource(doc));
291
      return Utils.getDocumentSource(doc);
292
    } else {
293
      return null;
294
    }
291
  }
295
  }
292
296
293
  /**
297
  /**

Return to bug 179368