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.db.AbstractEditor;
020 import org.opengion.hayabusa.db.CellEditor;
021 import org.opengion.hayabusa.db.DBColumn;
022 import org.opengion.hayabusa.db.Selection;
023 // import org.opengion.hayabusa.db.Selection_RADIO; // 5.7.3.0 (2014/02/07) SelectionFactory を使ã�?§˜に変更
024 import org.opengion.hayabusa.db.SelectionFactory; // 5.7.3.0 (2014/02/07)
025 import org.opengion.fukurou.util.Attributes;
026 import org.opengion.fukurou.util.TagBuffer;
027 import org.opengion.fukurou.util.XHTMLTag;
028
029 /**
030 * RADIO エãƒ?‚£ターは、カラãƒ??ãƒ??タをコードリソースに対応したラジオボタンで編é›?�™ã‚?
031 * 場合に使用するクラスですã?
032 * ラジオボタンは、ラベルがなã�?ж態で表示される為ã€?�‹用時には、ラベルに
033 * 値(選択肢のラベル)を作æ?して、columnEditor 等で登録して置ã�?�¦くださいã€?
034 *
035 * ä¸?¦§検索明細登録画面等で、ラベル表示がå¿?¦�な場合ã?、編é›?ƒ‘ラメータにã€?useLabel"と
036 * 記述しておくことで、ラベルをå?力することが可能ですã?
037 *
038 * こã?エãƒ?‚£タはeventColumnに対応してã�?�¾せんã€?
039 *
040 * カラãƒ??表示にå¿?¦�な属æ?は, DBColumn オブジェクãƒ?より取り出しますã?
041 * こã?クラスは、DBColumn オブジェクト毎に?‘つ作æ?されますã?
042 *
043 * @og.rev 3.5.1.0 (2003/10/03) 新規作æ?
044 * @og.group ãƒ??タ編é›?
045 *
046 * @version 4.0
047 * @author Kazuhiko Hasegawa
048 * @since JDK5.0,
049 */
050 public class Editor_RADIO extends AbstractEditor {
051 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
052 private static final String VERSION = "5.7.3.0 (2014/02/07)" ;
053
054 private final Selection selection ;
055 private final boolean writable ;
056 private final boolean useLabel ; // 4.3.3.0 (2008/10/01)
057
058 /**
059 * ãƒ?ƒ•ォルトコンストラクターã€?
060 * こã?コンストラクターで、基本オブジェクトを作æ?しますã?
061 *
062 */
063 public Editor_RADIO() {
064 // 4.3.4.4 (2009/01/01)
065 // super();
066 selection = null;
067 writable = false;
068 useLabel = false; // 4.3.3.0 (2008/10/01)
069 }
070
071 /**
072 * コンストラクターã€?
073 *
074 * @og.rev 3.5.4.2 (2003/12/15) makeCodeSelection メソãƒ?ƒ‰ã‚?CodeSelectionクラスに変更ã€?
075 * @og.rev 3.5.5.7 (2004/05/10) SelectionFactory を使用して、オブジェクト作æ?
076 * @og.rev 4.0.0.0 (2005/01/31) SelectionFactory ではなくã?直接 Selection_RADIO を作æ?ã€?
077 * @og.rev 4.3.3.0 (2008/10/01) 編é›?ƒ‘ラメーターで明細表示時でもラベルが使えるように対å¿?
078 * @og.rev 5.7.3.0 (2014/02/07) SelectionFactory 対å¿?
079 *
080 * @param clm DBColumnオブジェクãƒ?
081 */
082 private Editor_RADIO( final DBColumn clm ) {
083 // super( clm );
084 name = clm.getName();
085 // 5.7.3.0 (2014/02/07) SelectionFactory 対å¿?
086 // selection = new Selection_RADIO( clm.getCodeData() ); // 4.0.0 (2005/01/31)
087 selection = SelectionFactory.newSelection( "RADIO" , clm.getCodeData() );
088
089 writable = clm.isWritable();
090
091 attributes = new Attributes();
092 attributes.addAttributes( clm.getEditorAttributes() );
093
094 attributes.add( "class","RADIO" ); // (2003/10/08 修正åˆ?
095 tagBuffer.add( XHTMLTag.inputAttri( attributes ) );
096
097 optAttr = attributes.get( "optionAttributes" );
098
099 // 4.3.3.0 (2008/10/01)
100 useLabel = ( "useLabel".equalsIgnoreCase( clm.getEditorParam() ) ) ? true : false;
101 }
102
103 /**
104 * å�?‚ªブジェクトからè?åˆ??インスタンスを返しますã?
105 * 自åˆ??身をキャãƒ?‚·ュするのかã?新たに作æ?するのかã?、各サブクラスの実è£?�«
106 * まかされますã?
107 *
108 * @param clm DBColumnオブジェクãƒ?
109 *
110 * @return CellEditorオブジェクãƒ?
111 */
112 public CellEditor newInstance( final DBColumn clm ) {
113 return new Editor_RADIO( clm );
114 }
115
116 /**
117 * ãƒ??タの編é›?”¨æ–?—å?を返しますã?
118 *
119 * @param value 入力å?
120 *
121 * @return ãƒ??タの編é›?”¨æ–?—å?
122 */
123 @Override
124 public String getValue( final String value ) {
125 final String radio ;
126 if( writable ) {
127 radio = selection.getRadio( name,value,true );
128 }
129 else {
130 radio = selection.getValueLabel( value );
131 }
132
133 TagBuffer tag = new TagBuffer( "pre" );
134 tag.add( tagBuffer.makeTag() );
135 tag.add( optAttr ); // 3.5.5.8 (2004/05/20)
136 tag.setBody( radio );
137
138 return tag.makeTag();
139 }
140
141 /**
142 * name属æ?を変えたã?ãƒ??タ表示/編é›?”¨のHTMLæ–?—å?を作æ?しますã?
143 * ãƒ??ブル上ã? name に 行番号を付加して、名前_行番号 で登録するキーを作æ?ã�?
144 * リクエスト情報を1つ毎ã?フィールドで処ç�?�§きますã?
145 *
146 * @og.rev 3.5.5.0 (2004/03/12) 名前と行番号の区åˆ?‚Š記号("__")をã?HybsSystem.JOINT_STRING に変更ã€?
147 * @og.rev 3.5.5.5 (2004/04/23) changeOptionAttributes をå»?¢しますã?
148 * @og.rev 4.3.3.0 (2008/10/01) 編é›?ƒ‘ラメーターで明細表示時でもラベルが使えるように対å¿?
149 *
150 * @param row 行番号
151 * @param value 入力å?
152 *
153 * @return ãƒ??タ表示/編é›?”¨のæ–?—å?
154 */
155 @Override
156 public String getValue( final int row,final String value ) {
157 final String radio ;
158 if( writable ) {
159 // 4.3.3.0 (2008/10/01)
160 // radio = selection.getRadio( name + HybsSystem.JOINT_STRING + row,value,false );
161 radio = selection.getRadio( name + HybsSystem.JOINT_STRING + row,value,useLabel );
162 }
163 else {
164 radio = selection.getRadioLabel( value );
165 }
166
167 TagBuffer tag = new TagBuffer( "pre" );
168 tag.add( tagBuffer.makeTag() );
169 tag.setBody( radio );
170 tag.add( optAttr ); // 3.5.5.8 (2004/05/20)
171
172 return tag.makeTag( row,value );
173 }
174 }