forked from FR-Global/plugin-event-manager
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
5.9 KiB
139 lines
5.9 KiB
4 years ago
|
package com.fr.plugin.event.manager.ui;
|
||
|
|
||
|
import com.fr.base.parameter.ParameterUI;
|
||
|
import com.fr.design.gui.frpane.UITabbedPane;
|
||
|
import com.fr.design.layout.FRGUIPaneFactory;
|
||
|
import com.fr.form.ui.Widget;
|
||
|
import com.fr.main.TemplateWorkBook;
|
||
|
import com.fr.main.parameter.ReportParameterAttr;
|
||
|
import com.fr.plugin.event.manager.data.MyContainer;
|
||
|
import com.fr.plugin.event.manager.data.MySheet;
|
||
|
import com.fr.plugin.event.manager.data.MyWidget;
|
||
|
import com.fr.plugin.event.manager.data.WidgetSource;
|
||
|
import com.fr.report.cell.CellElement;
|
||
|
import com.fr.report.cell.TemplateCellElement;
|
||
|
import com.fr.report.cell.cellattr.highlight.DefaultHighlight;
|
||
|
import com.fr.report.cell.cellattr.highlight.WidgetHighlightAction;
|
||
|
import com.fr.report.elementcase.ElementCase;
|
||
|
import com.fr.report.poly.PolyECBlock;
|
||
|
import com.fr.report.report.Report;
|
||
|
|
||
|
import javax.swing.JPanel;
|
||
|
import java.awt.BorderLayout;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* @author Joe
|
||
|
* Created by Joe on 12/11/2020
|
||
|
*/
|
||
|
public class WorkbookEventManagerPane extends EventManagerPane<TemplateWorkBook> {
|
||
|
|
||
|
private MyContainer parameterContainer;
|
||
|
private List<MySheet> sheets = new ArrayList<>();
|
||
|
|
||
|
@Override
|
||
|
protected void initComponents(JPanel container) {
|
||
|
super.initComponents(container);
|
||
|
UITabbedPane tabbedPane = new UITabbedPane();
|
||
|
CellWidgetPane cellWidgetPane = new CellWidgetPane();
|
||
|
EventConfigPane eventConfigPane = new EventConfigPane();
|
||
|
eventConfigPane.addContainer(parameterContainer);
|
||
|
tabbedPane.addTab(cellWidgetPane.tabTitle(), cellWidgetPane);
|
||
|
tabbedPane.addTab("Parameter Widget", eventConfigPane);
|
||
|
|
||
|
container.setLayout(FRGUIPaneFactory.createBorderLayout());
|
||
|
container.add(tabbedPane, BorderLayout.CENTER);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void initData(TemplateWorkBook target) {
|
||
|
initParaWidget(target);
|
||
|
initReportWidget(target);
|
||
|
}
|
||
|
|
||
|
private void initParaWidget(TemplateWorkBook workBook) {
|
||
|
// 获取模板的参数属性对象
|
||
|
ReportParameterAttr reportParameterAttr = workBook.getReportParameterAttr();
|
||
|
// 获取参数面板对象
|
||
|
if (reportParameterAttr != null) {
|
||
|
ParameterUI parameterUI = reportParameterAttr.getParameterUI();
|
||
|
if (parameterUI != null) {
|
||
|
parameterContainer = new MyContainer();
|
||
|
// 获取参数面板所有控件
|
||
|
Widget[] widgets = parameterUI.getAllWidgets();
|
||
|
for (Widget widget : widgets) {
|
||
|
if (widget.getListenerSize() > 0) {
|
||
|
// 控件有事件
|
||
|
parameterContainer.addWidget(new MyWidget(widget));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void initReportWidget(TemplateWorkBook workBook) {
|
||
|
// 获取单元格控件
|
||
|
for (int i = 0; i < workBook.getReportCount(); i++) {
|
||
|
// 通过模板对象,获取报表页对象
|
||
|
Report report = workBook.getReport(i);
|
||
|
if (report != null) {
|
||
|
MySheet sheet = new MySheet();
|
||
|
Iterator it = report.iteratorOfElementCase();
|
||
|
while (it.hasNext()) {
|
||
|
// 通过迭代器,获取格子报表页对象
|
||
|
MyContainer container = new MyContainer();
|
||
|
ElementCase elementCase = (ElementCase) it.next();
|
||
|
Iterator cellIterator = elementCase.cellIterator();
|
||
|
while (cellIterator.hasNext()) {
|
||
|
// 通过迭代器,获取单元格对象
|
||
|
CellElement cell = (CellElement) cellIterator.next();
|
||
|
if (cell instanceof TemplateCellElement) {
|
||
|
if (((TemplateCellElement) cell).getWidget() != null) {
|
||
|
// 获取单元格控件
|
||
|
Widget widget0 = ((TemplateCellElement) cell).getWidget();
|
||
|
if (widget0.getListenerSize() > 0) {
|
||
|
// 控件有事件
|
||
|
container.addWidget(new MyWidget(widget0));
|
||
|
}
|
||
|
}
|
||
|
// 获取条件属性控件
|
||
|
if (((TemplateCellElement) cell).getHighlightGroup() != null) {
|
||
|
int highlightSize = ((TemplateCellElement) cell).getHighlightGroup().size();
|
||
|
for (int j = 0; j < highlightSize; j++) {
|
||
|
DefaultHighlight highlight = (DefaultHighlight) ((TemplateCellElement) cell).getHighlightGroup().getHighlight(j);
|
||
|
for (int k = 0; k < highlight.actionCount(); k++) {
|
||
|
if (highlight.getHighlightAction(k) instanceof WidgetHighlightAction) {
|
||
|
WidgetHighlightAction highlightAction = (WidgetHighlightAction) highlight.getHighlightAction(k);
|
||
|
container.addWidget(new MyWidget(highlightAction.getWidget(), WidgetSource.HIGHLIGHT));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (!container.getWidgets().isEmpty()) {
|
||
|
// 如果有控件
|
||
|
if (elementCase instanceof PolyECBlock) {
|
||
|
// 如果是聚合报表块
|
||
|
container.setBlockName(((PolyECBlock) elementCase).getBlockName());
|
||
|
}
|
||
|
sheet.addContainer(container);
|
||
|
}
|
||
|
}
|
||
|
sheets.add(sheet);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 当initComponents执行完后调用
|
||
|
*/
|
||
|
@Override
|
||
|
public void complete() {
|
||
|
// do nothing
|
||
|
}
|
||
|
|
||
|
}
|