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.db.AbstractEditor;
019import org.opengion.hayabusa.db.CellEditor;
020import org.opengion.hayabusa.db.DBColumn;
021import org.opengion.fukurou.util.XHTMLTag;
022import org.opengion.fukurou.util.TagBuffer;
023import org.opengion.hayabusa.common.*;
024
025
026/**
027 * YMD エディターは、カラムのデータを日付(年/月/日)編集する場合に使用するクラスです。
028 * YMD2はカレンダーのポップアップボタンが付属するタイプです。
029 *
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 5.9.30.3 (2018/03/30) 3monthを標準にする
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 = "5.6.5.2 (2013/06/21)" ;
051
052//      private static final String CAL1 = "<img src=\"../image/calendar.gif\" alt=\"Calendar\" onclick=\"window_open('../common/calendar.html',event,'" ;
053//      private static final String CAL2 = "','width=220px,height=170px,resizable=no');\">";
054        // 4.1.1.2 (2008/03/07) カレンダーポップアップのモーダル化
055//      private static final String CAL1 = "<button onclick=\"ogPopup('../common/calendar.html',250,265,null,this,new Array('" ;
056        // 5.6.5.2 (2013/06/21) htmlからjspに変更
057        //private static final String CAL1 = "<button onclick=\"ogPopup('../common/calendar.jsp',250,265,null,this,new Array('" ;
058        // 5.9.4.0 (2016/01/09) type=button追加
059//      private static final String CAL1 = "<button type=\"button\" onclick=\"ogPopup('../common/calendar.jsp',250,265,null,this,new Array('" ;
060        // 5.9.14.0 (2016/11/04) サイズ変更
061        private static final String CAL1 = "<button type=\"button\" onclick=\"ogPopup('../common/calendar.jsp',265,260,null,this,new Array('" ;
062
063        private static final String CAL3 = "<button type=\"button\" onclick=\"ogPopup('../common/calendar_3month.jsp',320,770,null,this,new Array('" ; // 5.9.30.3 (2019/03/30)
064
065        //      private static final String CAL2 = "'),event); \" style=\"background-color:Beige;border:0px\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>";
066        // 4.3.6.7 (2009/05/22) FireFox対応
067//      private static final String CAL2 = "'),event); return false;\" style=\"background-color:Beige;border:0px\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>";
068        // 5.9.4.0 背景色transparent 5.9.4.3 padding
069//      private static final String CAL2 = "'),event); return false;\" style=\"background-color:transparent;border:0px;padding:0;\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>";
070        // 5.9.32.3command,p_appendの対応
071        private static final String CAL2 = "'),'NEW',false,event); return false;\" style=\"background-color:transparent;border:0px;padding:0;\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>";
072
073
074        private static final String CAL_ST = "CAL1".equals( HybsSystem.sys( "CALENDAR_POPUP_TYPE" ) ) ? CAL1 : CAL3 ; // 5.9.30.3 (2018/03/30)
075        
076        /**
077         * デフォルトコンストラクター。
078         * このコンストラクターで、基本オブジェクトを作成します。
079         *
080         */
081        public Editor_YMD2() {
082                // 4.3.4.4 (2009/01/01)
083//              super();
084        }
085
086        /**
087         * コンストラクター。
088         *
089         * @param       clm     DBColumnオブジェクト
090         */
091        private Editor_YMD2( final DBColumn clm ) {
092                super( clm );
093                tagBuffer.add( XHTMLTag.inputAttri( attributes ) );
094        }
095
096        /**
097         * 各オブジェクトから自分のインスタンスを返します。
098         * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に
099         * まかされます。
100         *
101         * @param       clm     DBColumnオブジェクト
102         *
103         * @return      CellEditorオブジェクト
104         */
105        public CellEditor newInstance( final DBColumn clm ) {
106                return new Editor_YMD2( clm );
107        }
108
109        /**
110         * データの編集用文字列を返します。
111         *
112         * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない
113         * @og.rev 5.9.30.3 (2018/03/30) 3monthを標準にする
114         *
115         * @param       value 入力値
116         *
117         * @return      データの編集用文字列
118         */
119        @Override
120        public String getValue( final String value ) {
121                TagBuffer tag = new TagBuffer( "input" );
122                tag.add( "name"    , name );
123                if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
124                        tag.add( "id"      , name );
125                }
126                tag.add( "value"   , value );
127                tag.add( "size"    , size1 );
128                tag.add( tagBuffer.makeTag() );
129                tag.add( optAttr );             // 3.5.5.8 (2004/05/20)
130
131//              return tag.makeTag() + CAL1 + name + CAL2 ;
132                return tag.makeTag() + CAL_ST + name + CAL2 ; // 5.9.30.3 (2018/03/30)
133        }
134
135        /**
136         * name属性を変えた、データ表示/編集用のHTML文字列を作成します。
137         * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し,
138         * リクエスト情報を1つ毎のフィールドで処理できます。
139         *
140         * @og.rev 4.3.7.2 (2009/06/15) 属性でidが出力される場合は、idを出力しない
141         * @og.rev 5.9.30.3 (2018/03/30) 3monthを標準にする
142         *
143         * @param       row   行番号
144         * @param       value 入力値
145         *
146         * @return      データ表示/編集用の文字列
147         */
148        @Override
149        public String getValue( final int row,final String value ) {
150                TagBuffer tag = new TagBuffer( "input" );
151                String name2 =  name + HybsSystem.JOINT_STRING + row ;
152                tag.add( "name"    , name2);
153                if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
154                        tag.add( "id"      , name2);
155                }
156                tag.add( "value"   , value );
157                tag.add( "size"    , size2 );
158                tag.add( tagBuffer.makeTag() );
159                tag.add( optAttr );             // 3.5.5.8 (2004/05/20)
160
161//              return tag.makeTag( row,value ) + CAL1 + name2 + CAL2 ;
162                return tag.makeTag( row,value ) + CAL_ST + name2 + CAL2 ; // 5.9.30.3 (2018/03/30)
163        }
164}