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 /** 046 * DBTableModel から HTML文字列を作成して返します。 047 * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。 048 * 表示残りデータが pageSize 以下の場合は,残りのデータをすべて出力します。 049 * 050 * @og.rev 3.5.3.1 (2003/10/31) BgColorCycleClass の設定不具合修正。 051 * @og.rev 3.5.6.4 (2004/07/16) ヘッダーとボディー部をJavaScriptで分離 052 * @og.rev 3.8.8.5 (2007/03/09) 表示の仕方を修正しました。 053 * @og.rev 4.0.0.0 (2005/01/31) 新規作成(getColumnClassName ⇒ getColumnDbType) 054 * 055 * @param startNo 表示開始位置 056 * @param pageSize 表示件数 057 * 058 * @return DBTableModelから作成された HTML文字列 059 */ 060 @Override 061 public String create( final int startNo, final int pageSize ) { 062 if( getRowCount() == 0 ) { return ""; } // 暫定処置 063 064 int lastNo = getLastNo( startNo, pageSize ); 065 066 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE ); 067 068 out.append( getCountForm( startNo,pageSize ) ); 069 out.append( getHeader() ); 070 071 String clmCls = "<td>"; 072 out.append("<tbody>").append( HybsSystem.CR ); 073 int bgClrCnt = 0; 074 int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10) 075 for(int column = 0; column < clmCnt; column++) { 076 if( !isColumnDisplay( column ) ) { continue; } 077 int dummyRow = bgClrCnt++ ; // 3.8.8.5 (2007/03/09) 078 079 out.append("<tr").append( getBgColorCycleClass( dummyRow ) ).append(">"); 080 out.append( HybsSystem.CR ); 081 // 3.8.8.5 (2007/03/09) numberType 属性を考慮 082 if( isNumberDisplay() ) { 083 out.append( "<td>" ).append( getNumberData( dummyRow ) ).append( "</td>" ); 084 out.append( HybsSystem.CR ); 085 } 086 out.append( "<td>" ); 087 out.append( getColumnLabel(column) ).append("</td>"); 088 out.append( HybsSystem.CR ); 089 090 if( ! noClass ) { 091 clmCls = "<td class=\"" + getColumnDbType(column) + "\" >" ; // 4.0.0 (2005/01/31) 092 } 093 094 for( int row=startNo; row<lastNo; row++ ) { 095 out.append( clmCls ); 096 out.append( getValueLabel(row,column) ); 097 out.append("</td>").append( HybsSystem.CR ); 098 } 099 out.append("</tr>").append( HybsSystem.CR ); 100 } 101 out.append("</tbody>").append( HybsSystem.CR ); 102 out.append("</table>").append( HybsSystem.CR ); 103 104 out.append( getScrollBarEndDiv() ); // 3.8.0.3 (2005/07/15) 105 return out.toString(); 106 } 107 108 /** 109 * 内容をクリア(初期化)します。 110 * 111 */ 112 @Override 113 public void clear() { 114 super.clear(); 115 noClass = false; 116 } 117 118 /** 119 * テーブルのバックグラウンドカラーの値をセットします。 120 * 行番号は, 0から始まるので、偶数を HTML_BG_COLOR_ROW0 、 121 * 奇数行を HTML_BG_COLOR_ROW1 とします。 122 * setBgColorCycle で、設定値変換しています。 123 * なお、このクラスでは、最初の行に、row_h クラス属性を付加します。 124 * 125 * @og.rev 3.8.8.5 (2007/03/09) ヘッダー部の色付け 126 * 127 * @param indx 先頭からの連番( 0から始める ) 128 * 129 * @return 行の色を指定する class 属性( cssファイルで指定 ) 130 */ 131 @Override 132 protected String getBgColorCycleClass( final int indx ) { 133 return ( indx == 0 ) 134 ? " class=\"row_h\"" 135 : super.getBgColorCycleClass( indx ); 136 } 137 138 /** 139 * DBTableModel から テーブルのタグ文字列を作成して返します。 140 * 141 * @return テーブルのタグ文字列 142 */ 143 @Override 144 protected String getTableHead() { 145 146 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 147 if( isNumberDisplay() ) { 148 buf.append("<colgroup class=\"S9\">"); 149 } 150 buf.append("<colgroup class=\"HEADER\" />"); 151 buf.append(HybsSystem.CR); 152 153 return buf.toString(); 154 } 155 156 /** 157 * フォーマットメソッドを使用できるかどうかを問い合わせます。 158 * 159 * @return 使用可能(true)/ 使用不可能 (false) 160 */ 161 @Override 162 public boolean canUseFormat() { 163 return false; 164 } 165 166 /** 167 * カラムのクラス名(X,S9 など)のセットを行うかどうか指定します。 168 * 169 * "true" で、クラス属性を設定しません。これは、CSSファイルに書かれている属性を 170 * 使用しないことを意味します。 171 * 初期値は、"false" です。 172 * 173 * @param flag クラス名使用の有無(true:使用しない/false:使用する。) 174 */ 175 public void setBodyNoClass( final String flag ) { 176 noClass = StringUtil.nval( flag,noClass ); 177 } 178 179 /** 180 * 表示項目の編集(並び替え)が可能かどうかを返します 181 * 182 * @og.rev 5.1.6.0 (2010/05/01) 新規追加 183 * 184 * @return 表示項目の編集(並び替え)が可能かどうか(false:不可能) 185 */ 186 @Override 187 public boolean isEditable() { 188 return false; 189 } 190}