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.html;
017    
018    /**
019     * ã€å»?­¢ã€‘タブ表示を行ã†å ´åˆã?å?‚¿ãƒ–ã«å¯¾å¿œã™ã‚‹ãƒ‡ãƒ¼ã‚¿ã‚’管ç?—ã¾ã™ã?
020     *
021     * タブ表示ã«ã¯ã€text , id , body ã®é ?›®ã‚’æŒã£ã¦ã?¾ã™ã?
022     * ã“ã?タブ表示ã«ã¯ã€tabstrip.htc 㨠multipage.htc ã®?’ã¤ã® JavaScript ãŒå¿?¦ã§ã™ã?
023     * text ã¯ã€tabstrip ã® tab ã«è¡¨ç¤ºã™ã‚‹æ–?­—å?を指定ã—ã¾ã™ã?
024     * id ã¯ã€multipage ã® pageview ã® id を指定ã—ã¾ã™ã?
025     * body ã¯ã€multipage ã® pageview ã® BODY 部ã«è¨˜è¿°ã™ã‚‹ タブã?å†?®¹ã§ã™ã?
026     * タブã¨ã‚¿ãƒ–ã?é–“ã«ã¯ã€tabseparator ãŒæŒ¿å…¥ã•れã¾ã™ã?ã“れã¯ã€ã‚¿ãƒ–é–“ã®å¤§ãã•を指定ã—ã¾ã™ã?
027     * ä¸?•ªæœ?¾Œã? tabseparator ã¯ã€ã‚¿ãƒ–ã?é…置方æ³?ç¸¦ã‹æ¨ª)ã«å¿œã˜ã¦å¤‰æ›´ã•れã¾ã™ã?
028     * horizontal ã®å ´åˆã?ã€widt ã‚?100% ã«ã€vertical ã®å ´åˆã?ã€height ã‚?100% ã«è¨­å®šã—ã¾ã™ã?
029     * 設定方法ã?ã€tabseparator ã® defaultstyle 属æ?ã« style 属æ?ã®å½¢å¼?width:100%)ã§æŒ?®šã—ã¾ã™ã?
030     *
031     * @og.rev 3.5.6.5 (2004/08/09) æ–°è¦ä½œæ?
032     * @og.group ç”»é¢è¡¨ç¤º
033     *
034     * @version  4.0
035     * @author       Kazuhiko Hasegawa
036     * @since    JDK5.0,
037     */
038    public class TabData {
039            private final String text ;
040            private final String name  ;            // 3.5.6.6 (2004/08/23) id ã‹ã‚‰ name ã¸å¤‰æ›´
041            private final String body ;
042            private final String  style ;           // 3.8.6.1 (2006/10/24)
043            private final boolean openFlag ;
044    
045            /**
046             * コンストラクター
047             *
048             * @og.rev 3.8.6.1 (2006/10/20) action属æ?を追åŠ?
049             *
050             * @param       text    タブã?ãƒ?‚­ã‚¹ãƒ?
051             * @param       name    multipage ã® pageview ã® id を指定ã—ã¾ã™ã?
052             * @param       body    multipage ã® pageview ã® BODY 部ã«è¨˜è¿°ã™ã‚‹ã‚¿ãƒ–ã?å†?®¹ã‚’指定ã—ã¾ã™ã?
053             * @param       openFlag        タブãŒé¸æŠžã•れã¦ã?‚‹ã‹ã©ã?‹
054             * @param       style   ã‚¿ãƒ–ã«æŒ?®šã™ã‚‹ã‚¹ã‚¿ã‚¤ãƒ«ã‚·ãƒ¼ãƒˆå±žæ?を設定ã—ã¾ã™ã?
055             */
056            public TabData( final String text,final String name,final String body,
057                                                    final boolean openFlag,final String style ) {
058                    this.text               = text;
059                    this.name               = name;
060                    this.body               = body;
061                    this.openFlag   = openFlag;
062                    this.style              = style;
063            }
064    
065            /**
066             * tab ã®ã‚¿ã‚°ã‚’作æ?ã—ã¦è¿”ã—ã¾ã™ã?
067             *
068             * 引数㮠style ãŒã?null ã§ãªã‘れã°ã€defaultStyle 㨠selectedStyle ã«è¨­å®šã—ã¾ã™ã?
069             * ã¾ãŸã?タブå˜ç‹¬ã«ç›´æŽ¥æŒ?®šã•れã¦ã?‚‹å ´åˆã?ã€ãã¡ã‚‰ãŒå„ªå…ˆã•れã¾ã™ã?
070             *
071             * @param       inStyle 外部よりæŒ?®šã•れるスタイル
072             *
073             * @return      tabã®ã‚¿ã‚°
074             */
075            public String getTab( final String inStyle ) {
076                    return "<ts:tab " + getStyleString( style,inStyle ) + " text=\"" + text + "\" />" ;
077            }
078    
079            /**
080             * pageview ã®ã‚¿ã‚°ã‚’作æ?ã—ã¦è¿”ã—ã¾ã™ã?
081             * タブã?å†?®¹ã‚’表示ã™ã‚‹ã‚¿ã‚°ã‚’作æ?ã—ã¾ã™ã?
082             *
083             * @return      pageviewã®ã‚¿ã‚°
084             *
085             */
086            public String getTabBody() {
087                    return "<mp:pageview id=\"" + name + "\">" + body + "</mp:pageview>" ;
088            }
089    
090            /**
091             * タブãŒé¸æŠžã•れã¦ã?‚‹ã‹ã©ã?‹(true:鏿Š?false:通常)ã‚’å–å¾—ã—ã¾ã™ã?
092             *
093             * タブãŒé¸æŠžã•れるã‹ã©ã?‹ã¯ã€tabTag ã® term,termList ãŒæ?ç«‹ã™ã‚‹ã‹ã€?
094             * tabTableTag ã§ã€selectedIndex æŒ?®šã•れるã‹ã§ã™ã?
095             *
096             * @og.rev 3.8.6.1 (2006/10/24) æ–°è¦è¿½åŠ?
097             *
098             * @return      タブãŒé¸æŠžã•れã¦ã?‚‹ã‹ã©ã?‹(true:鏿Š?false:通常)
099             */
100            public boolean isOpen() {
101                    return openFlag ;
102            }
103    
104            /**
105             * defaultStyle 㨠selectedStyle を指定ã—ã?style属æ?を作æ?ã—ã¾ã™ã?
106             *
107             * style属æ? ã¯ã€ã“ã®ã‚¿ãƒ–æ§‹ç¯‰æ™‚ã«æŒ?®šã•れãŸã‚¹ã‚¿ã‚¤ãƒ«(defStyle)ãŒå„ªå…ˆã•れã¾ã™ã?
108             * ã“れã?null ã®å ´åˆã?ã€å¤–部よりæŒ?®šã•れるスタイル(inStyle)ã‚’é©ç”¨ã—ã¾ã™ã?
109             * ãれã‚?null ã®å ´åˆã?ã€ã‚¼ãƒ­æ–?­—å?ã‚’è¿”ã—ã¾ã™ã?
110             *
111             * @param       defStyle        ã“ã?ã‚¿ãƒ–æ§‹ç¯‰æ™‚ã«æŒ?®šã•れãŸã‚¹ã‚¿ã‚¤ãƒ«(優å…?
112             * @param       inStyle         外部よりæŒ?®šã•れるスタイル
113             *
114             * @return      styleã®ã‚¿ã‚°
115             */
116            private String getStyleString( final String defStyle, final String inStyle ) {
117                    String tmp = ( defStyle != null ) ? defStyle : inStyle ;
118    
119                    String rtn = "";
120                    if( tmp != null ) {
121                            rtn = "defaultStyle=\"" + tmp + "\" selectedStyle=\"" + tmp + "\"";
122                    }
123    
124                    return rtn ;
125            }
126    }