src/com/netscape/admin/dirserv/DSContentPage.java | 42 +++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
New commits:
commit af957c5bdf0a68c60446fef2a5da42181c21b20f
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Sep 19 16:17:34 2014 -0400
Ticket 135 - DS console - right clicking an object does not select that object
Bug Description: "right" clicking an object in the suffix tree, or the
child
list on the right, does not select that object. This can
lead to accidental operations, e.g. deleting the entire suffix
when you only wanted to delete a user.
Fix Description: For the JTree(suffix trees) simply set the row from the mouse
location. For the Jlist (child list) we need to set the last
focused component to the JList so we can get the correct
child node.
https://fedorahosted.org/389/ticket/135
Reviewed by: rmeggins(Thanks!)
diff --git a/src/com/netscape/admin/dirserv/DSContentPage.java
b/src/com/netscape/admin/dirserv/DSContentPage.java
index 6de20a7..bb6de7b 100644
--- a/src/com/netscape/admin/dirserv/DSContentPage.java
+++ b/src/com/netscape/admin/dirserv/DSContentPage.java
@@ -984,12 +984,52 @@ implements IPage,
*/
public void mousePressed(MouseEvent e) {
if ((_contextMenu != null) && (e.isPopupTrigger())) {
+ //
+ // Allow the right click to select the object
+ //
+ int list_index = _list.locationToIndex(e.getPoint());
+ int row = _tree.getRowForLocation(e.getX(), e.getY());
+ boolean tree = false;
+ boolean list = false;
+
+ if (e.getSource() instanceof JTree){
+ tree = true;
+ }
+ if (e.getSource() instanceof JList){
+ list = true;
+ }
+ if(tree && row >= 0){
+ // Select the "clicked" tree node
+ _tree.setSelectionRow(row);
+ } else if (list && list_index >= 0){
+ // Things get a little trickier when dealing with the child list
+ if (_list.getCellBounds(list_index, list_index).contains(e.getPoint())){
+ // Select the "clicked" list node
+ _list.setSelectedIndex( list_index );
+ //
+ // Next, set the lastFocusComponent to the JList so we get the
proper
+ // node, otherwise it could be the JTree and that would be bad.
+ //
+ _lastFocusComponent = _list;
+ IBrowserNodeInfo node = getSelectedNodeInfo();
+ if (node != null) {
+ String dn = Helper.getNodeInfoDN(node);
+ if (dn == null || dn.equals("")) {
+ _selectedDnLabel.setText(NO_SELECTED_DN);
+ } else {
+ _selectedDnLabel.setText(findDisplayNameFromNode(node));
+ }
+ _menuController.updateMenuState();
+ }
+ }
+ }
+
if (_contextMenu.getComponentCount() > 0) {
Point p = _treePanel.getViewport().getViewPosition();
_contextMenu.show((Component)e.getSource(), e.getX() - p.x,
e.getY() - p.y);
}
- }
+ }
}
/**