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