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-2005 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
12 |
*/ |
12 |
*/ |
13 |
|
13 |
|
Lines 24-29
Link Here
|
24 |
import java.io.ObjectInput; |
24 |
import java.io.ObjectInput; |
25 |
import java.io.ObjectOutput; |
25 |
import java.io.ObjectOutput; |
26 |
import java.util.ArrayList; |
26 |
import java.util.ArrayList; |
|
|
27 |
import java.util.Collection; |
27 |
import java.util.Enumeration; |
28 |
import java.util.Enumeration; |
28 |
import java.util.HashMap; |
29 |
import java.util.HashMap; |
29 |
import java.util.Iterator; |
30 |
import java.util.Iterator; |
Lines 47-59
Link Here
|
47 |
import org.openide.explorer.view.BeanTreeView; |
48 |
import org.openide.explorer.view.BeanTreeView; |
48 |
import org.openide.explorer.view.Visualizer; |
49 |
import org.openide.explorer.view.Visualizer; |
49 |
import org.openide.filesystems.FileObject; |
50 |
import org.openide.filesystems.FileObject; |
|
|
51 |
import org.openide.loaders.DataObject; |
50 |
import org.openide.nodes.Node; |
52 |
import org.openide.nodes.Node; |
51 |
import org.openide.nodes.NodeNotFoundException; |
53 |
import org.openide.nodes.NodeNotFoundException; |
52 |
import org.openide.nodes.NodeOp; |
54 |
import org.openide.nodes.NodeOp; |
53 |
import org.openide.util.HelpCtx; |
55 |
import org.openide.util.HelpCtx; |
|
|
56 |
import org.openide.util.Lookup; |
57 |
import org.openide.util.LookupEvent; |
58 |
import org.openide.util.LookupListener; |
54 |
import org.openide.util.NbBundle; |
59 |
import org.openide.util.NbBundle; |
55 |
import org.openide.util.RequestProcessor; |
60 |
import org.openide.util.RequestProcessor; |
56 |
import org.openide.util.Utilities; |
61 |
import org.openide.util.Utilities; |
|
|
62 |
import org.openide.util.WeakListeners; |
57 |
import org.openide.windows.TopComponent; |
63 |
import org.openide.windows.TopComponent; |
58 |
import org.openide.windows.WindowManager; |
64 |
import org.openide.windows.WindowManager; |
59 |
|
65 |
|
Lines 295-309
Link Here
|
295 |
|
301 |
|
296 |
// SEARCHING NODES |
302 |
// SEARCHING NODES |
297 |
|
303 |
|
|
|
304 |
private static final Lookup context = Utilities.actionsGlobalContext(); |
305 |
private static final Lookup.Result foSelection = context.lookup(new Lookup.Template(FileObject.class)); |
306 |
private static final Lookup.Result doSelection = context.lookup(new Lookup.Template(DataObject.class)); |
307 |
private final LookupListener baseListener = new LookupListener() { |
308 |
public void resultChanged(LookupEvent ev) { |
309 |
if (TopComponent.getRegistry().getActivated() == ProjectTab.this) { |
310 |
// Do not want to go into a loop. |
311 |
return; |
312 |
} |
313 |
Collection fos = foSelection.allInstances(); |
314 |
if (fos.size() == 1) { |
315 |
selectNodeAsyncNoSelect((FileObject) fos.iterator().next()); |
316 |
} else { |
317 |
Collection dos = doSelection.allInstances(); |
318 |
if (dos.size() == 1) { |
319 |
selectNodeAsyncNoSelect(((DataObject) dos.iterator().next()).getPrimaryFile()); |
320 |
} |
321 |
} |
322 |
} |
323 |
}; |
324 |
private final LookupListener weakListener = (LookupListener) WeakListeners.create(LookupListener.class, baseListener, null); |
325 |
private void startListening() { |
326 |
foSelection.addLookupListener(weakListener); |
327 |
doSelection.addLookupListener(weakListener); |
328 |
baseListener.resultChanged(null); |
329 |
} |
330 |
private void stopListening() { |
331 |
foSelection.removeLookupListener(weakListener); |
332 |
doSelection.removeLookupListener(weakListener); |
333 |
} |
334 |
protected void componentShowing() { |
335 |
super.componentShowing(); |
336 |
startListening(); |
337 |
} |
338 |
protected void componentHidden() { |
339 |
super.componentHidden(); |
340 |
stopListening(); |
341 |
} |
342 |
|
298 |
// Called from the SelectNodeAction |
343 |
// Called from the SelectNodeAction |
299 |
|
344 |
|
300 |
private final RequestProcessor RP = new RequestProcessor(); |
345 |
private final RequestProcessor RP = new RequestProcessor(); |
301 |
|
346 |
|
302 |
public void selectNodeAsync(final FileObject object) { |
347 |
public void selectNodeAsync(FileObject object) { |
303 |
|
|
|
304 |
setCursor( Utilities.createProgressCursor( this ) ); |
348 |
setCursor( Utilities.createProgressCursor( this ) ); |
305 |
open(); |
349 |
open(); |
306 |
requestActive(); |
350 |
requestActive(); |
|
|
351 |
|
352 |
selectNodeAsyncNoSelect(object); |
353 |
} |
354 |
|
355 |
private void selectNodeAsyncNoSelect(final FileObject object) { |
307 |
|
356 |
|
308 |
// Do it in different thread than AWT |
357 |
// Do it in different thread than AWT |
309 |
RP.post( new Runnable() { |
358 |
RP.post( new Runnable() { |