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.hayabusa.common.HybsSystem;
019 import org.opengion.hayabusa.db.DBTableModel;
020
021 /**
022 * å�?ƒ•ィールド情報から、動çš?�«カラãƒ?‚’作æ?する動的カラãƒ?¸?¦§表示クラスですã?
023 *
024 * AbstractViewForm により、setter/getterメソãƒ?ƒ‰のãƒ?ƒ•ォルト実è£?‚’提供してã�?�¾すã?
025 * 各HTMLのタグにå¿?¦�な setter/getterメソãƒ?ƒ‰のみ?Œ追åŠ?®š義してã�?�¾すã?
026 *
027 * AbstractViewForm を継承してã�?‚‹為,ロケールに応じたラベルをå?力させる事が出来ますã?
028 *
029 * @og.group 画面表示
030 *
031 * @version 4.0
032 * @author Kazuhiko Hasegawa
033 * @since JDK5.0,
034 */
035 public class ViewForm_HTMLDynamic extends ViewForm_HTMLTable {
036 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
037 private static final String VERSION = "5.1.6.0 (2010/05/01)" ;
038
039 /** カラãƒ??値を返す場合ã?、カラãƒ?‚ー名称 {@value} */
040 public static final String COLUMN_RETURN_KEY = "COLUMN_RETURN";
041 private int rtnColumnNo = -1; // column_return カラãƒ??番号
042
043 // 4.3.4.4 (2009/01/01)
044 // /**
045 // * ãƒ?ƒ•ォルトコンストラクター
046 // *
047 // */
048 // public ViewForm_HTMLDynamic() {
049 // super();
050 // }
051
052 /**
053 * 初期化しますã?
054 * ここでは、å?部で使用されてã�?‚‹キャãƒ?‚·ュをクリアしã?
055 * 新しいモãƒ?ƒ«(DBTableModel)とè¨?ª?lang) をå?にå†?ƒ¨ãƒ??タをå?構築しますã?
056 * ただしã?設定情報は、以前ã?状態がそã?ままキープされてã�?�¾すã?
057 *
058 * @og.rev 3.1.1.0 (2003/03/28) 同期メソãƒ?ƒ‰(synchronized付き)を非同期に変更するã€?
059 * @og.rev 3.5.6.1 (2004/06/25) lang è¨?ªžコーãƒ?属æ?を削除しますã?
060 *
061 * @param table DBTableModelオブジェクãƒ?
062 */
063 @Override
064 public void init( final DBTableModel table ) {
065 super.init( table );
066 int clmCnt = getColumnCount();
067 for( int i=0; i<clmCnt; i++ ) {
068 if( COLUMN_RETURN_KEY.equalsIgnoreCase( getColumnName(i) )) {
069 rtnColumnNo = i;
070 break;
071 }
072 }
073 }
074
075 /**
076 * DBTableModel から HTMLæ–?—å?を作æ?して返しますã?
077 * startNo(表示開始位置)から、pageSize(表示件数)までのViewæ–?—å?を作æ?しますã?
078 * 表示残りãƒ??タã�?pageSize 以下ã?場合ã?,残りのãƒ??タをすべて出力しますã?
079 *
080 * @og.rev 3.5.4.0 (2003/11/25) getBgColorCycleClass の返すæ–?—å?を変更するã€?
081 * @og.rev 3.5.6.4 (2004/07/16) ヘッãƒ??とボディー部をJavaScriptでåˆ?›¢
082 *
083 * @param startNo 表示開始位置
084 * @param pageSize 表示件数
085 *
086 * @return DBTableModelから作æ?されã�?HTMLæ–?—å?
087 */
088 @Override
089 public String create( final int startNo, final int pageSize ) {
090 if( getRowCount() == 0 ) { return ""; } // 暫定å?置
091
092 int lastNo = getLastNo( startNo, pageSize );
093
094 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE );
095
096 out.append( getCountForm( startNo,pageSize ) );
097 out.append( getHeader() );
098
099 int rowIndex = 0;
100 out.append("<tbody>").append( HybsSystem.CR );
101 out.append("<tr").append( getBgColorCycleClass( rowIndex++ ) ).append(">");
102 int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10)
103 for( int row=startNo; row<lastNo; row++ ) {
104 for(int column = 0; column < clmCnt; column++) {
105 if( isColumnReturn( row,column ) ) {
106 out.append("</tr>");
107 out.append("<tr").append( getBgColorCycleClass( rowIndex++ ) ).append(">");
108 }
109 else if( isColumnDisplay( column ) ) {
110 out.append(" <td>");
111 out.append( getValueLabel(row,column) );
112 out.append("</td>").append( HybsSystem.CR );
113 }
114 }
115 }
116 out.append("</tr>").append( HybsSystem.CR );
117 out.append("</tbody>").append( HybsSystem.CR );
118 out.append("</table>").append( HybsSystem.CR );
119
120 out.append( getScrollBarEndDiv() ); // 3.8.0.3 (2005/07/15)
121 return out.toString();
122 }
123
124 /**
125 * DBTableModel から ãƒ??ブルのタグæ–?—å?を作æ?して返しますã?
126 *
127 * @return ãƒ??ブルのタグæ–?—å?
128 */
129 @Override
130 protected String getTableHead() {
131 // ヘッãƒ??は?Œ不要ですã?
132 return "";
133 }
134
135 /**
136 * カラãƒ?�Œ表示可能かどã�?�‹を返しますã?
137 * もし?Œ表示不可の場合ã?,こã?カラãƒ??全ãƒ??タが,表示対象から外されますã?
138 *
139 * @param row 行番号
140 * @param column カラãƒ?•ª号
141 *
142 * @return 表示可能(true)?�不可能(false)
143 */
144 private boolean isColumnReturn( final int row,final int column ) {
145 boolean rtnFlag = false;
146
147 if( rtnColumnNo == column &&
148 "1".equals( getValue( row,column ) ) ) {
149 rtnFlag = true;
150 }
151
152 return rtnFlag;
153 }
154
155 /**
156 * 表示é ?›®の編é›?並び替ã�?が可能かどã�?�‹を返しまã�?
157 *
158 * @og.rev 5.1.6.0 (2010/05/01) 新規追åŠ?
159 *
160 * @return 表示é ?›®の編é›?並び替ã�?が可能かどã�?�‹(false:不可能)
161 */
162 @Override
163 public boolean isEditable() {
164 return false;
165 }
166 }