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 */ 016package org.opengion.plugin.column; 017 018import org.opengion.hayabusa.common.HybsSystem; 019import org.opengion.hayabusa.db.AbstractEditor; 020import org.opengion.hayabusa.db.CellEditor; 021import org.opengion.hayabusa.db.DBColumn; 022import org.opengion.fukurou.util.XHTMLTag; 023import org.opengion.fukurou.util.TagBuffer; 024 025import static org.opengion.fukurou.util.StringUtil.isNull; // 6.1.1.0 (2015/01/17) 026 027/** 028 * YMD エディターは、カラムのデータを日付(年/月/日)編集する場合に使用するクラスです。 029 * YMD2はカレンダーのポップアップボタンが付属するタイプです。 030 * 031 * このエディタはeventColumnに対応していません。 032 * 033 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 034 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 035 * 036 * @og.rev 3.5.6.2 (2004/07/05) 新規作成 037 * @og.rev 5.4.3.6 (2012/01/19) コメント修正 038 * @og.rev 5.6.5.2 (2013/06/21) ポップアップ変更 039 * @og.rev 5.9.4.0 (2016/01/08) type=button追加,背景色transparent 040 * @og.rev 5.9.4.3 (2016/01/15) buttonのpadding:0 041 * @og.rev 7.3.2.3 (2021/04/09) システム定数のICON_DIRやIMAGE_DIRを使用します。 042 * 043 * @og.group データ編集 044 * 045 * @version 4.0 046 * @author Kazuhiko Hasegawa 047 * @since JDK5.0, 048 */ 049public class Editor_YMD2 extends AbstractEditor { 050 /** このプログラムのVERSION文字列を設定します。 {@value} */ 051 private static final String VERSION = "6.9.8.0 (2018/05/28)" ; 052 053 // 5.6.5.2 (2013/06/21) htmlからjspに変更 054 // 6.0.2.5 (2014/10/31) height,width に、"px"を追加 055 // 5.9.4.0 (2016/01/09) type=button追加 056 // 6.5.0.1 (2016/10/21) サイズ変更 '250px','265px' → '265px','260px' 057 // 4.3.6.7 (2009/05/22) FireFox対応 058 // 5.9.4.0 背景色transparent 5.9.4.3 padding 059 // 6.4.2.0 (2016/01/29) alt属性にtitle属性を追記。 060 061 // 7.3.2.3 (2021/04/09) システム定数のICON_DIRやIMAGE_DIRを使用します。 062 private static final String JSP = HybsSystem.sys( "JSP" ) ; 063 private static final String JSP_ICON = HybsSystem.sys( "JSP_ICON" ) ; 064 065// private static final String CAL1 = "<button type=\"button\" onclick=\"ogPopup('../common/calendar.jsp','265px','260px',null,this,new Array('" ; 066 private static final String CAL1 = "<button type=\"button\" onclick=\"ogPopup('" + JSP + "/common/calendar.jsp','265px','260px',null,this,new Array('" ; 067 068 // 6.8.5.0 (2018/01/09) 069// private static final String CAL3 = "<button type=\"button\" onclick=\"ogPopup('../common/calendar_3month.jsp','320px','770px',null,this,new Array('" ; 070 private static final String CAL3 = "<button type=\"button\" onclick=\"ogPopup('" + JSP + "/common/calendar_3month.jsp','320px','770px',null,this,new Array('" ; 071 072 // 6.8.5.0 (2018/01/09) とりあえず、CAL1 と CAL3 しかないので、決め打ち 073 // 6.9.8.0 (2018/05/28) キーワード変更(CAL_ST → CAL_STR) 074 private static final String CAL_STR = "CAL1".equals( HybsSystem.sys( "CALENDAR_POPUP_TYPE" ) ) ? CAL1 : CAL3 ; 075 076// // 6.8.5.0 (2018/01/09) キーワード変更(CAL2 → CAL_END) 077// private static final String CAL_END = "'),event); return false;\" style=\"background-color:transparent;border:0px;padding:0;\">" 078// + "<img src=\"../image/calendar.gif\" alt=\"Calendar\" title=\"Calendar\"/></button>"; 079 // 5.9.32.3command,p_appendの対応 080 // 7.0.1.0 (2018/10/15) XHTML → HTML5 対応(空要素の、"/>" 止めを、">" に変更します)。 081 // 7.4.2.2 (2021/05/28) タブレット用にボタンを大きくしたので、元に戻します。 082// private static final String CAL_END = "'),'NEW',false,event); return false;\" style=\"background-color:transparent;border:0px;padding:0;\">" 083 private static final String CAL_END = "'),'NEW',false,event); return false;\" style=\"background-color:transparent;border:0px;padding:0;min-width:0;margin:0;\">" 084// + "<img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>"; 085// + "<img src=\"../image/calendar.gif\" alt=\"Calendar\"></button>"; 086 + "<img src=\"" + JSP_ICON + "/calendar.gif\" alt=\"Calendar\"></button>"; 087 088 // 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 089 private final boolean disabled ; 090 091 /** 092 * デフォルトコンストラクター。 093 * このコンストラクターで、基本オブジェクトを作成します。 094 * 095 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 096 */ 097// public Editor_YMD2() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 098 public Editor_YMD2() { 099 super(); 100 disabled = false; 101 } 102 103 /** 104 * DBColumnオブジェクトを指定したprivateコンストラクター。 105 * 106 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 107 * 108 * @param clm DBColumnオブジェクト 109 */ 110 private Editor_YMD2( final DBColumn clm ) { 111 super( clm ); 112 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 113 114 disabled = "disabled".equalsIgnoreCase( attributes.get( "disabled" ) ); // 6.9.8.0 (2018/05/28) 115 } 116 117 /** 118 * 各オブジェクトから自分のインスタンスを返します。 119 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 120 * まかされます。 121 * 122 * @param clm DBColumnオブジェクト 123 * 124 * @return CellEditorオブジェクト 125 * @og.rtnNotNull 126 */ 127 public CellEditor newInstance( final DBColumn clm ) { 128 return new Editor_YMD2( clm ); 129 } 130 131 /** 132 * データの編集用文字列を返します。 133 * 134 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 135 * @og.rev 6.8.5.0 (2018/01/09) カレンダポップアップで、3ヶ月ピッカー対応 136 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 137 * 138 * @param value 入力値 139 * 140 * @return データの編集用文字列 141 * @og.rtnNotNull 142 */ 143 @Override 144 public String getValue( final String value ) { 145 // 6.1.1.0 (2015/01/17) TagBufferの連結記述 146 final String tag = new TagBuffer( "input" ) 147 .add( "name" , name ) 148 .add( "id" , name , isNull( attributes.get( "id" ) ) ) // 4.3.7.2 (2009/06/15) 149 .add( "value" , value ) 150 .add( "size" , size1 ) 151 .add( tagBuffer.makeTag() ) 152 .makeTag(); 153 154// return tag + CAL_ST + name + CAL_END ; 155 return disabled ? tag // 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 156 : tag + CAL_STR + name + CAL_END ; // 6.9.8.0 (2018/05/28) 変数名を、CAL_ST → CAL_STR に変更。 157 } 158 159 /** 160 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 161 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 162 * リクエスト情報を1つ毎のフィールドで処理できます。 163 * 164 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 165 * @og.rev 6.8.5.0 (2018/01/09) カレンダポップアップで、3ヶ月ピッカー対応 166 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 167 * 168 * @param row 行番号 169 * @param value 入力値 170 * 171 * @return データ表示/編集用の文字列 172 * @og.rtnNotNull 173 */ 174 @Override 175 public String getValue( final int row,final String value ) { 176 final String name2 = name + HybsSystem.JOINT_STRING + row ; 177 178 // 6.1.1.0 (2015/01/17) TagBufferの連結記述 179 final String tag = new TagBuffer( "input" ) 180 .add( "name" , name2 ) 181 .add( "id" , name2 , isNull( attributes.get( "id" ) ) ) // 4.3.7.2 (2009/06/15) 182 .add( "value" , value ) 183 .add( "size" , size2 ) 184 .add( tagBuffer.makeTag() ) 185 .makeTag( row,value ); 186 187// return tag + CAL_ST + name2 + CAL_END ; 188 return disabled ? tag // 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 189 : tag + CAL_STR + name2 + CAL_END ; // 6.9.8.0 (2018/05/28) 変数名を、CAL_ST → CAL_STR に変更。 190 } 191}