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.fukurou.util.XHTMLTag; 024 import org.opengion.fukurou.util.Attributes; 025 import org.opengion.fukurou.util.TagBuffer; 026 027 /** 028 * MENU エãƒ?‚£ã‚¿ãƒ¼ã¯ã€ã‚«ãƒ©ãƒ??ãƒ??タをコードリソースã«å¯¾å¿œã—ã? 029 * プルãƒ?‚¦ãƒ³ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã§ç·¨é›?™ã‚‹å?åˆã«ä½¿ç”¨ã™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã? 030 * 031 * カラãƒ??表示ã«å¿?¦ãªå±žæ?ã¯, DBColumn オブジェクãƒ?よりå–り出ã—ã¾ã™ã? 032 * ã“ã?クラスã¯ã€DBColumn オブジェクト毎ã«?‘ã¤ä½œæ?ã•れã¾ã™ã? 033 * 034 * @og.group ãƒ??ã‚¿ç·¨é›? 035 * 036 * @version 4.0 037 * @author Kazuhiko Hasegawa 038 * @since JDK5.0, 039 */ 040 public class Editor_MENU extends AbstractEditor { 041 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */ 042 private static final String VERSION = "5.5.1.0 (2012/04/03)" ; 043 044 // 3.2.3.0 (2003/06/06) final を削除。サブクラスã‹ã‚‰ã‚¢ã‚¯ã‚»ã‚¹ã§ãるよã†ã«å¤‰æ›´ã€? 045 /** セレクションオブジェクãƒ?*/ 046 protected Selection selection ; 047 private final boolean addNoValue ; // 3.5.5.7 (2004/05/10) 048 /** シーケンスフラグ */ 049 protected boolean seqFlag ; // 3.6.0.6 (2004/10/22) 050 private final String useSLabel ; // 5.5.1.0 (2012/04/03) 051 052 /** 053 * ãƒ?ƒ•ォルトコンストラクターã€? 054 * ã“ã?コンストラクターã§ã€åŸºæœ¬ã‚ªãƒ–ジェクトを作æ?ã—ã¾ã™ã? 055 * 056 * @og.rev 3.1.1.1 (2003/04/03) å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã™ãƒ•ァクトリメソãƒ?ƒ‰ã‚’追åŠ?? 057 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã? 058 * @og.rev 5.5.1.0 (2012/04/03) Slabel対å¿? 059 * 060 */ 061 public Editor_MENU() { 062 // 4.3.4.4 (2009/01/01) 063 // super(); 064 selection = null; 065 addNoValue = false; // 3.5.5.7 (2004/05/10) 066 seqFlag = false; // 3.6.0.6 (2004/10/22) 067 useSLabel = "auto"; // 5.5.1.0 (2012/04/03) 068 } 069 070 /** 071 * コンストラクターã€? 072 * 073 * @og.rev 3.1.1.1 (2003/04/03) å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã™ãƒ•ァクトリメソãƒ?ƒ‰ã‚’追åŠ?? 074 * @og.rev 3.3.1.1 (2003/07/03) name , attributes 属æ?ã‚?final ã«ã™ã‚‹ã€? 075 * @og.rev 3.5.4.2 (2003/12/15) makeCodeSelection メソãƒ?ƒ‰ã‚?CodeSelectionクラスã«å¤‰æ›´ã€? 076 * @og.rev 3.5.5.7 (2004/05/10) SelectionFactory を使用ã—ã¦ã€ã‚ªãƒ–ジェクト作æ? 077 * @og.rev 3.5.5.7 (2004/05/10) addNoValue 属æ?を追åŠ?—ã¾ã™ã? 078 * @og.rev 3.5.6.0 (2004/06/18) XHTMLTag ã® å†?ƒ¨é…å? SELECT_KEY ã‚’éš è”½ã—ã¾ã™ã? 079 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã? 080 * @og.rev 4.0.0.0 (2005/01/31) Selection_CODE ã®ä½œæ?ã®å¼•æ•°ã‚?CodeData ã«å¤‰æ›´ã€? 081 * @og.rev 4.0.0.0 (2007/11/07) SelectionオブジェクトをDBColumnã‹ã‚‰å–å¾? 082 * @og.rev 5.1.7.0 (2010/06/01) 動的プルãƒ?‚¦ãƒ³å®Ÿè£?¦‹ç›´ã? 083 * @og.rev 5.5.1.0 (2012/04/03) Slabel対å¿? 084 * 085 * @param clm DBColumnオブジェクãƒ? 086 */ 087 protected Editor_MENU( final DBColumn clm ) { 088 // super( clm ); 089 name = clm.getName(); 090 addNoValue = clm.isAddNoValue() ; // 3.5.5.7 (2004/05/10) 091 seqFlag = "SEQ".equals( clm.getEditorParam() ); // 3.6.0.6 (2004/10/22) 092 // eventColumn = clm.getEventColumn(); // 4.3.6.0 (2009/04/01) 093 // eventURL = clm.getEventURL(); // 4.3.6.0 (2009/04/01) 094 // editor = clm.getEditor(); // 4.3.6.0 (2009/04/01) 095 useSLabel = clm.getUseSLabel() ; // 5.5.1.0 (2012/04/03) 096 097 String disabled = clm.isWritable() ? null : "disabled" ; 098 099 attributes = new Attributes(); 100 attributes.set( "disabled" ,disabled ); 101 102 attributes.addAttributes( clm.getEditorAttributes() ); 103 optAttr = attributes.get( "optionAttributes" ); 104 tagBuffer.add( XHTMLTag.selectAttri( attributes ) ); 105 106 selection = clm.getSelection(); // 4.0.0 (2005/01/31) 107 // 5.6.1.1 (2013/02/08) 暫定å?ç½® 108 if( selection != null ) { 109 boolean useMultiSelect = selection.useMultiSelect(); 110 if( useMultiSelect ) { tagBuffer.add( "onkeydown" , "setKeySelect(this);" ); } 111 } 112 } 113 114 /** 115 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã? 116 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?« 117 * ã¾ã‹ã•れã¾ã™ã? 118 * 119 * @og.rev 3.1.1.1 (2003/04/03) å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã™ãƒ•ァクトリメソãƒ?ƒ‰ã‚’追åŠ?? 120 * @og.rev 3.1.2.1 (2003/04/10) synchronized ã‚’ã?削除ã—ã¾ã™ã? 121 * 122 * @param clm DBColumnオブジェクãƒ? 123 * 124 * @return CellEditorオブジェクãƒ? 125 */ 126 public CellEditor newInstance( final DBColumn clm ) { 127 return new Editor_MENU( clm ); 128 } 129 130 /** 131 * ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã? 132 * 133 * @og.rev 3.5.5.5 (2004/04/23) æ–°è¦ã« Attributes オブジェクトを作æ?ã™ã‚‹æ–¹å¼ã‚’æ¢ã‚ã¾ã™ã? 134 * @og.rev 3.5.5.7 (2004/05/10) addNoValue 属æ?を追åŠ?—ã¾ã™ã? 135 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã? 136 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã? 137 * @og.rev 5.1.3.0 (2010/02/01) ä¸?¦§è¡¨ç¤ºã®ã¿ã§ã€ãƒ„ールãƒãƒƒãƒ—表示を行ã†ã€? 138 * @og.rev 5.1.7.0 (2010/06/01) 動的プルãƒ?‚¦ãƒ³å®Ÿè£?¦‹ç›´ã? 139 * @og.rev 5.5.1.0 (2012/04/03) useSLabel対å¿? 140 * 141 * @param value 入力å? 142 * 143 * @return ãƒ??ã‚¿ã®ç·¨é›?”¨æ–?—å? 144 */ 145 @Override 146 public String getValue( final String value ) { 147 // final boolean uslbl = !"true".equals(useSLabel) ? false : true; // 5.5.1.0 (2012/04/03) 148 final boolean uslbl = "true".equalsIgnoreCase( useSLabel ); // 5.5.1.0 (2012/04/03) 149 150 TagBuffer tag = new TagBuffer( "select" ); 151 tag.add( "name" , name ); 152 tag.add( tagBuffer.makeTag() ); 153 tag.add( optAttr ); // 3.5.5.8 (2004/05/20) 154 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15) 155 tag.add( "id" , name ); // 4.3.6.0 (2009/04/01) 156 } 157 158 if( addNoValue ) { 159 // 5.1.3.0 (2010/02/01) 160 // tag.setBody( Selection.NO_VALUE_OPTION + selection.getOption( value,seqFlag ) ); 161 // tag.setBody( Selection.NO_VALUE_OPTION + selection.getOption( value,seqFlag,false ) ); 162 tag.setBody( Selection.NO_VALUE_OPTION + selection.getOption( value,seqFlag,uslbl ) ); // 5.5.1.0 (2012/04/03) 163 } 164 else { 165 // 5.1.3.0 (2010/02/01) 166 // tag.setBody( selection.getOption( value,seqFlag ) ); 167 // tag.setBody( selection.getOption( value,seqFlag,false ) ); 168 tag.setBody( selection.getOption( value,seqFlag,uslbl ) ); // 5.5.1.0 (2012/04/03) 169 } 170 171 return tag.makeTag(); 172 // return tag.makeTag() + createEventColumnJS( name, editor, -1, eventURL ); // 4.3.6.0 (2009/04/01) 173 } 174 175 /** 176 * name属æ?を変ãˆãŸã?ãƒ??タ表示/ç·¨é›?”¨ã®HTMLæ–?—å?を作æ?ã—ã¾ã™ã? 177 * ãƒ??ブル上ã? name 㫠行番å·ã‚’ä»˜åŠ ã—ã¦ã€åå‰_è¡Œç•ªå· ã§ç™»éŒ²ã™ã‚‹ã‚ーを作æ?ã? 178 * ãƒªã‚¯ã‚¨ã‚¹ãƒˆæƒ…å ±ã‚’ï¼‘ã¤æ¯Žã?フィールドã§å‡¦ç?§ãã¾ã™ã? 179 * 180 * @og.rev 2.0.0.3 (2002/09/26) optionAttributes 属æ?ã« "$i" を使ã?¨ãã?行数ã«ç½®ãæ›ã‚‹æ©Ÿè?を追åŠ?? 181 * @og.rev 3.1.0.0 (2003/03/20) åå‰ã¨è¡Œç•ªå·ã®åŒºåˆ?‚Šè¨˜å·ã‚?"^" ã‹ã‚‰ "__" ã«å¤‰æ›´ã€? 182 * @og.rev 3.5.5.0 (2004/03/12) åå‰ã¨è¡Œç•ªå·ã®åŒºåˆ?‚Šè¨˜å·("__")ã‚’ã?HybsSystem.JOINT_STRING ã«å¤‰æ›´ã€? 183 * @og.rev 3.5.5.5 (2004/04/23) æ–°è¦ã« Attributes オブジェクトを作æ?ã™ã‚‹æ–¹å¼ã‚’æ¢ã‚ã¾ã™ã? 184 * @og.rev 3.5.5.7 (2004/05/10) addNoValue 属æ?を追åŠ?—ã¾ã™ã? 185 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?(seqFlag)を追åŠ?—ã¾ã? 186 * @og.rev 4.3.7.2 (2009/06/15) 属æ?ã§idãŒå?力ã•ã‚Œã‚‹å ´åˆã?ã€idã‚’å?力ã—ãªã? 187 * @og.rev 5.1.3.0 (2010/02/01) ä¸?¦§è¡¨ç¤ºã®ã¿ã§ã€ãƒ„ールãƒãƒƒãƒ—表示を行ã†ã€? 188 * @og.rev 5.1.7.0 (2010/06/01) 動的プルãƒ?‚¦ãƒ³å®Ÿè£?¦‹ç›´ã? 189 * @og.rev 5.5.1.0 (2012/04/03) useSLabel対å¿? 190 * 191 * @param row è¡Œç•ªå· 192 * @param value 入力å? 193 * 194 * @return ãƒ??タ表示/ç·¨é›?”¨ã®æ–?—å? 195 */ 196 @Override 197 public String getValue( final int row,final String value ) { 198 // final boolean uslbl = ("auto".equals(useSLabel) || "true".equals(useSLabel) ) ? true : false; // 5.5.1.0 (2012/04/03) 199 final boolean uslbl = "auto".equalsIgnoreCase( useSLabel ) || "true".equalsIgnoreCase( useSLabel ); // 5.5.1.0 (2012/04/03) 200 201 TagBuffer tag = new TagBuffer( "select" ); 202 String newName = name + HybsSystem.JOINT_STRING + row; // 4.3.6.0 (2009/04/01) 203 // tag.add( "name" , name + HybsSystem.JOINT_STRING + row ); 204 tag.add( "name", newName ); // 4.3.6.0 (2009/04/01) 205 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15) 206 tag.add( "id" , newName ); // 4.3.6.0 (2009/04/01) 207 } 208 tag.add( tagBuffer.makeTag() ); 209 tag.add( optAttr ); // 3.5.5.8 (2004/05/20) 210 211 if( addNoValue ) { 212 // 5.1.3.0 (2010/02/01) 213 // tag.setBody( Selection.NO_VALUE_OPTION + selection.getOption( value,seqFlag ) ); 214 // tag.setBody( Selection.NO_VALUE_OPTION + selection.getOption( value,seqFlag,true ) ); 215 tag.setBody( Selection.NO_VALUE_OPTION + selection.getOption( value,seqFlag,uslbl ) ); // 5.5.1.0 (2012/04/03) 216 } 217 else { 218 // 5.1.3.0 (2010/02/01) 219 // tag.setBody( selection.getOption( value,seqFlag ) ); 220 // tag.setBody( selection.getOption( value,seqFlag,true ) ); 221 tag.setBody( selection.getOption( value,seqFlag,uslbl ) ); // 5.5.1.0 (2012/04/03) 222 } 223 224 return tag.makeTag( row,value ); 225 // return tag.makeTag( row,value ) + createEventColumnJS( name, editor, row, eventURL ); // 4.3.6.0 (2009/04/01) 226 } 227 }