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.db.AbstractRenderer;
019    import org.opengion.hayabusa.db.CellRenderer;
020    import org.opengion.hayabusa.db.DBColumn;
021    import org.opengion.hayabusa.db.Selection;
022    
023    /**
024     * MENU レンãƒ?ƒ©ーは、カラãƒ??ãƒ??タをコードリソースに対応したラベルで
025     * プルãƒ?‚¦ンメニュー表示する場合に使用するクラスですã?
026     *
027     *  カラãƒ??表示にå¿?¦�な属æ?は, DBColumn オブジェクãƒ?より取り出しますã?
028     * こã?クラスは、DBColumn オブジェクト毎に?‘つ作æ?されますã?
029     *
030     * @og.group ãƒ??タ表示
031     *
032     * @version  4.0
033     * @author   Kazuhiko Hasegawa
034     * @since    JDK5.0,
035     */
036    public class Renderer_MENU extends AbstractRenderer {
037            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
038            private static final String VERSION = "5.5.1.0 (2012/04/03)" ;
039    
040            // 3.2.3.0 (2003/06/06) final を削除。サブクラスからアクセスできるように変更ã€?
041            private final Selection selection  ;
042            private final String useSLabel ;        // 5.5.1.0 (2012/04/03)
043    
044            /**
045             * ãƒ?ƒ•ォルトコンストラクターã€?
046             * こã?コンストラクターで、基本オブジェクトを作æ?しますã?
047             *
048             * @og.rev 3.1.1.1 (2003/04/03) å�?‚ªブジェクトからè?åˆ??インスタンスを返すファクトリメソãƒ?ƒ‰を追åŠ??
049             * @og.rev 3.2.3.0 (2003/06/06) key 変数をローカル化ã?
050             * @og.rev 5.5.1.0 (2012/04/03) Slabel対å¿?
051             *
052             */
053            public Renderer_MENU() {
054                    selection  = null;
055                    useSLabel = "auto";             // 5.5.1.0 (2012/04/03)
056            }
057    
058            /**
059             * ãƒ?ƒ•ォルトコンストラクターã€?
060             *
061             * @og.rev 3.1.1.1 (2003/04/03) å�?‚ªブジェクトからè?åˆ??インスタンスを返すファクトリメソãƒ?ƒ‰を追åŠ??
062             * @og.rev 3.2.3.0 (2003/06/06) key 変数をローカル化ã?
063             * @og.rev 3.3.1.1 (2003/07/03) CodeSelection の設定において、バグ修正ã€?
064             * @og.rev 3.5.4.2 (2003/12/15) makeCodeSelection メソãƒ?ƒ‰ã‚?CodeSelectionクラスに変更ã€?
065             * @og.rev 3.5.5.7 (2004/05/10) SelectionFactory を使用して、オブジェクト作æ?
066             * @og.rev 4.0.0.0 (2005/01/31) Selection_CODE の作æ?の引数ã‚?CodeData に変更ã€?
067             * @og.rev 4.0.0.0 (2007/11/07) SelectionオブジェクトをDBColumnから取å¾?
068             * @og.rev 5.5.1.0 (2012/04/03) Slabel対å¿?
069             *
070             * @param       clm     DBColumnオブジェクãƒ?
071             */
072            private Renderer_MENU( final DBColumn clm ) {
073                    selection = clm.getSelection();                                                                         // 4.0.0.0 (2007/11/07)
074                    useSLabel = clm.getUseSLabel() ;        // 5.5.1.0 (2012/04/03)
075            }
076    
077            /**
078             * å�?‚ªブジェクトからè?åˆ??インスタンスを返しますã?
079             * 自åˆ??身をキャãƒ?‚·ュするのかã?新たに作æ?するのかã?、各サブクラスの実è£?�«
080             * まかされますã?
081             *
082             * @og.rev 3.1.1.1 (2003/04/03) å�?‚ªブジェクトからè?åˆ??インスタンスを返すファクトリメソãƒ?ƒ‰を追åŠ??
083             * @og.rev 3.1.2.1 (2003/04/10) synchronized をã?削除しますã?
084             *
085             * @param       clm     DBColumnオブジェクãƒ?
086             *
087             * @return      CellRendererオブジェクãƒ?
088             */
089            public CellRenderer newInstance( final DBColumn clm ) {
090                    return new Renderer_MENU( clm );
091            }
092    
093            /**
094             * ãƒ??タの表示用æ–?­—å?を返しますã?
095             *
096             * @og.rev 5.5.1.0 (2012/04/03) Slabel対å¿?
097             *
098             * @param   value 入力å?
099             *
100             * @return  ãƒ??タの表示用æ–?­—å?
101             */
102            @Override
103            public String getValue( final String value ) {
104    //              final boolean uslbl = "true".equalsIgnoreCase( useSLabel );             // 5.5.1.0 (2012/04/03)
105                    final boolean uslbl = !"true".equals(useSLabel) ? false : true; // 5.5.1.0 (2012/04/03)
106    //              return selection.getValueLabel( value,false );
107                    return selection.getValueLabel( value,uslbl ); // 5.5.1.0 (2012/04/03)
108            }
109    
110            /**
111             * name属æ?を変えたã?ãƒ??タ表示/編é›?”¨のHTMLæ–?­—å?を作æ?しますã?
112             * ãƒ??ブル上ã? name に 行番号を付加して、名前_行番号 で登録するキーを作æ?ã�?
113             * リクエスト情報を1つ毎ã?フィールドで処ç�?�§きますã?
114             *
115             * @og.rev 4.0.0.0 (2005/11/30) ä¸?¦§表示では、短縮ラベルを使用しますã?
116             * @og.rev 5.5.1.0 (2012/04/03) Slabel対å¿?
117             *
118             * @param   row   行番号
119             * @param   value 入力å?
120             *
121             * @return  ãƒ??タ表示/編é›?”¨のæ–?­—å?
122             */
123            @Override
124            public String getValue( final int row,final String value ) {
125    //              final boolean uslbl = ("auto".equals(useSLabel) || "true".equals(useSLabel) ) ? true : false; // 5.5.1.0 (2012/04/03)
126                    final boolean uslbl = "auto".equalsIgnoreCase( useSLabel ) || "true".equalsIgnoreCase( useSLabel );             // 5.5.1.0 (2012/04/03)
127    //              return selection.getValueLabel( value,true )
128                    return selection.getValueLabel( value,uslbl );
129            }
130    }