本文整理了Java中org.openide.filesystems.FileUtil.preventFileChooserSymlinkTraversal()
方法的一些代码示例,展示了FileUtil.preventFileChooserSymlinkTraversal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.preventFileChooserSymlinkTraversal()
方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:preventFileChooserSymlinkTraversal
[英]Make sure that a JFileChooser does not traverse symlinks on Unix.
[中]确保JFileChooser不会在Unix上遍历符号链接。
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
FileUtil.preventFileChooserSymlinkTraversal(chooser,
chooser.getCurrentDirectory());
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-grailsproject
private void browseLocationJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocationJButtonActionPerformed
JFileChooser chooser = new JFileChooser ();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle(NbBundle.getMessage(PanelProjectLocationVisual.class,"GetProjectLocationPanel.FileChooserTitle"));
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
String path = projectLocationTextField.getText().trim();
if (path.length() > 0) {
File f = new File (path);
if (f.exists ()) {
chooser.setSelectedFile(f);
}
}
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this))) { //NOI18N
File projectDir = chooser.getSelectedFile();
projectLocationTextField.setText( projectDir.getAbsolutePath() );
}
}//GEN-LAST:event_browseLocationJButtonActionPerformed
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-project-ant-ui
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser chooser = new JFileChooser();
chooser.setFileHidingEnabled(false);
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
chooser.setDialogTitle(NbBundle.getBundle(VariablePanel.class).getString("MSG_Choose_Folder"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
locationTextField.setText(file.getAbsolutePath());
}
}//GEN-LAST:event_browseButtonActionPerformed
代码示例来源:origin: dcaoyuan/nbscala
private void browseProjectLocation(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseProjectLocation
// TODO add your handling code here:
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle(NbBundle.getMessage(PanelSourceFolders.class,"LBL_NWP1_SelectProjectLocation"));
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
String path = this.projectLocation.getText();
if (path.length() > 0) {
File f = new File (path);
if (f.exists()) {
chooser.setSelectedFile (f);
}
}
if (chooser.showOpenDialog(this)== JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
if (file != null) {
this.projectLocation.setText (FileUtil.normalizeFile(file).getAbsolutePath());
}
}
}//GEN-LAST:event_browseProjectLocation
代码示例来源:origin: dcaoyuan/nbscala
private static JFileChooser createChooser() {
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
chooser.setAcceptAllFileFilterUsed( false );
chooser.setName( "Select Project Directory" ); // XXX // NOI18N
return chooser;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-railsprojects
private static JFileChooser createChooser() {
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
chooser.setAcceptAllFileFilterUsed( false );
chooser.setName( "Select Project Directory" ); // XXX // NOI18N
return chooser;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle(NbBundle.getMessage(ConfigureProjectVisualPanel.class,
"ConfigureProjectVisualPanel.locationChooserTitle")); // NOI18N
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
String path = projectLocationTextField.getText();
if (path.length() > 0) {
File f = new File (path);
if (f.exists()) {
chooser.setSelectedFile(f);
}
}
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File projectDir = chooser.getSelectedFile();
projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
}
wizardPanel.visualPanelChanged(false);
}//GEN-LAST:event_browseButtonActionPerformed
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-paintapp
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(PaintAppPanelVisual.class, "PaintAppPanelVisual.select_project_location"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
String path = this.projectLocationTextField.getText();
if (path.length() > 0) {
File f = new File(path);
if (f.exists()) {
chooser.setSelectedFile(f);
}
}
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File projectDir = chooser.getSelectedFile();
projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
}
panel.fireChangeEvent();
}//GEN-LAST:event_browseButtonActionPerformed
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject
private void jButtonConfigFilesLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfigFilesLocationActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (jTextFieldConfigFiles.getText().length() > 0 && getConfigFiles().exists()) {
chooser.setSelectedFile(getConfigFiles());
} else {
chooser.setCurrentDirectory((File) wizardDescriptor.getProperty(ProjectLocationWizardPanel.PROJECT_DIR));
}
if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File configFilesDir = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextFieldConfigFiles.setText(configFilesDir.getAbsolutePath());
}
}//GEN-LAST:event_jButtonConfigFilesLocationActionPerformed
代码示例来源:origin: dcaoyuan/nbscala
private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
String workDir = jTextWorkingDirectory.getText();
if (workDir.equals("")) {
workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
}
chooser.setSelectedFile(new File(workDir));
chooser.setDialogTitle(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse_Title"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextWorkingDirectory.setText(file.getAbsolutePath());
}
}//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
代码示例来源:origin: org.codehaus.mevenide/nb-project
private void btnLocalRepositoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLocalRepositoryActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle(NbBundle.getMessage(SettingsPanel.class, "TIT_Select"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileHidingEnabled(false);
String path = txtLocalRepository.getText();
if (path.trim().length() == 0) {
path = new File(System.getProperty("user.home"), ".m2").getAbsolutePath(); //NOI18N
}
if (path.length() > 0) {
File f = new File(path);
if (f.exists()) {
chooser.setSelectedFile(f);
}
}
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File projectDir = chooser.getSelectedFile();
txtLocalRepository.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
}
}//GEN-LAST:event_btnLocalRepositoryActionPerformed
代码示例来源:origin: dcaoyuan/nbscala
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES);
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(new SplashFileFilter());
if (lastImageFolder != null) {
chooser.setSelectedFile(lastImageFolder);
} else {
// ???
}
chooser.setDialogTitle(NbBundle.getMessage(CustomizerApplication.class, "LBL_Select_Splash_Image"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
splashTextField.setText(file.getAbsolutePath());
lastImageFolder = file.getParentFile();
}
}//GEN-LAST:event_browseButtonActionPerformed
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-project
private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
String workDir = jTextWorkingDirectory.getText();
if (workDir.equals("")) {
workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
}
chooser.setSelectedFile(new File(workDir));
chooser.setDialogTitle(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse_Title"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextWorkingDirectory.setText(file.getAbsolutePath());
}
}//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
代码示例来源:origin: org.codehaus.mevenide/nb-project
private void btnWorkDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkDirActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
String workDir = txtWorkDir.getText();
if (workDir.equals("")) { //NOI18N
workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
}
chooser.setSelectedFile(new File(workDir));
chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(RunJarPanel.class, "TIT_SelectWorkingDirectory"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
txtWorkDir.setText(file.getAbsolutePath());
}
}//GEN-LAST:event_btnWorkDirActionPerformed
代码示例来源:origin: nl.cloudfarming.client/field-project
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {
String command = evt.getActionCommand();
if ("BROWSE".equals(command)) {
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setDialogTitle("Select Project Location");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
String path = this.projectLocationTextField.getText();
if (path.length() > 0) {
File f = new File(path);
if (f.exists()) {
chooser.setSelectedFile(f);
}
}
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File projectDir = chooser.getSelectedFile();
projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
}
panel.fireChangeEvent();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-ejbjarproject
private void jButtonLibrariesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLibrariesActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
if (jTextFieldLibraries.getText().length() > 0 && getLibraries().exists()) {
chooser.setSelectedFile(getLibraries());
} else {
chooser.setCurrentDirectory((File) wizardDescriptor.getProperty(ProjectLocationWizardPanel.PROJECT_DIR));
}
if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File configFilesDir = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextFieldLibraries.setText(configFilesDir.getAbsolutePath());
}
}//GEN-LAST:event_jButtonLibrariesActionPerformed
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject
private void jButtonLibrariesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLibrariesActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (jTextFieldLibraries.getText().length() > 0 && getLibraries().exists()) {
chooser.setSelectedFile(getLibraries());
} else {
chooser.setCurrentDirectory((File) wizardDescriptor.getProperty(ProjectLocationWizardPanel.PROJECT_DIR));
}
if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File configFilesDir = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextFieldLibraries.setText(configFilesDir.getAbsolutePath());
}
}//GEN-LAST:event_jButtonLibrariesActionPerformed
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-ejbjarproject
private void jButtonConfigFilesLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfigFilesLocationActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
if (jTextFieldConfigFiles.getText().length() > 0 && getConfigFiles().exists()) {
chooser.setSelectedFile(getConfigFiles());
} else {
chooser.setCurrentDirectory((File) wizardDescriptor.getProperty(ProjectLocationWizardPanel.PROJECT_DIR));
}
if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File configFilesDir = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextFieldConfigFiles.setText(configFilesDir.getAbsolutePath());
}
}//GEN-LAST:event_jButtonConfigFilesLocationActionPerformed
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject
private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
JFileChooser chooser = new JFileChooser();
FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setMultiSelectionEnabled(false);
String workDir = jTextWorkingDirectory.getText();
if (workDir.equals("")) {
workDir = FileUtil.toFile(uiProperties.getProject().getProjectDirectory()).getAbsolutePath();
}
chooser.setSelectedFile(new File(workDir));
chooser.setDialogTitle(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse_Title"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
jTextWorkingDirectory.setText(file.getAbsolutePath());
}
}//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2me-cdc-project
/** Factory method for project chooser
*/
public static JFileChooser createProjectChooser() {
ProjectManager.getDefault().clearNonProjectCache(); // #41882
JFileChooser chooser = new ProjectFileChooser();
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
if ("GTK".equals(javax.swing.UIManager.getLookAndFeel().getID())) { // NOI18N
// see BugTraq #5027268
chooser.putClientProperty("GTKFileChooser.showDirectoryIcons", Boolean.TRUE); // NOI18N
//chooser.putClientProperty("GTKFileChooser.showFileIcons", Boolean.TRUE); // NOI18N
}
//#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
chooser.setAcceptAllFileFilterUsed( false );
chooser.setFileFilter( ProjectDirFilter.INSTANCE );
File currDir = ProjectChooser.getProjectsFolder();
FileUtil.preventFileChooserSymlinkTraversal(chooser, currDir);
chooser.setFileView( new ProjectFileView( chooser.getFileSystemView() ) );
return chooser;
}
内容来源于网络,如有侵权,请联系作者删除!