001/*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016package org.opengion.hayabusa.taglib;
017
018import org.opengion.hayabusa.common.HybsSystemException;
019import org.opengion.hayabusa.html.TableFormatter;
020
021/**
022 * ガントチャート(タスク配置型)用の繰り返しタグのフォーマットに使用します。
023 *
024 * itd タグは、ガントヘッダー部の TDタグの繰返しに使用されます。
025 * この繰返しは、ganttParam タグの minDuration で指定された間隔で行われます。
026 * (例えば、0.5 を指定すれば、半日単位で処理されます。)
027 * itd タグの colspan 属性を指定した場合は、itd 自身が、td タグに colspan を
028 * 追加すると共に、繰返し自身を、その指定数だけに抑制します。
029 * 具体的には、colspan="2" とすると、2回に一回しか、itd タグが呼び出されなく
030 * なります。
031 *
032 * @og.formSample
033 * ●形式:<og:itd> ... Body ... </og:itd>
034 * ●body:あり(EVAL_BODY_BUFFERED:BODYを評価し、{@XXXX} を解析します)
035 *
036 * ●Tag定義:
037 *   <og:itd
038 *       debug              【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
039 *   >   ... Body ...
040 *   </og:itd>
041 *
042 * ●使用例
043 *    <og:thead rowspan="1">
044 *      <tr>
045 *        <og:itd>M/d</og:itd>
046 *      </tr>
047 *    </og:thead>
048 *    <og:tbody rowspan="1" >
049 *      <tr>
050 *        <og:itd>
051 *          <span class="cGntBar[!FGTASK]"
052 *                title="[NMMCN]
[NMKT]"
053 *                val1 ="[GVZOOM]"
054 *                val2 ="[CDJGS]"
055 *                val3 ="[WC]"
056 *                val4 ="[NOMCN]"
057 *                val5 ="[CDKT]"
058 *                val6 ="[FGTASK]"
059 *                val7 ="[DYSTART]"
060 *                val8 ="[DYDELAY]"
061 *                val9 ="[DURATION]" > </span>
062 *        </og:itd>
063 *      </tr>
064 *    </og:tbody>
065 *
066 * @og.rev 3.5.4.8 (2004/02/23) 新規作成
067 * @og.group 画面部品
068 *
069 * @version  4.0
070 * @author       Kazuhiko Hasegawa
071 * @since    JDK5.0,
072 */
073public class ItdTag extends CommonTagSupport {
074        //* このプログラムのVERSION文字列を設定します。   {@value} */
075        private static final String VERSION = "4.0.0.0 (2005/08/31)" ;
076
077        private static final long serialVersionUID = 400020050831L ;
078
079        private String itdBody = null;
080
081        /**
082         * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
083         *
084         * @return      後続処理の指示( EVAL_BODY_BUFFERED )
085         */
086        @Override
087        public int doStartTag() {
088                return EVAL_BODY_BUFFERED ;     // Body を評価する。( extends BodyTagSupport 時)
089        }
090
091        /**
092         * Taglibのタグ本体を処理する doAfterBody() を オーバーライドします。
093         *
094         * @return      後続処理の指示(SKIP_BODY)
095         */
096        @Override
097        public int doAfterBody() {
098                itdBody = getBodyString();
099
100                return SKIP_BODY ;                              // Body を評価しない
101        }
102
103        /**
104         * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
105         *
106         * @return      後続処理の指示
107         */
108        @Override
109        public int doEndTag() {
110                debugPrint();           // 4.0.0 (2005/02/28)
111                TFormatTag tFormat = (TFormatTag)findAncestorWithClass( this, TFormatTag.class );
112                if( tFormat != null ) {
113                        tFormat.setItdBody( itdBody );
114                        jspPrint( TableFormatter.HYBS_ITD_MARKER );
115                }
116                else {
117                        String errMsg = "<b><b>" + getTagName() + "タグは、TheadTag か、TBodyTagの内側(要素)に記述してください。</b>";
118                        throw new HybsSystemException( errMsg );
119                }
120
121                return EVAL_PAGE ;              // ページの残りを評価する。
122        }
123
124        /**
125         * タグリブオブジェクトをリリースします。
126         * キャッシュされて再利用されるので、フィールドの初期設定を行います。
127         *
128         */
129        @Override
130        protected void release2() {
131                super.release2();
132                itdBody = null;
133        }
134
135        /**
136         * このオブジェクトの文字列表現を返します。
137         * 基本的にデバッグ目的に使用します。
138         *
139         * @return このクラスの文字列表現
140         */
141        @Override
142        public String toString() {
143                return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
144                                .println( "VERSION"             ,VERSION        )
145                                .println( "itdBody"             ,itdBody        )
146                                .println( "Other..."    ,getAttributes().getAttribute() )
147                                .fixForm().toString() ;
148        }
149}