jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java
author darcy
Sun, 23 Mar 2014 13:49:48 -0700
changeset 23697 e556a715949f
parent 23328 4c53a6ebc779
child 24969 afa6934dd8e8
permissions -rw-r--r--
8034169: Fix serial lint warnings in javax.swing Reviewed-by: alanb, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2491
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2491
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2491
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2491
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2491
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.metal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.border.EmptyBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.filechooser.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.basic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.FileNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.*;
2491
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
    41
import java.security.AccessController;
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
    42
import java.security.PrivilegedAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.awt.shell.ShellFolder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 20100
diff changeset
    49
 * Metal L&F implementation of a FileChooser.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @author Jeff Dinkins
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public class MetalFileChooserUI extends BasicFileChooserUI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    // Much of the Metal UI for JFilechooser is just a copy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // the windows implementation, but using Metal themed buttons, lists,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // icons, etc. We are planning a complete rewrite, and hence we've
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // made most things in this class private.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private JLabel lookInLabel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private JComboBox directoryComboBox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private DirectoryComboBoxModel directoryComboBoxModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private Action directoryComboBoxAction = new DirectoryComboBoxAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private FilterComboBoxModel filterComboBoxModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private JTextField fileNameTextField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private FilePane filePane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private JToggleButton listViewButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private JToggleButton detailsViewButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private JButton approveButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private JButton cancelButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private JPanel buttonPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private JPanel bottomPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private JComboBox filterComboBox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static final Dimension hstrut5 = new Dimension(5, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private static final Dimension hstrut11 = new Dimension(11, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private static final Dimension vstrut5  = new Dimension(1, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private static final Insets shrinkwrap = new Insets(0,0,0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    // Preferred and Minimum sizes for the dialog box
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static int PREF_WIDTH = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static int PREF_HEIGHT = 326;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static Dimension PREF_SIZE = new Dimension(PREF_WIDTH, PREF_HEIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private static int MIN_WIDTH = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static int MIN_HEIGHT = 326;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private static Dimension MIN_SIZE = new Dimension(MIN_WIDTH, MIN_HEIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private static int LIST_PREF_WIDTH = 405;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private static int LIST_PREF_HEIGHT = 135;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private static Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    // Labels, mnemonics, and tooltips (oh my!)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private int    lookInLabelMnemonic = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private String lookInLabelText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private String saveInLabelText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private int    fileNameLabelMnemonic = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private String fileNameLabelText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    private int    folderNameLabelMnemonic = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private String folderNameLabelText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private int    filesOfTypeLabelMnemonic = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private String filesOfTypeLabelText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private String upFolderToolTipText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private String upFolderAccessibleName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private String homeFolderToolTipText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private String homeFolderAccessibleName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private String newFolderToolTipText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private String newFolderAccessibleName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private String listViewButtonToolTipText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private String listViewButtonAccessibleName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private String detailsViewButtonToolTipText = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private String detailsViewButtonAccessibleName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private AlignedLabel fileNameLabel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    private void populateFileNameLabel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            fileNameLabel.setText(folderNameLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            fileNameLabel.setDisplayedMnemonic(folderNameLabelMnemonic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            fileNameLabel.setText(fileNameLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            fileNameLabel.setDisplayedMnemonic(fileNameLabelMnemonic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    // ComponentUI Interface Implementation methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public static ComponentUI createUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return new MetalFileChooserUI((JFileChooser) c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public MetalFileChooserUI(JFileChooser filechooser) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        super(filechooser);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public void installUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        super.installUI(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public void uninstallComponents(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        fc.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        bottomPanel = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        buttonPanel = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    private class MetalFileChooserUIAccessor implements FilePane.FileChooserUIAccessor {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        public JFileChooser getFileChooser() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            return MetalFileChooserUI.this.getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        public BasicDirectoryModel getModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            return MetalFileChooserUI.this.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        public JPanel createList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            return MetalFileChooserUI.this.createList(getFileChooser());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        public JPanel createDetailsView() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            return MetalFileChooserUI.this.createDetailsView(getFileChooser());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        public boolean isDirectorySelected() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            return MetalFileChooserUI.this.isDirectorySelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        public File getDirectory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            return MetalFileChooserUI.this.getDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        public Action getChangeToParentDirectoryAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            return MetalFileChooserUI.this.getChangeToParentDirectoryAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        public Action getApproveSelectionAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            return MetalFileChooserUI.this.getApproveSelectionAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        public Action getNewFolderAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            return MetalFileChooserUI.this.getNewFolderAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        public MouseListener createDoubleClickListener(JList list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return MetalFileChooserUI.this.createDoubleClickListener(getFileChooser(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                                                     list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        public ListSelectionListener createListSelectionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return MetalFileChooserUI.this.createListSelectionListener(getFileChooser());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public void installComponents(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        FileSystemView fsv = fc.getFileSystemView();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        fc.setBorder(new EmptyBorder(12, 12, 11, 11));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        fc.setLayout(new BorderLayout(0, 11));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        filePane = new FilePane(new MetalFileChooserUIAccessor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        fc.addPropertyChangeListener(filePane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        // ********************************* //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        // **** Construct the top panel **** //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        // ********************************* //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        // Directory manipulation buttons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        JPanel topPanel = new JPanel(new BorderLayout(11, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        JPanel topButtonPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        // Add the top panel to the fileChooser
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        fc.add(topPanel, BorderLayout.NORTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        // ComboBox Label
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        lookInLabel = new JLabel(lookInLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        lookInLabel.setDisplayedMnemonic(lookInLabelMnemonic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        // CurrentDir ComboBox
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   237
        @SuppressWarnings("serial") // anonymous class
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   238
        JComboBox tmp1 = new JComboBox() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                Dimension d = super.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                // Must be small enough to not affect total width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                d.width = 150;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                return d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        };
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   246
        directoryComboBox = tmp1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                            lookInLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        directoryComboBox.putClientProperty( "JComboBox.isTableCellEditor", Boolean.TRUE );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        lookInLabel.setLabelFor(directoryComboBox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        directoryComboBoxModel = createDirectoryComboBoxModel(fc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        directoryComboBox.setModel(directoryComboBoxModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        directoryComboBox.addActionListener(directoryComboBoxAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        directoryComboBox.setMaximumRowCount(8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        topPanel.add(directoryComboBox, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        // Up Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        JButton upFolderButton = new JButton(getChangeToParentDirectoryAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        upFolderButton.setText(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        upFolderButton.setIcon(upFolderIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        upFolderButton.setToolTipText(upFolderToolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                         upFolderAccessibleName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        upFolderButton.setMargin(shrinkwrap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        topButtonPanel.add(upFolderButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        topButtonPanel.add(Box.createRigidArea(hstrut5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        // Home Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        File homeDir = fsv.getHomeDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        String toolTipText = homeFolderToolTipText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if (fsv.isRoot(homeDir)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        JButton b = new JButton(homeFolderIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        b.setToolTipText(toolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                            homeFolderAccessibleName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        b.setMargin(shrinkwrap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        b.addActionListener(getGoHomeAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        topButtonPanel.add(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        topButtonPanel.add(Box.createRigidArea(hstrut5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        // New Directory Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        if (!UIManager.getBoolean("FileChooser.readOnly")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            b = new JButton(filePane.getNewFolderAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            b.setText(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            b.setIcon(newFolderIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            b.setToolTipText(newFolderToolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                newFolderAccessibleName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            b.setMargin(shrinkwrap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        topButtonPanel.add(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        topButtonPanel.add(Box.createRigidArea(hstrut5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        // View button group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        ButtonGroup viewButtonGroup = new ButtonGroup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        // List Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        listViewButton = new JToggleButton(listViewIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        listViewButton.setToolTipText(listViewButtonToolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                         listViewButtonAccessibleName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        listViewButton.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        listViewButton.setMargin(shrinkwrap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        listViewButton.addActionListener(filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        topButtonPanel.add(listViewButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        viewButtonGroup.add(listViewButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        // Details Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        detailsViewButton = new JToggleButton(detailsViewIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                                            detailsViewButtonAccessibleName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        detailsViewButton.setMargin(shrinkwrap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        detailsViewButton.addActionListener(filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        topButtonPanel.add(detailsViewButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        viewButtonGroup.add(detailsViewButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        filePane.addPropertyChangeListener(new PropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                if ("viewType".equals(e.getPropertyName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                    int viewType = filePane.getViewType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                    switch (viewType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                      case FilePane.VIEWTYPE_LIST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                        listViewButton.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                      case FilePane.VIEWTYPE_DETAILS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                        detailsViewButton.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        // ************************************** //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        // ******* Add the directory pane ******* //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        // ************************************** //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        JComponent accessory = fc.getAccessory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        if(accessory != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            getAccessoryPanel().add(accessory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        filePane.setPreferredSize(LIST_PREF_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        fc.add(filePane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        // ********************************** //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        // **** Construct the bottom panel ** //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        // ********************************** //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        JPanel bottomPanel = getBottomPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        fc.add(bottomPanel, BorderLayout.SOUTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        // FileName label and textfield
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        JPanel fileNamePanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        bottomPanel.add(fileNamePanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        bottomPanel.add(Box.createRigidArea(vstrut5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        fileNameLabel = new AlignedLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        populateFileNameLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        fileNamePanel.add(fileNameLabel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   385
        @SuppressWarnings("serial") // anonymous class
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   386
        JTextField tmp2 = new JTextField(35) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            public Dimension getMaximumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        };
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   391
        fileNameTextField = tmp2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        fileNamePanel.add(fileNameTextField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        fileNameLabel.setLabelFor(fileNameTextField);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        fileNameTextField.addFocusListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            new FocusAdapter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                public void focusGained(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    if (!getFileChooser().isMultiSelectionEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                        filePane.clearSelection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        if (fc.isMultiSelectionEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            setFileName(fileNameString(fc.getSelectedFiles()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            setFileName(fileNameString(fc.getSelectedFile()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        // Filetype label and combobox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        JPanel filesOfTypePanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        bottomPanel.add(filesOfTypePanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        filesOfTypeLabel.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        filesOfTypePanel.add(filesOfTypeLabel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        filterComboBoxModel = createFilterComboBoxModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        fc.addPropertyChangeListener(filterComboBoxModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        filterComboBox = new JComboBox(filterComboBoxModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                         filesOfTypeLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        filesOfTypeLabel.setLabelFor(filterComboBox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        filterComboBox.setRenderer(createFilterComboBoxRenderer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        filesOfTypePanel.add(filterComboBox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        // buttons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        getButtonPanel().setLayout(new ButtonAreaLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        approveButton = new JButton(getApproveButtonText(fc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        // Note: Metal does not use mnemonics for approve and cancel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        approveButton.addActionListener(getApproveSelectionAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        approveButton.setToolTipText(getApproveButtonToolTipText(fc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        getButtonPanel().add(approveButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        cancelButton = new JButton(cancelButtonText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        cancelButton.setToolTipText(cancelButtonToolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        cancelButton.addActionListener(getCancelSelectionAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        getButtonPanel().add(cancelButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        if(fc.getControlButtonsAreShown()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            addControlButtons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    protected JPanel getButtonPanel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        if (buttonPanel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            buttonPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return buttonPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    protected JPanel getBottomPanel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        if(bottomPanel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            bottomPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        return bottomPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    protected void installStrings(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        super.installStrings(fc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        Locale l = fc.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
10413
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   468
        lookInLabelMnemonic = getMnemonic("FileChooser.lookInLabelMnemonic", l);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        lookInLabelText = UIManager.getString("FileChooser.lookInLabelText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        saveInLabelText = UIManager.getString("FileChooser.saveInLabelText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
10413
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   472
        fileNameLabelMnemonic = getMnemonic("FileChooser.fileNameLabelMnemonic", l);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        fileNameLabelText = UIManager.getString("FileChooser.fileNameLabelText",l);
10413
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   474
        folderNameLabelMnemonic = getMnemonic("FileChooser.folderNameLabelMnemonic", l);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        folderNameLabelText = UIManager.getString("FileChooser.folderNameLabelText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
10413
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   477
        filesOfTypeLabelMnemonic = getMnemonic("FileChooser.filesOfTypeLabelMnemonic", l);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        filesOfTypeLabelText = UIManager.getString("FileChooser.filesOfTypeLabelText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        upFolderToolTipText =  UIManager.getString("FileChooser.upFolderToolTipText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        upFolderAccessibleName = UIManager.getString("FileChooser.upFolderAccessibleName",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        homeFolderToolTipText =  UIManager.getString("FileChooser.homeFolderToolTipText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        homeFolderAccessibleName = UIManager.getString("FileChooser.homeFolderAccessibleName",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        newFolderAccessibleName = UIManager.getString("FileChooser.newFolderAccessibleName",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        listViewButtonToolTipText = UIManager.getString("FileChooser.listViewButtonToolTipText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        listViewButtonAccessibleName = UIManager.getString("FileChooser.listViewButtonAccessibleName",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        detailsViewButtonToolTipText = UIManager.getString("FileChooser.detailsViewButtonToolTipText",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        detailsViewButtonAccessibleName = UIManager.getString("FileChooser.detailsViewButtonAccessibleName",l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
10413
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   496
    private Integer getMnemonic(String key, Locale l) {
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   497
        return SwingUtilities2.getUIDefaultsInt(key, l);
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   498
    }
5bd4f81b6d45 7024118: possible hardcoded mnemonic for JFileChooser metal and motif l&f
rupashka
parents: 9665
diff changeset
   499
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    protected void installListeners(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        super.installListeners(fc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        ActionMap actionMap = getActionMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        SwingUtilities.replaceUIActionMap(fc, actionMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    protected ActionMap getActionMap() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        return createActionMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    protected ActionMap createActionMap() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        ActionMap map = new ActionMapUIResource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        FilePane.addActionsToMap(map, filePane.getActions());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        return map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    protected JPanel createList(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        return filePane.createList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    protected JPanel createDetailsView(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        return filePane.createDetailsView();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * Creates a selection listener for the list of files and directories.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * @param fc a <code>JFileChooser</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * @return a <code>ListSelectionListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    public ListSelectionListener createListSelectionListener(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        return super.createListSelectionListener(fc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    // Obsolete class, not used in this version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    protected class SingleClickListener extends MouseAdapter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        public  SingleClickListener(JList list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    // Obsolete class, not used in this version.
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   541
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    protected class FileRenderer extends DefaultListCellRenderer  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    public void uninstallUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        // Remove listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        c.removePropertyChangeListener(filterComboBoxModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        c.removePropertyChangeListener(filePane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        cancelButton.removeActionListener(getCancelSelectionAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        approveButton.removeActionListener(getApproveSelectionAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        fileNameTextField.removeActionListener(getApproveSelectionAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (filePane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            filePane.uninstallUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            filePane = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        super.uninstallUI(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * Returns the preferred size of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <code>JFileChooser</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * The preferred size is at least as large,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * in both height and width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * as the preferred size recommended
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * by the file chooser's layout manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * @param c  a <code>JFileChooser</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @return   a <code>Dimension</code> specifying the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     *           width and height of the file chooser
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    public Dimension getPreferredSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        int prefWidth = PREF_SIZE.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        Dimension d = c.getLayout().preferredLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        if (d != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            return new Dimension(d.width < prefWidth ? prefWidth : d.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                                 d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            return new Dimension(prefWidth, PREF_SIZE.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * Returns the minimum size of the <code>JFileChooser</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * @param c  a <code>JFileChooser</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @return   a <code>Dimension</code> specifying the minimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     *           width and height of the file chooser
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    public Dimension getMinimumSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        return MIN_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * Returns the maximum size of the <code>JFileChooser</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @param c  a <code>JFileChooser</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @return   a <code>Dimension</code> specifying the maximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *           width and height of the file chooser
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public Dimension getMaximumSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    private String fileNameString(File file) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        if (file == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            JFileChooser fc = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                return file.getPath();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                return file.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    private String fileNameString(File[] files) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        StringBuffer buf = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        for (int i = 0; files != null && i < files.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            if (i > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                buf.append(" ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            if (files.length > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                buf.append("\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            buf.append(fileNameString(files[i]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            if (files.length > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                buf.append("\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        return buf.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    /* The following methods are used by the PropertyChange Listener */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    private void doSelectedFileChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        File f = (File) e.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        JFileChooser fc = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        if (f != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            && ((fc.isFileSelectionEnabled() && !f.isDirectory())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                || (f.isDirectory() && fc.isDirectorySelectionEnabled()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            setFileName(fileNameString(f));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    private void doSelectedFilesChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        File[] files = (File[]) e.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        JFileChooser fc = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        if (files != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            && files.length > 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            setFileName(fileNameString(files));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    private void doDirectoryChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        JFileChooser fc = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        FileSystemView fsv = fc.getFileSystemView();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        clearIconCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        File currentDirectory = fc.getCurrentDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        if(currentDirectory != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            directoryComboBoxModel.addItem(currentDirectory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                if (fsv.isFileSystem(currentDirectory)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                    setFileName(currentDirectory.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                    setFileName(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    private void doFilterChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        clearIconCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    private void doFileSelectionModeChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        if (fileNameLabel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            populateFileNameLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        clearIconCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        JFileChooser fc = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        File currentDirectory = fc.getCurrentDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        if (currentDirectory != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            && fc.isDirectorySelectionEnabled()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            && !fc.isFileSelectionEnabled()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            && fc.getFileSystemView().isFileSystem(currentDirectory)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            setFileName(currentDirectory.getPath());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            setFileName(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    private void doAccessoryChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        if(getAccessoryPanel() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            if(e.getOldValue() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                getAccessoryPanel().remove((JComponent) e.getOldValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            JComponent accessory = (JComponent) e.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            if(accessory != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                getAccessoryPanel().add(accessory, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    private void doApproveButtonTextChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        JFileChooser chooser = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        approveButton.setText(getApproveButtonText(chooser));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    private void doDialogTypeChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        JFileChooser chooser = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        approveButton.setText(getApproveButtonText(chooser));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        if (chooser.getDialogType() == JFileChooser.SAVE_DIALOG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            lookInLabel.setText(saveInLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            lookInLabel.setText(lookInLabelText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    private void doApproveButtonMnemonicChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        // Note: Metal does not use mnemonics for approve and cancel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    private void doControlButtonsChanged(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        if(getFileChooser().getControlButtonsAreShown()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            addControlButtons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            removeControlButtons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * Listen for filechooser property changes, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * the selected file changing, or the type of the dialog changing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        return new PropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                String s = e.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                if(s.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                    doSelectedFileChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                } else if (s.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                    doSelectedFilesChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                } else if(s.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                    doDirectoryChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                } else if(s.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                    doFilterChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                } else if(s.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                    doFileSelectionModeChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                } else if(s.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                    doAccessoryChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                } else if (s.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                           s.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                    doApproveButtonTextChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                } else if(s.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                    doDialogTypeChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                } else if(s.equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                    doApproveButtonMnemonicChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                } else if(s.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                    doControlButtonsChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                } else if (s.equals("componentOrientation")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                    ComponentOrientation o = (ComponentOrientation)e.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                    JFileChooser cc = (JFileChooser)e.getSource();
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   775
                    if (o != e.getOldValue()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                        cc.applyComponentOrientation(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                } else if (s == "FileChooser.useShellFolder") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                    doDirectoryChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                } else if (s.equals("ancestor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                    if (e.getOldValue() == null && e.getNewValue() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                        // Ancestor was added, set initial focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                        fileNameTextField.selectAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                        fileNameTextField.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    protected void removeControlButtons() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        getBottomPanel().remove(getButtonPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    protected void addControlButtons() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        getBottomPanel().add(getButtonPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    public void ensureFileIsVisible(JFileChooser fc, File f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        filePane.ensureFileIsVisible(fc, f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    public void rescanCurrentDirectory(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        filePane.rescanCurrentDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    public String getFileName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        if (fileNameTextField != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            return fileNameTextField.getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    public void setFileName(String filename) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        if (fileNameTextField != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            fileNameTextField.setText(filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * Property to remember whether a directory is currently selected in the UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * This is normally called by the UI on a selection event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * @param directorySelected if a directory is currently selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    protected void setDirectorySelected(boolean directorySelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        super.setDirectorySelected(directorySelected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        JFileChooser chooser = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        if(directorySelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            if (approveButton != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                approveButton.setText(directoryOpenButtonText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                approveButton.setToolTipText(directoryOpenButtonToolTipText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
            if (approveButton != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                approveButton.setText(getApproveButtonText(chooser));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    public String getDirectoryName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        // PENDING(jeff) - get the name from the directory combobox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    public void setDirectoryName(String dirname) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        // PENDING(jeff) - set the name in the directory combobox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    protected DirectoryComboBoxRenderer createDirectoryComboBoxRenderer(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        return new DirectoryComboBoxRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    // Renderer for DirectoryComboBox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    //
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   861
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    class DirectoryComboBoxRenderer extends DefaultListCellRenderer  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        IndentIcon ii = new IndentIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        public Component getListCellRendererComponent(JList list, Object value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                                                      int index, boolean isSelected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                                                      boolean cellHasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            File directory = (File)value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            setText(getFileChooser().getName(directory));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            Icon icon = getFileChooser().getIcon(directory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            ii.icon = icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            ii.depth = directoryComboBoxModel.getDepth(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            setIcon(ii);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    final static int space = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    class IndentIcon implements Icon {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        Icon icon = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        int depth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            if (c.getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                icon.paintIcon(c, g, x+depth*space, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                icon.paintIcon(c, g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            return icon.getIconWidth() + depth*space;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            return icon.getIconHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    // DataModel for DirectoryComboxbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        return new DirectoryComboBoxModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * Data model for a type-face selection combo-box.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
   919
    @SuppressWarnings("serial") // Superclass is not serializable across versions
9665
f43db0b310cc 7031551: Generics: JComboBox
rupashka
parents: 5506
diff changeset
   920
    protected class DirectoryComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object> {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   921
        Vector<File> directories = new Vector<File>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        int[] depths = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        File selectedDirectory = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        JFileChooser chooser = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        FileSystemView fsv = chooser.getFileSystemView();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        public DirectoryComboBoxModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            // Add the current directory to the model, and make it the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            // selectedDirectory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            File dir = getFileChooser().getCurrentDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            if(dir != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                addItem(dir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
         * Adds the directory to the model and sets it to be selected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
         * additionally clears out the previous selected directory and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
         * the paths leading up to it, if any.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        private void addItem(File directory) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            if(directory == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
1842
824c7f885a64 6776856: Code with useShellFolder field shuold be simplify
rupashka
parents: 1290
diff changeset
   947
            boolean useShellFolder = FilePane.usesShellFolder(chooser);
824c7f885a64 6776856: Code with useShellFolder field shuold be simplify
rupashka
parents: 1290
diff changeset
   948
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            directories.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            File[] baseFolders;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
            if (useShellFolder) {
2491
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
   953
                baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
   954
                    public File[] run() {
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
   955
                        return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
   956
                    }
123954ad0034 6738668: JFileChooser cannot be created under SecurityManager
rupashka
parents: 1853
diff changeset
   957
                });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                baseFolders = fsv.getRoots();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            directories.addAll(Arrays.asList(baseFolders));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            // Get the canonical (full) path. This has the side
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            // benefit of removing extraneous chars from the path,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            // for example /foo/bar/ becomes /foo/bar
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   966
            File canonical;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                canonical = ShellFolder.getNormalizedFile(directory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                // Maybe drive is not ready. Can't abort here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                canonical = directory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            // create File instances of each directory leading up to the top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                                         : canonical;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                File f = sf;
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   979
                Vector<File> path = new Vector<File>(10);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                    path.addElement(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                } while ((f = f.getParentFile()) != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                int pathCount = path.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                // Insert chain at appropriate place in vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                for (int i = 0; i < pathCount; i++) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   987
                    f = path.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                    if (directories.contains(f)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                        int topIndex = directories.indexOf(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                        for (int j = i-1; j >= 0; j--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                            directories.insertElementAt(path.get(j), topIndex+i-j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                calculateDepths();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                setSelectedItem(sf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            } catch (FileNotFoundException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                calculateDepths();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        private void calculateDepths() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            depths = new int[directories.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            for (int i = 0; i < depths.length; i++) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
  1006
                File dir = directories.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                File parent = dir.getParentFile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                depths[i] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                    for (int j = i-1; j >= 0; j--) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
  1011
                        if (parent.equals(directories.get(j))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                            depths[i] = depths[j] + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        public int getDepth(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
        public void setSelectedItem(Object selectedDirectory) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            this.selectedDirectory = (File)selectedDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            fireContentsChanged(this, -1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
        public Object getSelectedItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            return selectedDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        public int getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            return directories.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        public Object getElementAt(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            return directories.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    // Renderer for Types ComboBox
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        return new FilterComboBoxRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * Render different type sizes and styles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
  1052
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    public class FilterComboBoxRenderer extends DefaultListCellRenderer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        public Component getListCellRendererComponent(JList list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            Object value, int index, boolean isSelected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            boolean cellHasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            if (value != null && value instanceof FileFilter) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                setText(((FileFilter)value).getDescription());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
    // DataModel for Types Comboxbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    protected FilterComboBoxModel createFilterComboBoxModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        return new FilterComboBoxModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * Data model for a type-face selection combo-box.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
  1078
    @SuppressWarnings("serial") // Same-version serialization only
23270
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1079
    protected class FilterComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object>, PropertyChangeListener {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1080
        protected FileFilter[] filters;
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1081
        protected FilterComboBoxModel() {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1082
            super();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1083
            filters = getFileChooser().getChoosableFileFilters();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1084
        }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1085
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1086
        public void propertyChange(PropertyChangeEvent e) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1087
            String prop = e.getPropertyName();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1088
            if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1089
                filters = (FileFilter[]) e.getNewValue();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1090
                fireContentsChanged(this, -1, -1);
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1091
            } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1092
                fireContentsChanged(this, -1, -1);
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1093
            }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1094
        }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1095
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1096
        public void setSelectedItem(Object filter) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1097
            if(filter != null) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1098
                getFileChooser().setFileFilter((FileFilter) filter);
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1099
                fireContentsChanged(this, -1, -1);
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1100
            }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1101
        }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1102
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1103
        public Object getSelectedItem() {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1104
            // Ensure that the current filter is in the list.
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1105
            // NOTE: we shouldnt' have to do this, since JFileChooser adds
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1106
            // the filter to the choosable filters list when the filter
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1107
            // is set. Lets be paranoid just in case someone overrides
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1108
            // setFileFilter in JFileChooser.
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1109
            FileFilter currentFilter = getFileChooser().getFileFilter();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1110
            boolean found = false;
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1111
            if(currentFilter != null) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1112
                for (FileFilter filter : filters) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1113
                    if (filter == currentFilter) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1114
                        found = true;
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1115
                    }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1116
                }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1117
                if(found == false) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1118
                    getFileChooser().addChoosableFileFilter(currentFilter);
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1119
                }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1120
            }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1121
            return getFileChooser().getFileFilter();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1122
        }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1123
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1124
        public int getSize() {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1125
            if(filters != null) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1126
                return filters.length;
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1127
            } else {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1128
                return 0;
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1129
            }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1130
        }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1131
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1132
        public Object getElementAt(int index) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1133
            if(index > getSize() - 1) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1134
                // This shouldn't happen. Try to recover gracefully.
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1135
                return getFileChooser().getFileFilter();
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1136
            }
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1137
            if(filters != null) {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1138
                return filters[index];
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1139
            } else {
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1140
                return null;
b5073d208bbf 8032063: javax.swing.plaf.metal.MetalFileChooserUI$FilterComboBoxModel extends non-standard API
alexsch
parents: 20169
diff changeset
  1141
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    public void valueChanged(ListSelectionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        JFileChooser fc = getFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        File f = fc.getSelectedFile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        if (!e.getValueIsAdjusting() && f != null && !getFileChooser().isTraversable(f)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
            setFileName(fileNameString(f));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     * Acts when DirectoryComboBox has changed the selected item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
  1156
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    protected class DirectoryComboBoxAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        protected DirectoryComboBoxAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
            super("DirectoryComboBoxAction");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
            directoryComboBox.hidePopup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
            File f = (File)directoryComboBox.getSelectedItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
            if (!getFileChooser().getCurrentDirectory().equals(f)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                getFileChooser().setCurrentDirectory(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
    protected JButton getApproveButton(JFileChooser fc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
        return approveButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * <code>ButtonAreaLayout</code> behaves in a similar manner to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * <code>FlowLayout</code>. It lays out all components from left to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     * right, flushed right. The widths of all components will be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     * to the largest preferred size width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    private static class ButtonAreaLayout implements LayoutManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        private int hGap = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        private int topMargin = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        public void addLayoutComponent(String string, Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        public void layoutContainer(Container container) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
            Component[] children = container.getComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
            if (children != null && children.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                int         numChildren = children.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                Dimension[] sizes = new Dimension[numChildren];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                Insets      insets = container.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                int         yLocation = insets.top + topMargin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                int         maxWidth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
                for (int counter = 0; counter < numChildren; counter++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                    sizes[counter] = children[counter].getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                    maxWidth = Math.max(maxWidth, sizes[counter].width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                int xLocation, xOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                if (container.getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                    xLocation = container.getSize().width - insets.left - maxWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                    xOffset = hGap + maxWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                    xLocation = insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                    xOffset = -(hGap + maxWidth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
                for (int counter = numChildren - 1; counter >= 0; counter--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                    children[counter].setBounds(xLocation, yLocation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
                                                maxWidth, sizes[counter].height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                    xLocation -= xOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
            if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                Component[] children = c.getComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                if (children != null && children.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                    int       numChildren = children.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                    int       height = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                    Insets    cInsets = c.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                    int       extraHeight = topMargin + cInsets.top + cInsets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
                    int       extraWidth = cInsets.left + cInsets.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                    int       maxWidth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                    for (int counter = 0; counter < numChildren; counter++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                        Dimension aSize = children[counter].getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                        height = Math.max(height, aSize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                        maxWidth = Math.max(maxWidth, aSize.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
                    return new Dimension(extraWidth + numChildren * maxWidth +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
                                         (numChildren - 1) * hGap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                                         extraHeight + height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
            return new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        public Dimension preferredLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
            return minimumLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
        public void removeLayoutComponent(Component c) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
    private static void groupLabels(AlignedLabel[] group) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        for (int i = 0; i < group.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            group[i].group = group;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23328
diff changeset
  1257
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
    private class AlignedLabel extends JLabel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
        private AlignedLabel[] group;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        private int maxWidth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
        AlignedLabel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
            setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
        AlignedLabel(String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
            super(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
            setAlignmentX(JComponent.LEFT_ALIGNMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            Dimension d = super.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
            // Align the width with all other labels in group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            return new Dimension(getMaxWidth() + 11, d.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        private int getMaxWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
            if (maxWidth == 0 && group != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
                int max = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
                for (int i = 0; i < group.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                    max = Math.max(group[i].getSuperPreferredWidth(), max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                for (int i = 0; i < group.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                    group[i].maxWidth = max;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
            return maxWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
        private int getSuperPreferredWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            return super.getPreferredSize().width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
}