From 2080facd57f7be23822c7c07ce893f7f251b1f2c Mon Sep 17 00:00:00 2001
From: Joe <825510477@qq.com>
Date: Mon, 21 Dec 2020 09:49:55 +0800
Subject: [PATCH] Event manager update stash
---
plugin.xml | 2 +-
.../event/manager/core/EventManager.java | 69 -------------
.../event/manager/core/FormEventManager.java | 65 ++++++++++---
.../manager/core/WorkbookEventManager.java | 63 ++++++++++--
.../event/manager/data/MyCellWidget.java | 1 -
.../fr/plugin/event/manager/data/MyNode.java | 7 +-
.../fr/plugin/event/manager/data/MyTree.java | 27 ++++--
.../plugin/event/manager/data/MyWidget.java | 7 +-
.../event/manager/ui/CellWidgetPane.java | 19 ++++
.../event/manager/ui/EventConfigPane.java | 4 +-
.../event/manager/ui/EventManagerPane.java | 1 +
.../manager/ui/FormEventManagerPane.java | 7 +-
.../manager/ui/WorkbookEventManagerPane.java | 96 +++++++++++--------
.../ui/tree/MyComponentCellRenderer.java | 5 +-
.../manager/ui/tree/MyComponentTree.java | 28 +++++-
15 files changed, 241 insertions(+), 160 deletions(-)
delete mode 100644 src/main/java/com/fr/plugin/event/manager/core/EventManager.java
diff --git a/plugin.xml b/plugin.xml
index d630479..7f2dce3 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -14,5 +14,5 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/event/manager/core/EventManager.java b/src/main/java/com/fr/plugin/event/manager/core/EventManager.java
deleted file mode 100644
index a5f7fb7..0000000
--- a/src/main/java/com/fr/plugin/event/manager/core/EventManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.fr.plugin.event.manager.core;
-
-import com.fr.base.BaseUtils;
-import com.fr.design.DesignModelAdapter;
-import com.fr.design.actions.JTemplateAction;
-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.design.mainframe.WidgetPropertyPane;
-import com.fr.form.main.Form;
-import com.fr.plugin.event.manager.ui.EventManagerDialog;
-import com.fr.plugin.event.manager.ui.EventManagerPane;
-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;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-/**
- * @author Joe
- * Created by Joe on 12/11/2020
- */
-@FunctionRecorder
-public abstract class EventManager extends JTemplateAction> {
-
- 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();
- final EventManagerPane eventManagerPane = initEventManager(target);
- UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane);
-
- dialog.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosed(WindowEvent e) {
- eventManagerPane.update();
- // 刷新一下右侧面板,避免事件显示不同步
- if (target instanceof Form) {
- WidgetPropertyPane.getInstance().refreshDockingView();
- }
- // 触发正在编辑的模板改变事件
- DesignModelAdapter.getCurrentModelAdapter().fireTargetModified();
- super.windowClosed(e);
- }
- });
- dialog.setVisible(true);
- }
-
- protected abstract EventManagerPane initEventManager(Object target);
-}
diff --git a/src/main/java/com/fr/plugin/event/manager/core/FormEventManager.java b/src/main/java/com/fr/plugin/event/manager/core/FormEventManager.java
index 6d1610d..1169dfe 100644
--- a/src/main/java/com/fr/plugin/event/manager/core/FormEventManager.java
+++ b/src/main/java/com/fr/plugin/event/manager/core/FormEventManager.java
@@ -1,32 +1,75 @@
package com.fr.plugin.event.manager.core;
-import com.fr.design.dialog.BasicPane;
-import com.fr.design.mainframe.JTemplate;
+import com.fr.base.BaseUtils;
+import com.fr.design.DesignModelAdapter;
+import com.fr.design.actions.JTemplateAction;
+import com.fr.design.dialog.FineJOptionPane;
+import com.fr.design.dialog.UIDialog;
+import com.fr.design.mainframe.DesignerContext;
+import com.fr.design.mainframe.JForm;
+import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.main.Form;
+import com.fr.plugin.event.manager.ui.EventManagerDialog;
import com.fr.plugin.event.manager.ui.EventManagerPane;
import com.fr.plugin.event.manager.ui.FormEventManagerPane;
+import com.fr.plugin.event.manager.utils.KeySetUtils;
+import com.fr.plugin.transform.ExecuteFunctionRecord;
+
+import javax.swing.JOptionPane;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
/**
* @author Joe
* Created by Joe on 9/3/2020
*/
-public class FormEventManager extends EventManager {
+public class FormEventManager extends JTemplateAction {
- public FormEventManager(JTemplate, ?> jTemplate) {
- super(jTemplate);
+ public FormEventManager(JForm form) {
+ super(form);
+ 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) {
+ JForm jf = getEditingComponent();
+ if (jf == null) {
+ FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "无法获取模板对象!",
+ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ final Form form = jf.getTarget();
+ final EventManagerPane eventManagerPane = initEventManager(form);
+ UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane);
+
+ dialog.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosed(WindowEvent e) {
+ eventManagerPane.update();
+ // 触发正在编辑的模板改变事件
+ DesignModelAdapter.getCurrentModelAdapter().fireTargetModified();
+ // 刷新一下右侧面板,避免事件显示不同步
+ WidgetPropertyPane.getInstance().refreshDockingView();
+ super.windowClosed(e);
+ }
+ });
+ dialog.setVisible(true);
}
/**
- * @param target
+ * @param form
* @return
*/
- @Override
- protected EventManagerPane initEventManager(Object target) {
+ private EventManagerPane initEventManager(Form form) {
FormEventManagerPane eventManagerPane = new FormEventManagerPane();
- if (target instanceof Form) {
- eventManagerPane.setTarget((Form) target);
- }
+ eventManagerPane.setTarget(form);
return eventManagerPane;
}
}
diff --git a/src/main/java/com/fr/plugin/event/manager/core/WorkbookEventManager.java b/src/main/java/com/fr/plugin/event/manager/core/WorkbookEventManager.java
index e29793e..4cb44f4 100644
--- a/src/main/java/com/fr/plugin/event/manager/core/WorkbookEventManager.java
+++ b/src/main/java/com/fr/plugin/event/manager/core/WorkbookEventManager.java
@@ -1,33 +1,76 @@
package com.fr.plugin.event.manager.core;
-import com.fr.design.mainframe.JTemplate;
+import com.fr.base.BaseUtils;
+import com.fr.design.DesignModelAdapter;
+import com.fr.design.actions.JWorkBookAction;
+import com.fr.design.dialog.FineJOptionPane;
+import com.fr.design.dialog.UIDialog;
+import com.fr.design.mainframe.DesignerContext;
+import com.fr.design.mainframe.JWorkBook;
import com.fr.main.TemplateWorkBook;
+import com.fr.plugin.event.manager.ui.EventManagerDialog;
import com.fr.plugin.event.manager.ui.EventManagerPane;
import com.fr.plugin.event.manager.ui.WorkbookEventManagerPane;
+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;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
/**
* @author Joe
* Created by Joe on 9/3/2020
*/
-public class WorkbookEventManager extends EventManager {
+@FunctionRecorder
+public class WorkbookEventManager extends JWorkBookAction {
- public WorkbookEventManager(JTemplate, ?> jTemplate) {
- super(jTemplate);
+ 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/plugin/event/manager/images/icon_event_manager.png"));
+ }
+
+ @Override
+ @ExecuteFunctionRecord
+ public void actionPerformed(ActionEvent e) {
+ JWorkBook jwb = getEditingComponent();
+ if (jwb == null) {
+ FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "无法获取模板对象!",
+ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ final TemplateWorkBook workBook = jwb.getTarget();
+ final EventManagerPane eventManagerPane = initEventManager(workBook);
+ UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane);
+
+ dialog.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosed(WindowEvent e) {
+ eventManagerPane.update();
+ // 触发正在编辑的模板改变事件
+ DesignModelAdapter.getCurrentModelAdapter().fireTargetModified();
+ super.windowClosed(e);
+ }
+ });
+ dialog.setVisible(true);
}
/**
* workbook返回tabPane
*
- * @param target
+ * @param workBook
* @return
*/
- @Override
- protected EventManagerPane initEventManager(Object target) {
+ private EventManagerPane initEventManager(TemplateWorkBook workBook) {
WorkbookEventManagerPane eventManagerPane = new WorkbookEventManagerPane();
- if (target instanceof TemplateWorkBook) {
- eventManagerPane.setTarget((TemplateWorkBook) target);
- }
+ eventManagerPane.setTarget(workBook);
return eventManagerPane;
}
diff --git a/src/main/java/com/fr/plugin/event/manager/data/MyCellWidget.java b/src/main/java/com/fr/plugin/event/manager/data/MyCellWidget.java
index 7ba7fad..fdd1b93 100644
--- a/src/main/java/com/fr/plugin/event/manager/data/MyCellWidget.java
+++ b/src/main/java/com/fr/plugin/event/manager/data/MyCellWidget.java
@@ -11,7 +11,6 @@ import javax.swing.Icon;
*/
public class MyCellWidget extends MyWidget {
private CellElement cellElement;
- private Widget widget;
// 来自普通还是条件属性
private WidgetSource source;
diff --git a/src/main/java/com/fr/plugin/event/manager/data/MyNode.java b/src/main/java/com/fr/plugin/event/manager/data/MyNode.java
index e1aee52..c201c6d 100644
--- a/src/main/java/com/fr/plugin/event/manager/data/MyNode.java
+++ b/src/main/java/com/fr/plugin/event/manager/data/MyNode.java
@@ -8,6 +8,7 @@ import javax.swing.Icon;
*/
public class MyNode {
protected String nodeName;
+ protected Icon icon;
public MyNode() {
@@ -26,6 +27,10 @@ public class MyNode {
}
public Icon getIcon() {
- return null;
+ return icon;
+ }
+
+ public void setIcon(Icon icon) {
+ this.icon = icon;
}
}
diff --git a/src/main/java/com/fr/plugin/event/manager/data/MyTree.java b/src/main/java/com/fr/plugin/event/manager/data/MyTree.java
index ac0ad60..89c1102 100644
--- a/src/main/java/com/fr/plugin/event/manager/data/MyTree.java
+++ b/src/main/java/com/fr/plugin/event/manager/data/MyTree.java
@@ -28,7 +28,9 @@ public class MyTree {
*/
private List elementsIndex;
- private boolean visible;
+ public MyTree() {
+ this(new MyNode());
+ }
/**
* 构造函数
@@ -40,15 +42,14 @@ public class MyTree {
this.children = new LinkedList<>();
this.elementsIndex = new LinkedList<>();
this.elementsIndex.add(this);
- this.visible = true;
}
public MyNode getData() {
return data;
}
- public void setVisible(boolean visible) {
- this.visible = visible;
+ public void setData(MyNode data) {
+ this.data = data;
}
public List getChildren() {
@@ -80,18 +81,24 @@ public class MyTree {
/**
* 添加一个子节点
*
- * @param child
- * @return
+ * @param child 子树
+ */
+ public void addChild(MyTree child) {
+ child.parent = this;
+ this.children.add(child);
+ this.registerChildForSearch(child);
+ }
+
+ /**
+ * 添加一个子节点
+ * @param child 子树的数据
+ * @return 子树
*/
public MyTree addChild(MyNode child) {
MyTree childNode = new MyTree(child);
-
childNode.parent = this;
-
this.children.add(childNode);
-
this.registerChildForSearch(childNode);
-
return childNode;
}
diff --git a/src/main/java/com/fr/plugin/event/manager/data/MyWidget.java b/src/main/java/com/fr/plugin/event/manager/data/MyWidget.java
index d2d5ead..7df01d5 100644
--- a/src/main/java/com/fr/plugin/event/manager/data/MyWidget.java
+++ b/src/main/java/com/fr/plugin/event/manager/data/MyWidget.java
@@ -16,6 +16,8 @@ public class MyWidget extends MyNode {
public MyWidget(Widget widget) {
this.widget = widget;
this.nodeName = widget.getWidgetName();
+ XCreator creator = XCreatorUtils.createXCreator(widget);
+ this.icon = XCreatorUtils.getCreatorIcon(creator);
}
public Widget getWidget() {
@@ -25,9 +27,4 @@ public class MyWidget extends MyNode {
public void setWidget(Widget widget) {
this.widget = widget;
}
-
- public Icon getIcon() {
- XCreator creator = XCreatorUtils.createXCreator(widget);
- return XCreatorUtils.getCreatorIcon(creator);
- }
}
diff --git a/src/main/java/com/fr/plugin/event/manager/ui/CellWidgetPane.java b/src/main/java/com/fr/plugin/event/manager/ui/CellWidgetPane.java
index 703dab3..6a0bf2e 100644
--- a/src/main/java/com/fr/plugin/event/manager/ui/CellWidgetPane.java
+++ b/src/main/java/com/fr/plugin/event/manager/ui/CellWidgetPane.java
@@ -1,8 +1,10 @@
package com.fr.plugin.event.manager.ui;
import com.fr.design.dialog.BasicPane;
+import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.plugin.event.manager.data.MyTree;
+import java.awt.BorderLayout;
import java.util.List;
/**
@@ -11,9 +13,26 @@ import java.util.List;
*/
public class CellWidgetPane extends BasicPane {
private List cellWidgetTrees;
+ private EventConfigPane eventConfigPane;
public CellWidgetPane(List cellWidgetTrees) {
this.cellWidgetTrees = cellWidgetTrees;
+ initComponentPane();
+ }
+
+ private void initComponentPane() {
+ this.setLayout(FRGUIPaneFactory.createBorderLayout());
+ initEventConfigPane();
+ this.add(eventConfigPane, BorderLayout.CENTER);
+ }
+
+ private void initEventConfigPane() {
+ // 初始化事件面板
+ if (cellWidgetTrees.size() > 0) {
+ eventConfigPane = new EventConfigPane(cellWidgetTrees.get(0));
+ } else {
+ eventConfigPane = new EventConfigPane(new MyTree());
+ }
}
public String tabTitle() {
diff --git a/src/main/java/com/fr/plugin/event/manager/ui/EventConfigPane.java b/src/main/java/com/fr/plugin/event/manager/ui/EventConfigPane.java
index 852e3e2..7366742 100644
--- a/src/main/java/com/fr/plugin/event/manager/ui/EventConfigPane.java
+++ b/src/main/java/com/fr/plugin/event/manager/ui/EventConfigPane.java
@@ -45,7 +45,7 @@ public class EventConfigPane extends BasicPane implements TreeSelectionListener
public EventConfigPane(MyTree tree, boolean rootVisible) {
this.tree = tree;
this.rootVisible = rootVisible;
- this.initComponentPane();
+ initComponentPane();
}
public MyTree getTree() {
@@ -102,7 +102,7 @@ public class EventConfigPane extends BasicPane implements TreeSelectionListener
leftPane.add(leftContentPane, BorderLayout.CENTER);
// 左上方 items with event
JPanel leftTopPane = getLeftTopPane();
- leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 6, 6, 0));
+ leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
leftPane.add(leftTopPane, BorderLayout.NORTH);
return leftPane;
}
diff --git a/src/main/java/com/fr/plugin/event/manager/ui/EventManagerPane.java b/src/main/java/com/fr/plugin/event/manager/ui/EventManagerPane.java
index 1222e8c..bd28751 100644
--- a/src/main/java/com/fr/plugin/event/manager/ui/EventManagerPane.java
+++ b/src/main/java/com/fr/plugin/event/manager/ui/EventManagerPane.java
@@ -5,6 +5,7 @@ import com.fr.design.gui.frpane.LoadingBasicPane;
import javax.swing.JPanel;
/**
+ * 普通报表和表单事件管理器的父类
* @author Joe
* Created by Joe on 12/11/2020
*/
diff --git a/src/main/java/com/fr/plugin/event/manager/ui/FormEventManagerPane.java b/src/main/java/com/fr/plugin/event/manager/ui/FormEventManagerPane.java
index c47e8fd..78e6e12 100644
--- a/src/main/java/com/fr/plugin/event/manager/ui/FormEventManagerPane.java
+++ b/src/main/java/com/fr/plugin/event/manager/ui/FormEventManagerPane.java
@@ -3,9 +3,9 @@ package com.fr.plugin.event.manager.ui;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget;
-import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WLayout;
+import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.plugin.event.manager.data.MyNode;
import com.fr.plugin.event.manager.data.MyTree;
import com.fr.plugin.event.manager.data.MyWidget;
@@ -26,7 +26,6 @@ public class FormEventManagerPane extends EventManagerPane