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 018import org.opengion.fukurou.util.StringUtil; 019 020/** 021 * 【廃止】タブ表示を行う場合の各タブに対応するデータを管理します。 022 * 023 * タブ表示には、text , id , body の項目を持っています。 024 * このタブ表示には、tabstrip.htc と multipage.htc の2つの JavaScript が必要です。 025 * text は、tabstrip の tab に表示する文字列を指定します。 026 * id は、multipage の pageview の id を指定します。 027 * body は、multipage の pageview の BODY 部に記述する タブの内容です。 028 * タブとタブの間には、tabseparator が挿入されます。これは、タブ間の大きさを指定します。 029 * 一番最後の tabseparator は、タブの配置方法(縦か横)に応じて変更されます。 030 * horizontal の場合は、widt を 100% に、vertical の場合は、height を 100% に設定します。 031 * 設定方法は、tabseparator の defaultstyle 属性に style 属性の形式(width:100%)で指定します。 032 * 033 * @og.rev 3.5.6.5 (2004/08/09) 新規作成 034 * @og.group 画面表示 035 * 036 * @version 4.0 037 * @author Kazuhiko Hasegawa 038 * @since JDK5.0, 039 */ 040public class TabData { 041 private final String text ; 042 private final String name ; // 3.5.6.6 (2004/08/23) id から name へ変更 043 private final String body ; 044 private final String style ; // 3.8.6.1 (2006/10/24) 045 private final boolean openFlag ; 046 047 /** 048 * コンストラクター 049 * 050 * @og.rev 3.8.6.1 (2006/10/20) action属性を追加 051 * 052 * @param text タブのテキスト 053 * @param name multipage の pageview の id を指定します。 054 * @param body multipage の pageview の BODY 部に記述するタブの内容を指定します。 055 * @param openFlag タブが選択されているかどうか 056 * @param style タブに指定するスタイルシート属性を設定します。 057 */ 058 public TabData( final String text,final String name,final String body, 059 final boolean openFlag,final String style ) { 060 this.text = text; 061 this.name = name; 062 this.body = body; 063 this.openFlag = openFlag; 064 this.style = style; 065 } 066 067 // 5.9.1.3 (2015/10/30) 削除 068// /** 069// * tab のタグを作成して返します。 070// * 071// * 引数の style が、null でなければ、defaultStyle と selectedStyle に設定します。 072// * また、タブ単独に直接指定されている場合は、そちらが優先されます。 073// * 074// * @param inStyle 外部より指定されるスタイル 075// * 076// * @return tabのタグ 077// */ 078// public String getTab( final String inStyle ) { 079// return "<ts:tab " + getStyleString( style,inStyle ) + " text=\"" + text + "\" />" ; 080// } 081 082 /** 083 * tab用 のタグを作成して返します。 084 * 085 * 引数の style が、null でなければ、defaultStyle と selectedStyle に設定します。 086 * また、タブ単独に直接指定されている場合は、そちらが優先されます。 087 * 088 * @og.rev 5.9.1.3 (2015/10/30) 引数追加で新規作成 089 * 090 * @param inStyle 外部より指定されるスタイル 091 * @param i ID用数値 092 * 093 * @return tab要のリストタグ 094 */ 095 public String getTab( final String inStyle, int i ) { 096 String id = StringUtil.nval( name,"ogtablist_" + Integer.toString(i) ); 097 return "<li><a href=\"#" + id + "\"><span " + getStyleString( style,inStyle ) + ">" 098 + text + "</span></a></li>" ; 099 } 100 101 // 5.9.1.3 (2015/10/30) 削除 102// /** 103// * pageview のタグを作成して返します。 104// * タブの内容を表示するタグを作成します。 105// * 106// * @return pageviewのタグ 107// * 108// */ 109// public String getTabBody() { 110// return "<mp:pageview id=\"" + name + "\">" + body + "</mp:pageview>" ; 111// } 112 113 /** 114 * pageview のタグを作成して返します。 115 * タブの内容を表示するタグを作成します。 116 * 117 * @return pageviewのタグ 118 * 119 * @param i id用数値 120 * 121 */ 122 public String getTabBody( int i ) { 123 String id = StringUtil.nval( name,"ogtablist_" + Integer.toString(i) ); 124 return "<div id=\"" + id + "\">" + body + "</div>" ; 125 } 126 127 /** 128 * タブが選択されているかどうか(true:選択/false:通常)を取得します。 129 * 130 * タブが選択されるかどうかは、tabTag の term,termList が成立するか、 131 * tabTableTag で、selectedIndex 指定されるかです。 132 * 133 * @og.rev 3.8.6.1 (2006/10/24) 新規追加 134 * 135 * @return タブが選択されているかどうか(true:選択/false:通常) 136 */ 137 public boolean isOpen() { 138 return openFlag ; 139 } 140 141 /** 142 * defaultStyle と selectedStyle を指定した style属性を作成します。 143 * 144 * style属性 は、このタブ構築時に指定されたスタイル(defStyle)が優先されます。 145 * これが null の場合は、外部より指定されるスタイル(inStyle)を適用します。 146 * それも null の場合は、ゼロ文字列を返します。 147 * 148 * @og.rev 5.9.1.3 (2015/10/30) 変更 149 * 150 * @param defStyle このタブ構築時に指定されたスタイル(優先) 151 * @param inStyle 外部より指定されるスタイル 152 * 153 * @return style属性 154 */ 155 private String getStyleString( final String defStyle, final String inStyle ) { 156 String tmp = ( defStyle != null ) ? defStyle : inStyle ; 157 158 String rtn = ""; 159 if( tmp != null ) { 160// rtn = "defaultStyle=\"" + tmp + "\" selectedStyle=\"" + tmp + "\""; 161 rtn = " style=\"" + tmp + "\" "; 162 } 163 164 return rtn ; 165 } 166}