File Source: SwingInputField.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.components.SwingInputField__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.components;
    24  
    25  import com.dmdirc.ui.IconManager;
    26  import com.dmdirc.config.IdentityManager;
    27  import com.dmdirc.ui.interfaces.InputField;
    28  import com.dmdirc.ui.interfaces.InputValidationListener;
    29  import com.dmdirc.addons.ui_swing.UIUtilities;
    30  import com.dmdirc.util.ListenerList;
    31  
    32  import com.dmdirc.util.ReturnableThread;
    33  import java.awt.Color;
    34  import java.awt.event.ActionEvent;
    35  import java.awt.event.ActionListener;
    36  import java.awt.event.KeyEvent;
    37  import java.awt.event.KeyListener;
    38  
    39  import javax.swing.JComponent;
    40  import javax.swing.JLabel;
    41  import javax.swing.JTextField;
    42  import javax.swing.text.BadLocationException;
    43  
    44  import net.miginfocom.swing.MigLayout;
    45  
    46  /** Swing input field. */
         /* 
    P/P   *  Method: JLabel access$400(SwingInputField)
          * 
          *  Preconditions:
          *    x0 != null
          * 
          *  Postconditions:
          *    return_value == x0.wrapIndicator
          *    init'ed(return_value)
          */
    47  public class SwingInputField extends JComponent implements InputField,
    48          KeyListener, InputValidationListener {
    49  
    50      /**
    51       * A version number for this class. It should be changed whenever the class
    52       * structure is changed (or anything else that would prevent serialized
    53       * objects being unserialized with the new class).
    54       */
    55      private static final long serialVersionUID = 1;
    56      /** Colour picker. */
    57      private ColourPickerDialog colourPicker;
    58      /** Input field text field. */
    59      private final JTextField textField;
    60      /** Line wrap indicator. */
    61      private final JLabel wrapIndicator;
    62      /** Error indicator. */
    63      private final JLabel errorIndicator;
    64      /** Listener list. */
    65      private final ListenerList listeners;
    66  
    67      /**
    68       * Instantiates a new swing input field.
    69       */
    70      public SwingInputField() {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.SwingInputField()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.ui.IconManager:getIconManager(...)@78 != null
                  *    com.dmdirc.ui.IconManager:getIconManager(...)@81 != null
                  * 
                  *  Postconditions:
                  *    this.errorIndicator == &new JLabel(SwingInputField#4)
                  *    this.listeners == &new ListenerList(SwingInputField#1)
                  *    this.textField == &new JTextField(SwingInputField#2)
                  *    this.wrapIndicator == &new JLabel(SwingInputField#3)
                  *    new JLabel(SwingInputField#3) num objects == 1
                  *    new JLabel(SwingInputField#4) num objects == 1
                  *    new JTextField(SwingInputField#2) num objects == 1
                  *    new ListenerList(SwingInputField#1) num objects == 1
                  */
    71          super();
    72  
    73          listeners = new ListenerList();
    74  
    75          textField = new JTextField();
    76          textField.setFocusTraversalKeysEnabled(false);
    77          textField.addKeyListener(this);
    78          wrapIndicator =
    79                  new JLabel(IconManager.getIconManager().getIcon("linewrap"));
    80          wrapIndicator.setVisible(false);
    81          errorIndicator =
    82                  new JLabel(IconManager.getIconManager().getIcon("input-error"));
    83          errorIndicator.setVisible(false);
    84  
    85          setLayout(new MigLayout("ins 0, hidemode 3"));
    86  
    87          add(textField, "growx, pushx");
    88          add(wrapIndicator, "");
    89          add(errorIndicator, "");
    90  
    91          setActionMap(textField.getActionMap());
    92          setInputMap(SwingInputField.WHEN_FOCUSED,
    93                  textField.getInputMap(SwingInputField.WHEN_FOCUSED));
    94          setInputMap(SwingInputField.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
    95                  textField.getInputMap(SwingInputField.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
    96          setInputMap(SwingInputField.WHEN_IN_FOCUSED_WINDOW,
    97                  textField.getInputMap(SwingInputField.WHEN_IN_FOCUSED_WINDOW));
    98      }
    99  
   100      /** {@inheritDoc} */
   101      @Override
   102      public void requestFocus() {
                 /* 
    P/P           *  Method: void requestFocus()
                  */
   103          UIUtilities.invokeLater(new Runnable() {
   104  
   105              /** {@inheritDoc} */
   106              @Override
   107              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   108                  textField.requestFocus();
   109              }
   110          });
   111      }
   112      
   113      /** {@inheritDoc} */
   114      @Override
   115      public boolean requestFocusInWindow() {
                 /* 
    P/P           *  Method: bool requestFocusInWindow()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ReturnableThread:getObject(...)@203 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   116          return UIUtilities.invokeAndWait(new ReturnableThread<Boolean>() {
   117  
   118              /** {@inheritDoc} */
   119              @Override
   120              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   121                  setObject(textField.requestFocusInWindow());
   122              }
   123          });
   124      }
   125  
   126      /** {@inheritDoc} */
   127      @Override
   128      public void showColourPicker(final boolean irc, final boolean hex) {
                 /* 
    P/P           *  Method: void showColourPicker(bool, bool)
                  */
   129          UIUtilities.invokeLater(new Runnable() {
   130  
   131              /** {@inheritDoc} */
   132              @Override
   133              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    (soft) this.textField != null
                          * 
                          *  Presumptions:
                          *    (int) (java.awt.Point:getX(...)@152) in {-231..232-1}
                          *    (int) (java.awt.Point:getY(...)@152) in {-232..8_589_934_590}
                          *    com.dmdirc.addons.ui_swing.components.ColourPickerDialog:getHeight(...)@152 - (int) (java.awt.Point:getY(...)@152) in {-232+1..231}
                          *    com.dmdirc.config.IdentityManager:getGlobalConfig(...)@134 != null
                          *    javax.swing.JTextField:getLocationOnScreen(...)@152 != null
                          * 
                          *  Postconditions:
                          *    this.colourPicker == One-of{old this.colourPicker, &amp;new ColourPickerDialog(run#1)}
                          *    new ArrayList(ColourPickerPanel#1) num objects <= 1
                          *    new ColourPickerDialog(run#1) num objects <= 1
                          *    new ColourPickerDialog(run#1).colourChooser == &amp;new ColourPickerPanel(ColourPickerDialog#1)
                          *    init'ed(new ColourPickerDialog(run#1).window)
                          *    new ColourPickerPanel(ColourPickerDialog#1) num objects <= 1
                          *    new ColourPickerPanel(ColourPickerDialog#1).listeners == &amp;new ArrayList(ColourPickerPanel#1)
                          *    new ColourPickerPanel(ColourPickerDialog#1).saturation == 1
                          *    init'ed(new ColourPickerPanel(ColourPickerDialog#1).showHex)
                          *    init'ed(new ColourPickerPanel(ColourPickerDialog#1).showIrc)
                          * 
                          *  Test Vectors:
                          *    com.dmdirc.config.ConfigManager:getOptionBool(...)@134: {0}, {1}
                          */
   134                  if (IdentityManager.getGlobalConfig().getOptionBool("general",
   135                          "showcolourdialog")) {
   136                      colourPicker = new ColourPickerDialog(irc, hex);
                             /* 
    P/P                       *  Method: void com.dmdirc.addons.ui_swing.components.SwingInputField$3$1(SwingInputField$3)
                              */
   137                      colourPicker.addActionListener(new ActionListener() {
   138  
   139                          @Override
   140                          public void actionPerformed(final ActionEvent actionEvent) {
   141                              try {
                                         /* 
    P/P                                   *  Method: void actionPerformed(ActionEvent)
                                          * 
                                          *  Preconditions:
                                          *    this.colourPicker != null
                                          *    (soft) actionEvent != null
                                          *    (soft) this.textField != null
                                          * 
                                          *  Presumptions:
                                          *    javax.swing.JTextField:getDocument(...)@142 != null
                                          */
   142                                  textField.getDocument().
   143                                          insertString(textField.getCaretPosition(),
   144                                          actionEvent.getActionCommand(), null);
   145                              } catch (BadLocationException ex) {
   146                              //Ignore, wont happen
   147                              }
   148                              colourPicker.dispose();
   149                              colourPicker = null;
   150                          }
   151                      });
   152                      colourPicker.setLocation((int) textField.getLocationOnScreen().
   153                              getX(),
   154                              (int) textField.getLocationOnScreen().getY() -
   155                              colourPicker.getHeight());
   156                      colourPicker.setVisible(true);
   157                  }
   158              }
   159          });
   160      }
   161  
   162      /** {@inheritDoc} */
   163      @Override
   164      public void hideColourPicker() {
                 /* 
    P/P           *  Method: void hideColourPicker()
                  */
   165          UIUtilities.invokeLater(new Runnable() {
   166  
   167              /** {@inheritDoc} */
   168              @Override
   169              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    init'ed(this.colourPicker)
                          * 
                          *  Test Vectors:
                          *    this.colourPicker: Addr_Set{null}, Inverse{null}
                          */
   170                  if (colourPicker != null) {
   171                      colourPicker.dispose();
   172                      colourPicker = null;
   173                  }
   174              }
   175          });
   176      }
   177  
   178      /**
   179       * Returns the textfield for this inputfield.
   180       * 
   181       * @return JTextField
   182       */
   183      public JTextField getTextField() {
                 /* 
    P/P           *  Method: JTextField getTextField()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   184          return UIUtilities.invokeAndWait(new ReturnableThread<JTextField>() {
   185  
   186              /** {@inheritDoc} */
   187              @Override
   188              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          */
   189                  setObject(textField);
   190              }
   191          });
   192      }
   193  
   194      /** {@inheritDoc} */
   195      @Override
   196      public void addActionListener(final ActionListener listener) {
                 /* 
    P/P           *  Method: void addActionListener(ActionListener)
                  */
   197          UIUtilities.invokeLater(new Runnable() {
   198  
   199              /** {@inheritDoc} */
   200              @Override
   201              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   202                  textField.addActionListener(listener);
   203              }
   204          });
   205      }
   206  
   207      /** {@inheritDoc} */
   208      @Override
   209      public void addKeyListener(final KeyListener listener) {
                 /* 
    P/P           *  Method: void addKeyListener(KeyListener)
                  */
   210          UIUtilities.invokeLater(new Runnable() {
   211  
   212              /** {@inheritDoc} */
   213              @Override
   214              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.listeners != null
                          */
   215                  listeners.add(KeyListener.class, listener);
   216              }
   217          });
   218      }
   219  
   220      /** {@inheritDoc} */
   221      @Override
   222      public void removeActionListener(final ActionListener listener) {
                 /* 
    P/P           *  Method: void removeActionListener(ActionListener)
                  */
   223          UIUtilities.invokeLater(new Runnable() {
   224  
   225              /** {@inheritDoc} */
   226              @Override
   227              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   228                  textField.removeActionListener(listener);
   229              }
   230          });
   231      }
   232  
   233      /** {@inheritDoc} */
   234      @Override
   235      public void removeKeyListener(final KeyListener listener) {
                 /* 
    P/P           *  Method: void removeKeyListener(KeyListener)
                  */
   236          UIUtilities.invokeLater(new Runnable() {
   237  
   238              /** {@inheritDoc} */
   239              @Override
   240              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.listeners != null
                          */
   241                  listeners.remove(KeyListener.class, listener);
   242              }
   243          });
   244      }
   245  
   246      /** {@inheritDoc} */
   247      @Override
   248      public String getSelectedText() {
                 /* 
    P/P           *  Method: String getSelectedText()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   249          return UIUtilities.invokeAndWait(new ReturnableThread<String>() {
   250  
   251              /** {@inheritDoc} */
   252              @Override
   253              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   254                  setObject(textField.getSelectedText());
   255              }
   256          });
   257      }
   258  
   259      /** {@inheritDoc} */
   260      @Override
   261      public int getSelectionEnd() {
                 /* 
    P/P           *  Method: int getSelectionEnd()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ReturnableThread:getObject(...)@203 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   262          return UIUtilities.invokeAndWait(new ReturnableThread<Integer>() {
   263  
   264              /** {@inheritDoc} */
   265              @Override
   266              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   267                  setObject(textField.getSelectionEnd());
   268              }
   269          });
   270      }
   271  
   272      /** {@inheritDoc} */
   273      @Override
   274      public int getSelectionStart() {
                 /* 
    P/P           *  Method: int getSelectionStart()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ReturnableThread:getObject(...)@203 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   275          return UIUtilities.invokeAndWait(new ReturnableThread<Integer>() {
   276  
   277              /** {@inheritDoc} */
   278              @Override
   279              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   280                  setObject(textField.getSelectionStart());
   281              }
   282          });
   283      }
   284  
   285      /** {@inheritDoc} */
   286      @Override
   287      public String getText() {
                 /* 
    P/P           *  Method: String getText()
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   288          return UIUtilities.invokeAndWait(new ReturnableThread<String>() {
   289  
   290              /** {@inheritDoc} */
   291              @Override
   292              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   293                  setObject(textField.getText());
   294              }
   295          });
   296      }
   297  
   298      /** {@inheritDoc} */
   299      @Override
   300      public void setText(final String text) {
                 /* 
    P/P           *  Method: void setText(String)
                  */
   301          UIUtilities.invokeLater(new Runnable() {
   302  
   303              /** {@inheritDoc} */
   304              @Override
   305              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   306                  textField.setText(text);
   307              }
   308          });
   309      }
   310  
   311      /** {@inheritDoc} */
   312      @Override
   313      public int getCaretPosition() {
                 /* 
    P/P           *  Method: int getCaretPosition()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ReturnableThread:getObject(...)@203 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   314          return UIUtilities.invokeAndWait(new ReturnableThread<Integer>() {
   315  
   316              /** {@inheritDoc} */
   317              @Override
   318              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   319                  setObject(textField.getCaretPosition());
   320              }
   321          });
   322      }
   323  
   324      /** {@inheritDoc} */
   325      @Override
   326      public void setCaretPosition(final int position) {
                 /* 
    P/P           *  Method: void setCaretPosition(int)
                  */
   327          UIUtilities.invokeLater(new Runnable() {
   328  
   329              /** {@inheritDoc} */
   330              @Override
   331              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   332                  textField.setCaretPosition(position);
   333              }
   334          });
   335      }
   336  
   337      /**
   338       * Replaces the selection with the specified text.
   339       * 
   340       * @param clipboard Text to replace selection with
   341       */
   342      public void replaceSelection(final String clipboard) {
                 /* 
    P/P           *  Method: void replaceSelection(String)
                  */
   343          UIUtilities.invokeLater(new Runnable() {
   344  
   345              /** {@inheritDoc} */
   346              @Override
   347              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   348                  textField.replaceSelection(clipboard);
   349              }
   350          });
   351      }
   352  
   353      /**
   354       * Sets the caret colour to the specified coloour.
   355       * 
   356       * @param optionColour Colour for the caret
   357       */
   358      public void setCaretColor(final Color optionColour) {
                 /* 
    P/P           *  Method: void setCaretColor(Color)
                  */
   359          UIUtilities.invokeLater(new Runnable() {
   360  
   361              /** {@inheritDoc} */
   362              @Override
   363              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   364                  textField.setCaretColor(optionColour);
   365              }
   366          });
   367      }
   368  
   369      /**
   370       * Sets the foreground colour to the specified coloour.
   371       * 
   372       * @param optionColour Colour for the caret
   373       */
   374      @Override
   375      public void setForeground(final Color optionColour) {
                 /* 
    P/P           *  Method: void setForeground(Color)
                  */
   376          UIUtilities.invokeLater(new Runnable() {
   377  
   378              /** {@inheritDoc} */
   379              @Override
   380              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   381                  textField.setForeground(optionColour);
   382              }
   383          });
   384      }
   385  
   386      /**
   387       * Sets the background colour to the specified coloour.
   388       * 
   389       * @param optionColour Colour for the caret
   390       */
   391      @Override
   392      public void setBackground(final Color optionColour) {
                 /* 
    P/P           *  Method: void setBackground(Color)
                  */
   393          UIUtilities.invokeLater(new Runnable() {
   394  
   395              /** {@inheritDoc} */
   396              @Override
   397              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   398                  textField.setBackground(optionColour);
   399              }
   400          });
   401      }
   402  
   403      /** {@inheritDoc} */
   404      @Override
   405      public boolean hasFocus() {
                 /* 
    P/P           *  Method: bool hasFocus()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ReturnableThread:getObject(...)@203 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   406          return UIUtilities.invokeAndWait(new ReturnableThread<Boolean>() {
   407  
   408              /** {@inheritDoc} */
   409              @Override
   410              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   411                  setObject(textField.hasFocus());
   412              }
   413          });
   414      }
   415  
   416      /** {@inheritDoc} */
   417      @Override
   418      public boolean isFocusOwner() {
                 /* 
    P/P           *  Method: bool isFocusOwner()
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ReturnableThread:getObject(...)@203 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   419          return UIUtilities.invokeAndWait(new ReturnableThread<Boolean>() {
   420  
   421              /** {@inheritDoc} */
   422              @Override
   423              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.textField != null
                          */
   424                  setObject(textField.isFocusOwner());
   425              }
   426          });
   427      }
   428  
   429      /** 
   430       * {@inheritDoc}
   431       * 
   432       * @param e Key event
   433       */
   434      @Override
   435      public void keyTyped(final KeyEvent e) {
                 /* 
    P/P           *  Method: void keyTyped(KeyEvent)
                  * 
                  *  Preconditions:
                  *    this.listeners != null
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ListenerList:get(...)@436 != null
                  *    java.util.Iterator:next(...)@436 != null
                  * 
                  *  Test Vectors:
                  *    java.util.Iterator:hasNext(...)@436: {0}, {1}
                  */
   436          for (KeyListener listener : listeners.get(KeyListener.class)) {
   437              listener.keyTyped(e);
   438          }
   439      }
   440  
   441      /** 
   442       * {@inheritDoc}
   443       * 
   444       * @param e Key event
   445       */
   446      @Override
   447      public void keyPressed(final KeyEvent e) {
                 /* 
    P/P           *  Method: void keyPressed(KeyEvent)
                  * 
                  *  Preconditions:
                  *    this.listeners != null
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ListenerList:get(...)@448 != null
                  *    java.util.Iterator:next(...)@448 != null
                  * 
                  *  Test Vectors:
                  *    java.util.Iterator:hasNext(...)@448: {0}, {1}
                  */
   448          for (KeyListener listener : listeners.get(KeyListener.class)) {
   449              listener.keyPressed(e);
   450          }
   451      }
   452  
   453      /** 
   454       * {@inheritDoc}
   455       * 
   456       * @param e Key event
   457       */
   458      @Override
   459      public void keyReleased(final KeyEvent e) {
                 /* 
    P/P           *  Method: void keyReleased(KeyEvent)
                  * 
                  *  Preconditions:
                  *    this.listeners != null
                  * 
                  *  Presumptions:
                  *    com.dmdirc.util.ListenerList:get(...)@460 != null
                  *    java.util.Iterator:next(...)@460 != null
                  * 
                  *  Test Vectors:
                  *    java.util.Iterator:hasNext(...)@460: {0}, {1}
                  */
   460          for (KeyListener listener : listeners.get(KeyListener.class)) {
   461              listener.keyReleased(e);
   462          }
   463      }
   464  
   465      /** {@inheritDoc} */
   466      @Override
   467      public void illegalCommand(final String reason) {
                 /* 
    P/P           *  Method: void illegalCommand(String)
                  */
   468          UIUtilities.invokeLater(new Runnable() {
   469  
   470              /** {@inheritDoc} */
   471              @Override
   472              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.errorIndicator != null
                          *    this.wrapIndicator != null
                          */
   473                  errorIndicator.setVisible(true);
   474                  errorIndicator.setToolTipText(reason);
   475                  wrapIndicator.setVisible(false);
   476              }
   477          });
   478      }
   479  
   480      /** {@inheritDoc} */
   481      @Override
   482      public void legalCommand() {
                 /* 
    P/P           *  Method: void legalCommand()
                  */
   483          UIUtilities.invokeLater(new Runnable() {
   484  
   485              /** {@inheritDoc} */
   486              @Override
   487              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.errorIndicator != null
                          */
   488                  errorIndicator.setVisible(false);
   489                  errorIndicator.setToolTipText(null);
   490              }
   491          });
   492      }
   493  
   494      /** {@inheritDoc} */
   495      @Override
   496      public void wrappedText(final int count) {
                 /* 
    P/P           *  Method: void wrappedText(int)
                  */
   497          UIUtilities.invokeLater(new Runnable() {
   498  
   499              /** {@inheritDoc} */
   500              @Override
   501              public void run() {
                         /* 
    P/P                   *  Method: void run()
                          * 
                          *  Preconditions:
                          *    this.errorIndicator != null
                          *    this.wrapIndicator != null
                          */
   502                  wrapIndicator.setVisible(count > 1);
   503                  wrapIndicator.setToolTipText(count + " lines");
   504                  errorIndicator.setVisible(false);
   505              }
   506          });
   507      }
   508  }








