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 * HTMLAREA エãƒ?‚£ã‚¿ãƒ¼ã¯ã€ã‚«ãƒ©ãƒ??ãƒ??タをテã‚ストエリアã§ç·¨é›?—ã€?
029 * HTMLæ–?—をエスケープã—ã¦ç™»éŒ²ã™ã‚‹å ´åˆã«ä½¿ç”¨ã™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã?
030 *
031 * エスケープã™ã‚‹ä»¥å¤–ã?TEXTAREAã¨åŒæ§˜ã§ã?
032 *
033 * @og.rev 5.5.8.0 (2012/11/01) æ–°è¦ä½œæ?
034 * @og.group �?タ編�
035 *
036 * @version 5.0
037 * @author Takahashi Masakazu
038 * @since JDK5.0,
039 */
040 public class Editor_HTMLAREA extends AbstractEditor {
041 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */
042 private static final String VERSION = "5.5.8.0 (2012/11/01)" ;
043
044 private String rows1 ;
045 private String rows2 ;
046
047 /**
048 * ãƒ?ƒ•ォルトコンストラクターã€?
049 * ã“ã?コンストラクターã§ã€åŸºæœ¬ã‚ªãƒ–ジェクトを作æ?ã—ã¾ã™ã?
050 *
051 */
052 public Editor_HTMLAREA() {
053 // 4.3.4.4 (2009/01/01)
054 // super();
055 }
056
057 /**
058 * コンストラクター�
059 *
060 *
061 * @param clm DBColumnオブジェク�
062 */
063 private Editor_HTMLAREA( final DBColumn clm ) {
064 super( clm );
065 String disabled = clm.isWritable() ? null : "disabled" ;
066
067 int r1 = (clm.getTotalSize()/Integer.parseInt(size1)) + 1; // // 4.0.0 (2005/01/31) メソãƒ?ƒ‰å変更
068 if( r1 > 5 ) { rows1 = "5"; }
069 else { rows1 = String.valueOf( r1 ); }
070
071 int r2 = (clm.getTotalSize()/Integer.parseInt(size2)) + 1; // // 4.0.0 (2005/01/31) メソãƒ?ƒ‰å変更
072 if( r2 > 5 ) { rows2 = "5"; }
073 else { rows2 = String.valueOf( r2 ); }
074
075 // 3.7.0.4 (2005/03/14) size ã«ã€?rows,cols" を指定ã§ãるよã†ã«å¤‰æ›´
076 String param = StringUtil.nval( clm.getEditorParam(),clm.getViewLength() );
077 if( param != null && param.length() != 0 ) {
078 int st = param.indexOf( ',' );
079 if( st > 0 ) {
080 rows1 = param.substring( 0,st );
081 rows2 = rows1 ;
082 size1 = param.substring( st+1 );
083 size2 = size1;
084 }
085 }
086
087 attributes = new Attributes();
088 attributes.set( "disabled" ,disabled );
089
090 attributes.addAttributes( clm.getEditorAttributes() );
091 attributes.add( "class" ,clm.getDbType() ); // 4.0.0 (2005/01/31)
092
093 optAttr = attributes.get( "optionAttributes" );
094 tagBuffer.add( XHTMLTag.textareaAttri( attributes ) );
095 }
096
097 /**
098 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã?
099 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?«
100 * ã¾ã‹ã•れã¾ã™ã?
101 *
102 *
103 * @param clm DBColumnオブジェク�
104 *
105 * @return CellEditorオブジェク�
106 */
107 public CellEditor newInstance( final DBColumn clm ) {
108 return new Editor_HTMLAREA( clm );
109 }
110
111 /**
112 * ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã?
113 *
114 * @param value 入力å?
115 *
116 * @return ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å?
117 */
118 @Override
119 public String getValue( final String value ) {
120
121 TagBuffer tag = new TagBuffer( "textarea" );
122 tag.add( "name" , name );
123 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
124 tag.add( "id" , name ); // 4.3.6.0 (2009/04/01)
125 }
126 tag.add( "cols" , size1 );
127 tag.add( "rows" , rows1 );
128 tag.add( tagBuffer.makeTag() );
129 tag.add( optAttr ); // 3.5.5.8 (2004/05/20)
130 tag.setBody( StringUtil.htmlFilter(value) );
131
132 return tag.makeTag();
133 }
134
135 /**
136 * name属æ?を変ãˆãŸã?ãƒ??タ表示/ç·¨é›?”¨ã®HTMLæ–?—å?を作æ?ã—ã¾ã™ã?
137 * ãƒ??ブル上ã? name 㫠行番å·ã‚’ä»˜åŠ ã—ã¦ã€åå‰_è¡Œç•ªå· ã§ç™»éŒ²ã™ã‚‹ã‚ーを作æ?ã?
138 * ãƒªã‚¯ã‚¨ã‚¹ãƒˆæƒ…å ±ã‚’ï¼‘ã¤æ¯Žã?フィールドã§å‡¦ç?§ãã¾ã™ã?
139 *
140 * @og.rev 3.1.0.0 (2003/03/20) åå‰ã¨è¡Œç•ªå·ã®åŒºåˆ?‚Šè¨˜å·ã‚?"^" ã‹ã‚‰ "__" ã«å¤‰æ›´ã€?
141 * @og.rev 3.5.5.0 (2004/03/12) åå‰ã¨è¡Œç•ªå·ã®åŒºåˆ?‚Šè¨˜å·("__")ã‚’ã?HybsSystem.JOINT_STRING ã«å¤‰æ›´ã€?
142 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã?
143 * @og.rev 5.1.2.0 (2010/01/01) å…ˆé?ã®'_'ã«ã‚ˆã‚‹æ›¸ãè¾¼ã¿åˆ¶å¾¡ã‚’行ã‚ãªã??(ä»–ã?クラスã¨ã®å®Ÿè£??共通化)
144 * @og.rev 5.1.7.0 (2010/06/01) 動的プルãƒ?‚¦ãƒ³å®Ÿè£?¦‹ç›´ã?
145 *
146 * @param row 行番å·
147 * @param value 入力å?
148 *
149 * @return ãƒ??タ表示/ç·¨é›?”¨ã®æ–?—å?
150 */
151 @Override
152 public String getValue( final int row,final String value ) {
153
154 TagBuffer tag = new TagBuffer( "textarea" );
155 String newName = name + HybsSystem.JOINT_STRING + row;
156 // tag.add( "name" , name + HybsSystem.JOINT_STRING + row );
157 tag.add( "name" , newName );
158 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
159 tag.add( "id" , newName );
160 }
161 tag.add( "cols" , size2 );
162 tag.add( "rows" , rows2 );
163 tag.add( tagBuffer.makeTag() );
164 tag.add( optAttr ); // 3.5.5.8 (2004/05/20)
165 tag.setBody( StringUtil.htmlFilter(value) );
166
167 return tag.makeTag( row,StringUtil.htmlFilter(value) );
168 }
169 }