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.common.HybsSystemException;
020 import org.opengion.hayabusa.html.TableFormatter;
021
022 import java.util.List;
023
024 /**
025 * フォーマットを外部からæŒ?®šして作æ?する自由レイアウトã?、テキストフィールド表示クラスですã?
026 *
027 * AbstractViewForm により、setter/getterメソãƒ?ƒ‰のãƒ?ƒ•ォルト実è£?‚’提供してã�?�¾すã?
028 * 各HTMLのタグにå¿?¦�な setter/getterメソãƒ?ƒ‰のみ?Œ追åŠ?®š義してã�?�¾すã?
029 * [XXXX]は、カラãƒ?‚’æŒ?®šしますã?ラベル?‹å?力フィールドをそれぞれtdで囲ã�?�¾すã?
030 * [#XXXX]は、テーブルタグのtdを使用せず、ラベルと入力フィールドを出力しますã?
031 * [$XXXX]は、ラベルもtdもå?さずに、å?力フィールドã?み出力しますã?
032 * [!XXXX]は、å?のみ出力しますã?
033 * 特殊記号の解釈ã?、HTMLFormatTextField系とHTMLFormatTable系で異なりますã?で
034 * ご注意くã�?�•ã�??
035 *
036 * AbstractViewForm を継承してã�?‚‹為,ロケールに応じたラベルをå?力させる事が出来ますã?
037 *
038 * @og.group 画面表示
039 *
040 * @version 4.0
041 * @author Kazuhiko Hasegawa
042 * @since JDK5.0,
043 */
044 public class ViewForm_HTMLFormatTextField extends ViewForm_HTMLTextField {
045 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
046 private static final String VERSION = "5.6.2.3 (2013/03/22)" ;
047
048 // 4.0.0 (2005/01/31) HTML_LABEL_SEPARATOR ã‚?boolean 変数として取得しますã?
049 private final String CLM = ( HybsSystem.sysBool( "HTML_LABEL_SEPARATOR" ) ) ? ":" : "" ;
050
051 // 3.5.4.0 (2003/11/25) TableFormatter クラス追åŠ?
052 private TableFormatter format = null;
053
054 // 4.3.4.4 (2009/01/01)
055 // /**
056 // * ãƒ?ƒ•ォルトコンストラクター
057 // *
058 // */
059 // public ViewForm_HTMLFormatTextField() {
060 // super();
061 // }
062
063 /**
064 * フォーマットを設定しますã?
065 *
066 * @og.rev 3.5.4.0 (2003/11/25) 新規作æ?
067 * @param list TableFormatterのリスãƒ?
068 */
069 @Override
070 public void setFormatterList( final List<TableFormatter> list ) { // 4.3.3.6 (2008/11/15) Generics警告対å¿?
071 format = list.get(0); // 4.3.3.6 (2008/11/15) Generics警告対å¿?
072 format.makeFormat( getDBTableModel() );
073 }
074
075 /**
076 * DBTableModel から HTMLæ–?—å?を作æ?して返しますã?
077 * startNo(表示開始位置)から、pageSize(表示件数)までのViewæ–?—å?を作æ?しますã?
078 * 表示残りãƒ??タã�?pageSize 以下ã?場合ã?,残りのãƒ??タをすべて出力しますã?
079 *
080 * @og.rev 2.0.1.0 (2002/10/10) ラベルã�?�‘、フィールドだけを取り出すフォーマットを追åŠ?
081 * @og.rev 2.0.1.0 (2002/10/10) ラベルとフィールドã?セパレーターとして、コロン(??を使用するかどã�?�‹を指定できる
082 * @og.rev 3.2.4.0 (2003/06/12) makeFormat() する位置を移動ã?
083 * @og.rev 3.5.4.0 (2003/11/25) TableFormatter クラスを使用するように変更ã€?
084 * @og.rev 3.5.5.0 (2004/03/12) systemFormat(例:[KEY.カラãƒ?��]形式ç?の対å¿?
085 * @og.rev 5.0.0.2 (2009/09/15) フォーマットが設定されてã�?�ªã�??合ã?エラー追åŠ?
086 * @og.rev 5.6.2.3 (2013/03/22) DBColumn に、useSLabel="false" の値をセãƒ?ƒˆしますã?
087 *
088 * @param startNo 表示開始位置
089 * @param pageSize 表示件数
090 *
091 * @return DBTableModelから作æ?されã�?HTMLæ–?—å?
092 */
093 @Override
094 public String create( final int startNo, final int pageSize ) {
095 if( getRowCount() == 0 ) { return ""; } // 暫定å?置
096
097 noSLabelSetting(); // 5.6.2.3 (2013/03/22) DBColumn に、useSLabel="false" の値をセãƒ?ƒˆしますã?
098
099 // 4.3.1.0 (2008/09/08)
100 if( format == null ) {
101 String errMsg = "ViewTagで canUseFormat() = true の場合ã?Formatter はå¿??ですã?";
102 throw new HybsSystemException( errMsg );
103 }
104
105 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE );
106 out.append( getCountForm( startNo,pageSize ) );
107 out.append( makeSelectNo( startNo ) ).append( HybsSystem.CR );
108
109 out.append( format.getTrTag() );
110 int cl = 0;
111 for( ; cl < format.getLocationSize(); cl++ ) {
112 out.append( format.getFormat(cl) );
113 int loc = format.getLocation(cl);
114 if( loc < 0 ) {
115 out.append( format.getSystemFormat(startNo,loc) ); // 5.0.0.2 (2009/09/15)
116 continue ;
117 }
118
119 char type = format.getType(cl);
120 if( type == '#' ) {
121 out.append("<span id=\"label\">");
122 out.append( getColumnLabel(loc) );
123 out.append( CLM );
124 out.append("</span>");
125 }
126 else if( type == '$' ) {
127 out.append( getValueLabel(startNo,loc) );
128 }
129 else if( type == '!' ) {
130 out.append( getValue(startNo,loc) );
131 }
132 else {
133 out.append("<td id=\"label\">");
134 out.append( getColumnLabel(loc) );
135 out.append( CLM );
136 out.append("</td>");
137 out.append("<td>");
138 out.append( getValueLabel(startNo,loc) );
139 out.append("</td>");
140 }
141 }
142 out.append( format.getFormat(cl) );
143
144 return out.toString();
145 }
146
147 /**
148 * å†?®¹をクリア(初期åŒ?しますã?
149 *
150 * @og.rev 2.0.1.0 (2002/10/10) ラベルã�?�‘、フィールドだけを取り出すフォーマットを追åŠ?
151 * @og.rev 3.1.1.0 (2003/03/28) 同期メソãƒ?ƒ‰(synchronized付き)を非同期に変更するã€?
152 * @og.rev 3.5.4.0 (2003/11/25) TableFormatter クラスを使用するように変更ã€?
153 *
154 */
155 @Override
156 public void clear() {
157 super.clear();
158 format = null;
159 }
160
161 /**
162 * フォーマットメソãƒ?ƒ‰を使用できるかどã�?�‹を問ã�?�ˆわせますã?
163 *
164 * @return 使用可能(true)/ 使用不可能 (false)
165 */
166 @Override
167 public boolean canUseFormat() {
168 return true;
169 }
170
171 /**
172 * 表示é ?›®の編é›?並び替ã�?が可能かどã�?�‹を返しまã�?
173 *
174 * @og.rev 5.1.6.0 (2010/05/01) 新規追åŠ?
175 *
176 * @return 表示é ?›®の編é›?並び替ã�?が可能かどã�?�‹(false:不可能)
177 */
178 @Override
179 public boolean isEditable() {
180 return false;
181 }
182 }