001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    package echopoint.tucana;
019    
020    import nextapp.echo.app.Border;
021    import nextapp.echo.app.Color;
022    import nextapp.echo.app.Extent;
023    import nextapp.echo.app.Insets;
024    
025    /**
026     * A custom progress bar component with default styles to use with the file
027     * upload component.
028     *
029     * <p><b>Note:</b> Similar to the {@link echopoint.ProgressBar} super-class,
030     * this component requires fixed size width and height.  Percentage based
031     * values will lead to display issues with the progress bar.</p>
032     *
033     * <p><b>Note:</b> Development of this component was sponsored by <a
034     * href='http://tcnbroadcasting.com/index.jsp' target='_top'>TCN
035     * Broadcasting</a>.  We are grateful for their support and sponsorship.</p>
036     *
037     * @author Rakesh 2008-11-6
038     * @version $Id: ProgressBar.java 103 2009-01-29 12:10:22Z sptrakesh $
039     */
040    public class ProgressBar extends echopoint.ProgressBar
041    {
042      private static final long serialVersionUID = 1l;
043    
044      /**
045       * The pattern to use to display the text message in the bar.  The following
046       * encoded fields may be embedded within the specified text to be replaced
047       * by the corresponding values:
048       *
049       * <ul>
050       *   <li><code>#bytes#</code> - This encoded value will be replaced by
051       *     the actual kilo bytes that have been transferred so far.</li>
052       *   <li><code>#length#</code> - This encoded value will be replaced
053       *     by actual size of the file being uploaded.</li>
054       *   <li><code>#percent#</code> - This encoded value will be replaced
055       *     by the upload completion ratio.</li>
056       *   <li><code>#rate#</code> - This encoded value will be replaced
057       *     by the rate at which kilo bytes are being uploaded per second.</li>
058       *   <li><code>#time#</code> - This encoded value will be replaced
059       *     by the estimated time (in seconds) for completion of the upload.</li>
060       * </ul>
061       *
062       * The following is a sample pattern expressed using the encoded fields:
063       * <code>Uploaded #bytes# of #length#Kb at #rate#...</code>
064       *
065       * This property may be styled.
066       */
067      public static final String PROPERTY_PATTERN = "pattern";
068    
069      /** Create a default styled progress bar. */
070      public ProgressBar()
071      {
072        setBackground( new Color( 0xd6d5d4 ) );
073        setForeground( new Color( 0xffffff ) );
074        setBarBackground( new Color( 0x1a428a ) );
075        setBorder( new Border( 1, Color.BLACK, Border.STYLE_INSET ) );
076        setInsets( new Insets( new Extent( 1 ) ) );
077      }
078    
079      /**
080       * Return the value of the {@link #PROPERTY_PATTERN} property.
081       *
082       * @return The pattern used to display the text.
083       */
084      public String getPattern()
085      {
086        return (String) get( PROPERTY_PATTERN );
087      }
088    
089      /**
090       * Set the value of the {@link #PROPERTY_PATTERN} property.  See the
091       * property notes for list of encoded values that may be specified in the
092       * pattern.
093       *
094       * @param pattern The pattern to use to display the text.
095       */
096      public void setPattern( final String pattern )
097      {
098        set( PROPERTY_PATTERN, pattern );
099      }
100    }