Browse Source

INO-6972

master
Joe 4 years ago committed by Joe.Jiang
parent
commit
97a309491b
  1. 12
      src/main/java/com/fr/plugin/event/manager/core/FormEventManager.java
  2. 23
      src/main/java/com/fr/plugin/event/manager/data/MyWidget.java
  3. 90
      src/main/java/com/fr/plugin/event/manager/ui/FormEventManagerPane.java
  4. 5
      src/main/java/com/fr/plugin/event/manager/ui/WorkbookEventManagerPane.java
  5. 14
      src/main/resources/com/fr/plugin/event/manager/locale/main_ja_JP.properties
  6. 14
      src/main/resources/com/fr/plugin/event/manager/locale/main_zh.properties

12
src/main/java/com/fr/plugin/event/manager/core/FormEventManager.java

@ -6,6 +6,7 @@ import com.fr.design.actions.JTemplateAction;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.main.Form; import com.fr.form.main.Form;
@ -48,8 +49,8 @@ public class FormEventManager extends JTemplateAction<JForm> {
return; return;
} }
final Form form = jf.getTarget(); final FormDesigner designer = jf.getFormDesign();
final EventManagerPane eventManagerPane = initEventManagerPane(form); final EventManagerPane eventManagerPane = initEventManagerPane(designer);
UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane); UIDialog dialog = new EventManagerDialog(DesignerContext.getDesignerFrame(), eventManagerPane);
dialog.addWindowListener(new WindowAdapter() { dialog.addWindowListener(new WindowAdapter() {
@ -68,12 +69,13 @@ public class FormEventManager extends JTemplateAction<JForm> {
/** /**
* 初始化事件管理器面板 * 初始化事件管理器面板
* @param form 当前表单对象 * 这地方和workbook不一样传UI对象方便获取组件层级
* @param designer 当前表单对象
* @return * @return
*/ */
private EventManagerPane initEventManagerPane(Form form) { private EventManagerPane initEventManagerPane(FormDesigner designer) {
FormEventManagerPane eventManagerPane = new FormEventManagerPane(); FormEventManagerPane eventManagerPane = new FormEventManagerPane();
eventManagerPane.setTarget(form); eventManagerPane.setTarget(designer);
return eventManagerPane; return eventManagerPane;
} }
} }

23
src/main/java/com/fr/plugin/event/manager/data/MyWidget.java

@ -13,24 +13,29 @@ import javax.swing.Icon;
* Created by Joe on 12/14/2020 * Created by Joe on 12/14/2020
*/ */
public class MyWidget extends MyNode { public class MyWidget extends MyNode {
private Widget widget; private XCreator creator;
// 是否含有事件 // 是否含有事件
private boolean hasEvent = false; private boolean hasEvent = false;
public MyWidget(XCreator creator) {
this.creator = creator;
this.nodeName = creator.toData().getWidgetName();
this.icon = XCreatorUtils.getCreatorIcon(creator);
}
public MyWidget(Widget widget) { public MyWidget(Widget widget) {
this.widget = widget; creator = XCreatorUtils.createXCreator(widget);
this.nodeName = widget.getWidgetName(); this.nodeName = widget.getWidgetName();
XCreator creator = XCreatorUtils.createXCreator(widget);
this.icon = XCreatorUtils.getCreatorIcon(creator); this.icon = XCreatorUtils.getCreatorIcon(creator);
} }
public Widget getWidget() { public XCreator getCreator() {
return widget; return creator;
} }
public void setWidget(Widget widget) { public void setCreator(XCreator creator) {
this.widget = widget; this.creator = creator;
} }
public boolean isHasEvent() { public boolean isHasEvent() {
@ -40,4 +45,8 @@ public class MyWidget extends MyNode {
public void setHasEvent(boolean hasEvent) { public void setHasEvent(boolean hasEvent) {
this.hasEvent = hasEvent; this.hasEvent = hasEvent;
} }
public Widget getWidget() {
return creator.toData();
}
} }

90
src/main/java/com/fr/plugin/event/manager/ui/FormEventManagerPane.java

@ -1,27 +1,29 @@
package com.fr.plugin.event.manager.ui; package com.fr.plugin.event.manager.ui;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.main.Form; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
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.MyTree;
import com.fr.plugin.event.manager.data.MyWidget; import com.fr.plugin.event.manager.data.MyWidget;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
/** /**
* 决策报表下的事件管理器面板 * 决策报表下的事件管理器面板
* @author Joe * @author Joe
* Created by Joe on 12/11/2020 * Created by Joe on 12/11/2020
*/ */
public class FormEventManagerPane extends EventManagerPane<Form> { public class FormEventManagerPane extends EventManagerPane<FormDesigner> {
// 组件树 // 组件树
private MyTree tree; private MyTree tree;
private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1;
/** /**
* 先调用super.initComponents()执行initData() * 先调用super.initComponents()执行initData()
* 之后tree已经被初始化了 * 之后tree已经被初始化了
@ -32,16 +34,15 @@ public class FormEventManagerPane extends EventManagerPane<Form> {
protected void initComponents(JPanel container) { protected void initComponents(JPanel container) {
super.initComponents(container); super.initComponents(container);
container.setLayout(FRGUIPaneFactory.createBorderLayout()); container.setLayout(FRGUIPaneFactory.createBorderLayout());
eventConfigPane = new EventConfigPane(tree); eventConfigPane = new EventConfigPane(tree, true);
container.add(eventConfigPane, BorderLayout.CENTER); container.add(eventConfigPane, BorderLayout.CENTER);
} }
@Override @Override
public void initData(Form target) { public void initData(FormDesigner target) {
WLayout rootContainer = target.getContainer(); tree = new MyTree();
MyNode root = new MyWidget(rootContainer); Component root = target.getTopContainer();
tree = new MyTree(root); traversalComponent(root);
traversalWidget(rootContainer, tree);
filterWidget(tree); filterWidget(tree);
} }
@ -54,35 +55,35 @@ public class FormEventManagerPane extends EventManagerPane<Form> {
} }
/** /**
* 关键算法遍历添加节点进树 * 遍历生成组件树
* * @param root
* @param widget
* @param tree
*/ */
private void traversalWidget(Widget widget, MyTree tree) { private void traversalComponent(Component root) {
if (widget instanceof CRBoundsWidget) { if (root instanceof XLayoutContainer) {
traversalWidget(((CRBoundsWidget) widget).getWidget(), tree); tree.setData(new MyWidget((XLayoutContainer) root));
} else if (widget instanceof WLayout) { for (int i = 0; i < tree.getElementsIndex().size(); i++) {
// 容器型控件,可能存在子节点 MyTree myTree = tree.getElementsIndex().get(i);
MyNode node = new MyWidget(widget); XCreator myCreator = ((MyWidget) myTree.getData()).getCreator();
MyTree subTree = tree.addChild(node); if (!myCreator.isComponentTreeLeaf()) {
if (widget instanceof WCardLayout) { // 非叶子节点
int idx = ((WCardLayout) widget).getShowIndex(); XLayoutContainer xLayout = (XLayoutContainer) myCreator;
if (((WCardLayout) widget).getWidgetCount() > idx) { for (int j = 0; j < xLayout.getShowXCreatorCount(); j++) {
traversalWidget(((WCardLayout) widget).getWidget(idx), subTree); XCreator creator = xLayout.getXCreator(j);
} int absoluteBodyIndex = getAbsoluteBodyIndex(creator);
MyWidget myWidget;
// 绝对布局作为body的时候不显示自适应布局父层
if (absoluteBodyIndex > ABSOLUTE_AS_BODY_NOT_FOUND) {
myWidget = new MyWidget((XCreator) creator.getComponent(absoluteBodyIndex));
} else { } else {
for (int i = 0, count = ((WLayout) widget).getWidgetCount(); i < count; i++) { myWidget = new MyWidget(creator.getXCreator());
traversalWidget(((WLayout) widget).getWidget(i), subTree);
} }
} if (myWidget.getWidget().getListenerSize() > 0) {
} else {
// 普通widget
MyWidget myWidget = new MyWidget(widget);
if (widget.getListenerSize() > 0) {
myWidget.setHasEvent(true); myWidget.setHasEvent(true);
} }
tree.addChild(myWidget); myTree.addChild(myWidget);
}
}
}
} }
} }
@ -103,4 +104,19 @@ public class FormEventManagerPane extends EventManagerPane<Form> {
} }
} }
private int getAbsoluteBodyIndex(XCreator xCreator) {
//绝对布局作为body,父层是自适应布局,找到绝对布局位于父层的index
int index = ABSOLUTE_AS_BODY_NOT_FOUND;
if (xCreator.acceptType(XWFitLayout.class)) {
XWFitLayout bodyFitLayout = (XWFitLayout) xCreator;
for (int i = 0; i < bodyFitLayout.getXCreatorCount(); i++) {
//类型是绝对布局并且还是body
if (bodyFitLayout.getXCreator(i).acceptType(XWAbsoluteBodyLayout.class)) {
index = i;
}
}
}
return index;
}
} }

5
src/main/java/com/fr/plugin/event/manager/ui/WorkbookEventManagerPane.java

@ -193,7 +193,9 @@ public class WorkbookEventManagerPane extends EventManagerPane<TemplateWorkBook>
if (highlight.getHighlightAction(k) instanceof WidgetHighlightAction) { if (highlight.getHighlightAction(k) instanceof WidgetHighlightAction) {
// 获取条件属性控件 // 获取条件属性控件
WidgetHighlightAction highlightAction = (WidgetHighlightAction) highlight.getHighlightAction(k); WidgetHighlightAction highlightAction = (WidgetHighlightAction) highlight.getHighlightAction(k);
MyWidget highlightWidget = new MyWidget(highlightAction.getWidget()); Widget widget1 = highlightAction.getWidget();
if (widget1 != null && widget1.getListenerSize() > 0) {
MyWidget highlightWidget = new MyWidget(widget1);
// 条件属性控件的命名不同于单元格控件 // 条件属性控件的命名不同于单元格控件
highlightWidget.setNodeName(cell.toString() + "(" + highlight.getName() + ")"); highlightWidget.setNodeName(cell.toString() + "(" + highlight.getName() + ")");
highlightWidget.setHasEvent(true); highlightWidget.setHasEvent(true);
@ -205,6 +207,7 @@ public class WorkbookEventManagerPane extends EventManagerPane<TemplateWorkBook>
} }
} }
} }
}
return hasWidgetEvent; return hasWidgetEvent;
} }

