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 025/** 026 * YMD エディターは、カラムのデータを日付(年/月/日)編集する場合に使用するクラスです。 027 * YMD2はカレンダーのポップアップボタンが付属するタイプです。 028 * 029 * 030 * このエディタはeventColumnに対応していません。 031 * 032 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 033 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 034 * 035 * @og.rev 3.5.6.2 (2004/07/05) 新規作成 036 * @og.rev 5.4.3.6 (2012/01/19) コメント修正 037 * @og.rev 5.6.5.2 (2013/06/21) ポップアップ変更 038 * @og.group データ編集 039 * 040 * @version 4.0 041 * @author Kazuhiko Hasegawa 042 * @since JDK5.0, 043 */ 044public class Editor_YMD2 extends AbstractEditor { 045 //* このプログラムのVERSION文字列を設定します。 {@value} */ 046 private static final String VERSION = "5.6.5.2 (2013/06/21)" ; 047 048 // 5.6.5.2 (2013/06/21) htmlからjspに変更 049 private static final String CAL1 = "<button onclick=\"ogPopup('../common/calendar.jsp',250,265,null,this,new Array('" ; 050 // 4.3.6.7 (2009/05/22) FireFox対応 051 private static final String CAL2 = "'),event); return false;\" style=\"background-color:Beige;border:0px\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>"; 052 053 /** 054 * デフォルトコンストラクター。 055 * このコンストラクターで、基本オブジェクトを作成します。 056 * 057 */ 058 public Editor_YMD2() {} 059 060 /** 061 * コンストラクター。 062 * 063 * @param clm DBColumnオブジェクト 064 */ 065 private Editor_YMD2( 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_YMD2( 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 TagBuffer tag = new TagBuffer( "input" ); 095 tag.add( "name" , name ); 096 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15) 097 tag.add( "id" , name ); 098 } 099 tag.add( "value" , value ); 100 tag.add( "size" , size1 ); 101 tag.add( tagBuffer.makeTag() ); 102 tag.add( optAttr ); // 3.5.5.8 (2004/05/20) 103 104 return tag.makeTag() + CAL1 + name + CAL2 ; 105 } 106 107 /** 108 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 109 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 110 * リクエスト情報を1つ毎のフィールドで処理できます。 111 * 112 * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない 113 * 114 * @param row 行番号 115 * @param value 入力値 116 * 117 * @return データ表示/編集用の文字列 118 */ 119 @Override 120 public String getValue( final int row,final String value ) { 121 TagBuffer tag = new TagBuffer( "input" ); 122 String name2 = name + HybsSystem.JOINT_STRING + row ; 123 tag.add( "name" , name2); 124 if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15) 125 tag.add( "id" , name2); 126 } 127 tag.add( "value" , value ); 128 tag.add( "size" , size2 ); 129 tag.add( tagBuffer.makeTag() ); 130 tag.add( optAttr ); // 3.5.5.8 (2004/05/20) 131 132 return tag.makeTag( row,value ) + CAL1 + name2 + CAL2 ; 133 } 134}