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     */
016    package org.opengion.hayabusa.taglib;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.common.HybsSystemException;
020    import org.opengion.fukurou.util.StringUtil;
021    import org.opengion.fukurou.util.TagBuffer;
022    
023    /**
024     * é…置図?座席表を表ã™ç‰¹æ®Šç³»ã®ãƒ“ューã§ã™ã?
025     *
026     * itd ã‚¿ã‚°ã¯ã€ã‚¬ãƒ³ãƒˆã?ãƒ?ƒ€ãƒ¼éƒ¨ã® TDã‚¿ã‚°ã®ç¹°è¿”ã—ã«ä½¿ç”¨ã•れã¾ã™ã?
027     * ã“ã?ç¹°è¿”ã—ã¯ã€ganttParam ã‚¿ã‚°ã® minDuration ã§æŒ?®šã•れãŸé–“éš”ã§è¡Œã‚れã¾ã™ã?
028     * (例ãˆã°ã€?.5 を指定ã™ã‚Œã?ã€åŠæ—¥å˜ä½ã§å‡¦ç?•れã¾ã™ã?)
029     * itd ã‚¿ã‚°ã® colspan 属æ?を指定ã—ãŸå?åˆã?ã€itd 自身ãŒã?td ã‚¿ã‚°ã« colspan ã‚?
030     * 追åŠ?™ã‚‹ã¨å…±ã«ã€ç¹°è¿”ã—自身をã?ãã?æŒ?®šæ•°ã?‘ã«æŠ‘åˆ¶ã—ã¾ã™ã?
031     * 具体的ã«ã¯ã€colspan="2" ã¨ã™ã‚‹ã¨ã€?¼’回ã«ä¸?›žã—ã‹ã€itd ã‚¿ã‚°ãŒå‘¼ã³å‡ºã•れãªã?
032     * ãªã‚Šã¾ã™ã?
033     *
034     * @og.formSample
035     * â—å½¢å¼ï¼?lt;og:iMatrix  ... />
036     * â—body?šãªã?
037     * â—å‰æï¼šheadã‚¿ã‚°ã§ã€adjustEvent="Matrix" を指定ã—ã¦ãã ã•ã„ã€?
038     *
039     * â—Tag定義??
040     *   <og:iMatrix
041     *       mode               ã€TAG】[Layout:レイアウト編é›?Value:設定å?ã®ç·¨é›?(åˆæœŸå€¤:Layout)
042     *       countPro           ã€TAG】データノã?ドã?属æ?æ•°( è¡? åˆ? åç§°, 値, 色, ç·¨é›?¯å¦, スãƒ??タス )(åˆæœŸå€¤:7)
043     *                                 (SQLæ–??カラãƒ?•°(éžè¡¨ç¤ºé ?›®ã‚’除ã?)
044     *       inputWidth         ã€TAG】編é›?™‚ã®å…¥åŠ›æ¬?¹?px)(åˆæœŸå€¤:50px)
045     *       cellWidth          ã€TAG】セルå¹?px) (åˆæœŸå€¤:75px)
046     *       cellHeight         ã€TAG】セル高ã•(px) (åˆæœŸå€¤:30px)
047     *       showStatus         ã€TAG】スãƒ??タスã®å‡ºåŠ›ã‚’è¡Œã†ã‹ã©ã?‹[[true:表示ã™ã‚‹/false:表示ã—ãªã„]](åˆæœŸå€¤:false)
048     *       countStatus        ã€TAG】スãƒ??タスã®ç¨®é¡žæ•°??:会議ã€?:æ¥å®¢ã€?:出張ã€?:外å?ã€?:休暇ã€?:ä»–ï¼?åˆæœŸå€¤:6)
049     *       writable           ã€TAG】画é¢ç·¨é›?ƒ•ラグを[true:å¯/false:ä¸å¯](åˆæœŸå€¤:false)
050     *       editColor          ã€TAG】セル背景色ã®ç·¨é›?¯å¦[true:ç·¨é›?¯/false:ç·¨é›?¸å¯](åˆæœŸå€¤:false)
051     *       separator          ã€TAG】セルåç§°ã¨è¨­å®šå?ã®é–“ã?区åˆ?‚Šæ–?­?åˆæœŸå€¤:":")
052     *       paramVal           ã€TAG】セルã®è¨­å®šå?ã¯ãƒ‘ラメータより渡ã?åˆæœŸå€¤:"")
053     *       paramColor         ã€TAG】セルã®èƒŒæ™¯è‰²ã¯ãƒ‘ラメータより渡ã?åˆæœŸå€¤:"")
054     *       notEditBgColor     ã€TAG】編é›?¸å¯ã®ã‚»ãƒ«ã®èƒŒæ™¯è‰²(åˆæœŸå€¤:gray)
055     *       debug              ã€TAG】デãƒãƒƒã‚°æƒ??ã‚’å?力ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)
056     *   />
057     *
058     * â—使用ä¾?
059     *  Select æ–??ã€è¡? åˆ? åç§°, 値, 色, ç·¨é›?¯å¦, スãƒ??タス ã®é ?§æ¤œç´¢ã—ã¾ã™ã?
060     *  <og:query >
061     *    select 行番å·,列番å·,セルåç§°,セル設定å?,セル背景色,セルã®ç·¨é›?¯å¦,セルã®ã‚¹ãƒ??タス
062     *    from   レイアウトテーブル
063     *    where  ロケーションID = 'XXXX'
064     *    order by 行番å·,列番å·
065     *  </og:query>
066     *
067     *  viewã‚¿ã‚°ã«ã‚ˆã‚‹HTML出åŠ?ã¯ã€ã“ã®é€šã‚Šã«ã—ã¦ãã ã•ã„ã€?
068     *  <og:view
069     *      viewFormType    = "HTMLDynamic"
070     *      useScrollBar    = "false"
071     *      useHilightRow   = "false"
072     *      noMessage       = "true"
073     *      pageSize        = "0"
074     *  />
075     *
076     *  <og:iMatrix
077     *     mode             =   "Layout/Value" 
078     *     countPro         =   "7"            
079     *     inputWidth       =   "80px"         
080     *     cellWidth        =   "100px"        
081     *     cellHeight       =   "30px"         
082     *     showStatus       =   "true/false"   
083     *     countStatus      =   "6"            
084     *     writable         =   "true/false"   
085     *     editColor        =   "true/false"   
086     *     separator        =   ":"            
087     *     paramVal         =   "{@XXX}"       
088     *     paramColor       =   "{@XXX}"       
089     *     notEditBgColor   =   "#XXXXXX"      
090     *  />
091     *
092     * @og.rev 5.6.3.2 (2013/04/12) æ–°è¦ä½œæ?
093     * @og.group ç”»é¢éƒ¨å“?
094     *
095     * @version  5.0
096     * @author       Kazuhiko Hasegawa
097     * @since    JDK6.0,
098     */
099    public class ViewIMatrixTag extends CommonTagSupport {
100            //* ã“ã?プログラãƒ??VERSIONæ–?­—å?を設定ã—ã¾ã™ã?       {@value} */
101            private static final String VERSION = "5.6.3.2 (2013/04/12)" ;
102    
103            private static final long serialVersionUID = 563220130412L ;
104    
105            /** mode å¼•æ•°ã«æ¸¡ã™äº‹ã?出æ¥ã‚?モードリスãƒ? */
106            private static final String[] MODE_LIST = new String[] { "Layout" , "Value" };
107    
108            private TagBuffer tag = new TagBuffer( "iMatrix" ) ;
109    
110            /**
111             * Taglibã®çµ‚äº?‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doEndTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
112             *
113             * @return      後続å?ç??æŒ?¤º
114             */
115            @Override
116            public int doEndTag() {
117                    debugPrint();           // 4.0.0 (2005/02/28)
118    
119                    jspPrint( tag.makeTag() );
120    
121                    return(EVAL_PAGE);              // ペã?ã‚¸ã®æ®‹ã‚Šã‚’評価ã™ã‚‹ã€?
122            }
123    
124            /**
125             * タグリブオブジェクトをリリースã—ã¾ã™ã?
126             * キャãƒ?‚·ãƒ¥ã•れã¦å†åˆ©ç”¨ã•れるã?ã§ã€ãƒ•ィールドã?åˆæœŸè¨­å®šã‚’行ã„ã¾ã™ã?
127             *
128             */
129            @Override
130            protected void release2() {
131                    super.release2();
132                    tag = new TagBuffer( "iMatrix" );
133            }
134    
135            /**
136             * ã€TAG】é?置図?座席表ã®ç·¨é›?ƒ¢ãƒ¼ãƒ?Layout:レイアウト編é›?Value:設定å?ã®ç·¨é›?を指定ã—ã¾ã?åˆæœŸå€¤:Layout)ã€?
137             *
138             * @og.tag
139             * mode ã¯ã€Layout:レイアウト編é›?‚’行ã†ã®ã‹ã?Value:設定å?ã®ç·¨é›?‚’行ã†ã‹ã‚’æŒ?®šã—ã¾ã™ã?
140             * Layout:レイアウト編é›?CELLNAMEã¨FGCELLEDITã®å€¤ã‚’ç·¨é›?—ã¾ã™ã?)
141             * Value :設定å?ã®ç·¨é›?VALUEã¨COLORã®å€¤ã‚’ç·¨é›?—ã¾ã™ã?)
142             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€Layout:レイアウト編é›?ã§ã™ã?
143             *
144             * @param   mode ç·¨é›?ƒ¢ãƒ¼ãƒ?Layout:レイアウト編é›?Value:設定å?ã®ç·¨é›?
145             */
146            public void setMode( final String mode ) {
147                    String tmpMode = StringUtil.nval( getRequestParameter( mode ),null );
148    
149                    if( !check( tmpMode, MODE_LIST ) ) {
150                            String errMsg = "æŒ?®šã?モーãƒ?mode)ã¯æŒ?®šã§ãã¾ã›ã‚“。モード指定エラー"
151                                                            + HybsSystem.CR
152                                                            + "mode=[" + tmpMode + "] "
153                                                            + HybsSystem.CR
154                                                            + StringUtil.array2csv( MODE_LIST ) ;
155                            throw new HybsSystemException( errMsg );
156                    }
157    
158                    tag.add( "mode",tmpMode );
159            }
160    
161            /**
162             * ã€TAG】データノã?ドã?属æ?æ•°( è¡? åˆ? åç§°, 値, 色, ç·¨é›?¯å¦, スãƒ??タス )を指定ã—ã¾ã?åˆæœŸå€¤:7)ã€?
163             *
164             * @og.tag
165             * SQLæ–??カラãƒ?•°(éžè¡¨ç¤ºé ?›®ã‚’除ã?を指定ã—ã¾ã™ã?
166             * SQLæ–??ã€å?é ­ã‹ã‚‰ã€ã?è¡? åˆ? åç§°, 値, 色, ç·¨é›?¯å¦, スãƒ??タスã€ã?é ?«æ¤œç´¢ã™ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
167             * ã“れ以外ã«ã€è¡¨ç¤ºé ?›®ã«ãªã‚‹ã‚«ãƒ©ãƒ?‚’æŒ?®šã™ã‚‹å?åˆã«ã€è¡¨ç¤ºã‚«ãƒ©ãƒ?•°ã‚’設定ã—ã¾ã™ã?
168             * å¿?¦å?ã?‘?ˆè¡? åˆ? åç§°, 値, 色, ç·¨é›?¯å¦, スãƒ??タス?‰ã?å ´åˆã?ã€?7" を指定ã—ã¾ã™ã?
169             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?7" ã§ã™ã?
170             *
171             * @param   countPro ãƒ??タノã?ドã?属æ?æ•°
172             */
173            public void setCountPro( final String countPro ) {
174                    tag.add( "countPro",StringUtil.nval( getRequestParameter( countPro ),null ) );
175            }
176    
177            /**
178             * ã€TAG】編é›?™‚ã®å…¥åŠ›æ¬?¹?px)を指定ã—ã¾ã?åˆæœŸå€¤:50px)ã€?
179             *
180             * @og.tag
181             * ç·¨é›?™‚ã®å…¥åŠ›æ¬?¹?px)を指定ã—ã¾ã™ã?
182             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?50px" ã§ã™ã?
183             *
184             * @param   inputWidth ç·¨é›?™‚ã®å…¥åŠ›æ¬?¹?px)
185             */
186            public void setInputWidth( final String inputWidth ) {
187                    tag.add( "inputWidth",StringUtil.nval( getRequestParameter( inputWidth ),null ) );
188            }
189    
190            /**
191             * ã€TAG】セルå¹?px)を指定ã—ã¾ã?åˆæœŸå€¤:75px)ã€?
192             *
193             * @og.tag
194             * セルå¹?px)を指定ã—ã¾ã™ã?
195             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?75px" ã§ã™ã?
196             *
197             * @param   cellWidth セル�px)
198             */
199            public void setCellWidth( final String cellWidth ) {
200                    tag.add( "cellWidth",StringUtil.nval( getRequestParameter( cellWidth ),null ) );
201            }
202    
203            /**
204             * ã€TAG】セル高ã•(px)を指定ã—ã¾ã?åˆæœŸå€¤:30px)ã€?
205             *
206             * @og.tag
207             * セル高ã•(px)を指定ã—ã¾ã™ã?
208             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?30px" ã§ã™ã?
209             *
210             * @param   cellHeight セル高ã•(px)
211             */
212            public void setCellHeight( final String cellHeight ) {
213                    tag.add( "cellHeight",StringUtil.nval( getRequestParameter( cellHeight ),null ) );
214            }
215    
216            /**
217             * ã€TAG】スãƒ??タスã®å‡ºåŠ›ã‚’è¡Œã†ã‹ã©ã?‹[true:表示ã™ã‚‹/false:表示ã—ãªã„]を指定ã—ã¾ã?åˆæœŸå€¤:false)ã€?
218             *
219             * @og.tag
220             * スãƒ??タスã®å‡ºåŠ›ã‚’è¡Œã†å ´åˆã?ã€?./image/status_番å·.png イメージを画é¢ã«è¡¨ç¤ºã—ã¾ã™ã?
221             * 番å·ãŒã?スãƒ??タス番å·ã«ãªã‚Šã¾ã™ã?
222             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€false:表示ã—ãªã?ã§ã™ã?
223             *
224             * @param   showStatus スãƒ??タスã®å‡ºåŠ›å¯å¦[true/false]
225             */
226            public void setShowStatus( final String showStatus ) {
227                    tag.add( "showStatus",StringUtil.nval( getRequestParameter( showStatus ),null ) );
228            }
229    
230            /**
231             * ã€TAG】スãƒ??タスã®ç¨®é¡žæ•°??:会議ã€?:æ¥å®¢ã€?:出張ã€?:外å?ã€?:休暇ã€?:他)をæŒ?®šã—ã¾ã?åˆæœŸå€¤:6)ã€?
232             *
233             * @og.tag
234             * スãƒ??タスã®ç¨®é¡žæ•°??:会議ã€?:æ¥å®¢ã€?:出張ã€?:外å?ã€?:休暇ã€?:他)ã?ã€ç·¨é›??ãƒ??ã‚¢ãƒ??ã®ä½œæ?ã«ä½¿ã?¾ã™ã?
235             * 上記ã?å ´åˆã??–種類ã«ãªã‚‹ãŸã‚ã?countStatus="6" ã¨ã—ã¾ã™ã?
236             * å†?ƒ¨çš?«ã¯ã€status_0.png ãŒã‚りã¾ã™ã?
237             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?6" ã§ã™ã?
238             *
239             * @param   countStatus スãƒ??タスã®ç¨®é¡žæ•°
240             */
241            public void setCountStatus( final String countStatus ) {
242                    tag.add( "countStatus",StringUtil.nval( getRequestParameter( countStatus ),null ) );
243            }
244    
245            /**
246             * ã€TAG】画é¢ç·¨é›?‚’許å¯ã™ã‚‹ã‹ã©ã?‹[true:å¯/false:ä¸å¯]を指定ã—ã¾ã?åˆæœŸå€¤:false)ã€?
247             *
248             * @og.tag
249             * true:ç”»é¢ç·¨é›?¯/false:ç”»é¢ç·¨é›?¸å¯ã‚’指定ã—ã¾ã™ã?
250             * ã“ã“ã§ã¯ã€mode=[Layout/Value] ã«é–¢ä¿‚ãªãã?false ã«ã™ã‚‹ã¨ç·¨é›?¸å¯ã«ãªã‚Šã¾ã™ã?
251             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€false:ç·¨é›?¸å¯ ã§ã™ã?
252             *
253             * @param   writable ç”»é¢ç·¨é›?¯å¦[true/false]
254             */
255            public void setWritable( final String writable ) {
256                    tag.add( "writable",StringUtil.nval( getRequestParameter( writable ),null ) );
257            }
258    
259            /**
260             * ã€TAG】セル背景色ã®ç·¨é›?¯å¦[true:ç·¨é›?¯/false:ç·¨é›?¸å¯]を指定ã—ã¾ã?åˆæœŸå€¤:false)ã€?
261             *
262             * @og.tag
263             * セル背景色ã®ç·¨é›?¯å¦[true:ç·¨é›?¯/false:ç·¨é›?¸å¯]を指定ã—ã¾ã™ã?
264             * ã“れã¯ã€mode="Value" ã§ã€writable="true" ã®å ´åˆã?ã¿æœ‰åйã§ã™ã?
265             * false ã«ã™ã‚‹ã¨ã€COLOR属æ?ã®ç·¨é›?Œã§ããªããªã‚Šã¾ã™ã?
266             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€false:ç·¨é›?¸å¯ ã§ã™ã?
267             *
268             * @param   editColor セル背景色ã®ç·¨é›?¯å¦[true/false]
269             */
270            public void setEditColor( final String editColor ) {
271                    tag.add( "editColor",StringUtil.nval( getRequestParameter( editColor ),null ) );
272            }
273    
274            /**
275             * ã€TAG】セルåç§°ã¨è¨­å®šå?ã®é–“ã?区åˆ?‚Šæ–?­—ã‚’æŒ?®šã—ã¾ã?åˆæœŸå€¤:":")ã€?
276             *
277             * @og.tag
278             * ç”»é¢ä¸Šã«ã¯ã€ã‚»ãƒ«åç§°(CELLNAME)ã¨è¨­å®šå?(VALUE)ãŒè¡¨ç¤ºã•れã¾ã™ã?ãã?時ã?ã€åŒºåˆ?‚Šæ–?­—ã‚’æŒ?®šã—ã¾ã™ã?
279             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?:" ã§ã™ã?
280             *
281             * @param   separator 区åˆ?‚Šæ–?­?
282             */
283            public void setSeparator( final String separator ) {
284                    tag.add( "separator",StringUtil.nval( getRequestParameter( separator ),null ) );
285            }
286    
287            /**
288             * ã€TAG】セルã®è¨­å®šå?(VALUE)を指定ã—ã¾ã?åˆæœŸå€¤:"")ã€?
289             *
290             * @og.tag
291             * セルã®è¨­å®šå?(VALUE)を指定ã—ã¾ã™ã?
292             *
293             * @param   paramVal セルã®è¨­å®šå?
294             */
295            public void setParamVal( final String paramVal ) {
296                    tag.add( "paramVal",StringUtil.nval( getRequestParameter( paramVal ),null ) );
297            }
298    
299            /**
300             * ã€TAG】セルã®èƒŒæ™¯è‰²(COLOR)を指定ã—ã¾ã?åˆæœŸå€¤:"")ã€?
301             *
302             * @og.tag
303             * セルã®èƒŒæ™¯è‰²ã‚’指定ã—ã¾ã™ã?
304             *
305             * @param   paramColor セルã®èƒŒæ™¯è‰²
306             */
307            public void setParamColor( final String paramColor ) {
308                    tag.add( "paramColor",StringUtil.nval( getRequestParameter( paramColor ),null ) );
309            }
310    
311            /**
312             * ã€TAG】編é›?¸å¯ã®ã‚»ãƒ«ã®èƒŒæ™¯è‰²ã‚’指定ã—ã¾ã?åˆæœŸå€¤:gray)ã€?
313             *
314             * @og.tag
315             * ç·¨é›?¸å¯ã®ã‚»ãƒ«ã®èƒŒæ™¯è‰²ã‚’指定ã—ã¾ã™ã?
316             * (adjustMatrix.jsã®)åˆæœŸå€¤ã¯ã€?gray" ã§ã™ã?
317             *
318             * @param   notEditBgColor ç·¨é›?¸å¯ã®ã‚»ãƒ«ã®èƒŒæ™¯è‰²
319             */
320            public void setNotEditBgColor( final String notEditBgColor ) {
321                    tag.add( "notEditBgColor",StringUtil.nval( getRequestParameter( notEditBgColor ),null ) );
322            }
323    
324            /**
325             * ã‚¿ã‚°ã®åç§°ã‚’ã?è¿”ã—ã¾ã™ã?
326             * 自åˆ??身ã®ã‚¯ãƒ©ã‚¹åよりã?自動的ã«å–り出ã›ãªã?Ÿã‚ã?ã“ã?メソãƒ?ƒ‰ã‚’オーãƒã?ライドã—ã¾ã™ã?
327             *
328             * @return  ã‚¿ã‚°ã®åç§°
329             */
330            @Override
331            protected String getTagName() {
332                    return "iMatrix" ;
333            }
334    
335            /**
336             * ã“ã?オブジェクトã?æ–?­—å?表ç¾ã‚’è¿”ã—ã¾ã™ã?
337             * 基本çš?«ãƒ?ƒãƒ?‚°ç›®çš?«ä½¿ç”¨ã—ã¾ã™ã?
338             *
339             * @return ã“ã?ã‚¯ãƒ©ã‚¹ã®æ–?­—å?表ç¾
340             */
341            @Override
342            public String toString() {
343                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
344                                    .println( "VERSION"             ,VERSION        )
345                                    .println( "tag"                 ,tag.makeTag()  )
346                                    .println( "Other..."    ,getAttributes().getAttribute() )
347                                    .fixForm().toString() ;
348            }
349    }