summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/BindingPanel.java
diff options
context:
space:
mode:
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.java239
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(); }
+ *
+ * }
+ */
}