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