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.html.AbstractViewForm;
020 import org.opengion.fukurou.util.XHTMLTag;
021
022 import org.opengion.hayabusa.db.DBColumn;
023 import org.opengion.hayabusa.db.DBColumnConfig;
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 */
039 public class ViewForm_HTMLTextField extends AbstractViewForm {
040 //* こ?プログラ??VERSION??を設定します? {@value} */
041 private static final String VERSION = "5.6.2.3 (2013/03/22)" ;
042
043 // 4.0.0 (2005/01/31) HTML_LABEL_SEPARATOR ?boolean 変数として取得します?
044 private final String CLM = ( HybsSystem.sysBool( "HTML_LABEL_SEPARATOR" ) ) ? ":" : "" ;
045
046 private String columnSpace = HybsSystem.sys( "HTML_COLUMS_SPACE" ) ; // ?間?スペ?ス
047 private int maxRowNumber = HybsSystem.sysInt( "HTML_MAXROW_NUMBER" ) ; // 縦方向??表示件数
048 private static final int PAGE_SIZE = 1;
049
050 // 4.3.4.4 (2009/01/01)
051 // /**
052 // * ?ォルトコンストラクター
053 // *
054 // */
055 // public ViewForm_HTMLTextField() {
056 // super();
057 // }
058
059 /**
060 * DBTableModel から HTML??を作?して返します?
061 * startNo(表示開始位置)から、pageSize(表示件数)までのView??を作?します?
062 * 表示残り??タ?pageSize 以下?場合?,残りの??タをすべて出力します?
063 *
064 * @og.rev 2.0.1.0 (2002/10/10) ラベルとフィールド?セパレーターとして、コロン(??を使用するかど?を指定できる
065 * @og.rev 3.6.0.5 (2004/10/18) 印刷時?罫線?力関連機?の追??id 属?を?力します?
066 * @og.rev 5.6.2.3 (2013/03/22) DBColumn に、useSLabel="false" の値をセ?します?
067 *
068 * @param startNo 表示開始位置
069 * @param pageSize 表示件数
070 *
071 * @return DBTableModelから作?され?HTML??
072 */
073 public String create( final int startNo, final int pageSize ) {
074 if( getRowCount() == 0 ) { return ""; } // 暫定?置
075
076 noSLabelSetting(); // 5.6.2.3 (2013/03/22) DBColumn に、useSLabel="false" の値をセ?します?
077
078 int numberOfColumns = getColumnDisplayCount() ;
079 String[] label = new String[numberOfColumns];
080 String[] value = new String[numberOfColumns];
081
082 int realCount = getColumnCount();
083 int clmNo = 0;
084 for( int i=0; i<realCount; i++ ) {
085 if( isColumnDisplay(i) ) {
086 label[clmNo] = getColumnLabel(i);
087 value[clmNo] = getValueLabel(startNo,i);
088 clmNo++ ;
089 }
090 }
091
092 int columnNumber = ( numberOfColumns / maxRowNumber ) + 1 ;
093
094 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE );
095
096 out.append( getCountForm( startNo,pageSize ) );
097 out.append( makeSelectNo( startNo ) ).append( HybsSystem.CR );
098
099 out.append("<table id=\"viewTextField\" border=\"0\" summary=\"ViewForm_HTMLTextField\" >"); // 3.6.0.5 (2004/10/18)
100 int rowNumber = (numberOfColumns +1 )/ columnNumber ;
101 for( int row=0; row<rowNumber; row++ ) {
102 out.append("<tr>").append( HybsSystem.CR );
103 for( int clm=0; clm<columnNumber; clm++ ) {
104 int realClm = row + clm * rowNumber ;
105 out.append("<td id=\"label\">");
106 if( realClm < numberOfColumns ) {
107 out.append( label[realClm] );
108 out.append( CLM );
109 }
110 out.append("</td>").append( HybsSystem.CR );
111 out.append("<td>");
112 if( realClm < numberOfColumns ) { out.append( value[realClm] ); }
113 out.append("</td>").append( HybsSystem.CR );
114 out.append("<td width=\"").append( columnSpace ).append("\">?/td>").append( HybsSystem.CR );
115 }
116 out.append("</tr>").append( HybsSystem.CR );
117 }
118 out.append("</table>");
119
120 return out.toString();
121 }
122
123 /**
124 * DBColumn に、useSLabel="false" の値をセ?します?
125 *
126 * @og.rev 5.6.2.3 (2013/03/22) 新規追?
127 *
128 */
129 protected void noSLabelSetting() {
130 int realCount = getColumnCount();
131
132 for( int clmNo=0; clmNo<realCount; clmNo++ ) {
133 DBColumnConfig config = getDBColumn( clmNo ).getConfig();
134 config.setUseSLabel( "false" );
135
136 setDBColumn( clmNo, new DBColumn( config ) );
137 }
138 }
139
140 /**
141 * 画面に選択された番号を表示します?
142 * また?書き込み許可がある?合??択用の?フィールドを作?します?
143 *
144 * @og.rev 3.5.5.5 (2004/04/23) hidden の出力に、XHTMLTag.hidden を使用します?
145 *
146 * @param row 行番号
147 *
148 * @return ?フィールド?HTML??
149 */
150 protected String makeSelectNo( final int row ) {
151 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
152
153 if( isWritable( row ) ) {
154 // XHTMLTag.hidden( name,value ) を使用?
155 out.append( XHTMLTag.hidden( HybsSystem.ROW_SEL_KEY,String.valueOf( row ) ) );
156 }
157
158 return out.toString();
159 }
160
161 /**
162 * ?をクリア(初期?します?
163 *
164 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
165 *
166 */
167 @Override
168 public void clear() {
169 super.clear();
170 columnSpace = HybsSystem.sys( "HTML_COLUMS_SPACE" ) ; // ?間?スペ?ス
171 maxRowNumber = HybsSystem.sysInt( "HTML_MAXROW_NUMBER" ) ; // 縦方向??表示件数
172 }
173
174 /**
175 * 表示件数を取得します?
176 *
177 * @return 表示件数
178 */
179 @Override
180 public int getPageSize() {
181 return PAGE_SIZE;
182 }
183
184 /**
185 * フォーマットメソ?を使用できるかど?を問?わせます?
186 *
187 * @return 使用可能(true)/ 使用不可能(false)
188 */
189 public boolean canUseFormat() {
190 return false;
191 }
192
193 /**
194 * カラ??ラベル?長)を返します?
195 * カラ???名に対して,見える形の??を返します?
196 * ?には,リソースバンドルと?せて,?ロケール毎にラベル?
197 * ?えます?
198 *
199 * @og.rev 4.0.0.0 (2005/01/31) 新規追? longLabel を返します?)
200 *
201 * @param column カラ?号
202 *
203 * @return カラ??ラベル?長)
204 */
205 @Override
206 protected String getColumnLabel( final int column ) {
207 return getDBColumn( column ).getLongLabel();
208 }
209
210 /**
211 * 表示?の編?並び替?が可能かど?を返しま?
212 *
213 * @og.rev 5.1.6.0 (2010/05/01) 新規追?
214 *
215 * @return 表示?の編?並び替?が可能かど?(false:不可能)
216 */
217 @Override
218 public boolean isEditable() {
219 return false;
220 }
221 }