List of usage examples for javax.swing JFileChooser showDialog
@SuppressWarnings("deprecation") public int showDialog(Component parent, String approveButtonText) throws HeadlessException
From source file:org.photovault.swingui.BrowserWindow.java
/** Shows an file selection dialog that allows user to select a file to import. After that shows the PhotoInfo dialog to allow the user to edit the eriginal information about the file. *//*from ww w . j ava 2s . c om*/ protected void importFile() { // Show the file chooser dialog JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new ImageFilter()); fc.setAccessory(new ImagePreview(fc)); fc.setMultiSelectionEnabled(true); int retval = fc.showDialog(window, "Import"); if (retval == JFileChooser.APPROVE_OPTION) { // Add the selected file to the database and allow user to edit its attributes final File[] files = fc.getSelectedFiles(); final ProgressDlg pdlg = new ProgressDlg(window, true); // Add all the selected files to DB final PhotoInfo[] photos = new PhotoInfo[files.length]; Thread importThread = new Thread() { @Override public void run() { for (int n = 0; n < files.length; n++) { try { photos[n] = PhotoInfo.addToDB(files[n]); pdlg.setProgressPercent((n * 100) / files.length); pdlg.setStatus("" + (n + 1) + " of " + files.length + " files imported."); } catch (Exception e) { log.error("Unexpected exception: " + e.getMessage()); } } pdlg.completed(); } }; importThread.start(); pdlg.setVisible(true); // Show editor dialog for the added photos // PhotoInfoDlg dlg = new PhotoInfoDlg( window, false, photos ); PhotoInfoDlg dlg = null; dlg.showDialog(); } }
From source file:org.piraso.ui.base.ExportDialog.java
private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseActionPerformed File home = new File(System.getProperty("user.home")); File pirasoDir = new File(home, "piraso"); if (!pirasoDir.isDirectory()) { pirasoDir.mkdirs();//from w ww . jav a 2 s.c o m } String username = System.getProperty("user.name"); JFileChooser browserFileChooser = new FileChooserBuilder("piraso-dir") .setTitle(NbBundle.getMessage(ExportDialog.class, "ExportDialog.browser.title")) .setDefaultWorkingDirectory(pirasoDir).setFileFilter(new PirasoSettingsFileFilter()) .createFileChooser(); browserFileChooser.setSelectedFile(new File(pirasoDir, String.format("%s-piraso.settings.prz", username))); int result = browserFileChooser.showDialog(this, NbBundle.getMessage(ExportDialog.class, "ExportDialog.browser.approveText")); if (JFileChooser.APPROVE_OPTION == result) { txtTargetFile.setText(browserFileChooser.getSelectedFile().getAbsolutePath()); refreshButtons(); } }
From source file:org.piraso.ui.base.ImportDialog.java
private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseActionPerformed File home = new File(System.getProperty("user.home")); File pirasoDir = new File(home, "piraso"); if (!pirasoDir.isDirectory()) { pirasoDir.mkdirs();//from ww w . java2 s .co m } JFileChooser browserFileChooser = new FileChooserBuilder("piraso-dir") .setTitle(NbBundle.getMessage(ImportDialog.class, "ImportDialog.browser.title")) .setDefaultWorkingDirectory(pirasoDir).setFileFilter(new PirasoSettingsFileFilter()) .createFileChooser(); browserFileChooser.setDialogType(JFileChooser.OPEN_DIALOG); int result = browserFileChooser.showDialog(this, NbBundle.getMessage(ImportDialog.class, "ImportDialog.browser.approveText")); if (JFileChooser.APPROVE_OPTION == result) { selectedFile = browserFileChooser.getSelectedFile(); txtSourceFile.setText(browserFileChooser.getSelectedFile().getAbsolutePath()); try { settings = JacksonUtils.MAPPER.readValue(selectedFile, ObjectEntrySettings.class); } catch (IOException e) { ErrorManager.getDefault().notify(e); return; } refresh(); } }
From source file:org.piraso.ui.base.OpenMonitorInstanceDialog.java
private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseActionPerformed File home = new File(System.getProperty("user.home")); File pirasoDir = new File(home, "piraso"); File pirasoSaveDir = new File(pirasoDir, "saved"); if (!pirasoSaveDir.isDirectory()) { pirasoSaveDir.mkdirs();/*ww w . j ava2s .c o m*/ } JFileChooser browserFileChooser = new FileChooserBuilder("piraso-saved-dir") .setTitle(NbBundle.getMessage(OpenMonitorInstanceDialog.class, "OpenMonitorInstanceDialog.browser.title")) .setFileFilter(new PirasoFileFilter()).setDefaultWorkingDirectory(pirasoSaveDir) .createFileChooser(); browserFileChooser.setDialogType(JFileChooser.OPEN_DIALOG); int result = browserFileChooser.showDialog(this, NbBundle.getMessage(OpenMonitorInstanceDialog.class, "OpenMonitorInstanceDialog.browser.approveText")); if (JFileChooser.APPROVE_OPTION == result) { selectedFile = browserFileChooser.getSelectedFile(); txtSourceFile.setText(browserFileChooser.getSelectedFile().getAbsolutePath()); refreshButtons(); } }
From source file:org.piraso.ui.base.SaveMonitorInstanceDialog.java
private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseActionPerformed File home = new File(System.getProperty("user.home")); File pirasoDir = new File(home, "piraso"); File pirasoSaveDir = new File(pirasoDir, "saved"); if (!pirasoSaveDir.isDirectory()) { pirasoSaveDir.mkdirs();/*from w w w .java 2s. c o m*/ } JFileChooser browserFileChooser = new FileChooserBuilder("piraso-saved-dir") .setTitle(NbBundle.getMessage(SaveMonitorInstanceDialog.class, "SaveMonitorInstanceDialog.browser.title")) .setFileFilter(new PirasoFileFilter()).setDefaultWorkingDirectory(pirasoSaveDir) .createFileChooser(); String replaceName = StringUtils.replaceChars(name, "[]", ""); if (!replaceName.endsWith(String.format(".%s", PirasoFileFilter.EXTENSION))) { replaceName = String.format("%s.%s", replaceName, PirasoFileFilter.EXTENSION); } browserFileChooser.setSelectedFile(new File(pirasoSaveDir, replaceName)); int result = browserFileChooser.showDialog(this, NbBundle.getMessage(SaveMonitorInstanceDialog.class, "SaveMonitorInstanceDialog.browser.approveText")); if (JFileChooser.APPROVE_OPTION == result) { txtTargetFile.setText(browserFileChooser.getSelectedFile().getAbsolutePath()); refreshButtons(); } }
From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java
/** * Creates a filechooser where the user can select the (comma-seperated) * file that he wants to export to. If this file already exists, permission * to overwrite is requested, else a new file is created to which the * time-metrics of the selected place/transitions are exported. * /* w ww .j a v a 2s .c o m*/ */ private void exportObjectMetrics() { // create and initialize the file chooser final JFileChooser fc = new JFileChooser(); NameFilter filt1 = new NameFilter(".csv"); NameFilter filt2 = new NameFilter(".txt"); fc.addChoosableFileFilter(filt1); fc.addChoosableFileFilter(filt2); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(filt1); // check whether a place is selected int result = fc.showDialog(this, "Export"); if (result == 0) { // Export-button was pushed File selectedFile = fc.getSelectedFile(); if (!(selectedFile.getName().endsWith(fc.getFileFilter().getDescription().substring(1)))) { // create new file, with filetype added to it selectedFile = new File( selectedFile.getAbsolutePath() + fc.getFileFilter().getDescription().substring(1)); } if (!selectedFile.exists()) { if (boxMap.get(sb1.getSelectedItem()) instanceof ExtendedPlace) { // actually perform export of place time-metrics exportPlaceMetrics(selectedFile); } else { if (boxMap.get(sb2.getSelectedItem()) instanceof ExtendedTransition) { // actually perform export of transition time-metrics exportTransitionMetrics(selectedFile); } else { // actually perform export of activity time-metrics exportActivityMetrics(selectedFile); } } } else { // file already exist, open a confirm dialog containing a // 'Yes' Button as well as a 'No' button int overwrite = JOptionPane.showConfirmDialog(this, "File already exists! Overwrite?", "Confirm Dialog", 0); if (overwrite == 0) { // user has selected Yes if (boxMap.get(sb1.getSelectedItem()) instanceof ExtendedPlace) { // actually perform export of place time-metrics exportPlaceMetrics(selectedFile); } else { if (boxMap.get(sb2.getSelectedItem()) instanceof ExtendedTransition) { // actually perform export of transition // time-metrics exportTransitionMetrics(selectedFile); } else { // actually perform export of activity time-metrics exportActivityMetrics(selectedFile); } } } } } }
From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java
/** * Creates a filechooser where the user can select the (comma-seperated) * file that he wants to export to. If this file already exists, permission * to overwrite is requested, else a new file is created to which the * throughput times of the selected process instances are exported. * //from w w w . ja va 2 s.c om */ private void exportProcessMetrics() { // create and initialize the file chooser final JFileChooser fc = new JFileChooser(); NameFilter filt1 = new NameFilter(".csv"); NameFilter filt2 = new NameFilter(".txt"); fc.addChoosableFileFilter(filt1); fc.addChoosableFileFilter(filt2); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(filt1); // check whether a place is selected int result = fc.showDialog(this, "Export"); if (result == 0) { // Export-button was pushed File selectedFile = fc.getSelectedFile(); if (!(selectedFile.getName().endsWith(fc.getFileFilter().getDescription().substring(1)))) { // create new file, with filetype added to it selectedFile = new File( selectedFile.getAbsolutePath() + fc.getFileFilter().getDescription().substring(1)); } if (!selectedFile.exists()) { try { // actually export the throughput times to the file replayResult.exportToFile(getSelectedInstances(), selectedFile, timeDivider, timeSort, advancedSettings[0]); } catch (IOException ex) { Message.add("IO exception: " + ex.toString(), 2); } } else { // file already exist, open a confirm dialog containing a // 'Yes' Button as well as a 'No' button int overwrite = JOptionPane.showConfirmDialog(this, "File already exists! Overwrite?", "Confirm Dialog", 0); if (overwrite == 0) { // user has selected Yes try { // actually export the throughput times to the file replayResult.exportToFile(getSelectedInstances(), selectedFile, timeDivider, timeSort, advancedSettings[0]); } catch (IOException ex) { Message.add("IO exception: " + ex.toString(), 2); } } } } }
From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java
/** * Creates a filechooser where the user can select the (comma-seperated) * file that he wants to export to. If this file already exists, permission * to overwrite is requested, else a new file is created to which the * time-metrics of the selected place/transitions are exported. * *///from w w w . ja v a 2 s . c o m private void exportObjectMetrics() { //create and initialize the file chooser final JFileChooser fc = new JFileChooser(); NameFilter filt1 = new NameFilter(".csv"); NameFilter filt2 = new NameFilter(".txt"); fc.addChoosableFileFilter(filt1); fc.addChoosableFileFilter(filt2); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(filt1); //check whether a place is selected int result = fc.showDialog(this, "Export"); if (result == 0) { //Export-button was pushed File selectedFile = fc.getSelectedFile(); if (!(selectedFile.getName().endsWith(fc.getFileFilter().getDescription().substring(1)))) { //create new file, with filetype added to it selectedFile = new File( selectedFile.getAbsolutePath() + fc.getFileFilter().getDescription().substring(1)); } if (!selectedFile.exists()) { if (boxMap.get(sb1.getSelectedItem()) instanceof ExtendedPlace) { //actually perform export of place time-metrics exportPlaceMetrics(selectedFile); } else { if (boxMap.get(sb2.getSelectedItem()) instanceof ExtendedTransition) { //actually perform export of transition time-metrics exportTransitionMetrics(selectedFile); } else { //actually perform export of activity time-metrics exportActivityMetrics(selectedFile); } } } else { //file already exist, open a confirm dialog containing a //'Yes' Button as well as a 'No' button int overwrite = JOptionPane.showConfirmDialog(this, "File already exists! Overwrite?", "Confirm Dialog", 0); if (overwrite == 0) { //user has selected Yes if (boxMap.get(sb1.getSelectedItem()) instanceof ExtendedPlace) { //actually perform export of place time-metrics exportPlaceMetrics(selectedFile); } else { if (boxMap.get(sb2.getSelectedItem()) instanceof ExtendedTransition) { //actually perform export of transition time-metrics exportTransitionMetrics(selectedFile); } else { //actually perform export of activity time-metrics exportActivityMetrics(selectedFile); } } } } } }
From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java
/** * Creates a filechooser where the user can select the (comma-seperated) * file that he wants to export to. If this file already exists, permission * to overwrite is requested, else a new file is created to which the * throughput times of the selected process instances are exported. * *//*from ww w.ja v a2s .c o m*/ private void exportProcessMetrics() { //create and initialize the file chooser final JFileChooser fc = new JFileChooser(); NameFilter filt1 = new NameFilter(".csv"); NameFilter filt2 = new NameFilter(".txt"); fc.addChoosableFileFilter(filt1); fc.addChoosableFileFilter(filt2); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(filt1); //check whether a place is selected int result = fc.showDialog(this, "Export"); if (result == 0) { //Export-button was pushed File selectedFile = fc.getSelectedFile(); if (!(selectedFile.getName().endsWith(fc.getFileFilter().getDescription().substring(1)))) { //create new file, with filetype added to it selectedFile = new File( selectedFile.getAbsolutePath() + fc.getFileFilter().getDescription().substring(1)); } if (!selectedFile.exists()) { try { //actually export the throughput times to the file replayResult.exportToFile(getSelectedInstances(), selectedFile, timeDivider, timeSort, advancedSettings[0]); } catch (IOException ex) { Message.add("IO exception: " + ex.toString(), 2); } } else { //file already exist, open a confirm dialog containing a //'Yes' Button as well as a 'No' button int overwrite = JOptionPane.showConfirmDialog(this, "File already exists! Overwrite?", "Confirm Dialog", 0); if (overwrite == 0) { //user has selected Yes try { //actually export the throughput times to the file replayResult.exportToFile(getSelectedInstances(), selectedFile, timeDivider, timeSort, advancedSettings[0]); } catch (IOException ex) { Message.add("IO exception: " + ex.toString(), 2); } } } } }
From source file:org.rvsnoop.ui.RvSnoopApplication.java
@Override protected void startup() { setMainFrame(injector.getInstance(Application.class).getFrame()); final JFrame frame = getMainFrame(); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new FrameClosingListener()); addExitListener(new MaybeExit()); ApplicationActionMap actionMap = getContext().getActionMap(); JMenu fileMenu = frame.getJMenuBar().getMenu(0); fileMenu.addSeparator();//from w w w. j a v a 2 s . c o m fileMenu.add(actionMap.get("quit")); frame.getJMenuBar().add(createHelpMenu()); getContext().getResourceMap().injectComponents(frame); if (AppHelper.getPlatform() == PlatformType.OS_X) { configureMacOsEventHandlers(); } if (initialProjectFile == null) { final JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new ProjectFileFilter()); final int option = chooser.showDialog(null, "Open Project"); initialProjectFile = chooser.getSelectedFile(); if (JFileChooser.APPROVE_OPTION != option || initialProjectFile == null) { exit(); } } show(frame); injector.getInstance(ProjectService.class).openProject(initialProjectFile); }