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