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 org.opengion.fukurou.util.StringUtil; 026 027/** 028 * YMD エディターは、カラムのデータを日付(年/月/日)編集する場合に使用するクラスです。 029 * YMD3はカレンダーのポップアップボタンが付属するタイプです。 030 * YMD2と異なり、ポップアップをmodalDialogで立ち上げるのではなく、JavaScriptで作成します。(HTML5対応) 031 * 032 * このエディタはeventColumnに対応していません。 033 * 034 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 035 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 036 * 037 * @og.rev 5.8.9.0 (2015/08/08) 新規作成 038 * @og.group データ編集 039 * 040 * @version 4.0 041 * @author Takahashi Masakazu 042 * @since JDK5.0, 043 */ 044public class Editor_YMD3 extends AbstractEditor { 045 /** このプログラムのVERSION文字列を設定します。 {@value} */ 046 private static final String VERSION = "6.9.8.0 (2018/05/28)" ; 047 048 // 6.4.2.0 (2016/01/29) alt属性にtitle属性を追記。 049 // 6.9.8.0 (2018/05/28) 変数名を、YMD2 と同じ、CAL_STR、CAL_END に変更します。 050// private static final String CAL1 = "<img src=\"../image/calendar.gif\" alt=\"Calendar\" title=\"Calendar\" class=\"calPic\" targetId=\""; 051// private static final String CAL2 = "\" />"; 052 private static final String CAL_STR = "<img src=\"../image/calendar.gif\" alt=\"Calendar\" title=\"Calendar\" class=\"calPic\" targetId=\""; 053 private static final String CAL_END = "\" />"; 054 055 // 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 056 private final boolean disabled ; 057 058 /** 059 * デフォルトコンストラクター。 060 * このコンストラクターで、基本オブジェクトを作成します。 061 * 062 * @og.rev 6.4.1.1 (2016/01/16) PMD refactoring. It is a good practice to call super() in a constructor 063 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 064 */ 065// public Editor_YMD3() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 066 public Editor_YMD3() { 067 super(); 068 disabled = false; 069 } 070 071 /** 072 * コンストラクター。 073 * 074 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 075 * 076 * @param clm DBColumnオブジェクト 077 */ 078 private Editor_YMD3( final DBColumn clm ) { 079 super( clm ); 080 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 081 082 disabled = "disabled".equalsIgnoreCase( attributes.get( "disabled" ) ); // 6.9.8.0 (2018/05/28) 083 } 084 085 /** 086 * 各オブジェクトから自分のインスタンスを返します。 087 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 088 * まかされます。 089 * 090 * @param clm DBColumnオブジェクト 091 * 092 * @return CellEditorオブジェクト 093 */ 094 public CellEditor newInstance( final DBColumn clm ) { 095 return new Editor_YMD3( clm ); 096 } 097 098 /** 099 * データの編集用文字列を返します。 100 * 101 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 102 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 103 * 104 * @param value 入力値 105 * 106 * @return データの編集用文字列 107 */ 108 @Override 109 public String getValue( final String value ) { 110 final String id = StringUtil.nval( attributes.get( "id" ) , name ); 111 112 final String tag = new TagBuffer( "input" ) 113 .add( "name" , name ) 114 .add( "id" , name , StringUtil.isNull( attributes.get( "id" ) ) ) 115 .add( "value" , value ) 116 .add( "size" , size1 ) 117 .add( tagBuffer.makeTag() ) 118 .makeTag(); 119 120// return tag + CAL1 + id + CAL2 ; 121 return disabled ? tag // 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 122 : tag + CAL_STR + id + CAL_END ; // 変数名を、YMD2 とあわせておきます。 123 } 124 125 /** 126 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 127 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 128 * リクエスト情報を1つ毎のフィールドで処理できます。 129 * 130 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 131 * @og.rev 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 132 * 133 * @param row 行番号 134 * @param value 入力値 135 * 136 * @return データ表示/編集用の文字列 137 */ 138 @Override 139 public String getValue( final int row,final String value ) { 140 final String name2 = name + HybsSystem.JOINT_STRING + row ; 141 142 // 6.1.1.0 (2015/01/17) TagBufferの連結記述 143 final String tag = new TagBuffer( "input" ) 144 .add( "name" , name2 ) 145 .add( "id" , name2 , StringUtil.isNull( attributes.get( "id" ) ) ) 146 .add( "value" , value ) 147 .add( "size" , size2 ) 148 .add( tagBuffer.makeTag() ) 149 .makeTag( row,value ); 150 151// return tag + CAL1 + name2 + CAL2 ; 152 return disabled ? tag // 6.9.8.0 (2018/05/28) disabled 時に、日付ピッカーを出さない対応 153 : tag + CAL_STR + name2 + CAL_END ; // 変数名を、YMD2 とあわせておきます。 154 } 155}