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 */
016 package org.opengion.plugin.view;
017
018 import org.opengion.fukurou.util.StringUtil;
019 import org.opengion.hayabusa.common.HybsSystem;
020 import org.opengion.hayabusa.common.HybsSystemException;
021
022 /**
023 * 検索結果を?動的に表形式に変換する、テーブル作?クラスです?
024 *
025 * ユーザー単位に表示するカラ???、表示可非を?できるように対応します?
026 * setColumnDisplay( final String columnName ) に、指定された?に
027 * 表示すると?HTMLFormatTable の簡易版として用意します?
028 * 各HTMLのタグに?な setter/getterメソ?のみ?追?義して?す?
029 *
030 * AbstractViewForm を継承して?為,ロケールに応じたラベルを?力させる事が出来ます?
031 *
032 * @og.group 画面表示
033 * @og.rev 5.1.6.0 (2010/05/01) 新規作?
034 *
035 * @version 4.0
036 * @author Kazuhiko Hasegawa
037 * @since JDK5.0,
038 */
039 public class ViewForm_HTMLSeqClmTable extends ViewForm_HTMLTable {
040 //* こ?プログラ??VERSION??を設定します? {@value} */
041 private static final String VERSION = "5.5.4.2 (2012/07/13)" ;
042
043 private int[] clmNo = null; // 5.1.6.0 (2010/05/01)
044 private int clmCnt = -1; // 5.1.6.0 (2010/05/01)
045
046 private String viewClms = null; //
047
048 /**
049 * DBTableModel から HTML??を作?して返します?
050 * startNo(表示開始位置)から、pageSize(表示件数)までのView??を作?します?
051 * 表示残り??タ?pageSize 以下?場合?,残りの??タをすべて出力します?
052 *
053 * @og.rev 5.5.4.2 (2012/07/13) editName?時の編??
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 if( clmCnt < 0 ) {
065 String errMsg = "ViewForm_HTMLSeqClmTable クラスの実行前に、setColumnDisplay しておく?があります?";
066 throw new HybsSystemException( errMsg );
067 }
068
069 headerLine = null;
070 int lastNo = getLastNo( startNo, pageSize );
071 int blc = getBackLinkCount();
072 int hsc = getHeaderSkipCount(); // 3.5.2.0 (2003/10/20)
073 int hscCnt = 1; // 3.5.2.0 (2003/10/20)
074
075 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE );
076
077 out.append( getCountForm( startNo,pageSize ) );
078 out.append( getHeader() );
079
080 String ckboxTD = " <td>";
081
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 row=startNo; row<lastNo; row++ ) {
086 if( isSkip( row ) || isSkipNoEdit( row ) ) { continue; } // 4.3.1.0 (2008/09/08)
087 out.append("<tr").append( getBgColorCycleClass( bgClrCnt++,row ) );
088 if( isNoTransition() ) { // 4.3.3.0 (2008/10/01)
089 out.append( getHiddenRowValue( row ) );
090 }
091 out.append(">"); // 3.7.0.3 (2005/03/01)
092 out.append( HybsSystem.CR );
093 // 3.5.5.0 (2004/03/12) No ?のも?の作?判断追?
094 if( isNumberDisplay() ) {
095 out.append( makeCheckbox( ckboxTD, row, blc ) ).append( HybsSystem.CR );
096 }
097 // 5.1.6.0 (2010/05/01)
098 // for(int column = 0; column < clmCnt; column++) {
099 for(int clm = 0; clm < clmCnt; clm++) {
100 int column = clmNo[clm];
101 if( isColumnDisplay( column ) ) {
102 out.append(" <td>");
103 out.append( getValueLabel(row,column) );
104 out.append("</td>").append( HybsSystem.CR );
105 }
106 }
107
108
109 // 5.5.4.2 (2012/07/13) mustとmuntAnyでwritableのも?はdisplay:noneで出力す?可能な限り余?なも?は出力しな?
110 for(int column = 0; column < clmCnt; column++) {
111 if( !isColumnDisplay( column ) && ( isMustColumn( column ) || isMustAnyColumn(column) ) && isColumnWritable( column) ) {
112 out.append(" <td style=\"display:none\">");
113 out.append( getValueLabel(row,column) );
114 out.append("</td>").append( HybsSystem.CR );
115 }
116 }
117
118
119 out.append("</tr>").append( HybsSystem.CR );
120
121 // 3.5.2.0 (2003/10/20) ヘッ??繰り返し属?( headerSkipCount )を採用
122 if( hsc > 0 && hscCnt % hsc == 0 ) {
123 out.append( getHeadLine() );
124 hscCnt = 1;
125 }
126 else {
127 hscCnt ++ ;
128 }
129 }
130 out.append("</tbody>").append( HybsSystem.CR );
131 out.append("</table>").append( HybsSystem.CR );
132
133 out.append( getScrollBarEndDiv() ); // 3.8.0.3 (2005/07/15)
134
135 return out.toString();
136 }
137
138 /**
139 * DBTableModel から ??ブルのタグ??を作?して返します?
140 *
141 * @og.rev 3.5.1.0 (2003/10/03) Noカラ?、numberType 属?を追?
142 * @og.rev 3.5.2.0 (2003/10/20) ヘッ??繰り返し部をgetHeadLine()へ移?
143 * @og.rev 3.5.3.1 (2003/10/31) VERCHAR2 ?VARCHAR2 に修正?
144 * @og.rev 3.5.5.0 (2004/03/12) No ?のも?の作?判断ロジ?を追?
145 * @og.rev 3.5.6.5 (2004/08/09) thead に、id="header" を追?
146 * @og.rev 4.0.0.0 (2005/01/31) DBColumn の 属?(CLS_NM)から、DBTYPEに変更
147 * @og.rev 4.0.0.0 (2005/01/31) 新規作?(getColumnClassName ?getColumnDbType)
148 *
149 * @return ??ブルのタグ??
150 */
151 @Override
152 protected String getTableHead() {
153 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
154
155 // 3.5.5.0 (2004/03/12) No ?のも?の作?判断追?
156 if( isNumberDisplay() ) {
157 buf.append("<colgroup class=\"X\" />"); // 4.0.0 (2005/01/31)
158 buf.append("<colgroup class=\"BIT\" />");
159 buf.append("<colgroup class=\"S9\" />"); // 4.0.0 (2005/01/31)
160 buf.append( HybsSystem.CR );
161 }
162
163 // int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10)
164 // 5.1.6.0 (2010/05/01)
165 // for(int column = 0; column < clmCnt; column++) {
166 for(int clm = 0; clm < clmCnt; clm++) {
167 int column = clmNo[clm];
168 if( isColumnDisplay( column ) ) {
169 buf.append("<colgroup class=\"" );
170 buf.append( getColumnDbType(column) ); // 4.0.0 (2005/01/31)
171 buf.append("\"/>");
172 buf.append( HybsSystem.CR );
173 }
174 }
175
176 // 3.5.2.0 (2003/10/20) ヘッ??繰り返し部をgetHeadLine()へ移?
177 buf.append("<thead id=\"header\">").append( HybsSystem.CR ); // 3.5.6.5 (2004/08/09)
178 buf.append( getHeadLine() );
179 buf.append("</thead>").append( HybsSystem.CR );
180
181 return buf.toString();
182 }
183
184 /**
185 * ヘッ??繰り返し部を?getTableHead()メソ?から??
186 *
187 * @og.rev 3.5.2.0 (2003/10/20) 新規作?
188 * @og.rev 3.5.4.3 (2004/01/05) useCheckControl 属?の機?を追?
189 * @og.rev 3.5.4.5 (2004/01/23) thタグの属?設定?来る様に新規追??
190 * @og.rev 3.5.4.6 (2004/01/30) numberType="none" 時?処?追?Noラベルを?さな?
191 * @og.rev 3.5.4.7 (2004/02/06) ヘッ??にソート機?用のリンクを追?ます?
192 * @og.rev 3.7.0.1 (2005/01/31) 全件チェ?コントロール処?更
193 *
194 * @param thTag タグの??
195 *
196 * @return ??ブルのタグ??
197 */
198 @Override
199 protected String getHeadLine( final String thTag ) {
200 if( headerLine != null ) { return headerLine; } // キャ?ュを返す?
201
202 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
203
204 // buf.append("<tr class=\"row_h\"").append(" >").append( HybsSystem.CR );
205 buf.append("<tr class=\"row_hu\"").append(" >").append( HybsSystem.CR );
206
207 // 3.5.5.0 (2004/03/12) No ?のも?の作?判断追?
208 if( isNumberDisplay() ) {
209 // 3.5.4.3 (2004/01/05) 追??
210 if( isUseCheckControl() && "checkbox".equals( getSelectedType() ) ) {
211 // 3.5.4.5 (2004/01/23) thタグの属?設定?来る様に変更?
212 buf.append( thTag ).append("></th>");
213 buf.append( thTag ).append(">").append( getAllCheckControl() ).append("</th>");
214 buf.append( thTag ).append(">").append( getNumberHeader() ).append("</th>"); // 3.5.4.6 (2004/01/30)
215 }
216 else {
217 // 3.5.4.5 (2004/01/23) thタグの属?設定?来る様に変更?
218 buf.append( thTag ).append(" colspan='3'>").append( getNumberHeader() ).append("</th>"); // 3.5.4.6 (2004/01/30)
219 }
220 }
221
222 buf.append( HybsSystem.CR );
223 // int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10)
224 // 5.1.6.0 (2010/05/01)
225 // for(int column = 0; column < clmCnt; column++) {
226 for(int clm = 0; clm < clmCnt; clm++) {
227 int column = clmNo[clm];
228 if( isColumnDisplay( column ) ) {
229 // 3.5.4.5 (2004/01/23) thタグの属?設定?来る様に変更?
230 buf.append( thTag ).append(">");
231 buf.append( getSortedColumnLabel(column) );
232 buf.append("</th>").append( HybsSystem.CR );
233 }
234 }
235 buf.append("</tr>").append( HybsSystem.CR );
236
237 headerLine = buf.toString();
238 return headerLine;
239 }
240
241 /**
242 * 表示可能カラ?を?カンマ区?で与えます?
243 * 例?OYA,KO,HJO,SU,DYSET,DYUPD"
244 * setColumnDisplay( int column,boolean rw ) の簡易版です?
245 * null を与えた?合?,なにもしません?
246 *
247 * @param columnName カラ?
248 */
249 @Override
250 public void setColumnDisplay( final String columnName ) {
251 super.setColumnDisplay( columnName );
252
253 if( columnName != null ) {
254 String[] clmNames = StringUtil.csv2Array( columnName );
255 clmCnt = clmNames.length;
256 clmNo = new int[clmCnt];
257 for( int i=0; i<clmCnt; i++ ) {
258 clmNo[i] = getColumnNo( clmNames[i] );
259 }
260 }
261 this.viewClms = columnName;
262 }
263
264 /**
265 * ビューで表示したカラ???をカンマ区?で返します?
266 *
267 * @og.rev 5.1.6.0 (2010/05/01) 新規追?
268 *
269 * @return ビューで表示したカラ???
270 */
271 @Override
272 public String getViewClms() {
273 return viewClms;
274 }
275 }