List of usage examples for javax.swing JFileChooser CANCEL_OPTION
int CANCEL_OPTION
To view the source code for javax.swing JFileChooser CANCEL_OPTION.
Click Source Link
From source file:view.ViewFiltrar.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed JFileChooser chooserDiretorio = new JFileChooser(ViewPrincipal.ROOTWOKSPACE); chooserDiretorio.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooserDiretorio.setDialogTitle("Escolha o diretrio de saida."); resultado = chooserDiretorio.showOpenDialog(getParent()); if (resultado == JFileChooser.APPROVE_OPTION) { String path = chooserDiretorio.getSelectedFile().getPath(); jTextFieldOutputDirectory.setText(path); } else if (resultado == JFileChooser.CANCEL_OPTION) System.out.println("Cancelado."); }
From source file:view.ViewFiltrar.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed JFileChooser chooserDiretorio = new JFileChooser(ViewPrincipal.ROOTWOKSPACE); chooserDiretorio.setFileFilter(filter); chooserDiretorio.setDialogTitle("Escolha o arquivo que deseja importar."); resultado = chooserDiretorio.showOpenDialog(getParent()); if (resultado == JFileChooser.APPROVE_OPTION) { File selectedFile = chooserDiretorio.getSelectedFile(); jTextFieldInputFileFiltragem.setText(selectedFile.getName()); String fileNameWithOutExt = FilenameUtils.removeExtension(selectedFile.getName()); jTextField4.setText(/*from w w w.j av a 2s. c o m*/ fileNameWithOutExt + "_filtered." + FilenameUtils.getExtension(selectedFile.getName())); } else if (resultado == JFileChooser.CANCEL_OPTION) System.out.println("Cancelado."); }
From source file:view.ViewFiltrar.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed JFileChooser chooserDiretorio = new JFileChooser(ViewPrincipal.ROOTWOKSPACE); chooserDiretorio.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooserDiretorio.setDialogTitle("Escolha o diretrio de saida."); resultado = chooserDiretorio.showOpenDialog(getParent()); if (resultado == JFileChooser.APPROVE_OPTION) { String path = chooserDiretorio.getSelectedFile().getPath(); jTextFieldOutputDiretorioFiltragem.setText(path); } else if (resultado == JFileChooser.CANCEL_OPTION) System.out.println("Cancelado."); }
From source file:view.WorkspacePanel.java
private void signDocument(Document document, boolean ocsp, boolean timestamp) { try {/*from w ww . j a v a2 s. com*/ if (tempCCAlias.getMainCertificate().getPublicKey().equals( CCInstance.getInstance().loadKeyStoreAndAliases().get(0).getMainCertificate().getPublicKey())) { try { String path1 = document.getDocumentLocation(); String path2 = null; if (path1.endsWith(".pdf")) { path2 = path1.substring(0, path1.length() - 4).concat("(aCCinado).pdf"); } JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle(Bundle.getBundle().getString("btn.saveAs")); if (null != path2) { boolean validPath = false; FileNameExtensionFilter pdfFilter = new FileNameExtensionFilter( Bundle.getBundle().getString("filter.pdfDocuments") + " (*.pdf)", "pdf"); fileChooser.setFileFilter(pdfFilter); File preferedFile = new File(path2); fileChooser.setCurrentDirectory(preferedFile); fileChooser.setSelectedFile(preferedFile); while (!validPath) { int userSelection = fileChooser.showSaveDialog(this); if (userSelection == JFileChooser.CANCEL_OPTION) { return; } if (userSelection == JFileChooser.APPROVE_OPTION) { String dest = fileChooser.getSelectedFile().getAbsolutePath(); if (new File(dest).exists()) { String msg = Bundle.getBundle().getString("msg.fileExists"); Object[] options = { Bundle.getBundle().getString("opt.replace"), Bundle.getBundle().getString("opt.chooseNewPath"), Bundle.getBundle().getString("btn.cancel") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { validPath = true; } else if (opt == JOptionPane.CANCEL_OPTION) { return; } } else { validPath = true; } signatureSettings.setOcspClient(ocsp); signatureSettings.setTimestamp(timestamp); if (validPath) { if (!CCInstance.getInstance().signPdf(document.getDocumentLocation(), dest, signatureSettings, null)) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("unknownErrorLog"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); return; } status = Status.READY; ArrayList<File> list = new ArrayList<>(); list.add(new File(document.getDocumentLocation())); int tempPage = imagePanel.getPageNumber(); mainWindow.closeDocuments(list, false); mainWindow.loadPdf(new File(dest), false); hideRightPanel(); imagePanel.setPageNumber(tempPage); JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("label.signatureOk"), "", JOptionPane.INFORMATION_MESSAGE); break; } } } } return; } catch (IOException ex) { if (ex instanceof FileNotFoundException) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.keystoreFileNotFound"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); controller.Logger.getLogger().addEntry(ex); } else if (ex.getLocalizedMessage().equals(Bundle.getBundle().getString("outputFileError"))) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.failedCreateOutputFile"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); controller.Logger.getLogger().addEntry(ex); signDocument(document, ocsp, timestamp); } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("unknownErrorLog"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); controller.Logger.getLogger().addEntry(ex); } } catch (DocumentException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | HeadlessException | CertificateException | KeyStoreException ex) { controller.Logger.getLogger().addEntry(ex); } catch (SignatureFailedException ex) { if (ex.getLocalizedMessage().equals(Bundle.getBundle().getString("timestampFailed"))) { String msg = Bundle.getBundle().getString("msg.timestampFailedNoInternet"); Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { signDocument(document, false, false); } } else { controller.Logger.getLogger().addEntry(ex); } } return; } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); } } catch (LibraryNotLoadedException | KeyStoreNotLoadedException | CertificateException | KeyStoreException | LibraryNotFoundException | AliasException ex) { controller.Logger.getLogger().addEntry(ex); } JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); }