1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
package net.wotonomy.test;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import net.wotonomy.ui.swing.components.ButtonPanel;
import net.wotonomy.ui.swing.components.TreeChooser;
/**
* BindingPanel is a FileChooser-like panel that uses a TreeModel as a data
* source. It basically provides an alternative to JTree for rendering and
* manipulating tree-like data.
*/
public class BindingPanel extends JPanel {
protected TreeChooser treeChooser;
protected ButtonPanel okPanel;
public BindingPanel() {
init();
}
protected void init() {
this.setBorder(new EmptyBorder(10, 10, 10, 10));
this.setLayout(new BorderLayout(10, 10));
this.add(treeChooser = new TreeChooser(), BorderLayout.CENTER);
okPanel = new ButtonPanel(new String[] { "OK", "Cancel" });
this.add(okPanel, BorderLayout.SOUTH);
}
/**
* Creates a new folder.
*/
protected class NewFolderAction extends AbstractAction {
protected NewFolderAction() {
super("New Folder", UIManager.getIcon("FileChooser.newFolderIcon"));
}
public void actionPerformed(ActionEvent e) {
}
}
/**
* Acts on the "home" key event or equivalent event.
*/
protected class GoHomeAction extends AbstractAction {
protected GoHomeAction() {
super("Go Home", UIManager.getIcon("FileChooser.homeFolderIcon"));
}
public void actionPerformed(ActionEvent e) {
}
}
protected class ChangeToParentDirectoryAction extends AbstractAction {
protected ChangeToParentDirectoryAction() {
super("Go Up", UIManager.getIcon("FileChooser.upFolderIcon"));
}
public void actionPerformed(ActionEvent e) {
}
}
/**
* Responds to an Open or Save request
*/
protected class ApproveSelectionAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
}
}
/**
* Responds to a cancel request.
*/
protected class CancelSelectionAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
}
}
/**
* Rescans the files in the current directory
*/
protected class UpdateAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
}
}
//
// Renderer for DirectoryComboBox
//
/*
* class DirectoryComboBoxRenderer extends DefaultListCellRenderer { IndentIcon
* ii = new IndentIcon(); public Component getListCellRendererComponent(JList
* list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
*
* super.getListCellRendererComponent(list, value, index, isSelected,
* cellHasFocus); File directory = (File) value; if(directory == null) {
* setText(""); return this; }
*
* String fileName = getFileChooser().getName(directory); setText(fileName);
*
* // Find the depth of the directory int depth = 0; if(index != -1) { File f =
* directory; while(f.getParent() != null) { depth++; f =
* getFileChooser().getFileSystemView().createFileObject( f.getParent() ); } }
*
* Icon icon = getFileChooser().getIcon(directory);
*
* ii.icon = icon; ii.depth = depth;
*
* setIcon(ii);
*
* return this; } }
*
* final static int space = 10; class IndentIcon implements Icon {
*
* Icon icon = null; int depth = 0;
*
* public void paintIcon(Component c, Graphics g, int x, int y) {
* icon.paintIcon(c, g, x+depth*space, y); }
*
* public int getIconWidth() { return icon.getIconWidth() + depth*space; }
*
* public int getIconHeight() { return icon.getIconHeight(); }
*
* }
*/
}
|