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.view; 017 018import org.opengion.hayabusa.common.HybsSystem; 019 020/** 021 * 検索結果を単純なリスト形式で表示するクラスです。 022 * 023 * このクラスでは、検索結果を単純なリストで表示します。 024 * 表示のみでこの表示フォーマットを利用してデータ編集を行うことはできません。 025 * 026 * 各カラムのデータは、カンマによって連結され、またヘッダー部分も出力されません。 027 * さらに各カラムの属性値に基づくclass属性等も一切出力されません。 028 * 029 * AbstractViewForm により、setter/getterメソッドのデフォルト実装を提供しています。 030 * 各HTMLのタグに必要な setter/getterメソッドのみ,追加定義しています。 031 * 032 * AbstractViewForm を継承している為,ロケールに応じたラベルを出力させる事が出来ます。 033 * 034 * @og.group 画面表示 035 * 036 * @version 4.0 037 * @author Hiroki Nakamura 038 * @since JDK5.0, 039 */ 040public class ViewForm_HTMLSimpleList extends ViewForm_HTMLTable { 041 //* このプログラムのVERSION文字列を設定します。 {@value} */ 042 private static final String VERSION = "5.1.6.0 (2010/05/01)" ; 043 044 // 警告時の行ごとに色を変更する時の、デフォルトクラス属性 045 private static final String BG_WARNING_COLOR = " class=\"row_warning\""; 046 047 // エラー時の行ごとに色を変更する時の、デフォルトクラス属性 048 private static final String BG_ERROR_COLOR = " class=\"row_error\""; 049 050 private String color_row = ""; 051 052 // 4.3.4.4 (2009/01/01) 053// /** 054// * デフォルトコンストラクター 055// * 056// */ 057// public ViewForm_HTMLSimpleList() { 058// super(); 059// } 060 061 // 4.3.4.4 (2009/01/01) 062// /** 063// * 内容をクリア(初期化)します。 064// * 065// */ 066// public void clear() { 067// super.clear(); 068// } 069 070 /** 071 * DBTableModel から HTML文字列を作成して返します。 072 * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。 073 * 表示残りデータが pageSize 以下の場合は,残りのデータをすべて出力します。 074 * 075 * @param startNo 表示開始位置 076 * @param pageSize 表示件数 077 * 078 * @return DBTableModelから作成された HTML文字列 079 */ 080 @Override 081 public String create( final int startNo, final int pageSize ) { 082 if( getRowCount() == 0 ) { return ""; } 083 084 int lastNo = getLastNo( startNo, pageSize ); 085 086 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE ); 087 088 int clmCnt = getColumnCount(); 089 for( int row=startNo; row<lastNo; row++ ) { 090 if( isSkip( row ) || isSkipNoEdit( row ) ) { continue; } 091 092 if( row != startNo ) { out.append( "<br />" ); } 093 094 out.append( "<span " +getBgColorCycleClass(row) + ">" ); 095 boolean isFirstColumn = true; 096 for(int column = 0; column < clmCnt; column++) { 097 if( isColumnDisplay( column ) ) { 098 if( isColumnDisplay( column ) ) { 099 if( isFirstColumn ) { 100 int no = row + 1; 101 out.append( no + "." ); 102 } 103 else { 104 out.append( "," ); 105 } 106 out.append( getValueLabel(row,column) ); 107 isFirstColumn = false; 108 } 109 } 110 } 111 out.append( "</span>" ); 112 } 113 114 return out.toString(); 115 } 116 117 /** 118 * テーブルのバックグラウンドカラーの入れ替えのサイクルをセットします。 119 * 0以上(通常)、-1(ワーニング)、-2以下(エラー) 120 * 初期値は、0以上(通常)です。 121 * 122 * @param sycle 0以上(通常)、-1(ワーニング)、-2以下(エラー) 123 */ 124 @Override 125 public void setBgColorCycle( final int sycle ) { 126 if( sycle == -1 ) { // -1(ワーニング) 127 color_row = BG_WARNING_COLOR ; 128 } 129 else if( sycle < -1 ) { // -2以下(エラー) 130 color_row = BG_ERROR_COLOR ; 131 } 132 } 133 134 /** 135 * テーブルのバックグラウンドカラーの値をセットします。 136 * 137 * @param row 行番号( 0から始める ) 138 * 139 * @return 行の色を指定する class 属性( cssファイルで指定 ) 140 */ 141 @Override 142 protected String getBgColorCycleClass( final int row ) { 143 return color_row ; 144 } 145 146 /** 147 * 表示項目の編集(並び替え)が可能かどうかを返します 148 * 149 * @og.rev 5.1.6.0 (2010/05/01) 新規追加 150 * 151 * @return 表示項目の編集(並び替え)が可能かどうか(false:不可能) 152 */ 153 @Override 154 public boolean isEditable() { 155 return false; 156 } 157 158}