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.html;
017
018/**
019 * 【廃止】タブ表示を行う場合の各タブに対応するデータを管理します。
020 *
021 * タブ表示には、text , id , body の項目を持っています。
022 * このタブ表示には、tabstrip.htc と multipage.htc の2つの 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 */
038public 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}