14
src/main/resources/com/fr/plugin/event/manager/locale/main_ja_JP.properties

@ -1,7 +1,7 @@
Fine-Plugin_Event_Manager_Alert_No_Target=テンプレート対象を獲得できません Fine-Plugin_Event_Manager_Alert_No_Target=\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5BFE\u8C61\u3092\u7372\u5F97\u3067\u304D\u307E\u305B\u3093
Fine-Plugin_Event_Manager_Config_Left_Title=コンポーネントイベントリスト Fine-Plugin_Event_Manager_Config_Left_Title=\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u30A4\u30D9\u30F3\u30C8\u30EA\u30B9\u30C8
Fine-Plugin_Event_Manager_Config_Right_Tip=この対象はイベントを設定したことがありません Fine-Plugin_Event_Manager_Config_Right_Tip=\u3053\u306E\u5BFE\u8C61\u306F\u30A4\u30D9\u30F3\u30C8\u3092\u8A2D\u5B9A\u3057\u305F\u3053\u3068\u304C\u3042\u308A\u307E\u305B\u3093
Fine-Plugin_Event_Manager_Config_Title=イベント設定 Fine-Plugin_Event_Manager_Config_Title=\u30A4\u30D9\u30F3\u30C8\u8A2D\u5B9A
Fine-Plugin_Event_Manager_Tab_Cell=セルウィジェット Fine-Plugin_Event_Manager_Tab_Cell=\u30BB\u30EB\u30A6\u30A3\u30B8\u30A7\u30C3\u30C8
Fine-Plugin_Event_Manager_Tab_Para=パラメータウィジェット Fine-Plugin_Event_Manager_Tab_Para=\u30D1\u30E9\u30E1\u30FC\u30BF\u30A6\u30A3\u30B8\u30A7\u30C3\u30C8
Fine-Plugin_Event_Manager_Title=コンポーネントイベントリスト Fine-Plugin_Event_Manager_Title=\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u30A4\u30D9\u30F3\u30C8\u30EA\u30B9\u30C8

