File Source: ActionGroupInformationPanel.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.dialogs.actionsmanager.ActionGroupInformationPanel__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  package com.dmdirc.addons.ui_swing.dialogs.actionsmanager;
    23  
    24  import com.dmdirc.actions.ActionGroup;
    25  
    26  import com.dmdirc.addons.ui_swing.components.text.OldTextLabel;
    27  import javax.swing.JLabel;
    28  import javax.swing.JPanel;
    29  
    30  import net.miginfocom.swing.MigLayout;
    31  
    32  /**
    33   * Action group information panel.
    34   */
    35  public final class ActionGroupInformationPanel 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      /** Action group. */
    44      private ActionGroup group;
    45      /** Description field. */
    46      private OldTextLabel infoLabel;
    47      /** Version label label. */
    48      private JLabel versionLabel;
    49      /** Version label. */
    50      private JLabel version;
    51      /** Author label label. */
    52      private JLabel authorLabel;
    53      /** Author label. */
    54      private JLabel author;
    55  
    56      /**
    57       * Initialises a new action group information panel.
    58       * 
    59       * @param group Action group
    60       */
    61      public ActionGroupInformationPanel(final ActionGroup group) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.dialogs.actionsmanager.ActionGroupInformationPanel(ActionGroup)
                  * 
                  *  Postconditions:
                  *    this.author == &new JLabel(initComponents#5)
                  *    this.authorLabel == &new JLabel(initComponents#4)
                  *    this.group == group
                  *    init'ed(this.group)
                  *    this.infoLabel == &new OldTextLabel(initComponents#1)
                  *    this.version == &new JLabel(initComponents#3)
                  *    this.versionLabel == &new JLabel(initComponents#2)
                  *    new JLabel(initComponents#2) num objects == 1
                  *    new JLabel(initComponents#3) num objects == 1
                  *    new JLabel(initComponents#4) num objects == 1
                  *    ...
                  */
    62          super();
    63  
    64          this.group = group;
    65  
    66          initComponents();
    67          addListeners();
    68          layoutComponents();
    69      }
    70  
    71      /**
    72       * Initialises the components.
    73       */
    74      private void initComponents() {
                 /* 
    P/P           *  Method: void initComponents()
                  * 
                  *  Preconditions:
                  *    init'ed(this.group)
                  * 
                  *  Postconditions:
                  *    this.author == &new JLabel(initComponents#5)
                  *    this.authorLabel == &new JLabel(initComponents#4)
                  *    this.group == old this.group
                  *    init'ed(this.group)
                  *    this.infoLabel == &new OldTextLabel(initComponents#1)
                  *    this.version == &new JLabel(initComponents#3)
                  *    this.versionLabel == &new JLabel(initComponents#2)
                  *    new JLabel(initComponents#2) num objects == 1
                  *    new JLabel(initComponents#3) num objects == 1
                  *    new JLabel(initComponents#4) num objects == 1
                  *    ...
                  */
    75          infoLabel = new OldTextLabel();
    76          versionLabel = new JLabel("Version: ");
    77          version = new JLabel();
    78          authorLabel = new JLabel("Author: ");
    79          author = new JLabel();
    80  
    81          setActionGroup(group);
    82      }
    83  
    84      /**
    85       * Adds listeners.
    86       */
    87      private void addListeners() {
    88          //Empty
             /* 
    P/P       *  Method: void addListeners()
              */
    89      }
    90  
    91      /**
    92       * Lays out the components.
    93       */
    94      private void layoutComponents() {
                 /* 
    P/P           *  Method: void layoutComponents()
                  * 
                  *  Preconditions:
                  *    init'ed(this.author)
                  *    init'ed(this.authorLabel)
                  *    init'ed(this.infoLabel)
                  *    init'ed(this.version)
                  *    init'ed(this.versionLabel)
                  */
    95          setLayout(new MigLayout("fill, wrap 2, hidemode 3"));
    96  
    97          add(infoLabel, "span 2, growx, pushx");
    98          add(authorLabel, "");
    99          add(author, "growx, pushx");
   100          add(versionLabel, "");
   101          add(version, "growx, pushx");
   102      }
   103  
   104      /**
   105       * Sets the action group for the panel.
   106       * 
   107       * @param group New action group
   108       */
   109      public void setActionGroup(final ActionGroup group) {
                 /* 
    P/P           *  Method: void setActionGroup(ActionGroup)
                  * 
                  *  Preconditions:
                  *    this.author != null
                  *    this.infoLabel != null
                  *    this.version != null
                  *    (soft) this.authorLabel != null
                  *    (soft) init'ed(this.infoLabel.sas)
                  *    (soft) this.versionLabel != null
                  * 
                  *  Postconditions:
                  *    this.group == group
                  *    init'ed(this.group)
                  * 
                  *  Test Vectors:
                  *    group: Addr_Set{null}, Inverse{null}
                  *    com.dmdirc.actions.ActionGroup:getDescription(...)@112: Inverse{null}, Addr_Set{null}
                  */
   110          this.group = group;
   111  
   112          if (group == null || group.getDescription() == null) {
   113              infoLabel.setText("");
   114              author.setText("");
   115              version.setText("");
   116          } else {
   117              infoLabel.setText(group.getDescription());
   118              author.setText(group.getAuthor());
   119              version.setText(Integer.toString(group.getVersion()));
   120  
   121              author.setVisible(group.getAuthor() != null);
   122              version.setVisible(group.getVersion() != -1);
   123              authorLabel.setVisible(group.getAuthor() != null);
   124              versionLabel.setVisible(group.getVersion() != -1);
   125          }
   126      }
   127  
   128      /**
   129       * Should the info panel be shown?
   130       * 
   131       * @return true iif the panel should be shown
   132       */
   133      public boolean shouldDisplay() {
                 /* 
    P/P           *  Method: bool shouldDisplay()
                  * 
                  *  Preconditions:
                  *    init'ed(this.group)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   134          return group != null && group.getDescription() != null;
   135      }
   136  }








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