use of javax.swing.JFileChooser in project zaproxy by zaproxy.
the class PolicyManagerDialog method getExportButton.
private JButton getExportButton() {
if (this.exportButton == null) {
this.exportButton = new JButton(Constant.messages.getString("ascan.policymgr.button.export"));
this.exportButton.setEnabled(false);
this.exportButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0);
if (name != null) {
JFileChooser chooser = new JFileChooser(Constant.getPoliciesDir());
File file = new File(Constant.getZapHome(), name + PolicyManager.POLICY_EXTENSION);
chooser.setSelectedFile(file);
chooser.setFileFilter(new FileFilter() {
@Override
public boolean accept(File file) {
if (file.isDirectory()) {
return true;
} else if (file.isFile() && file.getName().endsWith(".policy")) {
return true;
}
return false;
}
@Override
public String getDescription() {
return Constant.messages.getString("file.format.zap.policy");
}
});
int rc = chooser.showSaveDialog(View.getSingleton().getMainFrame());
if (rc == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
if (file == null) {
return;
}
try {
ScanPolicy policy = extension.getPolicyManager().getPolicy(name);
if (policy != null) {
extension.getPolicyManager().exportPolicy(policy, file);
}
} catch (ConfigurationException e1) {
logger.error(e1.getMessage(), e1);
View.getSingleton().showWarningDialog(Constant.messages.getString("ascan.policy.load.error"));
}
}
}
}
});
}
return this.exportButton;
}
use of javax.swing.JFileChooser in project zaproxy by zaproxy.
the class PopupMenuExportResponse method getOutputFile.
private File getOutputFile(HttpMessage msg) {
String filename = "";
try {
filename = msg.getRequestHeader().getURI().getPath();
int pos = filename.lastIndexOf("/");
filename = filename.substring(pos);
} catch (Exception e) {
}
JFileChooser chooser = new JFileChooser(extension.getModel().getOptionsParam().getUserDirectory());
if (filename.length() > 0) {
chooser.setSelectedFile(new File(filename));
}
File file = null;
int rc = chooser.showSaveDialog(extension.getView().getMainFrame());
if (rc == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
if (file == null) {
return file;
}
extension.getModel().getOptionsParam().setUserDirectory(chooser.getCurrentDirectory());
return file;
}
return file;
}
use of javax.swing.JFileChooser in project zaproxy by zaproxy.
the class BrowserDialog method capture.
private void capture() {
try {
// this.setAlwaysOnTop(true);
BufferedImage screencapture = new Robot().createScreenCapture(new Rectangle(this.getX(), this.getY(), this.getWidth(), this.getHeight() - this.jPanelBottom.getHeight()));
// Save as JPEG
JFileChooser chooser = new JFileChooser();
chooser.addChoosableFileFilter(new FileFilter() {
@Override
public boolean accept(File file) {
String filename = file.getName();
return filename.endsWith(".png");
}
@Override
public String getDescription() {
return "*.png";
}
});
chooser.showSaveDialog(this);
File file = chooser.getSelectedFile();
if (file != null)
ImageIO.write(screencapture, "png", file);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
// this.setAlwaysOnTop(false);
}
use of javax.swing.JFileChooser in project nhin-d by DirectProject.
the class CAPanel method signCSR.
private void signCSR() {
JFileChooser fc = new JFileChooser();
fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
fc.setDialogTitle("Open Signing Request PEM File");
int result = fc.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
final File fl = fc.getSelectedFile();
PEMReader reader = null;
try {
reader = new PEMReader(new InputStreamReader(FileUtils.openInputStream(fl)));
final PKCS10CertificationRequest certReq = (PKCS10CertificationRequest) reader.readObject();
certReq.verify();
final X509Certificate signedCert = CertGenerator.createCertFromCSR(certReq, currentCert);
// validate the certificate
signedCert.verify(currentCert.getSignerCert().getPublicKey());
// write it to a file
final String addressName = CryptoExtensions.getSubjectAddress(signedCert);
final File outFile = new File(addressName + ".der");
FileUtils.writeByteArrayToFile(outFile, signedCert.getEncoded());
JOptionPane.showMessageDialog(this, "Signing successful.\r\nCertificate saved to " + outFile.getAbsolutePath(), "CSR Sign", JOptionPane.PLAIN_MESSAGE);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Error signging CSR: " + e.getMessage(), "CSR Sign Error", JOptionPane.ERROR_MESSAGE);
} finally {
IOUtils.closeQuietly(reader);
}
}
}
use of javax.swing.JFileChooser in project android_frameworks_base by DirtyUnicorns.
the class ComputeThresholdAction method run.
@Override
public void run() {
Main.getUI().showWaitDialog();
Map<String, Set<String>> uses = new HashMap<String, Set<String>>();
for (DumpData d : dataTableModel.getData()) {
Main.getUI().updateWaitDialog("Merging " + d.getPackageName());
updateClassUse(d.getPackageName(), uses, getBootClassPathClasses(d.getDumpData()));
}
Main.getUI().updateWaitDialog("Computing thresholded set");
Set<String> result = fromThreshold(uses, blacklist, threshold);
Main.getUI().hideWaitDialog();
boolean ret = Main.getUI().showConfirmDialog("Computed a set with " + result.size() + " classes, would you like to save to disk?", "Save?");
if (ret) {
JFileChooser jfc = new JFileChooser();
int ret2 = jfc.showSaveDialog(Main.getUI());
if (ret2 == JFileChooser.APPROVE_OPTION) {
File f = jfc.getSelectedFile();
saveSet(result, f);
}
}
}
Aggregations