Methods Summary |
---|
protected void | align(javax.swing.JComponent c)
c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
c.setAlignmentY(JComponent.TOP_ALIGNMENT);
|
protected javax.swing.JScrollPane | createDirectoryList()
directoryList = new JList();
align(directoryList);
directoryList.setCellRenderer(new DirectoryCellRenderer());
directoryList.setModel(new MotifDirectoryListModel());
directoryList.getSelectionModel().removeSelectionInterval(0, 0);
directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList));
directoryList.addListSelectionListener(createListSelectionListener(getFileChooser()));
JScrollPane scrollpane = new JScrollPane(directoryList);
scrollpane.setMaximumSize(MAX_SIZE);
scrollpane.setPreferredSize(prefListSize);
align(scrollpane);
return scrollpane;
|
protected javax.swing.JScrollPane | createFilesList()
fileList = new JList();
if(getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
fileList.setModel(new MotifFileListModel());
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.setPreferredSize(prefListSize);
scrollpane.setMaximumSize(MAX_SIZE);
align(scrollpane);
return scrollpane;
|
protected com.sun.java.swing.plaf.motif.MotifFileChooserUI$FilterComboBoxModel | createFilterComboBoxModel()
return new FilterComboBoxModel();
|
protected com.sun.java.swing.plaf.motif.MotifFileChooserUI$FilterComboBoxRenderer | createFilterComboBoxRenderer()
return new FilterComboBoxRenderer();
|
public java.beans.PropertyChangeListener | createPropertyChangeListener(javax.swing.JFileChooser fc)
return new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if(prop.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
File f = (File) e.getNewValue();
if(f != null) {
setFileName(getFileChooser().getName(f));
}
}
else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
File[] files = (File[]) e.getNewValue();
JFileChooser fc = getFileChooser();
if (files != null && files.length > 0 && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
setFileName(fileNameString(files));
}
} else if(prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
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());
}
}
} else if(prop.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
directoryList.clearSelection();
} else if(prop == JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY) {
if(getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fileList.clearSelection();
getFileChooser().setSelectedFiles(null);
}
} else if(prop == JFileChooser.ACCESSORY_CHANGED_PROPERTY) {
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(PREF_ACC_SIZE);
getAccessoryPanel().setMaximumSize(MAX_SIZE);
} else {
getAccessoryPanel().setPreferredSize(ZERO_ACC_SIZE);
getAccessoryPanel().setMaximumSize(ZERO_ACC_SIZE);
}
}
} else if (prop == JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY ||
prop == JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY ||
prop == JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY) {
approveButton.setText(getApproveButtonText(getFileChooser()));
approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser()));
} else if (prop.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
doControlButtonsChanged(e);
} else if (prop.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JFileChooser cc = (JFileChooser)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) {
cc.applyComponentOrientation(o);
}
}
}
};
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)
return new MotifFileChooserUI((JFileChooser)c);
|
private void | doControlButtonsChanged(java.beans.PropertyChangeEvent e)
if (getFileChooser().getControlButtonsAreShown()) {
getFileChooser().add(bottomPanel,BorderLayout.SOUTH);
} else {
getFileChooser().remove(getBottomPanel());
}
|
public void | ensureFileIsVisible(javax.swing.JFileChooser fc, java.io.File f)
// PENDING(jeff)
|
private java.lang.String | fileNameString(java.io.File file)
if (file == null) {
return null;
} else {
JFileChooser fc = getFileChooser();
if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
return file.getPath();
} else {
return file.getName();
}
}
|
private java.lang.String | fileNameString(java.io.File[] files)
StringBuffer buf = new StringBuffer();
for (int i = 0; files != null && i < files.length; i++) {
if (i > 0) {
buf.append(" ");
}
if (files.length > 1) {
buf.append("\"");
}
buf.append(fileNameString(files[i]));
if (files.length > 1) {
buf.append("\"");
}
}
return buf.toString();
|
protected javax.swing.JButton | getApproveButton(javax.swing.JFileChooser fc)
return approveButton;
|
protected javax.swing.JPanel | getBottomPanel()
if (bottomPanel == null) {
bottomPanel = new JPanel(new BorderLayout(0, 4));
}
return bottomPanel;
|
public java.lang.String | getDirectoryName()
return pathField.getText();
|
public java.lang.String | getFileName()
if(filenameTextField != null) {
return filenameTextField.getText();
} else {
return null;
}
|
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 MIN_SIZE;
|
public java.awt.Dimension | getPreferredSize(javax.swing.JComponent c)
Dimension prefSize =
(getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE;
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)
fc.setLayout(new BorderLayout(10, 10));
fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);
JPanel interior = new JPanel() {
public Insets getInsets() {
return insets;
}
};
align(interior);
interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));
fc.add(interior, BorderLayout.CENTER);
// PENDING(jeff) - I18N
JLabel l = new JLabel(pathLabelText);
l.setDisplayedMnemonic(pathLabelMnemonic);
align(l);
interior.add(l);
File currentDirectory = fc.getCurrentDirectory();
String curDirName = null;
if(currentDirectory != null) {
curDirName = currentDirectory.getPath();
}
pathField = new JTextField(curDirName) {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
l.setLabelFor(pathField);
align(pathField);
// Change to folder on return
pathField.addActionListener(getUpdateAction());
interior.add(pathField);
interior.add(Box.createRigidArea(vstrut10));
// CENTER: left, right accessory
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
align(centerPanel);
// left panel - Filter & folderList
JPanel leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
align(leftPanel);
// add the filter PENDING(jeff) - I18N
l = new JLabel(filterLabelText);
l.setDisplayedMnemonic(filterLabelMnemonic);
align(l);
leftPanel.add(l);
filterComboBox = new JComboBox() {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
l.setLabelFor(filterComboBox);
filterComboBoxModel = createFilterComboBoxModel();
filterComboBox.setModel(filterComboBoxModel);
filterComboBox.setRenderer(createFilterComboBoxRenderer());
fc.addPropertyChangeListener(filterComboBoxModel);
align(filterComboBox);
leftPanel.add(filterComboBox);
// leftPanel.add(Box.createRigidArea(vstrut10));
// Add the Folder List PENDING(jeff) - I18N
l = new JLabel(foldersLabelText);
l.setDisplayedMnemonic(foldersLabelMnemonic);
align(l);
leftPanel.add(l);
JScrollPane sp = createDirectoryList();
sp.getVerticalScrollBar().setFocusable(false);
sp.getHorizontalScrollBar().setFocusable(false);
l.setLabelFor(sp.getViewport().getView());
leftPanel.add(sp);
// create files list
JPanel rightPanel = new JPanel();
align(rightPanel);
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));
l = new JLabel(filesLabelText);
l.setDisplayedMnemonic(filesLabelMnemonic);
align(l);
rightPanel.add(l);
sp = createFilesList();
l.setLabelFor(sp);
rightPanel.add(sp);
centerPanel.add(leftPanel);
centerPanel.add(Box.createRigidArea(hstrut10));
centerPanel.add(rightPanel);
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(PREF_ACC_SIZE);
accessoryPanel.setMaximumSize(MAX_SIZE);
}
align(accessoryPanel);
centerPanel.add(accessoryPanel);
}
interior.add(centerPanel);
interior.add(Box.createRigidArea(vstrut10));
// add the filename field PENDING(jeff) - I18N
l = new JLabel(enterFileNameLabelText);
l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
align(l);
interior.add(l);
filenameTextField = new JTextField() {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
l.setLabelFor(filenameTextField);
filenameTextField.addActionListener(getApproveSelectionAction());
align(filenameTextField);
filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
interior.add(filenameTextField);
bottomPanel = getBottomPanel();
bottomPanel.add(new JSeparator(), BorderLayout.NORTH);
// Add buttons
JPanel buttonPanel = new JPanel();
align(buttonPanel);
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
buttonPanel.add(Box.createGlue());
approveButton = new JButton(getApproveButtonText(fc)) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
approveButton.setMnemonic(getApproveButtonMnemonic(fc));
approveButton.setToolTipText(getApproveButtonToolTipText(fc));
align(approveButton);
approveButton.setMargin(buttonMargin);
approveButton.addActionListener(getApproveSelectionAction());
buttonPanel.add(approveButton);
buttonPanel.add(Box.createGlue());
JButton updateButton = new JButton(updateButtonText) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
updateButton.setMnemonic(updateButtonMnemonic);
updateButton.setToolTipText(updateButtonToolTipText);
align(updateButton);
updateButton.setMargin(buttonMargin);
updateButton.addActionListener(getUpdateAction());
buttonPanel.add(updateButton);
buttonPanel.add(Box.createGlue());
JButton cancelButton = new JButton(cancelButtonText) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
cancelButton.setMnemonic(cancelButtonMnemonic);
cancelButton.setToolTipText(cancelButtonToolTipText);
align(cancelButton);
cancelButton.setMargin(buttonMargin);
cancelButton.addActionListener(getCancelSelectionAction());
buttonPanel.add(cancelButton);
buttonPanel.add(Box.createGlue());
JButton helpButton = new JButton(helpButtonText) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
helpButton.setMnemonic(helpButtonMnemonic);
helpButton.setToolTipText(helpButtonToolTipText);
align(helpButton);
helpButton.setMargin(buttonMargin);
helpButton.setEnabled(false);
buttonPanel.add(helpButton);
buttonPanel.add(Box.createGlue());
bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
if (fc.getControlButtonsAreShown()) {
fc.add(bottomPanel, BorderLayout.SOUTH);
}
|
protected void | installIcons(javax.swing.JFileChooser fc)
// Since motif doesn't have button icons, leave this empty
// which overrides the supertype icon loading
|
protected void | installStrings(javax.swing.JFileChooser fc)
super.installStrings(fc);
Locale l = fc.getLocale();
enterFileNameLabelText = UIManager.getString("FileChooser.enterFileNameLabelText",l);
enterFileNameLabelMnemonic = UIManager.getInt("FileChooser.enterFileNameLabelMnemonic");
filesLabelText = UIManager.getString("FileChooser.filesLabelText",l);
filesLabelMnemonic = UIManager.getInt("FileChooser.filesLabelMnemonic");
foldersLabelText = UIManager.getString("FileChooser.foldersLabelText",l);
foldersLabelMnemonic = UIManager.getInt("FileChooser.foldersLabelMnemonic");
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)
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);
}
|
public void | uninstallComponents(javax.swing.JFileChooser fc)
fc.removeAll();
|
protected void | uninstallIcons(javax.swing.JFileChooser fc)
// Since motif doesn't have button icons, leave this empty
// which overrides the supertype icon loading
|
public void | uninstallUI(javax.swing.JComponent c)
getFileChooser().removeAll();
super.uninstallUI(c);
|