def approveSelection(self): if self._validator is not None: chosenFile = self.selectedFile chosenPath = chosenFile.path validatedPath = self._validator(chosenPath) if validatedPath is None or validatedPath is False: return elif validatedPath is True: pass elif validatedPath != chosenPath: self.selectedFile = File(validatedPath) JFileChooser.approveSelection(self)
def approveSelection(self): filePath = self.getSelectedFile().getPath() fileName = String(self.getSelectedFile().getName()) if fileName.matches('[_a-zA-Z0-9()~#.]+'): if os.path.exists(filePath): message = 'File "' + str(fileName) + ' exists. Overwrite?' result = JOptionPane.showConfirmDialog(self, message, 'Confirm Overwrite', JOptionPane.YES_NO_OPTION) if result == JOptionPane.YES_OPTION: JFileChooser.approveSelection(self) else: JFileChooser.approveSelection(self) else: message = 'The file name contains illegal characters. Please rename.' JOptionPane.showMessageDialog(self, message, 'Error', JOptionPane.ERROR_MESSAGE)
def approveSelection(self): filePath = self.getSelectedFile().getPath() fileName = String(self.getSelectedFile().getName()) if fileName.matches('[_a-zA-Z0-9()~#.]+'): if os.path.exists(filePath): message = 'File "' + str(fileName) + ' exists. Overwrite?' result = JOptionPane.showConfirmDialog( self, message, 'Confirm Overwrite', JOptionPane.YES_NO_OPTION) if result == JOptionPane.YES_OPTION: JFileChooser.approveSelection(self) else: JFileChooser.approveSelection(self) else: message = 'The file name contains illegal characters. Please rename.' JOptionPane.showMessageDialog(self, message, 'Error', JOptionPane.ERROR_MESSAGE)