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