當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.preventFileChooserSymlinkTraversal方法代碼示例

本文整理匯總了Java中org.openide.filesystems.FileUtil.preventFileChooserSymlinkTraversal方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.preventFileChooserSymlinkTraversal方法的具體用法?Java FileUtil.preventFileChooserSymlinkTraversal怎麽用?Java FileUtil.preventFileChooserSymlinkTraversal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.filesystems.FileUtil的用法示例。


在下文中一共展示了FileUtil.preventFileChooserSymlinkTraversal方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: browseButtonActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    JFileChooser jfc = new JFileChooser() {
        // Trick stolen from ProjectChooserAccessory.ProjectFileChooser:
        public void approveSelection() {
            File dir = FileUtil.normalizeFile(getSelectedFile());
            if (NbPlatform.isHarness(dir)) {
                super.approveSelection();
            } else {
                setCurrentDirectory(dir);
            }
        }
    };
    FileUtil.preventFileChooserSymlinkTraversal(jfc, null);
    jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    jfc.setSelectedFile(plaf.getHarnessLocation());
    if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
            plaf.setHarnessLocation(FileUtil.normalizeFile(jfc.getSelectedFile()));
        } catch (IOException e) {
            Exceptions.printStackTrace(e);
        }
    }
    update();
    ApisupportAntUIUtils.setText(otherText, plaf.getHarnessLocation().getAbsolutePath());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:NbPlatformCustomizerHarness.java

示例2: browseButtonActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    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();
    }
    
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:23,代碼來源:TemplateBotProjectPanelVisual.java

示例3: javadocBrowseActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void javadocBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javadocBrowseActionPerformed
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setMultiSelectionEnabled(false);
    if (lastChosenFile != null) {
        chooser.setSelectedFile(lastChosenFile);
    } else if (javadoc.getText().length() > 0) {
        chooser.setSelectedFile(new File(javadoc.getText()));
    } else {
        File files[] = model.getBaseFolder().listFiles();
        if (files != null && files.length > 0) {
            chooser.setSelectedFile(files[0]);
        } else {
            chooser.setSelectedFile(model.getBaseFolder());
        }
    }
    chooser.setDialogTitle(NbBundle.getMessage(OutputPanel.class, "LBL_Browse_Javadoc")); // NOI18N
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File file = chooser.getSelectedFile();
        file = FileUtil.normalizeFile(file);
        javadoc.setText(file.getAbsolutePath());
        lastChosenFile = file;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:OutputPanel.java

示例4: addOutputActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void addOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addOutputActionPerformed
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setMultiSelectionEnabled(true);
    if (lastChosenFile != null) {
        chooser.setSelectedFile(lastChosenFile);
    } else {
        File files[] = model.getBaseFolder().listFiles();
        if (files != null && files.length > 0) {
            chooser.setSelectedFile(files[0]);
        } else {
            chooser.setSelectedFile(model.getBaseFolder());
        }
    }
    chooser.setDialogTitle(NbBundle.getMessage(OutputPanel.class, "LBL_Browse_Output")); // NOI18N
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        for (File file : chooser.getSelectedFiles()) {
            file = FileUtil.normalizeFile(file);
            listModel.addElement(file.getAbsolutePath());
            lastChosenFile = file;
        }
        applyChanges();
        updateButtons();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:OutputPanel.java

示例5: jButtonWorkingDirectoryBrowseActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
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")); // NOI18N
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        jTextWorkingDirectory.setText(file.getAbsolutePath());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CustomizerRun.java

示例6: browseButtonActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setFileFilter(new IconFileFilter());
    if (lastImageFolder != null) {
        chooser.setSelectedFile(lastImageFolder);
    } else { // ???
        // workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
        // chooser.setSelectedFile(new File(workDir));
    }
    chooser.setDialogTitle(NbBundle.getMessage(JWSCustomizerPanel.class, "LBL_Select_Icon_Image")); //NOI18N
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        iconTextField.setText(file.getAbsolutePath());
        lastImageFolder = file.getParentFile();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:JWSCustomizerPanel.java

示例7: browseLocationAction

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseLocationAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocationAction
    String command = evt.getActionCommand();        
    if ( "BROWSE".equals( command ) ) { // NOI18N                
        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.projectLocationTextField.getText();
        if (path.length() > 0) {
            File f = new File (path);
            if (f.exists ()) {
                chooser.setSelectedFile(f);
            }
        }
        if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
            File projectDir = chooser.getSelectedFile();
            projectLocationTextField.setText( FileUtil.normalizeFile(projectDir).getAbsolutePath() );
        }            
        panel.fireChangeEvent();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:PanelProjectLocationVisual.java

示例8: browseProjectFolderActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseProjectFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseProjectFolderActionPerformed
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
    if (projectFolder.getText().length() > 0 && getProjectFolder().exists()) {
        chooser.setSelectedFile(getProjectFolder());
    } else if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) {
        chooser.setSelectedFile(getProjectLocation());
    } else {
        chooser.setSelectedFile(ProjectChooser.getProjectsFolder());
    }
    chooser.setDialogTitle(NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_Browse_Project_Folder"));  //NOI18N
    if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File projectDir = FileUtil.normalizeFile(chooser.getSelectedFile());
        projectFolder.setText(projectDir.getAbsolutePath());
    }                    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:BasicProjectInfoPanel.java

示例9: browseButtonActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    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();
    }

}
 
