forked from FR-Global/plugin-event-manager
25 changed files with 694 additions and 448 deletions
@ -1,51 +0,0 @@
|
||||
package com.fr.plugin.event.manager; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.JTemplateAction; |
||||
import com.fr.design.mainframe.JForm; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.ui.FormWidgetHelper; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.container.WLayout; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 9/3/2020 |
||||
*/ |
||||
public class FormEventManager extends JTemplateAction<JForm> { |
||||
|
||||
public FormEventManager(JForm jForm) { |
||||
super(jForm); |
||||
this.setMenuKeySet(KeySetUtils.EVENT_MANAGER); |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
final JForm jwb = getEditingComponent(); |
||||
if (jwb == null) { |
||||
return; |
||||
} |
||||
final Form wbTpl = jwb.getTarget(); |
||||
// 获取最底层的表单容器
|
||||
WLayout container = wbTpl.getContainer(); |
||||
|
||||
// 获取参数面板容器
|
||||
WLayout parameterContainer = wbTpl.getParaContainer(); |
||||
if (parameterContainer != null) { |
||||
System.out.println("表单参数面板控件数:" + parameterContainer.getWidgetCount()); |
||||
System.out.println("根据Index获取控件:" + parameterContainer.getWidget(0)); |
||||
System.out.println("根据名称获取控件:" + parameterContainer.getWidget("textEditor0")); |
||||
} |
||||
|
||||
// 获取表单中指定名字的控件
|
||||
Widget report = wbTpl.getWidgetByName("report0"); |
||||
// 获取表单中指定名字的控件(不对WTitleLayout和WScaleLayout进一步处理)
|
||||
Widget chart = wbTpl.getWidgetWithBound("chart0"); |
||||
} |
||||
} |
@ -1,274 +0,0 @@
|
||||
package com.fr.plugin.event.manager; |
||||
|
||||
import com.fr.base.Parameter; |
||||
import com.fr.base.TableData; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.io.attr.ReportExportAttr; |
||||
import com.fr.main.TemplateWorkBook; |
||||
import com.fr.main.parameter.ReportParameterAttr; |
||||
import com.fr.main.workbook.ResultWorkBook; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
import com.fr.report.mobile.ElementCaseMobileAttr; |
||||
import com.fr.report.report.ECReport; |
||||
import com.fr.report.report.Report; |
||||
import com.fr.report.report.TemplateReport; |
||||
import com.fr.report.stable.fun.Actor; |
||||
import com.fr.report.worksheet.WorkSheet; |
||||
import com.fr.stable.fun.IOFileAttrMark; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.web.attr.ReportWebAttr; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 装饰器模式 |
||||
* @author Joe |
||||
* Created by Joe on 9/24/2020 |
||||
*/ |
||||
public class TemplateWorkBookDecorator implements TemplateWorkBook { |
||||
protected TemplateWorkBook decoratedTemplateWorkBook; |
||||
|
||||
private List<Widget> widgetList; |
||||
|
||||
public TemplateWorkBookDecorator(TemplateWorkBook templateWorkBook) { |
||||
decoratedTemplateWorkBook = templateWorkBook; |
||||
widgetList = new ArrayList<>(); |
||||
} |
||||
|
||||
@Override |
||||
public void addReport(TemplateReport templateReport) { |
||||
decoratedTemplateWorkBook.addReport(templateReport); |
||||
} |
||||
|
||||
@Override |
||||
public void addReport(String s, TemplateReport templateReport) { |
||||
decoratedTemplateWorkBook.addReport(s, templateReport); |
||||
} |
||||
|
||||
@Override |
||||
public void setReport(int i, TemplateReport templateReport) { |
||||
decoratedTemplateWorkBook.setReport(i, templateReport); |
||||
} |
||||
|
||||
@Override |
||||
public void setReport(int i, String s, TemplateReport templateReport) { |
||||
decoratedTemplateWorkBook.setReport(i, s, templateReport); |
||||
} |
||||
|
||||
@Override |
||||
public TemplateReport getTemplateReport(int i) { |
||||
return decoratedTemplateWorkBook.getTemplateReport(i); |
||||
} |
||||
|
||||
@Override |
||||
public WorkSheet getTemplateElementCaseReport(int i) { |
||||
return decoratedTemplateWorkBook.getTemplateElementCaseReport(i); |
||||
} |
||||
|
||||
@Override |
||||
public int getReportIndex(TemplateReport templateReport) { |
||||
return decoratedTemplateWorkBook.getReportIndex(templateReport); |
||||
} |
||||
|
||||
@Override |
||||
public void apply4Parameters(Map<String, Object> map) { |
||||
decoratedTemplateWorkBook.apply4Parameters(map); |
||||
} |
||||
|
||||
@Override |
||||
public ResultWorkBook execute(Map<String, Object> map, Actor actor) { |
||||
return decoratedTemplateWorkBook.execute(map, actor); |
||||
} |
||||
|
||||
@Override |
||||
public ResultWorkBook execute(Map<String, Object> map, Actor actor, int i) { |
||||
return decoratedTemplateWorkBook.execute(map, actor, i); |
||||
} |
||||
|
||||
@Override |
||||
public ReportParameterAttr getReportParameterAttr() { |
||||
return decoratedTemplateWorkBook.getReportParameterAttr(); |
||||
} |
||||
|
||||
@Override |
||||
public void setReportParameterAttr(ReportParameterAttr reportParameterAttr) { |
||||
decoratedTemplateWorkBook.setReportParameterAttr(reportParameterAttr); |
||||
} |
||||
|
||||
@Override |
||||
public Parameter[] getParameters() { |
||||
return decoratedTemplateWorkBook.getParameters(); |
||||
} |
||||
|
||||
@Override |
||||
public String getReportName(int i) { |
||||
return decoratedTemplateWorkBook.getReportName(i); |
||||
} |
||||
|
||||
@Override |
||||
public void setReportName(int i, String s) { |
||||
decoratedTemplateWorkBook.setReportName(i, s); |
||||
} |
||||
|
||||
@Override |
||||
public void removeReport(String s) { |
||||
decoratedTemplateWorkBook.removeReport(s); |
||||
} |
||||
|
||||
@Override |
||||
public void removeReport(int i) { |
||||
decoratedTemplateWorkBook.removeReport(i); |
||||
} |
||||
|
||||
@Override |
||||
public void removeReports() { |
||||
decoratedTemplateWorkBook.removeReports(); |
||||
} |
||||
|
||||
@Override |
||||
public Report getReport(int i) { |
||||
return decoratedTemplateWorkBook.getReport(i); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isElementCaseBook() { |
||||
return decoratedTemplateWorkBook.isElementCaseBook(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isElementCaseBook(int i) { |
||||
return decoratedTemplateWorkBook.isElementCaseBook(i); |
||||
} |
||||
|
||||
@Override |
||||
public ECReport getElementCaseReport(int i) { |
||||
return decoratedTemplateWorkBook.getElementCaseReport(i); |
||||
} |
||||
|
||||
@Override |
||||
public int getReportCount() { |
||||
return decoratedTemplateWorkBook.getReportCount(); |
||||
} |
||||
|
||||
@Override |
||||
public ReportWebAttr getReportWebAttr() { |
||||
return decoratedTemplateWorkBook.getReportWebAttr(); |
||||
} |
||||
|
||||
@Override |
||||
public void setReportWebAttr(ReportWebAttr reportWebAttr) { |
||||
decoratedTemplateWorkBook.setReportWebAttr(reportWebAttr); |
||||
} |
||||
|
||||
@Override |
||||
public ReportExportAttr getReportExportAttr() { |
||||
return decoratedTemplateWorkBook.getReportExportAttr(); |
||||
} |
||||
|
||||
@Override |
||||
public void setReportExportAttr(ReportExportAttr reportExportAttr) { |
||||
decoratedTemplateWorkBook.setReportExportAttr(reportExportAttr); |
||||
} |
||||
|
||||
@Override |
||||
public ElementCaseMobileAttr getReportMobileAttr() { |
||||
return decoratedTemplateWorkBook.getReportMobileAttr(); |
||||
} |
||||
|
||||
@Override |
||||
public void setReportMobileAttr(ElementCaseMobileAttr elementCaseMobileAttr) { |
||||
decoratedTemplateWorkBook.setReportMobileAttr(elementCaseMobileAttr); |
||||
} |
||||
|
||||
@Override |
||||
public void addAttrMark(IOFileAttrMark ioFileAttrMark) { |
||||
decoratedTemplateWorkBook.addAttrMark(ioFileAttrMark); |
||||
} |
||||
|
||||
@Override |
||||
public <T extends IOFileAttrMark> T getAttrMark(String s) { |
||||
return decoratedTemplateWorkBook.getAttrMark(s); |
||||
} |
||||
|
||||
@Override |
||||
public Iterator<String> getAllMarkName() { |
||||
return decoratedTemplateWorkBook.getAllMarkName(); |
||||
} |
||||
|
||||
@Override |
||||
public Iterator<String> getTableDataNameIterator() { |
||||
return decoratedTemplateWorkBook.getTableDataNameIterator(); |
||||
} |
||||
|
||||
@Override |
||||
public TableData getTableData(String s) { |
||||
return decoratedTemplateWorkBook.getTableData(s); |
||||
} |
||||
|
||||
@Override |
||||
public void putTableData(String s, TableData tableData) { |
||||
decoratedTemplateWorkBook.putTableData(s, tableData); |
||||
} |
||||
|
||||
@Override |
||||
public boolean renameTableData(String s, String s1) { |
||||
return decoratedTemplateWorkBook.renameTableData(s, s1); |
||||
} |
||||
|
||||
@Override |
||||
public void removeTableData(String s) { |
||||
decoratedTemplateWorkBook.removeTableData(s); |
||||
} |
||||
|
||||
@Override |
||||
public void clearAllTableData() { |
||||
decoratedTemplateWorkBook.clearAllTableData(); |
||||
} |
||||
|
||||
@Override |
||||
public ReportFitAttr getReportFitAttr() { |
||||
return decoratedTemplateWorkBook.getReportFitAttr(); |
||||
} |
||||
|
||||
@Override |
||||
public void setReportFitAttr(ReportFitAttr reportFitAttr) { |
||||
decoratedTemplateWorkBook.setReportFitAttr(reportFitAttr); |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader xmLableReader) { |
||||
decoratedTemplateWorkBook.readXML(xmLableReader); |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter xmlPrintWriter) { |
||||
decoratedTemplateWorkBook.writeXML(xmlPrintWriter); |
||||
} |
||||
|
||||
@Override |
||||
public String[] getJSImport() { |
||||
return decoratedTemplateWorkBook.getJSImport(); |
||||
} |
||||
|
||||
@Override |
||||
public String[] getCSSImport() { |
||||
return decoratedTemplateWorkBook.getCSSImport(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
return decoratedTemplateWorkBook.clone(); |
||||
} |
||||
|
||||
public List<Widget> getWidgetList() { |
||||
return widgetList; |
||||
} |
||||
|
||||
public void addWidget(Widget widget) { |
||||
this.widgetList.add(widget); |
||||
} |
||||
} |
@ -1,116 +0,0 @@
|
||||
package com.fr.plugin.event.manager; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.parameter.ParameterUI; |
||||
import com.fr.design.actions.JWorkBookAction; |
||||
import com.fr.design.mainframe.JWorkBook; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.form.event.Listener; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.js.JavaScript; |
||||
import com.fr.js.JavaScriptImpl; |
||||
import com.fr.main.TemplateWorkBook; |
||||
import com.fr.main.parameter.ReportParameterAttr; |
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.privilege.finegrain.CellPrivilegeControl; |
||||
import com.fr.privilege.finegrain.WorkSheetPrivilegeControl; |
||||
import com.fr.report.cell.AbstractWidgetCellElement; |
||||
import com.fr.report.cell.CellElement; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.report.cell.WidgetAttrElem; |
||||
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.elementcase.TemplateElementCase; |
||||
import com.fr.report.report.Report; |
||||
import com.fr.report.report.TemplateReport; |
||||
|
||||
import javax.swing.KeyStroke; |
||||
import java.awt.event.ActionEvent; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
import static com.fr.plugin.event.manager.KeySetUtils.EVENT_MANAGER; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 9/3/2020 |
||||
*/ |
||||
@FunctionRecorder |
||||
public class WorkbookEventManager extends JWorkBookAction { |
||||
private List<Widget> widgetList = new ArrayList<>(); |
||||
|
||||
public WorkbookEventManager(JWorkBook jwb) { |
||||
super(jwb); |
||||
this.setMenuKeySet(KeySetUtils.EVENT_MANAGER); |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.png")); |
||||
} |
||||
|
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public void actionPerformed(ActionEvent e) { |
||||
JWorkBook jwb = getEditingComponent(); |
||||
if (jwb == null) { |
||||
return; |
||||
} |
||||
|
||||
final TemplateWorkBook wbTpl = jwb.getTarget(); |
||||
ReportParameterAttr reportParameterAttr = wbTpl.getReportParameterAttr(); |
||||
// 参数面板获取控件
|
||||
ParameterUI parameterUI = reportParameterAttr.getParameterUI(); |
||||
Widget[] widgets = parameterUI.getAllWidgets(); |
||||
for (Widget widget : widgets) { |
||||
if (widget.getListenerSize() > 0) { |
||||
// 有事件的控件
|
||||
widgetList.add(widget); |
||||
} |
||||
|
||||
// 获取单元格控件
|
||||
for (int i = 0; i < wbTpl.getReportCount(); i++) { |
||||
Report report = wbTpl.getReport(i); |
||||
if (report != null) { |
||||
Iterator it = report.iteratorOfElementCase(); |
||||
while (it.hasNext()) { |
||||
ElementCase elementCase = (ElementCase) it.next(); |
||||
Iterator cellIterator = elementCase.cellIterator(); |
||||
while (cellIterator.hasNext()) { |
||||
CellElement cell = (CellElement) cellIterator.next(); |
||||
//单元格内有控件
|
||||
if (cell instanceof TemplateCellElement && ((TemplateCellElement) cell).getWidget() != null) { |
||||
Widget widget0 = ((TemplateCellElement) cell).getWidget(); |
||||
if (widget0.getListenerSize() > 0) { |
||||
widgetList.add(widget0); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (Widget widget1 : widgetList) { |
||||
for (int i = 0; i < widget1.getListenerSize(); i++) { |
||||
Listener listener = widget1.getListener(i); |
||||
JavaScript javaScript = listener.getAction(); |
||||
System.out.println("控件名:" + widget1.getWidgetName()); |
||||
System.out.println("事件名:" + listener.getEventName()); |
||||
System.out.println("事件类型:" + javaScript.getClass().getName()); |
||||
} |
||||
} |
||||
|
||||
/* // 测试修改控件事件
|
||||
if("test".equals(widget.getWidgetName())) { |
||||
Listener listener = new Listener(); |
||||
listener.setEventName("afterinit"); |
||||
JavaScriptImpl javaScript = new JavaScriptImpl(); |
||||
javaScript.setContent("this is a test"); |
||||
listener.setAction(javaScript); |
||||
widget.addListener(listener); |
||||
}*/ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
|
||||
package com.fr.plugin.event.manager.core; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.JTemplateAction; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.plugin.event.manager.ui.EventManagerDialog; |
||||
import com.fr.plugin.event.manager.utils.KeySetUtils; |
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
@FunctionRecorder |
||||
public abstract class EventManager extends JTemplateAction<JTemplate<?, ?>> { |
||||
|
||||
public EventManager(JTemplate<?, ?> jTemplate) { |
||||
super(jTemplate); |
||||
this.setMenuKeySet(KeySetUtils.EVENT_MANAGER); |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/plugin/event/manager/images/icon_event_manager.png")); |
||||
} |
||||
|
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public void actionPerformed(ActionEvent e) { |
||||
JTemplate jt = getEditingComponent(); |
||||
if (jt == null) { |
||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "无法获取模板对象!", |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.ERROR_MESSAGE); |
||||
return; |
||||
} |
||||
|
||||
final Object target = jt.getTarget(); |
||||
BasicPane eventManagerPane = initEventManager(target); |
||||
|
||||
UIDialog dlg = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane); |
||||
dlg.setVisible(true); |
||||
|
||||
} |
||||
|
||||
protected abstract BasicPane initEventManager(Object target); |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.plugin.event.manager.core; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.plugin.event.manager.ui.FormEventManagerPane; |
||||
|
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 9/3/2020 |
||||
*/ |
||||
public class FormEventManager extends EventManager { |
||||
|
||||
public FormEventManager(JTemplate<?, ?> jTemplate) { |
||||
super(jTemplate); |
||||
} |
||||
|
||||
/** |
||||
* @param target |
||||
* @return |
||||
*/ |
||||
@Override |
||||
protected BasicPane initEventManager(Object target) { |
||||
// todo 控件对象整理
|
||||
FormEventManagerPane eventManagerPane = new FormEventManagerPane(); |
||||
if (target instanceof Form) { |
||||
eventManagerPane.setTarget((Form) target); |
||||
} |
||||
return eventManagerPane; |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.event.manager.core; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.main.TemplateWorkBook; |
||||
import com.fr.plugin.event.manager.ui.WorkbookEventManagerPane; |
||||
|
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 9/3/2020 |
||||
*/ |
||||
public class WorkbookEventManager extends EventManager { |
||||
|
||||
public WorkbookEventManager(JTemplate<?, ?> jTemplate) { |
||||
super(jTemplate); |
||||
} |
||||
|
||||
/** |
||||
* workbook返回tabPane |
||||
* |
||||
* @param target |
||||
* @return |
||||
*/ |
||||
@Override |
||||
protected BasicPane initEventManager(Object target) { |
||||
WorkbookEventManagerPane eventManagerPane = new WorkbookEventManagerPane(); |
||||
if (target instanceof TemplateWorkBook) { |
||||
eventManagerPane.setTarget((TemplateWorkBook) target); |
||||
} |
||||
return eventManagerPane; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.plugin.event.manager.data; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public class MyContainer { |
||||
private String blockName; |
||||
private List<MyWidget> widgets; |
||||
|
||||
public MyContainer() { |
||||
widgets = new ArrayList<>(); |
||||
} |
||||
|
||||
public String getBlockName() { |
||||
return blockName; |
||||
} |
||||
|
||||
public void setBlockName(String blockName) { |
||||
this.blockName = blockName; |
||||
} |
||||
|
||||
public void addWidget(MyWidget widget) { |
||||
this.widgets.add(widget); |
||||
} |
||||
|
||||
public void setWidgets(List<MyWidget> widgets) { |
||||
this.widgets = widgets; |
||||
} |
||||
|
||||
public List<MyWidget> getWidgets() { |
||||
return this.widgets; |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fr.plugin.event.manager.data; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/14/2020 |
||||
*/ |
||||
public interface MyNode { |
||||
String getNodeName(); |
||||
|
||||
String getIconPath(); |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.plugin.event.manager.data; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public class MySheet { |
||||
private List<MyContainer> containers; |
||||
|
||||
public MySheet() { |
||||
containers = new ArrayList<>(); |
||||
} |
||||
|
||||
public void addContainer(MyContainer container) { |
||||
this.containers.add(container); |
||||
} |
||||
|
||||
public void setContainers(List<MyContainer> containers) { |
||||
this.containers = containers; |
||||
} |
||||
|
||||
public List<MyContainer> getContainers() { |
||||
return containers; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.plugin.event.manager.data; |
||||
|
||||
import com.fr.form.ui.Widget; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/13/2020 |
||||
*/ |
||||
public class MyWidget { |
||||
private Widget widget; |
||||
// 来自普通还是条件属性
|
||||
private WidgetSource source; |
||||
|
||||
public MyWidget(Widget widget) { |
||||
this(widget, WidgetSource.NORMAL); |
||||
} |
||||
|
||||
public MyWidget(Widget widget, WidgetSource source) { |
||||
this.widget = widget; |
||||
this.source = source; |
||||
} |
||||
|
||||
public Widget getWidget() { |
||||
return widget; |
||||
} |
||||
|
||||
public void setWidget(Widget widget) { |
||||
this.widget = widget; |
||||
} |
||||
|
||||
public WidgetSource getSource() { |
||||
return source; |
||||
} |
||||
|
||||
public void setSource(WidgetSource source) { |
||||
this.source = source; |
||||
} |
||||
} |
@ -0,0 +1,9 @@
|
||||
package com.fr.plugin.event.manager.data; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/13/2020 |
||||
*/ |
||||
public enum WidgetSource { |
||||
NORMAL, HIGHLIGHT |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.plugin.event.manager.ui; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/13/2020 |
||||
*/ |
||||
public class CellWidgetPane extends BasicPane { |
||||
public String tabTitle() { |
||||
return "Cell Widget"; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "cell widget"; |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
package com.fr.plugin.event.manager.ui; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.icontainer.UIScrollPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.design.widget.FRWidgetFactory; |
||||
import com.fr.plugin.event.manager.data.MyContainer; |
||||
import com.fr.plugin.event.manager.ui.tree.ContainerRootTree; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JSplitPane; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public class EventConfigPane extends BasicPane { |
||||
private CardLayout cardLayout; |
||||
private JPanel cardPane; |
||||
private List<MyContainer> containers; |
||||
|
||||
public EventConfigPane() { |
||||
containers = new ArrayList<>(); |
||||
this.initComponentPane(); |
||||
} |
||||
|
||||
public void addContainer(MyContainer container) { |
||||
containers.add(container); |
||||
} |
||||
|
||||
private void initComponentPane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
initCardPane(); |
||||
// SplitPane
|
||||
// 增加边框
|
||||
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); |
||||
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); |
||||
mainSplitPane.setOneTouchExpandable(true); |
||||
|
||||
this.add(mainSplitPane, BorderLayout.CENTER); |
||||
// todo 考虑是否弹性
|
||||
mainSplitPane.setDividerLocation(230); |
||||
} |
||||
|
||||
private void initCardPane() { |
||||
// p: edit card layout
|
||||
this.cardLayout = new CardLayout(); |
||||
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
cardPane.setLayout(this.cardLayout); |
||||
// p:选择的Label
|
||||
UILabel selectLabel = new UILabel(); |
||||
cardPane.add(selectLabel); |
||||
} |
||||
|
||||
private JPanel getLeftPane() { |
||||
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
// 存放组件树
|
||||
JPanel leftContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
initLeftContentPane(leftContentPane); |
||||
leftPane.add(leftContentPane, BorderLayout.CENTER); |
||||
// 左上方 items with event
|
||||
JPanel leftTopPane = getLeftTopPane(); |
||||
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 6, 6, 0)); |
||||
leftPane.add(leftTopPane, BorderLayout.NORTH); |
||||
return leftPane; |
||||
} |
||||
|
||||
private void initLeftContentPane(JPanel leftContentPane) { |
||||
ContainerRootTree tree = new ContainerRootTree(); |
||||
// 把树添加到滚动框中
|
||||
leftContentPane.add(new UIScrollPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
private JPanel getLeftTopPane() { |
||||
JPanel leftTopPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
leftTopPane.add(FRWidgetFactory.createLineWrapLabel("Items with Event"), BorderLayout.CENTER); |
||||
return leftTopPane; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "event config"; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.plugin.event.manager.ui; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.awt.Frame; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public class EventManagerDialog extends UIDialog { |
||||
private static final Dimension SIZE = new Dimension(900, 600); |
||||
|
||||
public EventManagerDialog(Frame frame, BasicPane pane) { |
||||
super(frame, pane, false); |
||||
setTitle(pane.getTitle()); |
||||
setSize(SIZE); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.plugin.event.manager.ui; |
||||
|
||||
import com.fr.design.gui.frpane.LoadingBasicPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public abstract class EventManagerPane<T> extends LoadingBasicPane { |
||||
protected EventConfigPane eventConfigPane; |
||||
private T target; |
||||
|
||||
@Override |
||||
protected void initComponents(JPanel container) { |
||||
initData(target); |
||||
} |
||||
|
||||
public void setTarget(T target) { |
||||
this.target = target; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "event manager"; |
||||
} |
||||
|
||||
protected abstract void initData(T target); |
||||
|
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.plugin.event.manager.ui; |
||||
|
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.main.Form; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public class FormEventManagerPane extends EventManagerPane<Form> { |
||||
|
||||
@Override |
||||
protected void initComponents(JPanel container) { |
||||
super.initComponents(container); |
||||
container.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
|
||||
eventConfigPane = new EventConfigPane(); |
||||
container.add(eventConfigPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
public void initData(Form target) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 当initComponents执行完后调用 |
||||
*/ |
||||
@Override |
||||
public void complete() { |
||||
// do nothing
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,138 @@
|
||||
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
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.plugin.event.manager.ui.tree; |
||||
|
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.designer.treeview.ComponentTreeCellRenderer; |
||||
import com.fr.design.gui.itree.UITreeUI; |
||||
import com.fr.plugin.event.manager.data.MyContainer; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JTree; |
||||
import javax.swing.tree.TreeSelectionModel; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/14/2020 |
||||
*/ |
||||
public class ContainerRootTree extends JTree { |
||||
private MyContainer container; |
||||
private ContainerTreeModel model; |
||||
private UITreeUI uiTreeUI = new UITreeUI(); |
||||
|
||||
private static final int PADDING_LEFT = 5; |
||||
private static final int PADDING_TOP = 5; |
||||
|
||||
public ContainerRootTree(MyContainer container) { |
||||
this.container = container; |
||||
model = new ContainerTreeModel(container); |
||||
setModel(model); |
||||
this.setBackground(UIConstants.TREE_BACKGROUND); |
||||
// 根不可见
|
||||
setRootVisible(false); |
||||
setCellRenderer(new ComponentTreeCellRenderer()); |
||||
getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||
this.setDragEnabled(false); |
||||
// initListeners();
|
||||
setEditable(false); |
||||
setUI(uiTreeUI); |
||||
setBorder(BorderFactory.createEmptyBorder(PADDING_TOP, PADDING_LEFT, 0, 0)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,60 @@
|
||||
package com.fr.plugin.event.manager.ui.tree; |
||||
|
||||
import com.fr.plugin.event.manager.data.MyContainer; |
||||
|
||||
import javax.swing.event.TreeModelListener; |
||||
import javax.swing.tree.TreeModel; |
||||
import javax.swing.tree.TreePath; |
||||
|
||||
/** |
||||
* @author Joe |
||||
* Created by Joe on 12/11/2020 |
||||
*/ |
||||
public class ContainerTreeModel implements TreeModel { |
||||
|
||||
private MyContainer root; |
||||
|
||||
public ContainerTreeModel(MyContainer root) { |
||||
this.root = root; |
||||
} |
||||
|
||||
@Override |
||||
public Object getRoot() { |
||||
return root; |
||||
} |
||||
|
||||
@Override |
||||
public Object getChild(Object parent, int index) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public int getChildCount(Object parent) { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isLeaf(Object node) { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void valueForPathChanged(TreePath path, Object newValue) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public int getIndexOfChild(Object parent, Object child) { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void addTreeModelListener(TreeModelListener l) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void removeTreeModelListener(TreeModelListener l) { |
||||
|
||||
} |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.fr.plugin.event.manager; |
||||
package com.fr.plugin.event.manager.utils; |
||||
|
||||
import com.fr.design.menu.MenuKeySet; |
||||
|
After Width: | Height: | Size: 352 B |
After Width: | Height: | Size: 682 B |
After Width: | Height: | Size: 999 B |
Loading…
Reference in new issue