File Source: ActionsPanel.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.dialogs.sslcertificate.ActionsPanel__static_init
          */
     1  /*
     2   * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
     3   * 
     4   * Permission is hereby granted, free of charge, to any person obtaining a copy
     5   * of this software and associated documentation files (the "Software"), to deal
     6   * in the Software without restriction, including without limitation the rights
     7   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     8   * copies of the Software, and to permit persons to whom the Software is
     9   * furnished to do so, subject to the following conditions:
    10   * 
    11   * The above copyright notice and this permission notice shall be included in
    12   * all copies or substantial portions of the Software.
    13   * 
    14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    20   * SOFTWARE.
    21   */
    22  
    23  package com.dmdirc.addons.ui_swing.dialogs.sslcertificate;
    24  
    25  import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction;
    26  import javax.swing.BorderFactory;
    27  import javax.swing.ButtonGroup;
    28  import javax.swing.JPanel;
    29  import javax.swing.JRadioButton;
    30  import net.miginfocom.swing.MigLayout;
    31  
    32  /**
    33   * SSL certificate actions.
    34   */
    35  public class ActionsPanel extends JPanel {
    36  
    37      /**
    38       * A version number for this class. It should be changed whenever the class
    39       * structure is changed (or anything else that would prevent serialized
    40       * objects being unserialized with the new class).
    41       */
    42      private static final long serialVersionUID = 1;
    43      /** Radio button for temporarily accept. */
    44      private JRadioButton tempAccept;
    45      /** Radio button for permanently accept. */
    46      private JRadioButton permAccept;
    47      /** Radio button for do not connect. */
    48      private JRadioButton disconnect;
    49      /** Radio button group. */
    50      private ButtonGroup group;
    51  
             /* 
    P/P       *  Method: void com.dmdirc.addons.ui_swing.dialogs.sslcertificate.ActionsPanel()
              * 
              *  Postconditions:
              *    this.disconnect == &new JRadioButton(initComponents#3)
              *    this.group == &new ButtonGroup(initComponents#4)
              *    this.permAccept == &new JRadioButton(initComponents#2)
              *    this.tempAccept == &new JRadioButton(initComponents#1)
              *    new ButtonGroup(initComponents#4) num objects == 1
              *    new JRadioButton(initComponents#1) num objects == 1
              *    new JRadioButton(initComponents#2) num objects == 1
              *    new JRadioButton(initComponents#3) num objects == 1
              */
    52      public ActionsPanel() {
    53          initComponents();
    54          layoutComponents();
    55      }
    56  
    57      private void initComponents() {
                 /* 
    P/P           *  Method: void initComponents()
                  * 
                  *  Postconditions:
                  *    this.disconnect == &new JRadioButton(initComponents#3)
                  *    this.group == &new ButtonGroup(initComponents#4)
                  *    this.permAccept == &new JRadioButton(initComponents#2)
                  *    this.tempAccept == &new JRadioButton(initComponents#1)
                  *    new ButtonGroup(initComponents#4) num objects == 1
                  *    new JRadioButton(initComponents#1) num objects == 1
                  *    new JRadioButton(initComponents#2) num objects == 1
                  *    new JRadioButton(initComponents#3) num objects == 1
                  */
    58          tempAccept = new JRadioButton("Temporarily accept the problems with " +
    59                  "this certificate and connect.");
    60          permAccept = new JRadioButton("Permanently accept the problems with " +
    61                  "this certificate and connect.");
    62          disconnect = new JRadioButton("Do not connect.");
    63          group = new ButtonGroup();
    64          group.add(tempAccept);
    65          group.add(permAccept);
    66          group.add(disconnect);
    67          group.setSelected(tempAccept.getModel(), true);
    68      }
    69  
    70      private void layoutComponents() {
                 /* 
    P/P           *  Method: void layoutComponents()
                  * 
                  *  Preconditions:
                  *    init'ed(this.disconnect)
                  *    init'ed(this.permAccept)
                  *    init'ed(this.tempAccept)
                  */
    71          setBorder(BorderFactory.createTitledBorder("Actions"));
    72          setLayout(new MigLayout("fill, wrap 1"));
    73  
    74          add(tempAccept, "growx, pushx");
    75          add(permAccept, "growx, pushx");
    76          add(disconnect, "growx, pushx");
    77      }
    78  
    79      public CertificateAction getAction() {
                 /* 
    P/P           *  Method: CertificateAction getAction()
                  * 
                  *  Preconditions:
                  *    this.group != null
                  *    this.tempAccept != null
                  *    (soft) this.permAccept != null
                  * 
                  *  Presumptions:
                  *    init'ed(com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction.DISCONNECT)
                  *    init'ed(com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction.IGNORE_PERMANENTY)
                  *    init'ed(com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction.IGNORE_TEMPORARILY)
                  *    javax.swing.ButtonGroup:getSelection(...)@80 != null
                  *    javax.swing.ButtonGroup:getSelection(...)@82 != null
                  * 
                  *  Postconditions:
                  *    return_value == One-of{com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction.IGNORE_TEMPORARILY, com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction.IGNORE_PERMANENTY, com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction.DISCONNECT}
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    java.lang.Object:equals(...)@80: {0}, {1}
                  *    java.lang.Object:equals(...)@82: {0}, {1}
                  */
    80          if (group.getSelection().equals(tempAccept.getModel())) {
    81              return CertificateAction.IGNORE_TEMPORARILY;
    82          } else if (group.getSelection().equals(permAccept.getModel())) {
    83              return CertificateAction.IGNORE_PERMANENTY;
    84          } else {
    85              return CertificateAction.DISCONNECT;
    86          }
    87      }
    88  }








SofCheck Inspector Build Version : 2.17854
ActionsPanel.java 2009-Jun-25 01:54:24
ActionsPanel.class 2009-Sep-02 17:04:16