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

The following examples show how to use javax.swing.JFileChooser#isDirectorySelectionEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileChooserUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
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 2
Source File: FileChooserUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
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 3
Source File: FileChooserUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
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 4
Source File: FileChooserUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
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()) {
			if (fc.isFileSelectionEnabled()) {
				setFileName(null);
			} else {
				if (fsv.isFileSystem(currentDirectory)) {
					setFileName(currentDirectory.getPath());
				} else {
					setFileName(null);
				}
			}
			setFileSelected();
		}
	}
}
 
Example 5
Source File: FileChooserUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
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();
}