diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-05-20 17:58:16 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-05-20 17:58:16 -0400 |
| commit | 40a9d99496e098562f090fb7ffce9e749011b131 (patch) | |
| tree | 437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java | |
| parent | ff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff) | |
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java')
| -rw-r--r-- | projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java | 239 |
1 files changed, 100 insertions, 139 deletions
diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java index 624dc37..68740b4 100644 --- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java +++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java @@ -12,161 +12,122 @@ 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 -{ + * 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() - { + + 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 ); + + 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") ); + /** + * Creates a new folder. + */ + protected class NewFolderAction extends AbstractAction { + protected NewFolderAction() { + super("New Folder", UIManager.getIcon("FileChooser.newFolderIcon")); } - public void actionPerformed(ActionEvent e) - { + + public void actionPerformed(ActionEvent e) { } } - /** - * Responds to an Open or Save request - */ - protected class ApproveSelectionAction extends AbstractAction { - 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")); } - } - - /** - * Responds to a cancel request. - */ - protected class CancelSelectionAction extends AbstractAction { - public void actionPerformed(ActionEvent e) - { + public void actionPerformed(ActionEvent e) { } - } - - /** - * Rescans the files in the current directory - */ - protected class UpdateAction extends AbstractAction { - public void actionPerformed(ActionEvent e) - { + } + + protected class ChangeToParentDirectoryAction extends AbstractAction { + protected ChangeToParentDirectoryAction() { + super("Go Up", UIManager.getIcon("FileChooser.upFolderIcon")); } - } - - // - // 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; + + public void actionPerformed(ActionEvent e) { } - } - - 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); + } + + /** + * Responds to an Open or Save request + */ + protected class ApproveSelectionAction extends AbstractAction { + public void actionPerformed(ActionEvent e) { } - - public int getIconWidth() { - return icon.getIconWidth() + depth*space; + } + + /** + * Responds to a cancel request. + */ + protected class CancelSelectionAction extends AbstractAction { + public void actionPerformed(ActionEvent e) { } - - public int getIconHeight() { - return icon.getIconHeight(); + } + + /** + * 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(); } + * + * } + */ } |
