From 7b0d7935a3ca93d292908ebd642cd970a5cebb7e Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 8 Jun 2016 10:58:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/report/VerifierListPane.java | 2 +- .../fr/design/ExtraDesignClassManager.java | 19 +++++++++++++++ .../fr/design/fun/VerifyDefineProvider.java | 24 +++++++++++++++++++ .../impl/AbstractVerifyDefineProvider.java | 20 ++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 designer_base/src/com/fr/design/fun/VerifyDefineProvider.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractVerifyDefineProvider.java diff --git a/designer/src/com/fr/design/report/VerifierListPane.java b/designer/src/com/fr/design/report/VerifierListPane.java index 38187d0a69..e489953244 100644 --- a/designer/src/com/fr/design/report/VerifierListPane.java +++ b/designer/src/com/fr/design/report/VerifierListPane.java @@ -1 +1 @@ -package com.fr.design.report; import com.fr.write.ReportWriteAttrProvider; import com.fr.write.ValueVerifierProvider; import com.fr.write.WClassVerifierProvider; import com.fr.general.NameObject; import com.fr.data.Verifier; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ObjectJControlPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.stable.Nameable; import com.fr.stable.bridge.StableFactory; import javax.swing.*; import java.awt.*; import java.util.*; /** * Author : Shockway * Date: 13-7-29 * Time: 下午5:11 */ public class VerifierListPane extends ObjectJControlPane { public VerifierListPane(ElementCasePane ePane) { super(ePane); } /** * 创建选项 * @return 选项 */ public NameableCreator[] createNameableCreators() { return new NameableCreator[] { new NameObjectCreator(Inter.getLocText(new String[]{"BuildIn", "Verify"}), "/com/fr/web/images/reportlet.png", // ValueVerifier.class, // ReportWriteAttr.class, StableFactory.getRegisteredClass(ReportWriteAttrProvider.XML_TAG), BuildInVerifierPane.class), new NameObjectCreator( Inter.getLocText(new String[]{"Custom", "Verify"}), "/com/fr/web/images/reportlet.png", // WClassVerifier.class, StableFactory.getRegisteredClass(WClassVerifierProvider.TAG), CustomVerifierPane.class) }; } @Override protected String title4PopupWindow() { return null; } public void populate(ReportWriteAttrProvider reportWriteAttr) { if (reportWriteAttr == null) { return; } java.util.List nameObjectList = new ArrayList(); int verifierCount = reportWriteAttr.getVerifierCount(); boolean addedVVObject = false; for (int i = 0; i < verifierCount; i++) { Verifier verifier = reportWriteAttr.getVerifier(i); String name = reportWriteAttr.getVerifierNameList(i); // 内置的校验ValueVerifier只要加在一个面板中 if (verifier instanceof ValueVerifierProvider) { if (!addedVVObject) { nameObjectList.add(new NameObject(name, reportWriteAttr)); addedVVObject = true; } } else { nameObjectList.add(new NameObject(name, verifier)); } } this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); } private static String valueVerifyName = Inter.getLocText("Verify-Data_Verify"); /** * 更新报表填报属性 * @param reportWriteAttr 报表填报属性 */ public void updateReportWriteAttr(ReportWriteAttrProvider reportWriteAttr) { JNameEdList nameEdList = VerifierListPane.this.nameableList; DefaultListModel model = (DefaultListModel) nameEdList.getModel(); for (int i=0; i { private ValueVerifierEditPane valueVerifierEditPane; public BuildInVerifierPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); valueVerifierEditPane = new ValueVerifierEditPane(); this.add(valueVerifierEditPane, BorderLayout.CENTER); } @Override public void populateBean(ReportWriteAttrProvider ob) { valueVerifierEditPane.populate(ob); } @Override public ReportWriteAttrProvider updateBean() { ReportWriteAttrProvider ra = StableFactory.getMarkedInstanceObjectFromClass(ReportWriteAttrProvider.XML_TAG, ReportWriteAttrProvider.class); valueVerifierEditPane.update(ra, VerifierListPane.valueVerifyName); return ra; } @Override protected String title4PopupWindow() { return null; } } public static class CustomVerifierPane extends BasicBeanPane { private CustomVerifyJobPane pane; public CustomVerifierPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); pane = new CustomVerifyJobPane(); this.add(pane, BorderLayout.CENTER); } @Override public void populateBean(WClassVerifierProvider ob) { this.pane.populateBean(ob.getClassVerifyJob()); } @Override public WClassVerifierProvider updateBean() { WClassVerifierProvider cs = StableFactory.getMarkedInstanceObjectFromClass(WClassVerifierProvider.TAG, WClassVerifierProvider.class); cs.setClassVerifyJob(this.pane.updateBean()); return cs; } @Override protected String title4PopupWindow() { return "custom"; } } private boolean isBuildInVerifier(Object obj) { return obj instanceof ReportWriteAttrProvider; } } \ No newline at end of file +package com.fr.design.report; import com.fr.data.Verifier; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.fun.VerifyDefineProvider; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ObjectJControlPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.bridge.StableFactory; import com.fr.write.ReportWriteAttrProvider; import com.fr.write.ValueVerifierProvider; import com.fr.write.WClassVerifierProvider; import javax.swing.*; import java.awt.*; import java.util.ArrayList; /** * Author : Shockway * Date: 13-7-29 * Time: 下午5:11 */ public class VerifierListPane extends ObjectJControlPane { public VerifierListPane(ElementCasePane ePane) { super(ePane); } /** * 创建选项 * * @return 选项 */ public NameableCreator[] createNameableCreators() { NameableCreator[] creators = new NameableCreator[]{ new NameObjectCreator(Inter.getLocText(new String[]{"BuildIn", "Verify"}), "/com/fr/web/images/reportlet.png", StableFactory.getRegisteredClass(ReportWriteAttrProvider.XML_TAG), BuildInVerifierPane.class) }; for (VerifyDefineProvider provider : ExtraDesignClassManager.getInstance().getVerifyDefineProviders()) { creators = ArrayUtils.add(creators, new NameObjectCreator( provider.nameForVerifier(), provider.iconPath(), provider.classForVerifier(), provider.appearanceForVerifier() ) { }); } creators = ArrayUtils.add(creators, new NameObjectCreator( Inter.getLocText(new String[]{"Custom", "Verify"}), "/com/fr/web/images/reportlet.png", StableFactory.getRegisteredClass(WClassVerifierProvider.TAG), CustomVerifierPane.class)); return creators; } @Override protected String title4PopupWindow() { return null; } public void populate(ReportWriteAttrProvider reportWriteAttr) { if (reportWriteAttr == null) { return; } java.util.List nameObjectList = new ArrayList(); int verifierCount = reportWriteAttr.getVerifierCount(); boolean addedVVObject = false; for (int i = 0; i < verifierCount; i++) { Verifier verifier = reportWriteAttr.getVerifier(i); String name = reportWriteAttr.getVerifierNameList(i); // 内置的校验ValueVerifier只要加在一个面板中 if (verifier instanceof ValueVerifierProvider) { if (!addedVVObject) { nameObjectList.add(new NameObject(name, reportWriteAttr)); addedVVObject = true; } } else { nameObjectList.add(new NameObject(name, verifier)); } } this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); } private static String valueVerifyName = Inter.getLocText("Verify-Data_Verify"); /** * 更新报表填报属性 * * @param reportWriteAttr 报表填报属性 */ public void updateReportWriteAttr(ReportWriteAttrProvider reportWriteAttr) { JNameEdList nameEdList = VerifierListPane.this.nameableList; DefaultListModel model = (DefaultListModel) nameEdList.getModel(); for (int i = 0; i < model.size(); i++) { NameObject no = (NameObject) ((ListModelElement) model.get(i)).wrapper; if (no.getObject() instanceof ReportWriteAttrProvider) { valueVerifyName = no.getName(); break; } } Nameable[] res = this.update(); NameObject[] res_array = new NameObject[res.length]; java.util.Arrays.asList(res).toArray(res_array); reportWriteAttr.clearVerifiers(); for (int i = 0; i < res_array.length; i++) { NameObject nameObject = res_array[i]; if (nameObject.getObject() instanceof Verifier) { reportWriteAttr.addVerifier(nameObject.getName(), (Verifier) nameObject.getObject()); } else if (nameObject.getObject() instanceof ReportWriteAttrProvider) { ReportWriteAttrProvider ra = (ReportWriteAttrProvider) nameObject.getObject(); for (int k = 0; k < ra.getValueVerifierCount(); k++) { reportWriteAttr.addVerifier(nameObject.getName(), ra.getVerifier(k)); } } } } /** * 添加 * * @param nameable 添加的Nameable * @param index 序号 */ public void addNameable(Nameable nameable, int index) { JNameEdList nameEdList = VerifierListPane.this.nameableList; DefaultListModel model = (DefaultListModel) nameEdList.getModel(); // 内置的数据校验大框架只加一个 if (((NameObject) nameable).getObject() instanceof ReportWriteAttrProvider) { setToolbarDefEnable(0, 0, false); for (int i = 0; i < model.size(); i++) { if (isBuildInVerifier(((NameObject) ((ListModelElement) model.get(i)).wrapper).getObject())) { nameableList.setSelectedIndex(i); } } } ListModelElement el = new ListModelElement(nameable); model.add(index, el); nameableList.setSelectedIndex(index); nameableList.ensureIndexIsVisible(index); nameEdList.repaint(); } /** * 检查btn的状态 */ public void checkButtonEnabled() { super.checkButtonEnabled(); if (!hasBuildInVerifier()) { setToolbarDefEnable(0, 0, true); } } private boolean hasBuildInVerifier() { JNameEdList nameEdList = VerifierListPane.this.nameableList; DefaultListModel model = (DefaultListModel) nameEdList.getModel(); for (int i = 0; i < model.size(); i++) { if (isBuildInVerifier(((NameObject) ((ListModelElement) model.get(i)).wrapper).getObject())) { return true; } } return false; } public static class BuildInVerifierPane extends BasicBeanPane { private ValueVerifierEditPane valueVerifierEditPane; public BuildInVerifierPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); valueVerifierEditPane = new ValueVerifierEditPane(); this.add(valueVerifierEditPane, BorderLayout.CENTER); } @Override public void populateBean(ReportWriteAttrProvider ob) { valueVerifierEditPane.populate(ob); } @Override public ReportWriteAttrProvider updateBean() { ReportWriteAttrProvider ra = StableFactory.getMarkedInstanceObjectFromClass(ReportWriteAttrProvider.XML_TAG, ReportWriteAttrProvider.class); valueVerifierEditPane.update(ra, VerifierListPane.valueVerifyName); return ra; } @Override protected String title4PopupWindow() { return null; } } public static class CustomVerifierPane extends BasicBeanPane { private CustomVerifyJobPane pane; public CustomVerifierPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); pane = new CustomVerifyJobPane(); this.add(pane, BorderLayout.CENTER); } @Override public void populateBean(WClassVerifierProvider ob) { this.pane.populateBean(ob.getClassVerifyJob()); } @Override public WClassVerifierProvider updateBean() { WClassVerifierProvider cs = StableFactory.getMarkedInstanceObjectFromClass(WClassVerifierProvider.TAG, WClassVerifierProvider.class); cs.setClassVerifyJob(this.pane.updateBean()); return cs; } @Override protected String title4PopupWindow() { return "custom"; } } private boolean isBuildInVerifier(Object obj) { return obj instanceof ReportWriteAttrProvider; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index d676381678..b0a6bb2a79 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -138,6 +138,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private Set backgroundUIProviders; + private Set verifyDefineProviders; + public TableDataPaneProcessor getTableDataPaneProcessor() { return tableDataPaneProcessor; } @@ -804,6 +806,21 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi backgroundUIProviders.add((BackgroundUIProvider) level); } + public VerifyDefineProvider[] getVerifyDefineProviders() { + if (verifyDefineProviders == null) { + return new VerifyDefineProvider[0]; + } + return verifyDefineProviders.toArray(new VerifyDefineProvider[verifyDefineProviders.size()]); + } + + private void addVerifyDefineProvider(Level level, PluginSimplify simplify) throws Exception { + if (verifyDefineProviders == null) { + verifyDefineProviders = new HashSet<>(); + } + validAPILevel(level, VerifyDefineProvider.CURRENT_LEVEL, simplify.getPluginName()); + verifyDefineProviders.add((VerifyDefineProvider) level); + } + /** * 文件名 * @@ -902,6 +919,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi addWidgetAttrProvider(impl, simplify); } else if (tagName.equals(ExportAttrTabProvider.XML_TAG)) { addExportAttrTabProvider(impl, simplify); + } else if (tagName.equals(VerifyDefineProvider.MARK_STRING)) { + addVerifyDefineProvider(impl, simplify); } } catch (PluginInvalidLevelException e) { PluginMessage.remindUpdate(e.getMessage()); diff --git a/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java b/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java new file mode 100644 index 0000000000..4d695db603 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java @@ -0,0 +1,24 @@ +package com.fr.design.fun; + +import com.fr.data.Verifier; +import com.fr.design.beans.BasicBeanPane; +import com.fr.stable.fun.Level; +import com.fr.stable.fun.Provider; + +/** + * Created by richie on 16/6/8. + */ +public interface VerifyDefineProvider extends Level, Provider { + + String MARK_STRING = "VerifyDefineProvider"; + + int CURRENT_LEVEL = 1; + + Class classForVerifier(); + + Class appearanceForVerifier(); + + String nameForVerifier(); + + String iconPath(); +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractVerifyDefineProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractVerifyDefineProvider.java new file mode 100644 index 0000000000..04c6276104 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractVerifyDefineProvider.java @@ -0,0 +1,20 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.VerifyDefineProvider; +import com.fr.stable.fun.impl.AbstractProvider; + +/** + * Created by richie on 16/6/8. + */ +public abstract class AbstractVerifyDefineProvider extends AbstractProvider implements VerifyDefineProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} From e9a3c2b1d362df67fce13ff56a32f8193c450705 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 8 Jun 2016 11:02:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/fun/VerifyDefineProvider.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java b/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java index 4d695db603..35384bf0a5 100644 --- a/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java +++ b/designer_base/src/com/fr/design/fun/VerifyDefineProvider.java @@ -14,11 +14,27 @@ public interface VerifyDefineProvider extends Level, Provider { int CURRENT_LEVEL = 1; + /** + * 对应的校验类 + * @return 校验类 + */ Class classForVerifier(); + /** + * 校验设置的界面 + * @return 界面 + */ Class appearanceForVerifier(); + /** + * 此种类型的校验的名字 + * @return 名字 + */ String nameForVerifier(); + /** + * 菜单图标 + * @return 图标路径 + */ String iconPath(); }