/*
* 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.*;
/**
* Metal L&F implementation of a FileChooser.
*
* @author Jeff Dinkins
*/
// Much of the Metal UI for JFilechooser is just a copy of
// the windows implementation, but using Metal themed buttons, lists,
// icons, etc. We are planning a complete rewrite, and hence we've
// made most things in this class private.
// Preferred and Minimum sizes for the dialog box
// Labels, mnemonics, and tooltips (oh my!)
private void populateFileNameLabel() {
} else {
}
}
//
// ComponentUI Interface Implementation methods
//
return new MetalFileChooserUI((JFileChooser) c);
}
super(filechooser);
}
super.installUI(c);
}
bottomPanel = null;
buttonPanel = null;
}
return MetalFileChooserUI.this.getFileChooser();
}
return MetalFileChooserUI.this.getModel();
}
}
}
public boolean isDirectorySelected() {
return MetalFileChooserUI.this.isDirectorySelected();
}
return MetalFileChooserUI.this.getDirectory();
}
return MetalFileChooserUI.this.getChangeToParentDirectoryAction();
}
return MetalFileChooserUI.this.getApproveSelectionAction();
}
return MetalFileChooserUI.this.getNewFolderAction();
}
list);
}
}
}
// ********************************* //
// **** Construct the top panel **** //
// ********************************* //
// Directory manipulation buttons
// Add the top panel to the fileChooser
// ComboBox Label
// CurrentDir ComboBox
directoryComboBox = new JComboBox() {
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
// Must be small enough to not affect total width.
d.width = 150;
return d;
}
};
// Up Button
// Home Button
}
b.setMargin(shrinkwrap);
topButtonPanel.add(b);
// New Directory Button
b.setIcon(newFolderIcon);
b.setMargin(shrinkwrap);
}
topButtonPanel.add(b);
// View button group
// List Button
listViewButton.setSelected(true);
// Details Button
public void propertyChange(PropertyChangeEvent e) {
switch (viewType) {
case FilePane.VIEWTYPE_LIST:
listViewButton.setSelected(true);
break;
case FilePane.VIEWTYPE_DETAILS:
detailsViewButton.setSelected(true);
break;
}
}
}
});
// ************************************** //
// ******* Add the directory pane ******* //
// ************************************** //
}
// ********************************** //
// **** Construct the bottom panel ** //
// ********************************** //
// FileName label and textfield
fileNameLabel = new AlignedLabel();
public Dimension getMaximumSize() {
}
};
new FocusAdapter() {
public void focusGained(FocusEvent e) {
if (!getFileChooser().isMultiSelectionEnabled()) {
}
}
}
);
if (fc.isMultiSelectionEnabled()) {
} else {
}
// Filetype label and combobox
// buttons
// Note: Metal does not use mnemonics for approve and cancel
if(fc.getControlButtonsAreShown()) {
}
}
if (buttonPanel == null) {
buttonPanel = new JPanel();
}
return buttonPanel;
}
if(bottomPanel == null) {
bottomPanel = new JPanel();
}
return bottomPanel;
}
super.installStrings(fc);
detailsViewButtonAccessibleName = UIManager.getString("FileChooser.detailsViewButtonAccessibleName",l);
}
}
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.
}
// 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 {
}
}
// Note: Metal does not use mnemonics for approve and cancel
}
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.equals("componentOrientation")) {
if (o != e.getOldValue()) {
}
} else if (s == "FileChooser.useShellFolder") {
} 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) {
if (approveButton != null) {
}
} else {
if (approveButton != null) {
}
}
}
// PENDING(jeff) - get the name from the directory combobox
return null;
}
// PENDING(jeff) - set the name in the directory combobox
}
return new DirectoryComboBoxRenderer();
}
//
// 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.
*/
protected class DirectoryComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object> {
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<Object> implements ComboBoxModel<Object>, 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.
*/
protected DirectoryComboBoxAction() {
super("DirectoryComboBoxAction");
}
}
}
}
return approveButton;
}
/**
* <code>ButtonAreaLayout</code> behaves in a similar manner to
* <code>FlowLayout</code>. It lays out all components from left to
* right, flushed right. The widths of all components will be set
* to the largest preferred size width.
*/
}
int maxWidth = 0;
}
} else {
}
}
}
}
if (c != null) {
int height = 0;
int maxWidth = 0;
}
extraHeight + height);
}
}
}
return minimumLayoutSize(c);
}
}
}
}
AlignedLabel() {
super();
}
super(text);
}
Dimension d = super.getPreferredSize();
// Align the width with all other labels in group.
}
private int getMaxWidth() {
int max = 0;
}
}
}
return maxWidth;
}
private int getSuperPreferredWidth() {
return super.getPreferredSize().width;
}
}
}