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.db.AbstractEditor; 019 import org.opengion.hayabusa.db.CellEditor; 020 import org.opengion.hayabusa.db.DBColumn; 021 import org.opengion.fukurou.util.XHTMLTag; 022 import org.opengion.hayabusa.common.HybsSystem; 023 import org.opengion.fukurou.util.Attributes; 024 import org.opengion.fukurou.util.StringUtil; 025 import org.opengion.fukurou.util.TagBuffer; 026 027 /** 028 * TEXTAREA エãƒ?‚£ã‚¿ãƒ¼ã¯ã€ã‚«ãƒ©ãƒ??ãƒ??タをテã‚ストエリアã§ç·¨é›?™ã‚‹å?åˆã« 029 * 使用ã™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã? 030 * 031 * 従æ¥ã¨ã®é•ã„ã¯ã€cols 属æ?ã®æœ?¤§å€¤ã‚’ã?検索æ™?queryç”»é¢)ã§ã¯ã€HTML_COLUMNS_MAXSIZE ã‚’ã? 032 * 登録æ™?resultç”»é¢)ã§ã¯ã€HTML_VIEW_COLUMNS_MAXSIZE を使用ã—ã¾ã™ã? 033 * エリアã®å¤§ãã•ã¯ã€ãƒ‡ãƒ•ォルトå?を使用ã™ã‚‹ã‹ã?ç·¨é›?ƒ‘ラメータã«ã€x,yå½¢å¼ã§ 034 * æŒ?®šã—ã¾ã™ã? 035 * カラãƒ??表示ã«å¿?¦ãªå±žæ?ã¯, DBColumn オブジェクãƒ?よりå–り出ã—ã¾ã™ã? 036 * ã“ã?クラスã¯ã€DBColumn オブジェクト毎ã«?‘ã¤ä½œæ?ã•れã¾ã™ã? 037 * 038 * @og.rev 4.0.0.0 (2005/01/31) æ–°è¦ä½œæ? 039 * @og.group ãƒ??ã‚¿ç·¨é›? 040 * 041 * @version 4.0 042 * @author Kazuhiko Hasegawa 043 * @since JDK5.0, 044 */ 045 public class Editor_TEXTAREA extends AbstractEditor { 046 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */ 047 private static final String VERSION = "5.1.7.0 (2010/06/01)" ; 048 049 private String rows1 ; 050 private String rows2 ; 051 052 /** 053 * ãƒ?ƒ•ォルトコンストラクターã€? 054 * ã“ã?コンストラクターã§ã€åŸºæœ¬ã‚ªãƒ–ジェクトを作æ?ã—ã¾ã™ã? 055 * 056 * @og.rev 3.1.1.1 (2003/04/03) å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã™ãƒ•ァクトリメソãƒ?ƒ‰ã‚’追åŠ?? 057 * 058 */ 059 public Editor_TEXTAREA() { 060 // 4.3.4.4 (2009/01/01) 061 // super(); 062 } 063 064 /** 065 * コンストラクターã€? 066 * 067 * @og.rev 3.1.1.1 (2003/04/03) å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã™ãƒ•ァクトリメソãƒ?ƒ‰ã‚’追åŠ?? 068 * @og.rev 3.2.4.0 (2003/06/12) パラメータよりã€è¡Œå?(row,column)æƒ??ãŒã‚れã?ã€ãã®å€¤ã‚’利用ã™ã‚‹ã€? 069 * @og.rev 3.3.1.1 (2003/07/03) name , attributes 属æ?ã‚?final ã«ã™ã‚‹ã€? 070 * @og.rev 3.4.0.0 (2003/09/01) 表示パラメータã€ç·¨é›?ƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã€æ–‡å—パラメータã®è¿½åŠ?? 071 * @og.rev 3.5.5.0 (2004/03/12) æ¼¢å—å?åŠ?IMEモーãƒ?ã‚’ONã«ã™ã‚‹ã®ã‚’ã?"K" ã¨ã€?KX" ã®ã¿ã¨ã—ã¾ã™ã? 072 * @og.rev 3.5.6.0 (2004/06/18) XHTMLTag ã® å†?ƒ¨é…å? TEXTAREA_KEY ã‚’éš è”½ã—ã¾ã™ã? 073 * @og.rev 4.0.0.0 (2005/01/31) DBColumn ã® getClassName() ã‚?getDbType() ã«å¤‰æ›´ 074 * 075 * @param clm DBColumnオブジェクãƒ? 076 */ 077 private Editor_TEXTAREA( final DBColumn clm ) { 078 super( clm ); 079 String disabled = clm.isWritable() ? null : "disabled" ; 080 081 int r1 = (clm.getTotalSize()/Integer.parseInt(size1)) + 1; // // 4.0.0 (2005/01/31) メソãƒ?ƒ‰å変更 082 if( r1 > 5 ) { rows1 = "5"; } 083 else { rows1 = String.valueOf( r1 ); } 084 085 int r2 = (clm.getTotalSize()/Integer.parseInt(size2)) + 1; // // 4.0.0 (2005/01/31) メソãƒ?ƒ‰å変更 086 if( r2 > 5 ) { rows2 = "5"; } 087 else { rows2 = String.valueOf( r2 ); } 088 089 // 3.7.0.4 (2005/03/14) size ã«ã€?rows,cols" を指定ã§ãるよã†ã«å¤‰æ›´ 090 String param = StringUtil.nval( clm.getEditorParam(),clm.getViewLength() ); 091 if( param != null && param.length() != 0 ) { 092 int st = param.indexOf( ',' ); 093 if( st > 0 ) { 094 rows1 = param.substring( 0,st ); 095 rows2 = rows1 ; 096 size1 = param.substring( st+1 ); 097 size2 = size1; 098 } 099 } 100 101 attributes = new Attributes(); 102 attributes.set( "disabled" ,disabled ); 103 104 attributes.addAttributes( clm.getEditorAttributes() ); 105 attributes.add( "class" ,clm.getDbType() ); // 4.0.0 (2005/01/31) 106 107 optAttr = attributes.get( "optionAttributes" ); 108 tagBuffer.add( XHTMLTag.textareaAttri( attributes ) ); 109 } 110 111 /** 112 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã? 113 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?« 114 * ã¾ã‹ã•れã¾ã™ã? 115 * 116 * @og.rev 3.1.1.1 (2003/04/03) å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã™ãƒ•ァクトリメソãƒ?ƒ‰ã‚’追åŠ?? 117 * @og.rev 3.1.2.1 (2003/04/10) synchronized ã‚’ã?削除ã—ã¾ã™ã? 118 * 119 * @param clm DBColumnオブジェクãƒ? 120 * 121 * @return CellEditorオブジェクãƒ? 122 */ 123 public CellEditor newInstance( final DBColumn clm ) { 124 return new Editor_TEXTAREA( clm ); 125 } 126 127 /** 128 * ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã? 129 * 130 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã? 131 * @og.rev 5.1.2.0 (2010/01/01) å…ˆé?ã®'_'ã«ã‚ˆã‚‹æ›¸ãè¾¼ã¿åˆ¶å¾¡ã‚’行ã‚ãªã??(ä»–ã?クラスã¨ã®å®Ÿè£??共通化) 132 * @og.rev 5.1.7.0 (2010/06/01) 動的プルãƒ?‚¦ãƒ³å®Ÿè£?¦‹ç›´ã? 133 * 134 * @param value 入力å? 135 * 136 * @return ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å? 137 */ 138 @Override 139 public String getValue( final String value ) { 140 // if( value != null && value.length() >= 1 && value.charAt(0) == '_' ) { 141 // return value.substring( 1 ); 142 // } 143 144 TagBuffer tag = new TagBuffer( "textarea" ); 145 tag.add( "name" , name ); 146 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15) 147 tag.add( "id" , name ); // 4.3.6.0 (2009/04/01) 148 } 149 tag.add( "cols" , size1 ); 150 tag.add( "rows" , rows1 ); 151 tag.add( tagBuffer.makeTag() ); 152 tag.add( optAttr ); // 3.5.5.8 (2004/05/20) 153 tag.setBody( value ); 154 155 return tag.makeTag(); 156 // return tag.makeTag() + createEventColumnJS( name, editor, -1, eventURL ); // 4.3.6.0 (2009/04/01) 157 } 158 159 /** 160 * name属æ?を変ãˆãŸã?ãƒ??タ表示/ç·¨é›?”¨ã®HTMLæ–?—å?を作æ?ã—ã¾ã™ã? 161 * ãƒ??ブル上ã? name 㫠行番å·ã‚’ä»˜åŠ ã—ã¦ã€åå‰_è¡Œç•ªå· ã§ç™»éŒ²ã™ã‚‹ã‚ーを作æ?ã? 162 * ãƒªã‚¯ã‚¨ã‚¹ãƒˆæƒ…å ±ã‚’ï¼‘ã¤æ¯Žã?フィールドã§å‡¦ç?§ãã¾ã™ã? 163 * 164 * @og.rev 3.1.0.0 (2003/03/20) åå‰ã¨è¡Œç•ªå·ã®åŒºåˆ?‚Šè¨˜å·ã‚?"^" ã‹ã‚‰ "__" ã«å¤‰æ›´ã€? 165 * @og.rev 3.5.5.0 (2004/03/12) åå‰ã¨è¡Œç•ªå·ã®åŒºåˆ?‚Šè¨˜å·("__")ã‚’ã?HybsSystem.JOINT_STRING ã«å¤‰æ›´ã€? 166 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã? 167 * @og.rev 5.1.2.0 (2010/01/01) å…ˆé?ã®'_'ã«ã‚ˆã‚‹æ›¸ãè¾¼ã¿åˆ¶å¾¡ã‚’行ã‚ãªã??(ä»–ã?クラスã¨ã®å®Ÿè£??共通化) 168 * @og.rev 5.1.7.0 (2010/06/01) 動的プルãƒ?‚¦ãƒ³å®Ÿè£?¦‹ç›´ã? 169 * 170 * @param row è¡Œç•ªå· 171 * @param value 入力å? 172 * 173 * @return ãƒ??タ表示/ç·¨é›?”¨ã®æ–?—å? 174 */ 175 @Override 176 public String getValue( final int row,final String value ) { 177 // if( value != null && value.length() >= 1 && value.charAt(0) == '_' ) { 178 // return value.substring( 1 ); 179 // } 180 181 TagBuffer tag = new TagBuffer( "textarea" ); 182 String newName = name + HybsSystem.JOINT_STRING + row; 183 // tag.add( "name" , name + HybsSystem.JOINT_STRING + row ); 184 tag.add( "name" , newName ); 185 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15) 186 tag.add( "id" , newName ); 187 } 188 tag.add( "cols" , size2 ); 189 tag.add( "rows" , rows2 ); 190 tag.add( tagBuffer.makeTag() ); 191 tag.add( optAttr ); // 3.5.5.8 (2004/05/20) 192 tag.setBody( value ); 193 194 return tag.makeTag( row,value ); 195 // return tag.makeTag( row,value ) + createEventColumnJS( name, editor, row, eventURL ); // 4.3.6.0 (2009/04/01) 196 } 197 }