Java Code Examples for javax.swing.JFileChooser.isDirectorySelectionEnabled()

The following are Jave code examples for showing how to use isDirectorySelectionEnabled() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: rapidminer   File: FileChooserUI.java   View Source Code Vote up 6 votes
private void doDirectoryChanged(PropertyChangeEvent e) {
	JFileChooser fc = getFileChooser();
	FileSystemView fsv = fc.getFileSystemView();

	clearIconCache();

	File currentDirectory = fc.getCurrentDirectory();
	this.fileList.updatePath(currentDirectory);

	if (currentDirectory != null) {
		this.directoryComboBoxModel.addItem(currentDirectory);
		getNewFolderAction().setEnabled(currentDirectory.canWrite());
		getChangeToParentDirectoryAction().setEnabled(!fsv.isRoot(currentDirectory));
		getChangeToParentDirectoryAction().setEnabled(!fsv.isRoot(currentDirectory));
		getGoHomeAction().setEnabled(!userHomeDirectory.equals(currentDirectory));

		if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
			if (fsv.isFileSystem(currentDirectory)) {
				setFileName(currentDirectory.getPath());
			} else {
				setFileName(null);
			}
			setFileSelected();
		}
	}
}
 
Example 2
Project: rapidminer   File: FileChooserUI.java   View Source Code Vote up 5 votes
private String fileNameString(File file) {
	if (file == null) {
		return null;
	} else {
		JFileChooser fc = getFileChooser();
		if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
			return file.getPath();
		} else {
			return file.getName();
		}
	}
}
 
Example 3
Project: rapidminer   File: FileChooserUI.java   View Source Code Vote up 5 votes
private void doSelectedFileChanged(PropertyChangeEvent e) {
	File f = (File) e.getNewValue();
	JFileChooser fc = getFileChooser();
	if (f != null && (fc.isFileSelectionEnabled() && !f.isDirectory()
			|| f.isDirectory() && fc.isDirectorySelectionEnabled())) {
		setFileName(fileNameString(f));
		setFileSelected();
	}
}
 
Example 4
Project: rapidminer   File: FileChooserUI.java   View Source Code Vote up 5 votes
private void doSelectedFilesChanged(PropertyChangeEvent e) {
	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 {
		setFileName("");
	}
	setFileSelected();
}
 
Example 5
Project: rapidminer   File: FileChooserUI.java   View Source Code Vote up 5 votes
private void doFileSelectionModeChanged(PropertyChangeEvent e) {
	doFilterChanged(e);

	JFileChooser fc = getFileChooser();
	File currentDirectory = fc.getCurrentDirectory();
	if (currentDirectory != null && fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()
			&& fc.getFileSystemView().isFileSystem(currentDirectory)) {
		setFileName(currentDirectory.getPath());
	} else {
		setFileName(null);
	}
	setFileSelected();
}