本文整理汇总了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());
}
示例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();
}
}
示例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;
}
}
示例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();
}
}
示例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());
}
}
示例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();
}
}
示例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();
}
}
示例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());
}
}
示例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();
}
}
示例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]);
}
}
示例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]);
}
}
示例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);
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
}