Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

2 changed files:

Changes:

  • client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/ObserveNavigationTreeShowPopupAction.java
    ... ... @@ -112,41 +112,53 @@ public class ObserveNavigationTreeShowPopupAction {
    112 112
     
    
    113 113
             boolean rightClick = SwingUtilities.isRightMouseButton(e);
    
    114 114
     
    
    115
    -        if (rightClick) {
    
    116
    -
    
    117
    -            // get the coordinates of the mouse click
    
    118
    -            Point p = e.getPoint();
    
    115
    +        // get the coordinates of the mouse click
    
    116
    +        Point p = e.getPoint();
    
    119 117
     
    
    120
    -            int closestRowForLocation = tree.getClosestRowForLocation(e.getX(), e.getY());
    
    118
    +        int closestRowForLocation = tree.getClosestRowForLocation(e.getX(), e.getY());
    
    121 119
     
    
    122
    -            int rowToSelect = -1;
    
    120
    +        int rowToSelect = -1;
    
    123 121
     
    
    124
    -            if (isRowSelected(closestRowForLocation)) {
    
    122
    +        if (isRowSelected(closestRowForLocation)) {
    
    125 123
     
    
    126
    -                rowToSelect = closestRowForLocation;
    
    127
    -            }
    
    128
    -
    
    129
    -            if (rowToSelect == -1) {
    
    130
    -
    
    131
    -                // try to change selection
    
    124
    +            rowToSelect = closestRowForLocation;
    
    125
    +        }
    
    132 126
     
    
    133
    -                TreePath pathForRow = tree.getPathForRow(closestRowForLocation);
    
    134
    -                tree.setSelectionPath(pathForRow);
    
    127
    +        if (rowToSelect == -1) {
    
    135 128
     
    
    136
    -                if (isRowSelected(closestRowForLocation)) {
    
    129
    +            // try to change selection
    
    137 130
     
    
    138
    -                    rowToSelect = closestRowForLocation;
    
    139
    -                }
    
    131
    +            TreePath pathForRow = tree.getPathForRow(closestRowForLocation);
    
    132
    +            tree.setSelectionPath(pathForRow);
    
    140 133
     
    
    134
    +            if (isRowSelected(closestRowForLocation)) {
    
    135
    +                rowToSelect = closestRowForLocation;
    
    141 136
                 }
    
    142 137
     
    
    143
    -            if (rowToSelect != -1) {
    
    144
    -
    
    145
    -                showPopup(rowToSelect, p);
    
    146
    -
    
    138
    +        } else {
    
    139
    +            TreePath pathForRow = tree.getPathForRow(rowToSelect);
    
    140
    +
    
    141
    +            Rectangle pathBounds = tree.getPathBounds(pathForRow);
    
    142
    +            if (e.getClickCount() == 2 && pathBounds != null && !pathBounds.contains(e.getPoint())) {
    
    143
    +                SwingUtilities.invokeLater(() -> {
    
    144
    +                    if (tree.isExpanded(pathForRow)) {
    
    145
    +                        tree.collapsePath(pathForRow);
    
    146
    +                    } else {
    
    147
    +                        tree.expandPath(pathForRow);
    
    148
    +                    }
    
    149
    +                });
    
    150
    +                e.consume();
    
    151
    +                return;
    
    147 152
                 }
    
    148 153
     
    
    149 154
             }
    
    155
    +        if (rowToSelect != -1) {
    
    156
    +            return;
    
    157
    +        }
    
    158
    +
    
    159
    +        if (rightClick) {
    
    160
    +            showPopup(rowToSelect, p);
    
    161
    +        }
    
    150 162
         }
    
    151 163
     
    
    152 164
         private void openNodeMenu(KeyEvent e) {
    

  • client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/tree/navigation/NavigationTreeCellRenderer.java
    ... ... @@ -49,6 +49,7 @@ public class NavigationTreeCellRenderer extends DefaultTreeRenderer {
    49 49
                     defaultVisuals.setForeground(value.getColor());
    
    50 50
                 }
    
    51 51
                 super.configureVisuals(context);
    
    52
    +            rendererComponent.setBorder(null);
    
    52 53
             }
    
    53 54
     
    
    54 55
         }