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 /** 053 * DBTableModel から HTML文字列を作成して返します。 054 * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。 055 * 表示残りデータが pageSize 以下の場合は,残りのデータをすべて出力します。 056 * 057 * @param startNo 表示開始位置 058 * @param pageSize 表示件数 059 * 060 * @return DBTableModelから作成された HTML文字列 061 */ 062 @Override 063 public String create( final int startNo, final int pageSize ) { 064 if( getRowCount() == 0 ) { return ""; } 065 066 int lastNo = getLastNo( startNo, pageSize ); 067 068 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE ); 069 070 int clmCnt = getColumnCount(); 071 for( int row=startNo; row<lastNo; row++ ) { 072 if( isSkip( row ) || isSkipNoEdit( row ) ) { continue; } 073 074 if( row != startNo ) { out.append( "<br />" ); } 075 076 out.append( "<span " +getBgColorCycleClass(row) + ">" ); 077 boolean isFirstColumn = true; 078 for(int column = 0; column < clmCnt; column++) { 079 if( isColumnDisplay( column ) ) { 080 if( isFirstColumn ) { 081 int no = row + 1; 082 out.append( no + "." ); 083 } 084 else { 085 out.append( "," ); 086 } 087 out.append( getValueLabel(row,column) ); 088 isFirstColumn = false; 089 } 090 } 091 out.append( "</span>" ); 092 } 093 094 return out.toString(); 095 } 096 097 /** 098 * テーブルのバックグラウンドカラーの入れ替えのサイクルをセットします。 099 * 0以上(通常)、-1(ワーニング)、-2以下(エラー) 100 * 初期値は、0以上(通常)です。 101 * 102 * @param sycle 0以上(通常)、-1(ワーニング)、-2以下(エラー) 103 */ 104 @Override 105 public void setBgColorCycle( final int sycle ) { 106 if( sycle == -1 ) { // -1(ワーニング) 107 color_row = BG_WARNING_COLOR ; 108 } 109 else if( sycle < -1 ) { // -2以下(エラー) 110 color_row = BG_ERROR_COLOR ; 111 } 112 } 113 114 /** 115 * テーブルのバックグラウンドカラーの値をセットします。 116 * 117 * @param row 行番号( 0から始める ) 118 * 119 * @return 行の色を指定する class 属性( cssファイルで指定 ) 120 */ 121 @Override 122 protected String getBgColorCycleClass( final int row ) { 123 return color_row ; 124 } 125 126 /** 127 * 表示項目の編集(並び替え)が可能かどうかを返します 128 * 129 * @og.rev 5.1.6.0 (2010/05/01) 新規追加 130 * 131 * @return 表示項目の編集(並び替え)が可能かどうか(false:不可能) 132 */ 133 @Override 134 public boolean isEditable() { 135 return false; 136 } 137 138}