Lines 1-7
Link Here
|
1 |
/* |
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
3 |
* |
4 |
* Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. |
4 |
* Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
7 |
* General Public License Version 2 only ("GPL") or the Common |
Lines 43-48
Link Here
|
43 |
|
43 |
|
44 |
import java.awt.EventQueue; |
44 |
import java.awt.EventQueue; |
45 |
import java.util.ArrayList; |
45 |
import java.util.ArrayList; |
|
|
46 |
import java.util.Collections; |
47 |
import java.util.Comparator; |
46 |
import java.util.List; |
48 |
import java.util.List; |
47 |
import javax.swing.event.TreeModelEvent; |
49 |
import javax.swing.event.TreeModelEvent; |
48 |
import javax.swing.event.TreeModelListener; |
50 |
import javax.swing.event.TreeModelListener; |
Lines 71-76
Link Here
|
71 |
private int selectedObjectsCount; |
73 |
private int selectedObjectsCount; |
72 |
/** */ |
74 |
/** */ |
73 |
private List<TreeModelListener> treeModelListeners; |
75 |
private List<TreeModelListener> treeModelListeners; |
|
|
76 |
/** */ |
77 |
private List<MatchingObject> sortedMatchingObjects = new ArrayList<MatchingObject>(); |
74 |
|
78 |
|
75 |
/** |
79 |
/** |
76 |
* |
80 |
* |
Lines 103-109
Link Here
|
103 |
} else { |
107 |
} else { |
104 |
try { |
108 |
try { |
105 |
//PENDING - threading: |
109 |
//PENDING - threading: |
106 |
ret = resultModel.matchingObjects.get(index); |
110 |
ret = getSortedMatchingObjects().get(index); |
107 |
} catch (ArrayIndexOutOfBoundsException ex) { |
111 |
} catch (ArrayIndexOutOfBoundsException ex) { |
108 |
assert false; |
112 |
assert false; |
109 |
ret = null; |
113 |
ret = null; |
Lines 190-196
Link Here
|
190 |
int ret; |
194 |
int ret; |
191 |
if (parent == getRoot()) { |
195 |
if (parent == getRoot()) { |
192 |
ret = (child.getClass() == MatchingObject.class) |
196 |
ret = (child.getClass() == MatchingObject.class) |
193 |
? resultModel.matchingObjects.indexOf(child) |
197 |
? getSortedMatchingObjects().indexOf(child) |
194 |
: -1; |
198 |
: -1; |
195 |
} else { |
199 |
} else { |
196 |
ret = -1; |
200 |
ret = -1; |
Lines 273-278
Link Here
|
273 |
UPDATE_NAME_TASK.run(); //fireRootNodeChanged(); |
277 |
UPDATE_NAME_TASK.run(); //fireRootNodeChanged(); |
274 |
} |
278 |
} |
275 |
|
279 |
|
|
|
280 |
private List<MatchingObject> getSortedMatchingObjects() { |
281 |
return sortedMatchingObjects; |
282 |
} |
283 |
|
276 |
/** |
284 |
/** |
277 |
*/ |
285 |
*/ |
278 |
boolean isSelected() { |
286 |
boolean isSelected() { |
Lines 298-316
Link Here
|
298 |
*/ |
306 |
*/ |
299 |
private final class Task implements Runnable { |
307 |
private final class Task implements Runnable { |
300 |
private final MatchingObject foundObject; |
308 |
private final MatchingObject foundObject; |
301 |
private final int foundObjectIndex; |
309 |
private final int foundObjectResultModelIndex; |
302 |
private Task() { |
310 |
private Task() { |
303 |
this.foundObject = null; |
311 |
this.foundObject = null; |
304 |
this.foundObjectIndex = -1; |
312 |
this.foundObjectResultModelIndex = -1; |
305 |
} |
313 |
} |
306 |
private Task(MatchingObject object) { |
314 |
private Task(MatchingObject object) { |
307 |
this.foundObject = object; |
315 |
this.foundObject = object; |
308 |
this.foundObjectIndex = -1; |
316 |
this.foundObjectResultModelIndex = -1; |
309 |
} |
317 |
} |
310 |
private Task(MatchingObject foundObject, int foundObjectIndex) { |
318 |
private Task(MatchingObject foundObject, int foundObjectIndex) { |
311 |
assert (foundObject != null) && (foundObjectIndex >= 0); |
319 |
assert (foundObject != null) && (foundObjectIndex >= 0); |
312 |
this.foundObject = foundObject; |
320 |
this.foundObject = foundObject; |
313 |
this.foundObjectIndex = foundObjectIndex; |
321 |
this.foundObjectResultModelIndex = foundObjectIndex; |
314 |
} |
322 |
} |
315 |
public void run() { |
323 |
public void run() { |
316 |
if (!EventQueue.isDispatchThread()) { |
324 |
if (!EventQueue.isDispatchThread()) { |
Lines 320-328
Link Here
|
320 |
|
328 |
|
321 |
assert EventQueue.isDispatchThread(); |
329 |
assert EventQueue.isDispatchThread(); |
322 |
if (foundObject != null) { |
330 |
if (foundObject != null) { |
323 |
if (foundObjectIndex != -1) { |
331 |
if (foundObjectResultModelIndex != -1) { |
|
|
332 |
getSortedMatchingObjects().add(foundObject); |
333 |
Collections.sort(getSortedMatchingObjects(), new Comparator<MatchingObject>() { |
334 |
@Override public int compare(MatchingObject o1, MatchingObject o2) { |
335 |
return o1.getName().compareToIgnoreCase(o2.getName()); |
336 |
} |
337 |
}); |
338 |
|
324 |
objectsCount++; |
339 |
objectsCount++; |
325 |
fireNodeAdded(foundObjectIndex, foundObject); |
340 |
fireNodeAdded(getSortedMatchingObjects().indexOf(foundObject), |
|
|
341 |
foundObject); |
326 |
updateRootNodeSelection(true); |
342 |
updateRootNodeSelection(true); |
327 |
} else { |
343 |
} else { |
328 |
/* file became invalid */ |
344 |
/* file became invalid */ |
Lines 475-481
Link Here
|
475 |
return; |
491 |
return; |
476 |
} |
492 |
} |
477 |
|
493 |
|
478 |
final int index = resultModel.matchingObjects.indexOf(matchingObj); |
494 |
final int index = getSortedMatchingObjects().indexOf(matchingObj); |
479 |
|
495 |
|
480 |
/* Notify that the file node itself has changed... */ |
496 |
/* Notify that the file node itself has changed... */ |
481 |
TreeModelEvent event = new TreeModelEvent(this, |
497 |
TreeModelEvent event = new TreeModelEvent(this, |