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.column;
017
018 import org.opengion.hayabusa.common.HybsSystem;
019 import org.opengion.hayabusa.common.HybsSystemException;
020 import org.opengion.hayabusa.db.AbstractEditor;
021 import org.opengion.hayabusa.db.CellEditor;
022 import org.opengion.hayabusa.db.DBColumn;
023 import org.opengion.hayabusa.db.Selection;
024 import org.opengion.hayabusa.db.SelectionFactory;
025 import org.opengion.fukurou.util.StringFormat;
026 import org.opengion.fukurou.util.XHTMLTag;
027 import org.opengion.fukurou.util.Attributes;
028 import org.opengion.fukurou.util.TagBuffer;
029
030 /**
031 * INDBMENU エãƒ?‚£ã‚¿ãƒ¼ã¯ã€ã‚«ãƒ©ãƒ??表示パラメーターã®?³?±?¬æ–?‚’å®Ÿè¡Œçµæžœã‚ˆã‚Šã€?
032 * 作æ?ã—ãŸãƒ—ルãƒ?‚¦ãƒ³ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¨ã€ãƒ†ã‚ストフィールドã«ã‚ˆã‚‹å…¥åŠ›ã?両方をサãƒã?トã™ã‚‹ã?
033 * ç·¨é›?«ä½¿ç”¨ã™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã?
034 *
035 * JavaScript ã«ã‚ˆã‚Šãƒ?‚ストフィールドã¨ãƒ¡ãƒ‹ãƒ¥ãƒ¼(コンボã?ãƒ?‚¯ã‚¹)ã‚’é‡ãåˆã‚ã›ã¦
036 * 表示ã—ã¦ãŠãã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã§é¸æŠžã—ãŸå?ã‚’ã?ãƒ?‚ストフィールドã«è¨å®šã—ã¦ã?¾ã™ã?
037 * ã“ã?エãƒ?‚£ã‚¿ã‚’使用ã™ã‚‹ã«ã¯ã€jsp/common/inputMenu.js を予ã‚使用ã§ãるよã†ã«
038 * è¨å®šã—ã¦ãŠãå¿?¦ãŒã‚りã¾ã™ã?
039 *
040 * ã“ã?エãƒ?‚£ã‚¿ã¯eventColumnã«å¯¾å¿œã—ã¦ã?¾ã›ã‚“ã€?
041 *
042 * カラãƒ??表示ã«å¿?¦ãªå±žæ?ã¯, DBColumn オブジェクãƒ?よりå–り出ã—ã¾ã™ã?
043 * ã“ã?クラスã¯ã€DBColumn オブジェクト毎ã«?‘ã¤ä½œæ?ã•れã¾ã™ã?
044 *
045 * @og.rev 3.5.6.2 (2004/07/05) æ–°è¦ä½œæ?
046 * @og.group �?タ編�
047 *
048 * @version 4.0
049 * @author Kazuhiko Hasegawa
050 * @since JDK5.0,
051 */
052 public class Editor_INDBMENU extends AbstractEditor {
053 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */
054 private static final String VERSION = "5.6.3.0 (2013/04/01)" ;
055
056 private static final String SEL1 = "<script type=\"text/javascript\">makeInputMenu('" ;
057 private static final String SEL2 = "');</script>" ;
058
059 private final String query ;
060 private final String dbid ;
061 private final String lang ; // 4.0.0 (2006/11/15)
062 private final boolean addNoValue ; // 3.5.5.7 (2004/05/10)
063 private final boolean seqFlag ; // 3.6.0.6 (2004/10/22)
064 private final TagBuffer selTagBuffer = new TagBuffer() ;
065
066 /**
067 * ãƒ?ƒ•ォルトコンストラクターã€?
068 * ã“ã?コンストラクターã§ã€åŸºæœ¬ã‚ªãƒ–ジェクトを作æ?ã—ã¾ã™ã?
069 *
070 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã?
071 */
072 public Editor_INDBMENU() {
073 // 4.3.4.4 (2009/01/01)
074 // super();
075 query = null;
076 dbid = null;
077 lang = null; // 4.0.0 (2006/11/15)
078 addNoValue = false; // 3.5.5.7 (2004/05/10)
079 seqFlag = false; // 3.6.0.6 (2004/10/22)
080 name = null; // 4.3.4.0 (2008/12/01)
081 }
082
083 /**
084 * コンストラクター�
085 *
086 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã?
087 * @og.rev 4.0.0.0 (2006/11/24) TextFieldåˆ??属æ?è¨å®?
088 * @og.rev 5.6.3.0 (2013/04/01) プルãƒ?‚¦ãƒ³ã®onChangeã®è¨å®šå?æ‰?‚’変更
089 *
090 * @param clm DBColumnオブジェク�
091 */
092 private Editor_INDBMENU( final DBColumn clm ) {
093 super( clm );
094 tagBuffer.add( XHTMLTag.inputAttri( attributes ) );
095
096 addNoValue = clm.isAddNoValue() ; // 3.5.5.7 (2004/05/10)
097 query = clm.getEditorParam();
098 dbid = clm.getDbid();
099 lang = clm.getLang(); // 4.0.0 (2006/11/15)
100 seqFlag = false; // 3.6.0.6 (2004/10/22)
101 name = clm.getName(); //4.3.4.0 (2008/12/01)
102
103 if( query == null || query.length() == 0 ) {
104 String errMsg = "DBMENU Editor ã§ã¯ã€ç·¨é›?ƒ‘ラメータã¯å¿??ã§ã™ã?"
105 + " name=[" + name + "]" + HybsSystem.CR ;
106 throw new HybsSystemException( errMsg );
107 }
108
109 String disabled = clm.isWritable() ? null : "disabled" ;
110
111 Attributes selAttri = new Attributes();
112 selAttri.set( "disabled" ,disabled );
113 // selAttri.set( "onChange" ,"selChanged(this);" ); // INDBMENU 特有ã?JavaScript
114
115 selAttri.addAttributes( clm.getEditorAttributes() );
116
117 selAttri.set( "onChange" ,"selChanged(this);" ); // INDBMENU 特有ã?JavaScript 5.6.3.0 (2013/03/01) å ´æ‰?¤‰æ›´
118
119 selTagBuffer.add( XHTMLTag.selectAttri( selAttri ) );
120 }
121
122 /**
123 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã?
124 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?«
125 * ã¾ã‹ã•れã¾ã™ã?
126 *
127 * @param clm DBColumnオブジェク�
128 *
129 * @return CellEditorオブジェク�
130 */
131 public CellEditor newInstance( final DBColumn clm ) {
132 return new Editor_INDBMENU( clm );
133 }
134
135 /**
136 * ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã?
137 *
138 * ã“ã“ã§ã¯ã€AAA:BBB:CCC:DDD ã¨ã?†å€¤ã‚’ã?$1,$2,$3,$4 ã«å‰²ã‚Šå½“ã¦ãªãŠã—ã¦ã€?
139 * QUERYを実行ã—ã¾ã™ã?ã¾ãŸã?$1 ã¯ã€æœ¬æ¥ã®å€¤ã¨ã—ã¦ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®åˆæœŸå€¤è¨å®šç‰ã«
140 * 使用ã—ã¾ã™ã?上記ã?例ã§ã¯ã€AAA ãŒå?ã§ã€ãれ以é™ã?ã€å¼•æ•°ã«ãªã‚Šã¾ã™ã?
141 * ã•らã«ã€å?ã®æ–?—å?"AAA:BBB:CCC:DDD"ã¯ã€?0 ã«å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¾ã™ã?割り当ã¦ãŒãªã?
142 * 変数ã¯ã€?"(ã‚¼ãƒæ–?—å?)ã¨ã—ã¦ã€æ‰±ã‚れã¾ã™ã?
143 *
144 * @og.rev 3.8.5.3 (2006/06/30) ä½ç½®ã‚’絶対ä½ç½®æŒ?®?position:absolute;)
145 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã?
146 *
147 * @param value 入力å?
148 *
149 * @return ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å?
150 */
151 @Override
152 public String getValue( final String value ) {
153
154 // input ã‚¿ã‚°ã®ä½œæ?
155 TagBuffer intag = new TagBuffer( "input" );
156 intag.add( "name" , name );
157 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
158 intag.add( "id" , name ); // INDBMENU 特有ã?JavaScript用ã®ã‚ー
159 }
160 intag.add( "value" , value );
161 intag.add( "size" , size1 );
162 intag.add( tagBuffer.makeTag() );
163 intag.add( optAttr );
164
165 // select ã‚¿ã‚°ã®ä½œæ?
166 TagBuffer seltag = new TagBuffer( "select" );
167 seltag.add( "id" , name + ".sel" ); // INDBMENU 特有ã?JavaScript用ã®ã‚ー
168 seltag.add( "style" , "position:absolute;" ); // 3.8.5.3 (2006/06/30) ä½ç½®ã‚’絶対ä½ç½®æŒ?®?
169 seltag.add( selTagBuffer.makeTag() );
170 seltag.add( optAttr );
171
172 seltag = getOption( seltag,value );
173
174 return intag.makeTag() + HybsSystem.CR +
175 seltag.makeTag() + HybsSystem.CR +
176 SEL1 + name + SEL2;
177 }
178
179 /**
180 * name属æ?を変ãˆãŸã?ãƒ??タ表示/ç·¨é›?”¨ã®HTMLæ–?—å?を作æ?ã—ã¾ã™ã?
181 * ãƒ??ブル上ã? name 㫠行番å·ã‚’ä»˜åŠ ã—ã¦ã€åå‰_è¡Œç•ªå· ã§ç™»éŒ²ã™ã‚‹ã‚ーを作æ?ã?
182 * ãƒªã‚¯ã‚¨ã‚¹ãƒˆæƒ…å ±ã‚’ï¼‘ã¤æ¯Žã?フィールドã§å‡¦ç?§ãã¾ã™ã?
183 *
184 * ã“ã“ã§ã¯ã€AAA:BBB:CCC:DDD ã¨ã?†å€¤ã‚’ã?$1,$2,$3,$4 ã«å‰²ã‚Šå½“ã¦ãªãŠã—ã¦ã€?
185 * QUERYを実行ã—ã¾ã™ã?ã¾ãŸã?$1 ã¯ã€æœ¬æ¥ã®å€¤ã¨ã—ã¦ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®åˆæœŸå€¤è¨å®šç‰ã«
186 * 使用ã—ã¾ã™ã?上記ã?例ã§ã¯ã€AAA ãŒå?ã§ã€ãれ以é™ã?ã€å¼•æ•°ã«ãªã‚Šã¾ã™ã?
187 * ã•らã«ã€å?ã®æ–?—å?"AAA:BBB:CCC:DDD"ã¯ã€?0 ã«å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¾ã™ã?割り当ã¦ãŒãªã?
188 * 変数ã¯ã€?"(ã‚¼ãƒæ–?—å?)ã¨ã—ã¦ã€æ‰±ã‚れã¾ã™ã?
189 *
190 * @og.rev 3.8.5.1 (2006/04/28) makeInputMenu 呼ã³å‡ºã—時ã®å¼•数記述ミスを修æ£
191 * @og.rev 3.8.5.3 (2006/06/30) ä½ç½®ã‚’絶対ä½ç½®æŒ?®?position:absolute;)
192 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã?
193 *
194 * @param row 行番å·
195 * @param value 入力å?
196 *
197 * @return ãƒ??タ表示/ç·¨é›?”¨ã®æ–?—å?
198 */
199 @Override
200 public String getValue( final int row,final String value ) {
201
202 String name2 = name + HybsSystem.JOINT_STRING + row ;
203
204 // input ã‚¿ã‚°ã®ä½œæ?
205 TagBuffer intag = new TagBuffer( "input" );
206 intag.add( "name" , name2 );
207 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
208 intag.add( "id" , name2 ); // INDBMENU 特有ã?JavaScript用ã®ã‚ー
209 }
210 intag.add( "value" , value );
211 intag.add( "size" , size2 );
212 intag.add( tagBuffer.makeTag() );
213 intag.add( optAttr );
214
215 // select ã‚¿ã‚°ã®ä½œæ?
216 TagBuffer seltag = new TagBuffer( "select" );
217 seltag.add( "id" , name2 + ".sel" ); // INDBMENU 特有ã?JavaScript用ã®ã‚ー
218 seltag.add( "style" , "position:absolute;" ); // 3.8.5.3 (2006/06/30) ä½ç½®ã‚’絶対ä½ç½®æŒ?®?
219 seltag.add( selTagBuffer.makeTag() );
220 seltag.add( optAttr );
221
222 seltag = getOption( seltag,value );
223
224 return intag.makeTag( row,value ) + HybsSystem.CR +
225 seltag.makeTag( row,value ) + HybsSystem.CR +
226 SEL1 + name2 + SEL2;
227 }
228
229 /**
230 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’TagBuffer ã«åæ˜ ã—ã¾ã™ã?
231 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグ作æ?ã—ã?TagBuffer
232 * ã«å€¤ã‚’è¨å®šã—ã¦è¿”ã—ã¾ã™ã?
233 *
234 * ã“ã“ã§ã¯ã€AAA:BBB:CCC:DDD ã¨ã?†å€¤ã‚’ã?$1,$2,$3,$4 ã«å‰²ã‚Šå½“ã¦ãªãŠã—ã¦ã€?
235 * QUERYを実行ã—ã¾ã™ã?ã¾ãŸã?$1 ã¯ã€æœ¬æ¥ã®å€¤ã¨ã—ã¦ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®åˆæœŸå€¤è¨å®šç‰ã«
236 * 使用ã—ã¾ã™ã?上記ã?例ã§ã¯ã€AAA ãŒå?ã§ã€ãれ以é™ã?ã€å¼•æ•°ã«ãªã‚Šã¾ã™ã?
237 * ã•らã«ã€å?ã®æ–?—å?"AAA:BBB:CCC:DDD"ã¯ã€?0 ã«å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¾ã™ã?割り当ã¦ãŒãªã?
238 * 変数ã¯ã€?"(ã‚¼ãƒæ–?—å?)ã¨ã—ã¦ã€æ‰±ã‚れã¾ã™ã?
239 * åˆã?$Cã«ã¯è‡ªåˆ??身ã®ã‚«ãƒ©ãƒ?を割り当ã¦ã¾ã™ã?
240 *
241 * @og.rev 3.5.5.7 (2004/05/10) getOption( String value )ã®å»?¢ã‚’å—ã‘ã¦ã€æ–°è¦ä½œæ?
242 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã?
243 * @og.rev 4.0.0.0 (2006/11/15) SelectionFactory ã« lang 属æ?を追åŠ?—ã¾ã™ã?
244 * @og.rev 4.3.4.0 (2008/12/01) $C対�
245 *
246 * @param buf åæ˜ ã•ã›ã‚‹TagBufferオブジェクãƒ?
247 * @param value é¸æŠžã•れã¦ã?‚‹å€¤
248 *
249 * @return オプションタグ
250 */
251 private TagBuffer getOption( final TagBuffer buf,final String value ) {
252
253 // StringFormat format = new StringFormat( query,value );
254 StringFormat format = new StringFormat( query, value, name ); // 4.3.4.0 (2008/12/01)
255 String newQuery = format.format();
256 String newValue = format.getValue();
257
258 Selection selection = SelectionFactory.newDBSelection( newQuery, dbid, lang );
259
260 if( addNoValue ) {
261 buf.setBody( Selection.NO_VALUE_OPTION + selection.getOption( newValue, seqFlag ) );
262 }
263 else {
264 buf.setBody( selection.getOption( newValue, seqFlag ) );
265 }
266
267 return buf;
268 }
269 }