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.4.1.1 (2016/01/16)" ; 047 048 // 6.4.2.0 (2016/01/29) alt属性にtitle属性を追記。 049 private static final String CAL1 = "<img src=\"../image/calendar.gif\" alt=\"Calendar\" title=\"Calendar\" class=\"calPic\" targetId=\""; 050 private static final String CAL2 = "\" />"; 051 052 /** 053 * デフォルトコンストラクター。 054 * このコンストラクターで、基本オブジェクトを作成します。 055 * 056 * @og.rev 6.4.1.1 (2016/01/16) PMD refactoring. It is a good practice to call super() in a constructor 057 */ 058 public Editor_YMD3() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 059 060 /** 061 * コンストラクター。 062 * 063 * @param clm DBColumnオブジェクト 064 */ 065 private Editor_YMD3( final DBColumn clm ) { 066 super( clm ); 067 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 068 } 069 070 /** 071 * 各オブジェクトから自分のインスタンスを返します。 072 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 073 * まかされます。 074 * 075 * @param clm DBColumnオブジェクト 076 * 077 * @return CellEditorオブジェクト 078 */ 079 public CellEditor newInstance( final DBColumn clm ) { 080 return new Editor_YMD3( clm ); 081 } 082 083 /** 084 * データの編集用文字列を返します。 085 * 086 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 087 * 088 * @param value 入力値 089 * 090 * @return データの編集用文字列 091 */ 092 @Override 093 public String getValue( final String value ) { 094 final String id = StringUtil.nval( attributes.get( "id" ) , name ); 095 096 final String tag = new TagBuffer( "input" ) 097 .add( "name" , name ) 098 .add( "id" , name , StringUtil.isNull( attributes.get( "id" ) ) ) 099 .add( "value" , value ) 100 .add( "size" , size1 ) 101 .add( tagBuffer.makeTag() ) 102 .makeTag(); 103 104 return tag + CAL1 + id + CAL2 ; 105 106 } 107 108 /** 109 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 110 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 111 * リクエスト情報を1つ毎のフィールドで処理できます。 112 * 113 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 114 * 115 * @param row 行番号 116 * @param value 入力値 117 * 118 * @return データ表示/編集用の文字列 119 */ 120 @Override 121 public String getValue( final int row,final String value ) { 122 final String name2 = name + HybsSystem.JOINT_STRING + row ; 123 124 // 6.1.1.0 (2015/01/17) TagBufferの連結記述 125 final String tag = new TagBuffer( "input" ) 126 .add( "name" , name2 ) 127 .add( "id" , name2 , StringUtil.isNull( attributes.get( "id" ) ) ) 128 .add( "value" , value ) 129 .add( "size" , size2 ) 130 .add( tagBuffer.makeTag() ) 131 .makeTag( row,value ); 132 133 return tag + CAL1 + name2 + CAL2 ; 134 135 } 136}