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.TagBuffer;
023    import org.opengion.fukurou.util.XHTMLTag;
024    
025    /**
026     * COLOR エãƒ?‚£ターは、カラãƒ??ãƒ??タをカラーピッカーで選択するå?合に使用するクラスですã?
027     * 値は#FFFFFFのように#付き7桁で入りますã?
028     *
029     *  カラãƒ??表示にå¿?¦�な属æ?は, DBColumn オブジェクãƒ?より取り出しますã?
030     * こã?クラスは、DBColumn オブジェクト毎に?‘つ作æ?されますã?
031     *
032     * @og.group ãƒ??タ編é›?
033     *
034     * @og.rev 5.5.4.0 (2012/07/02) 新規作æ?
035     *
036     * @version  4.0
037     * @author   Kazuhiko Hasegawa
038     * @since    JDK5.0,
039     */
040    public class Editor_COLOR extends AbstractEditor {
041            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
042            private static final String VERSION = "5.5.4.0 (2012/07/02)" ;
043    
044            /**
045             * ãƒ?ƒ•ォルトコンストラクターã€?
046             * こã?コンストラクターで、基本オブジェクトを作æ?しますã?
047             *
048             * @og.rev 3.1.1.1 (2003/04/03) å�?‚ªブジェクトからè?åˆ??インスタンスを返すファクトリメソãƒ?ƒ‰を追åŠ??
049             *
050             */
051            public Editor_COLOR() {
052                    // 4.3.4.4 (2009/01/01)
053    //              super();
054            }
055    
056            /**
057             * コンストラクターã€?
058             *
059             * @param       clm     DBColumnオブジェクãƒ?
060             */
061            private Editor_COLOR( final DBColumn clm ) {
062                    super( clm );
063                    attributes.add( "class"        ,"colorPicker" );
064                    attributes.add( "readonly"        ,"readonly" );
065                    tagBuffer.add( XHTMLTag.inputAttri( attributes ) );
066            }
067    
068            /**
069             * å�?‚ªブジェクトからè?åˆ??インスタンスを返しますã?
070             * 自åˆ??身をキャãƒ?‚·ュするのかã?新たに作æ?するのかã?、各サブクラスの実è£?�«
071             * まかされますã?
072             *
073             * @param       clm     DBColumnオブジェクãƒ?
074             *
075             * @return      CellEditorオブジェクãƒ?
076             */
077            public CellEditor newInstance( final DBColumn clm ) {
078                    return new Editor_COLOR( clm );
079            }
080    
081            /**
082             * ãƒ??タの編é›?”¨æ–?­—å?を返しますã?(色付き)
083             *
084             * @param       value 入力å?
085             *
086             * @return      ãƒ??タの編é›?”¨æ–?­—å?
087             */
088            @Override
089            public String getValue( final String value ) {
090    
091                    TagBuffer tag = new TagBuffer( "input" );
092                    tag.add( "name"    , name );
093                    if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) {
094                            tag.add( "id"      , name );
095                    }
096                    tag.add( "value"   , value );
097                    tag.add( "size"    , size1 );
098                    tag.add( "style" , "background-color:"+value+"; color:"+value+";" );
099                    tag.add( tagBuffer.makeTag() );
100                    tag.add( optAttr );
101    
102                    return tag.makeTag();
103            }
104    
105            /**
106             * name属æ?を変えたã?ãƒ??タ表示/編é›?”¨のHTMLæ–?­—å?を作æ?しますã?(色付き)
107             * ãƒ??ブル上ã? name に 行番号を付加して、名前_行番号 で登録するキーを作æ?ã�?
108             * リクエスト情報を1つ毎ã?フィールドで処ç�?�§きますã?
109             *
110             * @param       row   行番号
111             * @param       value 入力å?
112             *
113             * @return      ãƒ??タ表示/編é›?”¨のæ–?­—å?
114             */
115            @Override
116            public String getValue( final int row,final String value ) {
117                    TagBuffer tag = new TagBuffer( "input" );
118                    String newName = name + HybsSystem.JOINT_STRING + row;
119                    tag.add( "name"  , newName );
120                    if( attributes.get( "id" ) == null || attributes.get( "id" ).length() == 0 ) {
121                            tag.add( "id"    , newName );
122                    }
123                    tag.add( "value"   , value );
124                    tag.add( "size"    , size2 );
125                    tag.add( "style" , "background-color:"+value+"; color:"+value+";" );
126                    tag.add( tagBuffer.makeTag() );
127                    tag.add( optAttr );
128    
129                    return tag.makeTag( row,value );
130            }
131    }