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.db.DBTableModel;
019import org.opengion.hayabusa.common.HybsSystem;
020import org.opengion.fukurou.util.XHTMLTag;
021
022/**
023 * エントリ形式フォーム作成クラスです。
024 *
025 * フォーマットを外部から指定することにより、自由にレイアウトを作成できます。
026 *
027 * AbstractViewForm により、setter/getterメソッドのデフォルト実装を提供しています。
028 * 各HTMLのタグに必要な setter/getterメソッドのみ,追加定義しています。
029 *
030 * AbstractViewForm を継承している為,ロケールに応じたラベルを出力させる事が出来ます。
031 *
032 * @og.rev 3.1.8.0 (2003/05/16) ViewForm_HTMLEntry クラスの新規作成
033 * @og.group 画面表示
034 *
035 * @version  4.0
036 * @author   Kazuhiko Hasegawa
037 * @since    JDK5.0,
038 */
039public class ViewForm_HTMLEntry extends ViewForm_HTMLFormatTextField {
040        //* このプログラムのVERSION文字列を設定します。   {@value} */
041        private static final String VERSION = "5.2.1.0 (2010/10/01)" ;
042
043        private String mustHidden = "";
044
045        /**
046         * DBTableModel から HTML文字列を作成して返します。
047         * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。
048         * 表示残りデータが pageSize 以下の場合は,残りのデータをすべて出力します。
049         *
050         * @og.rev 5.2.1.0 (2010/10/01) must 属性の処理を追加します。
051         *
052         * @param  startNo    表示開始位置
053         * @param  pageSize   表示件数
054         *
055         * @return  DBTableModelから作成された HTML文字列
056         */
057        @Override
058        public String create( final int startNo, final int pageSize )  {
059                return super.create( startNo,pageSize ) + mustHidden;
060        }
061
062        /**
063         * row行,colum列 のデータの値をHTML文字列に変換して返します。
064         * Entry 系のため、通常の行番号付の Editor ではなく、行番号無しの
065         * Editorを使用して、HTML文字列を作成します。
066         *
067         * @og.rev 3.8.0.9 (2005/10/17) writableControl 追加による引数変更
068         *
069         * @param       row             行番号
070         * @param       column  カラム番号
071         * @param       inVal   設定値
072         *
073         * @return      row行,colum列 のデータの値
074         */
075        @Override
076        protected String getEditorValue( final int row, final int column , final String inVal ) {
077                return getDBColumn(column).getEditorValue( inVal );
078        }
079
080        /**
081         * 画面に選択された番号を表示します。
082         * Entry 系のため、選択番号を作成しません。
083         *
084         * @param  row   行番号
085         *
086         * @return      空文字列 ""(固定)
087         */
088        @Override
089        protected String makeSelectNo( final int row ) {
090                return "" ;
091        }
092
093        /**
094         * 初期化します。
095         * このクラスでは、データが0件の場合は、初期データを1件作成します。
096         * 初期化時に、初期データ作成処理を行います。
097         *
098         * @og.rev 3.2.3.0 (2003/06/06) 新規追加
099         * @og.rev 3.5.6.0 (2004/06/18) null 比較でバグを修正
100         * @og.rev 3.5.6.1 (2004/06/25) lang 言語コード 属性を削除します。
101         * @og.rev 4.0.1.0 (2007/12/12) initの場所を変更
102         * @og.rev 5.2.1.0 (2010/10/01) must 属性の処理を追加します。
103         *
104         * @param       table   DBTableModelオブジェクト
105         */
106        @Override
107        public void init( final DBTableModel table ) {
108        //      super.init( table );
109                if( table != null && table.getRowCount() == 0 ) {
110                        String[] data = new String[table.getColumnCount()];
111                        for( int i=0; i<data.length; i++ ) {
112                                data[i] = table.getDBColumn(i).getDefault();
113                                if( data[i] == null ) { data[i] = ""; }
114                        }
115                        table.addValues( data,0 );
116
117                        // 5.2.1.0 (2010/10/01) must 属性の処理を追加します。
118                        String[] clms = table.getMustArray();
119                        if( clms != null ) {
120                                StringBuilder buf = new StringBuilder();
121                                for( int i=0; i<clms.length; i++ ) {
122                                        buf.append( XHTMLTag.hidden( HybsSystem.MUST_KEY +"must", clms[i] ) );
123                                }
124                                mustHidden = buf.toString();
125                        }
126                }
127                super.init( table ); // 4.0.1.0 (2007/12/12) 0件時不具合対応につき場所変更
128        }
129
130        /**
131         * 表示項目の編集(並び替え)が可能かどうかを返します
132         *
133         * @og.rev 5.1.6.0 (2010/05/01) 新規追加
134         *
135         * @return      表示項目の編集(並び替え)が可能かどうか(false:不可能)
136         */
137        @Override
138        public boolean isEditable() {
139                return false;
140        }
141}