diff --git a/README.md b/README.md
index bac74d0..1f0c013 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
# demo-menu-handler
设计器菜单扩展\
-demo生效后,设计器的模板工具栏会增加一个叫demo的菜单项,点击会出现Demo Action的弹窗
\ No newline at end of file
+demo生效后,设计器的模板工具栏会增加一个叫demo的菜单项,点击会出现Demo Action的弹窗\
+增补IOFileAttrMark用例\
+在Demo Action中可以输入一个txt文本(当前不支持特殊符号)。\
+可以作为模板的额外属性跟模板一起保存\
+测试可以用两个模板配置不同的txt分别打开查看
\ No newline at end of file
diff --git a/plugin.xml b/plugin.xml
index 43dc88e..7dd0e6d 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -9,7 +9,10 @@
com.tptj.demo.hg.menu.handler
-
+
+
+
+
diff --git a/src/main/java/com/tptj/demo/hg/menu/handler/DemoAction.java b/src/main/java/com/tptj/demo/hg/menu/handler/DemoAction.java
index 7c31dff..571df87 100644
--- a/src/main/java/com/tptj/demo/hg/menu/handler/DemoAction.java
+++ b/src/main/java/com/tptj/demo/hg/menu/handler/DemoAction.java
@@ -1,12 +1,11 @@
package com.tptj.demo.hg.menu.handler;
+import com.fr.base.io.AttrMark;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.dialog.*;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
-import com.fr.intelli.record.Focus;
-import com.fr.record.analyzer.EnableMetrics;
import com.fr.report.fit.FitProvider;
import java.awt.*;
@@ -17,7 +16,7 @@ import java.awt.event.ActionEvent;
* @version 10.0
* Created by 秃破天际 on 2021-05-20
**/
-@EnableMetrics
+
public class DemoAction extends JTemplateAction {
private static final Dimension MEDIUM = new Dimension(430, 400);
public DemoAction(JTemplate template) {
@@ -27,7 +26,6 @@ public class DemoAction extends JTemplateAction {
}
@Override
- @Focus(id="com.tptj.demo.hg.menu.handler.v10",text = "MenuHandler")
public void actionPerformed(ActionEvent e) {
JTemplate jwb = getEditingComponent();
if ( null == jwb ) {
@@ -40,14 +38,16 @@ public class DemoAction extends JTemplateAction {
}else{
//不是cpt
}
- DemoPane pane = new DemoPane();
+ DemoPane pane = new DemoPane( (AttrMark) wbTpl );
UIDialog dialog = pane.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
//做某些操作 从 pane中读取相关的交互结果设置到当前的模板中一般是这样
+ pane.update();
jwb.fireTargetModified();
}
});
+ pane.populate();
dialog.setSize(MEDIUM);
dialog.setVisible(true);
}
diff --git a/src/main/java/com/tptj/demo/hg/menu/handler/DemoAttrMark.java b/src/main/java/com/tptj/demo/hg/menu/handler/DemoAttrMark.java
new file mode 100644
index 0000000..5b1e4ff
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/menu/handler/DemoAttrMark.java
@@ -0,0 +1,64 @@
+package com.tptj.demo.hg.menu.handler;
+
+import com.fr.intelli.record.Focus;
+import com.fr.json.JSONException;
+import com.fr.json.JSONObject;
+import com.fr.record.analyzer.EnableMetrics;
+import com.fr.stable.StringUtils;
+import com.fr.stable.fun.impl.AbstractIOFileAttrMark;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-05-20
+ **/
+@EnableMetrics
+public class DemoAttrMark extends AbstractIOFileAttrMark {
+
+ public final static String XML_TAG = "DemoAttrMark";
+
+ private String txt;
+
+ @Focus(id="com.tptj.demo.hg.menu.handler.v10",text = "MenuHandler")
+ public String getTxt() {
+ return txt;
+ }
+
+ public void setTxt(String txt) {
+ this.txt = txt;
+ }
+
+ @Override
+ public String xmlTag() {
+ return XML_TAG;
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ String tag = reader.getTagName();
+ if( XML_TAG.equals(tag) ){
+ txt = reader.getAttrAsString("txt", StringUtils.EMPTY);
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ writer.startTAG(XML_TAG).attr("txt",txt).end();
+ }
+
+ @Override
+ public DemoAttrMark clone() {
+ DemoAttrMark obj = (DemoAttrMark)super.clone();
+ obj.txt = txt;
+ return obj;
+ }
+
+ @Override
+ public JSONObject createJSONConfig() throws JSONException{
+ JSONObject json = super.createJSONConfig();
+ json.put("txt",txt);
+ return json;
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/menu/handler/DemoPane.java b/src/main/java/com/tptj/demo/hg/menu/handler/DemoPane.java
index 3015091..da523f7 100644
--- a/src/main/java/com/tptj/demo/hg/menu/handler/DemoPane.java
+++ b/src/main/java/com/tptj/demo/hg/menu/handler/DemoPane.java
@@ -1,6 +1,15 @@
package com.tptj.demo.hg.menu.handler;
+import com.fr.base.io.AttrMark;
import com.fr.design.dialog.BasicPane;
+import com.fr.design.gui.ilable.UILabel;
+import com.fr.design.gui.itextfield.UITextField;
+import com.fr.design.layout.FRGUIPaneFactory;
+import com.fr.design.layout.TableLayout;
+import com.fr.design.layout.TableLayoutHelper;
+
+import javax.swing.*;
+import java.awt.*;
/**
* @author 秃破天际
@@ -8,8 +17,37 @@ import com.fr.design.dialog.BasicPane;
* Created by 秃破天际 on 2021-05-20
**/
public class DemoPane extends BasicPane {
+ private UITextField w_txt;
+ private AttrMark container;
+ public DemoPane( AttrMark container ){
+ this.container = container;
+ w_txt = new UITextField();
+ setLayout(FRGUIPaneFactory.createM_BorderLayout());
+ JPanel pane = TableLayoutHelper.createTableLayoutPane(
+ new Component[][]{
+ {new UILabel("txt:"), w_txt}
+ },
+ new double[]{TableLayout.PREFERRED},
+ new double[]{ TableLayout.PREFERRED,TableLayout.FILL}
+ );
+ add( pane, BorderLayout.NORTH );
+ }
+
@Override
protected String title4PopupWindow() {
return "Demo Action";
}
+
+ public void populate(){
+ DemoAttrMark attr = container.getAttrMark(DemoAttrMark.XML_TAG);
+ if( null != attr ){
+ w_txt.setText( attr.getTxt() );
+ }
+ }
+
+ public void update(){
+ DemoAttrMark attr = new DemoAttrMark();
+ attr.setTxt( w_txt.getText() );
+ container.addAttrMark( attr );
+ }
}