@ -3,13 +3,16 @@ package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData ;
import com.fr.design.actions.replace.utils.ShowValueUtils ;
import com.fr.form.event.Listener ;
import com.fr.general.GeneralUtils ;
import com.fr.js.JavaScriptImpl ;
import com.fr.js.NameJavaScript ;
import com.fr.plugin.chart.base.VanChartHtmlLabel ;
import com.fr.stable.StringUtils ;
import com.fr.stable.collections.combination.Pair ;
import com.fr.web.attr.ReportWebAttr ;
import org.jetbrains.annotations.Nullable ;
import java.util.Arrays ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
@ -184,33 +187,71 @@ public enum ReplaceObject implements DealWithInfoValue {
return StringUtils . equals ( javaScript . getContent ( ) , info . getContent ( ) . getOldShowStr ( ) ) ;
}
} ,
/ * *
* 模板Web属性 — — 引用JS
* /
IMPORT_JS ( "String" ) {
@Override
public Map < String , String > getValue ( Object . . . o ) {
HashMap < String , String > map = new HashMap < > ( ) ;
addValue2Map ( contentKey , GeneralUtils . objectToString ( o [ 0 ] ) , map ) ;
return map ;
}
@Override
public void setValue ( Info info , String findStr , String replaceStr , List < Pair < Integer , Integer > > operatorArray ) {
if ( info . getContent ( ) . getHoldObject ( ) instanceof ReportWebAttr ) {
ReportWebAttr attr = ( ReportWebAttr ) info . getContent ( ) . getHoldObject ( ) ;
List < String > jsImports = Arrays . asList ( attr . getJSImport ( ) ) ;
String jsName = GeneralUtils . objectToString ( info . getContent ( ) . getReplaceObject ( ) ) ;
for ( int i = 0 , len = jsImports . size ( ) ; i < len ; i + + ) {
if ( StringUtils . equals ( jsImports . get ( i ) , jsName ) ) {
jsImports . set ( i , ShowValueUtils . replaceAll ( jsName , findStr , replaceStr ) ) ;
}
}
attr . clearJSImportList ( ) ;
for ( int i = 0 , len = jsImports . size ( ) ; i < len ; i + + ) {
attr . addJSImport ( jsImports . get ( i ) ) ;
}
}
}
@Override
public String getInfoShowStr ( Info info ) {
return GeneralUtils . objectToString ( info . getContent ( ) . getReplaceObject ( ) ) ;
}
@Override
boolean check ( Info info ) {
return true ;
}
} ,
/ * *
* DBTableData — — SQL
* /
DB_TABLE_DATA ( "DBTableData" ) {
@Override
boolean check ( Info info ) {
boolean check ( Info info ) {
DBTableData dbTableData = ( DBTableData ) info . getContent ( ) . getReplaceObject ( ) ;
return StringUtils . equals ( dbTableData . getQuery ( ) , info . getContent ( ) . getOldShowStr ( ) ) ;
}
@Override
public Map < String , String > getValue ( Object . . . o ) {
public Map < String , String > getValue ( Object . . . o ) {
HashMap < String , String > map = new HashMap < > ( ) ;
addValue2Map ( contentKey , ( ( DBTableData ) o [ 0 ] ) . getQuery ( ) , map ) ;
return map ;
}
@Override
public void setValue ( Info info , String findStr , String replaceStr , List < Pair < Integer , Integer > > operatorArray ) {
public void setValue ( Info info , String findStr , String replaceStr , List < Pair < Integer , Integer > > operatorArray ) {
DBTableData dbTableData = ( DBTableData ) info . getContent ( ) . getReplaceObject ( ) ;
info . updateOldStr ( dbTableData . getQuery ( ) , findStr ) ;
dbTableData . setQuery ( ShowValueUtils . replaceAll ( dbTableData . getQuery ( ) , findStr , replaceStr ) ) ;
//todo DesignTableDataManager
}
@Override
public String getInfoShowStr ( Info info ) {
public String getInfoShowStr ( Info info ) {
return info . getInfoShowStr ( info ) ;
}
} ;
@ -256,4 +297,4 @@ public enum ReplaceObject implements DealWithInfoValue {
abstract boolean check ( Info info ) ;
}
}