286N/A AquaUtils.enforceComponentOrientation(filechooser, ComponentOrientation.getOrientation(Locale.getDefault()));
fc.registerKeyboardAction(new CancelSelectionAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
// Exist in basic.properties (though we might want to override)
newFolderErrorText = getString("FileChooser.newFolderErrorText", "Error occured during folder creation");
newFolderExistsErrorText = getString("FileChooser.newFolderExistsErrorText", "That name is already taken");
cancelNewFolderButtonToolTipText = UIManager.getString("FileChooser.cancelNewFolderButtonToolTipText");
return model;
return new PropertyChangeListener(){
if (f != null) {
if (!f.isDirectory()) {
return null;
return null;
if (f == null) {
public void run() {
return filechooser;
return accessoryPanel;
return fApproveButton;
if (f == null) return false;
return !traversable;
return new SelectionListener();
if (e.getValueIsAdjusting()) return;
selectionInProgress = true;
selectionInProgress = false;
textChanged();
textChanged();
if (openDirectory(f)) return;
if (!isSelectableInList(f)) return;
protected MouseListener createDoubleClickListener(final JFileChooser fc, final JTableExtension list) {
if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
final java.util.List<File> fileList = (java.util.List<File>)transferable.getTransferData(DataFlavor.javaFileListFlavor);
} catch (final Exception e) {
} catch (final Exception e) {
} catch (final Exception e) {
} catch (final Exception e) {
public void run() {
return acceptAllFileFilter;
return fileView;
return openTitleText;
return selectedFile;
return selectedFile;
super(newFolderAccessibleName);
private Object showNewFolderDialog(final Component parentComponent, final Object message, final String title, final int messageType, final Icon icon, final Object[] options, final Object initialSelectionValue) {
final JOptionPane pane = new JOptionPane(message, messageType, JOptionPane.OK_CANCEL_OPTION, icon, options, null);
return null;
setFont(f);
public Component getTableCellRendererComponent(final JTable list, final Object value, final boolean isSelected, final boolean cellHasFocus, final int index, final int col) {
super.getTableCellRendererComponent(list, value, isSelected, false, index, col); // No focus border, thanks
protected String layoutCL(final JLabel label, final FontMetrics fontMetrics, final String text, final Icon icon, final Rectangle viewR, final Rectangle iconR, final Rectangle textR) {
return SwingUtilities.layoutCompoundLabel(label, fontMetrics, text, icon, label.getVerticalAlignment(), label.getHorizontalAlignment(), label.getVerticalTextPosition(), label.getHorizontalTextPosition(), viewR, iconR, textR, label.getIconTextGap());
Rectangle paintViewR = new Rectangle(paintViewInsets.left, paintViewInsets.top, getWidth() - (paintViewInsets.left + paintViewInsets.right), getHeight() - (paintViewInsets.top + paintViewInsets.bottom));
if (isEnabled()) {
public Component getTableCellRendererComponent(final JTable list, final Object value, final boolean isSelected, final boolean cellHasFocus, final int index, final int col) {
super.getTableCellRendererComponent(list, value, isSelected, false, index, col); // No focus border, thanks
public Component getTableCellRendererComponent(final JTable list, final Object value, final boolean isSelected, final boolean cellHasFocus, final int index, final int col) {
return PREF_SIZE;
return MIN_SIZE;
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
return new DirectoryComboBoxModel();
return fSelectedDirectory;
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
return new FilterComboBoxModel();
protected class FilterComboBoxModel extends DefaultListModel implements ComboBoxModel, PropertyChangeListener {
this.clear();
boolean found = false;
found = true;
if (found == false) {
return returnValue;
super(cm);
filechooser.firePropertyChange(AquaFileSystemModel.SORT_ASCENDING_CHANGED, !fSortAscending[colIndex], fSortAscending[colIndex]);
repaint();
return null;
return label;
public Component getTableCellRendererComponent(final JTable localTable, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
cellBorder.setSortOrder(fSortAscending[column] ? AquaTableHeaderBorder.SORT_ASCENDING : AquaTableHeaderBorder.SORT_DECENDING);
if (f != null) {
return fSaveFilePanel;
return fOpenFilePanel;
return fOpenDirOrAnyPanel;
return fCustomFilePanel;
return fCustomDirOrAnyPanel;
// fTextfieldPanel and fDirectoryPanel both have NewFolder buttons; only one should be visible at a time
public void uninstallComponents(final JFileChooser fc) { //$ Metal (on which this is based) doesn't uninstall its components.
// Consistent with the AppKit NSSavePanel, clicks on a file (not a directory) should populate the text field
// rdar://problem/3734130 -- don't populate the text field if this file isn't selectable in this mode.
fFileList.registerKeyboardAction(new CancelSelectionAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
fFileList.registerKeyboardAction(new DefaultButtonAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_FOCUSED);
final JScrollPane scrollpane = new JScrollPane(fFileList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
protected static final String APPLICATION_TRAVERSABLE_PROPERTY = "JFileChooser.appBundleIsTraversable";
AbstractAction[] fButtonActions = {fApproveSelectionAction, fApproveSelectionAction, new CancelSelectionAction(), new OpenSelectionAction(), null, new NewFolderAction()};
if (o != null && o instanceof String) sGlobalPackageIsTraversable = parseTraversableProperty((String)o);
if (o != null && o instanceof String) sGlobalApplicationIsTraversable = parseTraversableProperty((String)o);
static final String[] sButtonKinds = {"openButton", "saveButton", "cancelButton", "openDirectoryButton", "helpButton", "newFolderButton"};
// This class returns the values for the Custom type, to avoid duplicating code in the two Custom subclasses
if (f == null) return false;
return fApproveButton;
return filenameTextField;
return fallbackText;
return fallbackText;
return cancelChooseButtonToolTipText;
else if (textfieldIsValid()) return false;
return selectionIsDirectory;
openDirectory(f);
if (f != null) {
selectionInProgress = true;
selectionInProgress = false;
boolean enabled = true;
if (f == null) return false;
if (f != null) {
selectionInProgress = true;
selectionInProgress = false;
return saveButtonMnemonic;
return cancelSaveButtonToolTipText;
return fFileList;
return openButtonMnemonic;
return cancelOpenButtonToolTipText;
return fFileList;
return chooseButtonMnemonic;
if (fc.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) fallbackText = chooseFolderButtonToolTipText;
if (f != null) {
selectionInProgress = true;
selectionInProgress = false;
int end;
if (!isSelectableInListIndex(i)) {
end = i;
if (isSetSelection) {
isSetSelection = false;