File Source: TextAreaInputField.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.components.TextAreaInputField__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.components;
    23  
    24  import com.dmdirc.config.IdentityManager;
    25  import com.dmdirc.ui.interfaces.InputField;
    26  
    27  import java.awt.event.ActionEvent;
    28  import java.awt.event.ActionListener;
    29  
    30  import javax.swing.JTextArea;
    31  import javax.swing.text.BadLocationException;
    32  
    33  /**
    34   *
    35   * @author chris
    36   */
    37  public class TextAreaInputField extends JTextArea implements InputField {
    38      
    39      /**
    40       * A version number for this class. It should be changed whenever the class
    41       * structure is changed (or anything else that would prevent serialized
    42       * objects being unserialized with the new class).
    43       */
    44      private static final long serialVersionUID = 2;
    45      
    46      /** Colour picker. */
    47      protected ColourPickerDialog colourPicker;    
    48  
    49      /**
    50       * Creates a new text area with the specified number of rows and columns.
    51       * 
    52       * @param rows The number of rows to use
    53       * @param columns The number of columns to use
    54       */
    55      public TextAreaInputField(final int rows, final int columns) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.TextAreaInputField(int, int)
                  */
    56          super(rows, columns);
    57      }
    58  
    59      /**
    60       * Creates a new text area containing the specified text.
    61       * 
    62       * @param text The text to contain initially
    63       */
    64      public TextAreaInputField(String text) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.TextAreaInputField(String)
                  */
    65          super(text);
    66      }
    67      
    68      /** {@inheritDoc} */
    69      @Override
    70      public void addActionListener(final ActionListener listener) {
    71          // Ignore request - we don't handle returns for text areas
             /* 
    P/P       *  Method: void addActionListener(ActionListener)
              */
    72      }
    73  
    74      /** {@inheritDoc} */
    75      @Override    
    76      public void removeActionListener(final ActionListener listener) {
    77          // Ignore request - we don't handle returns for text areas
             /* 
    P/P       *  Method: void removeActionListener(ActionListener)
              */
    78      }
    79  
    80      /** {@inheritDoc} */
    81      @Override
    82      public void showColourPicker(final boolean irc, final boolean hex) {
                 /* 
    P/P           *  Method: void showColourPicker(bool, bool)
                  * 
                  *  Presumptions:
                  *    (int) (java.awt.Point:getX(...)@100) in {-231..232-1}
                  *    (int) (java.awt.Point:getY(...)@100) in {-232..8_589_934_590}
                  *    com.dmdirc.addons.ui_swing.components.ColourPickerDialog:getHeight(...)@100 - (int) (java.awt.Point:getY(...)@100) in {-232+1..231}
                  *    com.dmdirc.addons.ui_swing.components.TextAreaInputField:getLocationOnScreen(...)@100 != null
                  *    com.dmdirc.config.IdentityManager:getGlobalConfig(...)@83 != null
                  * 
                  *  Postconditions:
                  *    this.colourPicker == One-of{old this.colourPicker, &new ColourPickerDialog(showColourPicker#1)}
                  *    new ArrayList(ColourPickerPanel#1) num objects <= 1
                  *    new ColourPickerDialog(showColourPicker#1) num objects <= 1
                  *    new ColourPickerDialog(showColourPicker#1).colourChooser == &amp;new ColourPickerPanel(ColourPickerDialog#1)
                  *    init'ed(new ColourPickerDialog(showColourPicker#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(...)@83: {0}, {1}
                  */
    83          if (IdentityManager.getGlobalConfig().getOptionBool("general",
    84                  "showcolourdialog")) {
    85              colourPicker = new ColourPickerDialog(irc, hex);
                     /* 
    P/P               *  Method: void com.dmdirc.addons.ui_swing.components.TextAreaInputField$1(TextAreaInputField)
                      */
    86              colourPicker.addActionListener(new ActionListener() {
    87  
    88                  @Override
    89                  public void actionPerformed(final ActionEvent actionEvent) {
    90                      try {
                                 /* 
    P/P                           *  Method: void actionPerformed(ActionEvent)
                                  * 
                                  *  Preconditions:
                                  *    this.colourPicker != null
                                  *    (soft) actionEvent != null
                                  * 
                                  *  Presumptions:
                                  *    com.dmdirc.addons.ui_swing.components.TextAreaInputField:getDocument(...)@91 != null
                                  */
    91                          getDocument().insertString(getCaretPosition(), 
    92                                  actionEvent.getActionCommand(), null);
    93                      } catch (BadLocationException ex) {
    94                          //Ignore, wont happen
    95                      }
    96                      colourPicker.dispose();
    97                      colourPicker = null;
    98                  }
    99              });
   100              colourPicker.setLocation((int) getLocationOnScreen().getX(),
   101                      (int) getLocationOnScreen().getY() -
   102                      colourPicker.getHeight());
   103              colourPicker.setVisible(true);
   104          }
   105      }
   106  
   107      /** {@inheritDoc} */
   108      @Override
   109      public void hideColourPicker() {
                 /* 
    P/P           *  Method: void hideColourPicker()
                  * 
                  *  Preconditions:
                  *    init'ed(this.colourPicker)
                  * 
                  *  Postconditions:
                  *    this.colourPicker == null
                  * 
                  *  Test Vectors:
                  *    this.colourPicker: Addr_Set{null}, Inverse{null}
                  */
   110          if (colourPicker != null) {
   111              colourPicker.dispose();
   112              colourPicker = null;
   113          }
   114      }
   115  
   116  }








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