Lines 45-59
Link Here
|
45 |
import java.awt.EventQueue; |
45 |
import java.awt.EventQueue; |
46 |
import java.awt.event.ActionEvent; |
46 |
import java.awt.event.ActionEvent; |
47 |
import java.awt.event.ActionListener; |
47 |
import java.awt.event.ActionListener; |
48 |
import java.beans.PropertyChangeEvent; |
|
|
49 |
import java.beans.PropertyChangeListener; |
50 |
import java.beans.PropertyVetoException; |
48 |
import java.beans.PropertyVetoException; |
51 |
import java.util.LinkedList; |
|
|
52 |
import java.util.List; |
49 |
import java.util.List; |
53 |
import java.util.ResourceBundle; |
50 |
import java.util.ResourceBundle; |
54 |
import javax.accessibility.AccessibleContext; |
51 |
import javax.accessibility.AccessibleContext; |
55 |
import javax.swing.AbstractButton; |
|
|
56 |
import javax.swing.ActionMap; |
57 |
import javax.swing.JButton; |
52 |
import javax.swing.JButton; |
58 |
import javax.swing.JToggleButton; |
53 |
import javax.swing.JToggleButton; |
59 |
import javax.swing.UIManager; |
54 |
import javax.swing.UIManager; |
Lines 66-80
Link Here
|
66 |
import org.netbeans.modules.search.ResultModel; |
61 |
import org.netbeans.modules.search.ResultModel; |
67 |
import org.netbeans.modules.search.ResultView; |
62 |
import org.netbeans.modules.search.ResultView; |
68 |
import org.netbeans.modules.search.TextDetail; |
63 |
import org.netbeans.modules.search.TextDetail; |
69 |
import org.netbeans.swing.outline.Outline; |
|
|
70 |
import org.openide.explorer.view.OutlineView; |
64 |
import org.openide.explorer.view.OutlineView; |
71 |
import org.openide.explorer.view.Visualizer; |
|
|
72 |
import org.openide.filesystems.FileObject; |
65 |
import org.openide.filesystems.FileObject; |
73 |
import org.openide.nodes.Node; |
66 |
import org.openide.nodes.Node; |
74 |
import org.openide.nodes.NodeAdapter; |
67 |
import org.openide.nodes.NodeAdapter; |
75 |
import org.openide.nodes.NodeListener; |
68 |
import org.openide.nodes.NodeListener; |
76 |
import org.openide.nodes.NodeMemberEvent; |
69 |
import org.openide.nodes.NodeMemberEvent; |
77 |
import org.openide.util.Exceptions; |
|
|
78 |
import org.openide.util.ImageUtilities; |
70 |
import org.openide.util.ImageUtilities; |
79 |
import org.openide.util.NbBundle; |
71 |
import org.openide.util.NbBundle; |
80 |
|
72 |
|
Lines 85-98
Link Here
|
85 |
public abstract class BasicAbstractResultsPanel |
77 |
public abstract class BasicAbstractResultsPanel |
86 |
extends AbstractSearchResultsPanel { |
78 |
extends AbstractSearchResultsPanel { |
87 |
|
79 |
|
88 |
private static final String NEXT_ICON = |
|
|
89 |
"org/netbeans/modules/search/res/next.png"; //NOI18N |
90 |
private static final String PREV_ICON = |
91 |
"org/netbeans/modules/search/res/prev.png"; //NOI18N |
92 |
private static final String EXPAND_ICON = |
93 |
"org/netbeans/modules/search/res/expandTree.png"; //NOI18N |
94 |
private static final String COLLAPSE_ICON = |
95 |
"org/netbeans/modules/search/res/colapseTree.png"; //NOI18N |
96 |
private static final String SHOW_DETAILS_ICON = |
80 |
private static final String SHOW_DETAILS_ICON = |
97 |
"org/netbeans/modules/search/res/search.gif"; //NOI18N |
81 |
"org/netbeans/modules/search/res/search.gif"; //NOI18N |
98 |
private static final String FOLDER_VIEW_ICON = |
82 |
private static final String FOLDER_VIEW_ICON = |
Lines 102-112
Link Here
|
102 |
private static final String MODE_FLAT = "flat"; //NOI18N |
86 |
private static final String MODE_FLAT = "flat"; //NOI18N |
103 |
private static final String MODE_TREE = "tree"; //NOI18N |
87 |
private static final String MODE_TREE = "tree"; //NOI18N |
104 |
protected ResultModel resultModel; |
88 |
protected ResultModel resultModel; |
105 |
protected JButton nextButton; |
89 |
protected JToggleButton btnTreeView; |
106 |
protected JButton prevButton; |
90 |
protected JToggleButton btnFlatView; |
107 |
protected JToggleButton expandButton; |
|
|
108 |
protected JToggleButton treeViewButton; |
109 |
protected JToggleButton flatViewButton; |
110 |
protected JButton showDetailsButton; |
91 |
protected JButton showDetailsButton; |
111 |
protected boolean details; |
92 |
protected boolean details; |
112 |
protected BasicComposition composition; |
93 |
protected BasicComposition composition; |
Lines 129-136
Link Here
|
129 |
this.resultsOutlineSupport = resultsOutlineSupport; |
110 |
this.resultsOutlineSupport = resultsOutlineSupport; |
130 |
getExplorerManager().setRootContext( |
111 |
getExplorerManager().setRootContext( |
131 |
resultsOutlineSupport.getRootNode()); |
112 |
resultsOutlineSupport.getRootNode()); |
132 |
initSelectionListeners(); |
113 |
initButtons(); |
133 |
initActions(); |
|
|
134 |
initResultNodeAdditionListener(); |
114 |
initResultNodeAdditionListener(); |
135 |
if (MODE_TREE.equals( |
115 |
if (MODE_TREE.equals( |
136 |
FindDialogMemory.getDefault().getResultsViewMode())) { |
116 |
FindDialogMemory.getDefault().getResultsViewMode())) { |
Lines 141-168
Link Here
|
141 |
initAccessibility(); |
121 |
initAccessibility(); |
142 |
} |
122 |
} |
143 |
|
123 |
|
144 |
private void initSelectionListeners() { |
|
|
145 |
getExplorerManager().addPropertyChangeListener( |
146 |
new PropertyChangeListener() { |
147 |
@Override |
148 |
public void propertyChange(PropertyChangeEvent evt) { |
149 |
if (evt.getPropertyName().equals( |
150 |
"selectedNodes")) { //NOI18N |
151 |
updateShiftButtons(); |
152 |
} |
153 |
} |
154 |
}); |
155 |
} |
156 |
|
124 |
|
157 |
private void initActions() { |
|
|
158 |
ActionMap map = getActionMap(); |
159 |
|
160 |
map.put("jumpNext", new PrevNextAction(1)); // NOI18N |
161 |
map.put("jumpPrev", new PrevNextAction(-1)); // NOI18N |
162 |
} |
163 |
public void update() { |
125 |
public void update() { |
164 |
if (details && expandButton != null && !expandButton.isEnabled()) { |
126 |
if (details && btnExpand.isVisible() && !btnExpand.isEnabled()) { |
165 |
expandButton.setEnabled(resultModel.size() > 0); |
127 |
btnExpand.setEnabled(resultModel.size() > 0); |
166 |
} |
128 |
} |
167 |
EventQueue.invokeLater(new Runnable() { |
129 |
EventQueue.invokeLater(new Runnable() { |
168 |
@Override |
130 |
@Override |
Lines 173-254
Link Here
|
173 |
resultsOutlineSupport.update(); |
135 |
resultsOutlineSupport.update(); |
174 |
} |
136 |
} |
175 |
|
137 |
|
176 |
private void updateShiftButtons() { |
138 |
protected void initButtons() { |
177 |
if (details && prevButton != null && nextButton != null) { |
|
|
178 |
prevButton.setEnabled( |
179 |
findShiftNode(-1, getOutlineView(), false) != null); |
180 |
nextButton.setEnabled( |
181 |
findShiftNode(1, getOutlineView(), false) != null); |
182 |
} |
183 |
} |
184 |
|
185 |
@Override |
186 |
protected AbstractButton[] createButtons() { |
187 |
final FindDialogMemory memory = FindDialogMemory.getDefault(); |
139 |
final FindDialogMemory memory = FindDialogMemory.getDefault(); |
188 |
treeViewButton = new JToggleButton(); |
140 |
btnTreeView = new JToggleButton(); |
189 |
treeViewButton.setEnabled(true); |
141 |
btnTreeView.setEnabled(true); |
190 |
treeViewButton.setIcon(ImageUtilities.loadImageIcon(FOLDER_VIEW_ICON, |
142 |
btnTreeView.setIcon(ImageUtilities.loadImageIcon(FOLDER_VIEW_ICON, |
191 |
true)); |
143 |
true)); |
192 |
treeViewButton.setToolTipText(UiUtils.getText( |
144 |
btnTreeView.setToolTipText(UiUtils.getText( |
193 |
"TEXT_BUTTON_TREE_VIEW")); //NOI18N |
145 |
"TEXT_BUTTON_TREE_VIEW")); //NOI18N |
194 |
treeViewButton.setSelected( |
146 |
btnTreeView.setSelected( |
195 |
MODE_TREE.equals(memory.getResultsViewMode())); |
147 |
MODE_TREE.equals(memory.getResultsViewMode())); |
196 |
treeViewButton.addActionListener(new ActionListener() { |
148 |
btnTreeView.addActionListener(new ActionListener() { |
197 |
@Override |
149 |
@Override |
198 |
public void actionPerformed(ActionEvent e) { |
150 |
public void actionPerformed(ActionEvent e) { |
199 |
toggleView(!treeViewButton.isSelected()); |
151 |
toggleView(!btnTreeView.isSelected()); |
200 |
} |
152 |
} |
201 |
}); |
153 |
}); |
202 |
flatViewButton = new JToggleButton(); |
154 |
btnFlatView = new JToggleButton(); |
203 |
flatViewButton.setEnabled(true); |
155 |
btnFlatView.setEnabled(true); |
204 |
flatViewButton.setIcon(ImageUtilities.loadImageIcon(FLAT_VIEW_ICON, |
156 |
btnFlatView.setIcon(ImageUtilities.loadImageIcon(FLAT_VIEW_ICON, |
205 |
true)); |
157 |
true)); |
206 |
flatViewButton.setToolTipText(UiUtils.getText( |
158 |
btnFlatView.setToolTipText(UiUtils.getText( |
207 |
"TEXT_BUTTON_FLAT_VIEW")); //NOI18N |
159 |
"TEXT_BUTTON_FLAT_VIEW")); //NOI18N |
208 |
flatViewButton.setSelected(!treeViewButton.isSelected()); |
160 |
btnFlatView.setSelected(!btnTreeView.isSelected()); |
209 |
flatViewButton.addActionListener(new ActionListener() { |
161 |
btnFlatView.addActionListener(new ActionListener() { |
210 |
@Override |
162 |
@Override |
211 |
public void actionPerformed(ActionEvent e) { |
163 |
public void actionPerformed(ActionEvent e) { |
212 |
toggleView(flatViewButton.isSelected()); |
164 |
toggleView(btnFlatView.isSelected()); |
213 |
} |
165 |
} |
214 |
}); |
166 |
}); |
|
|
167 |
addButton(btnTreeView); |
168 |
addButton(btnFlatView); |
215 |
if (!details) { |
169 |
if (!details) { |
216 |
return new AbstractButton[]{treeViewButton, flatViewButton}; |
170 |
btnPrev.setVisible(false); |
|
|
171 |
btnNext.setVisible(false); |
172 |
btnExpand.setVisible(false); |
173 |
return; |
217 |
} |
174 |
} |
218 |
prevButton = new JButton(); |
175 |
btnExpand.addActionListener(new ActionListener() { |
219 |
prevButton.setEnabled(false); |
|
|
220 |
prevButton.setIcon(ImageUtilities.loadImageIcon(PREV_ICON, true)); |
221 |
prevButton.setToolTipText(UiUtils.getText( |
222 |
"TEXT_BUTTON_PREV_MATCH")); //NOI18N |
223 |
prevButton.addActionListener(new ActionListener() { |
224 |
@Override |
176 |
@Override |
225 |
public void actionPerformed(ActionEvent e) { |
177 |
public void actionPerformed(ActionEvent e) { |
226 |
shift(-1); |
178 |
toggleExpandNodeChildren(btnExpand.isSelected()); |
227 |
} |
|
|
228 |
}); |
229 |
nextButton = new JButton(); |
230 |
nextButton.setEnabled(false); |
231 |
nextButton.setIcon(ImageUtilities.loadImageIcon(NEXT_ICON, true)); |
232 |
nextButton.setToolTipText(UiUtils.getText( |
233 |
"TEXT_BUTTON_NEXT_MATCH")); //NOI18N |
234 |
nextButton.addActionListener(new ActionListener() { |
235 |
@Override |
236 |
public void actionPerformed(ActionEvent e) { |
237 |
shift(1); |
238 |
} |
239 |
}); |
240 |
expandButton = new JToggleButton(); |
241 |
expandButton.setEnabled(false); |
242 |
expandButton.setIcon(ImageUtilities.loadImageIcon(EXPAND_ICON, true)); |
243 |
expandButton.setSelectedIcon(ImageUtilities.loadImageIcon( |
244 |
COLLAPSE_ICON, true)); |
245 |
expandButton.setToolTipText(UiUtils.getText( |
246 |
"TEXT_BUTTON_EXPAND")); //NOI18N |
247 |
expandButton.setSelected(false); |
248 |
expandButton.addActionListener(new ActionListener() { |
249 |
@Override |
250 |
public void actionPerformed(ActionEvent e) { |
251 |
toggleExpandNodeChildren(expandButton.isSelected()); |
252 |
} |
179 |
} |
253 |
}); |
180 |
}); |
254 |
showDetailsButton = new JButton(); |
181 |
showDetailsButton = new JButton(); |
Lines 263-276
Link Here
|
263 |
fillOutput(); |
190 |
fillOutput(); |
264 |
} |
191 |
} |
265 |
}); |
192 |
}); |
266 |
if (showDetailsButton != null) { |
193 |
showDetailsButton.getAccessibleContext().setAccessibleDescription( |
267 |
showDetailsButton.getAccessibleContext().setAccessibleDescription( |
194 |
NbBundle.getMessage(ResultView.class, |
268 |
NbBundle.getMessage(ResultView.class, |
195 |
"ACS_TEXT_BUTTON_FILL")); //NOI18N |
269 |
"ACS_TEXT_BUTTON_FILL")); //NOI18N |
196 |
addButton(showDetailsButton); |
270 |
} |
|
|
271 |
return new AbstractButton[]{prevButton, nextButton, |
272 |
treeViewButton, flatViewButton, expandButton, |
273 |
showDetailsButton}; |
274 |
} |
197 |
} |
275 |
|
198 |
|
276 |
private void toggleView(boolean flat) { |
199 |
private void toggleView(boolean flat) { |
Lines 282-289
Link Here
|
282 |
resultsOutlineSupport.setFolderTreeMode(); |
205 |
resultsOutlineSupport.setFolderTreeMode(); |
283 |
memory.setResultsViewMode(MODE_TREE); |
206 |
memory.setResultsViewMode(MODE_TREE); |
284 |
} |
207 |
} |
285 |
treeViewButton.setSelected(!flat); |
208 |
btnTreeView.setSelected(!flat); |
286 |
flatViewButton.setSelected(flat); |
209 |
btnFlatView.setSelected(flat); |
287 |
try { |
210 |
try { |
288 |
getExplorerManager().setSelectedNodes(new Node[]{ |
211 |
getExplorerManager().setSelectedNodes(new Node[]{ |
289 |
resultsOutlineSupport.getResultsNode()}); |
212 |
resultsOutlineSupport.getResultsNode()}); |
Lines 312-445
Link Here
|
312 |
bundle.getString("ACSD_ResultTree")); //NOI18N |
235 |
bundle.getString("ACSD_ResultTree")); //NOI18N |
313 |
} |
236 |
} |
314 |
|
237 |
|
315 |
private void shift(int direction) { |
|
|
316 |
|
317 |
Node next = findShiftNode(direction, getOutlineView(), true); |
318 |
if (next == null) { |
319 |
return; |
320 |
} |
321 |
try { |
322 |
getExplorerManager().setSelectedNodes(new Node[]{next}); |
323 |
TextDetail textDetail = next.getLookup().lookup( |
324 |
TextDetail.class); |
325 |
if (textDetail != null) { |
326 |
textDetail.showDetail(TextDetail.DH_GOTO); |
327 |
} |
328 |
} catch (PropertyVetoException ex) { |
329 |
Exceptions.printStackTrace(ex); |
330 |
} |
331 |
} |
332 |
|
333 |
private Node findShiftNode(int direction, OutlineView outlineView, |
334 |
boolean canExpand) { |
335 |
Node[] selected = getExplorerManager().getSelectedNodes(); |
336 |
Node n = null; |
337 |
if ((selected == null || selected.length == 0) |
338 |
&& getExplorerManager().getRootContext() |
339 |
== resultsOutlineSupport.getRootNode()) { |
340 |
n = resultsOutlineSupport.getResultsNode(); |
341 |
} else if (selected.length == 1) { |
342 |
n = selected[0]; |
343 |
} |
344 |
return n == null ? null : findTextDetailNode(n, direction, outlineView, |
345 |
canExpand); |
346 |
} |
347 |
|
348 |
static Node findTextDetailNode(Node fromNode, int direction, |
349 |
OutlineView outlineView, boolean canExpand) { |
350 |
return findUp(fromNode, direction, |
351 |
isTextDetailNode(fromNode) || direction < 0 ? direction : 0, |
352 |
outlineView, canExpand); |
353 |
} |
354 |
|
355 |
/** |
356 |
* Start finding for next or previous occurance, from a node or its previous |
357 |
* or next sibling of node {@code node} |
358 |
* |
359 |
* @param node reference node |
360 |
* @param offset 0 to start from node {@code node}, 1 to start from its next |
361 |
* sibling, -1 to start from its previous sibling. |
362 |
* @param dir Direction: 1 for next, -1 for previous. |
363 |
*/ |
364 |
static Node findUp(Node node, int dir, int offset, OutlineView outlineView, |
365 |
boolean canExpand) { |
366 |
if (node == null) { |
367 |
return null; |
368 |
} |
369 |
Node parent = node.getParentNode(); |
370 |
Node[] siblings; |
371 |
if (parent == null) { |
372 |
siblings = new Node[]{node}; |
373 |
} else { |
374 |
siblings = getChildren(parent, outlineView, canExpand); |
375 |
} |
376 |
int nodeIndex = findChildIndex(node, siblings); |
377 |
if (nodeIndex + offset < 0 || nodeIndex + offset >= siblings.length) { |
378 |
return findUp(parent, dir, dir, outlineView, canExpand); |
379 |
} |
380 |
for (int i = nodeIndex + offset; |
381 |
i >= 0 && i < siblings.length; i += dir) { |
382 |
Node found = findDown(siblings[i], siblings, i, dir, outlineView, |
383 |
canExpand); |
384 |
return found; |
385 |
} |
386 |
return findUp(parent, dir, offset, outlineView, canExpand); |
387 |
} |
388 |
|
389 |
/** |
390 |
* Find Depth-first search to find TextDetail node in the subtree. |
391 |
*/ |
392 |
private static Node findDown(Node node, Node[] siblings, int nodeIndex, |
393 |
int dir, OutlineView outlineView, boolean canExpand) { |
394 |
|
395 |
Node[] children = getChildren(node, outlineView, canExpand); |
396 |
for (int i = dir > 0 ? 0 : children.length - 1; |
397 |
i >= 0 && i < children.length; i += dir) { |
398 |
Node found = findDown(children[i], children, i, dir, outlineView, |
399 |
canExpand); |
400 |
if (found != null) { |
401 |
return found; |
402 |
} |
403 |
} |
404 |
for (int i = nodeIndex; i >= 0 && i < siblings.length; i += dir) { |
405 |
if (isTextDetailNode(siblings[i])) { |
406 |
return siblings[i]; |
407 |
} |
408 |
} |
409 |
return null; |
410 |
} |
411 |
|
412 |
private static boolean isTextDetailNode(Node n) { |
413 |
return n.getLookup().lookup(TextDetail.class) != null; |
414 |
} |
415 |
|
416 |
private static int findChildIndex(Node selectedNode, Node[] siblings) { |
417 |
int pos = -1; |
418 |
for (int i = 0; i < siblings.length; i++) { |
419 |
if (siblings[i] == selectedNode) { |
420 |
pos = i; |
421 |
break; |
422 |
} |
423 |
} |
424 |
return pos; |
425 |
} |
426 |
|
427 |
private static Node[] getChildren(Node n, OutlineView outlineView, |
428 |
boolean canExpand) { |
429 |
if (outlineView != null) { |
430 |
if (!outlineView.isExpanded(n)) { |
431 |
if (canExpand) { |
432 |
outlineView.expandNode(n); |
433 |
} else { |
434 |
return n.getChildren().getNodes(true); |
435 |
} |
436 |
} |
437 |
return getChildrenInDisplayedOrder(n, outlineView); |
438 |
} else { |
439 |
return n.getChildren().getNodes(true); |
440 |
} |
441 |
} |
442 |
|
443 |
private void toggleExpandNodeChildren(boolean expand) { |
238 |
private void toggleExpandNodeChildren(boolean expand) { |
444 |
Node resultsNode = resultsOutlineSupport.getResultsNode(); |
239 |
Node resultsNode = resultsOutlineSupport.getResultsNode(); |
445 |
for (Node n : resultsNode.getChildren().getNodes()) { |
240 |
for (Node n : resultsNode.getChildren().getNodes()) { |
Lines 447-464
Link Here
|
447 |
} |
242 |
} |
448 |
} |
243 |
} |
449 |
|
244 |
|
450 |
public void toggleExpand(Node root, boolean expand) { |
|
|
451 |
if (expand) { |
452 |
getOutlineView().expandNode(root); |
453 |
} |
454 |
for (Node n : root.getChildren().getNodes()) { |
455 |
toggleExpand(n, expand); |
456 |
} |
457 |
if (!expand) { |
458 |
getOutlineView().collapseNode(root); |
459 |
} |
460 |
} |
461 |
|
462 |
@Override |
245 |
@Override |
463 |
public void searchFinished() { |
246 |
public void searchFinished() { |
464 |
super.searchFinished(); |
247 |
super.searchFinished(); |
Lines 480-485
Link Here
|
480 |
public void addMatchingObject(MatchingObject mo) { |
263 |
public void addMatchingObject(MatchingObject mo) { |
481 |
resultsOutlineSupport.addMatchingObject(mo); |
264 |
resultsOutlineSupport.addMatchingObject(mo); |
482 |
updateRootNodeText(); |
265 |
updateRootNodeText(); |
|
|
266 |
afterMatchingNodeAdded(); |
483 |
} |
267 |
} |
484 |
|
268 |
|
485 |
public final OutlineView getOutlineView() { |
269 |
public final OutlineView getOutlineView() { |
Lines 552-624
Link Here
|
552 |
} |
336 |
} |
553 |
} |
337 |
} |
554 |
|
338 |
|
555 |
private static Node[] getChildrenInDisplayedOrder(Node parent, |
|
|
556 |
OutlineView outlineView) { |
557 |
|
558 |
Outline outline = outlineView.getOutline(); |
559 |
Node[] unsortedChildren = parent.getChildren().getNodes(true); |
560 |
int rows = outlineView.getOutline().getRowCount(); |
561 |
int start = findRowIndexInOutline(parent, outline, rows); |
562 |
if (start == -1) { |
563 |
return unsortedChildren; |
564 |
} |
565 |
List<Node> children = new LinkedList<Node>(); |
566 |
for (int j = start + 1; j < rows; j++) { |
567 |
int childModelIndex = outline.convertRowIndexToModel(j); |
568 |
if (childModelIndex == -1) { |
569 |
continue; |
570 |
} |
571 |
Object childObject = outline.getModel().getValueAt( |
572 |
childModelIndex, 0); |
573 |
Node childNode = Visualizer.findNode(childObject); |
574 |
if (childNode.getParentNode() == parent) { |
575 |
children.add(childNode); |
576 |
} else if (children.size() == unsortedChildren.length) { |
577 |
break; |
578 |
} |
579 |
} |
580 |
return children.toArray(new Node[children.size()]); |
581 |
} |
582 |
|
583 |
private static int findRowIndexInOutline(Node node, Outline outline, |
584 |
int rows) { |
585 |
|
586 |
int startRow = Math.max(outline.getSelectedRow(), 0); |
587 |
int offset = 0; |
588 |
while (startRow + offset < rows || startRow - offset >= 0) { |
589 |
int up = startRow + offset + 1; |
590 |
int down = startRow - offset; |
591 |
|
592 |
if (up < rows && testNodeInRow(outline, node, up)) { |
593 |
return up; |
594 |
} else if (down >= 0 && testNodeInRow(outline, node, down)) { |
595 |
return down; |
596 |
} else { |
597 |
offset++; |
598 |
} |
599 |
} |
600 |
return -1; |
601 |
} |
602 |
|
603 |
private static boolean testNodeInRow(Outline outline, Node node, int i) { |
604 |
int modelIndex = outline.convertRowIndexToModel(i); |
605 |
if (modelIndex != -1) { |
606 |
Object o = outline.getModel().getValueAt(modelIndex, 0); |
607 |
Node n = Visualizer.findNode(o); |
608 |
if (n == node) { |
609 |
return true; |
610 |
} |
611 |
} |
612 |
return false; |
613 |
} |
614 |
|
615 |
private void initResultNodeAdditionListener() { |
339 |
private void initResultNodeAdditionListener() { |
616 |
resultsNodeAdditionListener = new NodeAdapter() { |
340 |
resultsNodeAdditionListener = new NodeAdapter() { |
617 |
@Override |
341 |
@Override |
618 |
public void childrenAdded(NodeMemberEvent ev) { |
342 |
public void childrenAdded(NodeMemberEvent ev) { |
619 |
if (expandButton != null) { |
343 |
if (btnExpand != null) { |
620 |
for (final Node n : ev.getDelta()) { |
344 |
for (final Node n : ev.getDelta()) { |
621 |
if (expandButton.isSelected()) { |
345 |
if (btnExpand.isSelected()) { |
622 |
EventQueue.invokeLater(new Runnable() { |
346 |
EventQueue.invokeLater(new Runnable() { |
623 |
@Override |
347 |
@Override |
624 |
public void run() { |
348 |
public void run() { |
Lines 633-639
Link Here
|
633 |
|
357 |
|
634 |
@Override |
358 |
@Override |
635 |
public void childrenRemoved(NodeMemberEvent ev) { |
359 |
public void childrenRemoved(NodeMemberEvent ev) { |
636 |
if (expandButton != null) { |
360 |
if (btnExpand != null) { |
637 |
for (Node removedChild : ev.getDelta()) { |
361 |
for (Node removedChild : ev.getDelta()) { |
638 |
removeChildAdditionListener(removedChild); |
362 |
removeChildAdditionListener(removedChild); |
639 |
} |
363 |
} |
Lines 660-680
Link Here
|
660 |
removedNode.removeNodeListener(resultsNodeAdditionListener); |
384 |
removedNode.removeNodeListener(resultsNodeAdditionListener); |
661 |
} |
385 |
} |
662 |
|
386 |
|
663 |
private final class PrevNextAction extends javax.swing.AbstractAction { |
|
|
664 |
|
665 |
private int direction; |
666 |
|
667 |
public PrevNextAction(int direction) { |
668 |
this.direction = direction; |
669 |
} |
670 |
|
671 |
public void actionPerformed(java.awt.event.ActionEvent actionEvent) { |
672 |
shift(direction); |
673 |
} |
674 |
} |
675 |
|
676 |
@Override |
387 |
@Override |
677 |
public boolean requestFocusInWindow() { |
388 |
public boolean requestFocusInWindow() { |
678 |
return getOutlineView().requestFocusInWindow(); |
389 |
return getOutlineView().requestFocusInWindow(); |
679 |
} |
390 |
} |
|
|
391 |
|
392 |
@Override |
393 |
protected boolean isDetailNode(Node n) { |
394 |
return n.getLookup().lookup(TextDetail.class) != null; |
395 |
} |
396 |
|
397 |
@Override |
398 |
protected void onDetailShift(Node next) { |
399 |
TextDetail textDetail = next.getLookup().lookup( |
400 |
TextDetail.class); |
401 |
if (textDetail != null) { |
402 |
textDetail.showDetail(TextDetail.DH_GOTO); |
403 |
} |
404 |
} |
680 |
} |
405 |
} |