3599
|
1 |
/***************************************************************************
|
|
2 |
Title: GraphBrowser/TreeBrowser.java
|
|
3 |
ID: $Id$
|
|
4 |
Author: Stefan Berghofer, TU Muenchen
|
|
5 |
Copyright 1997 TU Muenchen
|
|
6 |
|
|
7 |
This class defines the browser window which is used to display directory
|
|
8 |
trees. It contains methods for handling events.
|
|
9 |
***************************************************************************/
|
|
10 |
|
|
11 |
package GraphBrowser;
|
|
12 |
|
|
13 |
import java.awt.*;
|
|
14 |
import awtUtilities.ScrollCanvas;
|
|
15 |
import java.util.*;
|
|
16 |
|
|
17 |
|
|
18 |
public class TreeBrowser extends ScrollCanvas
|
|
19 |
{
|
|
20 |
TreeNode t;
|
|
21 |
TreeNode selected;
|
|
22 |
GraphView gv;
|
|
23 |
long timestamp;
|
|
24 |
|
|
25 |
public TreeBrowser(TreeNode tn,GraphView gr) {
|
|
26 |
t=tn;gv=gr;
|
|
27 |
}
|
|
28 |
|
|
29 |
public boolean mouseDown(Event e,int x,int y)
|
|
30 |
{
|
|
31 |
TreeNode l=t.lookup(y);
|
|
32 |
|
|
33 |
if (l!=null)
|
|
34 |
{
|
|
35 |
if (l.select()) {
|
|
36 |
Vector v=new Vector(10,10);
|
|
37 |
t.collapsedDirectories(v);
|
|
38 |
gv.collapseDir(v);
|
|
39 |
gv.relayout();
|
|
40 |
} else {
|
|
41 |
Vertex vx=gv.getGraph().getVertexByNum(l.getNumber());
|
|
42 |
gv.focusToVertex(l.getNumber());
|
|
43 |
vx=gv.getOriginalGraph().getVertexByNum(l.getNumber());
|
|
44 |
if (e.when-timestamp < 400 && !(vx.getPath().equals("")))
|
|
45 |
gv.getBrowser().viewFile(vx.getPath());
|
|
46 |
timestamp=e.when;
|
|
47 |
|
|
48 |
}
|
|
49 |
selected=l;repaint();
|
|
50 |
|
|
51 |
}
|
|
52 |
return true;
|
|
53 |
}
|
|
54 |
|
|
55 |
public void selectNode(TreeNode nd) {
|
|
56 |
Vector v=new Vector(10,10);
|
|
57 |
nd.select();
|
|
58 |
t.collapsedDirectories(v);
|
|
59 |
gv.collapseDir(v);
|
|
60 |
gv.relayout();
|
|
61 |
selected=nd;repaint();
|
|
62 |
}
|
|
63 |
|
|
64 |
public void paintCanvas(Graphics g)
|
|
65 |
{
|
|
66 |
Dimension d=t.draw(g,5,5,selected);
|
|
67 |
set_size(5+d.width,5+d.height);
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|