private void updateFolder(JTextField textField) { JFileChooser chooser = new JFileChooser(); FileUtil.preventFileChooserSymlinkTraversal(chooser, null); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); File fileName = new File(textField.getText()); File folder = fileName.isAbsolute() ? fileName : new File(projectFld, fileName.getPath()); if (folder.exists()) { chooser.setSelectedFile(folder); } else { chooser.setSelectedFile(projectFld); } if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { File selected = FileUtil.normalizeFile(chooser.getSelectedFile()); String newFolder; if (CollocationQuery.areCollocated(projectFld, selected)) { newFolder = PropertyUtils.relativizeFile(projectFld, selected); } else { newFolder = selected.getPath(); } textField.setText(newFolder); } }
private void jButtonBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBrowseActionPerformed JFileChooser chooser = new JFileChooser(); FileUtil.preventFileChooserSymlinkTraversal(chooser, null); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); File fileName = new File(jTextFieldConfigFilesFolder.getText()); File configFiles = fileName.isAbsolute() ? fileName : new File(projectFld, fileName.getPath()); if (configFiles.isAbsolute()) { chooser.setSelectedFile(configFiles); } else { chooser.setSelectedFile(projectFld); } if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { File selected = FileUtil.normalizeFile(chooser.getSelectedFile()); String newConfigFiles; if (CollocationQuery.areCollocated(projectFld, selected)) { newConfigFiles = PropertyUtils.relativizeFile(projectFld, selected); } else { newConfigFiles = selected.getPath(); } jTextFieldConfigFilesFolder.setText(newConfigFiles); } }//GEN-LAST:event_jButtonBrowseActionPerformed
private boolean areCollocated(File base, Collection<File> files){ for(File file: files){ if (!CollocationQuery.areCollocated(Utilities.toURI(base), Utilities.toURI(file))) { return false; } } return true; }
private void configFilesFolderBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configFilesFolderBrowseActionPerformed JFileChooser chooser = new JFileChooser(); FileUtil.preventFileChooserSymlinkTraversal(chooser, null); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); File fileName = new File(jTextFieldConfigFilesFolder.getText()); File configFiles = fileName.isAbsolute() ? fileName : new File(projectFld, fileName.getPath()); if (configFiles.isAbsolute()) { chooser.setSelectedFile(configFiles); } else { chooser.setSelectedFile(projectFld); } if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { File selected = FileUtil.normalizeFile(chooser.getSelectedFile()); String newConfigFiles; if (CollocationQuery.areCollocated(projectFld, selected)) { newConfigFiles = PropertyUtils.relativizeFile(projectFld, selected); } else { newConfigFiles = selected.getPath(); } jTextFieldConfigFilesFolder.setText(newConfigFiles); } }//GEN-LAST:event_configFilesFolderBrowseActionPerformed
File projectLoc = FileUtil.normalizeFile(new File(projectLocation)); File libLoc = PropertyUtils.resolveFile(projectLoc, location); if (!CollocationQuery.areCollocated(projectLoc, libLoc)) { settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(PanelOptionsVisual.class, "WARN_PanelOptionsVisual.relativePath"));
File projectLoc = FileUtil.normalizeFile(new File(createdFolderTextField.getText())); File libLoc = PropertyUtils.resolveFile(projectLoc, location); if (!CollocationQuery.areCollocated(projectLoc, libLoc)) { wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, decorateMessage( NbBundle.getMessage(ProjectLocationPanel.class, "PanelSharability.relativePathWarning.text")));
if (!CollocationQuery.areCollocated(projectLocation, libLoc)) { wizardDescriptor.putProperty(ProjectLocationPanel.PROP_ERROR_MESSAGE, ProjectLocationPanel.decorateMessage( NbBundle.getMessage(ProjectImportLocationPanel.class, "PanelSharability.relativePathWarning.text")));
File jarFile = helper.resolveFile(value); String action = ACTION_COPY; if (CollocationQuery.areCollocated(prjDir, jarFile)) { } else if (absoluteLibrary && CollocationQuery.areCollocated(libraryFile.getParentFile(), jarFile)) { } else if (CollocationQuery.areCollocated(libraryFile.getParentFile(), jarFile)) { action = ACTION_RELATIVE;
File projectLoc = FileUtil.normalizeFile(visualPanel.getProjectDirectory()); File libLoc = PropertyUtils.resolveFile(projectLoc, location); if (!CollocationQuery.areCollocated(projectLoc, libLoc)) { wizard.putProperty( "WizardPanel_errorMessage", // NOI18N NbBundle.getMessage(ConfigureProjectPanel.class,
File projectLoc = FileUtil.normalizeFile(new File(projectLocation)); File libLoc = PropertyUtils.resolveFile(projectLoc, location); if (!CollocationQuery.areCollocated(projectLoc.toURI(), libLoc.toURI())) { settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(PanelOptionsVisual.class, "WARN_PanelOptionsVisual.relativePath")); // NOI18N
@Messages({ "WARN_MakeSharable.absolutePath=<html>Please make sure that the absolute path in the Libraries Folder field is valid for all users.<html>", "WARN_makeSharable.relativePath=<html>Please make sure that the relative path in the Libraries Folder field is valid for all users.<html>" }) boolean isValidPanel() { String location = getLibraryLocation(); boolean wrong = false; if (new File(location).isAbsolute()) { settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, WARN_MakeSharable_absolutePath()); wrong = true; } else { File projectLoc = FileUtil.toFile(helper.getProjectDirectory()); File libLoc = PropertyUtils.resolveFile(projectLoc, location); if (!CollocationQuery.areCollocated(projectLoc, libLoc)) { settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, WARN_makeSharable_relativePath()); wrong = true; } } if (!wrong) { settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null); } return true; }
}; else if (CollocationQuery.areCollocated(base, path)) {