Skip to content

Commit

Permalink
Attempt to fix auto scroll on tree selection sync (still a bit buggy)
Browse files Browse the repository at this point in the history
+ Added screenshots
  • Loading branch information
nanawel committed Aug 7, 2013
1 parent 3f02f17 commit af845e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Binary file added docs/Screenshot-JDuplicateFinder-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Screenshot-JDuplicateFinder-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Screenshot-JDuplicateFinder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 13 additions & 8 deletions src/nnwl/jduplicatefinder/ui/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -961,9 +962,9 @@ private class ResultsTreeSelectionListener implements TreeSelectionListener
{
@Override
public void valueChanged(TreeSelectionEvent e) {
ResultsTree sourceTree = (ResultsTree) e.getSource();
ResultsTree otherTree = this.getOtherTree(sourceTree);
JScrollPane otherScrollPane = this.getOtherScrollpane(sourceTree);
final ResultsTree sourceTree = (ResultsTree) e.getSource();
final ResultsTree otherTree = this.getOtherTree(sourceTree);
//final JScrollPane otherScrollPane = this.getOtherScrollpane(sourceTree);

DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) sourceTree.getLastSelectedPathComponent();
if (selectedNode == null) {
Expand All @@ -982,12 +983,16 @@ else if (selectedNode.getUserObject() instanceof SimilarityResult) {

DefaultMutableTreeNode similarFileNode = App.this.treeModel.getNodeFromPath(similarFile);

TreePath path = new TreePath(similarFileNode.getPath());
final TreePath path = new TreePath(similarFileNode.getPath());
otherTree.collapse();
otherTree.setSelectionPath(path);
otherTree.expandPath(path);

otherScrollPane.getViewport().scrollRectToVisible(otherTree.getPathBounds(path));
// Scroll to that node
// TODO Improve that
Rectangle bounds = otherTree.getPathBounds(path);
bounds.height = otherTree.getVisibleRect().height;
otherTree.scrollRectToVisible(bounds);
}
else {
App.this.fileInfoPanel.clear();
Expand All @@ -998,8 +1003,8 @@ private ResultsTree getOtherTree(ResultsTree t) {
return App.this.treeLeft == t ? App.this.treeRight : App.this.treeLeft;
}

private JScrollPane getOtherScrollpane(ResultsTree t) {
return App.this.treeLeft == t ? App.this.scrollPaneRight : App.this.scrollPaneLeft;
}
// private JScrollPane getOtherScrollpane(ResultsTree t) {
// return App.this.treeLeft == t ? App.this.scrollPaneRight : App.this.scrollPaneLeft;
// }
}
}

0 comments on commit af845e6

Please sign in to comment.