package View;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import Util.Constant;
import XML.ParseXML;
import Model.EncryptAndDecryptInterface;
public class View extends JFrame implements ViewInterface {
/**
*
*/
private static final long serialVersionUID = 1L;
EncryptAndDecryptInterface model;
JFileChooser fileChooser;
private JComboBox algorithmCombo;
private JPanel asymmetric;
private JRadioButton asymmetricRadio;
private JButton browseFileDesDecryptButton;
private JButton browseFileDesEncryptButton;
private JButton browseFileSourseDecryptButton;
private JButton browseFileSourseEncryptButton;
private JPanel chooseFilePane;
private JPanel chooseFilePane1;
private JButton decryptButton;
private JTextField desFileDecryptTextBox;
private JTextField desFileEncryptTextBox;
private JButton encryptButton;
private JTextField fileSourceDecryptTextField;
private JTextField fileSourceEncryptTextField;
private JLabel infoAlgorithm;
private JLabel infoMode;
private JLabel infoPadding;
private JLabel infoProvider;
private JLabel jLabel1;
private JLabel jLabel10;
private JLabel jLabel11;
private JLabel jLabel12;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JLabel jLabel5;
private JLabel jLabel6;
private JLabel jLabel7;
private JLabel jLabel8;
private JLabel jLabel9;
private JPanel jPanel1;
private JPanel jPanel2;
private JPanel jPanel3;
private JPanel jPanel4;
private JPanel jPanel5;
private JPanel jPanel6;
private JComboBox modeCombo;
private JComboBox paddingCombo;
private JProgressBar progressBar;
private JProgressBar progressBar1;
private JComboBox providerCombo;
private JPanel symmetricPan;
private JRadioButton symmetricRadio;
private JTabbedPane tabbedPan;
private ButtonGroup typeEncryptGroup;
// End of variables declaration
public View() {
initComponents();
}
public void setModel(EncryptAndDecryptInterface model) {
this.model = model;
}
private void initComponents() {
try {
setLocationRelativeTo(null);
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setTitle("Encrypt_Decrypt");
fileChooser = new JFileChooser();
typeEncryptGroup = new ButtonGroup();
tabbedPan = new JTabbedPane();
asymmetric = new JPanel();
symmetricPan = new JPanel();
chooseFilePane = new JPanel();
jLabel1 = new JLabel();
jLabel2 = new JLabel();
fileSourceEncryptTextField = new JTextField();
browseFileSourseEncryptButton = new JButton(new ImageIcon("images/open.gif"));
desFileEncryptTextBox = new JTextField();
browseFileDesEncryptButton = new JButton(new ImageIcon("images/open.gif"));
jPanel2 = new JPanel();
jPanel1 = new JPanel();
symmetricRadio = new JRadioButton();
asymmetricRadio = new JRadioButton();
jPanel3 = new JPanel();
jLabel4 = new JLabel();
modeCombo = new JComboBox();
jLabel5 = new JLabel();
paddingCombo = new JComboBox();
jPanel4 = new JPanel();
jLabel3 = new JLabel();
algorithmCombo = new JComboBox();
jLabel6 = new JLabel();
providerCombo = new JComboBox();
encryptButton = new JButton(new ImageIcon("images/encrypt.gif"));
progressBar = new JProgressBar();
progressBar.setMaximum(100);
jPanel5 = new JPanel();
chooseFilePane1 = new JPanel();
jLabel7 = new JLabel();
jLabel8 = new JLabel();
fileSourceDecryptTextField = new JTextField();
browseFileSourseDecryptButton = new JButton(new ImageIcon("images/open.gif"));
desFileDecryptTextBox = new JTextField();
browseFileDesDecryptButton = new JButton(new ImageIcon("images/open.gif"));
jPanel6 = new JPanel();
jLabel9 = new JLabel();
jLabel10 = new JLabel();
jLabel11 = new JLabel();
jLabel12 = new JLabel();
infoProvider = new JLabel();
infoAlgorithm = new JLabel();
infoMode = new JLabel();
infoPadding = new JLabel();
infoAlgorithm.setForeground(Color.BLUE);
infoProvider.setForeground(Color.BLUE);
infoMode.setForeground(Color.BLUE);
infoPadding.setForeground(Color.BLUE);
decryptButton = new JButton(new ImageIcon("images/decrypt.gif"));
progressBar1 = new JProgressBar();
progressBar1.setMaximum(100);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
tabbedPan.setName("asymmetric");
symmetricPan.setName("sysmetric");
chooseFilePane.setBorder(BorderFactory
.createTitledBorder("Choose File"));
jLabel1.setText("File Sourse:");
jLabel2.setText("File Des:");
fileSourceEncryptTextField.setText("");
fileSourceEncryptTextField
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fileSourceEncryptTextFieldActionPerformed(evt);
}
});
browseFileSourseEncryptButton.setText("Browse");
browseFileSourseEncryptButton
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
browseFileSourseEncryptButtonActionPerformed(evt);
}
});
desFileEncryptTextBox.setText("");
desFileEncryptTextBox
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
desFileEncryptTextBoxActionPerformed(evt);
}
});
browseFileDesEncryptButton.setText("Browse");
browseFileDesEncryptButton
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
browseFileDesEncryptButtonActionPerformed(evt);
}
});
GroupLayout chooseFilePaneLayout = new GroupLayout(chooseFilePane);
chooseFilePane.setLayout(chooseFilePaneLayout);
chooseFilePaneLayout
.setHorizontalGroup(chooseFilePaneLayout
.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(
chooseFilePaneLayout
.createSequentialGroup()
.addContainerGap()
.addGroup(
chooseFilePaneLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addGroup(
chooseFilePaneLayout
.createSequentialGroup()
.addComponent(
jLabel1)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
fileSourceEncryptTextField,
GroupLayout.DEFAULT_SIZE,
323,
Short.MAX_VA