Methods Summary |
---|
protected void | align(javax.swing.JComponent c)
c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
c.setAlignmentY(JComponent.TOP_ALIGNMENT);
|
protected com.sun.java.swing.plaf.gtk.GTKFileChooserUI$DirectoryComboBoxModel | createDirectoryComboBoxModel(javax.swing.JFileChooser fc)
return new DirectoryComboBoxModel();
|
protected javax.swing.JScrollPane | createDirectoryList()
directoryList = new JList();
directoryList.setName("GTKFileChooser.directoryList");
align(directoryList);
directoryList.setCellRenderer(new DirectoryCellRenderer());
directoryListModel = new GTKDirectoryListModel();
directoryList.getSelectionModel().removeSelectionInterval(0, 0);
directoryList.setModel(directoryListModel);
directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList));
directoryList.addListSelectionListener(createListSelectionListener(getFileChooser()));
JScrollPane scrollpane = new JScrollPane(directoryList);
scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollpane.setName("GTKFileChooser.directoryListScrollPane");
scrollpane.setMaximumSize(MAX_SIZE);
scrollpane.setPreferredSize(prefListSize);
align(scrollpane);
return scrollpane;
|
protected java.awt.event.MouseListener | createDoubleClickListener(javax.swing.JFileChooser fc, javax.swing.JList list)
return new DoubleClickListener(list);
|
protected javax.swing.JScrollPane | createFilesList()
fileList = new JList();
fileList.setName("GTKFileChooser.fileList");
if (getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
fileList.setModel(new GTKFileListModel());
fileList.getSelectionModel().removeSelectionInterval(0, 0);
fileList.setCellRenderer(new FileCellRenderer());
fileList.addListSelectionListener(createListSelectionListener(getFileChooser()));
fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList));
align(fileList);
JScrollPane scrollpane = new JScrollPane(fileList);
scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollpane.setName("GTKFileChooser.fileListScrollPane");
scrollpane.setPreferredSize(prefListSize);
scrollpane.setMaximumSize(MAX_SIZE);
align(scrollpane);
return scrollpane;
|
protected com.sun.java.swing.plaf.gtk.GTKFileChooserUI$FilterComboBoxModel | createFilterComboBoxModel()
return new FilterComboBoxModel();
|
protected com.sun.java.swing.plaf.gtk.GTKFileChooserUI$FilterComboBoxRenderer | createFilterComboBoxRenderer()
return new FilterComboBoxRenderer();
|
public javax.swing.event.ListSelectionListener | createListSelectionListener(javax.swing.JFileChooser fc)
return new SelectionListener();
|
protected void | createModel()
model = new GTKDirectoryModel();
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)
return new GTKFileChooserUI((JFileChooser)c);
|
protected void | doAccessoryChanged(java.beans.PropertyChangeEvent e)
if (getAccessoryPanel() != null) {
if (e.getOldValue() != null) {
getAccessoryPanel().remove((JComponent)e.getOldValue());
}
JComponent accessory = (JComponent)e.getNewValue();
if (accessory != null) {
getAccessoryPanel().add(accessory, BorderLayout.CENTER);
getAccessoryPanel().setPreferredSize(accessory.getPreferredSize());
getAccessoryPanel().setMaximumSize(MAX_SIZE);
} else {
getAccessoryPanel().setPreferredSize(ZERO_ACC_SIZE);
getAccessoryPanel().setMaximumSize(ZERO_ACC_SIZE);
}
}
|
protected void | doAncestorChanged(java.beans.PropertyChangeEvent e)
if (e.getOldValue() == null && e.getNewValue() != null) {
// Ancestor was added, set initial focus
fileNameTextField.selectAll();
fileNameTextField.requestFocus();
updateDefaultButton();
}
super.doAncestorChanged(e);
|
protected void | doControlButtonsChanged(java.beans.PropertyChangeEvent e)
super.doControlButtonsChanged(e);
JFileChooser filechooser = getFileChooser();
if (filechooser.getControlButtonsAreShown()) {
filechooser.add(bottomButtonPanel, BorderLayout.SOUTH);
} else {
filechooser.remove(bottomButtonPanel);
}
updateDefaultButton();
|
protected void | doDirectoryChanged(java.beans.PropertyChangeEvent e)
directoryList.clearSelection();
ListSelectionModel sm = directoryList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0);
}
fileList.clearSelection();
sm = fileList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0);
}
File currentDirectory = getFileChooser().getCurrentDirectory();
if (currentDirectory != null) {
try {
setDirectoryName(((File)e.getNewValue()).getCanonicalPath());
} catch (IOException ioe) {
setDirectoryName(((File)e.getNewValue()).getAbsolutePath());
}
directoryComboBoxModel.addItem(currentDirectory);
directoryListModel.directoryChanged();
}
super.doDirectoryChanged(e);
|
protected void | doFileSelectionModeChanged(java.beans.PropertyChangeEvent e)
directoryList.clearSelection();
rightPanel.setVisible(((Integer)e.getNewValue()).intValue() != JFileChooser.DIRECTORIES_ONLY);
super.doFileSelectionModeChanged(e);
|
protected void | doMultiSelectionChanged(java.beans.PropertyChangeEvent e)
if (getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fileList.clearSelection();
}
super.doMultiSelectionChanged(e);
|
protected void | doSelectedFileChanged(java.beans.PropertyChangeEvent e)
super.doSelectedFileChanged(e);
File f = (File) e.getNewValue();
if (f != null) {
setFileName(getFileChooser().getName(f));
}
|
public void | ensureFileIsVisible(javax.swing.JFileChooser fc, java.io.File f)
// PENDING
|
public javax.swing.JPanel | getAccessoryPanel()
return accessoryPanel;
|
public javax.swing.Action | getApproveSelectionAction()
return approveSelectionAction;
|
public java.lang.String | getFileName()
JFileChooser fc = getFileChooser();
String typedInName = fileNameTextField != null ?
fileNameTextField.getText() : null;
if (!fc.isMultiSelectionEnabled()) {
return typedInName;
}
int mode = fc.getFileSelectionMode();
JList list = mode == JFileChooser.DIRECTORIES_ONLY ?
directoryList : fileList;
Object[] files = list.getSelectedValues();
int len = files.length;
Vector result = new Vector(len + 1);
// we return all selected file names
for (int i = 0; i < len; i++) {
File file = (File)files[i];
result.add(file.getName());
}
// plus the file name typed into the text field, if not already there
if (typedInName != null && !result.contains(typedInName)) {
result.add(typedInName);
}
StringBuffer buf = new StringBuffer();
len = result.size();
// construct the resulting string
for (int i=0; i<len; i++) {
if (len > 1) {
buf.append(" \"");
}
buf.append(result.get(i));
if (len > 1) {
buf.append("\"");
}
}
return buf.toString();
|
public javax.swing.filechooser.FileView | getFileView(javax.swing.JFileChooser fc)
return fileView;
|
public java.awt.Dimension | getMaximumSize(javax.swing.JComponent x)
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
public java.awt.Dimension | getMinimumSize(javax.swing.JComponent x)
return new Dimension(MIN_SIZE);
|
public javax.swing.plaf.basic.BasicDirectoryModel | getModel()
return model;
|
public javax.swing.Action | getNewFolderAction()
if (newFolderAction == null) {
newFolderAction = new NewFolderAction();
newFolderAction.setEnabled(!readOnly);
}
return newFolderAction;
|
public java.awt.Dimension | getPreferredSize(javax.swing.JComponent c)
Dimension prefSize = new Dimension(PREF_SIZE);
JComponent accessory = getFileChooser().getAccessory();
if (accessory != null) {
prefSize.width += accessory.getPreferredSize().width + 20;
}
Dimension d = c.getLayout().preferredLayoutSize(c);
if (d != null) {
return new Dimension(d.width < prefSize.width ? prefSize.width : d.width,
d.height < prefSize.height ? prefSize.height : d.height);
} else {
return prefSize;
}
|
public void | installComponents(javax.swing.JFileChooser fc)
super.installComponents(fc);
boolean leftToRight = fc.getComponentOrientation().isLeftToRight();
fc.setLayout(new BorderLayout());
fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);
// Top row of buttons
JPanel topButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
topButtonPanel.setBorder(new EmptyBorder(10, 10, 0, 10));
topButtonPanel.setName("GTKFileChooser.topButtonPanel");
if (!UIManager.getBoolean("FileChooser.readOnly")) {
JButton newFolderButton = new JButton(getNewFolderAction());
newFolderButton.setName("GTKFileChooser.newFolderButton");
newFolderButton.setMnemonic(newFolderButtonMnemonic);
newFolderButton.setToolTipText(newFolderButtonToolTipText);
newFolderButton.setText(newFolderButtonText);
topButtonPanel.add(newFolderButton);
}
JButton deleteFileButton = new JButton(deleteFileButtonText);
deleteFileButton.setName("GTKFileChooser.deleteFileButton");
deleteFileButton.setMnemonic(deleteFileButtonMnemonic);
deleteFileButton.setToolTipText(deleteFileButtonToolTipText);
deleteFileButton.setEnabled(false);
topButtonPanel.add(deleteFileButton);
RenameFileAction rfa = new RenameFileAction();
JButton renameFileButton = new JButton(rfa);
if (readOnly) {
rfa.setEnabled(false);
}
renameFileButton.setText(renameFileButtonText);
renameFileButton.setName("GTKFileChooser.renameFileButton");
renameFileButton.setMnemonic(renameFileButtonMnemonic);
renameFileButton.setToolTipText(renameFileButtonToolTipText);
topButtonPanel.add(renameFileButton);
fc.add(topButtonPanel, BorderLayout.NORTH);
interior = new JPanel();
interior.setBorder(new EmptyBorder(0, 10, 10, 10));
interior.setName("GTKFileChooser.interiorPanel");
align(interior);
interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));
fc.add(interior, BorderLayout.CENTER);
JPanel comboBoxPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,
0, 0) {
public void layoutContainer(Container target) {
super.layoutContainer(target);
JComboBox comboBox = directoryComboBox;
if (comboBox.getWidth() > target.getWidth()) {
comboBox.setBounds(0, comboBox.getY(), target.getWidth(),
comboBox.getHeight());
}
}
});
comboBoxPanel.setBorder(new EmptyBorder(0, 0, 4, 0));
comboBoxPanel.setName("GTKFileChooser.directoryComboBoxPanel");
// CurrentDir ComboBox
directoryComboBoxModel = createDirectoryComboBoxModel(fc);
directoryComboBox = new JComboBox(directoryComboBoxModel);
directoryComboBox.setName("GTKFileChooser.directoryComboBox");
directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
directoryComboBox.addActionListener(directoryComboBoxAction);
directoryComboBox.setMaximumRowCount(8);
comboBoxPanel.add(directoryComboBox);
interior.add(comboBoxPanel);
// CENTER: left, right, accessory
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setName("GTKFileChooser.centerPanel");
// SPLIT PANEL: left, right
JSplitPane splitPanel = new JSplitPane();
splitPanel.setName("GTKFileChooser.splitPanel");
splitPanel.setDividerLocation((PREF_SIZE.width-8)/2);
// left panel - Filter & directoryList
JPanel leftPanel = new JPanel(new GridBagLayout());
leftPanel.setName("GTKFileChooser.directoryListPanel");
// Add the Directory List
// Create a label that looks like button (should be a table header)
TableCellRenderer headerRenderer = new JTableHeader().getDefaultRenderer();
JComponent directoryListLabel =
(JComponent)headerRenderer.getTableCellRendererComponent(null, foldersLabelText,
false, false, 0, 0);
directoryListLabel.setName("GTKFileChooser.directoryListLabel");
leftPanel.add(directoryListLabel, new GridBagConstraints(
0, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
leftPanel.add(createDirectoryList(), new GridBagConstraints(
0, 1, 1, 1, 1, 1, GridBagConstraints.EAST,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
// create files list
rightPanel = new JPanel(new GridBagLayout());
rightPanel.setName("GTKFileChooser.fileListPanel");
headerRenderer = new JTableHeader().getDefaultRenderer();
JComponent fileListLabel =
(JComponent)headerRenderer.getTableCellRendererComponent(null, filesLabelText,
false, false, 0, 0);
fileListLabel.setName("GTKFileChooser.fileListLabel");
rightPanel.add(fileListLabel, new GridBagConstraints(
0, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
rightPanel.add(createFilesList(), new GridBagConstraints(
0, 1, 1, 1, 1, 1, GridBagConstraints.EAST,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
splitPanel.add(leftPanel, leftToRight ? JSplitPane.LEFT : JSplitPane.RIGHT);
splitPanel.add(rightPanel, leftToRight ? JSplitPane.RIGHT : JSplitPane.LEFT);
centerPanel.add(splitPanel, BorderLayout.CENTER);
JComponent accessoryPanel = getAccessoryPanel();
JComponent accessory = fc.getAccessory();
if (accessoryPanel != null) {
if (accessory == null) {
accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
} else {
getAccessoryPanel().add(accessory, BorderLayout.CENTER);
accessoryPanel.setPreferredSize(accessory.getPreferredSize());
accessoryPanel.setMaximumSize(MAX_SIZE);
}
align(accessoryPanel);
centerPanel.add(accessoryPanel, BorderLayout.AFTER_LINE_ENDS);
}
interior.add(centerPanel);
interior.add(Box.createRigidArea(vstrut10));
JPanel pathFieldPanel = new JPanel(new FlowLayout(FlowLayout.LEADING,
0, 0));
pathFieldPanel.setBorder(new EmptyBorder(0, 0, 4, 0));
JLabel pathFieldLabel = new JLabel(pathLabelText);
pathFieldLabel.setName("GTKFileChooser.pathFieldLabel");
pathFieldLabel.setDisplayedMnemonic(pathLabelMnemonic);
align(pathFieldLabel);
pathFieldPanel.add(pathFieldLabel);
pathFieldPanel.add(Box.createRigidArea(hstrut3));
File currentDirectory = fc.getCurrentDirectory();
String curDirName = null;
if (currentDirectory != null) {
curDirName = currentDirectory.getPath();
}
pathField = new JLabel(curDirName) {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
pathField.setName("GTKFileChooser.pathField");
pathFieldLabel.setLabelFor(pathField);
align(pathField);
pathFieldPanel.add(pathField);
interior.add(pathFieldPanel);
// add the fileName field
fileNameTextField = new JTextField() {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
Set forwardTraversalKeys = fileNameTextField.getFocusTraversalKeys(
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
forwardTraversalKeys = new HashSet(forwardTraversalKeys);
forwardTraversalKeys.remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
fileNameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardTraversalKeys);
fileNameTextField.setName("GTKFileChooser.fileNameTextField");
fileNameTextField.getActionMap().put("fileNameCompletionAction", getFileNameCompletionAction());
fileNameTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "fileNameCompletionAction");
interior.add(fileNameTextField);
// Add the filter combo box
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
panel.setBorder(new EmptyBorder(0, 0, 4, 0));
JLabel filterLabel = new JLabel(filterLabelText);
filterLabel.setName("GTKFileChooser.filterLabel");
filterLabel.setDisplayedMnemonic(filterLabelMnemonic);
panel.add(filterLabel);
filterComboBoxModel = createFilterComboBoxModel();
fc.addPropertyChangeListener(filterComboBoxModel);
filterComboBox = new JComboBox(filterComboBoxModel);
filterComboBox.setRenderer(createFilterComboBoxRenderer());
filterLabel.setLabelFor(filterComboBox);
interior.add(Box.createRigidArea(vstrut10));
interior.add(panel);
interior.add(filterComboBox);
// Add buttons
bottomButtonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
bottomButtonPanel.setName("GTKFileChooser.bottomButtonPanel");
align(bottomButtonPanel);
JButton cancelButton = getCancelButton(fc);
align(cancelButton);
cancelButton.setMargin(buttonMargin);
bottomButtonPanel.add(cancelButton);
JButton approveButton = getApproveButton(fc);;
align(approveButton);
approveButton.setMargin(buttonMargin);
bottomButtonPanel.add(approveButton);
fc.add(bottomButtonPanel, BorderLayout.SOUTH);
|
protected void | installDefaults(javax.swing.JFileChooser fc)
super.installDefaults(fc);
readOnly = UIManager.getBoolean("FileChooser.readOnly");
showDirectoryIcons =
Boolean.TRUE.equals(fc.getClientProperty("GTKFileChooser.showDirectoryIcons"));
showFileIcons =
Boolean.TRUE.equals(fc.getClientProperty("GTKFileChooser.showFileIcons"));
|
protected void | installIcons(javax.swing.JFileChooser fc)
directoryIcon = UIManager.getIcon("FileView.directoryIcon");
fileIcon = UIManager.getIcon("FileView.fileIcon");
|
protected void | installListeners(javax.swing.JFileChooser fc)
super.installListeners(fc);
gtkFCPropertyChangeListener = new GTKFCPropertyChangeListener();
fc.addPropertyChangeListener(gtkFCPropertyChangeListener);
|
protected void | installStrings(javax.swing.JFileChooser fc)
super.installStrings(fc);
Locale l = fc.getLocale();
newFolderDialogText = UIManager.getString("FileChooser.newFolderDialogText", l);
newFolderErrorText = UIManager.getString("FileChooser.newFolderErrorText",l);
newFolderErrorSeparator = UIManager.getString("FileChooser.newFolderErrorSeparator",l);
newFolderButtonText = UIManager.getString("FileChooser.newFolderButtonText", l);
deleteFileButtonText = UIManager.getString("FileChooser.deleteFileButtonText", l);
renameFileButtonText = UIManager.getString("FileChooser.renameFileButtonText", l);
newFolderButtonMnemonic = UIManager.getInt("FileChooser.newFolderButtonMnemonic", l);
deleteFileButtonMnemonic = UIManager.getInt("FileChooser.deleteFileButtonMnemonic", l);
renameFileButtonMnemonic = UIManager.getInt("FileChooser.renameFileButtonMnemonic", l);
newFolderButtonToolTipText = UIManager.getString("FileChooser.newFolderButtonToolTipText", l);
deleteFileButtonToolTipText = UIManager.getString("FileChooser.deleteFileButtonToolTipText", l);
renameFileButtonToolTipText = UIManager.getString("FileChooser.renameFileButtonToolTipText", l);
renameFileDialogText = UIManager.getString("FileChooser.renameFileDialogText", l);
renameFileErrorTitle = UIManager.getString("FileChooser.renameFileErrorTitle", l);
renameFileErrorText = UIManager.getString("FileChooser.renameFileErrorText", l);
foldersLabelText = UIManager.getString("FileChooser.foldersLabelText",l);
filesLabelText = UIManager.getString("FileChooser.filesLabelText",l);
pathLabelText = UIManager.getString("FileChooser.pathLabelText",l);
pathLabelMnemonic = UIManager.getInt("FileChooser.pathLabelMnemonic");
filterLabelText = UIManager.getString("FileChooser.filterLabelText", l);
filterLabelMnemonic = UIManager.getInt("FileChooser.filterLabelMnemonic");
|
public void | installUI(javax.swing.JComponent c)
accessoryPanel = new JPanel(new BorderLayout(10, 10));
accessoryPanel.setName("GTKFileChooser.accessoryPanel");
super.installUI(c);
|
public void | rescanCurrentDirectory(javax.swing.JFileChooser fc)
getModel().validateFileCache();
|
public void | setDirectoryName(java.lang.String dirname)
pathField.setText(dirname);
|
public void | setFileName(java.lang.String fileName)
if (fileNameTextField != null) {
fileNameTextField.setText(fileName);
}
|
protected void | uninstallListeners(javax.swing.JFileChooser fc)
super.uninstallListeners(fc);
if (gtkFCPropertyChangeListener != null) {
fc.removePropertyChangeListener(gtkFCPropertyChangeListener);
}
|
protected void | uninstallStrings(javax.swing.JFileChooser fc)
super.uninstallStrings(fc);
newFolderButtonText = null;
deleteFileButtonText = null;
renameFileButtonText = null;
newFolderButtonToolTipText = null;
deleteFileButtonToolTipText = null;
renameFileButtonToolTipText = null;
renameFileDialogText = null;
renameFileErrorTitle = null;
renameFileErrorText = null;
foldersLabelText = null;
filesLabelText = null;
pathLabelText = null;
newFolderDialogText = null;
newFolderErrorText = null;
newFolderErrorSeparator = null;
|
public void | uninstallUI(javax.swing.JComponent c)
c.removePropertyChangeListener(filterComboBoxModel);
super.uninstallUI(c);
if (accessoryPanel != null) {
accessoryPanel.removeAll();
}
accessoryPanel = null;
getFileChooser().removeAll();
|
private void | updateDefaultButton()
JFileChooser filechooser = getFileChooser();
JRootPane root = SwingUtilities.getRootPane(filechooser);
if (root == null) {
return;
}
if (filechooser.getControlButtonsAreShown()) {
if (root.getDefaultButton() == null) {
root.setDefaultButton(getApproveButton(filechooser));
getCancelButton(filechooser).setDefaultCapable(false);
}
} else {
if (root.getDefaultButton() == getApproveButton(filechooser)) {
root.setDefaultButton(null);
}
}
|