Changeset 9109
- Timestamp:
- 2005-02-18T15:02:04+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r9072 r9109 1449 1449 this.tree = collection_tree; 1450 1450 1451 // Get the paths currently selected in the tree 1452 selection_paths = tree.getSelectionPaths(); 1451 // Note we have to use setImmediate() with the set selction paths 1452 // otherwise the selection doesn't get updated until after the 1453 // popup comes up. 1454 1455 // the right click position 1456 TreePath right_click_path = tree.getPathForLocation(event.getX(), event.getY()); 1457 if (right_click_path == null) { 1458 // user has clicked outside of the tree, clear the selection 1459 selection_paths = null; 1460 tree.setImmediate(true); 1461 tree.clearSelection(); 1462 tree.setImmediate(false); 1463 } else { 1464 // Get the paths currently selected in the tree 1465 selection_paths = tree.getSelectionPaths(); 1466 if (selection_paths == null) { 1467 // nothing currently selected - we shift the selection to 1468 // the node that was right clicked on 1469 selection_paths = new TreePath[1]; 1470 selection_paths[0] = right_click_path; 1471 tree.setImmediate(true); 1472 tree.setSelectionPath(right_click_path); 1473 tree.setImmediate(false); 1474 } else if (selection_paths.length == 1 && ! selection_paths[0].equals( right_click_path)) { 1475 tree.setImmediate(true); 1476 tree.clearSelection(); 1477 tree.setSelectionPath(right_click_path); 1478 tree.setImmediate(false); 1479 selection_paths[0] = right_click_path; 1480 } else { 1481 // we had multiply selected paths in the tree. 1482 // if we clicked on one of those paths, then use all the 1483 // current selection, otherwise clear the selection and 1484 // select the one we right clicked on 1485 boolean clicked_in_selection = false; 1486 for (int i=0; i<selection_paths.length; i++) { 1487 if (selection_paths[i].equals(right_click_path)) { 1488 clicked_in_selection = true; 1489 break; 1490 } 1491 } 1492 if (!clicked_in_selection) { 1493 // want the tree to update right away 1494 tree.setImmediate(true); 1495 tree.clearSelection(); 1496 tree.setSelectionPath(right_click_path); 1497 tree.setImmediate(false); 1498 selection_paths = new TreePath[1]; 1499 selection_paths[0] = right_click_path; 1500 } 1501 } 1502 } 1503 // finally we have the correct selection paths!! 1453 1504 1454 1505 // Create an appropriate context menu, based on what is selected
Note:
See TracChangeset
for help on using the changeset viewer.