def actionPerformed(self, event): option = event.getActionCommand() if option == 'Close': self.dispose() elif option == 'SCI': chooser = JFileChooser() returnVal = chooser.showSaveDialog(self) if returnVal == JFileChooser.APPROVE_OPTION: fileName = chooser.getSelectedFile().getPath() f = open(fileName, 'w') f.write("\t".join([ "Het", "Fst", "0.5(1-pval)quantile", "median", "0.5(1+pval)quantile" ]) + "\n") for line in self.confLines: f.write('\t'.join(map(lambda x: str(x), line)) + "\n") f.close() elif option == 'SLL': chooser = JFileChooser() returnVal = chooser.showSaveDialog(self) if returnVal == JFileChooser.APPROVE_OPTION: fileName = chooser.getSelectedFile().getPath() f = open(fileName, 'w') f.write("\t".join( ["Locus", "Het", "Fst", "P(Simul Fst<sample Fst)"]) + "\n") for i in range(self.data.size()): line = self.data.elementAt(i) lineList = [str(line.elementAt(0))] lineList.append(str(line.elementAt(1))) lineList.append(str(line.elementAt(2))) lineList.append(str(line.elementAt(3))) f.write("\t".join(lineList) + "\n") f.close()
def chooseFile(): global frame, dataPath global systemPanel, chartPanel global isTemporal fc = JFileChooser(dataPath) retVal = fc.showOpenDialog(frame) if retVal != JFileChooser.APPROVE_OPTION: return fname = fc.getSelectedFile().getAbsolutePath() dataPath = os.sep.join(fname.split(os.sep)[:-1]) if isTemporal: info(frame, "We need a file with information about the temporal point of each sample") tfc = JFileChooser(dataPath) tRetVal = tfc.showOpenDialog(frame) if retVal != JFileChooser.APPROVE_OPTION: return tname = tfc.getSelectedFile().getAbsolutePath() systemPanel.enableChartFun = False chartPanel.resetData() loadGenePop(fname) if isTemporal: if not loadTemporal(tname): return updateAll() enablePanel(empiricalPanel)
def _buildProjectJar(element, document): component = element.getRootElement().getComponent() larchJarURL = app_in_jar.getLarchJarURL() chosenJarURL = None if larchJarURL is None: openDialog = JFileChooser() openDialog.setFileFilter( FileNameExtensionFilter('Larch executable JAR (*.jar)', ['jar'])) response = openDialog.showDialog(component, 'Choose Larch JAR') if response == JFileChooser.APPROVE_OPTION: sf = openDialog.getSelectedFile() if sf is not None: chosenJarURL = sf.toURI().toURL() else: return jarFile = None bFinished = False while not bFinished: saveDialog = JFileChooser() saveDialog.setFileFilter( FileNameExtensionFilter('JAR file (*.jar)', ['jar'])) response = saveDialog.showSaveDialog(component) if response == JFileChooser.APPROVE_OPTION: sf = saveDialog.getSelectedFile() if sf is not None: if sf.exists(): response = JOptionPane.showOptionDialog( component, 'File already exists. Overwrite?', 'File already exists', JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, None, ['Overwrite', 'Cancel'], 'Cancel') if response == JFileChooser.APPROVE_OPTION: jarFile = sf bFinished = True else: bFinished = False else: jarFile = sf bFinished = True else: bFinished = True else: bFinished = True if jarFile is not None: outStream = FileOutputStream(jarFile) documentBytes = document.writeAsBytes() nameBytesPairs = [('app.larch', documentBytes)] app_in_jar.buildLarchJar(outStream, nameBytesPairs, larchJarURL=chosenJarURL) outStream.close()
def set_plugin_loc(self, event): """Attempts to load plugins from a specified location""" if self.config['Plugin Folder'] is not None: choose_plugin_location = JFileChooser(self.config['Plugin Folder']) else: choose_plugin_location = JFileChooser() choose_plugin_location.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY) choose_plugin_location.showDialog(self.tab, "Choose Folder") chosen_folder = choose_plugin_location.getSelectedFile() self.config['Plugin Folder'] = chosen_folder.getAbsolutePath() self._load_plugins(self.config['Plugin Folder'])
def add_file(self, evt): fc = JFileChooser() ret = fc.showOpenDialog(self.tab) if ret == JFileChooser.APPROVE_OPTION: with open(fc.getSelectedFile().getCanonicalPath()) as fd: for line in fd: self.listModel.addElement(line)
def _onExport(control, event): component = control.getElement().getRootElement().getComponent() openDialog = JFileChooser() openDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) response = openDialog.showDialog(component, 'Export') if response == JFileChooser.APPROVE_OPTION: sf = openDialog.getSelectedFile() if sf is not None: filename = sf.getPath() if filename is not None and os.path.isdir(filename): response = JOptionPane.showOptionDialog( component, 'Existing content will be overwritten. Proceed?', 'Overwrite existing content', JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, None, ['Overwrite', 'Cancel'], 'Cancel') if response == JFileChooser.APPROVE_OPTION: exc = None try: project.export(filename) except: exc = JythonException.getCurrentException() if exc is not None: BubblePopup.popupInBubbleAdjacentTo( DefaultPerspective.instance(exc), control.getElement(), Anchor.BOTTOM, True, True)
def openFile(self, event=None): ''' 1. Check if current file in text area has unsaved changes 1.1 Prompt user for file saving 1.1.1 Save file 2. Display browser for user to choose file 3. Load file in text area 4. Display file name in title bar ''' if self.handleUnsaved(): fileChooser = JFileChooser(self.get_working_dir()) file_filter = FileNameExtensionFilter("ATF files", ["atf"]) fileChooser.setFileFilter(file_filter) status = fileChooser.showDialog(self.view, "Choose file") if status == JFileChooser.APPROVE_OPTION: atfFile = fileChooser.getSelectedFile() filename = atfFile.getCanonicalPath() basename = atfFile.getName() atfText = self.readTextFile(filename) self.currentFilename = atfFile.getCanonicalPath() # Clear ATF area before adding next text to clean up tooltips # and such self.atfAreaController.clearAtfArea() self.atfAreaController.setAtfAreaText(atfText) self.logger.debug("File %s successfully opened.", filename) self.view.setTitle(basename) # TODO: Else, prompt user to choose again before closing # Update settings with current file's path self.update_config_element(self.get_working_dir(), 'default', 'working_dir')
def exportToCSV(self): parentFrame = JFrame() fileChooser = JFileChooser() fileChooser.setSelectedFile(File("AutorizeReport.csv")) fileChooser.setDialogTitle("Save Autorize Report") userSelection = fileChooser.showSaveDialog(parentFrame) if userSelection == JFileChooser.APPROVE_OPTION: fileToSave = fileChooser.getSelectedFile() enforcementStatusFilter = self.exportES.getSelectedItem() csvContent = "id\tMethod\tURL\tOriginal length\tModified length\tUnauthorized length\tAuthorization Enforcement Status\tAuthorization Unauthenticated Status\n" for i in range(0,self._log.size()): if enforcementStatusFilter == "All Statuses": csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized) elif enforcementStatusFilter == "As table filter": if ((self._extender.showAuthBypassModified.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatus) or (self._extender.showAuthPotentiallyEnforcedModified.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatus) or (self._extender.showAuthEnforcedModified.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatus) or (self._extender.showAuthBypassUnauthenticated.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatusUnauthorized) or (self._extender.showAuthPotentiallyEnforcedUnauthenticated.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatusUnauthorized) or (self._extender.showAuthEnforcedUnauthenticated.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatusUnauthorized) or (self._extender.showDisabledUnauthenticated.isSelected() and "Disabled" == self._log.get(i)._enfocementStatusUnauthorized)): csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized) else: if (enforcementStatusFilter == self._log.get(i)._enfocementStatus) or (enforcementStatusFilter == self._log.get(i)._enfocementStatusUnauthorized): csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized) f = open(fileToSave.getAbsolutePath(), 'w') f.writelines(csvContent) f.close()
def saveFile(self, event=None): ''' If file being edited has a path, then overwrite with latest changes. If file was created from scratch and has no path, prompt JFileChooser to save in desired location. Also checks for project name, and if found, makes it default. ''' atfText = self.atfAreaController.getAtfAreaText() if not self.currentFilename: fileChooser = JFileChooser(os.getcwd()) status = fileChooser.showSaveDialog(self.view) if status == JFileChooser.APPROVE_OPTION: atfFile = fileChooser.getSelectedFile() filename = atfFile.getCanonicalPath() basename = atfFile.getName() self.currentFilename = filename self.view.setTitle(basename) else: return try: self.writeTextFile(self.currentFilename, atfText) except: self.logger.error("There was an error trying to save %s.", self.currentFilename) else: self.logger.info("File %s successfully saved.", self.currentFilename) # Find project and add to setting.yaml as default project = self.get_project() if project: if self.config['projects']['default'] != project: self.config['projects']['default'] = [project] save_yaml_config(self.config)
def gcodeBottom(event): fc = JFileChooser() fc.setCurrentDirectory( File(boardcad.gui.jdk.BoardCAD.getInstance().defaultDirectory)) returnVal = fc.showSaveDialog( boardcad.gui.jdk.BoardCAD.getInstance().getFrame()) if (returnVal != JFileChooser.APPROVE_OPTION): return mfile = fc.getSelectedFile() filename = mfile.getPath() if (filename == None): return boardcad.gui.jdk.BoardCAD.getInstance().defaultDirectory = mfile.getPath() boardcam.BoardMachine.bottomFileName = filename boardcam.BoardMachine.read_machine_data() filename = boardcam.BoardMachine.bottomScript myconsole.insertText("execfile('" + filename + "')") myconsole.enter() board_draw = boardcad.gui.jdk.BoardCAD.getInstance().getBoardHandler( ).board_draw board_draw.bottom_cut = boardcam.BoardMachine.bottom_cut board_draw.nr_of_cuts_bottom = boardcam.BoardMachine.nr_of_cuts_bottom board_draw.bottom_collision = boardcam.BoardMachine.bottom_collision
def writeConfigDialog(self, e): """Open a file dialog to save configuration""" fileChooser = JFileChooser(os.getcwd()) retval = fileChooser.showSaveDialog(None) if retval == JFileChooser.APPROVE_OPTION: f = fileChooser.getSelectedFile() self.writeConfig(f.getPath())
def createFileChooserDialog(filters, filename, prefs, prefkey, multiselect): """ Creates a file chooser dialog that remembers its last directory. """ fileChooser = JFileChooser() # Add filters if not hasattr(filters, '__iter__'): filters = (filters, ) if filters: for filter in filters: fileChooser.addChoosableFileFilter(filter) fileChooser.fileFilter = filters[0] # Enable/disable multiple file select fileChooser.setMultiSelectionEnabled(multiselect) # Restore the last directory if prefs and prefkey: defaultDirName = prefs.get(prefkey, None) if defaultDirName: defaultDirectory = File(defaultDirName) if defaultDirectory.exists(): fileChooser.currentDirectory = defaultDirectory # Preset the file name if filename: fileChooser.selectedFile = File(fileChooser.currentDirectory, filename) return fileChooser
def selectFile(self, event): print("Choose !!") chooseFile = JFileChooser() ret = chooseFile.showDialog(frm.panel, "Choose file") if ret == JFileChooser.APPROVE_OPTION: file = chooseFile.getSelectedFile() frm.jTextField4.setText(file.getCanonicalPath())
def get_file_name(): fc = JFileChooser() result = fc.showOpenDialog(None) if not result == JFileChooser.APPROVE_OPTION: return None file_name = fc.getSelectedFile() return file_name
def actionPerformed(self, event): """Delete the last row""" # Generate a save dialog dialog = JFileChooser(Prefs.get("roiGroup.importDir", "")) dialog.setSelectedFile(File("roiGroups.txt")) dialog.setFileFilter(FileNameExtensionFilter("Text file", ["txt"])) output = dialog.showOpenDialog( self.groupTable) # could be None argument too if output in [JFileChooser.CANCEL_OPTION, JFileChooser.ERROR_OPTION]: return selectedFile = dialog.getSelectedFile() directory = selectedFile.getParent() Prefs.set("roiGroup.importDir", directory) if not selectedFile.isFile(): return filePath = selectedFile.getPath() # Read comma-separated group from file with open(filePath, "r") as textFile: stringGroup = textFile.readline().rstrip() # Update table with content of file tableModel = self.groupTable.tableModel tableModel.setGroupColumn(stringGroup)
def MultiFileDialog(title): #hide/show debug prints verbose = 0 # Choose image file(s) to open fc = JFileChooser() fc.setMultiSelectionEnabled(True) fc.setDialogTitle(title) sdir = OpenDialog.getDefaultDirectory() if sdir != None: fdir = File(sdir) if fdir != None: fc.setCurrentDirectory(fdir) returnVal = fc.showOpenDialog(IJ.getInstance()) if returnVal != JFileChooser.APPROVE_OPTION: return files = fc.getSelectedFiles() paths = [] for i in range(len(files)): paths.append(os.path.join(files[i].getParent(), files[i].getName())) if verbose > 0: for i in range(len(files)): path = os.path.join(files[i].getParent(), files[i].getName()) print "Path: " + path return paths
def initUI(self): self.tab = JPanel() # UI for Output self.outputLabel = JLabel("AutoRecon Log:") self.outputLabel.setFont(Font("Tahoma", Font.BOLD, 14)) self.outputLabel.setForeground(Color(255, 102, 52)) self.logPane = JScrollPane() self.outputTxtArea = JTextArea() self.outputTxtArea.setFont(Font("Consolas", Font.PLAIN, 12)) self.outputTxtArea.setLineWrap(True) self.logPane.setViewportView(self.outputTxtArea) self.clearBtn = JButton("Clear Log", actionPerformed=self.clearLog) self.exportBtn = JButton("Export Log", actionPerformed=self.exportLog) self.parentFrm = JFileChooser() # Layout layout = GroupLayout(self.tab) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) self.tab.setLayout(layout) layout.setHorizontalGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addGroup( layout.createParallelGroup().addComponent( self.outputLabel).addComponent(self.logPane).addComponent( self.clearBtn).addComponent(self.exportBtn)))) layout.setVerticalGroup(layout.createParallelGroup().addGroup( layout.createParallelGroup().addGroup( layout.createSequentialGroup().addComponent( self.outputLabel).addComponent(self.logPane).addComponent( self.clearBtn).addComponent(self.exportBtn))))
def check_directory(path): if (os.path.lexists(path)): contents = os.listdir(path) if (contents.count("install-birch") == 0): print_console("The selected directory " + path + " does NOT contain a BIRCH installation!") message = "The selected path does NOT contain a BIRCH installation.\nPlease select the base directory of the installation that you wish to update,\nOr click \"no\" to cancel update." reload = JOptionPane.showConfirmDialog(None, message, "Input", JOptionPane.YES_NO_OPTION) if (reload == JOptionPane.NO_OPTION): print_console("User aborted install.") commonlib.shutdown() fc = JFileChooser() fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) fc.showOpenDialog(None) path = fc.getSelectedFile().getPath() check_directory(path) else: ARGS.install_dir = path print_console("The selected directory " + path + " contains a BIRCH installation, it will be updated")
def openFolderDialog(dialogTitle): from javax.swing import JFileChooser chooser = JFileChooser() chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) chooser.setDialogTitle(dialogTitle) if chooser.showOpenDialog(None) == JFileChooser.APPROVE_OPTION: return str(chooser.getSelectedFile())
def getFilePath(self): chooseFile = JFileChooser() panel = JPanel() ret = chooseFile.showDialog(panel, "Choose output file (*.msc)") if ret == JFileChooser.APPROVE_OPTION: file=chooseFile.getSelectedFile() return file
def openFile(self, fileext, filedesc, fileparm): myFilePath = '' chooseFile = JFileChooser() myFilter = FileNameExtensionFilter(filedesc, [fileext]) chooseFile.setFileFilter(myFilter) ret = chooseFile.showOpenDialog(self.tab) if ret == JFileChooser.APPROVE_OPTION: file = chooseFile.getSelectedFile() myFilePath = str(file.getCanonicalPath()).lower() if not myFilePath.endswith(fileext): myFilePath += '.' + fileext okWrite = JOptionPane.YES_OPTION if os.path.isfile(myFilePath): okWrite = JOptionPane.showConfirmDialog( self.tab, 'File already exists. Ok to over-write?', '', JOptionPane.YES_NO_OPTION) if okWrite == JOptionPane.NO_OPTION: return j = True while j: try: f = open(myFilePath, mode=fileparm) j = False except IOError: okWrite = JOptionPane.showConfirmDialog( self.tab, 'File cannot be opened. Correct and retry?', '', JOptionPane.YES_NO_OPTION) if okWrite == JOptionPane.NO_OPTION: return None, False return f, True
def openFile(self, event=None): ''' 1. Check if current file in text area has unsaved changes 1.1 Prompt user for file saving 1.1.1 Save file 2. Display browser for user to choose file 3. Load file in text area 4. Display file name in title bar ''' if self.handleUnsaved(): if self.currentFilename: default_path = os.path.dirname(self.currentFilename) else: default_path = os.getcwd() fileChooser = JFileChooser(default_path) file_filter = FileNameExtensionFilter("ATF files", ["atf"]) fileChooser.setFileFilter(file_filter) status = fileChooser.showDialog(self.view, "Choose file") if status == JFileChooser.APPROVE_OPTION: atfFile = fileChooser.getSelectedFile() filename = atfFile.getCanonicalPath() basename = atfFile.getName() atfText = self.readTextFile(filename) self.currentFilename = atfFile.getCanonicalPath() # Clear ATF area before adding next text to clean up tooltips # and such self.atfAreaController.clearAtfArea() self.atfAreaController.setAtfAreaText(atfText) self.logger.debug("File %s successfully opened.", filename) self.view.setTitle(basename)
def searchFile2(event): label3.text = "Isi pesan terenkripsi" label4.text = "Isi pesan asli" myFileChooser = JFileChooser() rVal = int(myFileChooser.showOpenDialog(None)) print rVal if (rVal == JFileChooser.APPROVE_OPTION): encryptedTextFile.text = myFileChooser.getSelectedFile().getName() encryptedTextPath.text = myFileChooser.getCurrentDirectory().toString() try: myPath = encryptedTextPath.text + "/" + encryptedTextFile.text fileReaderX = FileReader(myPath) bufferedReaderX = BufferedReader(fileReaderX) inputFile = "" textFieldReadable = bufferedReaderX.readLine() while (textFieldReadable != None): inputFile += textFieldReadable inputFile += "\n" textFieldReadable = bufferedReaderX.readLine() pesanAsli.text = inputFile import myGUI.saveToFile as convertThis return convertThis.convertBackToInt(inputFile) except (RuntimeError, TypeError, NameError): print "eror gan"
def __init__(self): self.descriptors = OrderedDict() self.chooser = JFileChooser() self.chooser.addChoosableFileFilter(PROTO_FILENAME_EXTENSION_FILTER) self.chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES) self.chooser.setMultiSelectionEnabled(True)
def actionPerformed(self, e): file_chooser = JFileChooser() is_load_file = str(e.getActionCommand()) == "load" is_save_file = str(e.getActionCommand()) == "save" if is_load_file: file_chooser.setDialogTitle("Load JSON File") file_chooser.setDialogType(JFileChooser.OPEN_DIALOG) open_dialog = file_chooser.showOpenDialog(self.file_button) is_approve = open_dialog == JFileChooser.APPROVE_OPTION if is_approve: load_file = file_chooser.getSelectedFile() file_name = str(load_file) self.load_data(file_name) else: print("JSON file load cancelled") if is_save_file: file_chooser.setDialogTitle("Save JSON File") file_chooser.setDialogType(JFileChooser.SAVE_DIALOG) save_dialog = file_chooser.showSaveDialog(self.file_button) is_approve = save_dialog == JFileChooser.APPROVE_OPTION if is_approve: save_file = str(file_chooser.getSelectedFile()) self.save_data(save_file) else: print("JSON file save cancelled")
def promptSaveDocumentAs(world, component, handleSaveDocumentAsFn, existingFilename=None): filename = None bFinished = False while not bFinished: saveDialog = JFileChooser() saveDialog.setFileFilter( FileNameExtensionFilter( 'Larch project (*.larch)', [ 'larch' ] ) ) response = saveDialog.showSaveDialog( component ) if response == JFileChooser.APPROVE_OPTION: sf = saveDialog.getSelectedFile() if sf is not None: if sf.exists(): response = JOptionPane.showOptionDialog( component, 'File already exists. Overwrite?', 'File already exists', JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, None, [ 'Overwrite', 'Cancel' ], 'Cancel' ) if response == JFileChooser.APPROVE_OPTION: filename = sf.getPath() bFinished = True else: bFinished = False else: filename = sf.getPath() bFinished = True else: bFinished = True else: bFinished = True if filename is not None: handleSaveDocumentAsFn( filename ) return True else: return False
def showFC( self, event ) : fc = JFileChooser() result = fc.showOpenDialog( None ) if result == JFileChooser.APPROVE_OPTION : message = 'result = "%s"' % fc.getSelectedFile() else : message = 'Request canceled by user' self.label.setText( message )
def menuItemClicked(self, menuItemCaption, messageInfo): if menuItemCaption == 'Save PoC': if self.dir: fc = JFileChooser(self.dir) else: fc = JFileChooser() returnVal = fc.showSaveDialog(None) if returnVal == JFileChooser.APPROVE_OPTION: file = fc.getSelectedFile() try: mode = 'w' if file.exists(): res = JOptionPane.showConfirmDialog( None, "File exists. Append?") mode = { JOptionPane.YES_OPTION: 'a', JOptionPane.NO_OPTION: 'w', JOptionPane.CANCEL_OPTION: None, }[res] if not mode: return fp = open(str(file.getAbsolutePath()), mode) for req_resp in messageInfo: req = req_resp.getRequest() resp = req_resp.getResponse() fp.write(req.tostring()) fp.write('\r\n\r\n') fp.write(resp.tostring()) fp.write('\r\n\r\n') fp.close() except Exception, e: JOptionPane.showMessageDialog( None, "Error during save: " + str(e), "Error", JOptionPane.ERROR_MESSAGE) raise JOptionPane.showMessageDialog(None, "File was successfully saved", "Ok", JOptionPane.INFORMATION_MESSAGE) self.dir = fc.getCurrentDirectory()
def loadConfigDialog(self, e): """Open a file dialog to select configuration to load""" fileChooser = JFileChooser(os.getcwd()) retval = fileChooser.showOpenDialog(None) if retval == JFileChooser.APPROVE_OPTION: f = fileChooser.getSelectedFile() log.info("Selected file: " + f.getPath()) self.loadConfig(f.getPath())
def open(self, e): filechooser = JFileChooser() filter = FileNameExtensionFilter("c files", ["c"]) filechooser.addChoosableFileFilter(filter) ret = filechooser.showDialog(self.panel, "Elegir fichero") if ret == JFileChooser.APPROVE_OPTION: file = filechooser.getSelectedFile() text = self.readFile(file) self.area.setText(text)