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     */
016    package org.opengion.plugin.column;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.db.AbstractEditor;
020    import org.opengion.hayabusa.db.CellEditor;
021    import org.opengion.hayabusa.db.DBColumn;
022    import org.opengion.fukurou.util.XHTMLTag;
023    import org.opengion.fukurou.util.TagBuffer;
024    
025    /**
026     * YMD エãƒ?‚£ターは、カラãƒ??ãƒ??タを日ä»?年/æœ?日)編é›?�™るå?合に使用するクラスですã?
027     * YMD2はカレンãƒ??のポップアãƒ??ボタンが付属するタイプですã?
028     *
029     *
030     * こã?エãƒ?‚£タはeventColumnに対応してã�?�¾せんã€?
031     *
032     *  カラãƒ??表示にå¿?¦�な属æ?は, DBColumn オブジェクãƒ?より取り出しますã?
033     * こã?クラスは、DBColumn オブジェクト毎に?‘つ作æ?されますã?
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     */
044    public class Editor_YMD2 extends AbstractEditor {
045            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
046            private static final String VERSION = "5.6.5.2 (2013/06/21)" ;
047    
048    //      private static final String CAL1 = "<img src=\"../image/calendar.gif\" alt=\"Calendar\" onclick=\"window_open('../common/calendar.html',event,'" ;
049    //      private static final String CAL2 = "','width=220px,height=170px,resizable=no');\">";
050            // 4.1.1.2 (2008/03/07) カレンãƒ??ポップアãƒ??のモーãƒ?ƒ«åŒ?
051    //      private static final String CAL1 = "<button onclick=\"ogPopup('../common/calendar.html',250,265,null,this,new Array('" ;
052            // 5.6.5.2 (2013/06/21) htmlからjspに変更
053            private static final String CAL1 = "<button onclick=\"ogPopup('../common/calendar.jsp',250,265,null,this,new Array('" ;
054    //      private static final String CAL2 = "'),event); \" style=\"background-color:Beige;border:0px\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>";
055            // 4.3.6.7 (2009/05/22) FireFox対å¿?
056            private static final String CAL2 = "'),event); return false;\" style=\"background-color:Beige;border:0px\"><img src=\"../image/calendar.gif\" alt=\"Calendar\"/></button>";
057    
058            /**
059             * ãƒ?ƒ•ォルトコンストラクターã€?
060             * こã?コンストラクターで、基本オブジェクトを作æ?しますã?
061             *
062             */
063            public Editor_YMD2() {
064                    // 4.3.4.4 (2009/01/01)
065    //              super();
066            }
067    
068            /**
069             * コンストラクターã€?
070             *
071             * @param       clm     DBColumnオブジェクãƒ?
072             */
073            private Editor_YMD2( final DBColumn clm ) {
074                    super( clm );
075                    tagBuffer.add( XHTMLTag.inputAttri( attributes ) );
076            }
077    
078            /**
079             * å�?‚ªブジェクトからè?åˆ??インスタンスを返しますã?
080             * 自åˆ??身をキャãƒ?‚·ュするのかã?新たに作æ?するのかã?、各サブクラスの実è£?�«
081             * まかされますã?
082             *
083             * @param       clm     DBColumnオブジェクãƒ?
084             *
085             * @return      CellEditorオブジェクãƒ?
086             */
087            public CellEditor newInstance( final DBColumn clm ) {
088                    return new Editor_YMD2( clm );
089            }
090    
091            /**
092             * ãƒ??タの編é›?”¨æ–?­—å?を返しますã?
093             *
094             * @og.rev 4.3.7.2 (2009/06/15) 属æ?でidがå?力される場合ã?、idをå?力しなã�?
095             *
096             * @param       value 入力å?
097             *
098             * @return      ãƒ??タの編é›?”¨æ–?­—å?
099             */
100            @Override
101            public String getValue( final String value ) {
102                    TagBuffer tag = new TagBuffer( "input" );
103                    tag.add( "name"    , name );
104                    if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
105                            tag.add( "id"      , name );
106                    }
107                    tag.add( "value"   , value );
108                    tag.add( "size"    , size1 );
109                    tag.add( tagBuffer.makeTag() );
110                    tag.add( optAttr );             // 3.5.5.8 (2004/05/20)
111    
112                    return tag.makeTag() + CAL1 + name + CAL2 ;
113            }
114    
115            /**
116             * name属æ?を変えたã?ãƒ??タ表示/編é›?”¨のHTMLæ–?­—å?を作æ?しますã?
117             * ãƒ??ブル上ã? name に 行番号を付加して、名前_行番号 で登録するキーを作æ?ã�?
118             * リクエスト情報を1つ毎ã?フィールドで処ç�?�§きますã?
119             *
120             * @og.rev 4.3.7.2 (2009/06/15) 属æ?でidがå?力される場合ã?、idをå?力しなã�?
121             *
122             * @param       row   行番号
123             * @param       value 入力å?
124             *
125             * @return      ãƒ??タ表示/編é›?”¨のæ–?­—å?
126             */
127            @Override
128            public String getValue( final int row,final String value ) {
129                    TagBuffer tag = new TagBuffer( "input" );
130                    String name2 =  name + HybsSystem.JOINT_STRING + row ;
131                    tag.add( "name"    , name2);
132                    if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) { // 4.3.7.2 (2009/06/15)
133                            tag.add( "id"      , name2);
134                    }
135                    tag.add( "value"   , value );
136                    tag.add( "size"    , size2 );
137                    tag.add( tagBuffer.makeTag() );
138                    tag.add( optAttr );             // 3.5.5.8 (2004/05/20)
139    
140                    return tag.makeTag( row,value ) + CAL1 + name2 + CAL2 ;
141            }
142    }