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.view;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.fukurou.util.StringUtil;
020    
021    /**
022     * 行と列を入れ替えて表示する、テーブル回転表示クラスです?
023     *
024     * こ?クラスは、表示のみ実行可能です?旧ヘッ??部??、第?ラ?表示されます?
025     * こ?ビューでは、行と列が入れ替わって表示して?為、登録はできません?
026     *
027     * AbstractViewForm により、setter/getterメソ?の?ォルト実?提供して?す?
028     * 各HTMLのタグに?な setter/getterメソ?のみ?追?義して?す?
029     *
030     * AbstractViewForm を継承して?為,ロケールに応じたラベルを?力させる事が出来ます?
031     *
032     * @og.rev 3.5.3.0 (2003/10/27) 新規作?
033     * @og.group 画面表示
034     *
035     * @version  4.0
036     * @author   Kazuhiko Hasegawa
037     * @since    JDK5.0,
038     */
039    public class ViewForm_HTMLRotationTable extends ViewForm_HTMLTable  {
040            //* こ?プログラ??VERSION??を設定します?       {@value} */
041            private static final String VERSION = "5.1.6.0 (2010/05/01)" ;
042    
043            private boolean  noClass = false;
044    
045            // 4.3.4.4 (2009/01/01)
046    //      /**
047    //       * ?ォルトコンストラクター
048    //       *
049    //       */
050    //      public ViewForm_HTMLRotationTable() {
051    //              super();
052    //              super.clear();
053    //      }
054    
055            /**
056             * DBTableModel から HTML??を作?して返します?
057             * startNo(表示開始位置)から、pageSize(表示件数)までのView??を作?します?
058             * 表示残り??タ?pageSize 以下?場合?,残りの??タをすべて出力します?
059             *
060             * @og.rev 3.5.3.1 (2003/10/31) BgColorCycleClass の設定不?合修正?
061             * @og.rev 3.5.6.4 (2004/07/16) ヘッ??とボディー部をJavaScriptで?
062             * @og.rev 3.8.8.5 (2007/03/09) 表示の仕方を修正しました?
063             * @og.rev 4.0.0.0 (2005/01/31) 新規作?(getColumnClassName ?getColumnDbType)
064             *
065             * @param  startNo    表示開始位置
066             * @param  pageSize   表示件数
067             *
068             * @return  DBTableModelから作?され?HTML??
069             */
070            @Override
071            public String create( final int startNo, final int pageSize )  {
072                    if( getRowCount() == 0 ) { return ""; } // 暫定?置
073    
074                    int lastNo = getLastNo( startNo, pageSize );
075    
076                    StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE );
077    
078                    out.append( getCountForm( startNo,pageSize ) );
079                    out.append( getHeader() );
080    
081                    String clmCls = "<td>";
082                    out.append("<tbody>").append( HybsSystem.CR );
083                    int bgClrCnt = 0;
084                    int clmCnt = getColumnCount();  // 3.5.5.7 (2004/05/10)
085                    for(int column = 0; column < clmCnt; column++) {
086                            if( !isColumnDisplay( column ) ) { continue; }
087                            int dummyRow = bgClrCnt++ ;             // 3.8.8.5 (2007/03/09)
088    
089                            out.append("<tr").append( getBgColorCycleClass( dummyRow ) ).append(">");
090                            out.append( HybsSystem.CR );
091                            // 3.8.8.5 (2007/03/09) numberType 属?を?慮
092                            if( isNumberDisplay() ) {
093                                    out.append( "<td>" ).append( getNumberData( dummyRow ) ).append( "</td>" );
094                                    out.append( HybsSystem.CR );
095                            }
096                            out.append( "<td>" );
097                            out.append( getColumnLabel(column) ).append("</td>");
098                            out.append( HybsSystem.CR );
099    
100                            if( ! noClass ) {
101                                    clmCls = "<td class=\"" + getColumnDbType(column) + "\" >" ;      // 4.0.0 (2005/01/31)
102                            }
103    
104                            for( int row=startNo; row<lastNo; row++ ) {
105                                    out.append( clmCls );
106                                    out.append( getValueLabel(row,column) );
107                                    out.append("</td>").append( HybsSystem.CR );
108                            }
109                            out.append("</tr>").append( HybsSystem.CR );
110                    }
111                    out.append("</tbody>").append( HybsSystem.CR );
112                    out.append("</table>").append( HybsSystem.CR );
113    
114                    out.append( getScrollBarEndDiv() );     // 3.8.0.3 (2005/07/15)
115                    return out.toString();
116            }
117    
118            /**
119             * ?をクリア(初期?します?
120             *
121             */
122            @Override
123            public void clear() {
124                    super.clear();
125                    noClass                 = false;
126            }
127    
128            /**
129             * ??ブルのバックグラウンドカラーの値をセ?します?
130             * 行番号は, ?から始まる?で、?数?HTML_BG_COLOR_ROW0 ?
131             * ?行を HTML_BG_COLOR_ROW1 とします?
132             * setBgColorCycle で、設定?変換して?す?
133             * なお?こ?クラスでは、最初?行に、row_h クラス属?を付加します?
134             *
135             * @og.rev 3.8.8.5 (2007/03/09) ヘッ??部の色付け
136             *
137             * @param       indx 先?からの連番( ?から始め?)
138             *
139             * @return      行?色を指定す?class 属?( cssファイルで??)
140             */
141            @Override
142            protected String getBgColorCycleClass( final int indx ) {
143                    return ( indx == 0 )
144                                            ? " class=\"row_h\""
145                                            : super.getBgColorCycleClass( indx );
146            }
147    
148            /**
149             * DBTableModel から ??ブルのタグ??を作?して返します?
150             *
151             * @return  ??ブルのタグ??
152             */
153            @Override
154            protected String getTableHead() {
155    
156                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
157                    if( isNumberDisplay() ) {
158                            buf.append("<colgroup class=\"S9\">");
159                    }
160                    buf.append("<colgroup class=\"HEADER\" />");
161                    buf.append(HybsSystem.CR);
162    
163                    return buf.toString();
164            }
165    
166            /**
167             * フォーマットメソ?を使用できるかど?を問?わせます?
168             *
169             * @return  使用可能(true)/ 使用不可能 (false)
170             */
171            @Override
172            public boolean canUseFormat() {
173                    return false;
174            }
175    
176            /**
177             * カラ??クラス?X,S9 など)のセ?を行うかど??します?
178             *
179             * "true" で、クラス属?を設定しません。これ????ファイルに書かれて?属??
180             * 使用しな?とを意味します?
181             * 初期値は?false" です?
182             *
183             * @param       flag クラス名使用の有無(true:使用しな?false:使用する?
184             */
185            public void setBodyNoClass( final String flag ) {
186                    noClass = StringUtil.nval( flag,noClass );
187            }
188    
189            /**
190             * 表示?の編?並び替?が可能かど?を返しま?
191             *
192             * @og.rev 5.1.6.0 (2010/05/01) 新規追?
193             *
194             * @return      表示?の編?並び替?が可能かど?(false:不可能)
195             */
196            @Override
197            public boolean isEditable() {
198                    return false;
199            }
200    }