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