開發者ID:onekosha,項目名稱:nb-clojure,代碼行數:23,代碼來源:ClojureTemplatePanelVisual.java

示例10: btnJavadocActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Messages("LBL_Edit_Jar_Panel_browse=Select JAR/folder")
private void btnJavadocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnJavadocActionPerformed
    // Let user search for the Jar file
    FileChooser chooser;
    if (helper.isSharableProject()) {
        chooser = new FileChooser(helper, true);
    } else {
        chooser = new FileChooser(FileUtil.toFile(helper.getProjectDirectory()), null);
    }
    chooser.enableVariableBasedSelection(true);
    chooser.setFileHidingEnabled(false);
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setMultiSelectionEnabled(false);
    chooser.setDialogTitle(LBL_Edit_Jar_Panel_browse());
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileFilter(new SimpleFileFilter(
            "Javadoc Entry (folder, ZIP or JAR file)", 
            new String[]{"ZIP", "JAR"}));   // NOI18N 
    File curDir = helper.resolveFile(helper.getStandardPropertyEvaluator().evaluate(item.getJarFile()));
    chooser.setCurrentDirectory(curDir);
    int option = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)); // Sow the chooser

    if (option == JFileChooser.APPROVE_OPTION) {
        String files[];
        try {
            files = chooser.getSelectedPaths();
        } catch (IOException ex) {
            // TODO: add localized message
            Exceptions.printStackTrace(ex);
            return;
        }
        txtJavadoc.setText(chooser.getSelectedPathVariables() != null ? stripOffVariableMarkup(chooser.getSelectedPathVariables()[0]) : files[0]);
    }
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:EditJarPanel.java

示例11: btnSourceActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void btnSourceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSourceActionPerformed
    FileChooser chooser;
    if (helper.isSharableProject()) {
        chooser = new FileChooser(helper, true);
    } else {
        chooser = new FileChooser(FileUtil.toFile(helper.getProjectDirectory()), null);
    }
    chooser.enableVariableBasedSelection(true);
    chooser.setFileHidingEnabled(false);
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setMultiSelectionEnabled(false);
    chooser.setDialogTitle(LBL_Edit_Jar_Panel_browse());
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileFilter(new SimpleFileFilter(
            "Source Entry (folder, ZIP or JAR file)", 
            new String[]{"ZIP", "JAR"}));   // NOI18N 
    File curDir = helper.resolveFile(helper.getStandardPropertyEvaluator().evaluate(item.getJarFile()));
    chooser.setCurrentDirectory(curDir);
    int option = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)); // Sow the chooser

    if (option == JFileChooser.APPROVE_OPTION) {
        String files[];
        try {
            files = chooser.getSelectedPaths();
        } catch (IOException ex) {
            // TODO: add localized message
            Exceptions.printStackTrace(ex);
            return;
        }
        txtSource.setText(chooser.getSelectedPathVariables() != null ? stripOffVariableMarkup(chooser.getSelectedPathVariables()[0]) : files[0]);
    }

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:EditJarPanel.java

示例12: actionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    org.netbeans.api.project.ant.FileChooser chooser;
    if (helper.isSharableProject()) {
        chooser = new org.netbeans.api.project.ant.FileChooser(helper, true);
    } else {
        chooser = new org.netbeans.api.project.ant.FileChooser(FileUtil.toFile(helper.getProjectDirectory()), null);
    }
    chooser.enableVariableBasedSelection(true);
    chooser.setFileHidingEnabled(false);
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES );
    chooser.setMultiSelectionEnabled( true );
    chooser.setDialogTitle( NbBundle.getMessage( LibrariesNode.class, "LBL_AddJar_DialogTitle" ) ); // NOI18N
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed( false );
    FileFilter fileFilter = new SimpleFileFilter (
            NbBundle.getMessage( LibrariesNode.class, "LBL_ZipJarFolderFilter" )); // NOI18N
    chooser.setFileFilter(fileFilter);
    File curDir = EditMediator.getLastUsedClassPathFolder();
    chooser.setCurrentDirectory (curDir);
    int option = chooser.showOpenDialog( WindowManager.getDefault().getMainWindow() );
    if ( option == JFileChooser.APPROVE_OPTION ) {
        String filePaths[];
        try {
            filePaths = chooser.getSelectedPaths();
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
            return;
        }
        addJarOrFolder ( filePaths, chooser.getSelectedPathVariables(), fileFilter, FileUtil.toFile(helper.getProjectDirectory()));
        curDir = FileUtil.normalizeFile(chooser.getCurrentDirectory());
        EditMediator.setLastUsedClassPathFolder(curDir);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:LibrariesNode.java

示例13: browseProjectButtonActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void browseProjectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseProjectButtonActionPerformed
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(UpdateEclipseReferencePanel.class, "TITLE_Select_Eclipse_Project"));
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        eclipseProjectTextField.setText(file.getAbsolutePath());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:UpdateEclipseReferencePanel.java

示例14: browseButtonActionPerformed

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:VariablePanel.java

示例15: browseProjectLocation

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
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);
        File owner = f.getParentFile();
        if (owner == null) {
            if (f.isDirectory()) {
                chooser.setCurrentDirectory(f);
            }
        } else if (owner.exists()) {
            chooser.setCurrentDirectory(owner);
        }
        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());
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:PanelProjectLocationExtSrc.java


注:本文中的org.openide.filesystems.FileUtil.preventFileChooserSymlinkTraversal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。