//-----------------------------------------------------------------------//
//                                                                       //
//                               B o a r d                               //
//                                                                       //
//  Copyright (C) Herve Bitteur 2000-2005. All rights reserved.          //
//  This software is released under the terms of the GNU General Public  //
//  License. Please contact the author at herve.bitteur@laposte.net      //
//  to report bugs & suggestions.                                        //
//-----------------------------------------------------------------------//

package omr.ui;

import omr.util.Logger;

import com.jgoodies.forms.builder.*;
import com.jgoodies.forms.layout.*;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

/**
 * Class <code>Board</code> defines the common properties of any user board
 * such as PixelBoard, SectionBoard, and the like
 *
 * @author Herv&eacute Bitteur
 * @version $Id$
 */
public class Board
    extends Panel
{
    //~ Static variables/initializers -------------------------------------

    private static final Logger logger = Logger.getLogger(Board.class);

    /** To indicate that value is invalid */
    public static final int NO_VALUE = 0;

    //~ Instance variables ------------------------------------------------

    // Board Tag
    private Tag tag;

    //~ Constructors ------------------------------------------------------

    //-------//
    // Board //
    //-------//
    /**
     * Create a board
     *
     * @param tag the tag to wrap the board
     */
    public Board (Tag tag)
    {
        this.tag = tag;
    }

    //--------//
    // getTag //
    //--------//
    /**
     * Report the tag of the board
     *
     * @return the board tag
     */
    public Tag getTag ()
    {
        return tag;
    }

    //-------------//
    // emptyFields //
    //-------------//
    /**
     * Empty all the text fields of the given panel
     *
     * @param panel the panel to "blank".
     */
    protected void emptyFields(JPanel panel)
    {
        for (Component comp : panel.getComponents()) {
            if (comp instanceof JTextField){
                ((JTextField) comp).setText("");
            }
        }
    }

    //~ Classes -----------------------------------------------------------

    //-----//
    // Tag //
    //-----//
    /**
     * Enum <code>Tag</code> is used to refer to the various user boards.
     */
    public static enum Tag
    {
            /** Board for pixel info (coordinates, pixel grey level) */
            PIXEL   ("Pixel"),

            /** Board for section info */
            SECTION ("Section"),

            /** Board for glyph info */
            GLYPH   ("Glyph"),

            /** Board for filter results */
            FILTER  ("Filter"),

            /** Custom board */
            CUSTOM  ("Custom");

        //~ Instance variables --------------------------------------------

        private String label;

        //~ Constructors --------------------------------------------------

        //-----//
        // Tag //
        //-----//
        /**
         * Create a tag enum item, with its provided description
         *
         * @param label the tag description
         */
        Tag (String label)
        {
            this.label = label;
        }

        //----------//
        // toString //
        //----------//
        /**
         * Report the tag description
         *
         * @return the tag description
         */
        @Override
            public String toString()
        {
            return label;
        }
    }
}

@@ -1073,26 +1073,8 @@
 ard%0A
-    extends Panel%0A
 %7B%0A  
@@ -1382,24 +1382,85 @@
 ----------%0A%0A
+    // Concrete UI panel%0A    private final Panel component;%0A%0A
     // Board
@@ -1753,24 +1753,367 @@
 .tag = tag;%0A
+        component = new Panel();%0A    %7D%0A%0A    //~ Methods -----------------------------------------------------------%0A%0A    //--------------//%0A    // getComponent //%0A    //--------------//%0A    /**%0A     * Report the UI component%0A     *%0A     * @return the concrete component%0A     */%0A    public JPanel getComponent()%0A    %7B%0A        return component;%0A
     %7D%0A%0A    /
@@ -2417,23 +2417,26 @@
  of 
-the
+a
  given 
-panel
+JComponent
 %0A   
@@ -2457,23 +2457,31 @@
 ram 
-panel the panel
+component the component
  to 
@@ -2506,16 +2506,20 @@
    p
-rotected
+ublic static
  voi
@@ -2537,19 +2537,27 @@
 ds(J
-Panel panel
+Component component
 )%0A  
@@ -2590,21 +2590,25 @@
  comp : 
-panel
+component
 .getComp
@@ -3268,14 +3268,13 @@
 for 
-filter
+check
  res
@@ -3297,24 +3297,23 @@
     
-FILTER  (%22Filter
+CHECK   (%22Check
 %22),%0A

use of an inner component Moved from Filter board to Check board