24.12.2014 Views

Download - Svetlin Nakov

Download - Svetlin Nakov

Download - Svetlin Nakov

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

* Called when the browse button is pressed.<br />

* Shows file choose dialog and allows the user to locate a PFX file.<br />

*/<br />

private void browseForCertButton_actionPerformed() {<br />

JFileChooser fileChooser = new JFileChooser();<br />

PFXFileFilter pfxFileFilter = new PFXFileFilter();<br />

fileChooser.addChoosableFileFilter(pfxFileFilter);<br />

String certFileName = mCertFileNameTextField.getText();<br />

File directory = new File(certFileName).getParentFile();<br />

fileChooser.setCurrentDirectory(directory);<br />

if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {<br />

String selectedCertFile =<br />

fileChooser.getSelectedFile().getAbsolutePath();<br />

mCertFileNameTextField.setText(selectedCertFile);<br />

}<br />

}<br />

/**<br />

* Called when the sign button is pressed. Closses the dialog and sets the<br />

* result flag to true to indicate that the user is confirmed the information<br />

* entered in the dialog.<br />

*/<br />

private void signButton_actionPerformed() {<br />

mResult = true;<br />

hide();<br />

}<br />

/**<br />

* Called when the cancel button is pressed. Closses the dialog and sets the<br />

* result flag to false that indicates that the dialog is canceled.<br />

*/<br />

private void cancelButton_actionPerformed() {<br />

mResult = false;<br />

hide();<br />

}<br />

/**<br />

* @return the file name with full path to it where the dialog settings are<br />

* stored.<br />

*/<br />

private String getConfigFileName() {<br />

String configFileName = System.getProperty("user.home") +<br />

System.getProperty("file.separator") + CONFIG_FILE_NAME;<br />

return configFileName;<br />

}<br />

/**<br />

* Loads the dialog settings from the dialog configuration file. These settings<br />

* consist of a single value - the last used PFX file name with its full path.<br />

*/<br />

private void loadSettings()<br />

throws IOException {<br />

// Load settings file<br />

String configFileName = getConfigFileName();<br />

FileInputStream configFileStream = new FileInputStream(configFileName);<br />

Properties configProps = new Properties();<br />

configProps.load(configFileStream);<br />

configFileStream.close();<br />

// Apply setings from the config file<br />

String lastCertificateFileName =<br />

configProps.getProperty(PFX_FILE_NAME_KEY);<br />

if (lastCertificateFileName != null)<br />

mCertFileNameTextField.setText(lastCertificateFileName);<br />

84

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!