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.hayabusa.taglib;
017    
018    import static org.opengion.fukurou.util.StringUtil.nval;
019    
020    import java.util.ArrayList;
021    import java.util.Collections;
022    import java.util.Enumeration;
023    import java.util.HashMap;
024    import java.util.List;
025    import java.util.Map;
026    
027    import org.opengion.fukurou.util.StringUtil;
028    import org.opengion.fukurou.util.TagBuffer;
029    import org.opengion.hayabusa.common.HybsSystem;
030    import org.opengion.hayabusa.common.HybsSystemException;
031    import org.opengion.hayabusa.db.DBColumn;
032    import org.opengion.hayabusa.db.DBEditConfig;
033    import org.opengion.hayabusa.db.DBLastSql;
034    import org.opengion.hayabusa.db.DBTableModel;
035    
036    /**
037     * ç”»é¢è¡¨ç¤ºã€?›†è¨ˆã«é–¢ã™ã‚‹è¨­å®šæƒ…å ±ã®è¡¨ç¤ºã€ç™»éŒ²ã‚’行ã†ãŸã‚ã®ã‚¿ã‚°ã§ã™ã?
038     * (ã“ã?ã‚¿ã‚°ã¯æ¨™æº–ã?設定編é›?”»é¢ã«çµ?¿è¾¼ã‚“ã§ä½¿ç”¨ã•れã€å„ç”»é¢JSPã‹ã‚‰å‘¼ã³å‡ºã™ã“ã¨ã¯ã‚りã¾ã›ã‚“)
039     *
040     * ã“ã?ã‚¿ã‚°ã¯ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼å˜ä½ã«ç®¡ç?•れるエãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã«å¯¾ã™ã‚‹I/Fã®æ©Ÿè?ã‚?
041     * æä¾›ã—ã¦ã?¾ã™ã?ã“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã«ã¤ã?¦ã¯ã€ç”»é¢æ¯Žã«è¨­å®šã‚’行ã†ãŸã‚ã€?
042     * ã‚¿ã‚°ã®å‘¼ã³å‡ºã—ã«ã¯ã€ç”»é¢IDãŒå¿??ã¨ãªã£ã¦ã?¾ã™ã?
043     *
044     * å…·ä½“çš„ãªæ©Ÿè?ã¨ã—ã¦ã¯ã€?ã¤ã®æ©Ÿè?ã‚’æä¾›ã—ã¾ã™ã?
045     * (1)設定画é¢è¡¨ç¤º(command="GET")
046     *    ユーザーå˜ä½ã«ç®¡ç?•れるエãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトをHTMLã«å¤‰æ›ã—ã¦è¡¨ç¤º
047     *    ã¾ãŸã?表示カラãƒ??ä¸?¦§(カンマ区åˆ?‚Š)ã«ã¤ã?¦ã¯ã€ç”»é¢å´ã®JavaScriptã§å†è¨­å®šã‚’行ã†ãŸã‚ã€?
048     *    ãã?値ã‚?viewClms"ã¨ã?†åå‰ã®hiddenã‚¿ã‚°ã§å‡ºåŠ›ã—ã¾ã™ã?
049     * (2)エãƒ?‚£ãƒ?ƒˆåä¸?¦§(command="LIST")
050     *    æŒ?®šã?ç”»é¢IDã«å¯¾ã—ã¦ã€è¨­å®šã•れã¦ã?‚‹ã‚¨ãƒ?‚£ãƒ?ƒˆåã?ä¸?¦§ã‚’ã?ルãƒ?‚¦ãƒ³(selectã‚¿ã‚°)ã«
051     *    変æ›ã—ã¦è¡¨ç¤ºã—ã¾ã™ã?(name="editName")
052     * (3)設定情報登録/削除(command="SET"/"DELETE")
053     *    (1)ã§è¨­å®šã•れãŸå†?®¹ã«å¯¾ã—ã¦ã€ã‚¨ãƒ?‚£ãƒ?ƒˆåã‚’æŒ?®šã—ã¦ãã?å†?®¹ã‚’ä¿å­?削除ã—ã¾ã™ã?
054     *    æƒ??ã®ä¿å­˜ã?ã€command="GET"ã§è¡¨ç¤ºã•れるé?ç›®åã¨é€£å‹•ã—ã¦ã?¾ã™ã?ã§ã€å˜ç‹¬ã§ã®ä½¿ç”¨ã¯
055     *    ã§ãã¾ã›ã‚“ã€?
056     *
057     * @og.formSample
058     * â—å½¢å¼ï¼šä¸?ˆ¬ãƒ¦ãƒ¼ã‚¶ãƒ¼ãŒç›´æŽ¥çµ?¿è¾¼ã‚?“ã¨ã¯ã‚りã¾ã›ã‚“ã€?
059     * â—body?šãªã?
060     *
061     * â—Tag定義??
062     *   <og:editConfig
063     *       command          â—‹ã?TAG】command を指定ã—ã¾ã?å¿??)ã€?
064     *       gamenId          â—‹ã?TAG】画é¢ID を指定ã—ã¾ã?å¿??)ã€?
065     *       editName           ã€TAG】エãƒ?‚£ãƒ?ƒˆå?を指定ã—ã¾ã?
066     *       debug              ã€TAG】デãƒãƒƒã‚°æƒ??ã‚’å?力ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)
067     *   />
068     *
069     * â—使用ä¾?
070     *     <og:editConfig command="{@command}" gamenId="{@gamenId}" editName="{@editName}" />
071     *
072     *     <og:editConfig
073     *         command        = command設�(GET/LIST/SET/REMOVE)
074     *         gamenId        = "GE0000"    ç”»é¢ID
075     *       [ editName ]     = "EDITNAME"  エãƒ?‚£ãƒ?ƒˆå?
076     *     />
077     *
078     * @og.group エãƒ?‚£ãƒ?ƒˆè¨­å®?
079     *
080     * @og.rev 5.3.6.0 (2011/06/01)
081     *
082     * @version  5.0
083     * @author       Hiroki Nakamura
084     * @since    JDK6.0,
085     */
086    public class EditConfigTag extends CommonTagSupport {
087            //* ã“ã?プログラãƒ??VERSIONæ–?­—å?を設定ã—ã¾ã™ã?       {@value} */
088            private static final String VERSION = "5.5.5.2 (2012/08/10)" ;
089    
090            private static final long serialVersionUID = 555220120810L ;
091    
092            private static final String VIEW_PREFIX                 = "EDIT_VIEW_";
093            private static final String SUM_PREFIX                  = "EDIT_SUM_";
094            private static final String GROUP_PREFIX                = "EDIT_GROUP_";
095            private static final String SUBTOTAL_PREFIX             = "EDIT_SUBTOTAL_";
096            private static final String TOTAL_PREFIX                = "EDIT_TOTAL_";
097            private static final String ORDERBY_PREFIX              = "EDIT_ORDERBY_";
098            private static final String DESC_PREFIX                 = "EDIT_DESC_";
099            private static final String GRANDTOTAL_PREFIX   = "EDIT_GRANDTOTAL_";
100            private static final String COMMON_PREFIX               = "EDIT_COMMON_";
101    
102            private String  command                 = null;         // EW" ã€ã‚¢ãƒ??ローãƒ?"COPY|INSERT"
103            private String  gamenId                 = null;
104            private String  editName                = null;
105    
106            private transient DBTableModel table            = null;         // 5.5.2.4 (2012/05/16) transient 定義追�
107            private transient DBEditConfig config           = null;         // 5.5.2.4 (2012/05/16) transient 定義追�
108            
109            private boolean orderOnly               = false; // 5.5.5.2 (2012/08/10)
110    
111            /**
112             * Taglibã®é–‹å§‹ã‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doStartTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
113             *
114             * @return      後続å?ç??æŒ?¤º(SKIP_BODY)
115             */
116            @Override
117            public int doStartTag() {
118                    return(SKIP_BODY);                              // Body を評価ã—ãªã?
119            }
120    
121            /**
122             * Taglibã®çµ‚äº?‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doEndTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
123             * @return      後続å?ç??æŒ?¤º
124             */
125            @Override
126            public int doEndTag() {
127                    debugPrint();
128    
129                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
130    
131                    // エãƒ?‚£ãƒ?ƒˆæƒ??ã‚’HTMLã«å¤‰æ›ã—ã¦è¡¨ç¤ºã—ã¾ã™ã?
132                    // 表示ã«å½“ãŸã£ã¦ã€æœ€å¾Œã«ç™ºè¡Œã•れãŸQUERYã®tableIdã€scopeã‚’ãƒã‚§ãƒ?‚¯ã—ãŸä¸Šã§
133                    // 表示ã™ã‚‹ã‹ã‚’判断ã—ã¾ã™ã?
134                    if( "GET".equals( command ) ) {
135                            DBLastSql lastSql = (DBLastSql)getSessionAttribute( HybsSystem.DB_LAST_SQL_KEY );
136                            if( lastSql != null ) {
137                                    if( !lastSql.isViewEditable() ) {
138                                            // ã“ã?ç”»é¢ã¯ã€??ç›®ã®ä¸¦ã³æ›¿ãˆã?ã§ãã¾ã›ã‚“ã€?
139                                            String rtn = "<b style=\"font-color:red;\">" + getResource().getLabel( "GEE0003" ) + "</b>";
140                                            jspPrint( rtn );
141                                    }
142                                    else if( lastSql.isGuiMatch( gamenId ) ) {
143                                            setScope( lastSql.getScope() );
144                                            table = (DBTableModel)getObject( lastSql.getTableId() );
145                                            if( table != null ) {
146                                                    config = getUser().getEditConfig( gamenId, editName );
147                                                    String viewClms = null;
148                                                    if( config == null ) {
149                                                            viewClms = lastSql.getViewClmNames();
150                                                            config = new DBEditConfig();
151                                                    }
152                                                    else {
153                                                            viewClms = config.getViewClms();
154                                                    }
155                                                    buf.append( makeEditTable( viewClms ) );
156                                            }
157                                    }
158                            }
159                    }
160                    // エãƒ?‚£ãƒ?ƒˆæƒ??ã‚’ä¿å­˜ã—ã¾ã™ã?
161                    else if( "SET".equals( command ) ) {
162                            if( editName == null || editName.length() == 0 ) {
163                                    String msg = "エãƒ?‚£ãƒ?ƒˆåãŒæŒ?®šã•れã¦ã?¾ã›ã‚“ã€?;
164                                    throw new HybsSystemException( msg );
165                            }
166                            saveEditConfig();
167                    }
168                    // エãƒ?‚£ãƒ?ƒˆæƒ??を削除ã—ã¾ã™ã?
169                    else if( "DELETE".equals( command ) ) {
170                            if( editName == null || editName.length() == 0 ) {
171                                    String msg = "エãƒ?‚£ãƒ?ƒˆåãŒæŒ?®šã•れã¦ã?¾ã›ã‚“ã€?;
172                                    throw new HybsSystemException( msg );
173                            }
174                            deleteEditConfig();
175                    }
176                    // æŒ?®šã•れãŸç”»é¢IDã«å¯¾ã™ã‚‹ã‚¨ãƒ?‚£ãƒ?ƒˆæƒ??ã®ä¸?¦§(プルãƒ?‚¦ãƒ³)を表示ã—ã¾ã™ã?
177                    else if( "LIST".equals( command ) ) {
178                            DBEditConfig[] configs = getUser().getEditConfigs( gamenId );
179                            if( configs != null && configs.length > 0 ) {
180                                    buf.append( getEditSelect( configs ) ).append( HybsSystem.CR );
181                            }
182                    }
183    
184                    jspPrint( buf.toString() );
185    
186                    return(EVAL_PAGE);
187            }
188    
189            /**
190             * タグリブオブジェクトをリリースã—ã¾ã™ã?
191             * キャãƒ?‚·ãƒ¥ã•れã¦å†åˆ©ç”¨ã•れるã?ã§ã€ãƒ•ィールドã?åˆæœŸè¨­å®šã‚’行ã„ã¾ã™ã?
192             *
193             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
194             */
195            @Override
196            protected void release2() {
197                    super.release2();
198                    command = "GET";
199                    gamenId = null;
200                    editName = null;
201                    table = null;
202                    config = null;
203                    orderOnly               = false; //5.5.5.2 (2012/08/10)
204            }
205    
206            /**
207             * エãƒ?‚£ãƒ?ƒˆæƒ??ã‚’HTMLã«å¤‰æ›ã—ã¦è¡¨ç¤ºã—ã¾ã™ã?
208             *
209             * @og.rev 5.4.2.0 (2011/12/01) 入替ãˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ??ã§ã®ã¿ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãŒè¡¨ç¤ºã•れるよã?«å¯¾å¿œã—ã¾ã™ã?
210             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
211             *
212             * @param viewClms 表示カラãƒ?カンマ区åˆ?‚Š)
213             *
214             * @return エãƒ?‚£ãƒ?ƒˆæƒ??ã®HTML
215             */
216            private String makeEditTable( final String viewClms ) {
217                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
218    
219                    boolean useSum = getUseSum( viewClms );
220                    String[] viewGroups = StringUtil.csv2Array( viewClms, '|' );
221                    buf.append( "<input type=\"hidden\" name=\"viewClms\" id=\"viewClms\" value=\"" + viewClms + "\"/>" );
222                    buf.append( "<div />" );
223                    buf.append( "<div style=\"float:left;\">" );
224                    buf.append( makeLabelRow( useSum ) );
225                    buf.append( "</div>" );
226                    buf.append( "<div id=\"clmLayer\" style=\" float:left; width: 670px;overflow-x:scroll;\">" );
227                    for( int i=0; i<viewGroups.length; i++ ) {
228                            if( i > 0 ) {
229                                    buf.append( makeSeparateRow( useSum ) );
230                            }
231                            buf.append( "<table class=\"clmGroup\" style=\"float:left;\"><tr>" );
232                            String[] clms = StringUtil.csv2Array( viewGroups[i] );
233                            for( int j=0; j<clms.length; j++ ) {
234                                    String clm = ( !clms[j].startsWith( "!" ) ? clms[j] : clms[j].substring( 1 ) );
235                                    if( "rowCount".equals( clm ) ) { continue; }
236                                    boolean isView = ( !clms[j].startsWith( "!" ) ? true : false );
237                                    buf.append( makeColumnRow( clm, isView, useSum, config ) );
238                            }
239                            buf.append( "</tr></table>" );
240                    }
241                    buf.append( "</div>" );
242    
243                    String grandTotalLabel = "<b>" + getDBColumn( GRANDTOTAL_PREFIX + "LABEL" ).getLongLabel() + ":</b>";
244                    buf.append( "<div style=\"clear:both;\">" );
245                    buf.append( "<table>" );
246    //              buf.append( makeCheckbox( GRANDTOTAL_PREFIX, config.useGrandTotal(), "h", grandTotalLabel ) );
247                    buf.append( makeCheckbox( GRANDTOTAL_PREFIX, config.useGrandTotal(), "h", grandTotalLabel, orderOnly ) ); // 5.5.5.2 (2012/08/10)
248                    buf.append( "</table>" );
249                    buf.append( "</div>" );
250    
251                    return buf.toString();
252            }
253    
254            /**
255             * エãƒ?‚£ãƒ?ƒˆæƒ??ã®ãƒ˜ãƒƒãƒ??(ラベルè¡?ã®HTMLを生æˆã—ã¾ã™ã?
256             *
257             * @og.rev 5.4.2.0 (2011/12/01) 表示é ?›®ã®å…¨ãƒã‚§ãƒ?‚¯æ©Ÿè?を追åŠ?
258             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
259             *
260             * @param useSum é›?¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?=NUMBERåž?ãŒå­˜åœ¨ã—ã¦ã?‚‹ã?
261             *
262             * @return エãƒ?‚£ãƒ?ƒˆæƒ??ã®ãƒ˜ãƒƒãƒ??(ラベルè¡?ã®HTML
263             */
264            private String makeLabelRow( final boolean useSum ) {
265                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
266                    String commonLabel = "<b>" + getDBColumn( COMMON_PREFIX + "LABEL" ).getLongLabel() + ":</b>";
267                    String canEditCommon = HybsSystem.sys( "EDIT_COMMON_ROLES" );
268    
269                    String groupLabel = "<b>" + getDBColumn( GROUP_PREFIX + "LABEL" ).getLongLabel() + "</b>";
270                    groupLabel += "<img id=\"groupBtn\" src=\"" + HybsSystem.sys( "JSP" ) + "/image/ball-green.gif\" />";
271    
272                    buf.append( "<table><tr>" );
273                    buf.append( "<td style=\"margin:0px; padding:0px;\"><table>" );
274                    if( getUser().isAccess( canEditCommon ) ) {
275    //                      buf.append( makeCheckbox( COMMON_PREFIX, config.isCommon(), "h", commonLabel ) );
276                            buf.append( makeCheckbox( COMMON_PREFIX, config.isCommon(), "h", commonLabel, orderOnly ) ); // 5.5.5.2 (2012/08/10)
277                    }
278                    else {
279                            buf.append( makeLabel   ( commonLabel ) );
280                    }
281    //              buf.append( makeLabel   ( VIEW_PREFIX           + "LABEL" ) );
282                    String viewLabel = "<b>" + getDBColumn( VIEW_PREFIX + "LABEL" ).getLongLabel() + ":</b>";
283    //              buf.append( makeCheckbox( "VIEW_ALL_CHECK", true, "h", viewLabel ) );
284                    buf.append( makeCheckbox( "VIEW_ALL_CHECK", true, "h", viewLabel, orderOnly ) ); // 5.5.5.2 (2012/08/10)
285                    if( useSum ) {
286                            buf.append( makeLabel   ( SUM_PREFIX            + "LABEL" ) );
287                    }
288                    buf.append( makeCell    ( groupLabel, "h" ) );
289                    buf.append( makeLabel   ( SUBTOTAL_PREFIX       + "LABEL" ) );
290                    buf.append( makeLabel   ( TOTAL_PREFIX          + "LABEL" ) );
291                    buf.append( makeLabel   ( ORDERBY_PREFIX        + "LABEL" ) );
292                    buf.append( makeLabel   ( DESC_PREFIX           + "LABEL" ) );
293                    buf.append( "</table></td>" );
294                    buf.append( "</tr></table>" );
295                    return buf.toString();
296            }
297    
298            /**
299             * エãƒ?‚£ãƒ?ƒˆæƒ??ã®ã‚«ãƒ©ãƒ??ã®HTMLを生æˆã—ã¾ã™ã?
300             * 
301             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
302             *
303             * @param clm カラ�
304             * @param isView 表示対象ã‹ã©ã?‹
305             * @param useSum é›?¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?=NUMBERåž?ãŒå­˜åœ¨ã—ã¦ã?‚‹ã?
306             * @param config エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクãƒ?
307             *
308             * @return エãƒ?‚£ãƒ?ƒˆæƒ??ã®ã‚«ãƒ©ãƒ??ã®HTMLを生æˆã—ã¾ã™ã?
309             */
310            private String makeColumnRow( final String clm, final boolean isView, final boolean useSum, final DBEditConfig config ) {
311                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
312    
313                    int clmNo = table.getColumnNo( clm, false  );
314                    DBColumn column = ( clmNo < 0 ? getDBColumn( clm ) : table.getDBColumn( clmNo ) );
315                    buf.append( "<td name=\"" ).append( clm ).append( "\" class=\"sortItem\" style=\"margin:0px; padding:0px;\">" );
316                    buf.append( "<table>" );
317                    buf.append( makeLabel   ( column.getLongLabel() ) );
318    //              buf.append( makeCheckbox( VIEW_PREFIX                   + clm, isView                                           , "0", null ) );
319                    buf.append( makeCheckbox( VIEW_PREFIX                   + clm, isView                                           , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
320                    if( useSum ) {
321                            boolean isSumClm = isNumberClm( clm );
322    //                      buf.append( makeCheckbox( SUM_PREFIX            + clm, config.isSumClm( clm )           , "1", isSumClm , null ) );
323                            buf.append( makeCheckbox( SUM_PREFIX            + clm, config.isSumClm( clm )           , "1", isSumClm , null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
324                    }
325    //              buf.append( makeCheckbox( GROUP_PREFIX          + clm, config.isGroupClm( clm )         , "0", null ) );
326    //              buf.append( makeCheckbox( SUBTOTAL_PREFIX       + clm, config.isSubTotalClm( clm )      , "1", null ) );
327    //              buf.append( makeCheckbox( TOTAL_PREFIX          + clm, config.isTotalClm( clm )         , "0", null ) );
328    //              buf.append( makeInput   ( ORDERBY_PREFIX                + clm, config.getOrder( clm )           , "1", null ) );
329    //              buf.append( makeCheckbox( DESC_PREFIX                   + clm, config.isOrderByDesc( clm )      , "0", null ) );
330                    buf.append( makeCheckbox( GROUP_PREFIX          + clm, config.isGroupClm( clm )         , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
331                    buf.append( makeCheckbox( SUBTOTAL_PREFIX       + clm, config.isSubTotalClm( clm )      , "1", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
332                    buf.append( makeCheckbox( TOTAL_PREFIX          + clm, config.isTotalClm( clm )         , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
333                    buf.append( makeInput   ( ORDERBY_PREFIX                + clm, config.getOrder( clm )           , "1", null ) );
334                    buf.append( makeCheckbox( DESC_PREFIX                   + clm, config.isOrderByDesc( clm )      , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
335                    buf.append( "</table>" );
336                    buf.append( "</td>" );
337    
338                    return buf.toString();
339            }
340    
341            /**
342             * ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®HTMLæ–?­—å?を生æˆã—ã¾ã™ã?
343             * 生æ?ã—ãŸHTMLã¯ä»¥ä¸‹ã?よã†ã«ãªã‚Šã¾ã™ã?
344             * ä¾?&lt;tr&gt;&lt;td class="row_[bgCnt]" ...&gt;[prefix]&lt;input type="checkbox" name="[clm]" ... /&gt;&lt;/td&gt;&lt;/tr&gt;
345             *
346             * @param clm カラ�
347             * @param checked åˆæœŸãƒã‚§ãƒ?‚¯ã™ã‚‹ã‹ã©ã?‹
348             * @param bgCnt èƒŒæ™¯è‰²ã‚¼ãƒ–ãƒ©ã‚«ãƒ©ãƒ¼ã®æŒ?®?"0"or"1"or"h")
349             * @param prefix ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ã‚¿ã‚°ã®å‰ã«æŒ¿å…¥ã™ã‚‹HTMLæ–?­—å?
350             * @param readonly リードオンリー
351             * 
352             * @og.rev 5.5.5.2 (2012/08/10) readOnly追�
353             *
354             * @return ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®HMTLæ–?­—å?
355             */
356    //      private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final String prefix ) {
357            private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final String prefix, final boolean readonly ) {
358                    return makeCheckbox( clm, checked, bgCnt, true, prefix, readonly );
359            }
360    
361            /**
362             * ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®HTMLæ–?­—å?を生æˆã—ã¾ã™ã?
363             * 生æ?ã—ãŸHTMLã¯ä»¥ä¸‹ã?よã†ã«ãªã‚Šã¾ã™ã?
364             * ä¾?&lt;tr&gt;&lt;td class="row_[bgCnt]" ...&gt;[prefix]&lt;input type="checkbox" name="[clm]" ... /&gt;&lt;/td&gt;&lt;/tr&gt;
365             *
366             * @param clm カラ�
367             * @param checked åˆæœŸãƒã‚§ãƒ?‚¯ã™ã‚‹ã‹ã©ã?‹
368             * @param bgCnt èƒŒæ™¯è‰²ã‚¼ãƒ–ãƒ©ã‚«ãƒ©ãƒ¼ã®æŒ?®?"0"or"1"or"h")
369             * @param isChbox ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã‚’生æˆã™ã‚‹ã‹ã©ã?‹(falseã®å ´åˆã?ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®inputã‚¿ã‚°ã¯ç”Ÿæ?ã•れã¾ã›ã‚“)
370             * @param prefix ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ã‚¿ã‚°ã®å‰ã«æŒ¿å…¥ã™ã‚‹HTMLæ–?­—å?
371             * @param readonly リードオンリー
372             * 
373             * @og.rev 5.5.5.2 (2012/08/10) readOnly追�
374             *
375             * @return ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®HMTLæ–?­—å?
376             */
377    //      private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final boolean isChbox, final String prefix ) {
378            private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final boolean isChbox, final String prefix, final boolean readonly ) {
379                    if( isChbox ) {
380                            String suffix = "";
381                            TagBuffer tag = new TagBuffer( "input" );
382                            tag.add( "type", "checkbox" );
383                            tag.add( "name", clm );
384                            tag.add( "value", "1" );
385                            if( checked ) {
386                                    tag.add( "checked", "checked" );
387                            }
388                            if( readonly ){ // 5.5.5.2 (2012/08/10)
389                                    tag.add( "disabled", "disabled" );
390                                    if( checked ){
391                                            TagBuffer tag2 = new TagBuffer( "input" );
392                                            tag2.add( "type", "hidden" );
393                                            tag2.add( "name", clm );
394                                            tag2.add( "value", "1" );
395                                            suffix += tag2.makeTag();
396                                    }
397                                    
398                            }
399    //                      return makeCell( ( prefix == null ? "" : prefix ) + tag.makeTag(), bgCnt );
400                            return makeCell( ( prefix == null ? "" : prefix ) + tag.makeTag() + suffix, bgCnt ); // 5.5.5.2 (2012/08/10)
401                    }
402                    else {
403                            return makeCell( ( prefix == null ? "" : prefix ) + "&nbsp;", bgCnt );
404                    }
405            }
406    
407            /**
408             * ãƒ?‚­ã‚¹ãƒˆå?力HTMLæ–?­—å?を生æˆã—ã¾ã™ã?
409             * 生æ?ã—ãŸHTMLã¯ä»¥ä¸‹ã?よã†ã«ãªã‚Šã¾ã™ã?
410             * ä¾?&lt;tr&gt;&lt;td class="row_[bgCnt]" ...&gt;[prefix]&lt;input type="text" name="[clm]" ... /&gt;&lt;/td&gt;&lt;/tr&gt;
411             *
412             * @param clm カラ�
413             * @param value åˆæœŸãƒã‚§ãƒ?‚¯ã™ã‚‹ã‹ã©ã?‹
414             * @param bgCnt èƒŒæ™¯è‰²ã‚¼ãƒ–ãƒ©ã‚«ãƒ©ãƒ¼ã®æŒ?®?"0"or"1"or"h")
415             * @param prefix ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ã‚¿ã‚°ã®å‰ã«æŒ¿å…¥ã™ã‚‹HTMLæ–?­—å?
416             *
417             * @return ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®HMTLæ–?­—å?
418             */
419            private String makeInput( final String clm, final String value, final String bgCnt, final String prefix ) {
420                    TagBuffer tag = new TagBuffer( "input" );
421                    tag.add( "type", "text" );
422                    tag.add( "name", clm );
423                    tag.add( "value", value );
424                    tag.add( "style", "width: 10px; font-size:10px;" );
425                    tag.add( "maxlength", "2" );
426                    tag.add( "class", "S9" );
427    
428                    return makeCell( ( prefix == null ? "" : prefix ) + tag.makeTag(), bgCnt );
429            }
430    
431            /**
432             * å·¦å³åˆ?‰²ã•れã¦ã?‚‹éš›ã?åˆ?‰²åˆ—ã?HTMLæ–?­—å?を生æˆã—ã¾ã™ã?
433             *
434             * @param useSum é›?¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?=NUMBERåž?ãŒå­˜åœ¨ã—ã¦ã?‚‹ã?
435             *
436             * @return ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®HMTLæ–?­—å?
437             */
438            private String makeSeparateRow( final boolean useSum ) {
439                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
440    
441                    buf.append( "<table style=\"float:left;\"><tr>" );
442                    buf.append( "<td style=\"margin:0px; padding:0px;\"><table>" );
443                    buf.append( makeCell( "&nbsp", "h" ) );             // ラベル
444                    buf.append( makeCell( "&nbsp", "h" ) );             // 表示
445                    if( useSum ) {
446                            buf.append( makeCell( "&nbsp", "h" ) );             // é›?¨ˆé?ç›®
447                    }
448                    buf.append( makeCell( "&nbsp", "h" ) ); // é›?¨ˆã‚­ãƒ¼
449                    buf.append( makeCell( "&nbsp", "h" ) );     // å°è¨ˆã‚­ãƒ¼
450                    buf.append( makeCell( "&nbsp", "h" ) ); // åˆè¨ˆã‚­ãƒ¼
451                    buf.append( makeCell( "&nbsp", "h" ) ); // 表示�
452                    buf.append( makeCell( "&nbsp", "h" ) ); // æ˜??・é™é?
453                    buf.append( "</table></td>");
454                    buf.append( "</tr></table>" );
455    
456                    return buf.toString();
457            }
458    
459            /**
460             * ラベルã®HTMLæ–?­—å?を生æˆã—ã¾ã™ã?
461             *
462             * @param clm カラ�
463             *
464             * @return ラベルã®HTMLæ–?­—å?
465             */
466            private String makeLabel( final String clm ) {
467                    return makeCell( getDBColumn( clm ).getLongLabel(), "h" );
468            }
469    
470            /**
471             * セルã®HTMLæ–?­—å?を生æˆã—ã¾ã™ã?
472             *
473             * @param body tdã‚¿ã‚°å†??HTMLæ–?­—å?
474             * @param bgCnt èƒŒæ™¯è‰²ã‚¼ãƒ–ãƒ©ã‚«ãƒ©ãƒ¼ã®æŒ?®?"0"or"1"or"h")
475             *
476             * @return セルã®HTMLæ–?­—å?
477             */
478            private String makeCell( final String body, final String bgCnt ) {
479                    return "<tr><td align=\"center\" style=\"height:22px;\" class=\"row_" + bgCnt + "\">" + body + "</td></tr>";
480            }
481    
482            /**
483             * ã“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã§é›?¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?=NUMBERåž?ãŒå­˜åœ¨ã—ã¦ã?‚‹ã‹ã‚’è¿”ã—ã¾ã™ã?
484             *
485             * @param viewClms カラ�
486             *
487             * @return é›?¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?=NUMBERåž?ãŒå­˜åœ¨ã—ã¦ã?‚‹ã?
488             */
489            private boolean getUseSum( final String viewClms ) {
490                    if( viewClms == null ) { return false; }
491    
492                    boolean rtn = false;
493                    String[] clms = StringUtil.csv2Array( viewClms.replace( '|', ',' ) );
494                    for( int j=0; j<clms.length; j++ ) {
495                            String clm = ( !clms[j].startsWith( "!" ) ? clms[j] : clms[j].substring( 1 ) );
496                            rtn = isNumberClm( clm );
497                            if( rtn ) { break; }
498                    }
499                    return rtn;
500            }
501    
502            /**
503             * 引数ã®ã‚«ãƒ©ãƒ?ŒNUMBERåž‹ã‹ã©ã?‹ã‚’ãƒã‚§ãƒ?‚¯ã—ã¾ã™ã?
504             *
505             * @param clm カラ�
506             *
507             * @return NUMBERåž‹ã‹ã©ã?‹
508             */
509            private boolean isNumberClm( final String clm ) {
510                    if( clm == null ) { return false; }
511    
512                    int no = table.getColumnNo( clm, false );
513                    if( no >= 0 ) {
514                            DBColumn dbClm = table.getDBColumn( table.getColumnNo( clm ) );
515                            if( dbClm != null ) {
516                                    if( "NUMBER".equals( dbClm.getClassName()) ) {
517                                            return true;
518                                    }
519                            }
520                    }
521                    return false;
522            }
523    
524            /**
525             * エãƒ?‚£ãƒ?ƒˆè¨­å®šæƒ…報をä¿å­˜ã—ã¾ã™ã?
526             */
527            private void saveEditConfig() {
528                    String viewClms         = getRequest().getParameter( "viewClms" );
529                    String sumClms          = getColumns( SUM_PREFIX );
530                    String groupClms        = getColumns( GROUP_PREFIX );
531                    String subTotalClms = getColumns( SUBTOTAL_PREFIX );
532                    String totalClms        = getColumns( TOTAL_PREFIX );
533                    String useGrandTotal= getRequest().getParameter( GRANDTOTAL_PREFIX );
534                    String orderByClms      = getOrderByColumns();
535                    String isCommon         = getRequest().getParameter( COMMON_PREFIX );
536    
537                    DBEditConfig config
538                            = new DBEditConfig( editName, viewClms, sumClms, groupClms
539                                                                    , subTotalClms, totalClms, useGrandTotal, orderByClms, isCommon );
540    
541                    getUser().addEditConfig( gamenId, editName, config );
542            }
543    
544            /**
545             * エãƒ?‚£ãƒ?ƒˆè¨­å®šæƒ…報を削除ã—ã¾ã™ã?
546             */
547            private void deleteEditConfig() {
548                    getUser().deleteEditConfig( gamenId, editName );
549            }
550    
551            /**
552             * パラメーターã‹ã‚‰å¼•æ•°ã®ãƒ—レフィãƒ?‚¯ã‚¹ã‚’キーã«ã€ãƒã‚§ãƒ?‚¯ã•れãŸã‚«ãƒ©ãƒ?¸?¦§(カンマ区åˆ?‚Š)ã‚’è¿”ã—ã¾ã™ã?
553             *
554             * @param prefixKey å?‚­ãƒ¼ã®å–å¾—ã™ã‚‹ãŸã‚ã?プレフィãƒ?‚¯ã‚¹
555             *
556             * @return カラãƒ?¸?¦§(カンマ区åˆ?‚Š)
557             */
558            private String getColumns( final String prefixKey ) {
559                    StringBuilder buf = new StringBuilder();
560    
561                    Enumeration<?> enume = getParameterNames();
562                    while( enume.hasMoreElements() ) {
563                            String key = (String)(enume.nextElement());
564                            if( key.startsWith( prefixKey ) ) {
565                                    String val = getRequest().getParameter( key );
566                                    if( "1".equals( val ) ) {
567                                            String clm = key.substring( prefixKey.length() );
568                                            if( buf.length() > 0 ) { buf.append( "," ); }
569                                            buf.append( clm );
570                                    }
571                            }
572                    }
573    
574                    return buf.toString();
575            }
576    
577            /**
578             * 表示é ??カラãƒ?¸?¦§(カンマ区åˆ?‚Š)ã‚’è¿”ã—ã¾ã™ã?
579             *
580             * @return 表示é ??カラãƒ?¸?¦§(カンマ区åˆ?‚Š)
581             */
582            private String getOrderByColumns() {
583                    Enumeration<?> enume = getParameterNames();
584                    List<Integer> orderNo = new ArrayList<Integer>();
585                    Map<Integer,String> orderClm = new HashMap<Integer,String>();
586                    while( enume.hasMoreElements() ) {
587                            String key = (String)(enume.nextElement());
588                            if( key.startsWith( ORDERBY_PREFIX ) ) {
589                                    String val = getRequest().getParameter( key );
590                                    if( val != null && val.length() > 0 ) {
591                                            String clm = key.substring( ORDERBY_PREFIX.length() );
592                                            String desc = getRequest().getParameter( DESC_PREFIX + clm );
593                                            if( "1".equals( desc ) ) {
594                                                    clm = "!"  + clm;
595                                            }
596                                            // æ•°å­—é?目以外ãŒå…¥åŠ›ã•れãŸå ´åˆã?ç„¡è¦?
597                                            Integer odno = null;
598                                            try {
599                                                    odno = Integer.valueOf( val );
600                                            }
601                                            catch ( NumberFormatException ex ) {
602                                                    continue;
603                                            }
604                                            String str = orderClm.get( odno );
605                                            // åŒã˜ç•ªå·ã®å ´åˆã§ã‚‚é‡ãªã‚‰ãªã?‚ˆã?«æŒ¯ã‚Šç›´ã—ã™ã‚‹ã?
606                                            while( str != null ) {
607                                                    odno = Integer.valueOf( odno.intValue() + 1 );
608                                                    str = orderClm.get( odno );
609                                            }
610                                            orderClm.put( odno, clm );
611                                            orderNo.add( odno );
612                                    }
613                            }
614                    }
615    
616                    Collections.sort( orderNo );
617    
618                    StringBuilder buf = new StringBuilder();
619                    for( Integer i : orderNo ) {
620                            if( buf.length() > 0 ) { buf.append( "," ); }
621                            String clm = orderClm.get( i );
622                            buf.append( clm );
623                    }
624    
625                    return buf.toString();
626            }
627    
628            /**
629             * エãƒ?‚£ãƒ?ƒˆè¨­å®šä¸?¦§ã®ãƒ—ルãƒ?‚¦ãƒ³ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’作æ?ã—ã¾ã™ã?
630             *
631             * @param       configs DBEditConfigé…å?
632             *
633             * @return      エãƒ?‚£ãƒ?ƒˆä¸?¦§ã®ãƒ—ルãƒ?‚¦ãƒ³
634             */
635            private String getEditSelect( final DBEditConfig[] configs ) {
636                    DBColumn column = getDBColumn( "editName" );
637    
638                    StringBuilder buf = new StringBuilder();
639                    buf.append( "<span class=\"label editName\">" )
640                            .append( column.getLongLabel() )
641                            .append( ":</span><span class=\"editName\">" )
642                            .append( "<select name=\"editName\">" )
643                            .append( "<option />" );
644                    for( DBEditConfig config : configs ) {
645                            String name = config.getEditName();
646                            buf.append( "<option value=\"" ).append( name ).append( "\"" );
647                            if( config.isCommon() ) {
648                                    buf.append( " class=\"commonEdit\"" );
649                            }
650                            buf.append( "\">" );
651                            buf.append( name ).append( "</option>" );
652                    }
653                    buf.append( "</select></span>" );
654                    return buf.toString();
655            }
656    
657            /**
658             * ã€TAG】command を指定ã—ã¾ã™ã?
659             *
660             * @og.tag
661             * command を指定ã—ã¾ã™ã?
662             * [GET/LIST/SET/DELETE]ã®ã¿ãŒè¨­å®šå¯èƒ½ã§ã™ã?ãれ以外ã?å ´åˆã?何も処ç?•れã¾ã›ã‚“ã€?
663             *
664             * @param       cmd コマンド[GET/LIST/SET/DELETE]
665             */
666            public void setCommand( final String cmd ) {
667                    command = nval( getRequestParameter( cmd ),command );
668            }
669    
670            /**
671             * ã€TAG】画é¢ID を指定ã—ã¾ã™ã?
672             *
673             * @og.tag
674             * ç”»é¢ID を指定ã—ã¾ã™ã?
675             *
676             * @param       key ç”»é¢ID
677             */
678            public void setGamenId( final String key ) {
679                    gamenId = nval( getRequestParameter( key ),gamenId );
680            }
681    
682            /**
683             * ã€TAG】エãƒ?‚£ãƒ?ƒˆå?を指定ã—ã¾ã™ã?
684             *
685             * @og.tag
686             * エãƒ?‚£ãƒ?ƒˆå?を指定ã—ã¾ã™ã?
687             * commandãŒSETã¾ãŸã?DELETEã®å ´åˆã?å¿??ã§ã™ã?
688             * commandãŒGETã¾ãŸã?LISTã®å ´åˆã?無効ã§ã™ã?
689             *
690             * @param       name エãƒ?‚£ãƒ?ƒˆå?
691             */
692            public void setEditName( final String name ) {
693                    editName = nval( getRequestParameter( name ),editName );
694            }
695            
696            /**
697             * ã€TAG】ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ãƒªãƒ¼ãƒ‰ã‚ªãƒ³ãƒªãƒ¼åŒ–を行ã„ã¾ã?
698             *
699             * @og.tag
700             * é ?•ªã®å…¥ã‚Œæ›¿ãˆã¨ã€è¡¨ç¤ºé ??設定ã?ã¿ã‚’行ã†å ´åˆã«trueã«ã—ã¾ã™ã?
701             * 表示/éžè¡¨ç¤ºåˆ?›¿ã‚??é›?¨ˆæ©Ÿè?ã¯åˆ©ç”¨ã§ããªããªã‚Šã¾ã™ã?
702             * ?ˆãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ãƒªãƒ¼ãƒ‰ã‚ªãƒ³ãƒªãƒ¼ã¯ã§ããªã?Ÿã‚ã?実際ã«ã¯disable+hiddenã§å‡ºåŠ›ã—ã¦ã?¾ã™ï¼?
703             *
704             * @og.rev 5.5.5.2 (2012/08/10) æ–°è¦è¿½åŠ?
705             *
706             * @param   flag  [true:リードオンリー/ãれ以å¤?ç·¨é›?¯]
707             */
708            public void setOrderOnly( final String flag ) {
709                    orderOnly = nval( getRequestParameter( flag ),orderOnly );
710            }
711    
712            /**
713             * ã“ã?オブジェクトã?æ–?­—å?表ç¾ã‚’è¿”ã—ã¾ã™ã?
714             * 基本çš?«ãƒ?ƒãƒ?‚°ç›®çš?«ä½¿ç”¨ã—ã¾ã™ã?
715             *
716             * @return ã“ã?ã‚¯ãƒ©ã‚¹ã®æ–?­—å?表ç¾
717             */
718            @Override
719            public String toString() {
720                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
721                                    .println( "VERSION"             ,VERSION                )
722                                    .println( "command"             ,command                )
723                                    .println( "gamenId"             ,gamenId                )
724                                    .println( "editName"    ,editName               )
725                                    .println( "Other..."    ,getAttributes().getAttribute() )
726                                    .fixForm().toString() ;
727            }
728    }