Destiny.Lin
2 years ago
8 changed files with 140 additions and 32 deletions
@ -0,0 +1,87 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.js; |
||||||
|
|
||||||
|
import com.fr.base.chart.BaseChartCollection; |
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.design.actions.replace.action.content.component.SearchComponentAction; |
||||||
|
import com.fr.design.actions.replace.info.ComponentInfo; |
||||||
|
import com.fr.design.actions.replace.info.JSInfo; |
||||||
|
import com.fr.design.actions.replace.info.base.ITContent; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.form.ui.ChartEditor; |
||||||
|
import com.fr.form.ui.container.WTitleLayout; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 决策报表的图表组件中特殊存在的JS |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-09-20 |
||||||
|
*/ |
||||||
|
public class SearchComponentJSAction implements SearchJS { |
||||||
|
private SearchComponentJSAction() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void searchJSFromObject(JTemplate jTemplate, List<JSInfo> jsInfos) { |
||||||
|
List<JSInfo> componentJSInfos = new ArrayList<>(); |
||||||
|
addJSInfos2ListFromComponent(jTemplate, componentJSInfos); |
||||||
|
jsInfos.addAll(componentJSInfos); |
||||||
|
} |
||||||
|
|
||||||
|
private void addJSInfos2ListFromComponent(JTemplate jTemplate, List<JSInfo> componentJSInfos) { |
||||||
|
SearchComponentAction searchComponentAction = SearchComponentAction.getInstance(); |
||||||
|
searchComponentAction.search4Infos(jTemplate); |
||||||
|
List<ComponentInfo> componentInfoList = searchComponentAction.getComponentInfos(); |
||||||
|
for (ComponentInfo componentInfo : componentInfoList) { |
||||||
|
Object o = componentInfo.getContent().getReplaceObject(); |
||||||
|
if (o instanceof WTitleLayout) { |
||||||
|
if (((WTitleLayout) o).getBodyBoundsWidget().getWidget() instanceof ChartEditor) { |
||||||
|
ChartEditor chartEditor = (ChartEditor) ((WTitleLayout) o).getBodyBoundsWidget().getWidget(); |
||||||
|
SearchChartJSAction searchChartJSAction = SearchChartJSAction.getInstance(); |
||||||
|
for (BaseChartCollection chartCollection : chartEditor.getChartCollections()) { |
||||||
|
if (chartCollection instanceof ChartCollection) { |
||||||
|
searchChartJSAction.searchChartJS((ChartCollection) chartCollection, ITContent.copy(componentInfo.getContent()), componentJSInfos); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 对外开放获取对象的方法 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static SearchComponentJSAction getInstance() { |
||||||
|
return SearchComponentJSActionEnum.SINGLETON.getInstance(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 枚举实现单例 |
||||||
|
*/ |
||||||
|
private enum SearchComponentJSActionEnum { |
||||||
|
/** |
||||||
|
* 单例 |
||||||
|
*/ |
||||||
|
SINGLETON; |
||||||
|
private SearchComponentJSAction instance; |
||||||
|
|
||||||
|
SearchComponentJSActionEnum() { |
||||||
|
instance = new SearchComponentJSAction(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取单例的方法 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public SearchComponentJSAction getInstance() { |
||||||
|
return instance; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue