/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * CertificateWarningDialog.java * * Created on Nov 4, 2008, 11:45:10 AM */ package owsproxyclient; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; /** * * @author jeichar */ public class CertificateWarningDialog extends javax.swing.JDialog { private static final ResourceBundle translations = ResourceBundle.getBundle("owsproxyclient/translations"); private ExamineCertPanel examinePanel = new ExamineCertPanel(this); /** Creates new form CertificateWarningDialog */ public CertificateWarningDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); } /** Creates new form CertificateWarningDialog */ public CertificateWarningDialog(String serverName, String errorMessage, String certificateDetails, java.awt.Frame parent, boolean modal) { this(parent, modal); String msg = MessageFormat.format(generalMsgText.getText(), serverName); generalMsgText.setText(msg); examinePanel.setErrorMessage(errorMessage); examinePanel.setCertificateDetails(certificateDetails); } public ExamineCertPanel.AddCert addCertificateSelected(){ return examinePanel.addCertificateSelected(); } public void disablePermanentOption(){ examinePanel.addPermButton.setEnabled(false); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { cancel = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); generalMsgText = new javax.swing.JTextArea(); examineCertButton = new javax.swing.JToggleButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); cancel.setText(translations.getString("doNotAcceptButton")); // NOI18N cancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Arial", 1, 18)); jLabel1.setText(translations.getString("failedMsg")); // NOI18N jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/owsproxyclient/important.png"))); // NOI18N jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); generalMsgText.setColumns(20); generalMsgText.setEditable(false); generalMsgText.setRows(5); generalMsgText.setText(translations.getString("generalErrorMsg")); // NOI18N generalMsgText.setWrapStyleWord(true); generalMsgText.setAutoscrolls(false); jScrollPane1.setViewportView(generalMsgText); examineCertButton.setText(translations.getString("examineCertificateButton")); // NOI18N examineCertButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { examineCertButtonActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jLabel2) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 271, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(layout.createSequentialGroup() .add(0, 0, 0) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(examineCertButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 149, Short.MAX_VALUE) .add(cancel))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel2) .add(layout.createSequentialGroup() .add(20, 20, 20) .add(jLabel1))) .add(6, 6, 6) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 175, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(cancel) .add(examineCertButton)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void examineCertButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_examineCertButtonActionPerformed if(examineCertButton.isSelected()){ addExaminePanel(); }else{ getContentPane().remove(examinePanel); pack(); } }//GEN-LAST:event_examineCertButtonActionPerformed private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed dispose(); }//GEN-LAST:event_cancelActionPerformed private void addExaminePanel(){ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() .add(jLabel2) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jLabel1)) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() .add(0, 0, 0) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .add(examinePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .add(layout.createSequentialGroup() .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(examineCertButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 115, Short.MAX_VALUE) .add(cancel))) )) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel2) .add(layout.createSequentialGroup() .add(20, 20, 20) .add(jLabel1))) .add(6, 6, 6) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 175, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(cancel) .add(examineCertButton)) .add(6, 6, 6) .add(examinePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); pack(); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { CertificateWarningDialog dialog = new CertificateWarningDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancel; private javax.swing.JToggleButton examineCertButton; private javax.swing.JTextArea generalMsgText; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables }