37 |
|
|
38 |
package javax.swing.plaf.basic; |
package javax.swing.plaf.basic; |
39 |
|
|
|
import java.awt.BorderLayout; |
|
40 |
import java.awt.Color; |
import java.awt.Color; |
41 |
import java.awt.Component; |
import java.awt.Component; |
|
import java.awt.Dimension; |
|
|
import java.awt.Graphics; |
|
|
import java.awt.GridBagConstraints; |
|
|
import java.awt.GridBagLayout; |
|
|
import java.awt.Point; |
|
|
import java.awt.Polygon; |
|
42 |
import java.awt.Window; |
import java.awt.Window; |
43 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
|
import java.awt.event.ItemEvent; |
|
|
import java.awt.event.ItemListener; |
|
44 |
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseAdapter; |
45 |
import java.awt.event.MouseEvent; |
import java.awt.event.MouseEvent; |
46 |
import java.awt.event.MouseListener; |
import java.awt.event.MouseListener; |
53 |
|
|
54 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
55 |
import javax.swing.Action; |
import javax.swing.Action; |
|
import javax.swing.ButtonGroup; |
|
56 |
import javax.swing.Icon; |
import javax.swing.Icon; |
57 |
import javax.swing.JButton; |
import javax.swing.JButton; |
|
import javax.swing.JComboBox; |
|
58 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
59 |
import javax.swing.JDialog; |
import javax.swing.JDialog; |
60 |
import javax.swing.JFileChooser; |
import javax.swing.JFileChooser; |
61 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
62 |
import javax.swing.JList; |
import javax.swing.JList; |
63 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
|
import javax.swing.JScrollPane; |
|
64 |
import javax.swing.JTextField; |
import javax.swing.JTextField; |
|
import javax.swing.JToggleButton; |
|
65 |
import javax.swing.ListCellRenderer; |
import javax.swing.ListCellRenderer; |
66 |
import javax.swing.SwingConstants; |
import javax.swing.SwingConstants; |
67 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
75 |
import javax.swing.filechooser.FileView; |
import javax.swing.filechooser.FileView; |
76 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
77 |
import javax.swing.plaf.FileChooserUI; |
import javax.swing.plaf.FileChooserUI; |
78 |
|
import javax.swing.plaf.metal.MetalIconFactory; |
79 |
|
|
80 |
|
|
81 |
/** |
/** |
133 |
*/ |
*/ |
134 |
protected ApproveSelectionAction() |
protected ApproveSelectionAction() |
135 |
{ |
{ |
136 |
// Nothing to do here. |
super("approveSelection"); |
137 |
} |
} |
138 |
|
|
139 |
/** |
/** |
143 |
*/ |
*/ |
144 |
public void actionPerformed(ActionEvent e) |
public void actionPerformed(ActionEvent e) |
145 |
{ |
{ |
146 |
Object obj = new String(parentPath + entry.getText()); |
Object obj = new String(parentPath + getFileName()); |
147 |
if (obj != null) |
if (obj != null) |
148 |
{ |
{ |
149 |
File f = filechooser.getFileSystemView().createFileObject( |
File f = filechooser.getFileSystemView().createFileObject( |
296 |
*/ |
*/ |
297 |
protected CancelSelectionAction() |
protected CancelSelectionAction() |
298 |
{ |
{ |
299 |
// Nothing to do here. |
super(null); |
300 |
} |
} |
301 |
|
|
302 |
/** |
/** |
324 |
*/ |
*/ |
325 |
protected ChangeToParentDirectoryAction() |
protected ChangeToParentDirectoryAction() |
326 |
{ |
{ |
327 |
// Nothing to do here. |
super("Go Up"); |
328 |
} |
} |
329 |
|
|
330 |
/** |
/** |
347 |
*/ |
*/ |
348 |
protected class DoubleClickListener extends MouseAdapter |
protected class DoubleClickListener extends MouseAdapter |
349 |
{ |
{ |
|
/** A timer. */ |
|
|
private Timer timer = null; |
|
350 |
|
|
351 |
/** DOCUMENT ME! */ |
/** DOCUMENT ME! */ |
352 |
private Object lastSelected = null; |
private Object lastSelected = null; |
362 |
public DoubleClickListener(JList list) |
public DoubleClickListener(JList list) |
363 |
{ |
{ |
364 |
this.list = list; |
this.list = list; |
|
timer = new Timer(1000, null); |
|
|
timer.setRepeats(false); |
|
365 |
lastSelected = list.getSelectedValue(); |
lastSelected = list.getSelectedValue(); |
366 |
setDirectorySelected(false); |
setDirectorySelected(false); |
367 |
} |
} |
376 |
if (list.getSelectedValue() == null) |
if (list.getSelectedValue() == null) |
377 |
return; |
return; |
378 |
FileSystemView fsv = filechooser.getFileSystemView(); |
FileSystemView fsv = filechooser.getFileSystemView(); |
379 |
if (timer.isRunning() |
if (e.getClickCount() >= 2 && |
380 |
&& list.getSelectedValue().toString().equals(lastSelected.toString())) |
list.getSelectedValue().toString().equals(lastSelected.toString())) |
381 |
{ |
{ |
382 |
File f = fsv.createFileObject(lastSelected.toString()); |
File f = fsv.createFileObject(lastSelected.toString()); |
|
timer.stop(); |
|
383 |
if (filechooser.isTraversable(f)) |
if (filechooser.isTraversable(f)) |
384 |
{ |
{ |
385 |
filechooser.setCurrentDirectory(f); |
filechooser.setCurrentDirectory(f); |
408 |
} |
} |
409 |
lastSelected = path; |
lastSelected = path; |
410 |
parentPath = path.substring(0, path.lastIndexOf("/") + 1); |
parentPath = path.substring(0, path.lastIndexOf("/") + 1); |
411 |
entry.setText(path.substring(path.lastIndexOf("/") + 1)); |
setFileName(path.substring(path.lastIndexOf("/") + 1)); |
|
timer.restart(); |
|
412 |
} |
} |
413 |
} |
} |
414 |
|
|
436 |
*/ |
*/ |
437 |
protected GoHomeAction() |
protected GoHomeAction() |
438 |
{ |
{ |
439 |
// Nothing to do here. |
super("Go Home"); |
440 |
} |
} |
441 |
|
|
442 |
/** |
/** |
466 |
*/ |
*/ |
467 |
protected NewFolderAction() |
protected NewFolderAction() |
468 |
{ |
{ |
469 |
// Nothing to do here. |
super("New Folder"); |
470 |
} |
} |
471 |
|
|
472 |
/** |
/** |
512 |
*/ |
*/ |
513 |
public void valueChanged(ListSelectionEvent e) |
public void valueChanged(ListSelectionEvent e) |
514 |
{ |
{ |
515 |
Object f = filelist.getSelectedValue(); |
JList list = (JList) e.getSource(); |
516 |
|
Object f = list.getSelectedValue(); |
517 |
if (f == null) |
if (f == null) |
518 |
return; |
return; |
519 |
File file = filechooser.getFileSystemView().createFileObject(f.toString()); |
File file = filechooser.getFileSystemView().createFileObject(f.toString()); |
536 |
*/ |
*/ |
537 |
protected UpdateAction() |
protected UpdateAction() |
538 |
{ |
{ |
539 |
// Nothing to do here. |
super(null); |
540 |
} |
} |
541 |
|
|
542 |
/** |
/** |
560 |
protected String cancelButtonToolTipText; |
protected String cancelButtonToolTipText; |
561 |
|
|
562 |
/** An icon representing a computer. */ |
/** An icon representing a computer. */ |
563 |
protected Icon computerIcon = new Icon() |
protected Icon computerIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
// FIXME: is this not implemented, or is the icon intentionally blank? |
|
|
} |
|
|
}; |
|
564 |
|
|
565 |
/** An icon for the "details view" button. */ |
/** An icon for the "details view" button. */ |
566 |
protected Icon detailsViewIcon = new Icon() |
protected Icon detailsViewIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
g.setColor(Color.GRAY); |
|
|
g.drawRect(1, 1, 15, 20); |
|
|
g.drawLine(17, 6, 23, 6); |
|
|
g.drawLine(17, 12, 23, 12); |
|
|
g.drawLine(17, 18, 23, 18); |
|
|
|
|
|
g.setColor(saved); |
|
|
g.translate(-x, -y); |
|
|
} |
|
|
}; |
|
567 |
|
|
568 |
/** An icon representing a directory. */ |
/** An icon representing a directory. */ |
569 |
protected Icon directoryIcon = new Icon() |
protected Icon directoryIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
Point ap = new Point(3, 7); |
|
|
Point bp = new Point(3, 21); |
|
|
Point cp = new Point(21, 21); |
|
|
Point dp = new Point(21, 12); |
|
|
Point ep = new Point(16, 12); |
|
|
Point fp = new Point(13, 7); |
|
|
|
|
|
Polygon dir = new Polygon(new int[] { ap.x, bp.x, cp.x, dp.x, ep.x, fp.x }, |
|
|
new int[] { ap.y, bp.y, cp.y, dp.y, ep.y, fp.y }, |
|
|
6); |
|
|
|
|
|
g.setColor(new Color(153, 204, 255)); |
|
|
g.fillPolygon(dir); |
|
|
g.setColor(Color.BLACK); |
|
|
g.drawPolygon(dir); |
|
|
|
|
|
g.translate(-x, -y); |
|
|
g.setColor(saved); |
|
|
} |
|
|
}; |
|
570 |
|
|
571 |
/** The localised Mnemonic for the open button. */ |
/** The localised Mnemonic for the open button. */ |
572 |
protected int directoryOpenButtonMnemonic; |
protected int directoryOpenButtonMnemonic; |
578 |
protected String directoryOpenButtonToolTipText; |
protected String directoryOpenButtonToolTipText; |
579 |
|
|
580 |
/** An icon representing a file. */ |
/** An icon representing a file. */ |
581 |
protected Icon fileIcon = new Icon() |
protected Icon fileIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
Point a = new Point(5, 4); |
|
|
Point b = new Point(5, 20); |
|
|
Point d = new Point(19, 20); |
|
|
Point e = new Point(19, 7); |
|
|
Point f = new Point(16, 4); |
|
|
|
|
|
Polygon p = new Polygon(new int[] { a.x, b.x, d.x, e.x, f.x, }, |
|
|
new int[] { a.y, b.y, d.y, e.y, f.y }, 5); |
|
|
|
|
|
g.setColor(Color.WHITE); |
|
|
g.fillPolygon(p); |
|
|
g.setColor(Color.BLACK); |
|
|
g.drawPolygon(p); |
|
|
|
|
|
g.drawLine(16, 4, 14, 6); |
|
|
g.drawLine(14, 6, 19, 7); |
|
|
|
|
|
g.setColor(saved); |
|
|
g.translate(-x, -y); |
|
|
} |
|
|
}; |
|
582 |
|
|
583 |
/** An icon representing a floppy drive. */ |
/** An icon representing a floppy drive. */ |
584 |
protected Icon floppyDriveIcon = new Icon() |
protected Icon floppyDriveIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
// FIXME: is this not implemented, or is the icon intentionally blank? |
|
|
} |
|
|
}; |
|
585 |
|
|
586 |
/** An icon representing a hard drive. */ |
/** An icon representing a hard drive. */ |
587 |
protected Icon hardDriveIcon = new Icon() |
protected Icon hardDriveIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
// FIXME: is this not implemented, or is the icon intentionally blank? |
|
|
} |
|
|
}; |
|
588 |
|
|
589 |
/** The localised mnemonic for the "help" button. */ |
/** The localised mnemonic for the "help" button. */ |
590 |
protected int helpButtonMnemonic; |
protected int helpButtonMnemonic; |
596 |
protected String helpButtonToolTipText; |
protected String helpButtonToolTipText; |
597 |
|
|
598 |
/** An icon representing the user's home folder. */ |
/** An icon representing the user's home folder. */ |
599 |
protected Icon homeFolderIcon = new Icon() |
protected Icon homeFolderIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
Point a = new Point(12, 3); |
|
|
Point b = new Point(4, 10); |
|
|
Point d = new Point(20, 10); |
|
|
|
|
|
Polygon p = new Polygon(new int[] { a.x, b.x, d.x }, |
|
|
new int[] { a.y, b.y, d.y }, 3); |
|
|
|
|
|
g.setColor(new Color(104, 51, 0)); |
|
|
g.fillPolygon(p); |
|
|
g.setColor(Color.BLACK); |
|
|
g.drawPolygon(p); |
|
|
|
|
|
g.setColor(Color.WHITE); |
|
|
g.fillRect(8, 10, 8, 10); |
|
|
g.setColor(Color.BLACK); |
|
|
g.drawRect(8, 10, 8, 10); |
|
|
|
|
|
g.setColor(saved); |
|
|
g.translate(-x, -y); |
|
|
} |
|
|
}; |
|
600 |
|
|
601 |
/** An icon for the "list view" button. */ |
/** An icon for the "list view" button. */ |
602 |
protected Icon listViewIcon = new Icon() |
protected Icon listViewIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
// Not needed. Only simplifies things until we get real icons. |
|
|
private void paintPartial(Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
g.setColor(Color.GRAY); |
|
|
g.drawRect(1, 1, 7, 10); |
|
|
g.drawLine(8, 6, 11, 6); |
|
|
|
|
|
g.setColor(saved); |
|
|
g.translate(-x, -y); |
|
|
} |
|
|
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
paintPartial(g, 0, 0); |
|
|
paintPartial(g, 12, 0); |
|
|
paintPartial(g, 0, 12); |
|
|
paintPartial(g, 12, 12); |
|
|
|
|
|
g.setColor(saved); |
|
|
g.translate(-x, -y); |
|
|
} |
|
|
}; |
|
603 |
|
|
604 |
/** An icon for the "new folder" button. */ |
/** An icon for the "new folder" button. */ |
605 |
protected Icon newFolderIcon = directoryIcon; |
protected Icon newFolderIcon = directoryIcon; |
632 |
protected String updateButtonToolTipText; |
protected String updateButtonToolTipText; |
633 |
|
|
634 |
/** An icon for the "up folder" button. */ |
/** An icon for the "up folder" button. */ |
635 |
protected Icon upFolderIcon = new Icon() |
protected Icon upFolderIcon; |
|
{ |
|
|
public int getIconHeight() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public int getIconWidth() |
|
|
{ |
|
|
return ICON_SIZE; |
|
|
} |
|
|
|
|
|
public void paintIcon(Component comp, Graphics g, int x, int y) |
|
|
{ |
|
|
Color saved = g.getColor(); |
|
|
g.translate(x, y); |
|
|
|
|
|
Point a = new Point(3, 7); |
|
|
Point b = new Point(3, 21); |
|
|
Point c = new Point(21, 21); |
|
|
Point d = new Point(21, 12); |
|
|
Point e = new Point(16, 12); |
|
|
Point f = new Point(13, 7); |
|
|
|
|
|
Polygon dir = new Polygon(new int[] { a.x, b.x, c.x, d.x, e.x, f.x }, |
|
|
new int[] { a.y, b.y, c.y, d.y, e.y, f.y }, 6); |
|
|
|
|
|
g.setColor(new Color(153, 204, 255)); |
|
|
g.fillPolygon(dir); |
|
|
g.setColor(Color.BLACK); |
|
|
g.drawPolygon(dir); |
|
|
|
|
|
a = new Point(12, 15); |
|
|
b = new Point(9, 18); |
|
|
c = new Point(15, 18); |
|
|
|
|
|
Polygon arrow = new Polygon(new int[] { a.x, b.x, c.x }, |
|
|
new int[] { a.y, b.y, c.y }, 3); |
|
|
|
|
|
g.fillPolygon(arrow); |
|
|
|
|
|
g.drawLine(12, 15, 12, 22); |
|
|
|
|
|
g.translate(-x, -y); |
|
|
g.setColor(saved); |
|
|
} |
|
|
}; |
|
636 |
|
|
637 |
// -- begin private, but package local since used in inner classes -- |
// -- begin private, but package local since used in inner classes -- |
638 |
|
|
639 |
/** The file chooser component represented by this UI delegate. */ |
/** The file chooser component represented by this UI delegate. */ |
640 |
JFileChooser filechooser; |
JFileChooser filechooser; |
641 |
|
|
|
/** The file list. */ |
|
|
JList filelist; |
|
|
|
|
|
/** The combo box used to display/select file filters. */ |
|
|
JComboBox filters; |
|
|
|
|
642 |
/** The model for the directory list. */ |
/** The model for the directory list. */ |
643 |
BasicDirectoryModel model; |
BasicDirectoryModel model; |
644 |
|
|
648 |
/** The default file view. */ |
/** The default file view. */ |
649 |
FileView fv = new BasicFileView(); |
FileView fv = new BasicFileView(); |
650 |
|
|
|
/** The icon size. */ |
|
|
static final int ICON_SIZE = 24; |
|
|
|
|
|
/** A combo box for display/selection of parent directories. */ |
|
|
JComboBox parents; |
|
|
|
|
|
/** The current file name. */ |
|
|
String filename; |
|
|
|
|
651 |
/** The accept (open/save) button. */ |
/** The accept (open/save) button. */ |
652 |
JButton accept; |
JButton accept; |
653 |
|
|
|
/** The cancel button. */ |
|
|
JButton cancel; |
|
|
|
|
|
/** The button to move up to the parent directory. */ |
|
|
JButton upFolderButton; |
|
|
|
|
|
/** The button to create a new directory. */ |
|
|
JButton newFolderButton; |
|
|
|
|
|
/** The button to move to the user's home directory. */ |
|
|
JButton homeFolderButton; |
|
|
|
|
654 |
/** An optional accessory panel. */ |
/** An optional accessory panel. */ |
655 |
JPanel accessoryPanel; |
JPanel accessoryPanel; |
656 |
|
|
685 |
/** Current parent path */ |
/** Current parent path */ |
686 |
String parentPath; |
String parentPath; |
687 |
|
|
688 |
|
/** |
689 |
|
* The action for the 'approve' button. |
690 |
|
* @see #getApproveSelectionAction() |
691 |
|
*/ |
692 |
|
private ApproveSelectionAction approveSelectionAction; |
693 |
|
|
694 |
|
/** |
695 |
|
* The action for the 'cancel' button. |
696 |
|
* @see #getCancelSelectionAction() |
697 |
|
*/ |
698 |
|
private CancelSelectionAction cancelSelectionAction; |
699 |
|
|
700 |
|
/** |
701 |
|
* The action for the 'go home' control button. |
702 |
|
* @see #getGoHomeAction() |
703 |
|
*/ |
704 |
|
private GoHomeAction goHomeAction; |
705 |
|
|
706 |
|
/** |
707 |
|
* The action for the 'up folder' control button. |
708 |
|
* @see #getChangeToParentDirectoryAction() |
709 |
|
*/ |
710 |
|
private ChangeToParentDirectoryAction changeToParentDirectoryAction; |
711 |
|
|
712 |
|
/** |
713 |
|
* The action for the 'new folder' control button. |
714 |
|
* @see #getNewFolderAction() |
715 |
|
*/ |
716 |
|
private NewFolderAction newFolderAction; |
717 |
|
|
718 |
|
/** |
719 |
|
* The action for ???. // FIXME: what is this? |
720 |
|
* @see #getUpdateAction() |
721 |
|
*/ |
722 |
|
private UpdateAction updateAction; |
723 |
|
|
724 |
// -- end private -- |
// -- end private -- |
725 |
private class ListLabelRenderer extends JLabel implements ListCellRenderer |
private class ListLabelRenderer extends JLabel implements ListCellRenderer |
726 |
{ |
{ |
780 |
*/ |
*/ |
781 |
public BasicFileChooserUI(JFileChooser b) |
public BasicFileChooserUI(JFileChooser b) |
782 |
{ |
{ |
|
this.filechooser = b; |
|
783 |
} |
} |
784 |
|
|
785 |
/** |
/** |
804 |
if (c instanceof JFileChooser) |
if (c instanceof JFileChooser) |
805 |
{ |
{ |
806 |
JFileChooser fc = (JFileChooser) c; |
JFileChooser fc = (JFileChooser) c; |
807 |
|
this.filechooser = fc; |
808 |
fc.resetChoosableFileFilters(); |
fc.resetChoosableFileFilters(); |
809 |
createModel(); |
createModel(); |
810 |
clearIconCache(); |
clearIconCache(); |
854 |
if (parentFiles.size() == 0) |
if (parentFiles.size() == 0) |
855 |
return; |
return; |
856 |
|
|
857 |
if (parents.getItemCount() > 0) |
} |
|
parents.removeAllItems(); |
|
|
for (int i = parentFiles.size() - 1; i >= 0; i--) |
|
|
parents.addItem(parentFiles.get(i)); |
|
|
parents.setSelectedIndex(parentFiles.size() - 1); |
|
|
parents.revalidate(); |
|
|
parents.repaint(); |
|
|
} |
|
|
|
|
|
/** |
|
|
* DOCUMENT ME! |
|
|
* |
|
|
* @return DOCUMENT ME! |
|
|
*/ |
|
|
private ItemListener createBoxListener() |
|
|
{ |
|
|
return new ItemListener() |
|
|
{ |
|
|
public void itemStateChanged(ItemEvent e) |
|
|
{ |
|
|
if (parents.getItemCount() - 1 == parents.getSelectedIndex()) |
|
|
return; |
|
|
StringBuffer dir = new StringBuffer(); |
|
|
for (int i = 0; i <= parents.getSelectedIndex(); i++) |
|
|
{ |
|
|
dir.append(parents.getItemAt(i)); |
|
|
dir.append(File.separatorChar); |
|
|
} |
|
|
filechooser.setCurrentDirectory(filechooser.getFileSystemView() |
|
|
.createFileObject(dir |
|
|
.toString())); |
|
|
} |
|
|
}; |
|
|
} |
|
|
|
|
|
/** |
|
|
* DOCUMENT ME! |
|
|
* |
|
|
* @return DOCUMENT ME! |
|
|
*/ |
|
|
private ItemListener createFilterListener() |
|
|
{ |
|
|
return new ItemListener() |
|
|
{ |
|
|
public void itemStateChanged(ItemEvent e) |
|
|
{ |
|
|
int index = filters.getSelectedIndex(); |
|
|
if (index == -1) |
|
|
return; |
|
|
filechooser.setFileFilter(filechooser.getChoosableFileFilters()[index]); |
|
|
} |
|
|
}; |
|
|
} |
|
|
|
|
|
void filterEntries() |
|
|
{ |
|
|
FileFilter[] list = filechooser.getChoosableFileFilters(); |
|
|
if (filters.getItemCount() > 0) |
|
|
filters.removeAllItems(); |
|
|
|
|
|
int index = -1; |
|
|
String selected = filechooser.getFileFilter().getDescription(); |
|
|
for (int i = 0; i < list.length; i++) |
|
|
{ |
|
|
if (selected.equals(list[i].getDescription())) |
|
|
index = i; |
|
|
filters.addItem(list[i].getDescription()); |
|
|
} |
|
|
filters.setSelectedIndex(index); |
|
|
filters.revalidate(); |
|
|
filters.repaint(); |
|
|
} |
|
858 |
|
|
859 |
/** |
/** |
860 |
* Creates and install the subcomponents for the file chooser. |
* Creates and install the subcomponents for the file chooser. |
863 |
*/ |
*/ |
864 |
public void installComponents(JFileChooser fc) |
public void installComponents(JFileChooser fc) |
865 |
{ |
{ |
|
JLabel look = new JLabel("Look In:"); |
|
|
|
|
|
parents = new JComboBox(); |
|
|
parents.setRenderer(new BasicComboBoxRenderer()); |
|
|
boxEntries(); |
|
|
look.setLabelFor(parents); |
|
|
JPanel parentsPanel = new JPanel(); |
|
|
parentsPanel.add(look); |
|
|
parentsPanel.add(parents); |
|
|
JPanel buttonPanel = new JPanel(); |
|
|
|
|
|
upFolderButton = new JButton(); |
|
|
upFolderButton.setIcon(upFolderIcon); |
|
|
buttonPanel.add(upFolderButton); |
|
|
|
|
|
homeFolderButton = new JButton(); |
|
|
homeFolderButton = new JButton(homeFolderIcon); |
|
|
buttonPanel.add(homeFolderButton); |
|
|
|
|
|
newFolderButton = new JButton(); |
|
|
newFolderButton.setIcon(newFolderIcon); |
|
|
buttonPanel.add(newFolderButton); |
|
|
|
|
|
ButtonGroup toggles = new ButtonGroup(); |
|
|
JToggleButton listViewButton = new JToggleButton(); |
|
|
listViewButton.setIcon(listViewIcon); |
|
|
toggles.add(listViewButton); |
|
|
buttonPanel.add(listViewButton); |
|
|
|
|
|
JToggleButton detailsViewButton = new JToggleButton(); |
|
|
detailsViewButton.setIcon(detailsViewIcon); |
|
|
toggles.add(detailsViewButton); |
|
|
buttonPanel.add(detailsViewButton); |
|
|
|
|
|
JPanel topPanel = new JPanel(); |
|
|
parentsPanel.add(buttonPanel); |
|
|
topPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0)); |
|
|
topPanel.add(parentsPanel); |
|
|
|
|
|
accessoryPanel = new JPanel(); |
|
|
if (filechooser.getAccessory() != null) |
|
|
accessoryPanel.add(filechooser.getAccessory(), BorderLayout.CENTER); |
|
|
|
|
|
filelist = new JList(model); |
|
|
filelist.setVisibleRowCount(6); |
|
|
JScrollPane scrollp = new JScrollPane(filelist); |
|
|
scrollp.setPreferredSize(new Dimension(400, 175)); |
|
|
filelist.setBackground(Color.WHITE); |
|
|
|
|
|
filelist.setLayoutOrientation(JList.VERTICAL_WRAP); |
|
|
filelist.setCellRenderer(new ListLabelRenderer()); |
|
|
|
|
|
GridBagConstraints c = new GridBagConstraints(); |
|
|
c.gridx = 0; |
|
|
c.gridy = 0; |
|
|
c.fill = GridBagConstraints.BOTH; |
|
|
c.weightx = 1; |
|
|
c.weighty = 1; |
|
|
|
|
|
JPanel centrePanel = new JPanel(); |
|
|
centrePanel.setLayout(new GridBagLayout()); |
|
|
centrePanel.add(scrollp, c); |
|
|
|
|
|
c.gridx = 1; |
|
|
centrePanel.add(accessoryPanel, c); |
|
|
|
|
|
JLabel fileNameLabel = new JLabel("File Name:"); |
|
|
JLabel fileTypesLabel = new JLabel("Files of Type:"); |
|
|
|
|
|
entry = new JTextField(); |
|
|
filters = new JComboBox(); |
|
|
filterEntries(); |
|
|
|
|
|
fileNameLabel.setLabelFor(entry); |
|
|
fileNameLabel.setHorizontalTextPosition(SwingConstants.LEFT); |
|
|
fileTypesLabel.setLabelFor(filters); |
|
|
fileTypesLabel.setHorizontalTextPosition(SwingConstants.LEFT); |
|
|
|
|
|
closePanel = new JPanel(); |
|
|
accept = getApproveButton(filechooser); |
|
|
cancel = new JButton(cancelButtonText); |
|
|
cancel.setMnemonic(cancelButtonMnemonic); |
|
|
cancel.setToolTipText(cancelButtonToolTipText); |
|
|
closePanel.add(accept); |
|
|
closePanel.add(cancel); |
|
|
|
|
|
c.anchor = GridBagConstraints.WEST; |
|
|
c.weighty = 0; |
|
|
c.weightx = 0; |
|
|
c.gridx = 0; |
|
|
|
|
|
bottomPanel = new JPanel(); |
|
|
bottomPanel.setLayout(new GridBagLayout()); |
|
|
bottomPanel.add(fileNameLabel, c); |
|
|
|
|
|
c.gridy = 1; |
|
|
bottomPanel.add(fileTypesLabel, c); |
|
|
c.gridx = 1; |
|
|
c.gridy = 0; |
|
|
c.weightx = 1; |
|
|
c.weighty = 1; |
|
|
bottomPanel.add(entry, c); |
|
|
|
|
|
c.gridy = 1; |
|
|
bottomPanel.add(filters, c); |
|
|
|
|
|
c.fill = GridBagConstraints.NONE; |
|
|
c.gridy = 2; |
|
|
c.anchor = GridBagConstraints.EAST; |
|
|
bottomPanel.add(closePanel, c); |
|
|
|
|
|
filechooser.setLayout(new BorderLayout()); |
|
|
filechooser.add(topPanel, BorderLayout.NORTH); |
|
|
filechooser.add(centrePanel, BorderLayout.CENTER); |
|
|
filechooser.add(bottomPanel, BorderLayout.SOUTH); |
|
866 |
} |
} |
867 |
|
|
868 |
/** |
/** |
872 |
*/ |
*/ |
873 |
public void uninstallComponents(JFileChooser fc) |
public void uninstallComponents(JFileChooser fc) |
874 |
{ |
{ |
|
parents = null; |
|
|
|
|
|
accept = null; |
|
|
cancel = null; |
|
|
upFolderButton = null; |
|
|
homeFolderButton = null; |
|
|
newFolderButton = null; |
|
|
|
|
|
filelist = null; |
|
875 |
} |
} |
876 |
|
|
877 |
/** |
/** |
883 |
{ |
{ |
884 |
propertyChangeListener = createPropertyChangeListener(filechooser); |
propertyChangeListener = createPropertyChangeListener(filechooser); |
885 |
filechooser.addPropertyChangeListener(propertyChangeListener); |
filechooser.addPropertyChangeListener(propertyChangeListener); |
|
|
|
|
//parents.addItemListener(createBoxListener()); |
|
|
accept.addActionListener(getApproveSelectionAction()); |
|
|
cancel.addActionListener(getCancelSelectionAction()); |
|
|
upFolderButton.addActionListener(getChangeToParentDirectoryAction()); |
|
|
homeFolderButton.addActionListener(getGoHomeAction()); |
|
|
newFolderButton.addActionListener(getNewFolderAction()); |
|
|
filters.addItemListener(createFilterListener()); |
|
|
|
|
|
filelist.addMouseListener(createDoubleClickListener(filechooser, filelist)); |
|
|
filelist.addListSelectionListener(createListSelectionListener(filechooser)); |
|
886 |
} |
} |
887 |
|
|
888 |
/** |
/** |
919 |
} |
} |
920 |
|
|
921 |
/** |
/** |
922 |
* Installs the icons for this UI delegate (NOT YET IMPLEMENTED). |
* Installs the icons for this UI delegate. |
923 |
* |
* |
924 |
* @param fc the file chooser. |
* @param fc the file chooser (ignored). |
925 |
*/ |
*/ |
926 |
protected void installIcons(JFileChooser fc) |
protected void installIcons(JFileChooser fc) |
927 |
{ |
{ |
928 |
// FIXME: Implement. |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
929 |
|
computerIcon = MetalIconFactory.getTreeComputerIcon(); |
930 |
|
detailsViewIcon = defaults.getIcon("FileChooser.detailsViewIcon"); |
931 |
|
directoryIcon = new MetalIconFactory.TreeFolderIcon(); |
932 |
|
fileIcon = new MetalIconFactory.TreeLeafIcon(); |
933 |
|
floppyDriveIcon = MetalIconFactory.getTreeFloppyDriveIcon(); |
934 |
|
hardDriveIcon = MetalIconFactory.getTreeHardDriveIcon(); |
935 |
|
homeFolderIcon = defaults.getIcon("FileChooser.homeFolderIcon"); |
936 |
|
listViewIcon = defaults.getIcon("FileChooser.listViewIcon"); |
937 |
|
newFolderIcon = defaults.getIcon("FileChooser.newFolderIcon"); |
938 |
|
upFolderIcon = defaults.getIcon("FileChooser.upFolderIcon"); |
939 |
} |
} |
940 |
|
|
941 |
/** |
/** |
942 |
* Uninstalls the icons previously added by this UI delegate (NOT YET |
* Uninstalls the icons previously added by this UI delegate. |
|
* IMPLEMENTED). |
|
943 |
* |
* |
944 |
* @param fc the file chooser. |
* @param fc the file chooser. |
945 |
*/ |
*/ |
946 |
protected void uninstallIcons(JFileChooser fc) |
protected void uninstallIcons(JFileChooser fc) |
947 |
{ |
{ |
948 |
// FIXME: Implement. |
computerIcon = null; |
949 |
|
detailsViewIcon = null; |
950 |
|
directoryIcon = null; |
951 |
|
fileIcon = null; |
952 |
|
floppyDriveIcon = null; |
953 |
|
hardDriveIcon = null; |
954 |
|
homeFolderIcon = null; |
955 |
|
listViewIcon = null; |
956 |
|
newFolderIcon = null; |
957 |
|
upFolderIcon = null; |
958 |
} |
} |
959 |
|
|
960 |
/** |
/** |
966 |
{ |
{ |
967 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
968 |
|
|
|
acceptAllFileFilterText = defaults.getString("FileChooser.acceptAllFileFilterText"); |
|
|
cancelButtonMnemonic = defaults.getInt("FileChooser.cancelButtonMnemonic"); |
|
|
cancelButtonText = defaults.getString("FileChooser.cancelButtonText"); |
|
|
cancelButtonToolTipText = defaults.getString("FileChooser.cancelButtonToolTipText"); |
|
|
|
|
969 |
dirDescText = defaults.getString("FileChooser.directoryDescriptionText"); |
dirDescText = defaults.getString("FileChooser.directoryDescriptionText"); |
970 |
fileDescText = defaults.getString("FileChooser.fileDescriptionText"); |
fileDescText = defaults.getString("FileChooser.fileDescriptionText"); |
971 |
|
|
972 |
|
acceptAllFileFilterText = defaults.getString("FileChooser.acceptAllFileFilterText"); |
973 |
|
cancelButtonText = "Cancel"; |
974 |
|
cancelButtonToolTipText = "Abort file chooser dialog"; |
975 |
|
cancelButtonMnemonic = defaults.getInt("FileChooser.cancelButtonMnemonic"); |
976 |
|
|
977 |
|
directoryOpenButtonText = "Open"; |
978 |
|
directoryOpenButtonToolTipText = "Open selected directory"; |
979 |
|
directoryOpenButtonMnemonic |
980 |
|
= defaults.getInt("FileChooser.directoryOpenButtonMnemonic"); |
981 |
|
|
982 |
|
helpButtonText = "Help"; |
983 |
|
helpButtonToolTipText = "FileChooser help"; |
984 |
helpButtonMnemonic = defaults.getInt("FileChooser.helpButtonMnemonic"); |
helpButtonMnemonic = defaults.getInt("FileChooser.helpButtonMnemonic"); |
|
helpButtonText = defaults.getString("FileChooser.helpButtonText"); |
|
|
helpButtonToolTipText = defaults.getString("FileChooser.helpButtonToolTipText"); |
|
985 |
|
|
986 |
|
openButtonText = "Open"; |
987 |
|
openButtonToolTipText = "Open selected file"; |
988 |
openButtonMnemonic = defaults.getInt("FileChooser.openButtonMnemonic"); |
openButtonMnemonic = defaults.getInt("FileChooser.openButtonMnemonic"); |
|
openButtonText = defaults.getString("FileChooser.openButtonText"); |
|
|
openButtonToolTipText = defaults.getString("FileChooser.openButtonToolTipText"); |
|
989 |
|
|
990 |
saveButtonMnemonic = defaults.getInt("FileChooser.saveButtonMnemonic"); |
saveButtonText = "Save"; |
991 |
saveButtonText = defaults.getString("FileChooser.saveButtonText"); |
saveButtonToolTipText = "Save selected file"; |
992 |
saveButtonToolTipText = defaults.getString("FileChooser.saveButtonToolTipText"); |
saveButtonMnemonic = UIManager.getInt("FileChooser.saveButtonMnemonic"); |
993 |
|
|
994 |
|
updateButtonText = "Update"; |
995 |
|
updateButtonToolTipText = "Update directory listing"; |
996 |
|
updateButtonMnemonic = defaults.getInt("FileChooser.updateButtonMnemonic"); |
997 |
} |
} |
998 |
|
|
999 |
/** |
/** |
1004 |
protected void uninstallStrings(JFileChooser fc) |
protected void uninstallStrings(JFileChooser fc) |
1005 |
{ |
{ |
1006 |
acceptAllFileFilterText = null; |
acceptAllFileFilterText = null; |
1007 |
cancelButtonMnemonic = 0; |
dirDescText = null; |
1008 |
|
fileDescText = null; |
1009 |
|
|
1010 |
cancelButtonText = null; |
cancelButtonText = null; |
1011 |
cancelButtonToolTipText = null; |
cancelButtonToolTipText = null; |
1012 |
|
|
1013 |
dirDescText = null; |
directoryOpenButtonText = null; |
1014 |
fileDescText = null; |
directoryOpenButtonToolTipText = null; |
1015 |
|
|
|
helpButtonMnemonic = 0; |
|
1016 |
helpButtonText = null; |
helpButtonText = null; |
1017 |
helpButtonToolTipText = null; |
helpButtonToolTipText = null; |
1018 |
|
|
|
openButtonMnemonic = 0; |
|
1019 |
openButtonText = null; |
openButtonText = null; |
1020 |
openButtonToolTipText = null; |
openButtonToolTipText = null; |
1021 |
|
|
|
saveButtonMnemonic = 0; |
|
1022 |
saveButtonText = null; |
saveButtonText = null; |
1023 |
saveButtonToolTipText = null; |
saveButtonToolTipText = null; |
1024 |
|
|
1025 |
|
updateButtonText = null; |
1026 |
|
updateButtonToolTipText = null; |
1027 |
} |
} |
1028 |
|
|
1029 |
/** |
/** |
1058 |
{ |
{ |
1059 |
public void propertyChange(PropertyChangeEvent e) |
public void propertyChange(PropertyChangeEvent e) |
1060 |
{ |
{ |
|
// FIXME: Multiple file selection waiting on JList multiple selection |
|
|
// bug. |
|
|
if (e.getPropertyName().equals( |
|
|
JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) |
|
|
{ |
|
|
if (filechooser.getSelectedFile() == null) |
|
|
setFileName(null); |
|
|
else |
|
|
setFileName(filechooser.getSelectedFile().toString()); |
|
|
int index = -1; |
|
|
File file = filechooser.getSelectedFile(); |
|
|
for (index = 0; index < model.getSize(); index++) |
|
|
if (((File) model.getElementAt(index)).equals(file)) |
|
|
break; |
|
|
if (index == -1) |
|
|
return; |
|
|
filelist.setSelectedIndex(index); |
|
|
filelist.ensureIndexIsVisible(index); |
|
|
filelist.revalidate(); |
|
|
filelist.repaint(); |
|
|
} |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.DIRECTORY_CHANGED_PROPERTY)) |
|
|
{ |
|
|
filelist.clearSelection(); |
|
|
filelist.revalidate(); |
|
|
filelist.repaint(); |
|
|
setDirectorySelected(false); |
|
|
setDirectory(filechooser.getCurrentDirectory()); |
|
|
boxEntries(); |
|
|
} |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) |
|
|
|| e.getPropertyName().equals( |
|
|
JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) |
|
|
filterEntries(); |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY) |
|
|
|| e.getPropertyName().equals( |
|
|
JFileChooser.DIALOG_TITLE_CHANGED_PROPERTY)) |
|
|
{ |
|
|
Window owner = SwingUtilities.windowForComponent(filechooser); |
|
|
if (owner instanceof JDialog) |
|
|
((JDialog) owner).setTitle(getDialogTitle(filechooser)); |
|
|
accept.setText(getApproveButtonText(filechooser)); |
|
|
accept.setToolTipText(getApproveButtonToolTipText(filechooser)); |
|
|
accept.setMnemonic(getApproveButtonMnemonic(filechooser)); |
|
|
} |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY)) |
|
|
accept.setText(getApproveButtonText(filechooser)); |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) |
|
|
accept.setToolTipText(getApproveButtonToolTipText(filechooser)); |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) |
|
|
accept.setMnemonic(getApproveButtonMnemonic(filechooser)); |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) |
|
|
{ |
|
|
if (filechooser.getControlButtonsAreShown()) |
|
|
{ |
|
|
GridBagConstraints c = new GridBagConstraints(); |
|
|
c.gridy = 1; |
|
|
bottomPanel.add(filters, c); |
|
|
|
|
|
c.fill = GridBagConstraints.BOTH; |
|
|
c.gridy = 2; |
|
|
c.anchor = GridBagConstraints.EAST; |
|
|
bottomPanel.add(closePanel, c); |
|
|
bottomPanel.revalidate(); |
|
|
bottomPanel.repaint(); |
|
|
bottomPanel.doLayout(); |
|
|
} |
|
|
else |
|
|
bottomPanel.remove(closePanel); |
|
|
} |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY)) |
|
|
{ |
|
|
if (filechooser.isAcceptAllFileFilterUsed()) |
|
|
filechooser.addChoosableFileFilter(getAcceptAllFileFilter(filechooser)); |
|
|
else |
|
|
filechooser.removeChoosableFileFilter(getAcceptAllFileFilter(filechooser)); |
|
|
} |
|
|
else if (e.getPropertyName().equals( |
|
|
JFileChooser.ACCESSORY_CHANGED_PROPERTY)) |
|
|
{ |
|
|
JComponent old = (JComponent) e.getOldValue(); |
|
|
if (old != null) |
|
|
getAccessoryPanel().remove(old); |
|
|
JComponent newval = (JComponent) e.getNewValue(); |
|
|
if (newval != null) |
|
|
getAccessoryPanel().add(newval); |
|
|
} |
|
|
if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY) |
|
|
|| e.getPropertyName().equals( |
|
|
JFileChooser.FILE_FILTER_CHANGED_PROPERTY) |
|
|
|| e.getPropertyName().equals( |
|
|
JFileChooser.FILE_HIDING_CHANGED_PROPERTY)) |
|
|
rescanCurrentDirectory(filechooser); |
|
|
|
|
|
filechooser.revalidate(); |
|
|
filechooser.repaint(); |
|
1061 |
} |
} |
1062 |
}; |
}; |
1063 |
} |
} |
1069 |
*/ |
*/ |
1070 |
public String getFileName() |
public String getFileName() |
1071 |
{ |
{ |
1072 |
return filename; |
// FIXME: I'm thinking that this method just provides access to the |
1073 |
|
// text value in the JTextField component...but not sure yet |
1074 |
|
return null; //filename; |
1075 |
} |
} |
1076 |
|
|
1077 |
/** |
/** |
1096 |
*/ |
*/ |
1097 |
public void setFileName(String filename) |
public void setFileName(String filename) |
1098 |
{ |
{ |
1099 |
this.filename = filename; |
// FIXME: it might be the case that this method provides an access |
1100 |
|
// point for the JTextField (or whatever) a subclass is using... |
1101 |
|
//this.filename = filename; |
1102 |
} |
} |
1103 |
|
|
1104 |
/** |
/** |
1121 |
public void rescanCurrentDirectory(JFileChooser fc) |
public void rescanCurrentDirectory(JFileChooser fc) |
1122 |
{ |
{ |
1123 |
getModel().validateFileCache(); |
getModel().validateFileCache(); |
|
filelist.revalidate(); |
|
1124 |
} |
} |
1125 |
|
|
1126 |
/** |
/** |
1156 |
} |
} |
1157 |
|
|
1158 |
/** |
/** |
1159 |
* Creates and returns an approve (open or save) button for the dialog. |
* Returns the approve (open or save) button for the dialog. |
1160 |
* |
* |
1161 |
* @param fc the file chooser. |
* @param fc the file chooser. |
1162 |
* |
* |
1163 |
* @return The button. |
* @return The button. |
1164 |
*/ |
*/ |
1165 |
public JButton getApproveButton(JFileChooser fc) |
protected JButton getApproveButton(JFileChooser fc) |
1166 |
{ |
{ |
|
accept = new JButton(getApproveButtonText(fc)); |
|
|
accept.setMnemonic(getApproveButtonMnemonic(fc)); |
|
|
accept.setToolTipText(getApproveButtonToolTipText(fc)); |
|
1167 |
return accept; |
return accept; |
1168 |
} |
} |
1169 |
|
|
1275 |
} |
} |
1276 |
|
|
1277 |
/** |
/** |
1278 |
* Returns the file view for the file chooser. This returns either the |
* Returns the default file view (NOT the file view from the file chooser, |
1279 |
* file view that has been explicitly set for the {@link JFileChooser}, or |
* if there is one). |
|
* a default file view. |
|
1280 |
* |
* |
1281 |
* @param fc the file chooser component. |
* @param fc the file chooser component. |
1282 |
* |
* |
1300 |
*/ |
*/ |
1301 |
public String getDialogTitle(JFileChooser fc) |
public String getDialogTitle(JFileChooser fc) |
1302 |
{ |
{ |
1303 |
String ret = fc.getDialogTitle(); |
String result = fc.getDialogTitle(); |
1304 |
if (ret != null) |
if (result == null) |
1305 |
return ret; |
result = getApproveButtonText(fc); |
1306 |
switch (fc.getDialogType()) |
return result; |
|
{ |
|
|
case JFileChooser.OPEN_DIALOG: |
|
|
ret = openButtonText; |
|
|
break; |
|
|
case JFileChooser.SAVE_DIALOG: |
|
|
ret = saveButtonText; |
|
|
break; |
|
|
default: |
|
|
ret = fc.getApproveButtonText(); |
|
|
break; |
|
|
} |
|
|
if (ret == null) |
|
|
ret = openButtonText; |
|
|
return ret; |
|
1307 |
} |
} |
1308 |
|
|
1309 |
/** |
/** |
1336 |
*/ |
*/ |
1337 |
public String getApproveButtonText(JFileChooser fc) |
public String getApproveButtonText(JFileChooser fc) |
1338 |
{ |
{ |
1339 |
if (fc.getApproveButtonText() != null) |
String result = fc.getApproveButtonText(); |
1340 |
return fc.getApproveButtonText(); |
if (result == null) |
1341 |
else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG) |
{ |
1342 |
return saveButtonText; |
if (fc.getDialogType() == JFileChooser.SAVE_DIALOG) |
1343 |
else |
result = saveButtonText; |
1344 |
return openButtonText; |
else |
1345 |
|
result = openButtonText; |
1346 |
|
} |
1347 |
|
return result; |
1348 |
} |
} |
1349 |
|
|
1350 |
/** |
/** |
1351 |
* Creates and returns a new action that will be used with the "new folder" |
* Creates and returns a new action that will be used with the "new folder" |
1352 |
* button. |
* button. |
1353 |
* |
* |
1354 |
* @return A new instance of {@link GoHomeAction}. |
* @return A new instance of {@link NewFolderAction}. |
1355 |
*/ |
*/ |
1356 |
public Action getNewFolderAction() |
public Action getNewFolderAction() |
1357 |
{ |
{ |
1358 |
return new NewFolderAction(); |
if (newFolderAction == null) |
1359 |
|
newFolderAction = new NewFolderAction(); |
1360 |
|
return newFolderAction; |
1361 |
} |
} |
1362 |
|
|
1363 |
/** |
/** |
1368 |
*/ |
*/ |
1369 |
public Action getGoHomeAction() |
public Action getGoHomeAction() |
1370 |
{ |
{ |
1371 |
return new GoHomeAction(); |
if (goHomeAction == null) |
1372 |
|
goHomeAction = new GoHomeAction(); |
1373 |
|
return goHomeAction; |
1374 |
} |
} |
1375 |
|
|
1376 |
/** |
/** |
1377 |
* Creates and returns a new action that will be used with the "up folder" |
* Returns the action that handles events for the "up folder" control button. |
|
* button. |
|
1378 |
* |
* |
1379 |
* @return A new instance of {@link ChangeToParentDirectoryAction}. |
* @return An instance of {@link ChangeToParentDirectoryAction}. |
1380 |
*/ |
*/ |
1381 |
public Action getChangeToParentDirectoryAction() |
public Action getChangeToParentDirectoryAction() |
1382 |
{ |
{ |
1383 |
return new ChangeToParentDirectoryAction(); |
if (changeToParentDirectoryAction == null) |
1384 |
|
changeToParentDirectoryAction = new ChangeToParentDirectoryAction(); |
1385 |
|
return changeToParentDirectoryAction; |
1386 |
} |
} |
1387 |
|
|
1388 |
/** |
/** |
1389 |
* Creates and returns a new action that will be used with the "approve" |
* Returns the action that handles events for the "approve" button. |
|
* button. |
|
1390 |
* |
* |
1391 |
* @return A new instance of {@link ApproveSelectionAction}. |
* @return An instance of {@link ApproveSelectionAction}. |
1392 |
*/ |
*/ |
1393 |
public Action getApproveSelectionAction() |
public Action getApproveSelectionAction() |
1394 |
{ |
{ |
1395 |
return new ApproveSelectionAction(); |
if (approveSelectionAction == null) |
1396 |
|
approveSelectionAction = new ApproveSelectionAction(); |
1397 |
|
return approveSelectionAction; |
1398 |
} |
} |
1399 |
|
|
1400 |
/** |
/** |
1401 |
* Creates and returns a new action that will be used with the "cancel" |
* Returns the action that handles events for the "cancel" button. |
|
* button. |
|
1402 |
* |
* |
1403 |
* @return A new instance of {@link CancelSelectionAction}. |
* @return An instance of {@link CancelSelectionAction}. |
1404 |
*/ |
*/ |
1405 |
public Action getCancelSelectionAction() |
public Action getCancelSelectionAction() |
1406 |
{ |
{ |
1407 |
return new CancelSelectionAction(); |
if (cancelSelectionAction == null) |
1408 |
|
cancelSelectionAction = new CancelSelectionAction(); |
1409 |
|
return cancelSelectionAction; |
1410 |
} |
} |
1411 |
|
|
1412 |
/** |
/** |
1413 |
* Creates and returns a new instance of {@link UpdateAction}. |
* Returns the update action (an instance of {@link UpdateAction}). |
1414 |
* |
* |
1415 |
* @return An action. |
* @return An action. |
1416 |
*/ |
*/ |
1417 |
public Action getUpdateAction() |
public Action getUpdateAction() |
1418 |
{ |
{ |
1419 |
return new UpdateAction(); |
if (updateAction == null) |
1420 |
|
updateAction = new UpdateAction(); |
1421 |
|
return updateAction; |
1422 |
} |
} |
1423 |
} |
} |