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.column; 017 018import org.opengion.fukurou.util.StringUtil; 019import org.opengion.fukurou.util.TagBuffer; 020import org.opengion.hayabusa.common.HybsSystem; 021import org.opengion.hayabusa.db.AbstractRenderer; 022import org.opengion.hayabusa.db.CellRenderer; 023import org.opengion.hayabusa.db.DBColumn; 024 025/** 026 * IFRAME レï¾ï¾ƒï¾žï¾—ã¯ã€iframe 内部㫠value ã§æŒ‡å®šã—ãŸï¾Œï½§ï½²ï¾™ã‚’表示ã™ã‚‹å ´åˆã« 027 * 使用ã™ã‚‹ï½¸ï¾—ï½½ã§ã™ã€‚ 028 * iframeã®ï½»ï½²ï½½ï¾žã¯ï¾šï¾ï¾ƒï¾žï¾—ーパラメータã«ã€è¨å®šã—ãŸã„属性を記述ã—ã¾ã™ã€‚ 029 * 例ãˆã°ã€width='600px' height='450px' ãªã©ã§ã™ã€‚ 030 * src属性ã¯valueã‚’è¨å®šã—ã€name属性ã¯ï½¶ï¾—ムå(複数行ã®å ´åˆã¯ã€è¡Œç•ªå·ä»˜ãã®åå‰) 031 * iframe ã®è¦ªã«ã¯ã€divè¦ç´ 㨠class="Renderer_IFRAME" を付与ã—ã¦ãŠãã¾ã™ã€‚ 032 * 033 * <div class="Renderer_IFRAME"> 034 * <iframe name="カラムå" src="valueã®å€¤" レï¾ï¾ƒï¾žï¾—ーパラメータ ></iframe> 035 * </div> 036 * 037 * カラムã®è¡¨ç¤ºã«å¿…è¦ãªå±žæ€§ã¯ã€DBColumn オブジェクト よりå–り出ã—ã¾ã™ã€‚ 038 * ã“ã®ï½¸ï¾—ï½½ã¯ã€DBColumn オブジェクト毎ã«1ã¤ä½œæˆã•ã‚Œã¾ã™ã€‚ 039 * 040 * @og.rev 7.4.2.0 (2021/04/30) æ–°è¦ä½œæˆ 041 * @og.group データ表示 042 * 043 * @version 7.4 044 * @author Kazuhiko Hasegawa 045 * @since JDK11.0, 046 */ 047public class Renderer_IFRAME extends AbstractRenderer { 048 /** ã“ã®ï¾Œï¾Ÿï¾›ï½¸ï¾žï¾—ムã®VERSIONæ–‡å—列をè¨å®šã—ã¾ã™ã€‚ {@value} */ 049 private static final String VERSION = "8.5.3.0 (2023/09/08)" ; 050 051 private static final String DIV_ST = "<div class=\"Renderer_IFRAME\">"; 052 private static final String DIV_ED = "</div>"; 053 054 private String name; 055 private String param; 056 057 /** 058 * デフォルトコï¾ï½½ï¾„ラクター。 059 * ã“ã®ï½ºï¾ï½½ï¾„ラクターã§ã€åŸºæœ¬ï½µï¾Œï¾žï½¼ï¾žï½ªï½¸ï¾„を作æˆã—ã¾ã™ã€‚ 060 * 061 */ 062 public Renderer_IFRAME() { super(); } // ã“れもã€è‡ªå‹•çš„ã«å‘¼ã°ã‚Œã‚‹ãŒã€ç©ºã®ï¾’ソッドを作æˆã™ã‚‹ã¨è¦å‘Šã•ã‚Œã‚‹ã®ã§ã€æ˜Žç¤ºçš„ã«ã—ã¦ãŠãã¾ã™ã€‚ 063 064 /** 065 * DBColumnオブジェクトを指定ã—ãŸprivateコï¾ï½½ï¾„ラクター。 066 * 067 * @og.rev 7.4.2.0 (2021/04/30) æ–°è¦ä½œæˆ 068 * @og.rev 8.5.3.0 (2023/09/08) DynamicAttributes対応 069 * 070 * @param clm DBColumnオブジェクト 071 */ 072 private Renderer_IFRAME( final DBColumn clm ) { 073 // 6.4.1.1 (2016/01/16) PMD refactoring. It is a good practice to call super() in a constructor 074 super(); 075 076 name = clm.getName(); 077// param = StringUtil.nval( clm.getRendererParam(), null ); // 空文å—列ã¯ã‚ãˆã¦nullã«ã™ã‚‹ã€‚ 078// param = StringUtil.nvalAdd( clm.getRendererParam() , 079// clm.getRendererAttributes().get( "optionAttributes" ) ); 080 // 8.5.3.0 (2023/09/08) optionAttributesã®ä½¿ã„æ–¹ãŒåˆ†ã‹ã‚‰ãªã„為ã€å…ƒã«æˆ»ã™ 081 param = StringUtil.nval( clm.getRendererParam(), null ); // 空文å—列ã¯ã‚ãˆã¦nullã«ã™ã‚‹ã€‚ 082 } 083 084 /** 085 * å„オブジェクトã‹ã‚‰è‡ªåˆ†ã®ï½²ï¾ï½½ï¾€ï¾ï½½ã‚’è¿”ã—ã¾ã™ã€‚ 086 * 自分自身をキャッシï½ã™ã‚‹ã®ã‹ã€æ–°ãŸã«ä½œæˆã™ã‚‹ã®ã‹ã¯ã€å„サブクラスã®å®Ÿè£…ã« 087 * ã¾ã‹ã•ã‚Œã¾ã™ã€‚ 088 * 089 * @param clm DBColumnオブジェクト 090 * 091 * @return CellEditorオブジェクト 092 * @og.rtnNotNull 093 */ 094 public CellRenderer newInstance( final DBColumn clm ) { 095 return new Renderer_IFRAME( clm ); 096 } 097 098 /** 099 * データã®è¡¨ç¤ºç”¨æ–‡å—列を返ã—ã¾ã™ã€‚ 100 * 101 * @og.rev 7.4.2.0 (2021/04/30) æ–°è¦ä½œæˆ 102 * 103 * @param value 入力値 104 * @return データã®è¡¨ç¤ºç”¨æ–‡å—列 105 * @og.rtnNotNull 106 */ 107 @Override 108 public String getValue( final String value ) { 109 return makeIframe( name, value ); 110 } 111 112 /** 113 * データã®è¡¨ç¤ºç”¨æ–‡å—列を返ã—ã¾ã™ã€‚ 114 * 115 * @og.rev 7.4.2.0 (2021/04/30) æ–°è¦ä½œæˆ 116 * 117 * @param row è¡Œç•ªå· 118 * @param value 入力値 119 * @return データ表示用ã®æ–‡å—列 120 * @og.rtnNotNull 121 */ 122 @Override 123 public String getValue( final int row,final String value ) { 124 final String newName = name + HybsSystem.JOINT_STRING + row; 125 return makeIframe( newName, value ); 126 } 127 128 /** 129 * データ出力用ã®æ–‡å—列を作æˆã—ã¾ã™ã€‚ 130 * ファイルç‰ã«å‡ºåŠ›ã™ã‚‹å½¢å¼ã‚’想定ã—ã¾ã™ã®ã§ã€HTMLタグをå«ã¾ãªã„ 131 * データを返ã—ã¾ã™ã€‚ 132 * 基本㯠#getValue( String ) ã‚’ãã®ã¾ã¾è¿”ã—ã¾ã™ã€‚ 133 * 134 * @og.rev 7.4.2.0 (2021/04/30) æ–°è¦ä½œæˆ 135 * 136 * @param value 入力値 137 * @return データ出力用ã®æ–‡å—列 138 * @og.rtnNotNull 139 * @see #getValue( String ) 140 */ 141 @Override 142 public String getWriteValue( final String value ) { 143 return value == null ? "" : value; 144 } 145 146 /** 147 * データã®è¡¨ç¤ºç”¨æ–‡å—列を返ã—ã¾ã™ã€‚ 148 * 149 * @og.rev 7.4.2.0 (2021/04/30) æ–°è¦ä½œæˆ 150 * 151 * @param name カラムå 152 * @param value 入力値 表示ã™ã‚‹ï¾Œï½§ï½²ï¾™ã®ï½±ï¾„゙レス 153 * @return データ表示用ã®æ–‡å—列 154 * @og.rtnNotNull 155 */ 156 private String makeIframe( final String name,final String value ) { 157 return DIV_ST 158 + new TagBuffer( "iframe" ) 159 .add( "name" , name ) 160 .add( "id" , name ) 161 .add( "src" , value ) 162 .addOptions( param ) // タグã®å±žæ€§ã¨ã—ã¦è¿½åŠ 。nullã®å ´åˆã¯ã€ä½•ã‚‚ã—ãªã„。 163 .addBody( value ) // iframeãŒæ©Ÿèƒ½ã—ãªã„å ´åˆã«è¡¨ç¤ºã•ã‚Œã‚‹ã€‚ 164 .makeTag() 165 + DIV_ED; 166 } 167}