572 return createActionMap(); 573 } 574 575 protected ActionMap createActionMap() { 576 ActionMap map = new ActionMapUIResource(); 577 FilePane.addActionsToMap(map, filePane.getActions()); 578 return map; 579 } 580 581 protected JPanel createList(JFileChooser fc) { 582 return filePane.createList(); 583 } 584 585 protected JPanel createDetailsView(JFileChooser fc) { 586 return filePane.createDetailsView(); 587 } 588 589 /** 590 * Creates a selection listener for the list of files and directories. 591 * 592 * @param fc a <code>JFileChooser</code> 593 * @return a <code>ListSelectionListener</code> 594 */ 595 public ListSelectionListener createListSelectionListener(JFileChooser fc) { 596 return super.createListSelectionListener(fc); 597 } 598 599 // Obsolete class, not used in this version. 600 @SuppressWarnings("serial") 601 protected class WindowsNewFolderAction extends NewFolderAction { 602 } 603 604 // Obsolete class, not used in this version. 605 protected class SingleClickListener extends MouseAdapter { 606 } 607 608 // Obsolete class, not used in this version. 609 @SuppressWarnings("serial") // Superclass is not serializable across versions 610 protected class FileRenderer extends DefaultListCellRenderer { 611 } 612 613 public void uninstallUI(JComponent c) { 614 // Remove listeners 615 c.removePropertyChangeListener(filterComboBoxModel); 616 c.removePropertyChangeListener(filePane); 617 if (placesBar != null) { 618 c.removePropertyChangeListener(placesBar); 619 } 620 cancelButton.removeActionListener(getCancelSelectionAction()); 621 approveButton.removeActionListener(getApproveSelectionAction()); 622 filenameTextField.removeActionListener(getApproveSelectionAction()); 623 624 if (filePane != null) { 625 filePane.uninstallUI(); 626 filePane = null; 627 } 628 629 super.uninstallUI(c); 630 } 631 632 /** 633 * Returns the preferred size of the specified 634 * <code>JFileChooser</code>. 635 * The preferred size is at least as large, 636 * in both height and width, 637 * as the preferred size recommended 638 * by the file chooser's layout manager. 639 * 640 * @param c a <code>JFileChooser</code> 641 * @return a <code>Dimension</code> specifying the preferred 642 * width and height of the file chooser 643 */ 644 @Override 645 public Dimension getPreferredSize(JComponent c) { 646 int prefWidth = PREF_SIZE.width; 647 Dimension d = c.getLayout().preferredLayoutSize(c); 648 if (d != null) { 649 return new Dimension(d.width < prefWidth ? prefWidth : d.width, 650 d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height); 651 } else { 652 return new Dimension(prefWidth, PREF_SIZE.height); 653 } 654 } 655 656 /** 657 * Returns the minimum size of the <code>JFileChooser</code>. 658 * 659 * @param c a <code>JFileChooser</code> 660 * @return a <code>Dimension</code> specifying the minimum 661 * width and height of the file chooser 662 */ 663 @Override 664 public Dimension getMinimumSize(JComponent c) { 665 return new Dimension(MIN_WIDTH, MIN_HEIGHT); 666 } 667 668 /** 669 * Returns the maximum size of the <code>JFileChooser</code>. 670 * 671 * @param c a <code>JFileChooser</code> 672 * @return a <code>Dimension</code> specifying the maximum 673 * width and height of the file chooser 674 */ 675 @Override 676 public Dimension getMaximumSize(JComponent c) { 677 return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); 678 } 679 680 private String fileNameString(File file) { 681 if (file == null) { 682 return null; 683 } else { 684 JFileChooser fc = getFileChooser(); 685 if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) || 686 (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){ 687 return file.getPath(); 688 } else { 689 return file.getName(); 690 } 691 } 692 } | 572 return createActionMap(); 573 } 574 575 protected ActionMap createActionMap() { 576 ActionMap map = new ActionMapUIResource(); 577 FilePane.addActionsToMap(map, filePane.getActions()); 578 return map; 579 } 580 581 protected JPanel createList(JFileChooser fc) { 582 return filePane.createList(); 583 } 584 585 protected JPanel createDetailsView(JFileChooser fc) { 586 return filePane.createDetailsView(); 587 } 588 589 /** 590 * Creates a selection listener for the list of files and directories. 591 * 592 * @param fc a {@code JFileChooser} 593 * @return a {@code ListSelectionListener} 594 */ 595 public ListSelectionListener createListSelectionListener(JFileChooser fc) { 596 return super.createListSelectionListener(fc); 597 } 598 599 // Obsolete class, not used in this version. 600 @SuppressWarnings("serial") 601 protected class WindowsNewFolderAction extends NewFolderAction { 602 } 603 604 // Obsolete class, not used in this version. 605 protected class SingleClickListener extends MouseAdapter { 606 } 607 608 // Obsolete class, not used in this version. 609 @SuppressWarnings("serial") // Superclass is not serializable across versions 610 protected class FileRenderer extends DefaultListCellRenderer { 611 } 612 613 public void uninstallUI(JComponent c) { 614 // Remove listeners 615 c.removePropertyChangeListener(filterComboBoxModel); 616 c.removePropertyChangeListener(filePane); 617 if (placesBar != null) { 618 c.removePropertyChangeListener(placesBar); 619 } 620 cancelButton.removeActionListener(getCancelSelectionAction()); 621 approveButton.removeActionListener(getApproveSelectionAction()); 622 filenameTextField.removeActionListener(getApproveSelectionAction()); 623 624 if (filePane != null) { 625 filePane.uninstallUI(); 626 filePane = null; 627 } 628 629 super.uninstallUI(c); 630 } 631 632 /** 633 * Returns the preferred size of the specified 634 * {@code JFileChooser}. 635 * The preferred size is at least as large, 636 * in both height and width, 637 * as the preferred size recommended 638 * by the file chooser's layout manager. 639 * 640 * @param c a {@code JFileChooser} 641 * @return a {@code Dimension} specifying the preferred 642 * width and height of the file chooser 643 */ 644 @Override 645 public Dimension getPreferredSize(JComponent c) { 646 int prefWidth = PREF_SIZE.width; 647 Dimension d = c.getLayout().preferredLayoutSize(c); 648 if (d != null) { 649 return new Dimension(d.width < prefWidth ? prefWidth : d.width, 650 d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height); 651 } else { 652 return new Dimension(prefWidth, PREF_SIZE.height); 653 } 654 } 655 656 /** 657 * Returns the minimum size of the {@code JFileChooser}. 658 * 659 * @param c a {@code JFileChooser} 660 * @return a {@code Dimension} specifying the minimum 661 * width and height of the file chooser 662 */ 663 @Override 664 public Dimension getMinimumSize(JComponent c) { 665 return new Dimension(MIN_WIDTH, MIN_HEIGHT); 666 } 667 668 /** 669 * Returns the maximum size of the {@code JFileChooser}. 670 * 671 * @param c a {@code JFileChooser} 672 * @return a {@code Dimension} specifying the maximum 673 * width and height of the file chooser 674 */ 675 @Override 676 public Dimension getMaximumSize(JComponent c) { 677 return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); 678 } 679 680 private String fileNameString(File file) { 681 if (file == null) { 682 return null; 683 } else { 684 JFileChooser fc = getFileChooser(); 685 if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) || 686 (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){ 687 return file.getPath(); 688 } else { 689 return file.getName(); 690 } 691 } 692 } |