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.AbstractRenderer; 019import org.opengion.hayabusa.db.CellRenderer; 020import org.opengion.hayabusa.db.DBColumn; 021import org.opengion.hayabusa.db.Selection; 022 023/** 024 * MENU レンデラーは、カラムのデータをコードリソースに対応したラベルで 025 * プルダウンメニュー表示する場合に使用するクラスです。 026 * 027 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 028 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 029 * 030 * @og.group データ表示 031 * 032 * @version 4.0 033 * @author Kazuhiko Hasegawa 034 * @since JDK5.0, 035 */ 036public 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}