SofCheck Inspector Build Version : 2.17854
SwingInputField.java 2009-Jun-25 01:54:24
SwingInputField.class 2009-Sep-02 17:04:17
SwingInputField$1.class 2009-Sep-02 17:04:17
SwingInputField$10.class 2009-Sep-02 17:04:17
SwingInputField$11.class 2009-Sep-02 17:04:17
SwingInputField$12.class 2009-Sep-02 17:04:17
SwingInputField$13.class 2009-Sep-02 17:04:17
SwingInputField$14.class 2009-Sep-02 17:04:17
SwingInputField$15.class 2009-Sep-02 17:04:17
SwingInputField$16.class 2009-Sep-02 17:04:17
SwingInputField$17.class 2009-Sep-02 17:04:17
SwingInputField$18.class 2009-Sep-02 17:04:17
SwingInputField$19.class 2009-Sep-02 17:04:17
SwingInputField$2.class 2009-Sep-02 17:04:17
SwingInputField$20.class 2009-Sep-02 17:04:17
SwingInputField$21.class 2009-Sep-02 17:04:17
SwingInputField$22.class 2009-Sep-02 17:04:17
SwingInputField$23.class 2009-Sep-02 17:04:17
SwingInputField$24.class 2009-Sep-02 17:04:17
SwingInputField$25.class 2009-Sep-02 17:04:17
SwingInputField$3.class 2009-Sep-02 17:04:17
SwingInputField$3$1.class 2009-Sep-02 17:04:17
SwingInputField$4.class 2009-Sep-02 17:04:17
SwingInputField$5.class 2009-Sep-02 17:04:17
SwingInputField$6.class 2009-Sep-02 17:04:17
SwingInputField$7.class 2009-Sep-02 17:04:17
SwingInputField$8.class 2009-Sep-02 17:04:17
SwingInputField$9.class 2009-Sep-02 17:04:17