tbrugz avatar tbrugz committed ae45d31

added filter (CertFileFilter) for certificate file chooser (".ks", ".jks", ".p12", ".cer", ".crt")

Comments (0)

Files changed (2)

src/net/sf/pdfsplice/PDFSplice.java

 import javax.swing.SwingUtilities;
 import javax.swing.filechooser.FileFilter;
 
+import net.sf.pdfsplice.sign.CertFileFilter;
 import net.sf.pdfsplice.sign.Signer;
 import net.sf.pdfsplice.uiutil.FileNameExtensionFilter;
 import net.sf.pdfsplice.uiutil.LAFMenu;
 			}
 			else if(e.getSource().equals(signKeyPathButton)) {
 				JFileChooser chooser = new JFileChooser();
+				chooser.setFileFilter(certfilefilter);
 				int returnVal = chooser.showOpenDialog(parent);
 				if (returnVal == JFileChooser.APPROVE_OPTION) {
 					signKeyPath = chooser.getSelectedFile();
 			else if(e.getSource().equals(signCertInfoButton)) {
 				try {
 					JFrame jf = new JFrame();
+					jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 					JTextArea ta = new JTextArea();
 					jf.getContentPane().add(new JScrollPane(ta));
 					
 	JPasswordField signPassword = new JPasswordField("",20);
 	JTextField signReason = new JTextField("",20);
 	JTextField signLocation = new JTextField("",20);
+	CertFileFilter certfilefilter = new CertFileFilter();
 	
 	MultiFilePanel mfAttaches = new MultiFilePanel(false);
 	

src/net/sf/pdfsplice/sign/CertFileFilter.java

+package net.sf.pdfsplice.sign;
+
+import java.io.File;
+
+import javax.swing.filechooser.FileFilter;
+
+public class CertFileFilter extends FileFilter {
+	String[] exts = {".ks", ".jks", ".p12", ".cer", ".crt" };
+	String desc;
+	
+	{
+		desc = "Arquivos de Certificado (";
+		for(String s: exts) { desc += s+", "; }
+		desc += ")";
+	}
+	
+	public boolean accept(File f) {
+		if(f.isDirectory()) { return true; }
+		for(String s: exts) {
+			if(f.getName().toLowerCase().endsWith(s)) { return true; }
+		}
+		return false;
+	}
+
+	public String getDescription() {
+		return desc;
+	}	
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.