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; // 5.9.1.3 (2015/10/30) 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 /** 070 * tab用 のタグを作成して返します。 071 * 072 * 引数の style が、null でなければ、defaultStyle と selectedStyle に設定します。 073 * また、タブ単独に直接指定されている場合は、そちらが優先されます。 074 * 075 * @og.rev 5.9.1.3 (2015/10/30) 引数追加で新規作成 076 * 077 * @param inStyle 外部より指定されるスタイル 078 * @param idno ID用数値 079 * 080 * @return tab要のリストタグ 081 */ 082 public String getTab( final String inStyle, final int idno ) { 083 final String id = StringUtil.nval( name,"ogtablist_" + Integer.toString(idno) ); 084 return "<li><a href=\"#" + id + "\"><span " + getStyleString( style,inStyle ) + ">" 085 + text + "</span></a></li>" ; 086 } 087 088 // 5.9.1.3 (2015/10/30) 削除 089 090 /** 091 * pageview のタグを作成して返します。 092 * タブの内容を表示するタグを作成します。 093 * 094 * @og.rev 5.9.1.3 (2015/10/30) 引数追加で新規作成 095 * 096 * @return pageviewのタグ 097 * 098 * @param idno ID用数値 099 */ 100 public String getTabBody( final int idno ) { 101 final String id = StringUtil.nval( name,"ogtablist_" + Integer.toString(idno) ); 102 return "<div id=\"" + id + "\">" + body + "</div>" ; 103 } 104 105 /** 106 * タブが選択されているかどうか(true:選択/false:通常)を取得します。 107 * 108 * タブが選択されるかどうかは、tabTag の term,termList が成立するか、 109 * tabTableTag で、selectedIndex 指定されるかです。 110 * 111 * @og.rev 3.8.6.1 (2006/10/24) 新規追加 112 * 113 * @return タブが選択されているかどうか(true:選択/false:通常) 114 */ 115 public boolean isOpen() { 116 return openFlag ; 117 } 118 119 /** 120 * defaultStyle と selectedStyle を指定した style属性を作成します。 121 * 122 * style属性 は、このタブ構築時に指定されたスタイル(defStyle)が優先されます。 123 * これが null の場合は、外部より指定されるスタイル(inStyle)を適用します。 124 * それも null の場合は、ゼロ文字列を返します。 125 * 126 * @og.rev 5.9.1.3 (2015/10/30) 変更 127 * 128 * @param defStyle このタブ構築時に指定されたスタイル(優先) 129 * @param inStyle 外部より指定されるスタイル 130 * 131 * @return style属性 132 */ 133 private String getStyleString( final String defStyle, final String inStyle ) { 134 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid if (x != y) ..; else ..; 135 final String tmp = defStyle == null ? inStyle : defStyle ; 136 137 return tmp == null ? "" : " style=\"" + tmp + "\" "; 138 139 } 140}