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.hayabusa.db.DBTableModel; 020import org.opengion.hayabusa.html.AbstractViewForm; 021import org.opengion.hayabusa.html.TableFormatter; // 6.3.9.0 (2015/11/06) 022import org.opengion.fukurou.model.Formatter; 023import org.opengion.fukurou.util.StringUtil; 024 025/** 026 * 検索結果を自動的に表形式に変換する、テーブル作成クラスです。 027 * 028 * AbstractViewForm により、setter/getterメソッドのデフォルト実装を提供しています。 029 * 各HTMLのタグに必要な setter/getterメソッドのみ、追加定義しています。 030 * 031 * AbstractViewForm を継承している為、ロケールに応じたラベルを出力させる事が出来ます。 032 * 033 * @og.group 画面表示 034 * 035 * @version 4.0 036 * @author Kazuhiko Hasegawa 037 * @since JDK5.0, 038 */ 039public class ViewForm_HTMLTable extends AbstractViewForm { 040 /** このプログラムのVERSION文字列を設定します。 {@value} */ 041 private static final String VERSION = "8.0.1.0 (2021/11/02)" ; 042 043 // 3.6.0.0 (2004/09/17) チェック済みの行の先頭に、フォーカスを当てる処理 044 private static final String LAYER_FOCUS = "<a href=\"#top\" name=\"h_fcs\" id=\"h_fcs\" ></a>" ; 045 046 // 6.4.4.1 (2016/03/18) static final 定数化します。 047 // 7.0.4.0 (2019/05/31) colgroup 廃止 048// protected static final String NUMBER_DISPLAY = "<colgroup class=\"X\" ><!-- --></colgroup><colgroup class=\"BIT\" ><!-- --></colgroup><colgroup class=\"S9\" ><!-- --></colgroup>" + CR ; 049 050 // 5.2.3.0 (2010/12/01) テーブル罫線対応 051// private final String tableParam = HybsSystem.sys( "HTML_TABLE_PARAM" ) ; // 6.9.5.0 (2018/04/23) 廃止 052 private final boolean useRowId = HybsSystem.sysBool( "USE_CHECKBOX_ROW_ID" ) ; // 3.6.0.0 (2004/09/17) 053 054// // 6.1.2.0 (2015/01/24) HTML5 で colgroup が効かない対応で、protected化します。 055// // 6.9.5.0 (2018/04/23) USE_IE7_HEADER 廃止(false固定) 056// protected final boolean useIE7Header = HybsSystem.sysBool( "USE_IE7_HEADER" ); // 5.7.5.0 (2014/04/04) HTML5 で colgroup が効かない対応 057 058 /** ヘッダー部分のキャッシュ変数 */ 059 protected String headerLine ; // 3.5.2.0 (2003/10/20) 060 061 private String cacheTag ; // 3.5.5.5 (2004/04/23) 062 private int[] popupClmNo ; // 3.8.6.1 (2006/10/20) 063 064 /** 065 * デフォルトコンストラクター 066 * 067 * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. 068 */ 069 public ViewForm_HTMLTable() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 070 071 /** 072 * 内容をクリア(初期化)します。 073 * 074 * @og.rev 3.1.1.0 (2003/03/28) 同期メソッド(synchronized付き)を非同期に変更する。 075 * @og.rev 3.5.2.0 (2003/10/20) ヘッダー繰り返し属性( headerSkipCount )を採用 076 * @og.rev 3.5.5.5 (2004/04/23) cacheTag,isCache 属性追加(チェックボックス作成用) 077 * @og.rev 3.5.6.2 (2004/07/05) bgColorCycle 変数の削除。 078 * @og.rev 3.8.6.1 (2006/10/20) popup の値を返す為のカラム番号配列(popupClmNo)追加 079 * @og.rev 5.1.6.0 (2010/05/01) caption 属性が使われていないため、削除する。 080 */ 081 @Override 082 public void clear() { 083 super.clear(); 084 cacheTag = null; // 3.5.5.5 (2004/04/23) 085 popupClmNo = null; // 3.8.6.1 (2006/10/20) 086 } 087 088 /** 089 * DBTableModel から HTML文字列を作成して返します。 090 * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。 091 * 表示残りデータが pageSize 以下の場合は、残りのデータをすべて出力します。 092 * 093 * @og.rev 3.5.2.0 (2003/10/20) ヘッダー繰り返し属性( headerSkipCount )を採用 094 * @og.rev 3.5.3.1 (2003/10/31) skip属性を採用。headerLine のキャッシュクリア 095 * @og.rev 3.5.5.0 (2004/03/12) No 欄そのものの作成判断ロジックを追加 096 * @og.rev 3.5.6.4 (2004/07/16) ヘッダーとボディー部をJavaScriptで分離 097 * @og.rev 3.7.0.3 (2005/03/01) getBgColorCycleClass に、選択行マーカーを採用 098 * @og.rev 4.3.1.0 (2008/09/08) 編集行のみを表示する属性(isSkipNoEdit)追加 099 * @og.rev 4.3.3.0 (2008/10/01) noTransition属性対応 100 * @og.rev 6.8.1.1 (2017/07/22) ckboxTD変数は、<td> から <td に変更します(タグの最後が記述されていない状態でもらう)。 101 * @og.rev 8.0.1.0 (2021/11/02) tdClassClms,tdClass追加 102 * 103 * @param startNo 表示開始位置 104 * @param pageSize 表示件数 105 * 106 * @return DBTableModelから作成された HTML文字列 107 * @og.rtnNotNull 108 */ 109 public String create( final int startNo, final int pageSize ) { 110 if( getRowCount() == 0 ) { return ""; } // 暫定処置 111 112 headerLine = null; 113 final int lastNo = getLastNo( startNo, pageSize ); 114 final int blc = getBackLinkCount(); 115 final int hsc = getHeaderSkipCount(); // 3.5.2.0 (2003/10/20) 116 int hscCnt = 1; // 3.5.2.0 (2003/10/20) 117 118 final StringBuilder out = new StringBuilder( BUFFER_LARGE ) 119 .append( getCountForm( startNo,pageSize ) ) 120 .append( getHeader() ); 121 122 final String ckboxTD = " <td"; // 6.8.1.1 (2017/07/22) 123 124 out.append("<tbody>").append( CR ); 125 int bgClrCnt = 0; 126 final int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10) 127 for( int row=startNo; row<lastNo; row++ ) { 128 if( isSkip( row ) || isSkipNoEdit( row ) ) { continue; } // 4.3.1.0 (2008/09/08) 129 out.append(" <tr").append( getBgColorCycleClass( bgClrCnt++,row ) ); 130 if( isNoTransition() ) { // 4.3.3.0 (2008/10/01) 131 out.append( getHiddenRowValue( row ) ); 132 } 133 out.append('>').append( CR ); // 6.0.2.5 (2014/10/31) char を append する。 134 // 3.5.5.0 (2004/03/12) No 欄そのものの作成判断追加 135 if( isNumberDisplay() ) { 136 out.append( makeCheckbox( ckboxTD, row, blc ) ).append( CR ); 137 } 138 for( int column=0; column<clmCnt; column++ ) { 139 if( isColumnDisplay( column ) ) { 140 // 8.0.1.0 (2021/11/02) tdClassClms,tdClass追加 141 out.append(" <td" ).append( getTdClass( column ) ).append( '>' ) 142 // out.append(" <td>") 143 .append( getValueLabel(row,column) ) 144 .append("</td>").append( CR ); 145 } 146 } 147 out.append(" </tr>").append( CR ); 148 149 // 3.5.2.0 (2003/10/20) ヘッダー繰り返し属性( headerSkipCount )を採用 150 if( hsc > 0 && hscCnt % hsc == 0 ) { 151 out.append( getHeadLine() ); 152 hscCnt = 1; 153 } 154 else { 155 hscCnt ++ ; 156 } 157 } 158 out.append("</tbody>").append( CR ) 159 .append("</table>").append( CR ) 160 .append( getScrollBarEndDiv() ); // 3.8.0.3 (2005/07/15) 161 162 return out.toString(); 163 } 164 165 /** 166 * 選択用のチェックボックスと行番号と変更タイプ(A,C,D)を表示します。 167 * 168 * 行番号の個別に、class="S9" を入れる処理を行うための新しいメソッドを作成しました。 169 * 互換性を保つためのメソッドを追加します。 170 * 171 * @og.rev 6.8.1.1 (2017/07/22) 互換性を保つためのメソッド 172 * 173 * @param ckboxTD チェックボックスのタグ(マルチカラム時のrowspan対応) 174 * @param row 行番号 175 * @param blc バックラインカウント(先頭へ戻るリンク間隔) 176 * 177 * @return tdタグで囲まれたチェックボックスのHTML文字列 178 * @og.rtnNotNull 179 */ 180 protected String makeCheckbox( final String ckboxTD,final int row,final int blc ) { 181 return makeCheckbox( ckboxTD, row, blc, false ); 182 } 183 184 /** 185 * 選択用のチェックボックスと行番号と変更タイプ(A,C,D)を表示します。 186 * 187 * フォーマット系のViewに、makeNthChild を適用すると、思わぬ所で、副作用が発生します。 188 * その場合は、データ量は増えますが、個々の行番号欄に、class="S9" を入れていくのが 189 * もっとも確実な方法です。その切替を、useS9 変数で行います。 190 * 191 * @og.rev 3.5.1.0 (2003/10/03) Noカラムに、numberType 属性を追加 192 * @og.rev 3.5.4.0 (2003/11/25) Formatter をローカル変数に変更 193 * @og.rev 3.5.4.1 (2003/12/01) table オブジェクトのセット廃止 194 * @og.rev 3.5.5.5 (2004/04/23) Attributes オブジェクトのセット廃止 195 * @og.rev 3.6.0.0 (2004/09/17) ガントチャートの移動時にチェックするためのIDを追加 196 * @og.rev 3.6.0.0 (2004/09/17) チェック済みの行の先頭に、フォーカスを当てる処理を追加 197 * @og.rev 3.8.6.1 (2006/10/20) popup 用の値を設定する機能を追加 198 * @og.rev 6.4.3.4 (2016/03/11) Formatterに新しいコンストラクターを追加する。 199 * @og.rev 6.8.1.1 (2017/07/22) ckboxTD変数は、<td> から <td に変更します(タグの最後が記述されていない状態でもらう)。 200 * @og.rev 6.8.1.1 (2017/07/22) 行番号のtdに、個別に class="S9" を追加するための useS9 変数を追加。 201 * @og.rev 7.0.1.0 (2018/10/15) XHTML → HTML5 対応(空要素の、"/>" 止めを、">" に変更します)。 202 * 203 * @param ckboxTD チェックボックスのタグ(マルチカラム時のrowspan対応) 204 * @param row 行番号 205 * @param blc バックラインカウント(先頭へ戻るリンク間隔) 206 * @param useS9 trueにすると、行番号のtdに、class="S9" を個別に入れます。 207 * 208 * @return tdタグで囲まれたチェックボックスのHTML文字列 209 * @og.rtnNotNull 210 */ 211 protected String makeCheckbox( final String ckboxTD,final int row,final int blc,final boolean useS9 ) { 212 213 final DBTableModel table = getDBTableModel() ; 214 215 // 6.3.9.0 (2015/11/06) Found 'DD'-anomaly for variable(PMD) 216 final String opAtt; 217 final String fmt = getOptionTypeAttributes(); 218 if( fmt == null ) { 219 opAtt = null; // 6.3.9.0 (2015/11/06) 220 } 221 else { 222 final Formatter format = new Formatter( table,fmt ); // 6.4.3.4 (2016/03/11) 223 opAtt = format.getFormatString( row ); 224 } 225 226 final StringBuilder out = new StringBuilder( BUFFER_MIDDLE ) 227 .append( ckboxTD ).append( '>' ) // 6.8.1.1 (2017/07/22) 228 .append( table.getModifyType( row ) ) 229 .append("</td>") 230 .append( ckboxTD ).append( '>' ); // 6.8.1.1 (2017/07/22) 231 232 // 3.5.5.5 (2004/04/23) Attributes オブジェクトのセット廃止 233 final String inputTag = makeChboxTag(); 234 if( isWritable( row ) && inputTag != null ) { 235 out.append( inputTag ); 236 if( opAtt != null ) { out.append( opAtt ); } 237 if( isChecked( row ) ) { 238 out.append( " checked=\"checked\"" ); 239 } 240 if( useRowId ) { // 3.6.0.0 (2004/09/17) 241 out.append( " id=\"" ) 242 .append( HybsSystem.ROW_ID_KEY ) 243 .append( row ).append( '"' ); // 6.0.2.5 (2014/10/31) char を append する。 244 } 245 if( popupClmNo != null ) { // 3.8.6.1 (2006/10/20) 246 makePopupReturn( out,row ); // 内部で StringBuilder に append しています。 247 } 248// out.append( " value=\"" ).append( row ).append( "\" />" ); 249 out.append( " value=\"" ).append( row ).append( "\" >" ); // 7.0.1.0 (2018/10/15) 250 } 251 out.append("</td>" ); 252 // 6.8.1.1 (2017/07/22) useS9 変数を追加 253 if( useS9 ) { 254 final int ad = ckboxTD.indexOf( "class=" ); // class がすでに登録済みの場合 255 if( ad >= 0 ) { 256 out.append( ckboxTD.substring( 0,ad+7 ) ).append( "S9 " ) // +7 は、( class=" ) の文字数 257 .append( ckboxTD.substring( ad+7 ) ).append( '>' ); 258 } 259 else { 260 out.append( ckboxTD ).append( " class=\"S9\">"); 261 } 262 } 263 else { 264 out.append( ckboxTD ).append( '>' ); 265 } 266 267 // 3.5.1.0 (2003/10/03) Noカラムに、numberType 属性を追加 268 if( blc != 0 && (row+1) % blc == 0 ) { 269 out.append( "<a href=\"#top\">" ).append( getNumberData( row ) ).append( "</a>"); 270 } else { 271 out.append( getNumberData( row ) ); 272 } 273 274 // 4.3.5.3 (2008/02/22) Focus2のアンカー位置をtdタグ内に変更 275 if( isFirstChecked( row ) ) { 276 out.append( LAYER_FOCUS ); 277 } 278 out.append("</td>"); 279 // if( isFirstChecked( row ) ) { 280 // out.insert( 0,LAYER_FOCUS ); 281 // } 282 283 return out.toString(); 284 } 285 286 /** 287 * DBTableModel から テーブルのヘッダータグ文字列を作成して返します。 288 * 289 * @og.rev 3.5.2.0 (2003/10/20) ヘッダーそのもののキャッシュはしない。 290 * 291 * @return テーブルのヘッダータグ文字列 292 * @og.rtnNotNull 293 */ 294 protected String getHeader() { 295 return getTableTag() + getTableHead() ; 296 } 297 298 /** 299 * DBTableModel から テーブルのタグ文字列を作成して返します。 300 * 301 * @og.rev 3.5.0.0 (2003/09/17) <tr>属性は、元のフォーマットのまま使用します。 302 * @og.rev 3.5.1.0 (2003/10/03) Noカラムに、numberType 属性を追加 303 * @og.rev 3.5.4.0 (2003/11/25) TableFormatter クラスを使用するように変更。 304 * @og.rev 3.5.4.7 (2004/02/06) ヘッダーにソート機能用のリンクを追加します。 305 * @og.rev 3.5.5.0 (2004/03/12) systemFormat(例:[KEY.カラム名]形式等)の対応 306 * @og.rev 3.5.5.0 (2004/03/12) No 欄そのものの作成判断ロジックを追加 307 * @og.rev 6.2.0.0 (2015/02/27) フォーマット系の noDisplay 対応 308 * @og.rev 6.3.9.0 (2015/11/06) 引数にTableFormatterを渡して、処理の共有化を図る。 309 * 310 * @param footerFormat TableFormatterオブジェクト 311 * @return テーブルのタグ文字列 312 * @og.rtnNotNull 313 */ 314 protected String getTableFoot( final TableFormatter footerFormat ) { 315 footerFormat.makeFormat( getDBTableModel() ); 316 // 6.2.0.0 (2015/02/27) フォーマット系の noDisplay 対応 317 setFormatNoDisplay( footerFormat ); 318 319 final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE ) 320 .append("<tfoot>").append( CR ) 321 .append( footerFormat.getTrTag() ).append( CR ); 322 323 // 3.5.5.0 (2004/03/12) No 欄そのものの作成判断追加 324 if( isNumberDisplay() ) { 325 buf.append("<th colspan=\"3\"") 326 .append( footerFormat.getRowspan() ) 327 .append("></th>"); 328 } 329 330 int cl = 0; 331 for( ; cl<footerFormat.getLocationSize(); cl++ ) { 332 final int loc = footerFormat.getLocation(cl); 333 if( loc >= 0 ) { buf.append( getSortedColumnLabel(loc) ); } 334 } 335 buf.append( footerFormat.getFormat(cl) ).append( CR ) 336 .append("</tfoot>").append( CR ); 337 338 return buf.toString(); 339 } 340 341 /** 342 * DBTableModel から テーブルのタグ文字列を作成して返します。 343 * 344 * @og.rev 3.5.6.4 (2004/07/16) ヘッダーとボディー部をJavaScriptで分離 345 * @og.rev 3.6.0.0 (2004/09/17) ヘッダー固定スクロールの簡素化(スクロールバーを右に出す) 346 * @og.rev 3.6.0.5 (2004/10/18) 印刷時の罫線出力関連機能の追加。id 属性を出力します。 347 * @og.rev 4.0.0.0 (2005/08/31) テーブル表示の CSSファイル利用の有無 348 * @og.rev 5.1.6.0 (2010/05/01) caption 属性が使われていないため、削除する。 349 * @og.rev 5.2.3.0 (2010/12/01) テーブル罫線対応 350 * @og.rev 5.3.4.0 (2011/04/01) テーブル罫線の初期値チェック変更 351 * @og.rev 6.9.5.0 (2018/04/23) tableParam 廃止 352 * 353 * @return テーブルのタグ文字列 354 * @og.rtnNotNull 355 */ 356 protected String getTableTag() { 357 return new StringBuilder( BUFFER_MIDDLE ) 358 .append( getScrollBarStartDiv() ) // 3.8.0.3 (2005/07/15) 359 .append( "<table id=\"viewTable\" class=\"" ) 360 .append( getTableClass() ) 361 .append( "\">" ).append( CR ) 362 .toString(); 363 364// // 6.9.7.0 (2018/05/14) 整理します。 365// final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE ) 366// .append( getScrollBarStartDiv() ) // 3.8.0.3 (2005/07/15) 367// .append("<table "); 368// // 5.2.3.0 (2010/12/01) テーブル罫線対応 369//// if( tableParam != null && !tableParam.isEmpty() ) { // 6.9.5.0 (2018/04/23) tableParam 廃止 370//// buf.append( tableParam ).append( ' ' ); // 6.0.2.5 (2014/10/31) char を append する。 371//// } 372// buf.append( "id=\"viewTable\" class=\"" ) 373// .append( getTableClass() ) 374// .append( "\">" ).append( CR ); 375// 376// return buf.toString(); 377 } 378 379 /** 380 * HTML5 で colgroup が効かない暫定対応の、処理をまとめるメソッド 381 * 382 * #viewTable td:nth-child(n) { text-align:right; } CSSを出力するメソッドをまとめました。 383 * 呼び出し元の、getTableHead() のコードをすっきりさせるためのメソッドです。 384 * 385 * @og.rev 5.7.5.0 (2014/04/04) 新規追加 386 * @og.rev 6.1.2.0 (2015/01/24) 他のクラスでも使用する為、protected化します。 387 * @og.rev 5.9.5.3 (2016/02/26) viewTableにtableIdのクラスを追加する対応 388 * @og.rev 6.4.4.1 (2016/03/18) StringBuilderのappend部分の見直し。 389 * @og.rev 6.4.4.2 (2016/04/01) className に BIT が指定された場合の対応。 390 * @og.rev 6.4.6.1 (2016/06/03) tableId 廃止(利用目的を明確にするため、パラメータ名をviewClassに変更) 391 * @og.rev 6.4.6.1 (2016/06/03) DbType とClassName が複雑化しているため、とりあえずの暫定対策。 392 * 393 * @param buf タグ文字列をappendしていくStringBuilder 394 * @param ad TDタグの番号 nth-child(n)設置する場合の n の値 395 * @param dbType text-alignを決めるためのDBTYPE 396 * (R,S9,X9→text-align:right; , BIT→text-align:center; , left) 397 * 398 * @return テーブルのタグ文字列(入力と同じStringBuilder) 399 * @og.rtnNotNull 400 * @see #getTableHead() 401 */ 402 protected StringBuilder makeNthChild( final StringBuilder buf , final int ad , final String dbType ) { 403 // 6.4.6.1 (2016/06/03) DbType とClassName が複雑化しているため、とりあえずの暫定対策。 404 // 従来の dbType には、R,S9,X9 などが、単独で来ます。 405 // BIT は、ClassName に含まれており、R,S9,X9 も、スペース連結で含まれます。 406 // 先に、BIT判定を行います。 407 int hantei = 0; // 0:は素通りする。 408 if( dbType != null ) { // たぶん、不要 409 if( dbType.contains( "BIT" ) ) { hantei = 2; } 410 else { 411 final String type = " " + dbType + " " ; 412 if( type.contains( " R " ) || type.contains( " S9 " ) || type.contains( " X9 " ) ) { hantei = 1; } 413 } 414 } 415 416 if( hantei == 1 ) { // 6.4.6.1 (2016/06/03) 417 buf.append( " #viewTable." ).append( getViewClass() ).append( " td:nth-child(" ).append( ad ) 418 .append( ") { text-align:right; }" ).append( CR ); 419 } 420 else if( hantei == 2 ) { // 6.4.6.1 (2016/06/03) 421 buf.append( " #viewTable." ).append( getViewClass() ).append( " td:nth-child(" ).append( ad ) 422 .append( ") { text-align:center; }" ).append( CR ); 423 } 424 // 上記(R,S9,X9,BIT)以外のdbTypeの場合は、素通りします。(入力のStringBuilderをそのまま返すだけ) 425 426 return buf ; 427 } 428 429 /** 430 * DBTableModel から テーブルのタグ文字列を作成して返します。 431 * 432 * @og.rev 3.5.1.0 (2003/10/03) Noカラムに、numberType 属性を追加 433 * @og.rev 3.5.2.0 (2003/10/20) ヘッダー繰り返し部をgetHeadLine()へ移動 434 * @og.rev 3.5.3.1 (2003/10/31) VERCHAR2 を VARCHAR2 に修正。 435 * @og.rev 3.5.5.0 (2004/03/12) No 欄そのものの作成判断ロジックを追加 436 * @og.rev 3.5.6.5 (2004/08/09) thead に、id="header" を追加 437 * @og.rev 4.0.0.0 (2005/01/31) DBColumn の 属性(CLS_NM)から、DBTYPEに変更 438 * @og.rev 4.0.0.0 (2005/01/31) 新規作成(getColumnClassName ⇒ getColumnDbType) 439 * @og.rev 5.7.5.0 (2014/04/04) HTML5 で colgroup が効かない暫定対応(真の原因不明) 440 * @og.rev 5.9.1.2 (2015/10/23) 自己終了警告対応 441 * @og.rev 6.4.4.1 (2016/03/18) NUMBER_DISPLAYを、static final 定数化します。 442 * @og.rev 6.4.5.0 (2016/04/08) メソッド変更( getColumnDbType(int) → getClassName(int) ) 443 * @og.rev 6.4.6.1 (2016/06/03) DbType とClassName が複雑化しているため、とりあえずの暫定対策。 444 * @og.rev 6.8.1.0 (2017/07/14) HTML5対応ヘッダー出力設定時に、ブラウザを互換設定したときの対応。 445 * @og.rev 6.9.5.0 (2018/04/23) USE_IE7_HEADER 廃止(false固定) 446 * @og.rev 7.0.4.0 (2019/05/31) colgroup 廃止 447 * 448 * @return テーブルのタグ文字列 449 * @og.rtnNotNull 450 */ 451 protected String getTableHead() { 452 final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE ); 453 454 // 5.7.5.0 (2014/04/04) HTML5 で colgroup が効かない対応 455 // 本当は、tableタグの前に入れたかったが、ややこしいので table タグの直後に入れます。 456 // 互換モードでない場合専用。処理速度を気にするより、処理を一か所にまとめておきます。 457 // 6.9.5.0 (2018/04/23) USE_IE7_HEADER 廃止(false固定) 458// if( !useIE7Header ) { 459 // 8.1.0.0 (2021/12/28) HTML5 準拠に見直し(type="text/css" 不要) 460// buf.append( "<style type=\"text/css\">" ).append( CR ); 461 buf.append( "<style>" ).append( CR ); 462 // 6.3.9.0 (2015/11/06) Found 'DD'-anomaly for variable(PMD) 463 int ad = 1; 464 // int ad ; 465 if( isNumberDisplay() ) { 466 makeNthChild( buf,2,"BIT" ); 467 makeNthChild( buf,3,"S9" ); 468 ad = 4; 469 } 470 // else { 471 // ad = 1; // 6.3.9.0 (2015/11/06) 472 // } 473 474 final int clmCnt = getColumnCount(); 475 for( int column=0; column<clmCnt; column++ ) { 476 if( isColumnDisplay( column ) ) { 477 // 6.4.6.1 (2016/06/03) DbType とClassName が複雑化しているため、とりあえずの暫定対策。 478 makeNthChild( buf,ad,getClassName(column) ); // 6.4.6.1 (2016/06/03) 479 ad++ ; // tdタグの順番なので、表示する場合のみカウントする。 480 } 481 } 482 buf.append( "</style>" ).append( CR ); 483// } 484 485// // 3.5.5.0 (2004/03/12) No 欄そのものの作成判断追加 486// // 7.0.4.0 (2019/05/31) colgroup 廃止 487// if( isNumberDisplay() ) { 488// // 5.9.1.2 (2015/10/23) 自己終了警告対応 489// // 6.4.4.1 (2016/03/18) NUMBER_DISPLAYを、static final 定数化します。 490// buf.append( NUMBER_DISPLAY ); // 6.8.1.0 (2017/07/14) HTML5ネイティブ時でも、出力します。 491// } 492 493// final int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10) 6.9.5.0 (2018/04/23) useIE7Header の if を削除したため、宣言不要 494 // 7.0.4.0 (2019/05/31) colgroup 廃止 495// for( int column=0; column<clmCnt; column++ ) { 496// if( isColumnDisplay( column ) ) { 497// buf.append("<colgroup class=\"" ) 498// .append( getClassName(column) ) // 6.4.5.0 (2016/04/08) 499// // 5.9.1.2 (2015/10/23) 自己終了警告対応 500// .append("\"><!-- --></colgroup>") 501// .append( CR ); 502// } 503// } 504 505 // 3.5.2.0 (2003/10/20) ヘッダー繰り返し部をgetHeadLine()へ移動 506 buf.append("<thead id=\"header\">").append( CR ) // 3.5.6.5 (2004/08/09) 507 .append( getHeadLine() ) 508 .append("</thead>").append( CR ); 509 510 return buf.toString(); 511 } 512 513 /** 514 * ヘッダー繰り返し部を、getTableHead()メソッドから分離。 515 * 516 * @og.rev 3.5.4.5 (2004/01/23) 実装をgetHeadLine( String thTag )に移動 517 * @og.rev 6.1.2.0 (2015/01/24) キャッシュを返すのを、#getHeadLine() に移動。 518 * 519 * @return テーブルのタグ文字列 520 * @og.rtnNotNull 521 */ 522 protected String getHeadLine() { 523 if( headerLine == null ) { // キャッシュになければ、設定する。 524 headerLine = getHeadLine( "<th" ) ; 525 } 526 527 return headerLine ; 528 } 529 530 /** 531 * ヘッダー繰り返し部を、getTableHead()メソッドから分離。 532 * 533 * @og.rev 3.5.2.0 (2003/10/20) 新規作成 534 * @og.rev 3.5.4.3 (2004/01/05) useCheckControl 属性の機能を追加 535 * @og.rev 3.5.4.5 (2004/01/23) thタグの属性設定出来る様に新規追加。 536 * @og.rev 3.5.4.6 (2004/01/30) numberType="none" 時の処理を追加(Noラベルを出さない) 537 * @og.rev 3.5.4.7 (2004/02/06) ヘッダーにソート機能用のリンクを追加します。 538 * @og.rev 3.7.0.1 (2005/01/31) 全件チェックコントロール処理変更 539 * @og.rev 6.1.2.0 (2015/01/24) キャッシュを返すのを、#getHeadLine() に移動。 540 * @og.rev 6.9.8.1 (2018/06/11) 読み取り専用(writable="false") の場合のNo欄対応 541 * @og.rev 8.0.1.0 (2021/11/02) tdClassClms,tdClass追加 542 * 543 * @param thTag タグの文字列 544 * 545 * @return テーブルのタグ文字列 546 * @og.rtnNotNull 547 */ 548 protected String getHeadLine( final String thTag ) { 549 550 final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE ) 551 .append("<tr class=\"row_h\">").append( CR ); 552 553 // 3.5.5.0 (2004/03/12) No 欄そのものの作成判断追加 554 if( isNumberDisplay() ) { 555 // 3.5.4.3 (2004/01/05) 追加分 556 if( isUseCheckControl() && "checkbox".equals( getSelectedType() ) ) { 557 // 3.5.4.5 (2004/01/23) thタグの属性設定出来る様に変更。 558 // 6.0.2.5 (2014/10/31) char を append する。 559 buf.append( thTag ).append( "></th>" ) 560 .append( thTag ).append( '>' ).append( getAllCheckControl() ).append( "</th>" ) 561 .append( thTag ).append( '>' ).append( getNumberHeader() ).append( "</th>" ); // 3.5.4.6 (2004/01/30) 562 } 563 else { 564 // 3.5.4.5 (2004/01/23) thタグの属性設定出来る様に変更。 565 // 6.9.8.1 (2018/06/11) 読み取り専用(writable="false") の場合のNo欄対応 566// buf.append( thTag ).append( " colspan='3'>" ).append( getNumberHeader() ).append( "</th>" ); // 3.5.4.6 (2004/01/30) 567 buf.append( thTag ).append( "></th>" ) 568 .append( thTag ).append( "></th>" ) 569 .append( thTag ).append( '>' ).append( getNumberHeader() ).append( "</th>" ); // 3.5.4.6 (2004/01/30) 570 } 571 } 572 573 buf.append( CR ); 574 final int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10) 575 for( int column=0; column<clmCnt; column++ ) { 576 if( isColumnDisplay( column ) ) { 577 // 3.5.4.5 (2004/01/23) thタグの属性設定出来る様に変更。 578 // 8.0.1.0 (2021/11/02) tdClassClms,tdClass追加 579 buf.append( thTag ).append( getTdClass( column ) ).append( '>' ) 580 // buf.append( thTag ).append('>') // 6.0.2.5 (2014/10/31) char を append する。 581 .append( getSortedColumnLabel(column) ) 582 .append("</th>").append( CR ); 583 } 584 } 585 buf.append("</tr>").append( CR ); 586 587 return buf.toString(); // 6.1.2.0 (2015/01/24) 588 } 589 590 /** 591 * フォーマットメソッドを使用できるかどうかを問い合わせます。 592 * 593 * @return 使用可能(true)/ 使用不可能(false) 594 */ 595 public boolean canUseFormat() { 596 return false; 597 } 598 599 /** 600 * ogPopup で検索結果の値を返すキーを、CSV形式で指定します。 601 * 602 * popup の検索結果を返す画面で、結果のラジオボタンにイベントセットします。 603 * この場合、オープンもとのwindow に値を返しますが、そのキーをCSV形式で 604 * 指定します。なお、設定は、init 以降(つまり、DBTableModelは設定済み)の 605 * 状態で呼び出してください。(エラーにしません) 606 * なお、このメソッドは、一覧表示(HTMLTable)関係のビューのみでサポートして 607 * いますが、チェックメソッドの関係で、それ以外のビューに適用しても素通り 608 * するようにします。(エラーにしません) 609 * 610 * @og.rev 3.8.6.1 (2006/10/20) 新規追加 611 * 612 * @param rtnKeys ogPopupで値を返すカラム文字列(CSV形式) 613 */ 614 @Override 615 public void setPopupReturnKeys( final String rtnKeys ) { 616 final DBTableModel table = getDBTableModel() ; 617 if( table != null && table.getRowCount() > 0 && rtnKeys != null ) { 618 final String[] clmNames = StringUtil.csv2Array( rtnKeys ); 619 popupClmNo = new int[clmNames.length]; 620 for( int i=0; i<clmNames.length; i++ ) { 621 final int no = table.getColumnNo( clmNames[i] ); 622 if( no >= 0 ) { popupClmNo[ i ] = no; } 623 } 624 } 625 } 626 627 /** 628 * ogPopup で検索結果の値を返すキーを、CSV形式で指定します。 629 * 630 * popup の検索結果を返す画面で、結果のラジオボタンにイベントセットします。 631 * この場合、オープンもとのwindow に値を返しますが、そのキーをCSV形式で 632 * 指定します。なお、設定は、init 以降(つまり、DBTableModelは設定済み)の 633 * 状態で呼び出してください。(エラーにしません) 634 * なお、このメソッドは、一覧表示(HTMLTable)関係のビューのみでサポートして 635 * いますが、チェックメソッドの関係で、それ以外のビューに適用しても素通り 636 * するようにします。(エラーにしません) 637 * rtnPopup に値を渡す場合に、ダブルクオート(")、シングルクオート(')は、 638 * それぞれ、ASCII コード(¥x22、¥x27)に置き換えます。 639 * 640 * @og.rev 3.8.6.1 (2006/10/20) 新規追加 641 * 642 * @param buf StringBuilder 追加するStringBuilderオブジェクト 643 * @param rowNo 列番号 644 * 645 * @return 引数にデータを追加した後の同一オブジェクト 646 * @og.rtnNotNull 647 */ 648 private StringBuilder makePopupReturn( final StringBuilder buf,final int rowNo ) { 649 int clmNo = popupClmNo[ 0 ]; 650 String val = StringUtil.quoteFilter( getValue( rowNo,clmNo ) ); 651 buf.append( " onClick=\"rtnPopup(new Array('" ).append( val ).append( '\'' ); 652 for( int i=1; i<popupClmNo.length; i++ ) { 653 clmNo = popupClmNo[ i ]; 654 val = StringUtil.quoteFilter( getValue( rowNo,clmNo ) ); 655 buf.append( ",'" ).append( val ).append( '\'' ); 656 } 657 buf.append( "));\"" ); 658 659 return buf; 660 } 661 662 /** 663 * 選択用のチェックボックスの input タグを作成します。 664 * 665 * @og.rev 3.5.5.5 (2004/04/23) 新規作成 666 * 667 * @return チェックボックスのinputタグ 668 */ 669 private String makeChboxTag() { 670 // 6.3.9.1 (2015/11/27) A method should have only one exit point, and that should be the last statement in the method.(PMD) 671 if( cacheTag == null ) { 672 final String type = getSelectedType(); // "checkbox"/"radio"/"hidden" 673 674 if( type != null ) { 675 final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE ) 676 .append( "<input type=\"" ).append( type ).append( '"' ) 677 .append( " name=\"" ).append( HybsSystem.ROW_SEL_KEY ).append( '"' ); // 6.0.2.5 (2014/10/31) char を append する。 678 679 cacheTag = buf.toString(); 680 } 681 } 682 return cacheTag ; 683 } 684 685 /** 686 * カラムのラベル名(短)を返します。 687 * カラムの項目名に対して、見える形の文字列を返します。 688 * 一般には、リソースバンドルと組合せて、各国ロケール毎にラベルを 689 * 切替えます。 690 * 691 * @og.rev 4.0.0.0 (2005/01/31) 新規追加( shortLabel を返します。) 692 * 693 * @param column カラム番号 694 * 695 * @return カラムのラベル名(短) 696 */ 697 @Override 698 protected String getColumnLabel( final int column ) { 699 return getDBColumn( column ).getShortLabel(); 700 } 701}