14
src/main/resources/com/fr/plugin/event/manager/locale/main_zh.properties

@ -1,7 +1,7 @@
Fine-Plugin_Event_Manager_Alert_No_Target=无法获取模板对象 Fine-Plugin_Event_Manager_Alert_No_Target=\u65E0\u6CD5\u83B7\u53D6\u6A21\u677F\u5BF9\u8C61
Fine-Plugin_Event_Manager_Config_Left_Title=具有事件的组件列表 Fine-Plugin_Event_Manager_Config_Left_Title=\u5177\u6709\u4E8B\u4EF6\u7684\u7EC4\u4EF6\u5217\u8868
Fine-Plugin_Event_Manager_Config_Right_Tip=该对象没有设置过事件 Fine-Plugin_Event_Manager_Config_Right_Tip=\u8BE5\u5BF9\u8C61\u6CA1\u6709\u8BBE\u7F6E\u8FC7\u4E8B\u4EF6
Fine-Plugin_Event_Manager_Config_Title=事件设置 Fine-Plugin_Event_Manager_Config_Title=\u4E8B\u4EF6\u8BBE\u7F6E
Fine-Plugin_Event_Manager_Tab_Cell=单元格控件 Fine-Plugin_Event_Manager_Tab_Cell=\u5355\u5143\u683C\u63A7\u4EF6
Fine-Plugin_Event_Manager_Tab_Para=参数控件 Fine-Plugin_Event_Manager_Tab_Para=\u53C2\u6570\u63A7\u4EF6
Fine-Plugin_Event_Manager_Title=组件事件管理器 Fine-Plugin_Event_Manager_Title=\u7EC4\u4EF6\u4E8B\u4EF6\u7BA1\u7406\u5668
Loading…
Cancel
Save