File Source: ColourPickerDialog.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.components.ColourPickerDialog__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.addons.ui_swing.SwingController;
    26  
    27  import java.awt.Window;
    28  import java.awt.event.ActionListener;
    29  import java.awt.event.WindowAdapter;
    30  import java.awt.event.WindowEvent;
    31  
    32  import javax.swing.JDialog;
    33  
    34  /**
    35   * Colour picker dialog.
    36   */
    37  public final class ColourPickerDialog extends StandardDialog {
    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 = 1;
    45      /** Colour chooser panel. */
    46      private ColourPickerPanel colourChooser;
    47      /** Parent window. */
    48      private Window window;
    49  
    50      /**
    51       * Creates a new instance of ColourPickerDialog.
    52       * 
    53       * @since 0.6   
    54       */
    55      public ColourPickerDialog() {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.ColourPickerDialog()
                  * 
                  *  Postconditions:
                  *    this.colourChooser == &new ColourPickerPanel(ColourPickerDialog#1)
                  *    this.window == null
                  *    new ArrayList(ColourPickerPanel#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showHex == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showIrc == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).listeners == &new ArrayList(ColourPickerPanel#1)
                  *    new ColourPickerPanel(ColourPickerDialog#1).saturation == 1
                  */
    56          this(true, true);
    57      }
    58  
    59      /**
    60       * Creates a new instance of ColourPickerDialog.
    61       * 
    62       * @param window Parent window
    63       * 
    64       * @since 0.6
    65       */
    66      public ColourPickerDialog(final Window window) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.ColourPickerDialog(Window)
                  * 
                  *  Postconditions:
                  *    this.colourChooser == &new ColourPickerPanel(ColourPickerDialog#1)
                  *    this.window == window
                  *    init'ed(this.window)
                  *    new ArrayList(ColourPickerPanel#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showHex == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showIrc == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).listeners == &new ArrayList(ColourPickerPanel#1)
                  *    new ColourPickerPanel(ColourPickerDialog#1).saturation == 1
                  */
    67          this(true, true, window);
    68      }
    69  
    70      /**
    71       * Creates a new instance of ColourPickerDialog.
    72       * 
    73       * @param showIRC show irc colours
    74       * @param showHex show hex colours
    75       */
    76      public ColourPickerDialog(final boolean showIRC, final boolean showHex) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.ColourPickerDialog(bool, bool)
                  * 
                  *  Postconditions:
                  *    this.colourChooser == &new ColourPickerPanel(ColourPickerDialog#1)
                  *    this.window == null
                  *    new ArrayList(ColourPickerPanel#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).listeners == &new ArrayList(ColourPickerPanel#1)
                  *    new ColourPickerPanel(ColourPickerDialog#1).saturation == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showHex == showHex
                  *    init'ed(new ColourPickerPanel(ColourPickerDialog#1).showHex)
                  *    new ColourPickerPanel(ColourPickerDialog#1).showIrc == showIRC
                  *    init'ed(new ColourPickerPanel(ColourPickerDialog#1).showIrc)
                  */
    77          this(showIRC, showHex, null);
    78      }
    79  
    80      /**
    81       * Creates a new instance of ColourPickerDialog.
    82       * 
    83       * @param showIRC show irc colours
    84       * @param showHex show hex colours
    85       * @param window Parent window
    86       * 
    87       * @since 0.6
    88       */
    89      public ColourPickerDialog(final boolean showIRC, final boolean showHex,
    90              final Window window) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.ColourPickerDialog(bool, bool, Window)
                  * 
                  *  Presumptions:
                  *    init'ed(java.awt.Dialog$ModalityType.MODELESS)
                  * 
                  *  Postconditions:
                  *    this.colourChooser == &new ColourPickerPanel(ColourPickerDialog#1)
                  *    this.window == window
                  *    init'ed(this.window)
                  *    new ArrayList(ColourPickerPanel#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1) num objects == 1
                  *    this.colourChooser.listeners == &new ArrayList(ColourPickerPanel#1)
                  *    this.colourChooser.saturation == 1
                  *    this.colourChooser.showHex == showHex
                  *    init'ed(this.colourChooser.showHex)
                  *    this.colourChooser.showIrc == showIRC
                  *    ...
                  */
    91          super(window, ModalityType.MODELESS);
    92  
    93          colourChooser = new ColourPickerPanel(showIRC, showHex);
    94  
    95          setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    96          add(colourChooser);
    97          pack();
    98          setResizable(false);
    99          setFocusableWindowState(false);
   100  
   101          setWindow(window);
   102      }
   103  
   104      /** 
   105       * Creates and shows a new Colour picker dialog. 
   106       * @return Colour picker dialog
   107       */
   108      public static ColourPickerDialog showColourPicker() {
                 /* 
    P/P           *  Method: ColourPickerDialog showColourPicker()
                  * 
                  *  Postconditions:
                  *    return_value == &new ColourPickerDialog(showColourPicker#1*)
                  *    new ArrayList(ColourPickerPanel#1) num objects == 1
                  *    new ColourPickerDialog(showColourPicker#1*) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showHex == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showIrc == 1
                  *    new ColourPickerDialog(showColourPicker#1*).colourChooser == &new ColourPickerPanel(ColourPickerDialog#1)
                  *    init'ed(new ColourPickerDialog(showColourPicker#1*).window)
                  *    new ColourPickerPanel(ColourPickerDialog#1).listeners == &new ArrayList(ColourPickerPanel#1)
                  *    new ColourPickerPanel(ColourPickerDialog#1).saturation == 1
                  */
   109          return showColourPicker(true, true);
   110      }
   111  
   112      /** 
   113       * Creates and shows a new Colour picker dialog. 
   114       * @return Colour picker dialog
   115       * @param showIRC show irc colours
   116       * @param showHex show hex colours
   117       */
   118      public static ColourPickerDialog showColourPicker(final boolean showIRC,
   119              final boolean showHex) {
                 /* 
    P/P           *  Method: ColourPickerDialog showColourPicker(bool, bool)
                  * 
                  *  Postconditions:
                  *    return_value == &new ColourPickerDialog(showColourPicker#1)
                  *    new ArrayList(ColourPickerPanel#1) num objects == 1
                  *    new ColourPickerDialog(showColourPicker#1) num objects == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1) num objects == 1
                  *    return_value.colourChooser == &new ColourPickerPanel(ColourPickerDialog#1)
                  *    init'ed(return_value.window)
                  *    new ColourPickerPanel(ColourPickerDialog#1).listeners == &new ArrayList(ColourPickerPanel#1)
                  *    new ColourPickerPanel(ColourPickerDialog#1).saturation == 1
                  *    new ColourPickerPanel(ColourPickerDialog#1).showHex == showHex
                  *    init'ed(new ColourPickerPanel(ColourPickerDialog#1).showHex)
                  *    ...
                  */
   120          final ColourPickerDialog cpd = new ColourPickerDialog(showIRC, showHex);
   121          cpd.setVisible(true);
   122          return cpd;
   123      }
   124  
   125      /** 
   126       * Adds an actions listener to this dialog.
   127       *
   128       * @param listener the listener to add
   129       */
   130      public void addActionListener(final ActionListener listener) {
                 /* 
    P/P           *  Method: void addActionListener(ActionListener)
                  * 
                  *  Preconditions:
                  *    this.colourChooser != null
                  *    this.colourChooser.listeners != null
                  */
   131          colourChooser.addActionListener(listener);
   132      }
   133  
   134      /**
   135       * Sets the Parent window.
   136       * 
   137       * @param window Parent window
   138       */
   139      public void setWindow(final Window window) {
                 /* 
    P/P           *  Method: void setWindow(Window)
                  * 
                  *  Postconditions:
                  *    this.window == window
                  *    init'ed(this.window)
                  * 
                  *  Test Vectors:
                  *    window: Addr_Set{null}, Inverse{null}
                  */
   140          this.window = window;
   141  
   142          if (window != null) {
                     /* 
    P/P               *  Method: void com.dmdirc.addons.ui_swing.components.ColourPickerDialog$1(ColourPickerDialog)
                      */
   143              window.addWindowListener(new WindowAdapter() {
   144  
   145                  /** {@inheritDoc} */
   146                  @Override
   147                  public void windowClosed(WindowEvent e) {
                             /* 
    P/P                       *  Method: void windowClosed(WindowEvent)
                              */
   148                      dispose();
   149                  }
   150              });
   151          }
   152      }
   153  }








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