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 * ãƒªã‚¯ã‚¨ã‚¹ãƒˆæƒ…å ±ã‚’ï¼‘ã¤æ¯Žã?フィールドã§å‡¦ç?§ãã¾ã™ã?
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 }