List of usage examples for javax.swing JFileChooser showDialog
@SuppressWarnings("deprecation") public int showDialog(Component parent, String approveButtonText) throws HeadlessException
From source file:de.peterspan.csv2db.ui.FileSelectionPanel.java
private JButton getSelectCsvSelectButton() { if (selectCsvFileButton == null) { selectCsvFileButton = new JButton(); selectCsvFileButton.setText("Select CSV"); selectCsvFileButton.setIcon(Icons.IC_MIME_CSV_SMALL); selectCsvFileButton.addActionListener(new ActionListener() { @Override/* w w w.j a v a2s.com*/ public void actionPerformed(ActionEvent arg0) { JFileChooser fc = getFileChooser(); int returnValue = fc.showDialog(parent, "Select CSV"); if (returnValue == JFileChooser.APPROVE_OPTION) { inputCsvFile = fc.getSelectedFile(); getCsvFilenameTextField().setText(inputCsvFile.getAbsolutePath()); firePropertyChange("csvFileSelected", false, true); } } }); } return selectCsvFileButton; }
From source file:it.unibas.spicygui.controllo.mapping.ActionExportTranslatedInstancesCsv.java
@Override public void performAction() { Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO); MappingTask mappingTask = scenario.getMappingTask(); JFileChooser chooser = vista.getFileChooserSalvaFolder(); File file;//from ww w . ja v a 2 s . co m int returnVal = chooser.showDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(Costanti.class, Costanti.EXPORT)); if (returnVal == JFileChooser.APPROVE_OPTION) { try { file = chooser.getSelectedFile(); DAOCsv daoCsv = new DAOCsv(); daoCsv.exportTranslatedCSVinstances(mappingTask, file.getAbsolutePath(), scenario.getNumber()); //giannisk canonical tree not needed ////daoCsv.exportCanonicalCSVinstances(mappingTask.getMappingData().getCanonicalSolution().getDataSource(), file.getAbsolutePath()); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK))); //StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK)); } catch (DAOException ex) { logger.error(ex); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); } } }
From source file:it.unibas.spicygui.controllo.mapping.ActionExportTranslatedInstances.java
@Override public void performAction() { Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO); MappingTask mappingTask = scenario.getMappingTask(); JFileChooser chooser = vista.getFileChooserSalvaFolder(); File file;/* w w w. ja va 2 s. c o m*/ int returnVal = chooser.showDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(Costanti.class, Costanti.EXPORT)); if (returnVal == JFileChooser.APPROVE_OPTION) { try { file = chooser.getSelectedFile(); DAOXsd daoXsd = new DAOXsd(); daoXsd.exportTranslatedXMLinstances(mappingTask.getMappingData().getSolution().getDataSource(), file.getAbsolutePath()); //giannisk canonical tree not needed ////daoXsd.exportCanonicalXMLinstances(mappingTask.getMappingData().getCanonicalSolution().getDataSource(), file.getAbsolutePath()); StatusDisplayer.getDefault() .setStatusText(NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK)); } catch (DAOException ex) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); logger.error(ex); } } }
From source file:kuvalataaja.user_interface.GUI.java
/** * Select a directory and pass it to Main.run */// w ww .j av a 2s. co m public void runTheProgram() { String separatorString = openSettings(); char separator = separatorString.charAt(0); JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.showDialog(this, "Please select your Music folder"); File f = new File(chooser.getSelectedFile().getPath()); textArea.setText("Working..."); String[] result = kuvalataaja.kuvalataaja.Main.run(f, separator); //Shows a list of which album covers were fetched showResult(result); }
From source file:it.unibas.spicygui.controllo.mapping.ActionExportTgds.java
@Override public void performAction() { Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO); MappingTask mappingTask = scenario.getMappingTask(); JFileChooser chooser = vista.getFileChooserApriTXT(); File file;//from w w w.j a v a 2s .co m continua = true; while (continua) { int returnVal = chooser.showDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(Costanti.class, Costanti.EXPORT_TGDS)); if (returnVal == JFileChooser.APPROVE_OPTION) { file = chooser.getSelectedFile(); if (!file.exists()) { saveTGDs(mappingTask, file); } else { confirmSave(mappingTask, file); } } else { continua = false; } } /* List<FORule> foRules = mappingTask.getMappingData().getSTTgds(); for (FORule foRule : foRules) { System.out.println(foRule.toLogicalString(mappingTask)); }*/ }
From source file:filesscanner.MainWindow.java
private void scanBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scanBtnActionPerformed File f = new File("C:"); JFileChooser chooser = ShowChooser(f); int res = chooser.showDialog(this, " "); if (res == JFileChooser.APPROVE_OPTION) { File[] files = chooser.getSelectedFiles(); int key = 0; for (File file : files) { modelDirectories.add(key++, chooser.getSelectedFile().toString()); }/* ww w . j a va 2 s. co m*/ } }
From source file:it.unibas.spicygui.controllo.mapping.ActionGenerateAndTranslate.java
private void checkForPKConstraints(MappingTask mappingTask, HashSet<String> pkTableNames, int scenarioNo) throws DAOException { if (!pkTableNames.isEmpty()) { NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Confirmation( NbBundle.getMessage(Costanti.class, Costanti.MESSAGE_PK_TABLES), DialogDescriptor.YES_NO_OPTION); DialogDisplayer.getDefault().notify(notifyDescriptor); if (notifyDescriptor.getValue().equals(NotifyDescriptor.YES_OPTION)) { String[] format = { NbBundle.getMessage(Costanti.class, Costanti.OUTPUT_TYPE_CSV), NbBundle.getMessage(Costanti.class, Costanti.OUTPUT_TYPE_JSON) }; int formatResponse = JOptionPane.showOptionDialog(null, NbBundle.getMessage(Costanti.class, Costanti.MESSAGE_PK_OUTPUT), NbBundle.getMessage(Costanti.class, Costanti.PK_OUTPUT_TITLE), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, format, format[0]); if (formatResponse != JOptionPane.CLOSED_OPTION) { JFileChooser chooser = vista.getFileChooserSalvaFolder(); File file;/* w w w .j a va 2 s .c o m*/ int returnVal = chooser.showDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(Costanti.class, Costanti.EXPORT)); if (returnVal == JFileChooser.APPROVE_OPTION) { file = chooser.getSelectedFile(); if (formatResponse == 0) { DAOCsv daoCsv = new DAOCsv(); daoCsv.exportPKConstraintCSVinstances(mappingTask, pkTableNames, file.getAbsolutePath(), scenarioNo); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK))); } else if (formatResponse == 1) { DAOJson daoJson = new DAOJson(); daoJson.exportPKConstraintJsoninstances(mappingTask, pkTableNames, file.getAbsolutePath(), scenarioNo); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK))); } } } } } }
From source file:com.antelink.sourcesquare.gui.controller.SourceSquareController.java
public void bind() { this.view.getSelectButtonLabel().addMouseListener(new MouseListener() { @Override//from w ww . ja v a2s . co m public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileHidingEnabled(false); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int showDialog = fileChooser.showDialog(SourceSquareController.this.view, "Select directory"); if (showDialog == JFileChooser.APPROVE_OPTION) { SourceSquareController.this.view.getTextField() .setText(fileChooser.getSelectedFile().getAbsolutePath()); } } }); this.view.getScanButtonLabel().addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent arg0) { File toScan = new File(SourceSquareController.this.view.getTextField().getText()); if (!toScan.exists() || toScan.list().length == 0) { JOptionPane.showMessageDialog(SourceSquareController.this.view, "Choose a valid and not empty directory", null, JOptionPane.ERROR_MESSAGE); return; } SourceSquareController.this.view.setVisible(false); SourceSquareController.this.eventBus.fireEvent(new StartScanEvent(toScan)); } }); }
From source file:com.view.Main.java
private void filePathBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filePathBrowseButtonActionPerformed final JFileChooser fileChooser = new JFileChooser("."); final FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel files", "xlsx", "xls"); fileChooser.addChoosableFileFilter(filter); fileChooser.setFileFilter(filter);/* www . j av a 2 s.c om*/ int result = fileChooser.showDialog(this, "choose a file"); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); filePathTextField.setText(selectedFile.getAbsolutePath()); } }
From source file:filesscanner.MainWindow.java
private void saveToJSONBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveToJSONBtnActionPerformed JSONObject object = new JSONObject(); for (int i = 0; i < modelFiles.getSize(); i++) { object.put("filename" + i, modelFiles.get(i).toString()); }//from w ww.ja v a 2 s .c o m File file = new File("C:"); JFileChooser chooser = ShowChooser(file); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setDialogType(JFileChooser.SAVE_DIALOG); int res = chooser.showDialog(this, " ? ??!!!"); if (res == JFileChooser.APPROVE_OPTION) { try { Writer writer = new FileWriter(chooser.getSelectedFile()); object.writeJSONString(writer); JOptionPane.showMessageDialog(rootPane, "SAVED SUCCESFULLY!!!"); writer.flush(); writer.close(); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(rootPane, "Something bad!!!"); } } }