File Source: ActionSubstitutionsPanel.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.dialogs.actioneditor.ActionSubstitutionsPanel__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.actioneditor;
    24  
    25  import com.dmdirc.actions.ActionSubstitutor;
    26  import com.dmdirc.actions.interfaces.ActionType;
    27  import com.dmdirc.addons.ui_swing.components.substitutions.Substitution;
    28  import com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionLabel;
    29  import com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionsPanel;
    30  
    31  import java.util.ArrayList;
    32  import java.util.Map.Entry;
    33  
    34  import javax.swing.SwingUtilities;
    35  
    36  /**
    37   * Action substitutions panel
    38   */
         /* 
    P/P   *  Method: void access$500(ActionSubstitutionsPanel)
          * 
          *  Preconditions:
          *    x0 != null
          *    x0.alignment != null
          *    init'ed(x0.description)
          *    x0.substitutions != null
          */
    39  public class ActionSubstitutionsPanel extends SubstitutionsPanel<ActionType> {
    40  
    41      /**
    42       * A version number for this class. It should be changed whenever the class
    43       * structure is changed (or anything else that would prevent serialized
    44       * objects being unserialized with the new class).
    45       */
    46      private static final long serialVersionUID = 1;
    47  
    48      /** Instantiates the panel. */
    49      public ActionSubstitutionsPanel() {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.dialogs.actioneditor.ActionSubstitutionsPanel()
                  * 
                  *  Postconditions:
                  *    this.alignment == &amp;com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionsPanel$Alignment__static_init.new SubstitutionsPanel$Alignment(SubstitutionsPanel$Alignment__static_init#2)
                  *    this.description == &amp;"Substitutions may be used in the response and target fields"
                  */
    50          super("Substitutions may be used in the response and target fields", SubstitutionsPanel.Alignment.VERTICAL, null);
    51      }
    52      
    53      /**
    54       * Instantiates the panel.
    55       * 
    56       * @param type Action type
    57       */
    58      public ActionSubstitutionsPanel(final ActionType type) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.dialogs.actioneditor.ActionSubstitutionsPanel(ActionType)
                  * 
                  *  Postconditions:
                  *    this.alignment == &amp;com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionsPanel$Alignment__static_init.new SubstitutionsPanel$Alignment(SubstitutionsPanel$Alignment__static_init#2)
                  *    this.description == &amp;"Substitutions may be used in the response and target fields"
                  */
    59          super("Substitutions may be used in the response and target fields", type);
    60      }
    61  
    62      /**
    63       * Sets the action type for this substitution panel.
    64       * 
    65       * @param type New action type
    66       */
    67      @Override
    68      public void setType(final ActionType type) {
                 /* 
    P/P           *  Method: void setType(ActionType)
                  */
    69          SwingUtilities.invokeLater(new Runnable() {
    70  
    71              /** {@inheritDoc} */
    72              @Override
    73              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.alignment != null
                          *    init'ed(this.description)
                          * 
                          *  Presumptions:
                          *    com.dmdirc.actions.ActionSubstitutor:getComponentSubstitutions(...)@79 != null
                          *    com.dmdirc.actions.ActionSubstitutor:getConfigSubstitutions(...)@85 != null
                          *    com.dmdirc.actions.ActionSubstitutor:getServerSubstitutions(...)@90 != null
                          *    java.util.Iterator:next(...)@79 != null
                          *    java.util.Iterator:next(...)@90 != null
                          *    ...
                          * 
                          *  Postconditions:
                          *    new ArrayList(run#1) num objects == 1
                          * 
                          *  Test Vectors:
                          *    this.val$type: Addr_Set{null}, Inverse{null}
                          *    java.util.Iterator:hasNext(...)@79: {0}, {1}
                          *    java.util.Iterator:hasNext(...)@85: {0}, {1}
                          *    java.util.Iterator:hasNext(...)@90: {0}, {1}
                          */
    74                  substitutions = new ArrayList<SubstitutionLabel>();
    75  
    76                  if (type != null) {
    77                      final ActionSubstitutor sub = new ActionSubstitutor(type);
    78  
    79                      for (final Entry<String, String> entry : sub.getComponentSubstitutions().
    80                              entrySet()) {
    81                          substitutions.add(new SubstitutionLabel(new Substitution(entry.getValue(),
    82                                  entry.getKey())));
    83                      }
    84  
    85                      for (final String entry : sub.getConfigSubstitutions()) {
    86                          substitutions.add(new SubstitutionLabel(new Substitution(entry,
    87                                  entry)));
    88                      }
    89  
    90                      for (final Entry<String, String> entry : sub.getServerSubstitutions().
    91                              entrySet()) {
    92                          substitutions.add(new SubstitutionLabel(new Substitution(entry.getValue(),
    93                                  entry.getKey())));
    94                      }
    95                  }
    96  
    97                  layoutComponents();
    98                  validate();
    99                  layoutComponents();
   100              }
   101          });
   102      }
   103  }








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