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.plugin.view; 017 018import org.opengion.hayabusa.common.HybsSystem; 019import org.opengion.fukurou.util.StringUtil; 020 021/** 022 * 行と列を入れ替えて表示する、テーブル回転表示クラスです。 023 * 024 * このクラスは、表示のみ実行可能です。旧ヘッダー部分は、第一カラムに表示されます。 025 * このビューでは、行と列が入れ替わって表示している為、登録はできません。 026 * 027 * AbstractViewForm により、setter/getterメソッドのデフォルト実装を提供しています。 028 * 各HTMLのタグに必要な setter/getterメソッドのみ,追加定義しています。 029 * 030 * AbstractViewForm を継承している為,ロケールに応じたラベルを出力させる事が出来ます。 031 * 032 * @og.rev 3.5.3.0 (2003/10/27) 新規作成 033 * @og.group 画面表示 034 * 035 * @version 4.0 036 * @author Kazuhiko Hasegawa 037 * @since JDK5.0, 038 */ 039public class ViewForm_HTMLRotationTable extends ViewForm_HTMLTable { 040 //* このプログラムのVERSION文字列を設定します。 {@value} */ 041 private static final String VERSION = "5.1.6.0 (2010/05/01)" ; 042 043 private boolean noClass = false; 044 045 // 4.3.4.4 (2009/01/01) 046// /** 047// * デフォルトコンストラクター 048// * 049// */ 050// public ViewForm_HTMLRotationTable() { 051// super(); 052// super.clear(); 053// } 054 055 /** 056 * DBTableModel から HTML文字列を作成して返します。 057 * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。 058 * 表示残りデータが pageSize 以下の場合は,残りのデータをすべて出力します。 059 * 060 * @og.rev 3.5.3.1 (2003/10/31) BgColorCycleClass の設定不具合修正。 061 * @og.rev 3.5.6.4 (2004/07/16) ヘッダーとボディー部をJavaScriptで分離 062 * @og.rev 3.8.8.5 (2007/03/09) 表示の仕方を修正しました。 063 * @og.rev 4.0.0.0 (2005/01/31) 新規作成(getColumnClassName ⇒ getColumnDbType) 064 * 065 * @param startNo 表示開始位置 066 * @param pageSize 表示件数 067 * 068 * @return DBTableModelから作成された HTML文字列 069 */ 070 @Override 071 public String create( final int startNo, final int pageSize ) { 072 if( getRowCount() == 0 ) { return ""; } // 暫定処置 073 074 int lastNo = getLastNo( startNo, pageSize ); 075 076 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE ); 077 078 out.append( getCountForm( startNo,pageSize ) ); 079 out.append( getHeader() ); 080 081 String clmCls = "<td>"; 082 out.append("<tbody>").append( HybsSystem.CR ); 083 int bgClrCnt = 0; 084 int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10) 085 for(int column = 0; column < clmCnt; column++) { 086 if( !isColumnDisplay( column ) ) { continue; } 087 int dummyRow = bgClrCnt++ ; // 3.8.8.5 (2007/03/09) 088 089 out.append("<tr").append( getBgColorCycleClass( dummyRow ) ).append(">"); 090 out.append( HybsSystem.CR ); 091 // 3.8.8.5 (2007/03/09) numberType 属性を考慮 092 if( isNumberDisplay() ) { 093 out.append( "<td>" ).append( getNumberData( dummyRow ) ).append( "</td>" ); 094 out.append( HybsSystem.CR ); 095 } 096 out.append( "<td>" ); 097 out.append( getColumnLabel(column) ).append("</td>"); 098 out.append( HybsSystem.CR ); 099 100 if( ! noClass ) { 101 clmCls = "<td class=\"" + getColumnDbType(column) + "\" >" ; // 4.0.0 (2005/01/31) 102 } 103 104 for( int row=startNo; row<lastNo; row++ ) { 105 out.append( clmCls ); 106 out.append( getValueLabel(row,column) ); 107 out.append("</td>").append( HybsSystem.CR ); 108 } 109 out.append("</tr>").append( HybsSystem.CR ); 110 } 111 out.append("</tbody>").append( HybsSystem.CR ); 112 out.append("</table>").append( HybsSystem.CR ); 113 114 out.append( getScrollBarEndDiv() ); // 3.8.0.3 (2005/07/15) 115 return out.toString(); 116 } 117 118 /** 119 * 内容をクリア(初期化)します。 120 * 121 */ 122 @Override 123 public void clear() { 124 super.clear(); 125 noClass = false; 126 } 127 128 /** 129 * テーブルのバックグラウンドカラーの値をセットします。 130 * 行番号は, 0から始まるので、偶数を HTML_BG_COLOR_ROW0 、 131 * 奇数行を HTML_BG_COLOR_ROW1 とします。 132 * setBgColorCycle で、設定値変換しています。 133 * なお、このクラスでは、最初の行に、row_h クラス属性を付加します。 134 * 135 * @og.rev 3.8.8.5 (2007/03/09) ヘッダー部の色付け 136 * 137 * @param indx 先頭からの連番( 0から始める ) 138 * 139 * @return 行の色を指定する class 属性( cssファイルで指定 ) 140 */ 141 @Override 142 protected String getBgColorCycleClass( final int indx ) { 143 return ( indx == 0 ) 144 ? " class=\"row_h\"" 145 : super.getBgColorCycleClass( indx ); 146 } 147 148 /** 149 * DBTableModel から テーブルのタグ文字列を作成して返します。 150 * 151 * @og.rev 5.9.1.2 (2015/10/23) 自己終了警告対応 152 * @og.rev 5.9.3.3 (2015/12/26) colgroup対応 153 * 154 * @return テーブルのタグ文字列 155 */ 156 @Override 157 protected String getTableHead() { 158 159 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 160 161 // 5.9.3.3 (2015/12/26) HTML5 で colgroup が効かない対応 162 if( !useIE7Header ) { 163 buf.append( "<style type=\"text/css\">" ) 164 .append( HybsSystem.CR ); 165 if( isNumberDisplay() ) { 166 makeNthChild( buf,1,"S9" ); 167 } 168 buf.append( "</style>" ) 169 .append( HybsSystem.CR ); 170 } 171 172 if( isNumberDisplay() ) { 173// buf.append("<colgroup class=\"S9\">"); 174 buf.append("<colgroup class=\"S9\"><!-- --></colgroup>"); // 5.9.1.2 (2015/10/23) 175 } 176// buf.append("<colgroup class=\"HEADER\" />"); 177 buf.append("<colgroup class=\"HEADER\" ><!-- --></colgroup>"); 178 buf.append(HybsSystem.CR); 179 180 return buf.toString(); 181 } 182 183 /** 184 * フォーマットメソッドを使用できるかどうかを問い合わせます。 185 * 186 * @return 使用可能(true)/ 使用不可能 (false) 187 */ 188 @Override 189 public boolean canUseFormat() { 190 return false; 191 } 192 193 /** 194 * カラムのクラス名(X,S9 など)のセットを行うかどうか指定します。 195 * 196 * "true" で、クラス属性を設定しません。これは、CSSファイルに書かれている属性を 197 * 使用しないことを意味します。 198 * 初期値は、"false" です。 199 * 200 * @param flag クラス名使用の有無(true:使用しない/false:使用する。) 201 */ 202 public void setBodyNoClass( final String flag ) { 203 noClass = StringUtil.nval( flag,noClass ); 204 } 205 206 /** 207 * 表示項目の編集(並び替え)が可能かどうかを返します 208 * 209 * @og.rev 5.1.6.0 (2010/05/01) 新規追加 210 * 211 * @return 表示項目の編集(並び替え)が可能かどうか(false:不可能) 212 */ 213 @Override 214 public boolean isEditable() { 215 return false; 216 } 217}