/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.accessibility.*;
/**
* Windows L&F implementation of a FileChooser.
*
* @author Jeff Dinkins
*/
// The following are private because the implementation of the
// Windows FileChooser L&F is not complete yet.
// Preferred and Minimum sizes for the dialog box
// Labels, mnemonics, and tooltips (oh my!)
private void populateFileNameLabel() {
} else {
}
}
//
// ComponentUI Interface Implementation methods
//
return new WindowsFileChooserUI((JFileChooser) c);
}
super(filechooser);
}
super.installUI(c);
}
}
return WindowsFileChooserUI.this.getFileChooser();
}
return WindowsFileChooserUI.this.getModel();
}
}
}
public boolean isDirectorySelected() {
return WindowsFileChooserUI.this.isDirectorySelected();
}
return WindowsFileChooserUI.this.getDirectory();
}
return WindowsFileChooserUI.this.getChangeToParentDirectoryAction();
}
return WindowsFileChooserUI.this.getApproveSelectionAction();
}
return WindowsFileChooserUI.this.getNewFolderAction();
}
list);
}
}
}
// ********************************* //
// **** Construct the top panel **** //
// ********************************* //
// Directory manipulation buttons
topPanel.setFloatable(false);
// Add the top panel to the fileChooser
// ComboBox Label
public Dimension getPreferredSize() {
return getMinimumSize();
}
public Dimension getMinimumSize() {
Dimension d = super.getPreferredSize();
}
return d;
}
};
// CurrentDir ComboBox
directoryComboBox = new JComboBox() {
public Dimension getMinimumSize() {
Dimension d = super.getMinimumSize();
d.width = 60;
return d;
}
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
// Must be small enough to not affect total width.
d.width = 150;
return d;
}
};
// Up Button
// New Directory Button
}
// View button group
// Popup Menu
// Create icon for viewMenuButton
BufferedImage image = new BufferedImage(viewMenuIcon.getIconWidth() + 7, viewMenuIcon.getIconHeight(),
// Details Button
final JButton viewMenuButton = createToolButton(null, new ImageIcon(image), viewMenuButtonToolTipText,
public void mousePressed(MouseEvent e) {
viewMenuButton.setSelected(true);
}
}
});
public void keyPressed(KeyEvent e) {
// Forbid keyboard actions if the button is not in rollover state
viewMenuButton.setSelected(true);
}
}
});
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
public void run() {
viewMenuButton.setSelected(false);
}
});
}
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
public void propertyChange(PropertyChangeEvent e) {
switch (filePane.getViewType()) {
case FilePane.VIEWTYPE_LIST:
listViewMenuItem.setSelected(true);
break;
case FilePane.VIEWTYPE_DETAILS:
detailsViewMenuItem.setSelected(true);
break;
}
}
}
});
// ************************************** //
// ******* Add the directory pane ******* //
// ************************************** //
}
// ********************************** //
// **** Construct the bottom panel ** //
// ********************************** //
// Add the bottom panel to file chooser
// labels
fileNameLabel = new JLabel();
// file entry and filters
public Dimension getMaximumSize() {
}
};
new FocusAdapter() {
public void focusGained(FocusEvent e) {
if (!getFileChooser().isMultiSelectionEnabled()) {
}
}
}
);
if (fc.isMultiSelectionEnabled()) {
} else {
}
// buttons
public Dimension getMaximumSize() {
}
};
public Dimension getMaximumSize() {
}
};
if(fc.getControlButtonsAreShown()) {
}
}
private void updateUseShellFolder() {
// Decide whether to use the ShellFolder class to populate shortcut
// panel and combobox.
}
} else {
}
}
}
if(buttonPanel == null) {
buttonPanel = new JPanel();
}
return buttonPanel;
}
if(bottomPanel == null) {
bottomPanel = new JPanel();
}
return bottomPanel;
}
super.installStrings(fc);
}
}
super.installListeners(fc);
}
return createActionMap();
}
return map;
}
return filePane.createList();
}
return filePane.createDetailsView();
}
/**
* Creates a selection listener for the list of files and directories.
*
* @param fc a <code>JFileChooser</code>
* @return a <code>ListSelectionListener</code>
*/
return super.createListSelectionListener(fc);
}
// Obsolete class, not used in this version.
}
// Obsolete class, not used in this version.
}
// Obsolete class, not used in this version.
}
// Remove listeners
}
}
super.uninstallUI(c);
}
/**
* Returns the preferred size of the specified
* <code>JFileChooser</code>.
* The preferred size is at least as large,
* in both height and width,
* as the preferred size recommended
* by the file chooser's layout manager.
*
* @param c a <code>JFileChooser</code>
* @return a <code>Dimension</code> specifying the preferred
* width and height of the file chooser
*/
if (d != null) {
} else {
}
}
/**
* Returns the minimum size of the <code>JFileChooser</code>.
*
* @param c a <code>JFileChooser</code>
* @return a <code>Dimension</code> specifying the minimum
* width and height of the file chooser
*/
return MIN_SIZE;
}
/**
* Returns the maximum size of the <code>JFileChooser</code>.
*
* @param c a <code>JFileChooser</code>
* @return a <code>Dimension</code> specifying the maximum
* width and height of the file chooser
*/
}
return null;
} else {
(fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){
} else {
}
}
}
if (i > 0) {
}
}
}
}
}
/* The following methods are used by the PropertyChange Listener */
if (f != null
}
}
}
}
if(currentDirectory != null) {
} else {
}
}
}
}
}
if (fileNameLabel != null) {
}
if (currentDirectory != null
&& !fc.isFileSelectionEnabled()
} else {
}
}
if(getAccessoryPanel() != null) {
if(e.getOldValue() != null) {
}
}
}
}
}
} else {
}
}
}
if(getFileChooser().getControlButtonsAreShown()) {
} else {
}
}
/*
* Listen for filechooser property changes, such as
* the selected file changing, or the type of the dialog changing.
*/
return new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String s = e.getPropertyName();
doFilterChanged(e);
} else if (s == "FileChooser.useShellFolder") {
} else if (s.equals("componentOrientation")) {
if (o != e.getOldValue()) {
}
} else if (s.equals("ancestor")) {
// Ancestor was added, set initial focus
}
}
}
};
}
protected void removeControlButtons() {
}
protected void addControlButtons() {
}
}
}
if(filenameTextField != null) {
return filenameTextField.getText();
} else {
return null;
}
}
if(filenameTextField != null) {
}
}
/**
* Property to remember whether a directory is currently selected in the UI.
* This is normally called by the UI on a selection event.
*
* @param directorySelected if a directory is currently selected.
* @since 1.4
*/
if(directorySelected) {
} else {
}
}
// PENDING(jeff) - get the name from the directory combobox
return null;
}
// PENDING(jeff) - set the name in the directory combobox
}
return new DirectoryComboBoxRenderer();
}
private static JButton createToolButton(Action a, Icon defaultIcon, String toolTipText, String accessibleName) {
result.setRequestFocusEnabled(false);
result.setFocusPainted(false);
public void setPressed(boolean b) {
// Forbid keyboard actions if the button is not in rollover state
if (!b || isRollover()) {
super.setPressed(b);
}
}
public void setRollover(boolean b) {
if (b && !isRollover()) {
// Reset other buttons
}
}
}
super.setRollover(b);
}
public void setSelected(boolean b) {
super.setSelected(b);
if (b) {
} else {
}
}
});
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
}
});
return result;
}
//
// Renderer for DirectoryComboBox
//
int index, boolean isSelected,
boolean cellHasFocus) {
setText("");
return this;
}
return this;
}
}
if (c.getComponentOrientation().isLeftToRight()) {
} else {
}
}
public int getIconWidth() {
}
public int getIconHeight() {
return icon.getIconHeight();
}
}
//
// DataModel for DirectoryComboxbox
//
return new DirectoryComboBoxModel();
}
/**
* Data model for a type-face selection combo-box.
*/
public DirectoryComboBoxModel() {
// Add the current directory to the model, and make it the
// selectedDirectory
}
}
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
return;
}
directories.clear();
File[] baseFolders;
if (useShellFolder) {
}
});
} else {
}
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
try {
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
}
// create File instances of each directory leading up to the top
try {
: canonical;
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
if (directories.contains(f)) {
for (int j = i-1; j >= 0; j--) {
}
break;
}
}
} catch (FileNotFoundException ex) {
}
}
private void calculateDepths() {
depths[i] = 0;
for (int j = i-1; j >= 0; j--) {
break;
}
}
}
}
}
public int getDepth(int i) {
}
}
return selectedDirectory;
}
public int getSize() {
return directories.size();
}
}
}
//
// Renderer for Types ComboBox
//
return new FilterComboBoxRenderer();
}
/**
* Render different type sizes and styles.
*/
boolean cellHasFocus) {
}
return this;
}
}
//
// DataModel for Types Comboxbox
//
return new FilterComboBoxModel();
}
/**
* Data model for a type-face selection combo-box.
*/
protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener {
protected FilterComboBoxModel() {
super();
}
}
}
}
}
// Ensure that the current filter is in the list.
// NOTE: we shouldnt' have to do this, since JFileChooser adds
// the filter to the choosable filters list when the filter
// is set. Lets be paranoid just in case someone overrides
// setFileFilter in JFileChooser.
boolean found = false;
if(currentFilter != null) {
if (filter == currentFilter) {
found = true;
}
}
if(found == false) {
}
}
return getFileChooser().getFileFilter();
}
public int getSize() {
} else {
return 0;
}
}
// This shouldn't happen. Try to recover gracefully.
return getFileChooser().getFileFilter();
}
} else {
return null;
}
}
}
}
}
/**
* Acts when DirectoryComboBox has changed the selected item.
*/
}
}
return approveButton;
}
return fileView;
}
// ***********************
// * FileView operations *
// ***********************
/* FileView type descriptions */
return icon;
}
if (f != null) {
}
}
return icon;
}
}
}