From 0ecd214c014ba5532628510c3993f2f4dff69b75 Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 9 Dec 2020 21:17:44 +0800 Subject: [PATCH 01/51] =?UTF-8?q?REPORT-44714=20=E3=80=9010.0.12=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AE=B0=E5=BD=95=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=B1=E6=95=88=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E5=AE=9E=E9=99=85=E4=B8=8A?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=96=87=E4=BB=B6=E7=9A=84=E5=AD=98=E5=8F=96?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=AD=A4=E5=89=8D=E7=BC=93=E5=AD=98=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E8=AE=B0=E5=BD=95=E7=9A=84=E6=98=AF=E4=B8=8A?= =?UTF-8?q?=E5=AD=90=E9=9D=A2=E6=9D=BF=E7=9A=84=E9=AB=98=E5=BA=A6=E5=80=BC?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E5=9C=A8=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=BF=87=E7=A8=8B=E4=B8=AD=EF=BC=8C=E7=88=B6?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E7=9A=84=E9=AB=98=E5=BA=A6=E4=BC=9A=E5=8F=98?= =?UTF-8?q?=E5=8C=96(=E4=B8=94=E6=9C=89=E6=97=B6=E5=80=99=E5=8F=98?= =?UTF-8?q?=E4=B8=BA=E8=B4=9F=E6=95=B0)=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E4=BA=86=E5=85=B3=E9=97=AD=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=89=8D?= =?UTF-8?q?=EF=BC=8C=E4=B8=8A=E5=AD=90=E9=9D=A2=E6=9D=BF=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E4=BA=8E=E7=88=B6=E5=AE=B9=E5=99=A8=E9=AB=98=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E4=B8=8E=E6=89=93=E5=BC=80=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=B9=8B=E5=90=8E=E7=9A=84=E6=AF=94=E4=BE=8B=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=EF=BC=8C=E8=A7=86=E8=A7=89=E4=B8=8A=E5=B0=B1=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E4=BA=86=E9=9D=A2=E6=9D=BF=E9=AB=98=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E5=81=8F=E5=B7=AE=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D?= =?UTF-8?q?=E8=B7=AF=E3=80=91=E5=B0=86=E4=B9=8B=E5=89=8D=E7=9A=84=E6=80=9D?= =?UTF-8?q?=E8=B7=AF=E4=BF=AE=E6=94=B9=E4=B8=BA=EF=BC=8C=E5=9C=A8=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E9=AB=98=E5=BA=A6=E5=8F=91=E7=94=9F=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=A0=B9=E6=8D=AE=E4=B8=8A=E5=AD=90=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=8D=A0=E5=AE=B9=E5=99=A8=E9=AB=98=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E5=8E=BB=E8=B0=83=E6=95=B4=E4=B8=8A=E5=AD=90?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=9A=84=E9=AB=98=E5=BA=A6=EF=BC=8C=E4=B8=94?= =?UTF-8?q?=E5=B0=86=E7=BC=93=E5=AD=98=E6=96=87=E4=BB=B6=E4=B8=AD=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E4=B8=8A=E5=AD=90=E9=9D=A2=E6=9D=BF=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=AD=98=E5=82=A8=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 27 ++++++------- .../gui/icontainer/UIResizableContainer.java | 38 +++++++++++++------ .../fr/design/mainframe/DesignerFrame.java | 4 +- .../mainframe/WestRegionContainerPane.java | 16 ++++---- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index c6488d330..8d7c53645 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -141,8 +141,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private int eastRegionToolPaneY = 300; private int eastRegionContainerWidth = 260; - private int westRegionToolPaneY = 300; private int westRegionContainerWidth = 240; + private double westRegionToolPaneYRate = 0.5; private String encryptionKey; private String jdkHome; @@ -440,14 +440,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.lastOpenFilePath = lastOpenFilePath; } - /** - * 得到西面板的上下子面板的高度区分 - * + * 获取东面板的上子面板的高度占容器总高度的比例 * @return */ - public int getLastWestRegionToolPaneY() { - return this.westRegionToolPaneY; + public double getLastWestRegionToolPaneYRate() { + return westRegionToolPaneYRate; } /** @@ -460,12 +458,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 设置西面板的上下子面板的高度区分 - * - * @param toolPaneY + * 设置关闭设计器前,东面板的上子面板的高度占容器总高度的比例 + * @param westRegionToolPaneYRate */ - public void setLastWestRegionToolPaneY(int toolPaneY) { - this.westRegionToolPaneY = toolPaneY; + public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) { + this.westRegionToolPaneYRate = westRegionToolPaneYRate; } /** @@ -1610,8 +1607,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void readLastWestRegionLayout(XMLableReader reader) { String tmpVal; - if ((tmpVal = reader.getAttrAsString("toolPaneY", null)) != null) { - this.setLastWestRegionToolPaneY(Integer.parseInt(tmpVal)); + if ((tmpVal = reader.getAttrAsString("toolPaneYRate", null)) != null) { + this.setLastWestRegionToolPaneYRate(Double.parseDouble(tmpVal)); } if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) { this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal)); @@ -1934,8 +1931,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void writeLastWestRegionLayout(XMLPrintWriter writer) { writer.startTAG("LastWestRegionLayout"); - if (this.getLastWestRegionToolPaneY() >= 0) { - writer.attr("toolPaneY ", this.getLastWestRegionToolPaneY()); + if (this.getLastWestRegionToolPaneYRate() >= 0) { + writer.attr("toolPaneYRate", this.getLastWestRegionToolPaneYRate()); } if (this.getLastWestRegionContainerWidth() >= 0) { writer.attr("containerWidth", this.getLastWestRegionContainerWidth()); diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index 4f4ac9e3b..cc1067eb7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -1,12 +1,10 @@ package com.fr.design.gui.icontainer; -import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.stable.collections.utils.MathUtils; import javax.swing.*; import java.awt.*; @@ -46,6 +44,7 @@ public class UIResizableContainer extends JPanel { private boolean isDownPaneVisible = true ; private int paraHeight; private int parentHeight = -1; + private double toolPaneYRate; public UIResizableContainer(int direction) { this(new JPanel(), new JPanel(), direction); @@ -159,12 +158,19 @@ public class UIResizableContainer extends JPanel { } /** - * 设置关闭设计器前最后一次上下子面板的高度 - * - * @param toolPaneY + * 获取上子面板高度占容器总高度的比例 + * @return + */ + public double getToolPaneYRate() { + return toolPaneYRate; + } + + /** + * 设置关闭设计器前最新的上子面板的高度比例 + * @param toolPaneYRate */ - public void setLastToolPaneY(int toolPaneY) { - this.toolPaneY = toolPaneY; + public void setLastToolPaneYRate(double toolPaneYRate) { + this.toolPaneYRate = toolPaneYRate; } /** @@ -242,12 +248,12 @@ public class UIResizableContainer extends JPanel { if (parentHeight == -1) { // 初始化下parentheight,存一下当前的父容器height parentHeight = parent.getHeight(); - } else if (parentHeight != parent.getHeight()) { - // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi了,此时调整toolPaneY - toolPaneY = toolPaneY * parent.getHeight() / parentHeight; - toolPaneY = Math.min(toolPaneY, (parent.getHeight() - toolPaneHeight)); + } else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) { + // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY + toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); parentHeight = parent.getHeight(); } + System.out.println("toolPaneY:" + toolPaneY + ", rate:" + toolPaneYRate); } @Override @@ -371,6 +377,7 @@ public class UIResizableContainer extends JPanel { toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); + adjustToolPaneYRate(); refreshContainer(); } }); @@ -392,8 +399,10 @@ public class UIResizableContainer extends JPanel { public void mouseClicked(MouseEvent e) { if (e.getX() <= ARROW_RANGE) { toolPaneY = 0; + UIResizableContainer.this.adjustToolPaneYRate(); } else if (e.getX() >= getWidth() - ARROW_RANGE) { toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); + UIResizableContainer.this.adjustToolPaneYRate(); } else { return; } @@ -554,4 +563,11 @@ public class UIResizableContainer extends JPanel { jf.setSize(500, 500); jf.setVisible(true); } + + /** + * 当toolPaneY发生变化时,也需要调整toolPaneYRate + */ + private void adjustToolPaneYRate() { + this.toolPaneYRate = ((double) toolPaneY) / this.getHeight(); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 490b4e7e9..a5eafa0c0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -1170,8 +1170,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } - DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( - WestRegionContainerPane.getInstance().getToolPaneY()); + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneYRate( + WestRegionContainerPane.getInstance().getToolPaneYRate()); DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( WestRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 23c642dbd..358fba411 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -24,7 +24,7 @@ public class WestRegionContainerPane extends UIResizableContainer { public static final WestRegionContainerPane getInstance() { if (THIS == null) { THIS = new WestRegionContainerPane(); - THIS.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); + THIS.setLastToolPaneYRate(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneYRate()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); } return THIS; @@ -32,11 +32,11 @@ public class WestRegionContainerPane extends UIResizableContainer { public WestRegionContainerPane() { super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT); - + setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); - + GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { - + @Override public void on(PluginEvent event) { @@ -47,15 +47,15 @@ public class WestRegionContainerPane extends UIResizableContainer { } } }, new PluginFilter() { - + @Override public boolean accept(PluginContext context) { - + return context.contain(PluginModule.ExtraDesign); } }); - + setContainerWidth(165); setBackground(UIConstants.TREE_BACKGROUND); } -} \ No newline at end of file +} From e575d3a4ef9eb28b0b938a1777b72db774b8e0f3 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 10 Dec 2020 09:00:43 +0800 Subject: [PATCH 02/51] =?UTF-8?q?REPORT-44714=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/gui/icontainer/UIResizableContainer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index cc1067eb7..b48950485 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -253,7 +253,6 @@ public class UIResizableContainer extends JPanel { toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); parentHeight = parent.getHeight(); } - System.out.println("toolPaneY:" + toolPaneY + ", rate:" + toolPaneYRate); } @Override From 51289b43fafb456cc498ca4dd74624511fcb5ce7 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 10 Dec 2020 09:06:42 +0800 Subject: [PATCH 03/51] =?UTF-8?q?REPORT-44714=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/DesignerEnvManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 8d7c53645..44c0eba84 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -441,7 +441,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 获取东面板的上子面板的高度占容器总高度的比例 + * 获取西面板的上子面板的高度占容器总高度的比例 * @return */ public double getLastWestRegionToolPaneYRate() { @@ -458,7 +458,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 设置关闭设计器前,东面板的上子面板的高度占容器总高度的比例 + * 设置关闭设计器前,西面板的上子面板的高度占容器总高度的比例 * @param westRegionToolPaneYRate */ public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) { From 9b71b1241e286783ef08517f345a01bcfeda9392 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 10 Dec 2020 13:08:15 +0800 Subject: [PATCH 04/51] =?UTF-8?q?REPORT-44961=20=E3=80=9010.0.12=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E9=99=84=E4=BB=B6=E6=A8=A1=E6=9D=BF=E6=89=93?= =?UTF-8?q?=E5=BC=80=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=8D=A1=E6=AD=BB=EF=BC=8C?= =?UTF-8?q?=E4=B8=94=E5=B8=83=E5=B1=80=E5=8F=91=E7=94=9F=E5=8F=98=E5=8C=96?= =?UTF-8?q?=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91?= =?UTF-8?q?=E5=B8=A6=E6=9C=89=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=8E=A7=E4=BB=B6=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E7=9A=84=E6=97=B6=E5=80=99=E4=BC=9A=E5=8E=BB?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E8=8E=B7=E5=8F=96=E5=AD=97=E6=AE=B5=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E5=BD=93=E7=B3=BB=E7=BB=9F=E4=B8=AD=E6=9C=89?= =?UTF-8?q?=E5=90=8C=E5=90=8D=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E4=BD=86?= =?UTF-8?q?=E6=98=AF=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5=E5=88=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=8F=91=E7=94=9F=E5=81=87=E6=AD=BB=E3=80=82=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=BF=99=E4=B8=AA=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=9A=84=E5=90=8D=E5=AD=97=EF=BC=8C=E9=82=A3=E4=B9=88?= =?UTF-8?q?=E4=BC=9A=E7=9B=B4=E6=8E=A5=E6=8A=A5=E9=94=99=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E5=81=87=E6=AD=BB=E3=80=82=E4=B8=BB=E8=A6=81=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E8=BF=99=E4=B8=AA=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E7=9A=84=E6=93=8D=E4=BD=9C=E6=98=AF?= =?UTF-8?q?=E8=80=97=E6=97=B6=E6=93=8D=E4=BD=9C=EF=BC=8C=E4=B8=8D=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E5=9C=A8UI=E7=BA=BF=E7=A8=8B=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=80=97=E6=97=B6=E6=93=8D=E4=BD=9C=E3=80=82=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=96=B9=E6=A1=88=E3=80=91=E4=B8=BB=E8=A6=81?= =?UTF-8?q?=E5=88=86=E4=B8=BA=E4=B8=A4=E9=83=A8=E5=88=86=EF=BC=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=98=AF=E5=B0=86=E5=8E=9F=E6=9C=AC=E7=9A=84tdChange(?= =?UTF-8?q?)=E6=96=B9=E6=B3=95=E4=B8=AD=E7=9A=84=E8=80=97=E6=97=B6?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=94=BE=E5=88=B0SwingWorker=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E4=BD=9C=E7=BA=BF=E7=A8=8B=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E8=BF=99=E6=A0=B7=E7=9A=84=E8=AF=9D=E5=8D=B3=E4=BD=BF=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E4=B9=9F=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E9=98=BB=E5=A1=9E=E7=9B=B4=E5=88=B0=E9=87=8D?= =?UTF-8?q?=E8=BF=9E=E8=B6=85=E6=97=B6=EF=BC=9B=E7=AC=AC=E4=BA=8C=E6=98=AF?= =?UTF-8?q?=E5=BA=94=E4=BA=A7=E5=93=81=E7=9A=84=E8=A6=81=E6=B1=82=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E9=80=89=E4=B8=AD=E6=8E=A7=E4=BB=B6=E5=B0=B1=E4=BC=9A?= =?UTF-8?q?=E5=8E=BB=E8=AF=B7=E6=B1=82=E8=BF=9E=E6=8E=A5=E5=B9=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B1=9E=E4=BA=8E=E5=BD=93=E5=89=8D=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=88=97=E5=90=8D=E8=BF=99=E9=83=A8=E5=88=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=8F=B3=E4=BE=A7=E9=9D=A2=E6=9D=BF=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E6=97=81=E8=BE=B9?= =?UTF-8?q?=E7=9A=84button=EF=BC=8CshowDictPane=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=89=8D=E4=BC=9A=E5=8E=BB=E8=AF=B7=E6=B1=82=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wrapper/AbstractTableDataWrapper.java | 40 ++++----- .../AccessibleDictionaryEditor.java | 3 +- .../design/present/dict/DictionaryPane.java | 4 + .../present/dict/TableDataDictPane.java | 85 ++++++++++++------- 4 files changed, 83 insertions(+), 49 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java index 82022bea6..ceb0bd8b6 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java @@ -7,6 +7,7 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.utils.DesignUtils; import com.fr.general.ComparatorUtils; @@ -35,18 +36,18 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { /** * 获取数据集的所有列名list - * + * * @return 数据集的所有列名list - * + * * * @date 2014-11-24-下午3:51:41 - * + * */ public List calculateColumnNameList() { if(columnNameList != null){ return columnNameList; } - + DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); TableDataSource tds = adapter == null ? null : adapter.getBook(); String[] colNames = tabledata.getColumnNames(tds); @@ -56,13 +57,14 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { } else if (ArrayUtils.isNotEmpty(colNamesInCache)) { return toColumnNameList(colNamesInCache); } - + EmbeddedTableData embeddedTableData = null; try { embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false); } catch (Exception e) { if (e.getMessage()!=null) { - DesignUtils.errorMessage(e.getMessage()); + // 这个弹窗可能会成为数据字典页面的二级弹窗,所以修改下父窗口避免出现mac下的二级弹窗问题 + FineJOptionPane.showMessageDialog(null, e.getMessage()); } } columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); @@ -78,12 +80,12 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { /** * 生成子节点 - * + * * @return 生成子节点 - * + * * * @date 2014-11-24-下午3:51:17 - * + * */ public ExpandMutableTreeNode[] load() { List namelist = calculateColumnNameList(); @@ -97,10 +99,10 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { /** * 预览数据集 - * + * * * @date 2014-11-24-下午3:50:20 - * + * */ public void previewData() { PreviewTablePane.previewTableData(tabledata); @@ -108,30 +110,30 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { /** * 预览数据集,带有显示值和实际值的标记结果 - * + * * @param keyIndex 实际值 * @param valueIndex 显示值 - * + * * * @date 2014-11-24-下午3:50:20 - * + * */ public void previewData(final int keyIndex,final int valueIndex){ PreviewTablePane.previewTableData(tabledata, keyIndex, valueIndex); } @Override public String getTableDataName(){ - return name; + return name; } /** * 获取数据集的面板 - * + * * @return 数据集面板 - * + * * * @date 2014-11-24-下午3:50:00 - * + * */ public AbstractTableDataPane creatTableDataPane() { return TableDataFactory.creatTableDataPane(tabledata, name); @@ -143,4 +145,4 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { && ComparatorUtils.equals(this.tabledata, ((AbstractTableDataWrapper) obj).getTableData()); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java index c2195512a..f194e6d91 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java @@ -21,6 +21,7 @@ public class AccessibleDictionaryEditor extends UneditableAccessibleEditor { protected void showEditorPane() { if (dictPane == null) { dictPane = new DictionaryPane(); + dictPane.getTableDataDictPane().setNeedTableDataChange(true); } BasicDialog dlg = dictPane.showWindow(SwingUtilities.getWindowAncestor(this)); @@ -58,4 +59,4 @@ public class AccessibleDictionaryEditor extends UneditableAccessibleEditor { public Dictionary updateBean() { return (Dictionary) this.getValue(); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java b/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java index e50ed86b9..3966510fe 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java @@ -83,4 +83,8 @@ public class DictionaryPane extends UIComboBoxPane implements DataCr public void registerDSChangeListener() { tableDataDictPane.registerDSChangeListener(); } + + public TableDataDictPane getTableDataDictPane() { + return tableDataDictPane; + } } diff --git a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java index 3c08c1c9d..055b93fae 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java @@ -32,6 +32,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; @@ -41,7 +42,9 @@ import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutionException; /** * 数据字典的数据查询面板 @@ -60,6 +63,8 @@ public class TableDataDictPane extends FurtherBasicBeanPane private DoubleDeckValueEditorPane valueDictPane; private ItemListener itemListener; private UIObserverListener uiObserverListener; + private FormulaEditor formulaEditor1 = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); + private boolean needTableDataChange = false; public TableDataDictPane() { initBasicComponets(); @@ -67,6 +72,10 @@ public class TableDataDictPane extends FurtherBasicBeanPane iniListener(); } + public void setNeedTableDataChange(boolean needTableDataChange) { + this.needTableDataChange = needTableDataChange; + } + public static void main(String[] args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -83,7 +92,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane tableDataNameComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { - tdChange(e); + tdChange(e, needTableDataChange); } } }); @@ -153,44 +162,62 @@ public class TableDataDictPane extends FurtherBasicBeanPane return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dic_Data_Query"); } - private void tdChange(final ItemEvent e) { + private void tdChange(final ItemEvent e, boolean needTableDataChange) { TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); if (tableDataWrappe == null) { return; } - - List namelist = tableDataWrappe.calculateColumnNameList(); - String[] columnNames = null; - if (!namelist.isEmpty()) { - columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); - } else { - columnNames = new String[]{""}; + if (itemListener != null) { + itemListener.itemStateChanged(e); + formulaEditor1.addChangeListener(event -> { + itemListener.itemStateChanged(e); + }); + } + if (needTableDataChange) { + changeColumnsName(); } - ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); - columnNameEditor1.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor1.addItemListener(itemListener); - keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); + } - FormulaEditor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); - formulaEditor.setEnabled(true); - formulaEditor.addChangeListener(new ChangeListener() { + private void changeColumnsName() { + TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); + SwingWorker, Object> worker = new SwingWorker, Object>() { + @Override + protected List doInBackground() throws Exception { + if (tableDataWrappe == null) { + return new ArrayList<>(); + } + return tableDataWrappe.calculateColumnNameList(); + } @Override - public void stateChanged(ChangeEvent ee) { - if (itemListener != null) { - itemListener.itemStateChanged(e); + protected void done() { + try { + List namelist = get(); + String[] columnNames = null; + if (!namelist.isEmpty()) { + columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); + } else { + columnNames = new String[]{""}; + } + ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); + columnNameEditor1.addItemListener(itemListener); + ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); + columnIndexEditor1.addItemListener(itemListener); + keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); + + formulaEditor1.setEnabled(true); + + ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); + columnNameEditor2.addItemListener(itemListener); + ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); + columnIndexEditor2.addItemListener(itemListener); + valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor1}, columnNames[0]); + } catch (InterruptedException | ExecutionException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); } } - }); - ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); - columnNameEditor2.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor2.addItemListener(itemListener); - valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]); - if (itemListener != null) { - itemListener.itemStateChanged(e); - } + }; + worker.execute(); } @Override From 10056986e7dabf39361d320b5e4fdea888ef0a85 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 10 Dec 2020 18:04:43 +0800 Subject: [PATCH 05/51] =?UTF-8?q?REPORT-45095=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E8=AE=BE=E7=BD=AE=E6=8F=90=E4=BA=A4=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=E5=90=8E?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../write/submit/DBManipulationPane.java | 1749 +++++++++-------- .../submit/SmartInsertDBManipulationPane.java | 6 +- 2 files changed, 898 insertions(+), 857 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index ccf01dd5e..1e1ab1f72 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -53,7 +53,6 @@ import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; -import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -74,6 +73,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Image; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; @@ -92,136 +92,133 @@ public class DBManipulationPane extends BasicBeanPane { private static final Image ICODS_IMAGE = BaseUtils.readImage("/com/fr/web/core/css/images/icons.png"); private static final Icon HEIP_ICON = BaseUtils.createIcon(ICODS_IMAGE, 193, 1, 14, 14); private static final int DEFAULT_RETURN_VALUE = 4; - public KeyColumnNameValueTable keyColumnValuesTable; - private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor + public KeyColumnNameValueTable keyColumnValuesTable; + private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor private UICheckBox UpdateCheckBox; private JPanel checkBoxUpdatePane; - /* - * 记录当前选取的DS & Table对应的ColumnName[] - * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 - */ - private ColumnName[] currentColumnNames = null; + /* + * 记录当前选取的DS & Table对应的ColumnName[] + * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 + */ + private ColumnName[] currentColumnNames = null; - // 支持公式输入的数据表选择面板 - private ChoosePaneSupportFormula chooseTable; + // 支持公式输入的数据表选择面板 + private ChoosePaneSupportFormula chooseTable; - private UIComboBox dmlConfigComboBox = null; + private UIComboBox dmlConfigComboBox = null; - // 提交事件 - private NameSubmitJob[] jobs = null; + // 提交事件 + private NameSubmitJob[] jobs = null; - // 提交条件 - private Condition condition = null; + // 提交条件 + private Condition condition = null; - private JTree conditionsTree; + private JTree conditionsTree; - private Editor[] v_Types; + private Editor[] v_Types; - protected JavaScriptActionPane parentPane; + protected JavaScriptActionPane parentPane; - private int keyColumnWidth = 100; - private int resizeColumnCount = 4; - private int btnWidth = 110; - private int btnHeight = 20; private String subMitName; - private static final String[] DML_CONFIG_TYPES = new String[] { + private static final String[] DML_CONFIG_TYPES = new String[]{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Smart_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Delete_Submit"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Update_Submit")}; - /** - * 无单元格。没有智能添加单元格等按钮 - * 有单元格的参见其子类SmartInsertDBManipulationPane - */ - public DBManipulationPane() { - this(ValueEditorPaneFactory.extendedCellGroupEditors()); - } + /** + * 无单元格。没有智能添加单元格等按钮 + * 有单元格的参见其子类SmartInsertDBManipulationPane + */ + public DBManipulationPane() { + this(ValueEditorPaneFactory.extendedCellGroupEditors()); + } - public DBManipulationPane(Editor[] v_Types) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.v_Types = v_Types; + public DBManipulationPane(Editor[] v_Types) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.v_Types = v_Types; - JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(northPane, BorderLayout.NORTH); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(northPane, BorderLayout.NORTH); - dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); + dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); - JPanel typePane = GUICoreUtils.createFlowPane(new Component[] { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox }, - FlowLayout.LEFT, 10); - typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); - northPane.add(typePane, BorderLayout.NORTH); + JPanel typePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox}, + FlowLayout.LEFT, 10); + typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); + northPane.add(typePane, BorderLayout.NORTH); - chooseTable = new ChoosePaneSupportFormula(); - chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); - chooseTable.setTableNameComboBoxPopSize(160, 320); + chooseTable = new ChoosePaneSupportFormula(); + chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); + chooseTable.setTableNameComboBoxPopSize(160, 320); - northPane.add(chooseTable, BorderLayout.CENTER); + northPane.add(chooseTable, BorderLayout.CENTER); - // peter:编辑的TablePane - JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(editTablePane, BorderLayout.CENTER); - editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); + // peter:编辑的TablePane + JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(editTablePane, BorderLayout.CENTER); + editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); - keyColumnValuesTable = new KeyColumnNameValueTable(); - editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); - keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); - keyColumnValuesTable.setShowHorizontalLines(true); + keyColumnValuesTable = new KeyColumnNameValueTable(); + editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); + keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); + keyColumnValuesTable.setShowHorizontalLines(true); - initJTableColumn(); + initJTableColumn(); - addButtons(editTablePane); + addButtons(editTablePane); - addBottomPane(); + addBottomPane(); - addListeners(); - } + addListeners(); + } - public void setSubMitName(String subMitName){ + public void setSubMitName(String subMitName) { this.subMitName = subMitName; } - public String getSubMitName(){ + public String getSubMitName() { return this.subMitName; } - private void addButtons(JPanel editTablePane) { - // alex:添加操作按钮 - UpdateAction[] actions = this.getActions(); - if (actions != null && actions.length > 0) { - JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); - editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); + private void addButtons(JPanel editTablePane) { + // alex:添加操作按钮 + UpdateAction[] actions = this.getActions(); + if (actions != null && actions.length > 0) { + JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); + editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); - for (int i = 0; i < actions.length; i++) { - controlBtnPane.add(new UIButton(actions[i])); - } + for (UpdateAction action : actions) { + controlBtnPane.add(new UIButton(action)); + } checkBoxUpdatePane = new JPanel(new BorderLayout(0, 0)); - checkBoxUpdatePane.setPreferredSize(new Dimension(120,20)); + checkBoxUpdatePane.setPreferredSize(new Dimension(120, 20)); controlBtnPane.add(checkBoxUpdatePane); UpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_NotChange_Unmodified")); - UIButton helpButton = new UIButton(HEIP_ICON); + UIButton helpButton = new UIButton(HEIP_ICON); helpButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help")); helpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); + FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); BasicDialog dlg = formatExplanation.showMediumWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - new DialogActionAdapter(){}); + new DialogActionAdapter() { + }); dlg.setVisible(true); } }); helpButton.set4ToolbarButton(); - checkBoxUpdatePane.add(UpdateCheckBox,BorderLayout.WEST); - checkBoxUpdatePane.add(helpButton,BorderLayout.EAST); - } - } - - protected void updateUpdateCheckBoxEnable(){ - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - if (model.getRowCount() == 0){ + checkBoxUpdatePane.add(UpdateCheckBox, BorderLayout.WEST); + checkBoxUpdatePane.add(helpButton, BorderLayout.EAST); + } + } + + protected void updateUpdateCheckBoxEnable() { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + if (model.getRowCount() == 0) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(true); return; @@ -230,9 +227,8 @@ public class DBManipulationPane extends BasicBeanPane { for (int i = 0; i < model.getRowCount(); i++) { columnObjects.add(model.getKeyColumnNameValue(i).cv.getObj()); } - for (int i = 0;i < columnObjects.size();i++){ - Object ob = columnObjects.get(i) ; - if (!( ob instanceof ColumnRow || ob instanceof ColumnRowGroup)){ + for (Object ob : columnObjects) { + if (!(ob instanceof ColumnRow || ob instanceof ColumnRowGroup)) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(false); return; @@ -241,236 +237,241 @@ public class DBManipulationPane extends BasicBeanPane { setUpdateCheckBoxEnable(true); } - private void setUpdateCheckBoxEnable( boolean b){ + private void setUpdateCheckBoxEnable(boolean b) { UpdateCheckBox.setEnabled(b); } - private void addBottomPane() { - JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - eventPane.add(addEventButton()); + private void addBottomPane() { + JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + eventPane.add(addEventButton()); - JPanel conditionPane = this.createConditionPane(); + JPanel conditionPane = this.createConditionPane(); - JPanel btPane =new JPanel( FRGUIPaneFactory.createBorderLayout()); - btPane.add(eventPane,BorderLayout.CENTER); - btPane.add(conditionPane,BorderLayout.NORTH); - this.add(btPane, BorderLayout.SOUTH); - } + JPanel btPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + btPane.add(eventPane, BorderLayout.CENTER); + btPane.add(conditionPane, BorderLayout.NORTH); + this.add(btPane, BorderLayout.SOUTH); + } - private UIButton addEventButton() { - UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); - addSubmitEventButton.addActionListener(new ActionListener() { + private UIButton addEventButton() { + UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); + addSubmitEventButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final SubmitJobListPane jobsPane = createSubmitJobListPane(); + @Override + public void actionPerformed(ActionEvent e) { + final SubmitJobListPane jobsPane = createSubmitJobListPane(); - jobsPane.populate(jobs); - BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - jobs = jobsPane.updateDBManipulation(); - } - }); - dialog.setVisible(true); - } + jobsPane.populate(jobs); + BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + jobs = jobsPane.updateDBManipulation(); + } + }); + dialog.setVisible(true); + } - }); - return addSubmitEventButton; - } + }); + return addSubmitEventButton; + } - private JPanel createConditionPane() { - JPanel conditionPane = new JPanel(); - conditionPane.setPreferredSize(createConditionPanePreferredSize()); + private JPanel createConditionPane() { + JPanel conditionPane = new JPanel(); + conditionPane.setPreferredSize(createConditionPanePreferredSize()); setBorderAndLayout(conditionPane); - conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); - conditionsTree.setRootVisible(false); - conditionsTree.setShowsRootHandles(true); - conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); - conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); - DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); - cr.setForeground(UIConstants.NORMAL_BACKGROUND); - JScrollPane jp = new JScrollPane(conditionsTree); - addComponent(conditionPane,jp); - - UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); - addSubmitConditionButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { - @Override - protected boolean isNeedDoWithCondition(Condition liteCondition) { - return liteCondition != null; - } - }; - String[] columns = chooseTable.currentColumnNames(); - if (columns != null && columns.length > 0) { - conditionPane.populateColumns(chooseTable.currentColumnNames()); - } - - conditionPane.populateBean(condition); - BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - condition = conditionPane.updateBean(); - refreshConditionList(); - } - }); - dialog.setVisible(true); - } - }); - - JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); + conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); + conditionsTree.setRootVisible(false); + conditionsTree.setShowsRootHandles(true); + conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); + conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); + DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); + cr.setForeground(UIConstants.NORMAL_BACKGROUND); + JScrollPane jp = new JScrollPane(conditionsTree); + addComponent(conditionPane, jp); + + UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); + addSubmitConditionButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { + @Override + protected boolean isNeedDoWithCondition(Condition liteCondition) { + return liteCondition != null; + } + }; + String[] columns = chooseTable.currentColumnNames(); + if (columns != null && columns.length > 0) { + conditionPane.populateColumns(chooseTable.currentColumnNames()); + } + + conditionPane.populateBean(condition); + BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + condition = conditionPane.updateBean(); + refreshConditionList(); + } + }); + dialog.setVisible(true); + } + }); + + JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); controlBtnPane.setPreferredSize(createControlBtnPanePreferredSize()); - conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH),setControlBtnPanePosition()); - controlBtnPane.add(addSubmitConditionButton); + conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), setControlBtnPanePosition()); + controlBtnPane.add(addSubmitConditionButton); - return conditionPane; - } + return conditionPane; + } - protected void setBorderAndLayout(JPanel jPanel){ + protected void setBorderAndLayout(JPanel jPanel) { jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); jPanel.setBorder(BorderFactory.createTitledBorder( - new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); + new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); } - protected void addComponent(JPanel mainPane,JScrollPane addPane){ - mainPane.add(addPane,BorderLayout.CENTER); + protected void addComponent(JPanel mainPane, JScrollPane addPane) { + mainPane.add(addPane, BorderLayout.CENTER); } - protected Dimension createConditionPanePreferredSize(){ + protected Dimension createConditionPanePreferredSize() { return new Dimension(454, 80); } - protected Dimension createControlBtnPanePreferredSize(){ + protected Dimension createControlBtnPanePreferredSize() { return new Dimension(110, 20); } - protected String setControlBtnPanePosition(){ - return BorderLayout.EAST; + protected String setControlBtnPanePosition() { + return BorderLayout.EAST; } - private void refreshConditionList() { - DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); - ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); - rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); - rootTreeNode.removeAllChildren(); - Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); - } - } else { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); - rootTreeNode.add(newTreeNode); - } - defaultTreeModel.reload(rootTreeNode); - rootTreeNode.expandCurrentTreeNode(conditionsTree); - } - - private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); - parentTreeNode.add(newTreeNode); - Condition liteCondition = joinCondition.getCondition(); - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); - } - } - } - - private void addListeners() { - dmlConfigComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - Object ob = e.getItem(); - if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { - checkBoxUpdatePane.setVisible(true); - } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { - checkBoxUpdatePane.setVisible(false); - } - } - } - }); - - /* - * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, - * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 - * 也不能在tableNameComboBox.focusLost事件时,好像没用 - */ - keyColumnValuesTable.addFocusListener(new FocusAdapter() { - - public void focusGained(FocusEvent e) { - refreshColumnsComboBox(); - } - - }); - } - - protected UpdateAction[] getActions() { - return new UpdateAction[] { new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction() }; - } - - protected SubmitJobListPane createSubmitJobListPane() { - return new SubmitJobListPane(); - } - - public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { - this.parentPane = jsPane; - } - - @Override - protected String title4PopupWindow() { - return "DB"; - } - - protected class SmartAddFieldsAction extends UpdateAction { - public SmartAddFieldsAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); - } - - public void actionPerformed(ActionEvent evt) { - - BasicPane bPane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); - } - }; - bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - - final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { - public String value2Text(Object value) { - if (value instanceof ColumnName) { - return ((ColumnName)value).name; - } - - return super.value2Text(value); - } - }; - bPane.add(new JScrollPane(list), BorderLayout.CENTER); - - BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - public void doOk() { - addFields(list); + private void refreshConditionList() { + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); + ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); + rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); + rootTreeNode.removeAllChildren(); + Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); + } + } else { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); + rootTreeNode.add(newTreeNode); + } + defaultTreeModel.reload(rootTreeNode); + rootTreeNode.expandCurrentTreeNode(conditionsTree); + } + + private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); + parentTreeNode.add(newTreeNode); + Condition liteCondition = joinCondition.getCondition(); + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); + } + } + } + + private void addListeners() { + dmlConfigComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + Object ob = e.getItem(); + if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { + checkBoxUpdatePane.setVisible(true); + } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { + checkBoxUpdatePane.setVisible(false); + } + } + } + }); + + /* + * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, + * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 + * 也不能在tableNameComboBox.focusLost事件时,好像没用 + */ + keyColumnValuesTable.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + refreshColumnsComboBox(); + } + + }); + } + + protected UpdateAction[] getActions() { + return new UpdateAction[]{new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction()}; + } + + protected SubmitJobListPane createSubmitJobListPane() { + return new SubmitJobListPane(); + } + + public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { + this.parentPane = jsPane; + } + + @Override + protected String title4PopupWindow() { + return "DB"; + } + + protected class SmartAddFieldsAction extends UpdateAction { + public SmartAddFieldsAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + + BasicPane bPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); + } + }; + bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + + final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { + @Override + public String value2Text(Object value) { + if (value instanceof ColumnName) { + return ((ColumnName) value).name; + } + + return super.value2Text(value); + } + }; + bPane.add(new JScrollPane(list), BorderLayout.CENTER); + + BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + addFields(list); updateUpdateCheckBoxEnable(); - } - }); - dlg.setVisible(true); - } - } - - private void addFields (CheckBoxList list) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + } + }); + dlg.setVisible(true); + } + } + + private void addFields(CheckBoxList list) { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); List keyColumnNameValueList = new ArrayList(); keyColumnNameValueList.clear(); for (int i = 0; i < model.getRowCount(); i++) { @@ -481,28 +482,28 @@ public class DBManipulationPane extends BasicBeanPane { // Richie:用了存储新的KeyColumnNameValue的List. List newKeyColumnNameValueList = new ArrayList(); if (!keyColumnNameValueList.isEmpty()) { - for (int i = 0; i < selected.length; i++) { + for (Object o : selected) { // Richie:先填上空的. - newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } // Richie:初始化 int returnValue = DEFAULT_RETURN_VALUE; int coverNumber = 0; - if (!keyColumnNameValueList.isEmpty()) { - //如果存在先前项,设置状态为5 - returnValue = 5 ; - } + if (!keyColumnNameValueList.isEmpty()) { + //如果存在先前项,设置状态为5 + returnValue = 5; + } for (int i = 0; i < selected.length; i++) { if (returnValue == 0 || returnValue == 3) { break; } - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { - Object[] options = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None") }; + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { + Object[] options = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None")}; returnValue = JOptionPane.showOptionDialog(DBManipulationPane.this, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValueList.get(j).cn.name), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValue.cn.name), "", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); // Richie:全部覆盖 if (returnValue == 0) { @@ -514,7 +515,7 @@ public class DBManipulationPane extends BasicBeanPane { } else if (returnValue == 2) { coverNumber = i; newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); // Richie:全部不覆盖 } else if (returnValue == 3) { coverNumber = i; @@ -526,7 +527,7 @@ public class DBManipulationPane extends BasicBeanPane { checkTableModel(returnValue, coverNumber, model, selected, keyColumnNameValueList, newKeyColumnNameValueList); } - private void checkTableModel (int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { + private void checkTableModel(int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { if (returnValue == 0) { model.removeAllKeyColumnNameValue(); // Richie:全部覆盖,按selected的长度添加默认的行 @@ -538,10 +539,10 @@ public class DBManipulationPane extends BasicBeanPane { model.removeAllKeyColumnNameValue(); // Richie:全部不覆盖,已经存在的就保留,不存在的添加默认行 for (int i = coverNumber; i < selected.length; i++) { - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); } } @@ -552,610 +553,650 @@ public class DBManipulationPane extends BasicBeanPane { } } else if (returnValue == 1 || returnValue == 2) { - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } else if (returnValue == 5){ - //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } else if (returnValue == 5) { + //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } // Richie:初始化 if (keyColumnNameValueList.isEmpty()) { model.removeAllKeyColumnNameValue(); - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + for (Object o : selected) { + model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } - + model.fireTableDataChanged(); keyColumnValuesTable.validate(); } - protected class AddFieldAction extends UpdateAction { - public AddFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); - } + protected class AddFieldAction extends UpdateAction { + public AddFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); + } - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(ActionEvent e) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); - model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); + model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); updateUpdateCheckBoxEnable(); - model.fireTableDataChanged(); - - keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); - } - } - - protected class RemoveFieldAction extends UpdateAction { - public RemoveFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); - } - - public void actionPerformed(ActionEvent evt) { - // DBManipulationPane target = this.getDBManipulationPane(); - - int[] selectedRows = keyColumnValuesTable.getSelectedRows(); - if (selectedRows == null || selectedRows.length == 0) { - return; - } - - int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.OK_OPTION) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - - // 把selectedRows从小到大排个序,先删大的再删小的 - java.util.Arrays.sort(selectedRows); - for (int i = selectedRows.length - 1; i >= 0; i--) { - keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); - } + model.fireTableDataChanged(); + + keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); + } + } + + protected class RemoveFieldAction extends UpdateAction { + public RemoveFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + // DBManipulationPane target = this.getDBManipulationPane(); + + int[] selectedRows = keyColumnValuesTable.getSelectedRows(); + if (selectedRows == null || selectedRows.length == 0) { + return; + } + + int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.OK_OPTION) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + + // 把selectedRows从小到大排个序,先删大的再删小的 + java.util.Arrays.sort(selectedRows); + for (int i = selectedRows.length - 1; i >= 0; i--) { + keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); + } updateUpdateCheckBoxEnable(); - keyColumnNameValueTableModel.fireTableDataChanged(); - - // select other one. - if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); - } else if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - } - } - - /* - * 刷新columnsComboBox - */ - private void refreshColumnsComboBox() { - DefaultComboBoxModel model = (DefaultComboBoxModel)this.columnsComboBox.getModel(); - model.removeAllElements(); - - ColumnName[] columnNames = currentColumnNames(); - for (int i = 0; i < columnNames.length; i++) { - model.addElement(columnNames[i]); - } - } - - // 得到当前的ColumnName[] - private ColumnName[] currentColumnNames() { - // ben:清除原有的 - if (currentColumnNames != null) { - currentColumnNames = null; - } - String[] colNames = this.chooseTable.currentColumnNames(); - int len = colNames.length; - currentColumnNames = new ColumnName[len]; - for (int i = 0; i < len; i++) { - currentColumnNames[i] = new ColumnName(colNames[i]); - } - return currentColumnNames; - } - - /* - * 设置JTable的Column - */ - private void initJTableColumn() { - TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); - column0.setMaxWidth(50); - - TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); - column1.setCellRenderer(new ColumnNameTableCellRenderer()); - - TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); - column2.setCellRenderer(new ColumnValueTableCellRenderer()); - - // 设置column1的editor - columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); - columnsComboBox.setRenderer(new UIComboBoxRenderer() { - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - - }); - column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { - public boolean stopCellEditing() { - if (super.stopCellEditing()) { - return true; - } - - return false; - } - }); - ((DefaultCellEditor)column1.getCellEditor()).setClickCountToStart(2); - - //设置Column 2的Editor - column2.setCellEditor(new ColumnValueEditor()); - } - - public void populateBean(DBManipulation dbManipulation) { - if (dbManipulation == null) { - dbManipulation = new DBManipulation(); - } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // select other one. + if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); + } else if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + } + } + + /* + * 刷新columnsComboBox + */ + private void refreshColumnsComboBox() { + DefaultComboBoxModel model = (DefaultComboBoxModel) this.columnsComboBox.getModel(); + model.removeAllElements(); + + ColumnName[] columnNames = currentColumnNames(); + for (ColumnName columnName : columnNames) { + model.addElement(columnName); + } + } + + // 得到当前的ColumnName[] + private ColumnName[] currentColumnNames() { + // ben:清除原有的 + if (currentColumnNames != null) { + currentColumnNames = null; + } + String[] colNames = this.chooseTable.currentColumnNames(); + int len = colNames.length; + currentColumnNames = new ColumnName[len]; + for (int i = 0; i < len; i++) { + currentColumnNames[i] = new ColumnName(colNames[i]); + } + return currentColumnNames; + } + + /* + * 设置JTable的Column + */ + private void initJTableColumn() { + TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); + column0.setMaxWidth(50); + + TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); + column1.setCellRenderer(new ColumnNameTableCellRenderer()); + + TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); + column2.setCellRenderer(new ColumnValueTableCellRenderer()); + + // 设置column1的editor + columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); + columnsComboBox.setRenderer(new UIComboBoxRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + + }); + column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { + @Override + public boolean stopCellEditing() { + return super.stopCellEditing(); + } + }); + ((DefaultCellEditor) column1.getCellEditor()).setClickCountToStart(2); + + //设置Column 2的Editor + column2.setCellEditor(new ColumnValueEditor(DBManipulationPane.this)); + } + + @Override + public void populateBean(DBManipulation dbManipulation) { + if (dbManipulation == null) { + dbManipulation = new DBManipulation(); + } subMitName = dbManipulation.getName(); - DMLConfig dmlConfig = dbManipulation.getDmlConfig(); - - if (dmlConfig != null) { - if (dmlConfig instanceof IntelliDMLConfig) { - dmlConfigComboBox.setSelectedIndex(0); - } else if (dmlConfig instanceof DeleteConfig) { - dmlConfigComboBox.setSelectedIndex(1); - } else if (dmlConfig instanceof InsertConfig) { - dmlConfigComboBox.setSelectedIndex(2); - } else if (dmlConfig instanceof UpdateConfig) { - dmlConfigComboBox.setSelectedIndex(3); - } else { - dmlConfigComboBox.setSelectedIndex(0); - } - jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; - for (int i = 0; i < jobs.length; i++) { - jobs[i] = dmlConfig.getNameSubmitJob(i); - } - condition = dmlConfig.getCondition(); + DMLConfig dmlConfig = dbManipulation.getDmlConfig(); + + if (dmlConfig != null) { + if (dmlConfig instanceof IntelliDMLConfig) { + dmlConfigComboBox.setSelectedIndex(0); + } else if (dmlConfig instanceof DeleteConfig) { + dmlConfigComboBox.setSelectedIndex(1); + } else if (dmlConfig instanceof InsertConfig) { + dmlConfigComboBox.setSelectedIndex(2); + } else if (dmlConfig instanceof UpdateConfig) { + dmlConfigComboBox.setSelectedIndex(3); + } else { + dmlConfigComboBox.setSelectedIndex(0); + } + jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; + for (int i = 0; i < jobs.length; i++) { + jobs[i] = dmlConfig.getNameSubmitJob(i); + } + condition = dmlConfig.getCondition(); UpdateCheckBox.setSelected(dmlConfig.isUpdateSelected()); - } else { - jobs = null; - condition = null; - dmlConfigComboBox.setSelectedIndex(0); + } else { + jobs = null; + condition = null; + dmlConfigComboBox.setSelectedIndex(0); UpdateCheckBox.setSelected(false); - } + } - String schema = null; - String tableName = null; + String schema = null; + String tableName = null; Table table = null; - if (dmlConfig != null && dmlConfig.getOriTable() != null) { + if (dmlConfig != null && dmlConfig.getOriTable() != null) { table = dmlConfig.getOriTable(); if (table != null) { schema = table.getSchema(); tableName = table.getName(); } } - chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); + chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); - populateKeyColumnValueTable(dmlConfig); + populateKeyColumnValueTable(dmlConfig); updateUpdateCheckBoxEnable(); - refreshConditionList(); - } - - private void populateKeyColumnValueTable(DMLConfig dmlConfig) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); - - if (dmlConfig != null) { - boolean acceptPara = false; - for (int i = 0; i < v_Types.length; i++) { - if (v_Types[i].accept(new Parameter())) { - acceptPara = true; - break; - } - } - for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { - ColumnConfig column = dmlConfig.getColumnConfig(i); - String columnName = column.getColumnName(); - if (!acceptPara && column.getColumnValue() instanceof Parameter) { - // 表单中,将以前的参数转换为公式 - column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter)column.getColumnValue()).getName())); - } - - KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), - column.isSkipUnmodified()); - keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); - } - } - keyColumnNameValueTableModel.fireTableDataChanged(); - - // 选择第一个 - if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - - public DBManipulation updateBean() { - DataBaseItems para = chooseTable.updateBean(true); - DBManipulation dbMani = new DBManipulation(); - dbMani.setName(subMitName); - dbMani.setDBName(para.getDatabaseName()); + refreshConditionList(); + } + + private void populateKeyColumnValueTable(DMLConfig dmlConfig) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); + + if (dmlConfig != null) { + boolean acceptPara = false; + for (int i = 0; i < v_Types.length; i++) { + if (v_Types[i].accept(new Parameter())) { + acceptPara = true; + break; + } + } + for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { + ColumnConfig column = dmlConfig.getColumnConfig(i); + String columnName = column.getColumnName(); + if (!acceptPara && column.getColumnValue() instanceof Parameter) { + // 表单中,将以前的参数转换为公式 + column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter) column.getColumnValue()).getName())); + } + + KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), + column.isSkipUnmodified()); + keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); + } + } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // 选择第一个 + if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } - DMLConfig dmlConfig = new IntelliDMLConfig(); - if (dmlConfigComboBox.getSelectedIndex() == 1) { - dmlConfig = new DeleteConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 2) { - dmlConfig = new InsertConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 3) { - dmlConfig = new UpdateConfig(); - } + @Override + public DBManipulation updateBean() { + DataBaseItems para = chooseTable.updateBean(true); + DBManipulation dbMani = new DBManipulation(); + dbMani.setName(subMitName); + dbMani.setDBName(para.getDatabaseName()); + + DMLConfig dmlConfig = new IntelliDMLConfig(); + if (dmlConfigComboBox.getSelectedIndex() == 1) { + dmlConfig = new DeleteConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 2) { + dmlConfig = new InsertConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 3) { + dmlConfig = new UpdateConfig(); + } - dbMani.setDmlConfig(dmlConfig); + dbMani.setDmlConfig(dmlConfig); - dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); + dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); - for (int i = 0; i < rowCount; i++) { - KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); - // peter:先添加key column name. + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); + for (int i = 0; i < rowCount; i++) { + KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); + // peter:先添加key column name. - dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey,false)); - } + dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey, false)); + } dmlConfig.setUpdateSelected(UpdateCheckBox.isSelected()); - if (jobs != null) { - for (int i = 0; i < jobs.length; i++) { - dmlConfig.addSubmitJob(jobs[i]); - } - } - dmlConfig.setCondition(condition); - - return dbMani; - } - - protected class ValuePane extends BasicBeanPane { - ValueEditorPane vPane; - - public ValuePane() { - this(v_Types); - } - - public ValuePane(Editor[] types) { - vPane = new ValueEditorPane(types); - this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); - this.add(vPane); - vPane.setPreferredSize(new Dimension(220, 25)); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); - } - - public void populateBean(Object object) { - vPane.populate(object); - } - - @Override - public Object updateBean() { - return vPane.update(); - } - - } - - /* - * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 - */ - protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { - /** The Swing component being edited. */ - private UILabel textLabel; - private ValuePane vPane; - private BasicDialog vPaneDLG; - - protected ColumnValueEditor() { - this(v_Types); - } - - protected ColumnValueEditor(Editor[] types) { - textLabel = new UILabel(); - textLabel.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - vPaneDLG.setAlwaysOnTop(true); - vPaneDLG.setVisible(true); - - } - }); - - vPane = new ValuePane(types); - vPaneDLG = vPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { - public void doOk() { - fireEditingStopped(); // Make the renderer - // reappear. + if (jobs != null) { + for (NameSubmitJob job : jobs) { + dmlConfig.addSubmitJob(job); + } + } + dmlConfig.setCondition(condition); + + return dbMani; + } + + protected class ValuePane extends BasicBeanPane { + ValueEditorPane vPane; + + public ValuePane() { + this(v_Types); + } + + public ValuePane(Editor[] types) { + vPane = new ValueEditorPane(types); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); + this.add(vPane); + vPane.setPreferredSize(new Dimension(220, 25)); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); + } + + @Override + public void populateBean(Object object) { + vPane.populate(object); + } + + @Override + public Object updateBean() { + return vPane.update(); + } + + } + + /* + * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 + */ + protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { + /** + * The Swing component being edited. + */ + private final UILabel textLabel; + private final ValuePane vPane; + private final BasicDialog vPaneDLG; + private Component parent; + + /** + * 列值编辑器 + * + * @param parent 父组件,通过指定父组件启动下一级子窗口 + */ + protected ColumnValueEditor(Component parent) { + this(v_Types, parent); + } + + @Deprecated + protected ColumnValueEditor() { + this(v_Types, null); + } + + /** + * 列值编辑器 + * + * @param types 编辑器类型 + * @param parent 父组件,通过指定父组件启动下一级子窗口 + */ + protected ColumnValueEditor(Editor[] types, Component parent) { + textLabel = new UILabel(); + textLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + vPaneDLG.setVisible(true); + } + }); + + vPane = new ValuePane(types); + Window window = parent == null + ? DesignerContext.getDesignerFrame() + : SwingUtilities.getWindowAncestor(parent); + vPaneDLG = vPane.showSmallWindow(window, new DialogActionAdapter() { + @Override + public void doOk() { + fireEditingStopped(); // Make the renderer + // reappear. updateUpdateCheckBoxEnable(); - } - - public void doCancel() { - fireEditingCanceled(); - } - }); - } - - /* - * 双击以编辑 - */ - public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof MouseEvent) { - return ((MouseEvent)anEvent).getClickCount() >= 2; - } - return true; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof ColumnValue) { - vPane.populateBean(((ColumnValue)value).obj); - - if (((ColumnValue)value).obj != null) { - textLabel.setText(((ColumnValue)value).obj.toString()); - } else { - textLabel.setText(""); - } - } - - return textLabel; - } - - public Object getCellEditorValue() { - return new ColumnValue(vPane.updateBean()); - } - } - - public static class ColumnName { - public String name; - - public ColumnName(String name) { - this.name = name; - } - - public boolean equals(Object obj) { - if (!(obj instanceof ColumnName)) { - return false; - } - - return ComparatorUtils.equals(this.name, ((ColumnName)obj).name); - } - - @Override - protected ColumnName clone() throws CloneNotSupportedException { - return new ColumnName(name); - } - } - - public static class ColumnValue { - public Object obj; - - public ColumnValue(Object obj) { - this.obj = obj; - } - - public Object getObj(){ + } + + @Override + public void doCancel() { + fireEditingCanceled(); + } + }); + } + + /* + * 双击以编辑 + */ + @Override + public boolean isCellEditable(EventObject anEvent) { + if (anEvent instanceof MouseEvent) { + return ((MouseEvent) anEvent).getClickCount() >= 2; + } + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof ColumnValue) { + vPane.populateBean(((ColumnValue) value).obj); + + if (((ColumnValue) value).obj != null) { + textLabel.setText(((ColumnValue) value).obj.toString()); + } else { + textLabel.setText(""); + } + } + + return textLabel; + } + + @Override + public Object getCellEditorValue() { + return new ColumnValue(vPane.updateBean()); + } + } + + public static class ColumnName { + public String name; + + public ColumnName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnName)) { + return false; + } + + return ComparatorUtils.equals(this.name, ((ColumnName) obj).name); + } + + @Override + protected ColumnName clone() throws CloneNotSupportedException { + return new ColumnName(name); + } + } + + public static class ColumnValue { + public Object obj; + + public ColumnValue(Object obj) { + this.obj = obj; + } + + public Object getObj() { return obj; } - public boolean equals(Object obj) { - if (!(obj instanceof ColumnValue)) { - return false; - } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnValue)) { + return false; + } - return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj); - } + return ComparatorUtils.equals(this.obj, ((ColumnValue) obj).obj); + } - @Override - protected ColumnValue clone() throws CloneNotSupportedException { - return new ColumnValue(obj); - } - } + @Override + protected ColumnValue clone() throws CloneNotSupportedException { + return new ColumnValue(obj); + } + } - protected static class KeyColumnNameValueTable extends JTable { + protected static class KeyColumnNameValueTable extends JTable { - public KeyColumnNameValueTable() { - super(new KeyColumnValueTableModel(null)); - } + public KeyColumnNameValueTable() { + super(new KeyColumnValueTableModel(null)); + } - public KeyColumnTableModel getTableModel4SmartAddCell() { - KeyColumnTableModel clonedTableModel = null; - try { - //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 - clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return new KeyColumnValueTableModel(clonedTableModel); - } + public KeyColumnTableModel getTableModel4SmartAddCell() { + KeyColumnTableModel clonedTableModel = null; + try { + //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 + clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return new KeyColumnValueTableModel(clonedTableModel); + } - } + } - protected abstract static class KeyColumnTableModel extends AbstractTableModel { + protected abstract static class KeyColumnTableModel extends AbstractTableModel { public static final String RAW_KEY = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_RWA_Key"); public static final String COLUMN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Column"); - public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); - - public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; - - protected List keyColumnNameValueList = new ArrayList<>(); - - public KeyColumnTableModel(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - - public String getColumnName(int col) { - return COLUMN_NAMES[col]; - } - - public int getColumnCount() { - return COLUMN_NAMES.length; - } - - public int getRowCount() { - return keyColumnNameValueList.size(); - } - - public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { - this.keyColumnNameValueList.add(keyColumnNameValue); - } - - public void removeKeyColumnNameValue(int index) { - this.keyColumnNameValueList.remove(index); - } - - public KeyColumnNameValue getKeyColumnNameValue(int index) { - return this.keyColumnNameValueList.get(index); - } - - public void removeAllKeyColumnNameValue() { - this.keyColumnNameValueList.clear(); - } - - public void refreshNameValueList(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.clear(); - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - } - - protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable{ - - public KeyColumnValueTableModel(KeyColumnTableModel model) { - super(model); - } - - public Object getValueAt(int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - switch (col) { - case 0: - return knv.isKey; - case 1: - return knv.cn; - case 2: - return knv.cv; - } - return null; - } - - public void setValueAt(Object value, int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - if (col == 0 && value instanceof Boolean) { - knv.isKey = ((Boolean)value).booleanValue(); - } else if (col == 1 && value instanceof ColumnName) { - knv.cn = (ColumnName)value; - } else if (col == 2 && value instanceof ColumnValue) { - knv.cv = (ColumnValue)value; - } - } - - public Class getColumnClass(int c) { - switch (c) { - case 0: - return Boolean.class; - case 1: - return ColumnName.class; - case 2: - return ColumnValue.class; - } - return String.class; - } - - public boolean isCellEditable(int row, int col) { - return true; - } - - @Override - protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { - KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); - cloned.keyColumnNameValueList = new ArrayList<>(); - for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { - cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); - } - return cloned; - } - } - - - - public static class KeyColumnNameValue { - private boolean isKey = false; - private ColumnName cn; - public ColumnValue cv; - - public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { - this.isKey = isKey; - this.cn = cn; - this.cv = cv; - } - - /** - * 字符串 - * - * @return 字符串z - */ - public String toString() { - return (isKey ? "* " : "") + cn + ":" + cv; - } - - @Override - protected KeyColumnNameValue clone() throws CloneNotSupportedException { - return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); - } - } - - /* - * ColumnNameTableCellRenderer - */ - public class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - } - - /* - * ColumnValueTableCellRenderer - */ - private class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnValue) { - if (((ColumnValue)value).obj != null) { - if (((ColumnValue)value).obj instanceof Date) { - this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue)value).obj)); - } else { - this.setText(((ColumnValue)value).obj.toString()); - } - } else { - this.setText(""); - } - } - - return this; - } - } + public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); + + public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; + + protected List keyColumnNameValueList = new ArrayList<>(); + + public KeyColumnTableModel(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + + @Override + public String getColumnName(int col) { + return COLUMN_NAMES[col]; + } + + @Override + public int getColumnCount() { + return COLUMN_NAMES.length; + } + + @Override + public int getRowCount() { + return keyColumnNameValueList.size(); + } + + public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { + this.keyColumnNameValueList.add(keyColumnNameValue); + } + + public void removeKeyColumnNameValue(int index) { + this.keyColumnNameValueList.remove(index); + } + + public KeyColumnNameValue getKeyColumnNameValue(int index) { + return this.keyColumnNameValueList.get(index); + } + + public void removeAllKeyColumnNameValue() { + this.keyColumnNameValueList.clear(); + } + + public void refreshNameValueList(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.clear(); + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + } + + protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable { + + public KeyColumnValueTableModel(KeyColumnTableModel model) { + super(model); + } + + @Override + public Object getValueAt(int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + switch (col) { + case 0: + return knv.isKey; + case 1: + return knv.cn; + case 2: + return knv.cv; + } + return null; + } + + @Override + public void setValueAt(Object value, int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + if (col == 0 && value instanceof Boolean) { + knv.isKey = ((Boolean) value).booleanValue(); + } else if (col == 1 && value instanceof ColumnName) { + knv.cn = (ColumnName) value; + } else if (col == 2 && value instanceof ColumnValue) { + knv.cv = (ColumnValue) value; + } + } + + @Override + public Class getColumnClass(int c) { + switch (c) { + case 0: + return Boolean.class; + case 1: + return ColumnName.class; + case 2: + return ColumnValue.class; + } + return String.class; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { + KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); + cloned.keyColumnNameValueList = new ArrayList<>(); + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); + } + return cloned; + } + } + + + public static class KeyColumnNameValue { + private boolean isKey = false; + private ColumnName cn; + public ColumnValue cv; + + public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { + this.isKey = isKey; + this.cn = cn; + this.cv = cv; + } + + /** + * 字符串 + * + * @return 字符串z + */ + @Override + public String toString() { + return (isKey ? "* " : "") + cn + ":" + cv; + } + + @Override + protected KeyColumnNameValue clone() throws CloneNotSupportedException { + return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); + } + } + + /* + * ColumnNameTableCellRenderer + */ + public static class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + } + + /* + * ColumnValueTableCellRenderer + */ + private static class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnValue) { + if (((ColumnValue) value).obj != null) { + if (((ColumnValue) value).obj instanceof Date) { + this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue) value).obj)); + } else { + this.setText(((ColumnValue) value).obj.toString()); + } + } else { + this.setText(""); + } + } + + return this; + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index a430faeec..4c283cd71 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -356,7 +356,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { if (isCellGroup) { column2.setCellRenderer(new ColumnRowGroupCellRenderer2()); - column2.setCellEditor(new ColumnValueEditor(ValueEditorPaneFactory.cellGroupEditor())); + column2.setCellEditor(new ColumnValueEditor(ValueEditorPaneFactory.cellGroupEditor(), this)); } else { column2.setCellRenderer(new SelectedColumnValueTableCellRenderer()); } @@ -456,7 +456,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { newAdd.clear(); for (int i = 0; i < cs; i++) { for (int j = 0; j < rs; j++) { - TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j ); + TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j); if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) { String value = cellElement.toString(); if (!newAdd.contains(value) && !allColumnRow.contains(value)) { @@ -512,7 +512,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { private SmartJTablePaneAction a = new AbstractSmartJTablePaneAction(this, SmartInsertDBManipulationPane.this) { @Override public void doOk() { - ((KeyColumnTableModel)keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel)model); + ((KeyColumnTableModel) keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel) model); } @Override From 9206f6ed83c6956746a3980d779f11859a6ce961 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Wed, 9 Dec 2020 19:46:08 +0800 Subject: [PATCH 06/51] =?UTF-8?q?CHART-17340=20=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E7=BB=84=E4=BB=B6=E5=A2=9E=E5=8A=A0=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/editor/script/i18n.js | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js b/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js index 95b4585c9..35acc1ffa 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js @@ -16,7 +16,10 @@ "BI-Basic_Font_Color": "文字颜色", "BI-Word_Align_Left": "文字居左", "BI-Word_Align_Center": "文字居中", - "BI-Word_Align_Right": "文字居右" + "BI-Word_Align_Right": "文字居右", + "BI-Basic_Cancel": "取消", + "BI-Basic_Save": "保存", + "BI-Basic_More": "更多" }; var taiwan = { @@ -35,7 +38,10 @@ "BI-Basic_Font_Color": "文字顏色", "BI-Word_Align_Left": "文字居左", "BI-Word_Align_Center": "文字居中", - "BI-Word_Align_Right": "文字居右" + "BI-Word_Align_Right": "文字居右", + "BI-Basic_Cancel": "取消", + "BI-Basic_Save": "保存", + "BI-Basic_More": "更多" }; var english = { @@ -54,7 +60,10 @@ "BI-Basic_Font_Color": "Font Color", "BI-Word_Align_Left": "Align Left", "BI-Word_Align_Center": "Align Center", - "BI-Word_Align_Right": "Align Right" + "BI-Word_Align_Right": "Align Right", + "BI-Basic_Cancel": "Cancel", + "BI-Basic_Save": "Save", + "BI-Basic_More": "More" }; var japanese = { @@ -73,7 +82,10 @@ "BI-Basic_Font_Color": "テキストの色", "BI-Word_Align_Left": "左のテキスト", "BI-Word_Align_Center": "テキスト中心", - "BI-Word_Align_Right": "右のテキスト" + "BI-Word_Align_Right": "右のテキスト", + "BI-Basic_Cancel": "キャンセル", + "BI-Basic_Save": "セーブ", + "BI-Basic_More": "もっと" }; var korean = { @@ -92,7 +104,10 @@ "BI-Basic_Font_Color": "텍스트 색상", "BI-Word_Align_Left": "왼쪽 텍스트", "BI-Word_Align_Center": "텍스트 중심", - "BI-Word_Align_Right": "오른쪽 텍스트" + "BI-Word_Align_Right": "오른쪽 텍스트", + "BI-Basic_Cancel": "취소", + "BI-Basic_Save": "저장", + "BI-Basic_More": "더" }; function transformI18n(language) { From 0a647992b2d85eebdfaa1f882fb2f6cdb240594e Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 10 Dec 2020 11:25:17 +0800 Subject: [PATCH 07/51] =?UTF-8?q?CHART-17340=20=E8=A1=A5=E5=85=85=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=9B=BD=E9=99=85=E5=8C=96=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/editor/script/i18n.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js b/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js index 35acc1ffa..205117f3c 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js @@ -19,7 +19,9 @@ "BI-Word_Align_Right": "文字居右", "BI-Basic_Cancel": "取消", "BI-Basic_Save": "保存", - "BI-Basic_More": "更多" + "BI-Basic_More": "更多", + "BI-Custom_Color": "自定义颜色", + "BI-Transparent_Color": "透明" }; var taiwan = { @@ -41,7 +43,9 @@ "BI-Word_Align_Right": "文字居右", "BI-Basic_Cancel": "取消", "BI-Basic_Save": "保存", - "BI-Basic_More": "更多" + "BI-Basic_More": "更多", + "BI-Custom_Color": "自定義顏色", + "BI-Transparent_Color": "透明" }; var english = { @@ -63,7 +67,9 @@ "BI-Word_Align_Right": "Align Right", "BI-Basic_Cancel": "Cancel", "BI-Basic_Save": "Save", - "BI-Basic_More": "More" + "BI-Basic_More": "More", + "BI-Custom_Color": "Custom Color", + "BI-Transparent_Color": "Transparent Color" }; var japanese = { @@ -85,7 +91,9 @@ "BI-Word_Align_Right": "右のテキスト", "BI-Basic_Cancel": "キャンセル", "BI-Basic_Save": "セーブ", - "BI-Basic_More": "もっと" + "BI-Basic_More": "もっと", + "BI-Custom_Color": "カスタムカラー", + "BI-Transparent_Color": "トランスペアレント" }; var korean = { @@ -107,7 +115,9 @@ "BI-Word_Align_Right": "오른쪽 텍스트", "BI-Basic_Cancel": "취소", "BI-Basic_Save": "저장", - "BI-Basic_More": "더" + "BI-Basic_More": "더", + "BI-Custom_Color": "맞춤 색상", + "BI-Transparent_Color": "투명한" }; function transformI18n(language) { From 329b58d8b8bb9c312b22fbacf9a28e36cc845bdd Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 11 Dec 2020 11:16:31 +0800 Subject: [PATCH 08/51] =?UTF-8?q?REPORT-44714=20=E3=80=9010.0.12=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AE=B0=E5=BD=95=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=B1=E6=95=88=20=E4=B8=8E=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=B2=9F=E9=80=9A=E5=90=8E=EF=BC=8C=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=A1=88=E4=B8=BA=EF=BC=8C=E5=BD=93?= =?UTF-8?q?=E5=8F=91=E7=94=9F=E4=BA=86=E8=B6=B3=E4=BB=A5=E9=80=A0=E6=88=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E9=9D=A2=E6=9D=BF=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E5=AE=B9=E5=99=A8=E9=AB=98=E5=BA=A6=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=87=B3=E5=B0=91=E4=BF=9D=E8=AF=81=E6=B0=B4?= =?UTF-8?q?=E5=B9=B3=E6=8B=96=E6=8B=BD=E9=9D=A2=E6=9D=BF=E4=B8=8D=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 45 ++++++++++--------- .../gui/icontainer/UIResizableContainer.java | 32 +++---------- .../fr/design/mainframe/DesignerFrame.java | 4 +- .../mainframe/WestRegionContainerPane.java | 2 +- 4 files changed, 34 insertions(+), 49 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 44c0eba84..83f8133d7 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -141,8 +141,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private int eastRegionToolPaneY = 300; private int eastRegionContainerWidth = 260; + private int westRegionToolPaneY = 300; private int westRegionContainerWidth = 240; - private double westRegionToolPaneYRate = 0.5; private String encryptionKey; private String jdkHome; @@ -240,7 +240,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String installHome = StableUtils.getInstallHome(); //这里不判断路径是.的情况,放在checkValid方法里面,重新选 if (installHome != null) { - String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); + String name = Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); String envPath = designerEnvManager.getDefaultenvPath(installHome); designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath)); designerEnvManager.setCurEnvName(name); @@ -304,8 +304,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String today = calender.get(Calendar.YEAR) + "-" + (calender.get(Calendar.MONTH) + 1) + "-" + calender.get(Calendar.DAY_OF_MONTH); String fileName = StableUtils.pathJoin(logLocation, "fr_" + today + "_%g.log"); - if (!new java.io.File(fileName).exists()) { - StableUtils.makesureFileExist(new java.io.File(fileName)); + if (!new File(fileName).exists()) { + StableUtils.makesureFileExist(new File(fileName)); } Handler handler = new FileHandler(fileName, true); @@ -440,12 +440,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.lastOpenFilePath = lastOpenFilePath; } + /** - * 获取西面板的上子面板的高度占容器总高度的比例 + * 得到西面板的上下子面板的高度区分 + * * @return */ - public double getLastWestRegionToolPaneYRate() { - return westRegionToolPaneYRate; + public int getLastWestRegionToolPaneY() { + return this.westRegionToolPaneY; } /** @@ -458,11 +460,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 设置关闭设计器前,西面板的上子面板的高度占容器总高度的比例 - * @param westRegionToolPaneYRate + * 设置西面板的上下子面板的高度区分 + * + * @param toolPaneY */ - public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) { - this.westRegionToolPaneYRate = westRegionToolPaneYRate; + public void setLastWestRegionToolPaneY(int toolPaneY) { + this.westRegionToolPaneY = toolPaneY; } /** @@ -526,7 +529,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return env; } } - String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); + String name = Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath); this.putEnv(name, newDefaultEnv); return newDefaultEnv; @@ -549,7 +552,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } } - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); + return Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); } @@ -1607,8 +1610,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void readLastWestRegionLayout(XMLableReader reader) { String tmpVal; - if ((tmpVal = reader.getAttrAsString("toolPaneYRate", null)) != null) { - this.setLastWestRegionToolPaneYRate(Double.parseDouble(tmpVal)); + if ((tmpVal = reader.getAttrAsString("toolPaneY", null)) != null) { + this.setLastWestRegionToolPaneY(Integer.parseInt(tmpVal)); } if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) { this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal)); @@ -1640,7 +1643,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { // marks:兼容6.1的 // marks:设置默认的目录. - String curReportServerName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); + String curReportServerName = Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal); this.putEnv(curReportServerName, reportServer); @@ -1931,8 +1934,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void writeLastWestRegionLayout(XMLPrintWriter writer) { writer.startTAG("LastWestRegionLayout"); - if (this.getLastWestRegionToolPaneYRate() >= 0) { - writer.attr("toolPaneYRate", this.getLastWestRegionToolPaneYRate()); + if (this.getLastWestRegionToolPaneY() >= 0) { + writer.attr("toolPaneY ", this.getLastWestRegionToolPaneY()); } if (this.getLastWestRegionContainerWidth() >= 0) { writer.attr("containerWidth", this.getLastWestRegionContainerWidth()); @@ -2060,9 +2063,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { Self; public void handle(Throwable throwable) { ErrorDialog dialog = new ErrorDialog(null, - Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), - Toolkit.i18nText("Fine-Design_Error_Start_Report"), - throwable.getMessage()) { + Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), + Toolkit.i18nText("Fine-Design_Error_Start_Report"), + throwable.getMessage()) { @Override protected void okEvent() { dispose(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index b48950485..f3f45768f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -44,7 +44,6 @@ public class UIResizableContainer extends JPanel { private boolean isDownPaneVisible = true ; private int paraHeight; private int parentHeight = -1; - private double toolPaneYRate; public UIResizableContainer(int direction) { this(new JPanel(), new JPanel(), direction); @@ -157,20 +156,12 @@ public class UIResizableContainer extends JPanel { return this.toolPaneY; } - /** - * 获取上子面板高度占容器总高度的比例 - * @return - */ - public double getToolPaneYRate() { - return toolPaneYRate; - } - /** * 设置关闭设计器前最新的上子面板的高度比例 - * @param toolPaneYRate + * @param toolPaneY */ - public void setLastToolPaneYRate(double toolPaneYRate) { - this.toolPaneYRate = toolPaneYRate; + public void setLastToolPaneY(int toolPaneY) { + this.toolPaneY = toolPaneY; } /** @@ -248,9 +239,10 @@ public class UIResizableContainer extends JPanel { if (parentHeight == -1) { // 初始化下parentheight,存一下当前的父容器height parentHeight = parent.getHeight(); - } else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) { - // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY - toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); + } + if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) { + // 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失 + toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight); parentHeight = parent.getHeight(); } } @@ -376,7 +368,6 @@ public class UIResizableContainer extends JPanel { toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); - adjustToolPaneYRate(); refreshContainer(); } }); @@ -398,10 +389,8 @@ public class UIResizableContainer extends JPanel { public void mouseClicked(MouseEvent e) { if (e.getX() <= ARROW_RANGE) { toolPaneY = 0; - UIResizableContainer.this.adjustToolPaneYRate(); } else if (e.getX() >= getWidth() - ARROW_RANGE) { toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); - UIResizableContainer.this.adjustToolPaneYRate(); } else { return; } @@ -562,11 +551,4 @@ public class UIResizableContainer extends JPanel { jf.setSize(500, 500); jf.setVisible(true); } - - /** - * 当toolPaneY发生变化时,也需要调整toolPaneYRate - */ - private void adjustToolPaneYRate() { - this.toolPaneYRate = ((double) toolPaneY) / this.getHeight(); - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index a5eafa0c0..490b4e7e9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -1170,8 +1170,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } - DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneYRate( - WestRegionContainerPane.getInstance().getToolPaneYRate()); + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( + WestRegionContainerPane.getInstance().getToolPaneY()); DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( WestRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 358fba411..004fbd55a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -24,7 +24,7 @@ public class WestRegionContainerPane extends UIResizableContainer { public static final WestRegionContainerPane getInstance() { if (THIS == null) { THIS = new WestRegionContainerPane(); - THIS.setLastToolPaneYRate(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneYRate()); + THIS.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); } return THIS; From ff0ded7b125833d461601b16c696a3f84ea80f44 Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 11 Dec 2020 11:36:12 +0800 Subject: [PATCH 09/51] =?UTF-8?q?REPORT-44714=20=E3=80=9010.0.12=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AE=B0=E5=BD=95=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=B1=E6=95=88=20=E5=B0=86=E5=AF=B9?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=96=87=E4=BB=B6=E7=9A=84=E8=AF=AF=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E5=9B=9E=E9=80=80=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/DesignerEnvManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 83f8133d7..791d679b3 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -2063,9 +2063,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { Self; public void handle(Throwable throwable) { ErrorDialog dialog = new ErrorDialog(null, - Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), - Toolkit.i18nText("Fine-Design_Error_Start_Report"), - throwable.getMessage()) { + Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), + Toolkit.i18nText("Fine-Design_Error_Start_Report"), + throwable.getMessage()) { @Override protected void okEvent() { dispose(); From f0edaca90666027a2eed9fd04f5363a78f18dc5f Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 11 Dec 2020 11:59:01 +0800 Subject: [PATCH 10/51] =?UTF-8?q?REPORT-44714=20=E3=80=9010.0.12=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AE=B0=E5=BD=95=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=B1=E6=95=88=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E9=9C=80=E8=A6=81=E5=9C=A8?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E7=89=88=E6=9C=AC=E5=8F=91=E5=B8=83=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E4=B8=80=E4=BB=BD=E5=88=B0final=20=E3=80=90=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E6=94=B9=E5=8A=A8=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=9C=A8release=E4=B8=AD=E9=80=9A=E8=BF=87=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E4=B8=80=E4=BB=BD=E5=88=B0final?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icontainer/UIResizableContainer.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index 0a8529abf..54ed4d18a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -45,6 +45,7 @@ public class UIResizableContainer extends JPanel { private boolean isLeftRightDragEnabled = true; private boolean isDownPaneVisible = true ; private int paraHeight; + private int parentHeight = -1; public UIResizableContainer(int direction) { this(new JPanel(), new JPanel(), direction); @@ -207,7 +208,8 @@ public class UIResizableContainer extends JPanel { if (verticalToolPane == null || downPane == null) { return; } - + // REPORT-42913 如果用户修改了分辨率或者dpi,可能造成toolPaneY大于parent.getHeight,整个downPane将丢失,因此这里调整下toolPaneY + adjustToolPaneY(parent); if (direction == Constants.RIGHT) { if(isDownPaneVisible){ upPane.setBounds(0, 0, containerWidth - toolPaneHeight, toolPaneY); @@ -236,6 +238,18 @@ public class UIResizableContainer extends JPanel { } } + private void adjustToolPaneY(Container parent) { + if (parentHeight == -1) { + // 初始化下parentheight,存一下当前的父容器height + parentHeight = parent.getHeight(); + } + if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) { + // 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失 + toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight); + parentHeight = parent.getHeight(); + } + } + @Override public void addLayoutComponent(String name, Component comp) { } @@ -540,4 +554,4 @@ public class UIResizableContainer extends JPanel { jf.setSize(500, 500); jf.setVisible(true); } -} \ No newline at end of file +} From 8c138328e230149c1643abb9addac9afb824cd53 Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 11 Dec 2020 16:09:10 +0800 Subject: [PATCH 11/51] =?UTF-8?q?REPORT-45095=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F&=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../write/submit/DBManipulationPane.java | 45 +++++++------------ .../submit/SmartInsertDBManipulationPane.java | 2 +- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index 1e1ab1f72..46b11d2a8 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -697,7 +697,7 @@ public class DBManipulationPane extends BasicBeanPane { ((DefaultCellEditor) column1.getCellEditor()).setClickCountToStart(2); //设置Column 2的Editor - column2.setCellEditor(new ColumnValueEditor(DBManipulationPane.this)); + column2.setCellEditor(new ColumnValueEditor()); } @Override @@ -864,43 +864,19 @@ public class DBManipulationPane extends BasicBeanPane { */ private final UILabel textLabel; private final ValuePane vPane; - private final BasicDialog vPaneDLG; - private Component parent; - /** - * 列值编辑器 - * - * @param parent 父组件,通过指定父组件启动下一级子窗口 - */ - protected ColumnValueEditor(Component parent) { - this(v_Types, parent); - } - - @Deprecated protected ColumnValueEditor() { - this(v_Types, null); + this(v_Types); } /** * 列值编辑器 * - * @param types 编辑器类型 - * @param parent 父组件,通过指定父组件启动下一级子窗口 + * @param types 编辑器类型 */ - protected ColumnValueEditor(Editor[] types, Component parent) { + protected ColumnValueEditor(Editor[] types) { textLabel = new UILabel(); - textLabel.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - vPaneDLG.setVisible(true); - } - }); - - vPane = new ValuePane(types); - Window window = parent == null - ? DesignerContext.getDesignerFrame() - : SwingUtilities.getWindowAncestor(parent); - vPaneDLG = vPane.showSmallWindow(window, new DialogActionAdapter() { + DialogActionAdapter adapter = new DialogActionAdapter() { @Override public void doOk() { fireEditingStopped(); // Make the renderer @@ -912,7 +888,18 @@ public class DBManipulationPane extends BasicBeanPane { public void doCancel() { fireEditingCanceled(); } + }; + textLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + Window window = e.getComponent() == null + ? DesignerContext.getDesignerFrame() + : SwingUtilities.getWindowAncestor(e.getComponent()); + vPane.showSmallWindow(window, adapter) + .setVisible(true); + } }); + vPane = new ValuePane(types); } /* diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index 4c283cd71..d306bb179 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -356,7 +356,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { if (isCellGroup) { column2.setCellRenderer(new ColumnRowGroupCellRenderer2()); - column2.setCellEditor(new ColumnValueEditor(ValueEditorPaneFactory.cellGroupEditor(), this)); + column2.setCellEditor(new ColumnValueEditor(ValueEditorPaneFactory.cellGroupEditor())); } else { column2.setCellRenderer(new SelectedColumnValueTableCellRenderer()); } From 21c4355bcbbce04172e455397e2d7914d0784efb Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 11 Dec 2020 17:27:36 +0800 Subject: [PATCH 12/51] =?UTF-8?q?REPORT-44961=20=E3=80=9010.0.12=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E9=99=84=E4=BB=B6=E6=A8=A1=E6=9D=BF=E6=89=93?= =?UTF-8?q?=E5=BC=80=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=8D=A1=E6=AD=BB=EF=BC=8C?= =?UTF-8?q?=E4=B8=94=E5=B8=83=E5=B1=80=E5=8F=91=E7=94=9F=E5=8F=98=E5=8C=96?= =?UTF-8?q?=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91?= =?UTF-8?q?=E5=B8=A6=E6=9C=89=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E7=9A=84?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=8E=A7=E4=BB=B6=EF=BC=8C=E5=9C=A8=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=97=B6=E5=80=99=E4=BC=9A=E5=8E=BB=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E8=8E=B7=E5=8F=96=E5=AD=97=E6=AE=B5=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E7=B3=BB=E7=BB=9F=E4=B8=AD=E6=9C=89=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BC=9A=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E5=81=87=E6=AD=BB=E3=80=82=E5=A6=82=E6=9E=9C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=BF=99=E4=B8=AA=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E7=9A=84=E5=90=8D=E5=AD=97=EF=BC=8C=E9=82=A3=E4=B9=88=E4=BC=9A?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8A=A5=E9=94=99=E4=B8=8D=E4=BC=9A=E5=81=87?= =?UTF-8?q?=E6=AD=BB=E3=80=82=E4=B8=BB=E8=A6=81=E8=BF=98=E6=98=AF=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E6=93=8D=E4=BD=9C=E6=98=AF=E8=80=97?= =?UTF-8?q?=E6=97=B6=E6=93=8D=E4=BD=9C=EF=BC=8C=E4=B8=8D=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E5=9C=A8UI=E7=BA=BF=E7=A8=8B=E8=BF=9B=E8=A1=8C=E8=80=97?= =?UTF-8?q?=E6=97=B6=E6=93=8D=E4=BD=9C=E3=80=82=20=E3=80=90=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E4=B8=BB=E8=A6=81=E5=88=86?= =?UTF-8?q?=E4=B8=BA=E4=B8=A4=E9=83=A8=E5=88=86=EF=BC=8C=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=98=AF=E5=B0=86=E5=8E=9F=E6=9C=AC=E7=9A=84tdChange()?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E4=B8=AD=E7=9A=84=E8=80=97=E6=97=B6=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=94=BE=E5=88=B0SwingWorker=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=BA=BF=E7=A8=8B=E4=B8=AD=EF=BC=8C=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=E8=AF=9D=E5=8D=B3=E4=BD=BF=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E4=B9=9F=E4=B8=8D=E4=BC=9A=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E9=98=BB=E5=A1=9E=E7=9B=B4=E5=88=B0=E9=87=8D=E8=BF=9E?= =?UTF-8?q?=E8=B6=85=E6=97=B6=EF=BC=9B=E7=AC=AC=E4=BA=8C=E6=98=AF=E5=BA=94?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=9A=84=E8=A6=81=E6=B1=82=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E6=8E=A7=E4=BB=B6=E5=B0=B1=E4=BC=9A=E5=8E=BB?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=BF=9E=E6=8E=A5=E5=B9=B6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=B1=9E=E4=BA=8E=E5=BD=93=E5=89=8D=E6=8E=A7=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E5=88=97=E5=90=8D=E8=BF=99=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=94=A8=E6=88=B7=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=8F=B3=E4=BE=A7=E9=9D=A2=E6=9D=BF=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E6=97=81=E8=BE=B9=E7=9A=84?= =?UTF-8?q?button=E7=9A=84=E6=97=B6=E5=80=99=E6=89=8D=E4=BC=9A=E5=8E=BB?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=BF=9E=E6=8E=A5=EF=BC=8C=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2=E5=BD=93=E5=89=8D=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=88=97=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccessibleDictionaryEditor.java | 3 +- .../design/present/dict/DictionaryPane.java | 4 + .../present/dict/TableDataDictPane.java | 103 +++++++++++------- 3 files changed, 71 insertions(+), 39 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java index c2195512a..6be31c526 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java @@ -21,6 +21,7 @@ public class AccessibleDictionaryEditor extends UneditableAccessibleEditor { protected void showEditorPane() { if (dictPane == null) { dictPane = new DictionaryPane(); + dictPane.setNeedTableDataChange(true); } BasicDialog dlg = dictPane.showWindow(SwingUtilities.getWindowAncestor(this)); @@ -58,4 +59,4 @@ public class AccessibleDictionaryEditor extends UneditableAccessibleEditor { public Dictionary updateBean() { return (Dictionary) this.getValue(); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java b/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java index e50ed86b9..f74138be5 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java @@ -83,4 +83,8 @@ public class DictionaryPane extends UIComboBoxPane implements DataCr public void registerDSChangeListener() { tableDataDictPane.registerDSChangeListener(); } + + public void setNeedTableDataChange(boolean needTableDataChange) { + tableDataDictPane.setNeedTableDataChange(needTableDataChange); + } } diff --git a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java index 3c08c1c9d..53801293a 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java @@ -31,17 +31,20 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - +import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingWorker; +import java.awt.BorderLayout; +import java.awt.Component; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutionException; /** * 数据字典的数据查询面板 @@ -60,6 +63,8 @@ public class TableDataDictPane extends FurtherBasicBeanPane private DoubleDeckValueEditorPane valueDictPane; private ItemListener itemListener; private UIObserverListener uiObserverListener; + private FormulaEditor localFormulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); + private boolean needTableDataChange = false; public TableDataDictPane() { initBasicComponets(); @@ -67,6 +72,14 @@ public class TableDataDictPane extends FurtherBasicBeanPane iniListener(); } + /** + * 设置为true后,一旦触发TableDataComboBox的itemChange,就会通过数据连接,更换当前数据字典的列名List + * @param needTableDataChange + */ + public void setNeedTableDataChange(boolean needTableDataChange) { + this.needTableDataChange = needTableDataChange; + } + public static void main(String[] args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -80,11 +93,9 @@ public class TableDataDictPane extends FurtherBasicBeanPane private void initBasicComponets() { tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); - tableDataNameComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - tdChange(e); - } + tableDataNameComboBox.addItemListener(e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + tdChange(e, needTableDataChange); } }); // keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); @@ -153,44 +164,60 @@ public class TableDataDictPane extends FurtherBasicBeanPane return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dic_Data_Query"); } - private void tdChange(final ItemEvent e) { + private void tdChange(final ItemEvent e, boolean needTableDataChange) { TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); if (tableDataWrappe == null) { return; } - - List namelist = tableDataWrappe.calculateColumnNameList(); - String[] columnNames = null; - if (!namelist.isEmpty()) { - columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); - } else { - columnNames = new String[]{""}; + if (itemListener != null) { + itemListener.itemStateChanged(e); + localFormulaEditor.addChangeListener(event -> itemListener.itemStateChanged(e)); } - ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); - columnNameEditor1.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor1.addItemListener(itemListener); - keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); + if (needTableDataChange) { + changeColumnsName(); + } + } - FormulaEditor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); - formulaEditor.setEnabled(true); - formulaEditor.addChangeListener(new ChangeListener() { + private void changeColumnsName() { + TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); + SwingWorker, Object> worker = new SwingWorker, Object>() { + @Override + protected List doInBackground() { + if (tableDataWrappe == null) { + return new ArrayList<>(); + } + return tableDataWrappe.calculateColumnNameList(); + } @Override - public void stateChanged(ChangeEvent ee) { - if (itemListener != null) { - itemListener.itemStateChanged(e); + protected void done() { + try { + List namelist = get(); + String[] columnNames = null; + if (!namelist.isEmpty()) { + columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); + } else { + columnNames = new String[]{""}; + } + ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); + columnNameEditor1.addItemListener(itemListener); + ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); + columnIndexEditor1.addItemListener(itemListener); + keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); + + localFormulaEditor.setEnabled(true); + + ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); + columnNameEditor2.addItemListener(itemListener); + ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); + columnIndexEditor2.addItemListener(itemListener); + valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, localFormulaEditor}, columnNames[0]); + } catch (InterruptedException | ExecutionException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - }); - ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); - columnNameEditor2.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor2.addItemListener(itemListener); - valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]); - if (itemListener != null) { - itemListener.itemStateChanged(e); - } + }; + worker.execute(); } @Override From b7987f61f8e4f436620e58f33caf0e427b4dc31f Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 11 Dec 2020 17:31:18 +0800 Subject: [PATCH 13/51] =?UTF-8?q?REPORT-44961=20=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E9=87=8C=E5=85=88=E4=B8=8D=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/tabledata/wrapper/AbstractTableDataWrapper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java index ceb0bd8b6..3f1068d01 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java @@ -63,8 +63,7 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false); } catch (Exception e) { if (e.getMessage()!=null) { - // 这个弹窗可能会成为数据字典页面的二级弹窗,所以修改下父窗口避免出现mac下的二级弹窗问题 - FineJOptionPane.showMessageDialog(null, e.getMessage()); + DesignUtils.errorMessage(e.getMessage()); } } columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); From cb919feb8b42eb4796a0ebc84665c6b6836957d6 Mon Sep 17 00:00:00 2001 From: vito Date: Sun, 13 Dec 2020 09:55:07 +0800 Subject: [PATCH 14/51] =?UTF-8?q?REPORT-45095=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E8=AE=BE=E7=BD=AE=E6=8F=90=E4=BA=A4=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=E5=90=8E?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../write/submit/DBManipulationPane.java | 1736 +++++++++-------- .../submit/SmartInsertDBManipulationPane.java | 4 +- 2 files changed, 884 insertions(+), 856 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index ccf01dd5e..46b11d2a8 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -53,7 +53,6 @@ import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; -import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -74,6 +73,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Image; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; @@ -92,136 +92,133 @@ public class DBManipulationPane extends BasicBeanPane { private static final Image ICODS_IMAGE = BaseUtils.readImage("/com/fr/web/core/css/images/icons.png"); private static final Icon HEIP_ICON = BaseUtils.createIcon(ICODS_IMAGE, 193, 1, 14, 14); private static final int DEFAULT_RETURN_VALUE = 4; - public KeyColumnNameValueTable keyColumnValuesTable; - private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor + public KeyColumnNameValueTable keyColumnValuesTable; + private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor private UICheckBox UpdateCheckBox; private JPanel checkBoxUpdatePane; - /* - * 记录当前选取的DS & Table对应的ColumnName[] - * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 - */ - private ColumnName[] currentColumnNames = null; + /* + * 记录当前选取的DS & Table对应的ColumnName[] + * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 + */ + private ColumnName[] currentColumnNames = null; - // 支持公式输入的数据表选择面板 - private ChoosePaneSupportFormula chooseTable; + // 支持公式输入的数据表选择面板 + private ChoosePaneSupportFormula chooseTable; - private UIComboBox dmlConfigComboBox = null; + private UIComboBox dmlConfigComboBox = null; - // 提交事件 - private NameSubmitJob[] jobs = null; + // 提交事件 + private NameSubmitJob[] jobs = null; - // 提交条件 - private Condition condition = null; + // 提交条件 + private Condition condition = null; - private JTree conditionsTree; + private JTree conditionsTree; - private Editor[] v_Types; + private Editor[] v_Types; - protected JavaScriptActionPane parentPane; + protected JavaScriptActionPane parentPane; - private int keyColumnWidth = 100; - private int resizeColumnCount = 4; - private int btnWidth = 110; - private int btnHeight = 20; private String subMitName; - private static final String[] DML_CONFIG_TYPES = new String[] { + private static final String[] DML_CONFIG_TYPES = new String[]{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Smart_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Delete_Submit"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Update_Submit")}; - /** - * 无单元格。没有智能添加单元格等按钮 - * 有单元格的参见其子类SmartInsertDBManipulationPane - */ - public DBManipulationPane() { - this(ValueEditorPaneFactory.extendedCellGroupEditors()); - } + /** + * 无单元格。没有智能添加单元格等按钮 + * 有单元格的参见其子类SmartInsertDBManipulationPane + */ + public DBManipulationPane() { + this(ValueEditorPaneFactory.extendedCellGroupEditors()); + } - public DBManipulationPane(Editor[] v_Types) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.v_Types = v_Types; + public DBManipulationPane(Editor[] v_Types) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.v_Types = v_Types; - JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(northPane, BorderLayout.NORTH); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(northPane, BorderLayout.NORTH); - dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); + dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); - JPanel typePane = GUICoreUtils.createFlowPane(new Component[] { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox }, - FlowLayout.LEFT, 10); - typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); - northPane.add(typePane, BorderLayout.NORTH); + JPanel typePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox}, + FlowLayout.LEFT, 10); + typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); + northPane.add(typePane, BorderLayout.NORTH); - chooseTable = new ChoosePaneSupportFormula(); - chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); - chooseTable.setTableNameComboBoxPopSize(160, 320); + chooseTable = new ChoosePaneSupportFormula(); + chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); + chooseTable.setTableNameComboBoxPopSize(160, 320); - northPane.add(chooseTable, BorderLayout.CENTER); + northPane.add(chooseTable, BorderLayout.CENTER); - // peter:编辑的TablePane - JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(editTablePane, BorderLayout.CENTER); - editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); + // peter:编辑的TablePane + JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(editTablePane, BorderLayout.CENTER); + editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); - keyColumnValuesTable = new KeyColumnNameValueTable(); - editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); - keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); - keyColumnValuesTable.setShowHorizontalLines(true); + keyColumnValuesTable = new KeyColumnNameValueTable(); + editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); + keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); + keyColumnValuesTable.setShowHorizontalLines(true); - initJTableColumn(); + initJTableColumn(); - addButtons(editTablePane); + addButtons(editTablePane); - addBottomPane(); + addBottomPane(); - addListeners(); - } + addListeners(); + } - public void setSubMitName(String subMitName){ + public void setSubMitName(String subMitName) { this.subMitName = subMitName; } - public String getSubMitName(){ + public String getSubMitName() { return this.subMitName; } - private void addButtons(JPanel editTablePane) { - // alex:添加操作按钮 - UpdateAction[] actions = this.getActions(); - if (actions != null && actions.length > 0) { - JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); - editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); + private void addButtons(JPanel editTablePane) { + // alex:添加操作按钮 + UpdateAction[] actions = this.getActions(); + if (actions != null && actions.length > 0) { + JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); + editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); - for (int i = 0; i < actions.length; i++) { - controlBtnPane.add(new UIButton(actions[i])); - } + for (UpdateAction action : actions) { + controlBtnPane.add(new UIButton(action)); + } checkBoxUpdatePane = new JPanel(new BorderLayout(0, 0)); - checkBoxUpdatePane.setPreferredSize(new Dimension(120,20)); + checkBoxUpdatePane.setPreferredSize(new Dimension(120, 20)); controlBtnPane.add(checkBoxUpdatePane); UpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_NotChange_Unmodified")); - UIButton helpButton = new UIButton(HEIP_ICON); + UIButton helpButton = new UIButton(HEIP_ICON); helpButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help")); helpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); + FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); BasicDialog dlg = formatExplanation.showMediumWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - new DialogActionAdapter(){}); + new DialogActionAdapter() { + }); dlg.setVisible(true); } }); helpButton.set4ToolbarButton(); - checkBoxUpdatePane.add(UpdateCheckBox,BorderLayout.WEST); - checkBoxUpdatePane.add(helpButton,BorderLayout.EAST); - } - } - - protected void updateUpdateCheckBoxEnable(){ - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - if (model.getRowCount() == 0){ + checkBoxUpdatePane.add(UpdateCheckBox, BorderLayout.WEST); + checkBoxUpdatePane.add(helpButton, BorderLayout.EAST); + } + } + + protected void updateUpdateCheckBoxEnable() { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + if (model.getRowCount() == 0) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(true); return; @@ -230,9 +227,8 @@ public class DBManipulationPane extends BasicBeanPane { for (int i = 0; i < model.getRowCount(); i++) { columnObjects.add(model.getKeyColumnNameValue(i).cv.getObj()); } - for (int i = 0;i < columnObjects.size();i++){ - Object ob = columnObjects.get(i) ; - if (!( ob instanceof ColumnRow || ob instanceof ColumnRowGroup)){ + for (Object ob : columnObjects) { + if (!(ob instanceof ColumnRow || ob instanceof ColumnRowGroup)) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(false); return; @@ -241,236 +237,241 @@ public class DBManipulationPane extends BasicBeanPane { setUpdateCheckBoxEnable(true); } - private void setUpdateCheckBoxEnable( boolean b){ + private void setUpdateCheckBoxEnable(boolean b) { UpdateCheckBox.setEnabled(b); } - private void addBottomPane() { - JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - eventPane.add(addEventButton()); + private void addBottomPane() { + JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + eventPane.add(addEventButton()); - JPanel conditionPane = this.createConditionPane(); + JPanel conditionPane = this.createConditionPane(); - JPanel btPane =new JPanel( FRGUIPaneFactory.createBorderLayout()); - btPane.add(eventPane,BorderLayout.CENTER); - btPane.add(conditionPane,BorderLayout.NORTH); - this.add(btPane, BorderLayout.SOUTH); - } + JPanel btPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + btPane.add(eventPane, BorderLayout.CENTER); + btPane.add(conditionPane, BorderLayout.NORTH); + this.add(btPane, BorderLayout.SOUTH); + } - private UIButton addEventButton() { - UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); - addSubmitEventButton.addActionListener(new ActionListener() { + private UIButton addEventButton() { + UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); + addSubmitEventButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final SubmitJobListPane jobsPane = createSubmitJobListPane(); + @Override + public void actionPerformed(ActionEvent e) { + final SubmitJobListPane jobsPane = createSubmitJobListPane(); - jobsPane.populate(jobs); - BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - jobs = jobsPane.updateDBManipulation(); - } - }); - dialog.setVisible(true); - } + jobsPane.populate(jobs); + BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + jobs = jobsPane.updateDBManipulation(); + } + }); + dialog.setVisible(true); + } - }); - return addSubmitEventButton; - } + }); + return addSubmitEventButton; + } - private JPanel createConditionPane() { - JPanel conditionPane = new JPanel(); - conditionPane.setPreferredSize(createConditionPanePreferredSize()); + private JPanel createConditionPane() { + JPanel conditionPane = new JPanel(); + conditionPane.setPreferredSize(createConditionPanePreferredSize()); setBorderAndLayout(conditionPane); - conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); - conditionsTree.setRootVisible(false); - conditionsTree.setShowsRootHandles(true); - conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); - conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); - DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); - cr.setForeground(UIConstants.NORMAL_BACKGROUND); - JScrollPane jp = new JScrollPane(conditionsTree); - addComponent(conditionPane,jp); - - UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); - addSubmitConditionButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { - @Override - protected boolean isNeedDoWithCondition(Condition liteCondition) { - return liteCondition != null; - } - }; - String[] columns = chooseTable.currentColumnNames(); - if (columns != null && columns.length > 0) { - conditionPane.populateColumns(chooseTable.currentColumnNames()); - } - - conditionPane.populateBean(condition); - BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - condition = conditionPane.updateBean(); - refreshConditionList(); - } - }); - dialog.setVisible(true); - } - }); - - JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); + conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); + conditionsTree.setRootVisible(false); + conditionsTree.setShowsRootHandles(true); + conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); + conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); + DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); + cr.setForeground(UIConstants.NORMAL_BACKGROUND); + JScrollPane jp = new JScrollPane(conditionsTree); + addComponent(conditionPane, jp); + + UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); + addSubmitConditionButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { + @Override + protected boolean isNeedDoWithCondition(Condition liteCondition) { + return liteCondition != null; + } + }; + String[] columns = chooseTable.currentColumnNames(); + if (columns != null && columns.length > 0) { + conditionPane.populateColumns(chooseTable.currentColumnNames()); + } + + conditionPane.populateBean(condition); + BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + condition = conditionPane.updateBean(); + refreshConditionList(); + } + }); + dialog.setVisible(true); + } + }); + + JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); controlBtnPane.setPreferredSize(createControlBtnPanePreferredSize()); - conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH),setControlBtnPanePosition()); - controlBtnPane.add(addSubmitConditionButton); + conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), setControlBtnPanePosition()); + controlBtnPane.add(addSubmitConditionButton); - return conditionPane; - } + return conditionPane; + } - protected void setBorderAndLayout(JPanel jPanel){ + protected void setBorderAndLayout(JPanel jPanel) { jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); jPanel.setBorder(BorderFactory.createTitledBorder( - new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); + new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); } - protected void addComponent(JPanel mainPane,JScrollPane addPane){ - mainPane.add(addPane,BorderLayout.CENTER); + protected void addComponent(JPanel mainPane, JScrollPane addPane) { + mainPane.add(addPane, BorderLayout.CENTER); } - protected Dimension createConditionPanePreferredSize(){ + protected Dimension createConditionPanePreferredSize() { return new Dimension(454, 80); } - protected Dimension createControlBtnPanePreferredSize(){ + protected Dimension createControlBtnPanePreferredSize() { return new Dimension(110, 20); } - protected String setControlBtnPanePosition(){ - return BorderLayout.EAST; + protected String setControlBtnPanePosition() { + return BorderLayout.EAST; + } + + private void refreshConditionList() { + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); + ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); + rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); + rootTreeNode.removeAllChildren(); + Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); + } + } else { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); + rootTreeNode.add(newTreeNode); + } + defaultTreeModel.reload(rootTreeNode); + rootTreeNode.expandCurrentTreeNode(conditionsTree); + } + + private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); + parentTreeNode.add(newTreeNode); + Condition liteCondition = joinCondition.getCondition(); + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); + } + } + } + + private void addListeners() { + dmlConfigComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + Object ob = e.getItem(); + if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { + checkBoxUpdatePane.setVisible(true); + } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { + checkBoxUpdatePane.setVisible(false); + } + } + } + }); + + /* + * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, + * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 + * 也不能在tableNameComboBox.focusLost事件时,好像没用 + */ + keyColumnValuesTable.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + refreshColumnsComboBox(); + } + + }); + } + + protected UpdateAction[] getActions() { + return new UpdateAction[]{new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction()}; + } + + protected SubmitJobListPane createSubmitJobListPane() { + return new SubmitJobListPane(); + } + + public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { + this.parentPane = jsPane; + } + + @Override + protected String title4PopupWindow() { + return "DB"; } - private void refreshConditionList() { - DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); - ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); - rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); - rootTreeNode.removeAllChildren(); - Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); - } - } else { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); - rootTreeNode.add(newTreeNode); - } - defaultTreeModel.reload(rootTreeNode); - rootTreeNode.expandCurrentTreeNode(conditionsTree); - } - - private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); - parentTreeNode.add(newTreeNode); - Condition liteCondition = joinCondition.getCondition(); - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); - } - } - } - - private void addListeners() { - dmlConfigComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - Object ob = e.getItem(); - if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { - checkBoxUpdatePane.setVisible(true); - } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { - checkBoxUpdatePane.setVisible(false); - } - } - } - }); - - /* - * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, - * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 - * 也不能在tableNameComboBox.focusLost事件时,好像没用 - */ - keyColumnValuesTable.addFocusListener(new FocusAdapter() { - - public void focusGained(FocusEvent e) { - refreshColumnsComboBox(); - } - - }); - } - - protected UpdateAction[] getActions() { - return new UpdateAction[] { new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction() }; - } - - protected SubmitJobListPane createSubmitJobListPane() { - return new SubmitJobListPane(); - } - - public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { - this.parentPane = jsPane; - } - - @Override - protected String title4PopupWindow() { - return "DB"; - } - - protected class SmartAddFieldsAction extends UpdateAction { - public SmartAddFieldsAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); - } - - public void actionPerformed(ActionEvent evt) { - - BasicPane bPane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); - } - }; - bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - - final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { - public String value2Text(Object value) { - if (value instanceof ColumnName) { - return ((ColumnName)value).name; - } - - return super.value2Text(value); - } - }; - bPane.add(new JScrollPane(list), BorderLayout.CENTER); - - BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - public void doOk() { - addFields(list); + protected class SmartAddFieldsAction extends UpdateAction { + public SmartAddFieldsAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + + BasicPane bPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); + } + }; + bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + + final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { + @Override + public String value2Text(Object value) { + if (value instanceof ColumnName) { + return ((ColumnName) value).name; + } + + return super.value2Text(value); + } + }; + bPane.add(new JScrollPane(list), BorderLayout.CENTER); + + BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + addFields(list); updateUpdateCheckBoxEnable(); - } - }); - dlg.setVisible(true); - } - } - - private void addFields (CheckBoxList list) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + } + }); + dlg.setVisible(true); + } + } + + private void addFields(CheckBoxList list) { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); List keyColumnNameValueList = new ArrayList(); keyColumnNameValueList.clear(); for (int i = 0; i < model.getRowCount(); i++) { @@ -481,28 +482,28 @@ public class DBManipulationPane extends BasicBeanPane { // Richie:用了存储新的KeyColumnNameValue的List. List newKeyColumnNameValueList = new ArrayList(); if (!keyColumnNameValueList.isEmpty()) { - for (int i = 0; i < selected.length; i++) { + for (Object o : selected) { // Richie:先填上空的. - newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } // Richie:初始化 int returnValue = DEFAULT_RETURN_VALUE; int coverNumber = 0; - if (!keyColumnNameValueList.isEmpty()) { - //如果存在先前项,设置状态为5 - returnValue = 5 ; - } + if (!keyColumnNameValueList.isEmpty()) { + //如果存在先前项,设置状态为5 + returnValue = 5; + } for (int i = 0; i < selected.length; i++) { if (returnValue == 0 || returnValue == 3) { break; } - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { - Object[] options = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None") }; + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { + Object[] options = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None")}; returnValue = JOptionPane.showOptionDialog(DBManipulationPane.this, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValueList.get(j).cn.name), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValue.cn.name), "", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); // Richie:全部覆盖 if (returnValue == 0) { @@ -514,7 +515,7 @@ public class DBManipulationPane extends BasicBeanPane { } else if (returnValue == 2) { coverNumber = i; newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); // Richie:全部不覆盖 } else if (returnValue == 3) { coverNumber = i; @@ -526,7 +527,7 @@ public class DBManipulationPane extends BasicBeanPane { checkTableModel(returnValue, coverNumber, model, selected, keyColumnNameValueList, newKeyColumnNameValueList); } - private void checkTableModel (int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { + private void checkTableModel(int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { if (returnValue == 0) { model.removeAllKeyColumnNameValue(); // Richie:全部覆盖,按selected的长度添加默认的行 @@ -538,10 +539,10 @@ public class DBManipulationPane extends BasicBeanPane { model.removeAllKeyColumnNameValue(); // Richie:全部不覆盖,已经存在的就保留,不存在的添加默认行 for (int i = coverNumber; i < selected.length; i++) { - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); } } @@ -552,610 +553,637 @@ public class DBManipulationPane extends BasicBeanPane { } } else if (returnValue == 1 || returnValue == 2) { - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } else if (returnValue == 5){ - //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } else if (returnValue == 5) { + //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } // Richie:初始化 if (keyColumnNameValueList.isEmpty()) { model.removeAllKeyColumnNameValue(); - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + for (Object o : selected) { + model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } - + model.fireTableDataChanged(); keyColumnValuesTable.validate(); } - protected class AddFieldAction extends UpdateAction { - public AddFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); - } + protected class AddFieldAction extends UpdateAction { + public AddFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); + } - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(ActionEvent e) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); - model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); + model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); updateUpdateCheckBoxEnable(); - model.fireTableDataChanged(); - - keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); - } - } - - protected class RemoveFieldAction extends UpdateAction { - public RemoveFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); - } - - public void actionPerformed(ActionEvent evt) { - // DBManipulationPane target = this.getDBManipulationPane(); - - int[] selectedRows = keyColumnValuesTable.getSelectedRows(); - if (selectedRows == null || selectedRows.length == 0) { - return; - } - - int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.OK_OPTION) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - - // 把selectedRows从小到大排个序,先删大的再删小的 - java.util.Arrays.sort(selectedRows); - for (int i = selectedRows.length - 1; i >= 0; i--) { - keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); - } + model.fireTableDataChanged(); + + keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); + } + } + + protected class RemoveFieldAction extends UpdateAction { + public RemoveFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + // DBManipulationPane target = this.getDBManipulationPane(); + + int[] selectedRows = keyColumnValuesTable.getSelectedRows(); + if (selectedRows == null || selectedRows.length == 0) { + return; + } + + int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.OK_OPTION) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + + // 把selectedRows从小到大排个序,先删大的再删小的 + java.util.Arrays.sort(selectedRows); + for (int i = selectedRows.length - 1; i >= 0; i--) { + keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); + } updateUpdateCheckBoxEnable(); - keyColumnNameValueTableModel.fireTableDataChanged(); - - // select other one. - if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); - } else if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - } - } - - /* - * 刷新columnsComboBox - */ - private void refreshColumnsComboBox() { - DefaultComboBoxModel model = (DefaultComboBoxModel)this.columnsComboBox.getModel(); - model.removeAllElements(); - - ColumnName[] columnNames = currentColumnNames(); - for (int i = 0; i < columnNames.length; i++) { - model.addElement(columnNames[i]); - } - } - - // 得到当前的ColumnName[] - private ColumnName[] currentColumnNames() { - // ben:清除原有的 - if (currentColumnNames != null) { - currentColumnNames = null; - } - String[] colNames = this.chooseTable.currentColumnNames(); - int len = colNames.length; - currentColumnNames = new ColumnName[len]; - for (int i = 0; i < len; i++) { - currentColumnNames[i] = new ColumnName(colNames[i]); - } - return currentColumnNames; - } - - /* - * 设置JTable的Column - */ - private void initJTableColumn() { - TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); - column0.setMaxWidth(50); - - TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); - column1.setCellRenderer(new ColumnNameTableCellRenderer()); - - TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); - column2.setCellRenderer(new ColumnValueTableCellRenderer()); - - // 设置column1的editor - columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); - columnsComboBox.setRenderer(new UIComboBoxRenderer() { - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - - }); - column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { - public boolean stopCellEditing() { - if (super.stopCellEditing()) { - return true; - } - - return false; - } - }); - ((DefaultCellEditor)column1.getCellEditor()).setClickCountToStart(2); - - //设置Column 2的Editor - column2.setCellEditor(new ColumnValueEditor()); - } - - public void populateBean(DBManipulation dbManipulation) { - if (dbManipulation == null) { - dbManipulation = new DBManipulation(); - } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // select other one. + if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); + } else if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + } + } + + /* + * 刷新columnsComboBox + */ + private void refreshColumnsComboBox() { + DefaultComboBoxModel model = (DefaultComboBoxModel) this.columnsComboBox.getModel(); + model.removeAllElements(); + + ColumnName[] columnNames = currentColumnNames(); + for (ColumnName columnName : columnNames) { + model.addElement(columnName); + } + } + + // 得到当前的ColumnName[] + private ColumnName[] currentColumnNames() { + // ben:清除原有的 + if (currentColumnNames != null) { + currentColumnNames = null; + } + String[] colNames = this.chooseTable.currentColumnNames(); + int len = colNames.length; + currentColumnNames = new ColumnName[len]; + for (int i = 0; i < len; i++) { + currentColumnNames[i] = new ColumnName(colNames[i]); + } + return currentColumnNames; + } + + /* + * 设置JTable的Column + */ + private void initJTableColumn() { + TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); + column0.setMaxWidth(50); + + TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); + column1.setCellRenderer(new ColumnNameTableCellRenderer()); + + TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); + column2.setCellRenderer(new ColumnValueTableCellRenderer()); + + // 设置column1的editor + columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); + columnsComboBox.setRenderer(new UIComboBoxRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + + }); + column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { + @Override + public boolean stopCellEditing() { + return super.stopCellEditing(); + } + }); + ((DefaultCellEditor) column1.getCellEditor()).setClickCountToStart(2); + + //设置Column 2的Editor + column2.setCellEditor(new ColumnValueEditor()); + } + + @Override + public void populateBean(DBManipulation dbManipulation) { + if (dbManipulation == null) { + dbManipulation = new DBManipulation(); + } subMitName = dbManipulation.getName(); - DMLConfig dmlConfig = dbManipulation.getDmlConfig(); - - if (dmlConfig != null) { - if (dmlConfig instanceof IntelliDMLConfig) { - dmlConfigComboBox.setSelectedIndex(0); - } else if (dmlConfig instanceof DeleteConfig) { - dmlConfigComboBox.setSelectedIndex(1); - } else if (dmlConfig instanceof InsertConfig) { - dmlConfigComboBox.setSelectedIndex(2); - } else if (dmlConfig instanceof UpdateConfig) { - dmlConfigComboBox.setSelectedIndex(3); - } else { - dmlConfigComboBox.setSelectedIndex(0); - } - jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; - for (int i = 0; i < jobs.length; i++) { - jobs[i] = dmlConfig.getNameSubmitJob(i); - } - condition = dmlConfig.getCondition(); + DMLConfig dmlConfig = dbManipulation.getDmlConfig(); + + if (dmlConfig != null) { + if (dmlConfig instanceof IntelliDMLConfig) { + dmlConfigComboBox.setSelectedIndex(0); + } else if (dmlConfig instanceof DeleteConfig) { + dmlConfigComboBox.setSelectedIndex(1); + } else if (dmlConfig instanceof InsertConfig) { + dmlConfigComboBox.setSelectedIndex(2); + } else if (dmlConfig instanceof UpdateConfig) { + dmlConfigComboBox.setSelectedIndex(3); + } else { + dmlConfigComboBox.setSelectedIndex(0); + } + jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; + for (int i = 0; i < jobs.length; i++) { + jobs[i] = dmlConfig.getNameSubmitJob(i); + } + condition = dmlConfig.getCondition(); UpdateCheckBox.setSelected(dmlConfig.isUpdateSelected()); - } else { - jobs = null; - condition = null; - dmlConfigComboBox.setSelectedIndex(0); + } else { + jobs = null; + condition = null; + dmlConfigComboBox.setSelectedIndex(0); UpdateCheckBox.setSelected(false); - } + } - String schema = null; - String tableName = null; + String schema = null; + String tableName = null; Table table = null; - if (dmlConfig != null && dmlConfig.getOriTable() != null) { + if (dmlConfig != null && dmlConfig.getOriTable() != null) { table = dmlConfig.getOriTable(); if (table != null) { schema = table.getSchema(); tableName = table.getName(); } } - chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); + chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); - populateKeyColumnValueTable(dmlConfig); + populateKeyColumnValueTable(dmlConfig); updateUpdateCheckBoxEnable(); - refreshConditionList(); - } - - private void populateKeyColumnValueTable(DMLConfig dmlConfig) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); - - if (dmlConfig != null) { - boolean acceptPara = false; - for (int i = 0; i < v_Types.length; i++) { - if (v_Types[i].accept(new Parameter())) { - acceptPara = true; - break; - } - } - for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { - ColumnConfig column = dmlConfig.getColumnConfig(i); - String columnName = column.getColumnName(); - if (!acceptPara && column.getColumnValue() instanceof Parameter) { - // 表单中,将以前的参数转换为公式 - column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter)column.getColumnValue()).getName())); - } - - KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), - column.isSkipUnmodified()); - keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); - } - } - keyColumnNameValueTableModel.fireTableDataChanged(); - - // 选择第一个 - if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - - public DBManipulation updateBean() { - DataBaseItems para = chooseTable.updateBean(true); - DBManipulation dbMani = new DBManipulation(); - dbMani.setName(subMitName); - dbMani.setDBName(para.getDatabaseName()); + refreshConditionList(); + } + + private void populateKeyColumnValueTable(DMLConfig dmlConfig) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); + + if (dmlConfig != null) { + boolean acceptPara = false; + for (int i = 0; i < v_Types.length; i++) { + if (v_Types[i].accept(new Parameter())) { + acceptPara = true; + break; + } + } + for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { + ColumnConfig column = dmlConfig.getColumnConfig(i); + String columnName = column.getColumnName(); + if (!acceptPara && column.getColumnValue() instanceof Parameter) { + // 表单中,将以前的参数转换为公式 + column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter) column.getColumnValue()).getName())); + } - DMLConfig dmlConfig = new IntelliDMLConfig(); - if (dmlConfigComboBox.getSelectedIndex() == 1) { - dmlConfig = new DeleteConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 2) { - dmlConfig = new InsertConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 3) { - dmlConfig = new UpdateConfig(); - } + KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), + column.isSkipUnmodified()); + keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); + } + } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // 选择第一个 + if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + + @Override + public DBManipulation updateBean() { + DataBaseItems para = chooseTable.updateBean(true); + DBManipulation dbMani = new DBManipulation(); + dbMani.setName(subMitName); + dbMani.setDBName(para.getDatabaseName()); + + DMLConfig dmlConfig = new IntelliDMLConfig(); + if (dmlConfigComboBox.getSelectedIndex() == 1) { + dmlConfig = new DeleteConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 2) { + dmlConfig = new InsertConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 3) { + dmlConfig = new UpdateConfig(); + } - dbMani.setDmlConfig(dmlConfig); + dbMani.setDmlConfig(dmlConfig); - dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); + dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); - for (int i = 0; i < rowCount; i++) { - KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); - // peter:先添加key column name. + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); + for (int i = 0; i < rowCount; i++) { + KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); + // peter:先添加key column name. - dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey,false)); - } + dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey, false)); + } dmlConfig.setUpdateSelected(UpdateCheckBox.isSelected()); - if (jobs != null) { - for (int i = 0; i < jobs.length; i++) { - dmlConfig.addSubmitJob(jobs[i]); - } - } - dmlConfig.setCondition(condition); - - return dbMani; - } - - protected class ValuePane extends BasicBeanPane { - ValueEditorPane vPane; - - public ValuePane() { - this(v_Types); - } - - public ValuePane(Editor[] types) { - vPane = new ValueEditorPane(types); - this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); - this.add(vPane); - vPane.setPreferredSize(new Dimension(220, 25)); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); - } - - public void populateBean(Object object) { - vPane.populate(object); - } - - @Override - public Object updateBean() { - return vPane.update(); - } - - } - - /* - * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 - */ - protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { - /** The Swing component being edited. */ - private UILabel textLabel; - private ValuePane vPane; - private BasicDialog vPaneDLG; - - protected ColumnValueEditor() { - this(v_Types); - } - - protected ColumnValueEditor(Editor[] types) { - textLabel = new UILabel(); - textLabel.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - vPaneDLG.setAlwaysOnTop(true); - vPaneDLG.setVisible(true); - - } - }); - - vPane = new ValuePane(types); - vPaneDLG = vPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { - public void doOk() { - fireEditingStopped(); // Make the renderer - // reappear. + if (jobs != null) { + for (NameSubmitJob job : jobs) { + dmlConfig.addSubmitJob(job); + } + } + dmlConfig.setCondition(condition); + + return dbMani; + } + + protected class ValuePane extends BasicBeanPane { + ValueEditorPane vPane; + + public ValuePane() { + this(v_Types); + } + + public ValuePane(Editor[] types) { + vPane = new ValueEditorPane(types); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); + this.add(vPane); + vPane.setPreferredSize(new Dimension(220, 25)); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); + } + + @Override + public void populateBean(Object object) { + vPane.populate(object); + } + + @Override + public Object updateBean() { + return vPane.update(); + } + + } + + /* + * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 + */ + protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { + /** + * The Swing component being edited. + */ + private final UILabel textLabel; + private final ValuePane vPane; + + protected ColumnValueEditor() { + this(v_Types); + } + + /** + * 列值编辑器 + * + * @param types 编辑器类型 + */ + protected ColumnValueEditor(Editor[] types) { + textLabel = new UILabel(); + DialogActionAdapter adapter = new DialogActionAdapter() { + @Override + public void doOk() { + fireEditingStopped(); // Make the renderer + // reappear. updateUpdateCheckBoxEnable(); - } - - public void doCancel() { - fireEditingCanceled(); - } - }); - } - - /* - * 双击以编辑 - */ - public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof MouseEvent) { - return ((MouseEvent)anEvent).getClickCount() >= 2; - } - return true; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof ColumnValue) { - vPane.populateBean(((ColumnValue)value).obj); - - if (((ColumnValue)value).obj != null) { - textLabel.setText(((ColumnValue)value).obj.toString()); - } else { - textLabel.setText(""); - } - } - - return textLabel; - } - - public Object getCellEditorValue() { - return new ColumnValue(vPane.updateBean()); - } - } - - public static class ColumnName { - public String name; - - public ColumnName(String name) { - this.name = name; - } - - public boolean equals(Object obj) { - if (!(obj instanceof ColumnName)) { - return false; - } - - return ComparatorUtils.equals(this.name, ((ColumnName)obj).name); - } - - @Override - protected ColumnName clone() throws CloneNotSupportedException { - return new ColumnName(name); - } - } - - public static class ColumnValue { - public Object obj; - - public ColumnValue(Object obj) { - this.obj = obj; - } - - public Object getObj(){ + } + + @Override + public void doCancel() { + fireEditingCanceled(); + } + }; + textLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + Window window = e.getComponent() == null + ? DesignerContext.getDesignerFrame() + : SwingUtilities.getWindowAncestor(e.getComponent()); + vPane.showSmallWindow(window, adapter) + .setVisible(true); + } + }); + vPane = new ValuePane(types); + } + + /* + * 双击以编辑 + */ + @Override + public boolean isCellEditable(EventObject anEvent) { + if (anEvent instanceof MouseEvent) { + return ((MouseEvent) anEvent).getClickCount() >= 2; + } + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof ColumnValue) { + vPane.populateBean(((ColumnValue) value).obj); + + if (((ColumnValue) value).obj != null) { + textLabel.setText(((ColumnValue) value).obj.toString()); + } else { + textLabel.setText(""); + } + } + + return textLabel; + } + + @Override + public Object getCellEditorValue() { + return new ColumnValue(vPane.updateBean()); + } + } + + public static class ColumnName { + public String name; + + public ColumnName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnName)) { + return false; + } + + return ComparatorUtils.equals(this.name, ((ColumnName) obj).name); + } + + @Override + protected ColumnName clone() throws CloneNotSupportedException { + return new ColumnName(name); + } + } + + public static class ColumnValue { + public Object obj; + + public ColumnValue(Object obj) { + this.obj = obj; + } + + public Object getObj() { return obj; } - public boolean equals(Object obj) { - if (!(obj instanceof ColumnValue)) { - return false; - } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnValue)) { + return false; + } - return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj); - } + return ComparatorUtils.equals(this.obj, ((ColumnValue) obj).obj); + } - @Override - protected ColumnValue clone() throws CloneNotSupportedException { - return new ColumnValue(obj); - } - } + @Override + protected ColumnValue clone() throws CloneNotSupportedException { + return new ColumnValue(obj); + } + } - protected static class KeyColumnNameValueTable extends JTable { + protected static class KeyColumnNameValueTable extends JTable { - public KeyColumnNameValueTable() { - super(new KeyColumnValueTableModel(null)); - } + public KeyColumnNameValueTable() { + super(new KeyColumnValueTableModel(null)); + } - public KeyColumnTableModel getTableModel4SmartAddCell() { - KeyColumnTableModel clonedTableModel = null; - try { - //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 - clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return new KeyColumnValueTableModel(clonedTableModel); - } + public KeyColumnTableModel getTableModel4SmartAddCell() { + KeyColumnTableModel clonedTableModel = null; + try { + //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 + clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return new KeyColumnValueTableModel(clonedTableModel); + } - } + } - protected abstract static class KeyColumnTableModel extends AbstractTableModel { + protected abstract static class KeyColumnTableModel extends AbstractTableModel { public static final String RAW_KEY = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_RWA_Key"); public static final String COLUMN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Column"); - public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); - - public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; - - protected List keyColumnNameValueList = new ArrayList<>(); - - public KeyColumnTableModel(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - - public String getColumnName(int col) { - return COLUMN_NAMES[col]; - } - - public int getColumnCount() { - return COLUMN_NAMES.length; - } - - public int getRowCount() { - return keyColumnNameValueList.size(); - } - - public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { - this.keyColumnNameValueList.add(keyColumnNameValue); - } - - public void removeKeyColumnNameValue(int index) { - this.keyColumnNameValueList.remove(index); - } - - public KeyColumnNameValue getKeyColumnNameValue(int index) { - return this.keyColumnNameValueList.get(index); - } - - public void removeAllKeyColumnNameValue() { - this.keyColumnNameValueList.clear(); - } - - public void refreshNameValueList(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.clear(); - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - } - - protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable{ - - public KeyColumnValueTableModel(KeyColumnTableModel model) { - super(model); - } - - public Object getValueAt(int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - switch (col) { - case 0: - return knv.isKey; - case 1: - return knv.cn; - case 2: - return knv.cv; - } - return null; - } - - public void setValueAt(Object value, int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - if (col == 0 && value instanceof Boolean) { - knv.isKey = ((Boolean)value).booleanValue(); - } else if (col == 1 && value instanceof ColumnName) { - knv.cn = (ColumnName)value; - } else if (col == 2 && value instanceof ColumnValue) { - knv.cv = (ColumnValue)value; - } - } - - public Class getColumnClass(int c) { - switch (c) { - case 0: - return Boolean.class; - case 1: - return ColumnName.class; - case 2: - return ColumnValue.class; - } - return String.class; - } - - public boolean isCellEditable(int row, int col) { - return true; - } - - @Override - protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { - KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); - cloned.keyColumnNameValueList = new ArrayList<>(); - for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { - cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); - } - return cloned; - } - } - - - - public static class KeyColumnNameValue { - private boolean isKey = false; - private ColumnName cn; - public ColumnValue cv; - - public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { - this.isKey = isKey; - this.cn = cn; - this.cv = cv; - } - - /** - * 字符串 - * - * @return 字符串z - */ - public String toString() { - return (isKey ? "* " : "") + cn + ":" + cv; - } - - @Override - protected KeyColumnNameValue clone() throws CloneNotSupportedException { - return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); - } - } - - /* - * ColumnNameTableCellRenderer - */ - public class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - } - - /* - * ColumnValueTableCellRenderer - */ - private class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnValue) { - if (((ColumnValue)value).obj != null) { - if (((ColumnValue)value).obj instanceof Date) { - this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue)value).obj)); - } else { - this.setText(((ColumnValue)value).obj.toString()); - } - } else { - this.setText(""); - } - } - - return this; - } - } + public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); + + public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; + + protected List keyColumnNameValueList = new ArrayList<>(); + + public KeyColumnTableModel(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + + @Override + public String getColumnName(int col) { + return COLUMN_NAMES[col]; + } + + @Override + public int getColumnCount() { + return COLUMN_NAMES.length; + } + + @Override + public int getRowCount() { + return keyColumnNameValueList.size(); + } + + public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { + this.keyColumnNameValueList.add(keyColumnNameValue); + } + + public void removeKeyColumnNameValue(int index) { + this.keyColumnNameValueList.remove(index); + } + + public KeyColumnNameValue getKeyColumnNameValue(int index) { + return this.keyColumnNameValueList.get(index); + } + + public void removeAllKeyColumnNameValue() { + this.keyColumnNameValueList.clear(); + } + + public void refreshNameValueList(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.clear(); + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + } + + protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable { + + public KeyColumnValueTableModel(KeyColumnTableModel model) { + super(model); + } + + @Override + public Object getValueAt(int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + switch (col) { + case 0: + return knv.isKey; + case 1: + return knv.cn; + case 2: + return knv.cv; + } + return null; + } + + @Override + public void setValueAt(Object value, int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + if (col == 0 && value instanceof Boolean) { + knv.isKey = ((Boolean) value).booleanValue(); + } else if (col == 1 && value instanceof ColumnName) { + knv.cn = (ColumnName) value; + } else if (col == 2 && value instanceof ColumnValue) { + knv.cv = (ColumnValue) value; + } + } + + @Override + public Class getColumnClass(int c) { + switch (c) { + case 0: + return Boolean.class; + case 1: + return ColumnName.class; + case 2: + return ColumnValue.class; + } + return String.class; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { + KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); + cloned.keyColumnNameValueList = new ArrayList<>(); + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); + } + return cloned; + } + } + + + public static class KeyColumnNameValue { + private boolean isKey = false; + private ColumnName cn; + public ColumnValue cv; + + public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { + this.isKey = isKey; + this.cn = cn; + this.cv = cv; + } + + /** + * 字符串 + * + * @return 字符串z + */ + @Override + public String toString() { + return (isKey ? "* " : "") + cn + ":" + cv; + } + + @Override + protected KeyColumnNameValue clone() throws CloneNotSupportedException { + return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); + } + } + + /* + * ColumnNameTableCellRenderer + */ + public static class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + } + + /* + * ColumnValueTableCellRenderer + */ + private static class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnValue) { + if (((ColumnValue) value).obj != null) { + if (((ColumnValue) value).obj instanceof Date) { + this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue) value).obj)); + } else { + this.setText(((ColumnValue) value).obj.toString()); + } + } else { + this.setText(""); + } + } + + return this; + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index a430faeec..d306bb179 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -456,7 +456,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { newAdd.clear(); for (int i = 0; i < cs; i++) { for (int j = 0; j < rs; j++) { - TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j ); + TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j); if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) { String value = cellElement.toString(); if (!newAdd.contains(value) && !allColumnRow.contains(value)) { @@ -512,7 +512,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { private SmartJTablePaneAction a = new AbstractSmartJTablePaneAction(this, SmartInsertDBManipulationPane.this) { @Override public void doOk() { - ((KeyColumnTableModel)keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel)model); + ((KeyColumnTableModel) keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel) model); } @Override From f531d4cf4d83406c8329fa6db7dce2fc44a3ce28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 14 Dec 2020 10:50:51 +0800 Subject: [PATCH 15/51] =?UTF-8?q?CHART-17393=20=E8=BE=B9=E6=A1=86=E5=92=8C?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E9=9A=90=E8=97=8F=E5=90=8E=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/label/VanChartPlotLabelDetailPane.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 5a8af100d..546648963 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -122,8 +122,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return new Component[][]{ new Component[]{dataLabelContentPane, null}, new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, - new Component[]{createLabelBorderPane(), null}, - new Component[]{createLabelBackgroundPane(), null} + new Component[]{createBorderAndBackgroundPane(), null}, }; } @@ -138,6 +137,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }; } + private JPanel createBorderAndBackgroundPane() { + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 5)); + jPanel.add(createLabelBorderPane(), BorderLayout.NORTH); + jPanel.add(createLabelBackgroundPane(), BorderLayout.CENTER); + return jPanel; + } + private JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); From fbf2036d5d8a1d1cadcb099f4dc98225ddeee126 Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 14 Dec 2020 11:02:24 +0800 Subject: [PATCH 16/51] =?UTF-8?q?REPORT-44961=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=8F=98=E9=87=8F=E5=90=8D=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E5=8E=BB=E6=97=A0=E7=94=A8=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wrapper/AbstractTableDataWrapper.java | 1 - .../present/dict/TableDataDictPane.java | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java index 3f1068d01..be993fa68 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java @@ -7,7 +7,6 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.utils.DesignUtils; import com.fr.general.ComparatorUtils; diff --git a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java index 53801293a..098280bc5 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java @@ -197,21 +197,24 @@ public class TableDataDictPane extends FurtherBasicBeanPane if (!namelist.isEmpty()) { columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } else { - columnNames = new String[]{""}; + columnNames = new String[]{StringUtils.EMPTY}; } - ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); - columnNameEditor1.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor1.addItemListener(itemListener); - keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); + // 实际值列名 + ColumnNameEditor actualColumnNameEditor = new ColumnNameEditor(columnNames); + actualColumnNameEditor.addItemListener(itemListener); + // 实际值列序号 + ColumnIndexEditor actualColumnIndexEditor = new ColumnIndexEditor(columnNames.length); + actualColumnIndexEditor.addItemListener(itemListener); + keyColumnPane.setEditors(new Editor[]{actualColumnNameEditor, actualColumnIndexEditor}, columnNames[0]); localFormulaEditor.setEnabled(true); - - ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); - columnNameEditor2.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor2.addItemListener(itemListener); - valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, localFormulaEditor}, columnNames[0]); + // 显示值列名 + ColumnNameEditor displayColumnNameEditor = new ColumnNameEditor(columnNames); + displayColumnNameEditor.addItemListener(itemListener); + // 显示值列序号 + ColumnIndexEditor displayColumnIndexEditor = new ColumnIndexEditor(columnNames.length); + displayColumnIndexEditor.addItemListener(itemListener); + valueDictPane.setEditors(new Editor[]{displayColumnNameEditor, displayColumnIndexEditor, localFormulaEditor}, columnNames[0]); } catch (InterruptedException | ExecutionException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } From f99aac406bc05b05fa2369b111fe969276c44d1b Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 14 Dec 2020 11:12:24 +0800 Subject: [PATCH 17/51] =?UTF-8?q?REPORT-44961=20=E4=B8=BA=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=A0=BC=E5=B1=9E=E6=80=A7-=E5=BD=A2=E6=80=81-?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E4=B8=AD=E7=9A=84Dictionar?= =?UTF-8?q?yPane=E4=B9=9F=E8=AE=BE=E7=BD=AEneedChangeTableData=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E4=B8=BAtrue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/present/DictPresentPane.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java b/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java index cba37ea19..85f027217 100644 --- a/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java +++ b/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java @@ -10,7 +10,7 @@ import com.fr.design.present.dict.DictionaryPane; /** - * + * * @author zhou * @since 2012-5-31上午10:54:20 */ @@ -19,6 +19,7 @@ public class DictPresentPane extends FurtherBasicBeanPane implement public DictPresentPane() { dictionaryPane = new DictionaryPane(); + dictionaryPane.setNeedTableDataChange(true); this.setLayout(new BorderLayout()); this.add(dictionaryPane, BorderLayout.CENTER); } @@ -42,7 +43,7 @@ public class DictPresentPane extends FurtherBasicBeanPane implement public boolean accept(Object ob) { return ob instanceof DictPresent; } - + public void addTabChangeListener(ItemListener l){ dictionaryPane.addTabChangeListener(l); } @@ -55,4 +56,4 @@ public class DictPresentPane extends FurtherBasicBeanPane implement public void registerDSChangeListener() { dictionaryPane.registerDSChangeListener(); } -} \ No newline at end of file +} From bc9a93d903fa1fc49f141dfbdd0ef06c2d25bed8 Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 14 Dec 2020 14:41:00 +0800 Subject: [PATCH 18/51] =?UTF-8?q?REPORT-44961=20=E6=8A=8ATableDataDictPane?= =?UTF-8?q?=E4=B8=AD=E7=9A=84needTableDataChange=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BAtrue=EF=BC=8C=E5=9C=A8CheckBoxGroupD?= =?UTF-8?q?efinePane=E4=B8=AD=E5=88=9B=E5=BB=BADictionaryPane=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BC=A0=E5=85=A5=E4=B8=80=E4=B8=AAfalse?= =?UTF-8?q?=EF=BC=8C=E8=BF=99=E6=A0=B7=E5=B0=B1=E4=B8=8D=E4=BC=9A=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E5=85=B6=E5=AE=83=E4=BD=BF=E7=94=A8=E4=BA=86Dictionar?= =?UTF-8?q?yPane=E7=9A=84=E5=9C=B0=E6=96=B9=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accessibles/AccessibleDictionaryEditor.java | 1 - .../java/com/fr/design/present/DictPresentPane.java | 1 - .../com/fr/design/present/dict/DictionaryPane.java | 11 +++++++---- .../fr/design/present/dict/TableDataDictPane.java | 12 ++++++++---- .../widget/ui/designer/CheckBoxGroupDefinePane.java | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java index 6be31c526..3edf47b05 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java @@ -21,7 +21,6 @@ public class AccessibleDictionaryEditor extends UneditableAccessibleEditor { protected void showEditorPane() { if (dictPane == null) { dictPane = new DictionaryPane(); - dictPane.setNeedTableDataChange(true); } BasicDialog dlg = dictPane.showWindow(SwingUtilities.getWindowAncestor(this)); diff --git a/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java b/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java index 85f027217..82cf70372 100644 --- a/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java +++ b/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java @@ -19,7 +19,6 @@ public class DictPresentPane extends FurtherBasicBeanPane implement public DictPresentPane() { dictionaryPane = new DictionaryPane(); - dictionaryPane.setNeedTableDataChange(true); this.setLayout(new BorderLayout()); this.add(dictionaryPane, BorderLayout.CENTER); } diff --git a/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java b/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java index f74138be5..3f42732f1 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java @@ -24,6 +24,13 @@ import java.util.List; public class DictionaryPane extends UIComboBoxPane implements DataCreatorUI, Prepare4DataSourceChange { private TableDataDictPane tableDataDictPane; + public DictionaryPane() { + } + + public DictionaryPane(boolean needTableDataChange) { + this.tableDataDictPane.setNeedTableDataChange(needTableDataChange); + } + @Override protected void initLayout() { this.setLayout(new BorderLayout(0, 4)); @@ -83,8 +90,4 @@ public class DictionaryPane extends UIComboBoxPane implements DataCr public void registerDSChangeListener() { tableDataDictPane.registerDSChangeListener(); } - - public void setNeedTableDataChange(boolean needTableDataChange) { - tableDataDictPane.setNeedTableDataChange(needTableDataChange); - } } diff --git a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java index 098280bc5..5eb6c2873 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java @@ -64,7 +64,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane private ItemListener itemListener; private UIObserverListener uiObserverListener; private FormulaEditor localFormulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); - private boolean needTableDataChange = false; + private boolean needTableDataChange = true; public TableDataDictPane() { initBasicComponets(); @@ -95,7 +95,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); tableDataNameComboBox.addItemListener(e -> { if (e.getStateChange() == ItemEvent.SELECTED) { - tdChange(e, needTableDataChange); + tdChange(e); } }); // keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); @@ -164,7 +164,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dic_Data_Query"); } - private void tdChange(final ItemEvent e, boolean needTableDataChange) { + private void tdChange(final ItemEvent e) { TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); if (tableDataWrappe == null) { return; @@ -173,7 +173,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane itemListener.itemStateChanged(e); localFormulaEditor.addChangeListener(event -> itemListener.itemStateChanged(e)); } - if (needTableDataChange) { + if (isNeedTableDataChange()) { changeColumnsName(); } } @@ -404,4 +404,8 @@ public class TableDataDictPane extends FurtherBasicBeanPane public void registerDSChangeListener() { tableDataNameComboBox.registerGlobalDSChangeListener(); } + + public boolean isNeedTableDataChange() { + return needTableDataChange; + } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java index 19a61a631..022afc610 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java @@ -29,9 +29,9 @@ public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane Date: Mon, 14 Dec 2020 16:41:55 +0800 Subject: [PATCH 19/51] merge code --- .../com/fr/design/DesignerEnvManager.java | 39 +- .../gui/icontainer/UIResizableContainer.java | 32 +- .../fr/design/mainframe/DesignerFrame.java | 4 +- .../mainframe/WestRegionContainerPane.java | 2 +- .../write/submit/DBManipulationPane.java | 1736 +++++++++-------- .../label/VanChartPlotLabelDetailPane.java | 11 +- .../submit/SmartInsertDBManipulationPane.java | 4 +- 7 files changed, 924 insertions(+), 904 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 44c0eba84..791d679b3 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -141,8 +141,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private int eastRegionToolPaneY = 300; private int eastRegionContainerWidth = 260; + private int westRegionToolPaneY = 300; private int westRegionContainerWidth = 240; - private double westRegionToolPaneYRate = 0.5; private String encryptionKey; private String jdkHome; @@ -240,7 +240,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String installHome = StableUtils.getInstallHome(); //这里不判断路径是.的情况,放在checkValid方法里面,重新选 if (installHome != null) { - String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); + String name = Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); String envPath = designerEnvManager.getDefaultenvPath(installHome); designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath)); designerEnvManager.setCurEnvName(name); @@ -304,8 +304,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String today = calender.get(Calendar.YEAR) + "-" + (calender.get(Calendar.MONTH) + 1) + "-" + calender.get(Calendar.DAY_OF_MONTH); String fileName = StableUtils.pathJoin(logLocation, "fr_" + today + "_%g.log"); - if (!new java.io.File(fileName).exists()) { - StableUtils.makesureFileExist(new java.io.File(fileName)); + if (!new File(fileName).exists()) { + StableUtils.makesureFileExist(new File(fileName)); } Handler handler = new FileHandler(fileName, true); @@ -440,12 +440,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.lastOpenFilePath = lastOpenFilePath; } + /** - * 获取西面板的上子面板的高度占容器总高度的比例 + * 得到西面板的上下子面板的高度区分 + * * @return */ - public double getLastWestRegionToolPaneYRate() { - return westRegionToolPaneYRate; + public int getLastWestRegionToolPaneY() { + return this.westRegionToolPaneY; } /** @@ -458,11 +460,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 设置关闭设计器前,西面板的上子面板的高度占容器总高度的比例 - * @param westRegionToolPaneYRate + * 设置西面板的上下子面板的高度区分 + * + * @param toolPaneY */ - public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) { - this.westRegionToolPaneYRate = westRegionToolPaneYRate; + public void setLastWestRegionToolPaneY(int toolPaneY) { + this.westRegionToolPaneY = toolPaneY; } /** @@ -526,7 +529,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return env; } } - String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); + String name = Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath); this.putEnv(name, newDefaultEnv); return newDefaultEnv; @@ -549,7 +552,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } } - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); + return Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); } @@ -1607,8 +1610,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void readLastWestRegionLayout(XMLableReader reader) { String tmpVal; - if ((tmpVal = reader.getAttrAsString("toolPaneYRate", null)) != null) { - this.setLastWestRegionToolPaneYRate(Double.parseDouble(tmpVal)); + if ((tmpVal = reader.getAttrAsString("toolPaneY", null)) != null) { + this.setLastWestRegionToolPaneY(Integer.parseInt(tmpVal)); } if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) { this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal)); @@ -1640,7 +1643,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { // marks:兼容6.1的 // marks:设置默认的目录. - String curReportServerName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); + String curReportServerName = Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal); this.putEnv(curReportServerName, reportServer); @@ -1931,8 +1934,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void writeLastWestRegionLayout(XMLPrintWriter writer) { writer.startTAG("LastWestRegionLayout"); - if (this.getLastWestRegionToolPaneYRate() >= 0) { - writer.attr("toolPaneYRate", this.getLastWestRegionToolPaneYRate()); + if (this.getLastWestRegionToolPaneY() >= 0) { + writer.attr("toolPaneY ", this.getLastWestRegionToolPaneY()); } if (this.getLastWestRegionContainerWidth() >= 0) { writer.attr("containerWidth", this.getLastWestRegionContainerWidth()); diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index b48950485..f3f45768f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -44,7 +44,6 @@ public class UIResizableContainer extends JPanel { private boolean isDownPaneVisible = true ; private int paraHeight; private int parentHeight = -1; - private double toolPaneYRate; public UIResizableContainer(int direction) { this(new JPanel(), new JPanel(), direction); @@ -157,20 +156,12 @@ public class UIResizableContainer extends JPanel { return this.toolPaneY; } - /** - * 获取上子面板高度占容器总高度的比例 - * @return - */ - public double getToolPaneYRate() { - return toolPaneYRate; - } - /** * 设置关闭设计器前最新的上子面板的高度比例 - * @param toolPaneYRate + * @param toolPaneY */ - public void setLastToolPaneYRate(double toolPaneYRate) { - this.toolPaneYRate = toolPaneYRate; + public void setLastToolPaneY(int toolPaneY) { + this.toolPaneY = toolPaneY; } /** @@ -248,9 +239,10 @@ public class UIResizableContainer extends JPanel { if (parentHeight == -1) { // 初始化下parentheight,存一下当前的父容器height parentHeight = parent.getHeight(); - } else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) { - // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY - toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); + } + if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) { + // 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失 + toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight); parentHeight = parent.getHeight(); } } @@ -376,7 +368,6 @@ public class UIResizableContainer extends JPanel { toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); - adjustToolPaneYRate(); refreshContainer(); } }); @@ -398,10 +389,8 @@ public class UIResizableContainer extends JPanel { public void mouseClicked(MouseEvent e) { if (e.getX() <= ARROW_RANGE) { toolPaneY = 0; - UIResizableContainer.this.adjustToolPaneYRate(); } else if (e.getX() >= getWidth() - ARROW_RANGE) { toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); - UIResizableContainer.this.adjustToolPaneYRate(); } else { return; } @@ -562,11 +551,4 @@ public class UIResizableContainer extends JPanel { jf.setSize(500, 500); jf.setVisible(true); } - - /** - * 当toolPaneY发生变化时,也需要调整toolPaneYRate - */ - private void adjustToolPaneYRate() { - this.toolPaneYRate = ((double) toolPaneY) / this.getHeight(); - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index a5eafa0c0..490b4e7e9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -1170,8 +1170,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } - DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneYRate( - WestRegionContainerPane.getInstance().getToolPaneYRate()); + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( + WestRegionContainerPane.getInstance().getToolPaneY()); DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( WestRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 358fba411..004fbd55a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -24,7 +24,7 @@ public class WestRegionContainerPane extends UIResizableContainer { public static final WestRegionContainerPane getInstance() { if (THIS == null) { THIS = new WestRegionContainerPane(); - THIS.setLastToolPaneYRate(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneYRate()); + THIS.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); } return THIS; diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index ccf01dd5e..46b11d2a8 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -53,7 +53,6 @@ import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; -import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -74,6 +73,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Image; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; @@ -92,136 +92,133 @@ public class DBManipulationPane extends BasicBeanPane { private static final Image ICODS_IMAGE = BaseUtils.readImage("/com/fr/web/core/css/images/icons.png"); private static final Icon HEIP_ICON = BaseUtils.createIcon(ICODS_IMAGE, 193, 1, 14, 14); private static final int DEFAULT_RETURN_VALUE = 4; - public KeyColumnNameValueTable keyColumnValuesTable; - private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor + public KeyColumnNameValueTable keyColumnValuesTable; + private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor private UICheckBox UpdateCheckBox; private JPanel checkBoxUpdatePane; - /* - * 记录当前选取的DS & Table对应的ColumnName[] - * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 - */ - private ColumnName[] currentColumnNames = null; + /* + * 记录当前选取的DS & Table对应的ColumnName[] + * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 + */ + private ColumnName[] currentColumnNames = null; - // 支持公式输入的数据表选择面板 - private ChoosePaneSupportFormula chooseTable; + // 支持公式输入的数据表选择面板 + private ChoosePaneSupportFormula chooseTable; - private UIComboBox dmlConfigComboBox = null; + private UIComboBox dmlConfigComboBox = null; - // 提交事件 - private NameSubmitJob[] jobs = null; + // 提交事件 + private NameSubmitJob[] jobs = null; - // 提交条件 - private Condition condition = null; + // 提交条件 + private Condition condition = null; - private JTree conditionsTree; + private JTree conditionsTree; - private Editor[] v_Types; + private Editor[] v_Types; - protected JavaScriptActionPane parentPane; + protected JavaScriptActionPane parentPane; - private int keyColumnWidth = 100; - private int resizeColumnCount = 4; - private int btnWidth = 110; - private int btnHeight = 20; private String subMitName; - private static final String[] DML_CONFIG_TYPES = new String[] { + private static final String[] DML_CONFIG_TYPES = new String[]{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Smart_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Delete_Submit"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Update_Submit")}; - /** - * 无单元格。没有智能添加单元格等按钮 - * 有单元格的参见其子类SmartInsertDBManipulationPane - */ - public DBManipulationPane() { - this(ValueEditorPaneFactory.extendedCellGroupEditors()); - } + /** + * 无单元格。没有智能添加单元格等按钮 + * 有单元格的参见其子类SmartInsertDBManipulationPane + */ + public DBManipulationPane() { + this(ValueEditorPaneFactory.extendedCellGroupEditors()); + } - public DBManipulationPane(Editor[] v_Types) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.v_Types = v_Types; + public DBManipulationPane(Editor[] v_Types) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.v_Types = v_Types; - JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(northPane, BorderLayout.NORTH); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(northPane, BorderLayout.NORTH); - dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); + dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); - JPanel typePane = GUICoreUtils.createFlowPane(new Component[] { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox }, - FlowLayout.LEFT, 10); - typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); - northPane.add(typePane, BorderLayout.NORTH); + JPanel typePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox}, + FlowLayout.LEFT, 10); + typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); + northPane.add(typePane, BorderLayout.NORTH); - chooseTable = new ChoosePaneSupportFormula(); - chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); - chooseTable.setTableNameComboBoxPopSize(160, 320); + chooseTable = new ChoosePaneSupportFormula(); + chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); + chooseTable.setTableNameComboBoxPopSize(160, 320); - northPane.add(chooseTable, BorderLayout.CENTER); + northPane.add(chooseTable, BorderLayout.CENTER); - // peter:编辑的TablePane - JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(editTablePane, BorderLayout.CENTER); - editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); + // peter:编辑的TablePane + JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(editTablePane, BorderLayout.CENTER); + editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); - keyColumnValuesTable = new KeyColumnNameValueTable(); - editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); - keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); - keyColumnValuesTable.setShowHorizontalLines(true); + keyColumnValuesTable = new KeyColumnNameValueTable(); + editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); + keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); + keyColumnValuesTable.setShowHorizontalLines(true); - initJTableColumn(); + initJTableColumn(); - addButtons(editTablePane); + addButtons(editTablePane); - addBottomPane(); + addBottomPane(); - addListeners(); - } + addListeners(); + } - public void setSubMitName(String subMitName){ + public void setSubMitName(String subMitName) { this.subMitName = subMitName; } - public String getSubMitName(){ + public String getSubMitName() { return this.subMitName; } - private void addButtons(JPanel editTablePane) { - // alex:添加操作按钮 - UpdateAction[] actions = this.getActions(); - if (actions != null && actions.length > 0) { - JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); - editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); + private void addButtons(JPanel editTablePane) { + // alex:添加操作按钮 + UpdateAction[] actions = this.getActions(); + if (actions != null && actions.length > 0) { + JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); + editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); - for (int i = 0; i < actions.length; i++) { - controlBtnPane.add(new UIButton(actions[i])); - } + for (UpdateAction action : actions) { + controlBtnPane.add(new UIButton(action)); + } checkBoxUpdatePane = new JPanel(new BorderLayout(0, 0)); - checkBoxUpdatePane.setPreferredSize(new Dimension(120,20)); + checkBoxUpdatePane.setPreferredSize(new Dimension(120, 20)); controlBtnPane.add(checkBoxUpdatePane); UpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_NotChange_Unmodified")); - UIButton helpButton = new UIButton(HEIP_ICON); + UIButton helpButton = new UIButton(HEIP_ICON); helpButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help")); helpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); + FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); BasicDialog dlg = formatExplanation.showMediumWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - new DialogActionAdapter(){}); + new DialogActionAdapter() { + }); dlg.setVisible(true); } }); helpButton.set4ToolbarButton(); - checkBoxUpdatePane.add(UpdateCheckBox,BorderLayout.WEST); - checkBoxUpdatePane.add(helpButton,BorderLayout.EAST); - } - } - - protected void updateUpdateCheckBoxEnable(){ - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - if (model.getRowCount() == 0){ + checkBoxUpdatePane.add(UpdateCheckBox, BorderLayout.WEST); + checkBoxUpdatePane.add(helpButton, BorderLayout.EAST); + } + } + + protected void updateUpdateCheckBoxEnable() { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + if (model.getRowCount() == 0) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(true); return; @@ -230,9 +227,8 @@ public class DBManipulationPane extends BasicBeanPane { for (int i = 0; i < model.getRowCount(); i++) { columnObjects.add(model.getKeyColumnNameValue(i).cv.getObj()); } - for (int i = 0;i < columnObjects.size();i++){ - Object ob = columnObjects.get(i) ; - if (!( ob instanceof ColumnRow || ob instanceof ColumnRowGroup)){ + for (Object ob : columnObjects) { + if (!(ob instanceof ColumnRow || ob instanceof ColumnRowGroup)) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(false); return; @@ -241,236 +237,241 @@ public class DBManipulationPane extends BasicBeanPane { setUpdateCheckBoxEnable(true); } - private void setUpdateCheckBoxEnable( boolean b){ + private void setUpdateCheckBoxEnable(boolean b) { UpdateCheckBox.setEnabled(b); } - private void addBottomPane() { - JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - eventPane.add(addEventButton()); + private void addBottomPane() { + JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + eventPane.add(addEventButton()); - JPanel conditionPane = this.createConditionPane(); + JPanel conditionPane = this.createConditionPane(); - JPanel btPane =new JPanel( FRGUIPaneFactory.createBorderLayout()); - btPane.add(eventPane,BorderLayout.CENTER); - btPane.add(conditionPane,BorderLayout.NORTH); - this.add(btPane, BorderLayout.SOUTH); - } + JPanel btPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + btPane.add(eventPane, BorderLayout.CENTER); + btPane.add(conditionPane, BorderLayout.NORTH); + this.add(btPane, BorderLayout.SOUTH); + } - private UIButton addEventButton() { - UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); - addSubmitEventButton.addActionListener(new ActionListener() { + private UIButton addEventButton() { + UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); + addSubmitEventButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final SubmitJobListPane jobsPane = createSubmitJobListPane(); + @Override + public void actionPerformed(ActionEvent e) { + final SubmitJobListPane jobsPane = createSubmitJobListPane(); - jobsPane.populate(jobs); - BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - jobs = jobsPane.updateDBManipulation(); - } - }); - dialog.setVisible(true); - } + jobsPane.populate(jobs); + BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + jobs = jobsPane.updateDBManipulation(); + } + }); + dialog.setVisible(true); + } - }); - return addSubmitEventButton; - } + }); + return addSubmitEventButton; + } - private JPanel createConditionPane() { - JPanel conditionPane = new JPanel(); - conditionPane.setPreferredSize(createConditionPanePreferredSize()); + private JPanel createConditionPane() { + JPanel conditionPane = new JPanel(); + conditionPane.setPreferredSize(createConditionPanePreferredSize()); setBorderAndLayout(conditionPane); - conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); - conditionsTree.setRootVisible(false); - conditionsTree.setShowsRootHandles(true); - conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); - conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); - DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); - cr.setForeground(UIConstants.NORMAL_BACKGROUND); - JScrollPane jp = new JScrollPane(conditionsTree); - addComponent(conditionPane,jp); - - UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); - addSubmitConditionButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { - @Override - protected boolean isNeedDoWithCondition(Condition liteCondition) { - return liteCondition != null; - } - }; - String[] columns = chooseTable.currentColumnNames(); - if (columns != null && columns.length > 0) { - conditionPane.populateColumns(chooseTable.currentColumnNames()); - } - - conditionPane.populateBean(condition); - BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - condition = conditionPane.updateBean(); - refreshConditionList(); - } - }); - dialog.setVisible(true); - } - }); - - JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); + conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); + conditionsTree.setRootVisible(false); + conditionsTree.setShowsRootHandles(true); + conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); + conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); + DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); + cr.setForeground(UIConstants.NORMAL_BACKGROUND); + JScrollPane jp = new JScrollPane(conditionsTree); + addComponent(conditionPane, jp); + + UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); + addSubmitConditionButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { + @Override + protected boolean isNeedDoWithCondition(Condition liteCondition) { + return liteCondition != null; + } + }; + String[] columns = chooseTable.currentColumnNames(); + if (columns != null && columns.length > 0) { + conditionPane.populateColumns(chooseTable.currentColumnNames()); + } + + conditionPane.populateBean(condition); + BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + condition = conditionPane.updateBean(); + refreshConditionList(); + } + }); + dialog.setVisible(true); + } + }); + + JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); controlBtnPane.setPreferredSize(createControlBtnPanePreferredSize()); - conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH),setControlBtnPanePosition()); - controlBtnPane.add(addSubmitConditionButton); + conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), setControlBtnPanePosition()); + controlBtnPane.add(addSubmitConditionButton); - return conditionPane; - } + return conditionPane; + } - protected void setBorderAndLayout(JPanel jPanel){ + protected void setBorderAndLayout(JPanel jPanel) { jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); jPanel.setBorder(BorderFactory.createTitledBorder( - new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); + new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); } - protected void addComponent(JPanel mainPane,JScrollPane addPane){ - mainPane.add(addPane,BorderLayout.CENTER); + protected void addComponent(JPanel mainPane, JScrollPane addPane) { + mainPane.add(addPane, BorderLayout.CENTER); } - protected Dimension createConditionPanePreferredSize(){ + protected Dimension createConditionPanePreferredSize() { return new Dimension(454, 80); } - protected Dimension createControlBtnPanePreferredSize(){ + protected Dimension createControlBtnPanePreferredSize() { return new Dimension(110, 20); } - protected String setControlBtnPanePosition(){ - return BorderLayout.EAST; + protected String setControlBtnPanePosition() { + return BorderLayout.EAST; + } + + private void refreshConditionList() { + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); + ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); + rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); + rootTreeNode.removeAllChildren(); + Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); + } + } else { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); + rootTreeNode.add(newTreeNode); + } + defaultTreeModel.reload(rootTreeNode); + rootTreeNode.expandCurrentTreeNode(conditionsTree); + } + + private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); + parentTreeNode.add(newTreeNode); + Condition liteCondition = joinCondition.getCondition(); + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); + } + } + } + + private void addListeners() { + dmlConfigComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + Object ob = e.getItem(); + if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { + checkBoxUpdatePane.setVisible(true); + } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { + checkBoxUpdatePane.setVisible(false); + } + } + } + }); + + /* + * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, + * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 + * 也不能在tableNameComboBox.focusLost事件时,好像没用 + */ + keyColumnValuesTable.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + refreshColumnsComboBox(); + } + + }); + } + + protected UpdateAction[] getActions() { + return new UpdateAction[]{new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction()}; + } + + protected SubmitJobListPane createSubmitJobListPane() { + return new SubmitJobListPane(); + } + + public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { + this.parentPane = jsPane; + } + + @Override + protected String title4PopupWindow() { + return "DB"; } - private void refreshConditionList() { - DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); - ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); - rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); - rootTreeNode.removeAllChildren(); - Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); - } - } else { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); - rootTreeNode.add(newTreeNode); - } - defaultTreeModel.reload(rootTreeNode); - rootTreeNode.expandCurrentTreeNode(conditionsTree); - } - - private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); - parentTreeNode.add(newTreeNode); - Condition liteCondition = joinCondition.getCondition(); - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); - } - } - } - - private void addListeners() { - dmlConfigComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - Object ob = e.getItem(); - if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { - checkBoxUpdatePane.setVisible(true); - } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { - checkBoxUpdatePane.setVisible(false); - } - } - } - }); - - /* - * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, - * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 - * 也不能在tableNameComboBox.focusLost事件时,好像没用 - */ - keyColumnValuesTable.addFocusListener(new FocusAdapter() { - - public void focusGained(FocusEvent e) { - refreshColumnsComboBox(); - } - - }); - } - - protected UpdateAction[] getActions() { - return new UpdateAction[] { new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction() }; - } - - protected SubmitJobListPane createSubmitJobListPane() { - return new SubmitJobListPane(); - } - - public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { - this.parentPane = jsPane; - } - - @Override - protected String title4PopupWindow() { - return "DB"; - } - - protected class SmartAddFieldsAction extends UpdateAction { - public SmartAddFieldsAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); - } - - public void actionPerformed(ActionEvent evt) { - - BasicPane bPane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); - } - }; - bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - - final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { - public String value2Text(Object value) { - if (value instanceof ColumnName) { - return ((ColumnName)value).name; - } - - return super.value2Text(value); - } - }; - bPane.add(new JScrollPane(list), BorderLayout.CENTER); - - BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - public void doOk() { - addFields(list); + protected class SmartAddFieldsAction extends UpdateAction { + public SmartAddFieldsAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + + BasicPane bPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); + } + }; + bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + + final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { + @Override + public String value2Text(Object value) { + if (value instanceof ColumnName) { + return ((ColumnName) value).name; + } + + return super.value2Text(value); + } + }; + bPane.add(new JScrollPane(list), BorderLayout.CENTER); + + BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + addFields(list); updateUpdateCheckBoxEnable(); - } - }); - dlg.setVisible(true); - } - } - - private void addFields (CheckBoxList list) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + } + }); + dlg.setVisible(true); + } + } + + private void addFields(CheckBoxList list) { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); List keyColumnNameValueList = new ArrayList(); keyColumnNameValueList.clear(); for (int i = 0; i < model.getRowCount(); i++) { @@ -481,28 +482,28 @@ public class DBManipulationPane extends BasicBeanPane { // Richie:用了存储新的KeyColumnNameValue的List. List newKeyColumnNameValueList = new ArrayList(); if (!keyColumnNameValueList.isEmpty()) { - for (int i = 0; i < selected.length; i++) { + for (Object o : selected) { // Richie:先填上空的. - newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } // Richie:初始化 int returnValue = DEFAULT_RETURN_VALUE; int coverNumber = 0; - if (!keyColumnNameValueList.isEmpty()) { - //如果存在先前项,设置状态为5 - returnValue = 5 ; - } + if (!keyColumnNameValueList.isEmpty()) { + //如果存在先前项,设置状态为5 + returnValue = 5; + } for (int i = 0; i < selected.length; i++) { if (returnValue == 0 || returnValue == 3) { break; } - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { - Object[] options = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None") }; + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { + Object[] options = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None")}; returnValue = JOptionPane.showOptionDialog(DBManipulationPane.this, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValueList.get(j).cn.name), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValue.cn.name), "", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); // Richie:全部覆盖 if (returnValue == 0) { @@ -514,7 +515,7 @@ public class DBManipulationPane extends BasicBeanPane { } else if (returnValue == 2) { coverNumber = i; newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); // Richie:全部不覆盖 } else if (returnValue == 3) { coverNumber = i; @@ -526,7 +527,7 @@ public class DBManipulationPane extends BasicBeanPane { checkTableModel(returnValue, coverNumber, model, selected, keyColumnNameValueList, newKeyColumnNameValueList); } - private void checkTableModel (int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { + private void checkTableModel(int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { if (returnValue == 0) { model.removeAllKeyColumnNameValue(); // Richie:全部覆盖,按selected的长度添加默认的行 @@ -538,10 +539,10 @@ public class DBManipulationPane extends BasicBeanPane { model.removeAllKeyColumnNameValue(); // Richie:全部不覆盖,已经存在的就保留,不存在的添加默认行 for (int i = coverNumber; i < selected.length; i++) { - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); } } @@ -552,610 +553,637 @@ public class DBManipulationPane extends BasicBeanPane { } } else if (returnValue == 1 || returnValue == 2) { - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } else if (returnValue == 5){ - //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } else if (returnValue == 5) { + //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } // Richie:初始化 if (keyColumnNameValueList.isEmpty()) { model.removeAllKeyColumnNameValue(); - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + for (Object o : selected) { + model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } - + model.fireTableDataChanged(); keyColumnValuesTable.validate(); } - protected class AddFieldAction extends UpdateAction { - public AddFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); - } + protected class AddFieldAction extends UpdateAction { + public AddFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); + } - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(ActionEvent e) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); - model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); + model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); updateUpdateCheckBoxEnable(); - model.fireTableDataChanged(); - - keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); - } - } - - protected class RemoveFieldAction extends UpdateAction { - public RemoveFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); - } - - public void actionPerformed(ActionEvent evt) { - // DBManipulationPane target = this.getDBManipulationPane(); - - int[] selectedRows = keyColumnValuesTable.getSelectedRows(); - if (selectedRows == null || selectedRows.length == 0) { - return; - } - - int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.OK_OPTION) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - - // 把selectedRows从小到大排个序,先删大的再删小的 - java.util.Arrays.sort(selectedRows); - for (int i = selectedRows.length - 1; i >= 0; i--) { - keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); - } + model.fireTableDataChanged(); + + keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); + } + } + + protected class RemoveFieldAction extends UpdateAction { + public RemoveFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + // DBManipulationPane target = this.getDBManipulationPane(); + + int[] selectedRows = keyColumnValuesTable.getSelectedRows(); + if (selectedRows == null || selectedRows.length == 0) { + return; + } + + int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.OK_OPTION) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + + // 把selectedRows从小到大排个序,先删大的再删小的 + java.util.Arrays.sort(selectedRows); + for (int i = selectedRows.length - 1; i >= 0; i--) { + keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); + } updateUpdateCheckBoxEnable(); - keyColumnNameValueTableModel.fireTableDataChanged(); - - // select other one. - if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); - } else if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - } - } - - /* - * 刷新columnsComboBox - */ - private void refreshColumnsComboBox() { - DefaultComboBoxModel model = (DefaultComboBoxModel)this.columnsComboBox.getModel(); - model.removeAllElements(); - - ColumnName[] columnNames = currentColumnNames(); - for (int i = 0; i < columnNames.length; i++) { - model.addElement(columnNames[i]); - } - } - - // 得到当前的ColumnName[] - private ColumnName[] currentColumnNames() { - // ben:清除原有的 - if (currentColumnNames != null) { - currentColumnNames = null; - } - String[] colNames = this.chooseTable.currentColumnNames(); - int len = colNames.length; - currentColumnNames = new ColumnName[len]; - for (int i = 0; i < len; i++) { - currentColumnNames[i] = new ColumnName(colNames[i]); - } - return currentColumnNames; - } - - /* - * 设置JTable的Column - */ - private void initJTableColumn() { - TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); - column0.setMaxWidth(50); - - TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); - column1.setCellRenderer(new ColumnNameTableCellRenderer()); - - TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); - column2.setCellRenderer(new ColumnValueTableCellRenderer()); - - // 设置column1的editor - columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); - columnsComboBox.setRenderer(new UIComboBoxRenderer() { - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - - }); - column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { - public boolean stopCellEditing() { - if (super.stopCellEditing()) { - return true; - } - - return false; - } - }); - ((DefaultCellEditor)column1.getCellEditor()).setClickCountToStart(2); - - //设置Column 2的Editor - column2.setCellEditor(new ColumnValueEditor()); - } - - public void populateBean(DBManipulation dbManipulation) { - if (dbManipulation == null) { - dbManipulation = new DBManipulation(); - } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // select other one. + if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); + } else if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + } + } + + /* + * 刷新columnsComboBox + */ + private void refreshColumnsComboBox() { + DefaultComboBoxModel model = (DefaultComboBoxModel) this.columnsComboBox.getModel(); + model.removeAllElements(); + + ColumnName[] columnNames = currentColumnNames(); + for (ColumnName columnName : columnNames) { + model.addElement(columnName); + } + } + + // 得到当前的ColumnName[] + private ColumnName[] currentColumnNames() { + // ben:清除原有的 + if (currentColumnNames != null) { + currentColumnNames = null; + } + String[] colNames = this.chooseTable.currentColumnNames(); + int len = colNames.length; + currentColumnNames = new ColumnName[len]; + for (int i = 0; i < len; i++) { + currentColumnNames[i] = new ColumnName(colNames[i]); + } + return currentColumnNames; + } + + /* + * 设置JTable的Column + */ + private void initJTableColumn() { + TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); + column0.setMaxWidth(50); + + TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); + column1.setCellRenderer(new ColumnNameTableCellRenderer()); + + TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); + column2.setCellRenderer(new ColumnValueTableCellRenderer()); + + // 设置column1的editor + columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); + columnsComboBox.setRenderer(new UIComboBoxRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + + }); + column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { + @Override + public boolean stopCellEditing() { + return super.stopCellEditing(); + } + }); + ((DefaultCellEditor) column1.getCellEditor()).setClickCountToStart(2); + + //设置Column 2的Editor + column2.setCellEditor(new ColumnValueEditor()); + } + + @Override + public void populateBean(DBManipulation dbManipulation) { + if (dbManipulation == null) { + dbManipulation = new DBManipulation(); + } subMitName = dbManipulation.getName(); - DMLConfig dmlConfig = dbManipulation.getDmlConfig(); - - if (dmlConfig != null) { - if (dmlConfig instanceof IntelliDMLConfig) { - dmlConfigComboBox.setSelectedIndex(0); - } else if (dmlConfig instanceof DeleteConfig) { - dmlConfigComboBox.setSelectedIndex(1); - } else if (dmlConfig instanceof InsertConfig) { - dmlConfigComboBox.setSelectedIndex(2); - } else if (dmlConfig instanceof UpdateConfig) { - dmlConfigComboBox.setSelectedIndex(3); - } else { - dmlConfigComboBox.setSelectedIndex(0); - } - jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; - for (int i = 0; i < jobs.length; i++) { - jobs[i] = dmlConfig.getNameSubmitJob(i); - } - condition = dmlConfig.getCondition(); + DMLConfig dmlConfig = dbManipulation.getDmlConfig(); + + if (dmlConfig != null) { + if (dmlConfig instanceof IntelliDMLConfig) { + dmlConfigComboBox.setSelectedIndex(0); + } else if (dmlConfig instanceof DeleteConfig) { + dmlConfigComboBox.setSelectedIndex(1); + } else if (dmlConfig instanceof InsertConfig) { + dmlConfigComboBox.setSelectedIndex(2); + } else if (dmlConfig instanceof UpdateConfig) { + dmlConfigComboBox.setSelectedIndex(3); + } else { + dmlConfigComboBox.setSelectedIndex(0); + } + jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; + for (int i = 0; i < jobs.length; i++) { + jobs[i] = dmlConfig.getNameSubmitJob(i); + } + condition = dmlConfig.getCondition(); UpdateCheckBox.setSelected(dmlConfig.isUpdateSelected()); - } else { - jobs = null; - condition = null; - dmlConfigComboBox.setSelectedIndex(0); + } else { + jobs = null; + condition = null; + dmlConfigComboBox.setSelectedIndex(0); UpdateCheckBox.setSelected(false); - } + } - String schema = null; - String tableName = null; + String schema = null; + String tableName = null; Table table = null; - if (dmlConfig != null && dmlConfig.getOriTable() != null) { + if (dmlConfig != null && dmlConfig.getOriTable() != null) { table = dmlConfig.getOriTable(); if (table != null) { schema = table.getSchema(); tableName = table.getName(); } } - chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); + chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); - populateKeyColumnValueTable(dmlConfig); + populateKeyColumnValueTable(dmlConfig); updateUpdateCheckBoxEnable(); - refreshConditionList(); - } - - private void populateKeyColumnValueTable(DMLConfig dmlConfig) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); - - if (dmlConfig != null) { - boolean acceptPara = false; - for (int i = 0; i < v_Types.length; i++) { - if (v_Types[i].accept(new Parameter())) { - acceptPara = true; - break; - } - } - for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { - ColumnConfig column = dmlConfig.getColumnConfig(i); - String columnName = column.getColumnName(); - if (!acceptPara && column.getColumnValue() instanceof Parameter) { - // 表单中,将以前的参数转换为公式 - column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter)column.getColumnValue()).getName())); - } - - KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), - column.isSkipUnmodified()); - keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); - } - } - keyColumnNameValueTableModel.fireTableDataChanged(); - - // 选择第一个 - if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - - public DBManipulation updateBean() { - DataBaseItems para = chooseTable.updateBean(true); - DBManipulation dbMani = new DBManipulation(); - dbMani.setName(subMitName); - dbMani.setDBName(para.getDatabaseName()); + refreshConditionList(); + } + + private void populateKeyColumnValueTable(DMLConfig dmlConfig) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); + + if (dmlConfig != null) { + boolean acceptPara = false; + for (int i = 0; i < v_Types.length; i++) { + if (v_Types[i].accept(new Parameter())) { + acceptPara = true; + break; + } + } + for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { + ColumnConfig column = dmlConfig.getColumnConfig(i); + String columnName = column.getColumnName(); + if (!acceptPara && column.getColumnValue() instanceof Parameter) { + // 表单中,将以前的参数转换为公式 + column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter) column.getColumnValue()).getName())); + } - DMLConfig dmlConfig = new IntelliDMLConfig(); - if (dmlConfigComboBox.getSelectedIndex() == 1) { - dmlConfig = new DeleteConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 2) { - dmlConfig = new InsertConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 3) { - dmlConfig = new UpdateConfig(); - } + KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), + column.isSkipUnmodified()); + keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); + } + } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // 选择第一个 + if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + + @Override + public DBManipulation updateBean() { + DataBaseItems para = chooseTable.updateBean(true); + DBManipulation dbMani = new DBManipulation(); + dbMani.setName(subMitName); + dbMani.setDBName(para.getDatabaseName()); + + DMLConfig dmlConfig = new IntelliDMLConfig(); + if (dmlConfigComboBox.getSelectedIndex() == 1) { + dmlConfig = new DeleteConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 2) { + dmlConfig = new InsertConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 3) { + dmlConfig = new UpdateConfig(); + } - dbMani.setDmlConfig(dmlConfig); + dbMani.setDmlConfig(dmlConfig); - dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); + dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); - for (int i = 0; i < rowCount; i++) { - KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); - // peter:先添加key column name. + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); + for (int i = 0; i < rowCount; i++) { + KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); + // peter:先添加key column name. - dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey,false)); - } + dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey, false)); + } dmlConfig.setUpdateSelected(UpdateCheckBox.isSelected()); - if (jobs != null) { - for (int i = 0; i < jobs.length; i++) { - dmlConfig.addSubmitJob(jobs[i]); - } - } - dmlConfig.setCondition(condition); - - return dbMani; - } - - protected class ValuePane extends BasicBeanPane { - ValueEditorPane vPane; - - public ValuePane() { - this(v_Types); - } - - public ValuePane(Editor[] types) { - vPane = new ValueEditorPane(types); - this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); - this.add(vPane); - vPane.setPreferredSize(new Dimension(220, 25)); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); - } - - public void populateBean(Object object) { - vPane.populate(object); - } - - @Override - public Object updateBean() { - return vPane.update(); - } - - } - - /* - * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 - */ - protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { - /** The Swing component being edited. */ - private UILabel textLabel; - private ValuePane vPane; - private BasicDialog vPaneDLG; - - protected ColumnValueEditor() { - this(v_Types); - } - - protected ColumnValueEditor(Editor[] types) { - textLabel = new UILabel(); - textLabel.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - vPaneDLG.setAlwaysOnTop(true); - vPaneDLG.setVisible(true); - - } - }); - - vPane = new ValuePane(types); - vPaneDLG = vPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { - public void doOk() { - fireEditingStopped(); // Make the renderer - // reappear. + if (jobs != null) { + for (NameSubmitJob job : jobs) { + dmlConfig.addSubmitJob(job); + } + } + dmlConfig.setCondition(condition); + + return dbMani; + } + + protected class ValuePane extends BasicBeanPane { + ValueEditorPane vPane; + + public ValuePane() { + this(v_Types); + } + + public ValuePane(Editor[] types) { + vPane = new ValueEditorPane(types); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); + this.add(vPane); + vPane.setPreferredSize(new Dimension(220, 25)); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); + } + + @Override + public void populateBean(Object object) { + vPane.populate(object); + } + + @Override + public Object updateBean() { + return vPane.update(); + } + + } + + /* + * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 + */ + protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { + /** + * The Swing component being edited. + */ + private final UILabel textLabel; + private final ValuePane vPane; + + protected ColumnValueEditor() { + this(v_Types); + } + + /** + * 列值编辑器 + * + * @param types 编辑器类型 + */ + protected ColumnValueEditor(Editor[] types) { + textLabel = new UILabel(); + DialogActionAdapter adapter = new DialogActionAdapter() { + @Override + public void doOk() { + fireEditingStopped(); // Make the renderer + // reappear. updateUpdateCheckBoxEnable(); - } - - public void doCancel() { - fireEditingCanceled(); - } - }); - } - - /* - * 双击以编辑 - */ - public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof MouseEvent) { - return ((MouseEvent)anEvent).getClickCount() >= 2; - } - return true; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof ColumnValue) { - vPane.populateBean(((ColumnValue)value).obj); - - if (((ColumnValue)value).obj != null) { - textLabel.setText(((ColumnValue)value).obj.toString()); - } else { - textLabel.setText(""); - } - } - - return textLabel; - } - - public Object getCellEditorValue() { - return new ColumnValue(vPane.updateBean()); - } - } - - public static class ColumnName { - public String name; - - public ColumnName(String name) { - this.name = name; - } - - public boolean equals(Object obj) { - if (!(obj instanceof ColumnName)) { - return false; - } - - return ComparatorUtils.equals(this.name, ((ColumnName)obj).name); - } - - @Override - protected ColumnName clone() throws CloneNotSupportedException { - return new ColumnName(name); - } - } - - public static class ColumnValue { - public Object obj; - - public ColumnValue(Object obj) { - this.obj = obj; - } - - public Object getObj(){ + } + + @Override + public void doCancel() { + fireEditingCanceled(); + } + }; + textLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + Window window = e.getComponent() == null + ? DesignerContext.getDesignerFrame() + : SwingUtilities.getWindowAncestor(e.getComponent()); + vPane.showSmallWindow(window, adapter) + .setVisible(true); + } + }); + vPane = new ValuePane(types); + } + + /* + * 双击以编辑 + */ + @Override + public boolean isCellEditable(EventObject anEvent) { + if (anEvent instanceof MouseEvent) { + return ((MouseEvent) anEvent).getClickCount() >= 2; + } + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof ColumnValue) { + vPane.populateBean(((ColumnValue) value).obj); + + if (((ColumnValue) value).obj != null) { + textLabel.setText(((ColumnValue) value).obj.toString()); + } else { + textLabel.setText(""); + } + } + + return textLabel; + } + + @Override + public Object getCellEditorValue() { + return new ColumnValue(vPane.updateBean()); + } + } + + public static class ColumnName { + public String name; + + public ColumnName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnName)) { + return false; + } + + return ComparatorUtils.equals(this.name, ((ColumnName) obj).name); + } + + @Override + protected ColumnName clone() throws CloneNotSupportedException { + return new ColumnName(name); + } + } + + public static class ColumnValue { + public Object obj; + + public ColumnValue(Object obj) { + this.obj = obj; + } + + public Object getObj() { return obj; } - public boolean equals(Object obj) { - if (!(obj instanceof ColumnValue)) { - return false; - } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnValue)) { + return false; + } - return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj); - } + return ComparatorUtils.equals(this.obj, ((ColumnValue) obj).obj); + } - @Override - protected ColumnValue clone() throws CloneNotSupportedException { - return new ColumnValue(obj); - } - } + @Override + protected ColumnValue clone() throws CloneNotSupportedException { + return new ColumnValue(obj); + } + } - protected static class KeyColumnNameValueTable extends JTable { + protected static class KeyColumnNameValueTable extends JTable { - public KeyColumnNameValueTable() { - super(new KeyColumnValueTableModel(null)); - } + public KeyColumnNameValueTable() { + super(new KeyColumnValueTableModel(null)); + } - public KeyColumnTableModel getTableModel4SmartAddCell() { - KeyColumnTableModel clonedTableModel = null; - try { - //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 - clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return new KeyColumnValueTableModel(clonedTableModel); - } + public KeyColumnTableModel getTableModel4SmartAddCell() { + KeyColumnTableModel clonedTableModel = null; + try { + //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 + clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return new KeyColumnValueTableModel(clonedTableModel); + } - } + } - protected abstract static class KeyColumnTableModel extends AbstractTableModel { + protected abstract static class KeyColumnTableModel extends AbstractTableModel { public static final String RAW_KEY = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_RWA_Key"); public static final String COLUMN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Column"); - public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); - - public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; - - protected List keyColumnNameValueList = new ArrayList<>(); - - public KeyColumnTableModel(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - - public String getColumnName(int col) { - return COLUMN_NAMES[col]; - } - - public int getColumnCount() { - return COLUMN_NAMES.length; - } - - public int getRowCount() { - return keyColumnNameValueList.size(); - } - - public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { - this.keyColumnNameValueList.add(keyColumnNameValue); - } - - public void removeKeyColumnNameValue(int index) { - this.keyColumnNameValueList.remove(index); - } - - public KeyColumnNameValue getKeyColumnNameValue(int index) { - return this.keyColumnNameValueList.get(index); - } - - public void removeAllKeyColumnNameValue() { - this.keyColumnNameValueList.clear(); - } - - public void refreshNameValueList(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.clear(); - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - } - - protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable{ - - public KeyColumnValueTableModel(KeyColumnTableModel model) { - super(model); - } - - public Object getValueAt(int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - switch (col) { - case 0: - return knv.isKey; - case 1: - return knv.cn; - case 2: - return knv.cv; - } - return null; - } - - public void setValueAt(Object value, int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - if (col == 0 && value instanceof Boolean) { - knv.isKey = ((Boolean)value).booleanValue(); - } else if (col == 1 && value instanceof ColumnName) { - knv.cn = (ColumnName)value; - } else if (col == 2 && value instanceof ColumnValue) { - knv.cv = (ColumnValue)value; - } - } - - public Class getColumnClass(int c) { - switch (c) { - case 0: - return Boolean.class; - case 1: - return ColumnName.class; - case 2: - return ColumnValue.class; - } - return String.class; - } - - public boolean isCellEditable(int row, int col) { - return true; - } - - @Override - protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { - KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); - cloned.keyColumnNameValueList = new ArrayList<>(); - for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { - cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); - } - return cloned; - } - } - - - - public static class KeyColumnNameValue { - private boolean isKey = false; - private ColumnName cn; - public ColumnValue cv; - - public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { - this.isKey = isKey; - this.cn = cn; - this.cv = cv; - } - - /** - * 字符串 - * - * @return 字符串z - */ - public String toString() { - return (isKey ? "* " : "") + cn + ":" + cv; - } - - @Override - protected KeyColumnNameValue clone() throws CloneNotSupportedException { - return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); - } - } - - /* - * ColumnNameTableCellRenderer - */ - public class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - } - - /* - * ColumnValueTableCellRenderer - */ - private class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnValue) { - if (((ColumnValue)value).obj != null) { - if (((ColumnValue)value).obj instanceof Date) { - this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue)value).obj)); - } else { - this.setText(((ColumnValue)value).obj.toString()); - } - } else { - this.setText(""); - } - } - - return this; - } - } + public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); + + public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; + + protected List keyColumnNameValueList = new ArrayList<>(); + + public KeyColumnTableModel(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + + @Override + public String getColumnName(int col) { + return COLUMN_NAMES[col]; + } + + @Override + public int getColumnCount() { + return COLUMN_NAMES.length; + } + + @Override + public int getRowCount() { + return keyColumnNameValueList.size(); + } + + public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { + this.keyColumnNameValueList.add(keyColumnNameValue); + } + + public void removeKeyColumnNameValue(int index) { + this.keyColumnNameValueList.remove(index); + } + + public KeyColumnNameValue getKeyColumnNameValue(int index) { + return this.keyColumnNameValueList.get(index); + } + + public void removeAllKeyColumnNameValue() { + this.keyColumnNameValueList.clear(); + } + + public void refreshNameValueList(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.clear(); + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + } + + protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable { + + public KeyColumnValueTableModel(KeyColumnTableModel model) { + super(model); + } + + @Override + public Object getValueAt(int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + switch (col) { + case 0: + return knv.isKey; + case 1: + return knv.cn; + case 2: + return knv.cv; + } + return null; + } + + @Override + public void setValueAt(Object value, int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + if (col == 0 && value instanceof Boolean) { + knv.isKey = ((Boolean) value).booleanValue(); + } else if (col == 1 && value instanceof ColumnName) { + knv.cn = (ColumnName) value; + } else if (col == 2 && value instanceof ColumnValue) { + knv.cv = (ColumnValue) value; + } + } + + @Override + public Class getColumnClass(int c) { + switch (c) { + case 0: + return Boolean.class; + case 1: + return ColumnName.class; + case 2: + return ColumnValue.class; + } + return String.class; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { + KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); + cloned.keyColumnNameValueList = new ArrayList<>(); + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); + } + return cloned; + } + } + + + public static class KeyColumnNameValue { + private boolean isKey = false; + private ColumnName cn; + public ColumnValue cv; + + public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { + this.isKey = isKey; + this.cn = cn; + this.cv = cv; + } + + /** + * 字符串 + * + * @return 字符串z + */ + @Override + public String toString() { + return (isKey ? "* " : "") + cn + ":" + cv; + } + + @Override + protected KeyColumnNameValue clone() throws CloneNotSupportedException { + return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); + } + } + + /* + * ColumnNameTableCellRenderer + */ + public static class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + } + + /* + * ColumnValueTableCellRenderer + */ + private static class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnValue) { + if (((ColumnValue) value).obj != null) { + if (((ColumnValue) value).obj instanceof Date) { + this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue) value).obj)); + } else { + this.setText(((ColumnValue) value).obj.toString()); + } + } else { + this.setText(""); + } + } + + return this; + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 5a8af100d..546648963 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -122,8 +122,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return new Component[][]{ new Component[]{dataLabelContentPane, null}, new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, - new Component[]{createLabelBorderPane(), null}, - new Component[]{createLabelBackgroundPane(), null} + new Component[]{createBorderAndBackgroundPane(), null}, }; } @@ -138,6 +137,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }; } + private JPanel createBorderAndBackgroundPane() { + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 5)); + jPanel.add(createLabelBorderPane(), BorderLayout.NORTH); + jPanel.add(createLabelBackgroundPane(), BorderLayout.CENTER); + return jPanel; + } + private JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index a430faeec..d306bb179 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -456,7 +456,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { newAdd.clear(); for (int i = 0; i < cs; i++) { for (int j = 0; j < rs; j++) { - TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j ); + TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j); if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) { String value = cellElement.toString(); if (!newAdd.contains(value) && !allColumnRow.contains(value)) { @@ -512,7 +512,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { private SmartJTablePaneAction a = new AbstractSmartJTablePaneAction(this, SmartInsertDBManipulationPane.this) { @Override public void doOk() { - ((KeyColumnTableModel)keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel)model); + ((KeyColumnTableModel) keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel) model); } @Override From 8a63306c395142faaa35345a238be4495f84d6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 15 Dec 2020 10:04:51 +0800 Subject: [PATCH 20/51] =?UTF-8?q?CHART-15835=20=20=E9=A5=BC=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=94=B9=E4=B8=BA=E5=80=BC=E6=A0=87=E7=AD=BE?= =?UTF-8?q?+=E5=88=86=E7=B1=BB=E6=A0=87=E7=AD=BE=E7=BB=84=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/van/chart/designer/PlotFactory.java | 3 + .../border/VanChartBorderWithShapePane.java | 6 +- .../SummaryValueFormatPaneWithCheckBox.java | 23 ++++ ...SummaryValueFormatPaneWithoutCheckBox.java | 23 ++++ .../VanChartPieCategoryLabelDetailPane.java | 68 +++++++++ .../style/label/VanChartPiePlotLabelPane.java | 61 ++++++++ .../VanChartPieValueLabelDetailPane.java | 72 ++++++++++ .../label/VanChartPlotLabelDetailPane.java | 17 ++- .../style/label/VanChartPlotLabelPane.java | 4 + .../VanChartPieCategoryLabelContentPane.java | 130 ++++++++++++++++++ .../VanChartPieValueLabelContentPane.java | 79 +++++++++++ 11 files changed, 483 insertions(+), 3 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index 46126d277..ab46f5526 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -35,6 +35,7 @@ import com.fr.van.chart.designer.style.VanChartRangeLegendPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanLegendPaneWidthOutHighlight; import com.fr.van.chart.designer.style.label.VanChartGaugePlotLabelPane; +import com.fr.van.chart.designer.style.label.VanChartPiePlotLabelPane; import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotRefreshTooltipPane; @@ -209,6 +210,8 @@ public class PlotFactory { public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane, boolean inCondition) { if (plot instanceof VanChartGaugePlot) { return new VanChartGaugePlotLabelPane(plot, stylePane); + } else if (plot instanceof PiePlot4VanChart) { + return new VanChartPiePlotLabelPane(plot, stylePane, inCondition); } return new VanChartPlotLabelPane(plot, stylePane, inCondition); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java index f764c9baa..f40a51f12 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java @@ -46,6 +46,10 @@ public class VanChartBorderWithShapePane extends BasicPane { createBorderPane(); } + public LineComboBox getLineTypeBox() { + return lineTypeBox; + } + private void initComponents() { lineTypeBox = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); lineColorButton = new UIButtonGroup<>(new String[]{ @@ -106,7 +110,7 @@ public class VanChartBorderWithShapePane extends BasicPane { borderRadius.setEnabled(borderShape.getSelectedIndex() == RECTANGULAR_INDEX || borderShape.getSelectedIndex() == DIALOG_INDEX); } - private JPanel createLineTypePane() { + protected JPanel createLineTypePane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java new file mode 100644 index 000000000..8d088827f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java @@ -0,0 +1,23 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-10 + */ +public class SummaryValueFormatPaneWithCheckBox extends VanChartFormatPaneWithCheckBox { + + public SummaryValueFormatPaneWithCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Use_Summary_Value"); + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java new file mode 100644 index 000000000..400af6b7f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java @@ -0,0 +1,23 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-10 + */ +public class SummaryValueFormatPaneWithoutCheckBox extends VanChartFormatPaneWithoutCheckBox { + + public SummaryValueFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Use_Summary_Value"); + } +} + diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java new file mode 100644 index 000000000..bf13ca445 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java @@ -0,0 +1,68 @@ +package com.fr.van.chart.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.stable.Constants; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.pie.style.VanChartPieCategoryLabelContentPane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPieCategoryLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartPieCategoryLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); + } + + protected void initToolTipContentPane(Plot plot) { + setDataLabelContentPane(new VanChartPieCategoryLabelContentPane(getParentPane(), this, isInCondition())); + } + + protected JPanel createLabelPositionPane(String title, Plot plot) { + String[] positionName = new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), + Toolkit.i18nText("Fine-Design_Form_Center"), + Toolkit.i18nText("Fine-Design_Chart_Axis_Top") + }; + + Integer[] positionValue = new Integer[]{Constants.BOTTOM, Constants.CENTER, Constants.TOP}; + + UIButtonGroup position = new UIButtonGroup<>(positionName, positionValue); + setPosition(position); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p, p}; + double[] col = {f, e}; + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), position}, + }; + + return TableLayoutHelper.createTableLayoutPane(components, row, col); + } + + protected void checkPositionPane(String title) { + + } + + protected JPanel createLabelBorderPane() { + return null; + } + + protected JPanel createLabelBackgroundPane() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java new file mode 100644 index 000000000..ac24b9951 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java @@ -0,0 +1,61 @@ +package com.fr.van.chart.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.AttrLabelDetail; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPiePlotLabelPane extends VanChartPlotLabelPane { + + private VanChartPlotLabelDetailPane pieCategoryLabelPane; + + public VanChartPiePlotLabelPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); + } + + protected void createLabelPane() { + setLabelPane(new JPanel(new BorderLayout(0, 4))); + setLabelDetailPane(new VanChartPieValueLabelDetailPane(getPlot(), getParentPane(), isInCondition())); + JPanel valuePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Label"), getLabelDetailPane()); + getLabelPane().add(valuePane, BorderLayout.NORTH); + + if (!isInCondition()) { + pieCategoryLabelPane = new VanChartPieCategoryLabelDetailPane(getPlot(), getParentPane(), isInCondition()); + JPanel categoryPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category_Label"), pieCategoryLabelPane); + getLabelPane().add(categoryPane, BorderLayout.CENTER); + } + } + + public void populate(AttrLabel attrLabel) { + if (attrLabel == null) { + attrLabel = ((VanChartPlot) this.getPlot()).getDefaultAttrLabel(); + } + super.populate(attrLabel); + if (pieCategoryLabelPane != null) { + AttrLabelDetail labelDetail = attrLabel.getSecondLabelDetail(); + pieCategoryLabelPane.populate(labelDetail); + } + } + + public AttrLabel update() { + AttrLabel attrLabel = super.update(); + if (pieCategoryLabelPane != null) { + AttrLabelDetail labelDetail = attrLabel.getSecondLabelDetail(); + pieCategoryLabelPane.update(labelDetail); + } else { + attrLabel.setSecondLabelDetail(null); + } + return attrLabel; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java new file mode 100644 index 000000000..707f6f5fd --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java @@ -0,0 +1,72 @@ +package com.fr.van.chart.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; +import com.fr.van.chart.designer.component.border.VanChartBorderWithShapePane; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.pie.style.VanChartPieValueLabelContentPane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPieValueLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartPieValueLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); + } + + protected void initToolTipContentPane(Plot plot) { + setDataLabelContentPane(new VanChartPieValueLabelContentPane(getParentPane(), this, isInCondition())); + } + + protected JPanel getLabelLayoutPane(JPanel panel, String title) { + return panel; + } + + protected JPanel createLabelBorderPane() { + VanChartBorderWithShapePane borderPane = new VanChartBorderWithShapePane() { + @Override + protected JPanel createLineTypePane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + double[] columnSize = {f, e}; + double[] rowSize = {p}; + + Component[][] components = new Component[][]{ + new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Border")), + UIComponentUtils.wrapWithBorderLayoutPane(getLineTypeBox())}}; + + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + } + }; + setBorderPane(borderPane); + return borderPane; + } + + protected JPanel createLabelBackgroundPane() { + VanChartBackgroundWithOutImagePane backgroundPane = new VanChartBackgroundWithOutImagePane() { + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Utils_Background")), typeComboBox}, + new Component[]{null, centerPane}, + new Component[]{getTransparentLabel(), transparent}, + }; + } + }; + setBackgroundPane(backgroundPane); + return backgroundPane; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 546648963..0e6071b55 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -83,6 +83,19 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return parent; } + public void setPosition(UIButtonGroup position) { + this.position = position; + } + + public void setBorderPane(VanChartBorderWithShapePane borderPane) { + this.borderPane = borderPane; + } + + public void setBackgroundPane(VanChartBackgroundWithOutImagePane backgroundPane) { + this.backgroundPane = backgroundPane; + } + + protected void initLabelDetailPane(Plot plot) { this.setLayout(new BorderLayout()); initToolTipContentPane(plot); @@ -145,14 +158,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return jPanel; } - private JPanel createLabelBorderPane() { + protected JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); return borderPaneWithTitle; } - private JPanel createLabelBackgroundPane() { + protected JPanel createLabelBackgroundPane() { backgroundPane = new VanChartBackgroundWithOutImagePane() { protected Component[][] getPaneComponents() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java index 71ad599fd..4aed8c30a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java @@ -44,6 +44,10 @@ public class VanChartPlotLabelPane extends BasicPane { addComponents(); } + public boolean isInCondition() { + return inCondition; + } + public VanChartPlotLabelDetailPane getLabelDetailPane() { return labelDetailPane; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java new file mode 100644 index 000000000..e5b55d749 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java @@ -0,0 +1,130 @@ +package com.fr.van.chart.pie.style; + +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; +import com.fr.plugin.chart.pie.attr.PieCategoryLabelContent; +import com.fr.van.chart.designer.component.VanChartLabelContentPane; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.SummaryValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SummaryValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-10 + */ +public class VanChartPieCategoryLabelContentPane extends VanChartLabelContentPane { + + private SummaryValueFormatPaneWithCheckBox summaryValueFormatPane; + + private SummaryValueFormatPaneWithoutCheckBox richTextSummaryValueFormatPane; + + public VanChartPieCategoryLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); + } + + @Override + protected JPanel getLabelContentPane(JPanel contentPane) { + return contentPane; + } + + @Override + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setCategoryNameFormatPane(new CategoryNameFormatPaneWithCheckBox(parent, showOnPane)); + summaryValueFormatPane = new SummaryValueFormatPaneWithCheckBox(parent, showOnPane); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane)); + richTextSummaryValueFormatPane = new SummaryValueFormatPaneWithoutCheckBox(parent, showOnPane); + } + + @Override + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{summaryValueFormatPane, null}, + }; + } + + @Override + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{richTextSummaryValueFormatPane, null}, + }; + } + + @Override + protected double[] getRowSize(double p) { + return new double[]{p, p}; + } + + public JPanel createCommonStylePane() { + setTextAttrPane(new ChartTextAttrPane()); + return getTextAttrPane(); + } + + @Override + protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + super.populateFormatPane(pieCategoryLabelContent); + summaryValueFormatPane.populate(pieCategoryLabelContent.getSummaryValueFormat()); + } + + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + getRichTextCategoryNameFormatPane(), + richTextSummaryValueFormatPane + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + pieCategoryLabelContent.getRichTextCategoryFormat(), + pieCategoryLabelContent.getRichTextSummaryValueFormat() + }; + + setRichTextAttr(new AttrTooltipRichText()); + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(pieCategoryLabelContent.getRichTextAttr()); + + checkRichEditorState(pieCategoryLabelContent); + } + + @Override + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + super.updateFormatPane(pieCategoryLabelContent); + summaryValueFormatPane.update(pieCategoryLabelContent.getSummaryValueFormat()); + } + + protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + super.updateRichEditor(pieCategoryLabelContent); + richTextSummaryValueFormatPane.update(pieCategoryLabelContent.getRichTextSummaryValueFormat()); + } + + @Override + public void setDirty(boolean isDirty) { + getCategoryNameFormatPane().setDirty(isDirty); + summaryValueFormatPane.setDirty(isDirty); + } + + @Override + public boolean isDirty() { + return getCategoryNameFormatPane().isDirty() || summaryValueFormatPane.isDirty(); + } + + protected AttrTooltipContent createAttrTooltip() { + return new PieCategoryLabelContent(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java new file mode 100644 index 000000000..ddc6e6631 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java @@ -0,0 +1,79 @@ +package com.fr.van.chart.pie.style; + +import com.fr.van.chart.designer.component.VanChartLabelContentPane; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPieValueLabelContentPane extends VanChartLabelContentPane { + + public VanChartPieValueLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); + } + + @Override + protected JPanel getLabelContentPane(JPanel contentPane) { + return contentPane; + } + + @Override + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); + } + + @Override + protected double[] getRowSize(double p) { + return new double[]{p, p, p}; + } + + @Override + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + }; + } + + @Override + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null} + }; + } + + @Override + public void setDirty(boolean isDirty) { + getSeriesNameFormatPane().setDirty(isDirty); + getValueFormatPane().setDirty(isDirty); + getPercentFormatPane().setDirty(isDirty); + } + + @Override + public boolean isDirty() { + return getSeriesNameFormatPane().isDirty() || getValueFormatPane().isDirty() || getPercentFormatPane().isDirty(); + } +} From ab4f4465686579f917794a628389495c2eed5dcd Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Dec 2020 11:37:09 +0800 Subject: [PATCH 21/51] =?UTF-8?q?KERNEL-6224=20=E6=96=B0=E5=A2=9E=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=93=8D=E4=BD=9C=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 13 ++++++++++++- .../fr/design/mainframe/JTemplateEvent.java | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 6c6de287e..316f48fc3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -49,6 +49,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.preview.PagePreview; import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationPane; +import com.fr.event.EventDispatcher; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.MemFILE; @@ -107,7 +108,6 @@ public abstract class JTemplate> private DesignModelAdapter designModel; private PreviewProvider previewType; protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); - public int resolution = ScreenResolution.getScreenResolution(); private PluginEventListener pluginListener; @@ -125,6 +125,7 @@ public abstract class JTemplate> public JTemplate(T t, FILE file, boolean isNewFile) { super(t); + beforeInit(); // 判断是否切换设计器状态到禁止拷贝剪切 if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT); @@ -301,6 +302,13 @@ public abstract class JTemplate> } + /** + * 模板初始化之前 + */ + private void beforeInit() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_INIT, this); + } + /** * 模板关闭时 */ @@ -309,6 +317,7 @@ public abstract class JTemplate> PluginListenerRegistration.getInstance().stopListen(this.pluginListener); } + /** * 刷新内部资源 * @@ -1083,6 +1092,7 @@ public abstract class JTemplate> * 激活已存在的模板 */ public void activeOldJTemplate() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); DesignerContext.getDesignerFrame().activateJTemplate(this); } @@ -1090,6 +1100,7 @@ public abstract class JTemplate> * 激活新的模板 */ public void activeNewJTemplate() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java new file mode 100644 index 000000000..d60d06474 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java @@ -0,0 +1,19 @@ +package com.fr.design.mainframe; + +import com.fr.event.Event; + +/** + * Created by kerry on 2020-12-11 + */ +public enum JTemplateEvent implements Event { + /** + * 模板初始化之前 + */ + BEFORE_TEMPLATE_INIT, + + /** + * 模板激活之前 + */ + BEFORE_TEMPLATE_ACTIVE + +} From 0d92fd4e9d3bfe39f68696f0e30ca7064f527c99 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Dec 2020 11:40:29 +0800 Subject: [PATCH 22/51] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/FormDesignerUI.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index a21a2efad..cdec956ed 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -49,7 +49,6 @@ public class FormDesignerUI extends ComponentUI { private FormDesigner designer; private SelectionModel selectionModel; private Rectangle2D.Double back_or_selection_rect = new Rectangle2D.Double(0, 0, 0, 0); - private float time; public FormDesignerUI() { } @@ -71,7 +70,6 @@ public class FormDesignerUI extends ComponentUI { @Override public void paint(final Graphics g, JComponent c) { XCreator rootComponent = designer.getRootComponent(); - this.time = (float) designer.getResolution() / ScreenResolution.getScreenResolution(); AffineTransform at = new AffineTransform(); if (rootComponent.getParent() != null) { at.translate(designer.getPaintX(), designer.getPaintY()); From 454e69707bd76de4df30f9f813b74575d0123ba5 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Dec 2020 11:43:33 +0800 Subject: [PATCH 23/51] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8impor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/FormDesignerUI.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index cdec956ed..7c3e86a57 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe; import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; import com.fr.base.Utils; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.vcs.DesignerMode; From 981f025d40d6eb91beec3ab7504545d99c79c55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 15 Dec 2020 14:09:14 +0800 Subject: [PATCH 24/51] fix --- .../style/label/VanChartPieCategoryLabelDetailPane.java | 6 +----- .../designer/style/label/VanChartPlotLabelDetailPane.java | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java index bf13ca445..4c28c78b0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java @@ -58,11 +58,7 @@ public class VanChartPieCategoryLabelDetailPane extends VanChartPlotLabelDetailP } - protected JPanel createLabelBorderPane() { - return null; - } - - protected JPanel createLabelBackgroundPane() { + protected JPanel createBorderAndBackgroundPane() { return null; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 0e6071b55..20ce7452b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -150,7 +150,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }; } - private JPanel createBorderAndBackgroundPane() { + protected JPanel createBorderAndBackgroundPane() { JPanel jPanel = new JPanel(); jPanel.setLayout(new BorderLayout(0, 5)); jPanel.add(createLabelBorderPane(), BorderLayout.NORTH); @@ -158,14 +158,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return jPanel; } - protected JPanel createLabelBorderPane() { + private JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); return borderPaneWithTitle; } - protected JPanel createLabelBackgroundPane() { + private JPanel createLabelBackgroundPane() { backgroundPane = new VanChartBackgroundWithOutImagePane() { protected Component[][] getPaneComponents() { From 941a3837e700de9bb7c042316d3004b2f6c4719d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 8 Dec 2020 18:48:02 +0800 Subject: [PATCH 25/51] =?UTF-8?q?CHART-17249=20=E9=AB=98=E5=BE=B7=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=85=8D=E7=BD=AE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/drillMap/DrillMapLayerPane.java | 4 +- .../designer/data/comp/DrillMapLayerPane.java | 4 +- .../type/VanChartDrillMapPlotPane.java | 16 +- .../type/VanChartHeatMapSourceChoosePane.java | 15 - .../type/VanChartHeatMapTypePane.java | 24 +- .../chart/map/designer/type/GeoUrlPane.java | 258 +++++++ .../chart/map/designer/type/GisLayerPane.java | 303 ++++++++ .../map/designer/type/MapStatusPane.java | 167 ++++ .../map/designer/type/TileLayerPane.java | 51 ++ .../designer/type/VanChartMapPlotPane.java | 1 - .../type/VanChartMapSourceChoosePane.java | 714 ++---------------- .../chart/map/designer/type/WMSLayerPane.java | 165 ++++ 12 files changed, 1022 insertions(+), 700 deletions(-) delete mode 100644 designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java index 1102f7a64..8c62d6e72 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java @@ -14,7 +14,7 @@ import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; -import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; +import com.fr.van.chart.map.designer.type.MapStatusPane; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -154,7 +154,7 @@ public class DrillMapLayerPane extends BasicBeanPane { rowSize[i + 1] = p; int d = i + 1; UILabel label = new UILabel(String.format("%s%d%s", Toolkit.i18nText("Fine-Design_Chart_Index_Article"), d, Toolkit.i18nText("Fine-Design_Chart_Index_Layer"))); - UIComboBox level = new UIComboBox(VanChartMapSourceChoosePane.ZOOM_LEVELS); + UIComboBox level = new UIComboBox(MapStatusPane.ZOOM_LEVELS); level.setEnabled(i != 0); UIComboBox type = new UIComboBox(items); detailComps[i + 1] = new Component[]{label, level, type}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java index 0c6fcc1e4..749755991 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java @@ -14,7 +14,7 @@ import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; +import com.fr.van.chart.map.designer.type.MapStatusPane; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -105,7 +105,7 @@ public class DrillMapLayerPane extends BasicScrollPane { rowSize[i + 1] = p; int d = i + 1; UILabel label = new UILabel(String.format("%s%d%s", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Article"), d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Layer"))); - UIComboBox level = new UIComboBox(VanChartMapSourceChoosePane.ZOOM_LEVELS); + UIComboBox level = new UIComboBox(MapStatusPane.ZOOM_LEVELS); level.setEnabled(i != 0); UIComboBox type = new UIComboBox(TEMP.get(oldMapType)); detailComps[i + 1] = new Component[]{label, level, type}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java index c4a803134..48f8b2434 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java @@ -8,11 +8,14 @@ import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.drillmap.DrillMapIndependentVanChart; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.drillmap.data.DrillMapDefinition; +import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.van.chart.map.designer.type.GeoUrlPane; import com.fr.van.chart.map.designer.type.VanChartMapPlotPane; import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; +import javax.swing.tree.TreeNode; import java.util.ArrayList; /** @@ -30,10 +33,15 @@ public class VanChartDrillMapPlotPane extends VanChartMapPlotPane { @Override protected VanChartMapSourceChoosePane createSourceChoosePane() { - return new VanChartMapSourceChoosePane(){ + return new VanChartMapSourceChoosePane() { @Override - protected boolean supportParam(){ - return false; + protected void initGeoUrlPane() { + setGeoUrlPane(new GeoUrlPane() { + @Override + protected TreeNode getRootNode() { + return GEOJSONTreeHelper.getInstance().getRootNodeWithoutPara(); + } + }); } }; } @@ -59,7 +67,7 @@ public class VanChartDrillMapPlotPane extends VanChartMapPlotPane { protected void resetAttr(Plot plot) { super.resetAttr(plot); - if(plot instanceof VanChartDrillMapPlot) { + if (plot instanceof VanChartDrillMapPlot) { resetLayerTypeAndZoomLevel((VanChartDrillMapPlot) plot); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java deleted file mode 100644 index 3eaec5f59..000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fr.van.chart.heatmap.designer.type; - -import com.fr.design.gui.ilable.UILabel; - -import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; - -/** - * Created by Mitisky on 16/10/20. - */ -public class VanChartHeatMapSourceChoosePane extends VanChartMapSourceChoosePane { - @Override - protected UILabel createSourceTitleLabel() { - return new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java index 8f4a72de2..32529591e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java @@ -3,6 +3,8 @@ package com.fr.van.chart.heatmap.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -11,6 +13,7 @@ import com.fr.plugin.chart.heatmap.HeatMapIndependentVanChart; import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.van.chart.map.designer.type.GeoUrlPane; import com.fr.van.chart.map.designer.type.VanChartMapPlotPane; import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; @@ -27,18 +30,27 @@ public class VanChartHeatMapTypePane extends VanChartMapPlotPane { @Override protected VanChartMapSourceChoosePane createSourceChoosePane() { - return new VanChartHeatMapSourceChoosePane(); + return new VanChartMapSourceChoosePane() { + @Override + protected void initGeoUrlPane() { + setGeoUrlPane(new GeoUrlPane() { + @Override + protected UILabel createSourceTitleLabel() { + return new UILabel(Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); + } + }); + } + }; } //适用一种图表只有一种类型的 public void populateBean(VanChart chart) { typeDemo.get(0).isPressing = true; - VanChartHeatMapPlot plot = (VanChartHeatMapPlot)chart.getPlot(); + VanChartHeatMapPlot plot = (VanChartHeatMapPlot) chart.getPlot(); populateSourcePane(plot); boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(plot.getGeoUrl()); GUICoreUtils.setEnabled(this.getTypePane(), enabled); - GUICoreUtils.setEnabled(this.getSourceChoosePane().getSourceComboBox(), enabled); checkDemosBackground(); } @@ -53,13 +65,13 @@ public class VanChartHeatMapTypePane extends VanChartMapPlotPane { return tools; } - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { Chart chart = getDefaultChart(); - VanChartHeatMapPlot newPlot = (VanChartHeatMapPlot)chart.getPlot(); + VanChartHeatMapPlot newPlot = (VanChartHeatMapPlot) chart.getPlot(); Plot cloned = null; try { - cloned = (Plot)newPlot.clone(); + cloned = (Plot) newPlot.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java new file mode 100644 index 000000000..c69297fa8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java @@ -0,0 +1,258 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.base.Parameter; +import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.FRTreeComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; +import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; +import com.fr.plugin.chart.type.MapType; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; +import com.fr.workspace.WorkContext; + +import javax.swing.JPanel; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class GeoUrlPane extends JPanel implements UIObserver { + + private UILabel sourceTitleLabel; + private FRTreeComboBox sourceComboBox; + private MapDataTree mapDataTree; + private TreePath selectTreePath; + + private UIObserverListener listener; + + private String[] oldParams; + + public GeoUrlPane() { + initComps(); + } + + private void initComps() { + this.setLayout(new BorderLayout()); + this.add(createMapSourcesPane(), BorderLayout.CENTER); + } + + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + private JPanel createMapSourcesPane() { + + mapDataTree = new MapDataTree(this.getRootNode()); + mapDataTree.setEditable(false); + mapDataTree.selectDefaultTreeNode(); + sourceComboBox = new FRTreeComboBox(mapDataTree, mapDataTree.getCellRenderer()) { + //搜索 + protected void dealSamePath(TreePath parent, TreeNode node, UITextField textField) { + String searchText = textField.getText(); + GeoUrlPane.this.mapDataTree.search(searchText); + } + + //选中 tree---combobox + public void setSelectedItem(Object o) { + TreePath oldPath = mapDataTree.getSelectionPath(); + Object oldText = getSelectedItem(); + if (o != null && o instanceof TreePath) { + selectTreePath = (TreePath) o; + this.tree.setSelectionPath(selectTreePath); + this.getModel().setSelectedItem(pathToString(selectTreePath)); + if (ComparatorUtils.equals(oldText, getSelectedItem()) && !ComparatorUtils.equals(oldPath, selectTreePath)) { + //point的江苏省切换到area的江苏省 + listener.doChange(); + } + } else if (o instanceof String) {//list里面没有 + selectTreePath = null; + this.tree.setSelectionPath(null); + this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o)); + } + } + + @Override + protected String pathToString(TreePath path) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); + //不显示后缀 + return ChartGEOJSONHelper.getPresentNameWithPath(node.toString()); + } + + @Override + protected boolean customSelectable(DefaultMutableTreeNode node) { + return GEOJSONTreeHelper.isSelectableTreeNode(node); + } + }; + sourceComboBox.setEditable(true); + sourceComboBox.setOnlyLeafSelectable(false); + sourceComboBox.addPopupMenuListener(popupMenuListener); + sourceTitleLabel = createSourceTitleLabel(); + + + boolean hasRefreshButton = !WorkContext.getCurrent().isLocal(); + UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/images/control/refresh.png")); + button.setToolTipText(Toolkit.i18nText("Fine-Design_Chart_Update_Remote_Map_JSON")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + GEOJSONHelper.reset(); + GEOJSONHelper.getInstance(); + } + }); + + double p = TableLayout.PREFERRED; + double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double f = TableLayout.FILL; + double[] rowSize = {p, p}; + double[] columnSize = hasRefreshButton ? new double[]{d + 10, e - 20, 20} : new double[]{f, e}; + + Component[] comps = hasRefreshButton + ? new Component[]{sourceTitleLabel, sourceComboBox, button} + : new Component[]{sourceTitleLabel, sourceComboBox}; + + double hGap = hasRefreshButton ? 0 : TableLayout4VanChartHelper.COMPONENT_INTERVAL; + Component[][] components = new Component[][]{ + new Component[]{null, null}, + comps, + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, hGap, LayoutConstants.VGAP_LARGE); + } + + protected UILabel createSourceTitleLabel() { + return new UILabel(Toolkit.i18nText("Fine-Design_Chart_Map_Area")); + } + + protected TreeNode getRootNode() { + return GEOJSONTreeHelper.getInstance().getRootNodeWithPara(); + } + + private String[] getParamsName() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + + if (jTemplate == null) { + return new String[0]; + } + + Parameter[] parameters = jTemplate.getJTemplateParameters(); + + int len = parameters.length; + String[] names = new String[len]; + + for (int i = 0; i < len; i++) { + names[i] = parameters[i].getName(); + } + + return names; + } + + private PopupMenuListener popupMenuListener = new PopupMenuListener() { + public void popupMenuCanceled(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + + GEOJSONTreeHelper.reset(); + mapDataTree.changeRootNode(GeoUrlPane.this.getRootNode()); + GEOJSONTreeHelper.getInstance().updateParamRootNode(GeoUrlPane.this.getParamsName()); + + if (selectTreePath != null) { + mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); + selectTreePath = mapDataTree.getSelectionPath(); + } + + mapDataTree.updateUI();//因为服务器那边可能随时编辑,所以这边要重画 + mapDataTree.setSelectionPath(selectTreePath); + mapDataTree.scrollPathToVisible(selectTreePath); + } + }; + + public void populate(VanChartMapPlot mapPlot) { + resetComponentValue(mapPlot, false); + String geoUrl = mapPlot.getGeoUrl(); + mapDataTree.setSelectNodePath(geoUrl); + selectTreePath = mapDataTree.getSelectionPath(); + + if (selectTreePath == null) {//此url当前环境没有 + sourceComboBox.setSelectedItem(geoUrl); + } else { + sourceComboBox.setSelectedItem(selectTreePath); + } + boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl()); + GUICoreUtils.setEnabled(sourceComboBox, enabled); + } + + public String update() { + return mapDataTree.getSelectNodeJSONPath(); + } + + protected void resetComponentValue(VanChartMapPlot mapPlot, boolean samePlotChange) { + MapType mapType = mapPlot.getMapType(); + + //获取最新的参数 + String[] params = getParamsName(); + + if (!ComparatorUtils.equals(oldParams, params)) { + oldParams = params; + GEOJSONTreeHelper.getInstance().updateParamRootNode(params); + } + + mapDataTree.changeRootNode(this.getRootNode()); + if (samePlotChange) { + String nodePath = ChartGEOJSONHelper.getDefaultJSONURL(); + mapPlot.setGeoUrl(nodePath); + mapDataTree.setSelectNodePath(nodePath); + selectTreePath = mapDataTree.getSelectionPath(); + sourceComboBox.setSelectedItem(selectTreePath); + } + switch (mapType) { + case CUSTOM: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); + break; + case POINT: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Point")); + break; + case LINE: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Point")); + break; + default: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Area")); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java new file mode 100644 index 000000000..406b89610 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java @@ -0,0 +1,303 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.base.Utils; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.base.GisLayer; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.server.MapLayerConfigManager; +import com.fr.plugin.chart.type.GISLayerType; +import com.fr.plugin.chart.type.GaoDeGisType; +import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ItemEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class GisLayerPane extends JPanel implements UIObserver { + + private UIButtonGroup gisButton; + private JPanel layerPaneCheckPane; + private UIComboBox gisGaoDeLayer; + private UIComboBox gisLayer; + private JPanel layerCardPane; + + private WMSLayerPane wmsLayerPane; + private TileLayerPane tileLayerPane; + + private UIComboBox zoomLevel; + + private String[] layers = MapLayerConfigManager.getLayerItems(); + + public GisLayerPane() { + initComps(); + } + + private void initComps() { + this.setLayout(new BorderLayout()); + this.add(createGISLayerPane(), BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.wmsLayerPane.registerChangeListener(listener); + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + public void registerZoomLevel(UIComboBox zoomLevel) { + this.zoomLevel = zoomLevel; + } + + private boolean isStandardGis() { + return gisButton.getSelectedIndex() == 0; + } + + + private JPanel createGISLayerPane() { + gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); + gisGaoDeLayer = new UIComboBox(MapLayerConfigManager.getGaoDeLayerItems()); + gisButton.addActionListener(event -> { + refreshZoomLevel(); + checkLayerCardPane(); + }); + + gisGaoDeLayer.addItemListener(event -> refreshZoomLevel()); + + initCustomGISLayerPane(); + initLayerCardPane(); + + layerPaneCheckPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (isStandardGis()) { + return gisGaoDeLayer.getPreferredSize(); + } else { + return gisLayer.getPreferredSize(); + } + } + }; + layerPaneCheckPane.add(gisGaoDeLayer, "standard"); + layerPaneCheckPane.add(gisLayer, "custom"); + + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p, p, p}; + double[] col = {f, e}; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gis_Layer")), gisButton}, + new Component[]{null, layerPaneCheckPane}, + new Component[]{layerCardPane, null}, + }; + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + return panel; + } + + private void initLayerCardPane() { + tileLayerPane = new TileLayerPane(); + wmsLayerPane = new WMSLayerPane(); + + layerCardPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (isStandardGis()) { + return new Dimension(0, 0); + } + String itemName = Utils.objectToString(gisLayer.getSelectedItem()); + if (MapLayerConfigManager.isCustomLayer(itemName)) { + return tileLayerPane.getPreferredSize(); + } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { + return wmsLayerPane.getPreferredSize(); + } + return new Dimension(0, 0); + } + }; + + for (String itemName : layers) { + JPanel pane = new JPanel(); + if (MapLayerConfigManager.isCustomLayer(itemName)) { + pane = tileLayerPane; + } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { + pane = wmsLayerPane; + } + layerCardPane.add(pane, itemName); + } + } + + private void initCustomGISLayerPane() { + gisLayer = new UIComboBox(layers); + + gisLayer.addItemListener(e -> + { + if (e.getStateChange() == ItemEvent.SELECTED) { + checkCustomLayerCardPane(); + } + refreshZoomLevel(); + } + ); + + gisLayer.addPopupMenuListener(new PopupMenuListener() { + public void popupMenuCanceled(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + + String selected = Utils.objectToString(gisLayer.getSelectedItem()); + ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); + + gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); + + gisLayer.setSelectedItem(selected); + zoomLevel.setSelectedItem(zoomSelected); + } + }); + } + + private void refreshZoomLevel() { + //gis图层不同,对应的缩放等级不同。 + ZoomLevel[] levels; + if (isStandardGis()) { + if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { + levels = MapStatusPane.ZOOM_LEVELS; + } else { + levels = MapStatusPane.GAODE_ZOOM_LEVELS; + } + } else { + if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { + levels = MapStatusPane.BLUE_ZOOM_LEVELS; + } else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { + levels = MapStatusPane.GAODE_ZOOM_LEVELS; + } else { + levels = MapStatusPane.ZOOM_LEVELS; + } + } + zoomLevel.setModel(new DefaultComboBoxModel(levels)); + } + + + private void checkLayerCardPane() { + CardLayout cardLayout = (CardLayout) layerPaneCheckPane.getLayout(); + cardLayout.show(layerPaneCheckPane, isStandardGis() ? "standard" : "custom"); + } + + private void checkCustomLayerCardPane() { + CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); + cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); + } + + public void resetGisLayer(VanChartMapPlot mapPlot) { + //TODO Bjorn 地图gis图层自动逻辑 + /* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); + mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ + + GaoDeGisType gaoDeGisType= mapPlot.getDefaultGisLayerType(); + + mapPlot.getGisLayer().setGisLayerType(GISLayerType.GAO_DE_API); + mapPlot.getGisLayer().setLayerName(gaoDeGisType.getTypeName()); + mapPlot.getGisLayer().setGaoDeGisType(gaoDeGisType); + populate(mapPlot.getGisLayer()); + } + + public void populate(GisLayer layer) { + switch (layer.getGisLayerType()) { + case GAO_DE_API: + case LAYER_NULL: + populateStandardGis(layer); + break; + default: + populateCustomGis(layer); + } + refreshZoomLevel(); + + checkCustomLayerCardPane(); + checkLayerCardPane(); + } + + private void populateStandardGis(GisLayer layer) { + gisButton.setSelectedIndex(0); + if (layer.getGisLayerType() == GISLayerType.LAYER_NULL) { + gisGaoDeLayer.setSelectedIndex(gisGaoDeLayer.getItemCount() - 1); + } else { + gisGaoDeLayer.setSelectedItem(layer.getGaoDeGisType().getTypeName()); + } + } + + private void populateCustomGis(GisLayer layer) { + gisButton.setSelectedIndex(1); + gisLayer.setSelectedItem(layer.getShowItemName()); + + switch (layer.getGisLayerType()) { + case CUSTOM_WMS_LAYER: + wmsLayerPane.populate(layer); + break; + case CUSTOM_TILE_LAYER: + tileLayerPane.populate(layer); + break; + } + } + + public void update(GisLayer layer) { + if (isStandardGis()) { + updateStandardGis(layer); + } else { + updateCustomGis(layer); + } + } + + private void updateStandardGis(GisLayer layer) { + String layerName = Utils.objectToString(gisGaoDeLayer.getSelectedItem()); + layer.setLayerName(layerName); + if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { + layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); + } else { + layer.setGisLayerType(GISLayerType.GAO_DE_API); + layer.setGaoDeGisType(GaoDeGisType.parseByLocaleName(layerName)); + } + } + + private void updateCustomGis(GisLayer layer) { + String layerName = Utils.objectToString(gisLayer.getSelectedItem()); + layer.setLayerName(layerName); + layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); + + switch (layer.getGisLayerType()) { + case CUSTOM_WMS_LAYER: + wmsLayerPane.update(layer); + break; + case CUSTOM_TILE_LAYER: + tileLayerPane.update(layer); + break; + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java new file mode 100644 index 000000000..668a9b774 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java @@ -0,0 +1,167 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.plugin.chart.base.ViewCenter; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.stable.ArrayUtils; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class MapStatusPane extends JPanel { + + public static final ZoomLevel[] ZOOM_LEVELS = new ZoomLevel[]{ + ZoomLevel.AUTO, + ZoomLevel.ZERO, ZoomLevel.ZEROPOINTFIVE, + ZoomLevel.ONE, ZoomLevel.ONEPOINTFIVE, + ZoomLevel.TWO, ZoomLevel.TWOPOINTFIVE, + ZoomLevel.THREE, ZoomLevel.THREEPOINTFIVE, + ZoomLevel.FOUR, ZoomLevel.FOURPOINTFIVE, + ZoomLevel.FIVE, ZoomLevel.FIVEPOINTFIVE, + ZoomLevel.SIX, ZoomLevel.SIXPOINTFIVE, + ZoomLevel.SEVEN, ZoomLevel.SEVENPOINTFIVE, + ZoomLevel.EIGHT, ZoomLevel.EIGHTPOINTFIVE, + ZoomLevel.NINE, ZoomLevel.NINEPOINTFIVE, + ZoomLevel.TEN, ZoomLevel.TENPOINTFIVE, + ZoomLevel.ELEVEN, ZoomLevel.ELEVENTPOINTFIVE, + ZoomLevel.TWELVE, ZoomLevel.TWELVEPOINTFIVE, + ZoomLevel.THIRTEEN, ZoomLevel.THIRTEENPOINTFIVE, + ZoomLevel.FOURTEEN, ZoomLevel.FOURTEENPOINTFIVE, + ZoomLevel.FIFTEEN, ZoomLevel.FIFTEENPOINTFIVE, + ZoomLevel.SIXTEEN, ZoomLevel.SIXTEENPOINTFIVE, + ZoomLevel.SEVENTEEN, ZoomLevel.SEVENTEENPOINTFIVE, + ZoomLevel.EIGHTEEN + }; + //深蓝和高德地图下拉框层级 + public static final ZoomLevel[] BLUE_ZOOM_LEVELS = ArrayUtils.subarray(ZOOM_LEVELS, 0, 34); + public static final ZoomLevel[] GAODE_ZOOM_LEVELS = ArrayUtils.addAll(new ZoomLevel[]{ZoomLevel.AUTO}, (ZoomLevel[]) ArrayUtils.subarray(ZOOM_LEVELS, 7, 38)); + private static final String AUTO_CENTER_STRING = Toolkit.i18nText("Fine-Design_Chart_Automatic"); + private static final String CUSTOM_CENTER_STRING = Toolkit.i18nText("Fine-Design_Chart_Custom"); + + + private JPanel levelAndCenterPane; + private JPanel longAndLatPane; + + private UIComboBox zoomLevel; + private UIButtonGroup viewCenterCom; + private UISpinner longitude; + private UISpinner latitude; + + public MapStatusPane() { + initComps(); + } + + public UIComboBox getZoomLevel() { + return zoomLevel; + } + + private void initComps() { + zoomLevel = new UIComboBox(ZOOM_LEVELS); + viewCenterCom = new UIButtonGroup(new String[]{AUTO_CENTER_STRING, CUSTOM_CENTER_STRING}); + longitude = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1, 0.0); + latitude = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1, 0.0); + + double p = TableLayout.PREFERRED; + double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; + double[] rowSize = {p, p, p}; + double[] columnSize = {d, e}; + double[] column = {d, s}; + + Component[][] comps = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), zoomLevel}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_View_Center")), viewCenterCom}, + }; + levelAndCenterPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, columnSize); + + Component[][] longAndLatComps = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitude}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitude} + }; + longAndLatPane = TableLayout4VanChartHelper.createGapTableLayoutPane(longAndLatComps, rowSize, column); + longAndLatPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); + longAndLatPane.setVisible(false); + + this.setLayout(new BorderLayout(0, 6)); + + this.add(levelAndCenterPane, BorderLayout.NORTH); + this.add(longAndLatPane, BorderLayout.CENTER); + + viewCenterCom.addActionListener(event -> + longAndLatPane.setVisible(!isAutoViewCenter())); + } + + @Override + public Dimension getPreferredSize() { + if (longAndLatPane.isVisible()) { + return super.getPreferredSize(); + } else { + return levelAndCenterPane.getPreferredSize(); + } + } + + private boolean isAutoViewCenter() { + return viewCenterCom.getSelectedIndex() == 0; + } + + + public void resetViewCenter(VanChartMapPlot mapPlot) { + mapPlot.setViewCenter(new ViewCenter()); + viewCenterCom.setSelectedIndex(0); + longitude.setValue(0); + latitude.setValue(0); + longAndLatPane.setVisible(false); + } + + public void resetZoomLevel(VanChartMapPlot mapPlot) { + mapPlot.setZoomLevel(ZoomLevel.AUTO); + zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); + } + + public void populate(VanChartMapPlot mapPlot) { + zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); + + ViewCenter viewCenter = mapPlot.getViewCenter(); + if (viewCenter.isAuto()) { + viewCenterCom.setSelectedIndex(0); + longitude.setValue(0); + latitude.setValue(0); + } else { + viewCenterCom.setSelectedIndex(1); + longitude.setValue(viewCenter.getLongitude()); + latitude.setValue(viewCenter.getLatitude()); + } + + longAndLatPane.setVisible(!isAutoViewCenter()); + } + + public void update(VanChartMapPlot mapPlot) { + mapPlot.setZoomLevel((ZoomLevel) zoomLevel.getSelectedItem()); + + ViewCenter viewCenter = mapPlot.getViewCenter(); + if (isAutoViewCenter()) { + viewCenter.setAuto(true); + } else { + viewCenter.setAuto(false); + viewCenter.setLongitude(longitude.getValue()); + viewCenter.setLatitude(latitude.getValue()); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java new file mode 100644 index 000000000..4101fbd9d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java @@ -0,0 +1,51 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.layout.TableLayout; +import com.fr.plugin.chart.base.GisLayer; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class TileLayerPane extends JPanel { + + private UITextArea customTileLayer; + private UITextArea attribution; + + + public TileLayerPane() { + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH - 3}; + + customTileLayer = new UITextArea(); + attribution = new UITextArea(); + Component[][] comps = new Component[][]{ + new Component[]{new UILabel("url"), customTileLayer}, + new Component[]{new UILabel("Attribution"), attribution} + }; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); + panel.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); + + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); + } + + public void populate(GisLayer layer) { + customTileLayer.setText(layer.getCustomTileLayer()); + attribution.setText(layer.getAttribution()); + } + + public void update(GisLayer layer) { + layer.setCustomTileLayer(customTileLayer.getText()); + layer.setAttribution(attribution.getText()); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java index a4356be87..a5e26427b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java @@ -78,7 +78,6 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(plot.getGeoUrl()); GUICoreUtils.setEnabled(this.getTypePane(), enabled); - GUICoreUtils.setEnabled(this.sourceChoosePane.getSourceComboBox(), enabled); checkDemosBackground(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java index bbe9d7dd4..5be437619 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java @@ -1,739 +1,113 @@ package com.fr.van.chart.map.designer.type; -import com.fr.base.Parameter; -import com.fr.base.Utils; -import com.fr.decision.webservice.v10.map.WMSFactory; -import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.FRTreeComboBox; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextarea.UITextArea; -import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.JTemplate; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.general.http.HttpClient; -import com.fr.plugin.chart.base.GisLayer; -import com.fr.plugin.chart.base.ViewCenter; import com.fr.plugin.chart.map.VanChartMapPlot; -import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; -import com.fr.plugin.chart.map.layer.WMSLayer; -import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; -import com.fr.plugin.chart.map.server.MapLayerConfigManager; -import com.fr.plugin.chart.type.GISLayerType; -import com.fr.plugin.chart.type.MapType; -import com.fr.plugin.chart.type.ZoomLevel; -import com.fr.stable.ArrayUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; -import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.SwingWorker; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; -import java.util.ArrayList; -import java.util.List; import java.awt.BorderLayout; -import java.awt.CardLayout; import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; /** * Created by Mitisky on 16/5/11. * 地图类型选择面板,关于json资源路径/gis图层等设置面板 */ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { - private static final double[] COLUMN_SIZE = {48, TableLayout.FILL, TableLayout.PREFERRED}; - public static final ZoomLevel[] ZOOM_LEVELS = new ZoomLevel[]{ - ZoomLevel.AUTO, - ZoomLevel.ZERO, ZoomLevel.ZEROPOINTFIVE, - ZoomLevel.ONE, ZoomLevel.ONEPOINTFIVE, - ZoomLevel.TWO, ZoomLevel.TWOPOINTFIVE, - ZoomLevel.THREE, ZoomLevel.THREEPOINTFIVE, - ZoomLevel.FOUR, ZoomLevel.FOURPOINTFIVE, - ZoomLevel.FIVE, ZoomLevel.FIVEPOINTFIVE, - ZoomLevel.SIX, ZoomLevel.SIXPOINTFIVE, - ZoomLevel.SEVEN, ZoomLevel.SEVENPOINTFIVE, - ZoomLevel.EIGHT, ZoomLevel.EIGHTPOINTFIVE, - ZoomLevel.NINE, ZoomLevel.NINEPOINTFIVE, - ZoomLevel.TEN, ZoomLevel.TENPOINTFIVE, - ZoomLevel.ELEVEN, ZoomLevel.ELEVENTPOINTFIVE, - ZoomLevel.TWELVE, ZoomLevel.TWELVEPOINTFIVE, - ZoomLevel.THIRTEEN, ZoomLevel.THIRTEENPOINTFIVE, - ZoomLevel.FOURTEEN, ZoomLevel.FOURTEENPOINTFIVE, - ZoomLevel.FIFTEEN, ZoomLevel.FIFTEENPOINTFIVE, - ZoomLevel.SIXTEEN, ZoomLevel.SIXTEENPOINTFIVE, - ZoomLevel.SEVENTEEN, ZoomLevel.SEVENTEENPOINTFIVE, - ZoomLevel.EIGHTEEN - }; - //深蓝和高德地图下拉框层级 - private static final ZoomLevel[] BLUE_ZOOM_LEVELS =(ZoomLevel[]) ArrayUtils.subarray(ZOOM_LEVELS, 0, 34); - private static final ZoomLevel[] GAODE_ZOOM_LEVELS =ArrayUtils.addAll(new ZoomLevel[]{ZoomLevel.AUTO}, (ZoomLevel[])ArrayUtils.subarray(ZOOM_LEVELS, 7, 38)); - private static final String AUTO_CENTER_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"); - private static final String CUSTOM_CENTER_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom"); - private UILabel sourceTitleLabel; - private FRTreeComboBox sourceComboBox; - private MapDataTree mapDataTree; - private TreePath selectTreePath; + private GeoUrlPane geoUrlPane; - private UIComboBox gisLayer; - private JPanel layerCardPane; + private GisLayerPane gisLayerPane; - private UITextArea wmsUrl; - private UIButton connectButton; - private JPanel wmsLayerPane; - - private java.util.List wmsLayerCheckBoxs = new ArrayList(); - - private UITextArea customTileLayer; - private UITextArea attribution; - - private UIComboBox zoomLevel; - private UIButtonGroup viewCenterCom; - private JPanel longAndLatPane; - private UISpinner longitude; - private UISpinner latitude; - - private String[] oldParams; - - private UIObserverListener listener; - private String[] layers = MapLayerConfigManager.getLayerItems(); - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - @Override - public void registerChangeListener(UIObserverListener listener) { - this.listener = listener; - } - - /** - * 组件是否需要响应添加的观察者事件 - * - * @return 如果需要响应观察者事件则返回true,否则返回false - */ - @Override - public boolean shouldResponseChangeListener() { - return true; - } + private MapStatusPane mapStatusPane; public VanChartMapSourceChoosePane() { + initGeoUrlPane(); + initMapStatusPane(); + initGisLayerPane(); + this.setLayout(new BorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10,5,0,0)); + this.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); double p = TableLayout.PREFERRED; double[] columnSize = {230}; - double[] rowSize = {p,p,p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p, p}; JPanel panel = new JPanel(new BorderLayout()); - panel.add(createMapSourcesPane(), BorderLayout.NORTH); - panel.add(createGISLayerPane(), BorderLayout.CENTER); - JPanel BasePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), panel); + panel.add(geoUrlPane, BorderLayout.NORTH); + panel.add(gisLayerPane, BorderLayout.CENTER); + JPanel basePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Report_Basic"), panel); + + JPanel mapStatusPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Map_Init_Status"), mapStatusPane); Component[][] comps = new Component[][]{ - new Component[]{BasePane}, - new Component[]{createMapInitStatusPane()} + new Component[]{basePane}, + new Component[]{mapStatusPaneWithTitle} }; - JPanel contentPane = TableLayoutHelper.createTableLayoutPane(comps,rowSize,columnSize); + JPanel contentPane = TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize); this.add(contentPane, BorderLayout.CENTER); } - protected boolean supportParam(){ - return true; - } - - protected TreeNode getRootNode() { - return supportParam() ? GEOJSONTreeHelper.getInstance().getRootNodeWithPara() : GEOJSONTreeHelper.getInstance().getRootNodeWithoutPara(); + public void setGeoUrlPane(GeoUrlPane geoUrlPane) { + this.geoUrlPane = geoUrlPane; } - protected UILabel createSourceTitleLabel() { - return new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area")); - } - - private JPanel createMapSourcesPane() { - mapDataTree = new MapDataTree(this.getRootNode()); - mapDataTree.setEditable(false); - mapDataTree.selectDefaultTreeNode(); - sourceComboBox = new FRTreeComboBox(mapDataTree, mapDataTree.getCellRenderer()){ - //搜索 - protected void dealSamePath(TreePath parent, TreeNode node, UITextField textField){ - String searchText = textField.getText(); - VanChartMapSourceChoosePane.this.mapDataTree.search(searchText); - } - - //选中 tree---combobox - public void setSelectedItem(Object o) { - TreePath oldPath = mapDataTree.getSelectionPath(); - Object oldText = getSelectedItem(); - if(o != null && o instanceof TreePath){ - selectTreePath =(TreePath)o; - this.tree.setSelectionPath(selectTreePath); - this.getModel().setSelectedItem(pathToString(selectTreePath)); - if(ComparatorUtils.equals(oldText, getSelectedItem()) && !ComparatorUtils.equals(oldPath, selectTreePath)) { - //point的江苏省切换到area的江苏省 - listener.doChange(); - } - } else if(o instanceof String){//list里面没有 - selectTreePath = null; - this.tree.setSelectionPath(null); - this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o)); - } - } - - @Override - protected String pathToString(TreePath path) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - //不显示后缀 - return ChartGEOJSONHelper.getPresentNameWithPath(node.toString()); - } - - @Override - protected boolean customSelectable(DefaultMutableTreeNode node){ - return GEOJSONTreeHelper.isSelectableTreeNode(node); - } - }; - sourceComboBox.setEditable(true); - sourceComboBox.setOnlyLeafSelectable(false); - sourceComboBox.addPopupMenuListener(popupMenuListener); - - sourceTitleLabel = createSourceTitleLabel(); - - boolean hasRefreshButton = !WorkContext.getCurrent().isLocal(); - - UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/images/control/refresh.png")); - button.setToolTipText(Toolkit.i18nText("Fine-Design_Chart_Update_Remote_Map_JSON")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - GEOJSONHelper.reset(); - GEOJSONHelper.getInstance(); - } - }); - - - double p = TableLayout.PREFERRED; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] rowSize = {p, p}; - - double[] columnSize = hasRefreshButton ? new double[]{d + 10, e - 20, 20} : new double[]{d, e}; - Component[] comps = hasRefreshButton ? new Component[]{sourceTitleLabel, sourceComboBox, button} : new Component[]{sourceTitleLabel, sourceComboBox}; - double hGap = hasRefreshButton ? 0 : TableLayout4VanChartHelper.COMPONENT_INTERVAL; - Component[][] components = new Component[][]{ - new Component[]{null,null}, - comps, - - }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, hGap, LayoutConstants.VGAP_LARGE); - } - - private JPanel createGISLayerPane() { - JPanel panel = new JPanel(new BorderLayout(0, 8)); - - gisLayer = new UIComboBox(layers); - - gisLayer.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - refreshZoomLevel(); - } - }); - - gisLayer.addPopupMenuListener(new PopupMenuListener() { - public void popupMenuCanceled(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - - String selected = Utils.objectToString(gisLayer.getSelectedItem()); - ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); - - gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); - - gisLayer.setSelectedItem(selected); - zoomLevel.setSelectedItem(zoomSelected); - } - }); - - - gisLayer.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - checkLayerCardPane(); - } - } - }); - - final JPanel tileLyaerPane = createCustomTileLayer(); - final JPanel wmsLayerPane = createWMSPanel(); - - layerCardPane = new JPanel(new CardLayout()){ - @Override - public Dimension getPreferredSize() { - String itemName = Utils.objectToString(gisLayer.getSelectedItem()); - if (MapLayerConfigManager.isCustomLayer(itemName)) { - return tileLyaerPane.getPreferredSize(); - } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { - return wmsLayerPane.getPreferredSize(); - } - return new Dimension(0,0); - } - }; - - for(String itemName : layers){ - JPanel pane = new JPanel(); - if (MapLayerConfigManager.isCustomLayer(itemName)) { - pane = tileLyaerPane; - } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { - pane = wmsLayerPane; - } - - layerCardPane.add(pane, itemName); - } - - JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gis_Layer"), gisLayer); - - panel.add(panel1, BorderLayout.CENTER); - panel.add(layerCardPane, BorderLayout.SOUTH); - - return panel; - } - - private void refreshZoomLevel(){ - //gis图层不同,对应的缩放等级不同。 - ZoomLevel[] levels; - if (ComparatorUtils.equals(gisLayer.getSelectedItem(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { - levels = BLUE_ZOOM_LEVELS; - } else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { - levels = GAODE_ZOOM_LEVELS; - } else { - levels = ZOOM_LEVELS; - } - zoomLevel.setModel(new DefaultComboBoxModel(levels)); - } - - - private JPanel createCustomTileLayer() { - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p}; - double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH-3}; - - customTileLayer = new UITextArea(); - attribution = new UITextArea(); - Component[][] comps = new Component[][]{ - new Component[]{new UILabel("url"), customTileLayer}, - new Component[]{new UILabel("Attribution"), attribution} - }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); - panel.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); - return panel; - } - - private JPanel createWMSPanel() { - - final double p = TableLayout.PREFERRED; - double[] rowSize = {p}; - double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, 84,44}; - - - wmsUrl = new UITextArea(); - connectButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); - - Component[][] comps = new Component[][]{ - new Component[]{new UILabel("url"), wmsUrl, connectButton} - }; - JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); - northPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); - JPanel wmsPanel = new JPanel(new BorderLayout(0, 4)); - wmsLayerPane = new JPanel(new BorderLayout()); - resetWMSLayerPane(new ArrayList()); - wmsPanel.add(northPane, BorderLayout.NORTH); - wmsPanel.add(wmsLayerPane, BorderLayout.CENTER); - - connectButton.addActionListener(actionListener); - - addMouseListener(); - - return wmsPanel; - } - - ActionListener actionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - - new SwingWorker() { - private java.util.List list = new ArrayList<>(); - - @Override - protected Void doInBackground() throws Exception { - HttpClient httpClient = new HttpClient(wmsUrl.getText() + "service=WMS&request=GetCapabilities"); - httpClient.asGet(); - - if (!httpClient.isServerAlive()) { - return null; - } - - String res = httpClient.getResponseText(); - List layers = WMSFactory.readLayers(res); - list.clear(); - for (String layer : layers) { - list.add(new WMSLayer(layer, false)); - } - return null; - } - - @Override - protected void done() { - connectButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); - if(list != null && list.size() > 0) { - resetWMSLayerPane(list); - } else { - FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); - } - } - }.execute(); - } - }; - - private void addMouseListener() { - connectButton.addMouseListener(new MouseListener() { - @Override - public void mouseClicked(MouseEvent e) { - - } - - @Override - public void mousePressed(MouseEvent e) { - connectButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Connecting_WMP")); - } - - @Override - public void mouseReleased(MouseEvent e) { - - } - - @Override - public void mouseEntered(MouseEvent e) { - - } - - @Override - public void mouseExited(MouseEvent e) { - - } - }); + @Override + public void registerChangeListener(UIObserverListener listener) { + geoUrlPane.registerChangeListener(listener); + gisLayerPane.registerChangeListener(listener); } - private void resetWMSLayerPane(java.util.List wmsLayers) { - - int size = wmsLayers.size(); - double[] rowSize = new double[size]; - Component[][] comps = new Component[size][2]; - wmsLayerCheckBoxs.clear(); - wmsLayerPane.removeAll(); - for(int i =0; i < size; i++){ - rowSize[i] = TableLayout.PREFERRED; - comps[i][0] = i == 0 ? new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_WMS_Layers"), SwingConstants.RIGHT) : null; - WMSLayer layer = wmsLayers.get(i); - UICheckBox checkBox = new UICheckBox(layer.getLayer()); - checkBox.registerChangeListener(listener); - checkBox.setToolTipText(layer.getLayer()); - checkBox.setSelected(layer.isSelected()); - comps[i][1] = checkBox; - wmsLayerCheckBoxs.add(checkBox); - } - - wmsLayerPane.add(TableLayoutHelper.createCommonTableLayoutPane(comps,rowSize, COLUMN_SIZE,0), BorderLayout.CENTER); - - VanChartMapSourceChoosePane.this.updateUI(); + @Override + public boolean shouldResponseChangeListener() { + return true; } - private JPanel createMapInitStatusPane() { - zoomLevel = new UIComboBox(ZOOM_LEVELS); - viewCenterCom = new UIButtonGroup(new String[]{AUTO_CENTER_STRING, CUSTOM_CENTER_STRING}); - longitude = new UISpinner(-Double.MAX_VALUE,Double.MAX_VALUE,1,0.0); - latitude = new UISpinner(-Double.MAX_VALUE,Double.MAX_VALUE,1,0.0); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; - double[] rowSize = {p,p,p}; - double[] columnSize = {d, e}; - double[] column = {d, s}; - - Component[][] comps = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), zoomLevel}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_View_Center")), viewCenterCom}, - }; - final JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps,rowSize,columnSize); - - Component[][] longAndLatComps = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitude}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitude} - }; - longAndLatPane =TableLayout4VanChartHelper.createGapTableLayoutPane(longAndLatComps,rowSize,column); - longAndLatPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); - longAndLatPane.setVisible(false); - - JPanel contentPane = new JPanel(new BorderLayout(0, 6)){ - - @Override - public Dimension getPreferredSize() { - if(longAndLatPane.isVisible()) { - return super.getPreferredSize(); - } else { - return northPane.getPreferredSize(); - } - } - }; - contentPane.add(northPane, BorderLayout.NORTH); - contentPane.add(longAndLatPane, BorderLayout.CENTER); - - viewCenterCom.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - longAndLatPane.setVisible(!isAutoViewCenter()); - } - }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Init_Status"), contentPane); + protected void initGeoUrlPane() { + geoUrlPane = new GeoUrlPane(); } - private boolean isAutoViewCenter() { - return viewCenterCom.getSelectedIndex()==0; + private void initGisLayerPane() { + gisLayerPane = new GisLayerPane(); + gisLayerPane.registerZoomLevel(mapStatusPane.getZoomLevel()); } - private PopupMenuListener popupMenuListener = new PopupMenuListener() { - public void popupMenuCanceled(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - - GEOJSONTreeHelper.reset(); - mapDataTree.changeRootNode(VanChartMapSourceChoosePane.this.getRootNode()); - GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams()); - - if(selectTreePath != null){ - mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); - selectTreePath = mapDataTree.getSelectionPath(); - } - - mapDataTree.updateUI();//因为服务器那边可能随时编辑,所以这边要重画 - mapDataTree.setSelectionPath(selectTreePath); - mapDataTree.scrollPathToVisible(selectTreePath); - } - }; - - private void checkLayerCardPane() { - CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); - cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); + private void initMapStatusPane() { + mapStatusPane = new MapStatusPane(); } public void resetComponentValue(VanChartMapPlot mapPlot) { - resetComponentValue(mapPlot, true); + geoUrlPane.resetComponentValue(mapPlot, true); //重置图层属性 - resetGisLayer(mapPlot); + gisLayerPane.resetGisLayer(mapPlot); //重置缩放等级 - resetZoomLevel(mapPlot); + mapStatusPane.resetZoomLevel(mapPlot); //重置中心点位置 - resetViewCenter(mapPlot); + mapStatusPane.resetViewCenter(mapPlot); } - protected void resetComponentValue(VanChartMapPlot mapPlot, boolean samePlotChange) { - MapType mapType = mapPlot.getMapType(); - - //获取最新的参数 - String[] params = getParams(); - - if (!ComparatorUtils.equals(oldParams, params)){ - oldParams = params; - GEOJSONTreeHelper.getInstance().updateParamRootNode(params); - } - - mapDataTree.changeRootNode(this.getRootNode()); - if(samePlotChange) { - String nodePath = ChartGEOJSONHelper.getDefaultJSONURL(); - mapPlot.setGeoUrl(nodePath); - mapDataTree.setSelectNodePath(nodePath); - selectTreePath = mapDataTree.getSelectionPath(); - sourceComboBox.setSelectedItem(selectTreePath); - } - switch (mapType){ - case CUSTOM: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); - break; - case POINT: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Point")); - break; - case LINE: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Point")); - break; - default: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area")); - } - - } - - private String[] getParams() { - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate == null){ - return new String[0]; - } - - return getParamsName((jTemplate.getJTemplateParameters())); - } - - private String[] getParamsName(Parameter[] parameters) { - String[] names = new String[parameters.length]; - for (int i = 0; i < parameters.length; i++){ - names[i] = parameters[i].getName(); - } - return names; - } - - private void resetViewCenter(VanChartMapPlot mapPlot) { - mapPlot.setViewCenter(new ViewCenter()); - viewCenterCom.setSelectedIndex(0); - longitude.setValue(0); - latitude.setValue(0); - longAndLatPane.setVisible(false); - } - - private void resetZoomLevel(VanChartMapPlot mapPlot) { - mapPlot.setZoomLevel(ZoomLevel.AUTO); - zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); - } - - private void resetGisLayer(VanChartMapPlot mapPlot) { - //TODO Bjorn 地图gis图层自动逻辑 - /* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); - mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ - - String layerName = mapPlot.getDefaultGisLayerName(); - - mapPlot.getGisLayer().setGisLayerType(GISLayerType.PREDEFINED_LAYER); - mapPlot.getGisLayer().setLayerName(layerName); - gisLayer.setSelectedItem(mapPlot.getGisLayer().getShowItemName()); - } public void populateBean(VanChartMapPlot mapPlot) { - resetComponentValue(mapPlot, false); - - mapDataTree.setSelectNodePath(mapPlot.getGeoUrl()); - selectTreePath = mapDataTree.getSelectionPath(); - - if(selectTreePath == null){//此url当前环境没有 - sourceComboBox.setSelectedItem(mapPlot.getGeoUrl()); - } else { - sourceComboBox.setSelectedItem(selectTreePath); - } - - GisLayer layer = mapPlot.getGisLayer(); - gisLayer.setSelectedItem(layer.getShowItemName()); - - wmsUrl.setText(layer.getWmsUrl()); - resetWMSLayerPane(layer.getWmsLayers()); - customTileLayer.setText(layer.getCustomTileLayer()); - attribution.setText(layer.getAttribution()); - - refreshZoomLevel(); - zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); - - ViewCenter viewCenter = mapPlot.getViewCenter(); - if(viewCenter.isAuto()){ - viewCenterCom.setSelectedIndex(0); - longitude.setValue(0); - latitude.setValue(0); - } else { - viewCenterCom.setSelectedIndex(1); - longitude.setValue(viewCenter.getLongitude()); - latitude.setValue(viewCenter.getLatitude()); - } - - longAndLatPane.setVisible(!isAutoViewCenter()); - - checkLayerCardPane(); + geoUrlPane.populate(mapPlot); + gisLayerPane.populate(mapPlot.getGisLayer()); + mapStatusPane.populate(mapPlot); } public void updateBean(VanChartMapPlot mapPlot) { - if(!CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl())){ - mapPlot.setGeoUrl(mapDataTree.getSelectNodeJSONPath()); - } - - GisLayer layer = mapPlot.getGisLayer(); - String layerName = Utils.objectToString(gisLayer.getSelectedItem()); - - layer.setLayerName(layerName); - layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); - - switch (layer.getGisLayerType()){ - case CUSTOM_WMS_LAYER: - layer.setWmsUrl(wmsUrl.getText()); - layer.setWmsLayers(new ArrayList()); - for(UICheckBox checkBox : wmsLayerCheckBoxs){ - layer.addWmsLayer(new WMSLayer(checkBox.getText(), checkBox.isSelected())); - } - break; - case CUSTOM_TILE_LAYER: - layer.setCustomTileLayer(customTileLayer.getText()); - layer.setAttribution(attribution.getText()); - break; + if (!CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl())) { + mapPlot.setGeoUrl(geoUrlPane.update()); } - mapPlot.setZoomLevel((ZoomLevel) zoomLevel.getSelectedItem()); - - ViewCenter viewCenter = mapPlot.getViewCenter(); - if(isAutoViewCenter()){ - viewCenter.setAuto(true); - } else { - viewCenter.setAuto(false); - viewCenter.setLongitude(longitude.getValue()); - viewCenter.setLatitude(latitude.getValue()); - } - } - - public UIComboBox getSourceComboBox(){ - return this.sourceComboBox; + gisLayerPane.update(mapPlot.getGisLayer()); + mapStatusPane.update(mapPlot); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java new file mode 100644 index 000000000..19afd688f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java @@ -0,0 +1,165 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.decision.webservice.v10.map.WMSFactory; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.http.HttpClient; +import com.fr.plugin.chart.base.GisLayer; +import com.fr.plugin.chart.map.layer.WMSLayer; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.SwingWorker; +import java.util.ArrayList; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class WMSLayerPane extends JPanel implements UIObserver { + private static final double[] COLUMN_SIZE = {48, TableLayout.FILL, TableLayout.PREFERRED}; + + private UITextArea wmsUrl; + private UIButton connectButton; + private JPanel wmsLayerPane; + + private List wmsLayerCheckBoxs = new ArrayList<>(); + + private UIObserverListener listener; + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + + public WMSLayerPane() { + final double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, 84, 44}; + + + wmsUrl = new UITextArea(); + connectButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); + + Component[][] comps = new Component[][]{ + new Component[]{new UILabel("url"), wmsUrl, connectButton} + }; + JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); + northPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); + + wmsLayerPane = new JPanel(new BorderLayout()); + resetWMSLayerPane(new ArrayList<>()); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(wmsLayerPane, BorderLayout.CENTER); + addListener(); + } + + private void addListener() { + connectButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + new SwingWorker() { + private java.util.List list = new ArrayList<>(); + + @Override + protected Void doInBackground() { + HttpClient httpClient = new HttpClient(wmsUrl.getText() + "service=WMS&request=GetCapabilities"); + httpClient.asGet(); + + if (!httpClient.isServerAlive()) { + return null; + } + + String res = httpClient.getResponseText(); + List layers = WMSFactory.readLayers(res); + list.clear(); + for (String layer : layers) { + list.add(new WMSLayer(layer, false)); + } + return null; + } + + @Override + protected void done() { + connectButton.setText(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); + if (list != null && list.size() > 0) { + resetWMSLayerPane(list); + } else { + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); + } + } + }.execute(); + } + }); + + connectButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + connectButton.setText(Toolkit.i18nText("Fine-Design_Chart_Connecting_WMP")); + } + }); + } + + private void resetWMSLayerPane(java.util.List wmsLayers) { + int size = wmsLayers.size(); + double[] rowSize = new double[size]; + Component[][] comps = new Component[size][2]; + wmsLayerCheckBoxs.clear(); + wmsLayerPane.removeAll(); + for (int i = 0; i < size; i++) { + rowSize[i] = TableLayout.PREFERRED; + comps[i][0] = i == 0 ? new UILabel(Toolkit.i18nText("Fine-Design_Chart_WMS_Layers"), SwingConstants.RIGHT) : null; + WMSLayer layer = wmsLayers.get(i); + UICheckBox checkBox = new UICheckBox(layer.getLayer()); + checkBox.registerChangeListener(listener); + checkBox.setToolTipText(layer.getLayer()); + checkBox.setSelected(layer.isSelected()); + comps[i][1] = checkBox; + wmsLayerCheckBoxs.add(checkBox); + } + + wmsLayerPane.add(TableLayoutHelper.createCommonTableLayoutPane(comps, rowSize, COLUMN_SIZE, 0), BorderLayout.CENTER); + + updateUI(); + } + + public void populate(GisLayer layer) { + wmsUrl.setText(layer.getWmsUrl()); + resetWMSLayerPane(layer.getWmsLayers()); + } + + public void update(GisLayer layer) { + layer.setWmsUrl(wmsUrl.getText()); + layer.setWmsLayers(new ArrayList<>()); + for (UICheckBox checkBox : wmsLayerCheckBoxs) { + layer.addWmsLayer(new WMSLayer(checkBox.getText(), checkBox.isSelected())); + } + } +} + From 0bb145cb4122d202ce5e3fed895b393d870f5b1a Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Dec 2020 16:06:16 +0800 Subject: [PATCH 26/51] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/JTemplate.java | 12 ++++++++++-- .../com/fr/design/mainframe/JVirtualTemplate.java | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 316f48fc3..eb191383f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -309,6 +309,13 @@ public abstract class JTemplate> EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_INIT, this); } + /** + * 模板激活之前之前 + */ + protected void beforeActive() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); + } + /** * 模板关闭时 */ @@ -1085,6 +1092,7 @@ public abstract class JTemplate> * 激活指定的template */ public void activeJTemplate(int index, JTemplate jt) { + beforeActive(); DesignerContext.getDesignerFrame().activateJTemplate(this); } @@ -1092,7 +1100,7 @@ public abstract class JTemplate> * 激活已存在的模板 */ public void activeOldJTemplate() { - EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); + beforeActive(); DesignerContext.getDesignerFrame().activateJTemplate(this); } @@ -1100,7 +1108,7 @@ public abstract class JTemplate> * 激活新的模板 */ public void activeNewJTemplate() { - EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); + beforeActive(); DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java index 64a10c88f..911c0dc17 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java @@ -208,6 +208,7 @@ public class JVirtualTemplate extends JTemplate { @Override public void activeJTemplate(int index, JTemplate jt) { + beforeActive(); List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); historyList.set(index, jt); DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt); @@ -217,11 +218,13 @@ public class JVirtualTemplate extends JTemplate { @Override public void activeOldJTemplate() { + beforeActive(); DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); } @Override public void activeNewJTemplate() { + beforeActive(); DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); } From 69f0ecdcbf5f04a812ee94427c5c250bd8e437dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 15 Dec 2020 16:55:27 +0800 Subject: [PATCH 27/51] =?UTF-8?q?CHART-17429=20=20=20=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98=E8=BD=B4=E9=87=8D=E7=BD=AE=E9=9D=A2=E6=9D=BF=E6=97=B6?= =?UTF-8?q?=E5=80=99=E9=87=8D=E7=BD=AEhtml=E9=A1=B5=E9=9D=A2=E7=9B=91?= =?UTF-8?q?=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java index 1a4fccf58..cd6c4fcf6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java @@ -176,6 +176,7 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { gaugeStyle = gaugePlot.getGaugeStyle(); reLayoutPane(false); parent.initAllListeners(); + setParentPane(parent); } populateBean(gaugePlot.getGaugeAxis()); } From 676980d1230f91d5e3ab0c2e304a37b03cc2168b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 15 Dec 2020 17:27:02 +0800 Subject: [PATCH 28/51] =?UTF-8?q?CHART-15835=20=20=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/style/label/VanChartPlotLabelDetailPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 20ce7452b..624e6c879 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -158,14 +158,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return jPanel; } - private JPanel createLabelBorderPane() { + protected JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); return borderPaneWithTitle; } - private JPanel createLabelBackgroundPane() { + protected JPanel createLabelBackgroundPane() { backgroundPane = new VanChartBackgroundWithOutImagePane() { protected Component[][] getPaneComponents() { From 5e9cc42c95e3f3a3da13de9b6b0d47fc511b6fba Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 15 Dec 2020 17:45:25 +0800 Subject: [PATCH 29/51] =?UTF-8?q?REPORT-45015=20=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=B1=9E=E6=80=A7-=E6=95=B0=E5=AD=97=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/widget/component/NumberEditorValidatePane.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java index 72a199a5b..ab4f7e4e2 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java @@ -150,6 +150,7 @@ public class NumberEditorValidatePane extends JPanel { setMaxListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + errorMsgTextFieldPane.setVisible(setMaxValueCheckBox.isSelected() || setMinValueCheckBox.isSelected()); if (setMaxValueCheckBox.isSelected()) { maxValueSpinner.setEnabled(true); Double value = (double) 0; @@ -171,6 +172,7 @@ public class NumberEditorValidatePane extends JPanel { setMinListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + errorMsgTextFieldPane.setVisible(setMaxValueCheckBox.isSelected() || setMinValueCheckBox.isSelected()); if (setMinValueCheckBox.isSelected()) { minValueSpinner.setEnabled(true); Double value = (double) 0; From eaeffb57140b57bdcb0ed2edee5b37dd927f46bb Mon Sep 17 00:00:00 2001 From: shine Date: Wed, 16 Dec 2020 17:51:56 +0800 Subject: [PATCH 30/51] =?UTF-8?q?CHART-17231=20=E9=BB=98=E8=AE=A4=E4=B8=8D?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E4=BB=BB=E4=BD=95=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/extended/chart/UIComboBoxWithNone.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 65e7bbb43..9c6636fd7 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -23,7 +23,11 @@ public class UIComboBoxWithNone extends UIComboBox { } protected void setDefaultSelectedItem() { - setSelectedItem(StringUtils.EMPTY); + // JComboBox.setSelectedItem(o) + // if(o!=null)寻找o对应的下拉选项 如果找不到 还是选中之前选中的 + // 所以空字符串 不是选中空 是选中上次选中的 + // 所以这边 可以写setSelectedItem(null) or setSelectedIndex(-1) + setSelectedIndex(-1); } @Override From 5a95835d2ac6cc5a709fef12ad27d7ccaa30345a Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 17 Dec 2020 11:39:13 +0800 Subject: [PATCH 31/51] =?UTF-8?q?REPORT-44785=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86-=E6=95=B0=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86-=E8=A7=86=E5=9B=BE=E4=B8=8D=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/gui/ilist/TableViewList.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java index cccf64e26..73da78151 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java @@ -106,6 +106,13 @@ public class TableViewList extends UIList { if (!status) { throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); } + String[] schemas = DataCoreUtils.getDatabaseSchema(datasource); + schemas = (schemas == null || schemas.length == 0) ? new String[]{null} : schemas; + for (String schema : schemas) { + DataCoreUtils.refreshTables(datasource, TableProcedure.TABLE, schema); + DataCoreUtils.refreshTables(datasource, TableProcedure.VIEW, schema); + DataCoreUtils.refreshTables(datasource, TableProcedure.PROCEDURE, schema); + } return processDataInAnotherThread(databaseName, searchFilter, typesFilter); } From f692c2a5e2b26d2654e6ccdae39f9de3503dcf86 Mon Sep 17 00:00:00 2001 From: Lanlan Date: Thu, 17 Dec 2020 15:35:34 +0800 Subject: [PATCH 32/51] =?UTF-8?q?REPORT-45402=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E5=AE=89=E8=A3=85=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=B7=B2=E7=BB=8F=E5=AE=89=E8=A3=85=E4=BD=8E?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E6=8F=92=E4=BB=B6=EF=BC=8C=E7=82=B9?= =?UTF-8?q?=E5=90=A6=E4=B8=8D=E6=9B=B4=E6=96=B0=EF=BC=8C=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E4=BC=9A=E6=9B=B4=E6=96=B0=E5=B7=B2=E5=AE=89=E8=A3=85=E7=9A=84?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/exe/callback/InstallOnlineCallback.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index f597180e8..dce9a25ce 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -51,12 +51,13 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + jsCallback.execute("success"); return; } PluginMarker pluginMarker = result.getCurrentTask().getMarker(); PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback); - }else { + } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); From 25fd375c88e25af5f73ff3a3dce64916d79d134c Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 15:29:02 +0800 Subject: [PATCH 33/51] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 19 +++ .../fr/design/extra/PluginOperateUtils.java | 43 +++-- .../java/com/fr/design/extra/PluginUtils.java | 3 +- .../exe/callback/InstallFromDiskCallback.java | 17 +- .../exe/callback/InstallOnlineCallback.java | 16 +- .../exe/callback/ModifyStatusCallback.java | 14 +- .../exe/callback/UninstallPluginCallback.java | 19 ++- .../exe/callback/UpdateFromDiskCallback.java | 22 +-- .../exe/callback/UpdateOnlineCallback.java | 12 +- .../com/fr/env/PluginErrorRemindDialog.java | 108 ++++++++++++ .../com/fr/design/EnvChangeEntranceTest.java | 62 +++++-- .../design/extra/PluginOperateUtilsTest.java | 155 ++++++++++++++++++ .../com/fr/design/extra/PluginUtilsTest.java | 23 +++ .../manager/impl/PluginSearchManager.java | 3 +- .../module/DesignerWorkspaceProvider.java | 1 + .../manager/impl/PluginSearchManagerTest.java | 25 +++ 16 files changed, 476 insertions(+), 66 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java create mode 100644 designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java create mode 100644 designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java create mode 100644 designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 0ddb74926..ed67299f6 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,6 +1,7 @@ package com.fr.design; import com.fr.common.report.ReportState; +import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -35,6 +36,7 @@ import com.fr.process.engine.core.FineProcessContext; import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; +import com.fr.env.PluginErrorRemindDialog; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -144,6 +146,7 @@ public class EnvChangeEntrance { template.refreshToolArea(); } showServiceDialog(selectedEnv); + pluginErrorRemind(selectedEnv); } catch (WorkspaceAuthException | RegistEditionException e) { // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); @@ -297,6 +300,22 @@ public class EnvChangeEntrance { } } + /** + * 插件启动错误信息提示 + * @param selectedEnv 选择的工作环境 + */ + public void pluginErrorRemind(DesignerWorkspaceInfo selectedEnv) { + if (selectedEnv.getType() == DesignerWorkspaceType.Remote) { + return; + } + + String content = PluginErrorRemindHandler.pluginErrorContent(); + if (StringUtils.isNotEmpty(content)) { + PluginErrorRemindDialog dialog = new PluginErrorRemindDialog(DesignerContext.getDesignerFrame(), content); + dialog.setVisible(true); + } + } + /** * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 801b4e369..46683e0a0 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -18,6 +18,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.context.PluginMarkerAdapter; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginControllerHelper; import com.fr.plugin.manage.control.PluginTask; @@ -26,7 +27,8 @@ import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import java.io.File; import java.net.HttpURLConnection; import java.util.List; @@ -38,11 +40,23 @@ import java.util.List; public class PluginOperateUtils { public static void installPluginOnline(final PluginMarker pluginMarker, JSCallback jsCallback) { + PluginMarker marker = updateMarker2Online(pluginMarker); //下载插件 - PluginTask pluginTask = PluginTask.installTask(pluginMarker); + PluginTask pluginTask = PluginTask.installTask(marker); PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback)); } + public static PluginMarker updateMarker2Online(PluginMarker pluginMarker) { + try { + JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); + String pluginName = latestPluginInfo.getString("name"); + return PluginMarkerAdapter.create(pluginMarker, pluginName); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return pluginMarker; + } + public static void installPluginFromDisk(File zipFile, JSCallback jsCallback) { PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); } @@ -57,10 +71,11 @@ public class PluginOperateUtils { public static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback) { try { JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); - String latestPluginVersion = (String) latestPluginInfo.get("version"); - PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion); + String latestPluginVersion = latestPluginInfo.getString("version"); + String pluginName = latestPluginInfo.getString("name"); + PluginMarker toPluginMarker = PluginMarkerAdapter.create(pluginMarker.getPluginID(), latestPluginVersion, pluginName); //当前已经安装的相同ID插件marker - PluginMarker currentMarker = PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID()); + PluginMarker currentMarker = PluginMarkerAdapter.create(PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID()), pluginName); PluginTask pluginTask = PluginTask.updateTask(currentMarker, toPluginMarker); PluginControllerHelper.updateOnline(currentMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback)); } catch (Exception e) { @@ -203,16 +218,22 @@ public class PluginOperateUtils { continue; } PluginMarker pluginMarker = pluginTask.getToMarker(); - PluginContext pluginContext = PluginManager.getContext(pluginMarker); - if (pluginContext != null) { - pluginInfo.append(pluginContext.getName()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); - } else { - pluginInfo.append(pluginMarker.getPluginID()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); - } + PluginContext pluginContext = PluginManager.getContext(pluginMarker.getPluginID()); + pluginInfo.append(getPluginName(pluginContext, pluginMarker)).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); } return pluginInfo.toString(); } + private static String getPluginName(PluginContext pluginContext, PluginMarker pluginMarker) { + if (pluginContext != null) { + return pluginContext.getName(); + } + else if (pluginMarker instanceof PluginMarkerAdapter) { + return ((PluginMarkerAdapter) pluginMarker).getPluginName(); + } + return pluginMarker == null ? null : pluginMarker.getPluginID(); + } + public static String getSwitchedInfo(PluginTaskResult result) { StringBuilder pluginInfo = new StringBuilder(); List pluginTaskResults = result.asList(); diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index bec02a200..81f476961 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -10,6 +10,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginVerifyException; import com.fr.plugin.basic.version.Version; +import com.fr.plugin.basic.version.VersionCompatibleType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; @@ -248,7 +249,7 @@ public class PluginUtils { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); + return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 19bd89ef1..14a6de942 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -3,7 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; -import com.fr.design.extra.PluginUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -12,7 +12,7 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -41,8 +41,9 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); - FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo; + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, @@ -66,8 +67,8 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -80,8 +81,8 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index f597180e8..38c1bc780 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -11,7 +12,7 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** @@ -38,13 +39,14 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { if (result.isSuccess()) { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); - FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo; + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -58,8 +60,8 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback); }else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java index c48a47fae..8015e00fb 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java @@ -2,12 +2,14 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.extra.PluginUtils; +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/27. @@ -22,12 +24,16 @@ public class ModifyStatusCallback implements PluginTaskCallback{ } @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); + String modifyMessage = isActive ? + pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : + pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); + FineLoggerFactory.getLogger().info(modifyMessage); FineJOptionPane.showMessageDialog(null, modifyMessage); } else { - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index b3773ef6f..bfa921125 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -2,7 +2,8 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.extra.PluginUtils; +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -10,7 +11,7 @@ import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/27. @@ -25,15 +26,17 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); - FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success"); + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); }else if (result.errorCode() == PluginErrorCode.NeedUninstallDependingPluginFirst) { int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -46,8 +49,8 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback)); } else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 7cced40f0..551d94488 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -3,7 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; -import com.fr.design.extra.PluginUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -12,7 +12,7 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -37,15 +37,17 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); - FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -64,8 +66,8 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { } else if(result.errorCode() == PluginErrorCode.NoPluginToUpdate){ int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -78,8 +80,8 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 69998a316..deeed7497 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -3,13 +3,14 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/26. @@ -33,12 +34,13 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); - FineJOptionPane.showMessageDialog(null,pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java new file mode 100644 index 000000000..3654cca2d --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java @@ -0,0 +1,108 @@ +package com.fr.env; + +import com.fr.design.actions.server.PluginManagerAction; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Locale; + +/** + * 插件启动失败提示窗 + */ +public class PluginErrorRemindDialog extends JDialog implements ActionListener { + + public PluginErrorRemindDialog(Frame parent, String areaText) { + super(parent, true); + //上面的标签面板 + JPanel topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel imagePanel = new JPanel(); + Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png"); + + JLabel imageLabel = new JLabel(); + imageLabel.setIcon(icon); + imagePanel.add(imageLabel); + imagePanel.setPreferredSize(new Dimension(130, 100)); + + JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + + JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Title")); + label.setFont(FRFont.getInstance().applySize(18).applyStyle(1)); + label.setPreferredSize(new Dimension(650, 100)); + + verticalPanel.add(label); + + topPanel.add(imagePanel, BorderLayout.WEST); + topPanel.add(verticalPanel, BorderLayout.CENTER); + topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + + //中间的文本域面板 + JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + centerPanel.setPreferredSize(new Dimension(480, 320)); + + JTextArea checkArea = new JTextArea(areaText); + checkArea.setEnabled(false); + centerPanel.add(checkArea, BorderLayout.CENTER); + + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Not_Deal_With")); + UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Deal_With")); + + cancelButton.addActionListener(this); + okButton.addActionListener(new PluginManagerActionAdapter(this)); + + // 按钮 + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + buttonPanel.add(cancelButton); + buttonPanel.add(okButton); + + + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")); + this.setResizable(false); + + this.add(topPanel, BorderLayout.NORTH); + this.add(centerPanel, BorderLayout.CENTER); + this.add(buttonPanel, BorderLayout.SOUTH); + this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500)); + + GUICoreUtils.centerWindow(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + this.dispose(); + } + + private static class PluginManagerActionAdapter extends PluginManagerAction { + + private JDialog jDialog; + + public PluginManagerActionAdapter(JDialog jDialog) { + this.jDialog = jDialog; + } + + @Override + public void actionPerformed(ActionEvent e) { + this.jDialog.dispose(); + super.actionPerformed(e); + } + } + +} diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java index d9d6e4484..7f53d05de 100644 --- a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -1,10 +1,12 @@ package com.fr.design; +import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.env.CheckServiceDialog; +import com.fr.env.PluginErrorRemindDialog; import com.fr.invoke.Reflect; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; @@ -16,13 +18,19 @@ import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.awt.Frame; + /** * @author: Maksim * @Date: Created in 2020/3/5 * @Description: */ @RunWith(PowerMockRunner.class) -@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class, DesignerEnvManager.class}) +@PrepareForTest({FunctionalHttpRequest.class, + EnvChangeEntrance.class, + CheckServiceDialog.class, + DesignerEnvManager.class, + PluginErrorRemindHandler.class}) public class EnvChangeEntranceTest { @Test @@ -44,17 +52,15 @@ public class EnvChangeEntranceTest { EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); - PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog); + PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog); - EasyMock.replay(request); - EasyMock.replay(selectedEnv); - EasyMock.replay(connectionInfo); + EasyMock.replay(request, selectedEnv, connectionInfo); PowerMock.replayAll(); entrance.showServiceDialog(selectedEnv); - Assert.assertTrue(true); + }catch (Exception e){ - Assert.assertTrue(false); + Assert.fail(); } } @@ -94,10 +100,44 @@ public class EnvChangeEntranceTest { DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path"); DesignerWorkspaceInfo info4 = null; - Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info1).get()); - Assert.assertTrue((boolean) Reflect.on(entrance).call("isNotRememberPwd", info2).get()); - Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info3).get()); - Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info4).get()); + Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get()); + Assert.assertTrue(Reflect.on(entrance).call("isNotRememberPwd", info2).get()); + Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info3).get()); + Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get()); } + @Test + public void testPluginErrorRemind() throws Exception { + + try { + DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); + EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once(); + EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2); + + PowerMock.mockStatic(PluginErrorRemindHandler.class); + EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once(); + EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("111").once(); + + PluginErrorRemindDialog dialog = EasyMock.mock(PluginErrorRemindDialog.class); + PowerMock.expectNew(PluginErrorRemindDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString()).andReturn(dialog).once(); + + dialog.setVisible(true); + EasyMock.expectLastCall(); + + EasyMock.replay(selectedEnv, dialog); + PowerMock.replayAll(); + + EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); + + entrance.pluginErrorRemind(selectedEnv); + entrance.pluginErrorRemind(selectedEnv); + entrance.pluginErrorRemind(selectedEnv); + + + EasyMock.verify(selectedEnv, dialog); + PowerMock.verifyAll(); + } catch (Exception e) { + Assert.fail(); + } + } } \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java new file mode 100644 index 000000000..887cde43e --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java @@ -0,0 +1,155 @@ +package com.fr.design.extra; + +import com.fr.invoke.Reflect; +import com.fr.json.JSONObject; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.context.PluginMarkerAdapter; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskResult; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/12/17 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({PluginManager.class, PluginUtils.class}) +public class PluginOperateUtilsTest { + + @Test + public void testGetSuccessInfo() { + PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class); + PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class); + PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class); + + List pluginTaskResults1 = new ArrayList<>(); + pluginTaskResults1.add(pluginTaskResult1); + List pluginTaskResults2 = new ArrayList<>(); + pluginTaskResults2.add(pluginTaskResult1); + pluginTaskResults2.add(pluginTaskResult2); + + PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0"); + PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2"); + PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1); + PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2); + + EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2); + EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2); + EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes(); + EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes(); + + EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes(); + EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes(); + + PluginContext plugin1 = EasyMock.mock(PluginContext.class); + PluginContext plugin2 = EasyMock.mock(PluginContext.class); + EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes(); + EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes(); + PowerMock.mockStatic(PluginManager.class); + EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID())) + .andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once(); + EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID())) + .andReturn(plugin2).once().andReturn(null).once(); + + EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); + PowerMock.replayAll(); + + // 1个 + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem"); + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem"); + + + // 2个 + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem"); + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem"); + + EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); + PowerMock.verifyAll(); + + } + + + @Test + public void testGetPluginName() { + PluginContext pluginContext = EasyMock.mock(PluginContext.class); + EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once(); + + PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1"); + PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2"); + + EasyMock.replay(pluginContext); + + Assert.assertNull(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get()); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext"); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1"); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); + + EasyMock.verify(pluginContext); + } + + @Test + public void testUpdateMarker2Online() { + + try { + PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); + String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; + JSONObject object = new JSONObject(pluginJson); + + PowerMock.mockStatic(PluginUtils.class); + EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); + EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once(); + + PowerMock.replayAll(); + + PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker); + PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker); + + Assert.assertTrue(marker1 instanceof PluginMarkerAdapter); + Assert.assertEquals(marker1.getPluginID(), "plugin-1"); + Assert.assertEquals(marker1.getVersion(), "1.0"); + Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)"); + Assert.assertEquals(marker2, pluginMarker); + + PowerMock.verifyAll(); + } catch (Exception e) { + Assert.fail(); + } + + } + + + @Test + public void testUpdatePluginOnline() { + try { + PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); + String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; + JSONObject object = new JSONObject(pluginJson); + + PowerMock.mockStatic(PluginUtils.class); + EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); + EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once(); + + PowerMock.replayAll(); + + PluginOperateUtils.updatePluginOnline(pluginMarker, null); + + PowerMock.verifyAll(); + } catch (Exception e) { + Assert.fail(); + } + } + +} diff --git a/designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java b/designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java new file mode 100644 index 000000000..bbb809ebf --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java @@ -0,0 +1,23 @@ +package com.fr.design.extra; + +import com.fr.invoke.Reflect; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/12/18 + */ +public class PluginUtilsTest { + + @Test + public void testIsCompatibleCurrentEnv() { + Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "~9.0").get()); + Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get()); + Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get()); + Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get()); + Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get()); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index a902d0e00..8efc5323e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -15,6 +15,7 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; +import com.fr.plugin.basic.version.VersionCompatibleType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; @@ -44,7 +45,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); + return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index 420f0f2b6..14bb23b18 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -71,6 +71,7 @@ public class DesignerWorkspaceProvider extends Activator { } catch (Exception e) { FineLoggerFactory.getLogger().warn("Check Service Failed"); } + EnvChangeEntrance.getInstance().pluginErrorRemind(selectEnv); } }); } diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java new file mode 100644 index 000000000..f4c9c1b7a --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java @@ -0,0 +1,25 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + + +import com.fr.invoke.Reflect; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/12/17 + */ +public class PluginSearchManagerTest { + + @Test + public void testIsCompatibleCurrentEnv() { + + Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "~9.0").get()); + Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get()); + Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get()); + Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get()); + Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get()); + } + +} From 563617b9a3b2dba5b656cbf7a1e2f83704157c41 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 15:50:53 +0800 Subject: [PATCH 34/51] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginUtils.java | 4 ++-- .../alphafine/search/manager/impl/PluginSearchManager.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index 81f476961..7fa050f60 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -10,7 +10,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginVerifyException; import com.fr.plugin.basic.version.Version; -import com.fr.plugin.basic.version.VersionCompatibleType; +import com.fr.plugin.basic.version.VersionIntervalType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; @@ -249,7 +249,7 @@ public class PluginUtils { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 8efc5323e..fbc3ce57b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -11,16 +11,14 @@ import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvi import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; -import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; -import com.fr.plugin.basic.version.VersionCompatibleType; +import com.fr.plugin.basic.version.VersionIntervalType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; -import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -45,7 +43,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { From 3d15e4b6fd17720ad81abe2ab3c3ab44c6649de6 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 17:40:29 +0800 Subject: [PATCH 35/51] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginUtils.java | 2 +- .../alphafine/search/manager/impl/PluginSearchManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index 7fa050f60..ed7253bad 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -249,7 +249,7 @@ public class PluginUtils { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index fbc3ce57b..31a1b18ed 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -43,7 +43,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { From 9b9fd7a297748f88e4547dd85b06a3ebda411d11 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 17:57:16 +0800 Subject: [PATCH 36/51] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exe/callback/InstallFromDiskCallback.java | 19 +++++++++---------- .../exe/callback/InstallOnlineCallback.java | 12 +++++------- .../exe/callback/UninstallPluginCallback.java | 12 +++++------- .../exe/callback/UpdateFromDiskCallback.java | 19 +++++++++---------- .../exe/callback/UpdateOnlineCallback.java | 4 +--- 5 files changed, 29 insertions(+), 37 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 14a6de942..81e76fa45 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -12,7 +12,6 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -45,17 +44,17 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Dependence"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } List pluginTasks = result.getPreTasks(); @@ -65,24 +64,24 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { } PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 0fd43c43b..c7059f50d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -12,8 +12,6 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; - /** * Created by ibm on 2017/5/26. @@ -43,17 +41,17 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { jsCallback.execute("success"); return; } @@ -62,7 +60,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index bfa921125..df3839427 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -11,8 +11,6 @@ import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; - /** * Created by ibm on 2017/5/27. */ @@ -33,24 +31,24 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); }else if (result.errorCode() == PluginErrorCode.NeedUninstallDependingPluginFirst) { - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback)); } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 551d94488..e5396d35c 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -12,7 +12,6 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -44,17 +43,17 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } List pluginTasks = result.getPreTasks(); @@ -64,24 +63,24 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { } PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback)); } else if(result.errorCode() == PluginErrorCode.NoPluginToUpdate){ - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index deeed7497..8dbad6a54 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -10,8 +10,6 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; - /** * Created by ibm on 2017/5/26. */ @@ -40,7 +38,7 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } From 74f382550f2e841622881b74d2c2d8d9a0749724 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Mon, 21 Dec 2020 23:31:52 +0800 Subject: [PATCH 37/51] =?UTF-8?q?CHART-17494=20=E4=BF=AE=E6=94=B9=E7=82=B9?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=A0=87=E8=AE=B0=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../van/chart/map/VanChartMapSeriesPane.java | 154 ++++++++++++++---- .../VanChartMapConditionAttrContentPane.java | 3 + .../VanChartAnchorMarkerConditionPane.java | 42 +++++ .../VanChartAnchorPointMapConditionPane.java | 26 +++ .../series/VanChartMapAnchorMarkerPane.java | 64 ++++++++ 5 files changed, 253 insertions(+), 36 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/item/VanChartAnchorMarkerConditionPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartAnchorPointMapConditionPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index 00a847e2e..62b5bb489 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -37,6 +37,7 @@ import com.fr.van.chart.designer.component.marker.VanChartImageMarkerPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.designer.style.series.VanChartColorValueSeriesPane; import com.fr.van.chart.designer.style.series.VanChartEffectPane; +import com.fr.van.chart.map.designer.style.series.VanChartMapAnchorMarkerPane; import com.fr.van.chart.map.designer.style.series.VanChartMapScatterMarkerPane; import com.fr.van.chart.map.line.VanChartCurvePane; import com.fr.van.chart.map.line.VanChartLineMapEffectPane; @@ -61,16 +62,24 @@ import java.awt.event.ItemListener; * 地图-系列界面 */ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { - private static final String AREA_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Region"); - private static final String POINT_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Point"); - private static final String LINE_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Flow"); + private static final String AREA_STRING = Toolkit.i18nText("Fine-Design_Chart_Region"); + private static final String POINT_STRING = Toolkit.i18nText("Fine-Design_Chart_Point"); + private static final String LINE_STRING = Toolkit.i18nText("Fine-Design_Chart_Flow"); - private static final String[] MARKER_TYPES = new String[]{MapMarkerType.DEFAULT.toLocalString(), + private static final String[] MARKER_TYPES = new String[]{MapMarkerType.ANCHOR.toLocalString(), MapMarkerType.COMMON.toLocalString(), MapMarkerType.BUBBLE.toLocalString(), MapMarkerType.IMAGE.toLocalString()}; - private static final String[] LARGE_MARKER_TYPES = new String[]{MapMarkerType.DEFAULT.toLocalString(), + private static final String[] LARGE_MARKER_TYPES = new String[]{MapMarkerType.ANCHOR.toLocalString(), MapMarkerType.COMMON.toLocalString(), MapMarkerType.BUBBLE.toLocalString()}; + private static final String[] COMPATIBLE_MARKER_TYPES = new String[]{MapMarkerType.DEFAULT.toLocalString(), + MapMarkerType.ANCHOR.toLocalString(), MapMarkerType.COMMON.toLocalString(), + MapMarkerType.BUBBLE.toLocalString(), MapMarkerType.IMAGE.toLocalString()}; + + private static final String[] COMPATIBLE_LARGE_MARKER_TYPES = new String[]{MapMarkerType.DEFAULT.toLocalString(), + MapMarkerType.ANCHOR.toLocalString(), MapMarkerType.COMMON.toLocalString(), + MapMarkerType.BUBBLE.toLocalString()}; + //custom private UIButtonGroup areaPointAndLineGroup; @@ -85,9 +94,15 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { //point private UIComboBox markerTypeCom; + + private VanChartMapAnchorMarkerPane anchorMarkerPane; private VanChartMapScatterMarkerPane commonMarkerPane; private VanChartBubblePane bubblePane; private VanChartImageMarkerPane imageMarkerPane; + + private CardLayout markerTypeLayout; + private JPanel markerContentPane; + private UINumberDragPane pointAlphaPane; private VanChartEffectPane pointEffectPane; @@ -147,7 +162,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { checkLineMapLarge(); } }); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), lineMapLargeDataModelGroup); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Large_Model"), lineMapLargeDataModelGroup); return createLargeDataModelPane(panel); } @@ -162,14 +177,11 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { if (pointEffectPane != null) { GUICoreUtils.setEnabled(pointEffectPane, !largeModel); } - if (markerTypeCom != null) { - Object selectedItem = markerTypeCom.getSelectedItem(); - markerTypeCom.setModel(new DefaultComboBoxModel(largeModel ? LARGE_MARKER_TYPES : MARKER_TYPES)); - if (ComparatorUtils.equals(MapMarkerType.IMAGE.toLocalString(), selectedItem) && largeModel) { - markerTypeCom.setSelectedItem(MapMarkerType.COMMON.toLocalString()); - } else { - markerTypeCom.setSelectedItem(selectedItem); - } + + checkMarkerComboboxModel((VanChartMapPlot) plot); + + if (largeModel) { + checkLargeModelPlotSelectedItem(); } } @@ -182,6 +194,61 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } } + private void checkMarkerComboboxModel(VanChartMapPlot plot) { + if (markerTypeCom == null) { + return; + } + + if (shouldRefreshComboboxModel(plot)) { + + refreshMarkerTypeComboboxModel(plot); + + markerTypeCom.setSelectedItem(plot.getMapMarkerType().toLocalString()); + if (markerTypeLayout != null && markerContentPane != null) { + markerTypeLayout.show(markerContentPane, plot.getMapMarkerType().toLocalString()); + } + } + } + + private void checkLargeModelPlotSelectedItem() { + MapMarkerType selectedType = (MapMarkerType) markerTypeCom.getSelectedItem(); + + if (ComparatorUtils.equals(MapMarkerType.IMAGE.toLocalString(), selectedType)) { + markerTypeCom.setSelectedItem(MapMarkerType.COMMON.toLocalString()); + } else { + markerTypeCom.setSelectedItem(selectedType); + } + } + + private boolean shouldRefreshComboboxModel(VanChartMapPlot plot) { + MapMarkerType selectedType = plot.getMapMarkerType(); + DefaultComboBoxModel model = (DefaultComboBoxModel) markerTypeCom.getModel(); + + if (selectedType == MapMarkerType.DEFAULT) { + return model.getIndexOf(MapMarkerType.DEFAULT.toLocalString()) < 0; + } + + return model.getIndexOf(MapMarkerType.DEFAULT.toLocalString()) > -1; + } + + private void refreshMarkerTypeComboboxModel(VanChartMapPlot plot) { + if (largeModel(plot)) { + + if (plot.getMapMarkerType() == MapMarkerType.DEFAULT) { + markerTypeCom.setModel(new DefaultComboBoxModel<>(COMPATIBLE_LARGE_MARKER_TYPES)); + } else { + markerTypeCom.setModel(new DefaultComboBoxModel<>(LARGE_MARKER_TYPES)); + } + } else { + + if (plot.getMapMarkerType() == MapMarkerType.DEFAULT) { + markerTypeCom.setModel(new DefaultComboBoxModel<>(COMPATIBLE_MARKER_TYPES)); + } else { + markerTypeCom.setModel(new DefaultComboBoxModel<>(MARKER_TYPES)); + } + } + } + @Override protected JPanel getContentPane(boolean custom) { JPanel panel = new JPanel(new BorderLayout()); @@ -272,7 +339,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { Component[][] components = new Component[][]{ new Component[]{getColorPane(MapType.AREA)}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderWithAlphaPane)}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderWithAlphaPane)}, }; return TableLayoutHelper.createTableLayoutPane(components, row, col); @@ -357,28 +424,29 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { private Component createCurvePane() { curvePane = new VanChartCurvePane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve"), curvePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Curve"), curvePane); } private Component createAnimationPane() { lineMapEffectPane = new VanChartLineMapEffectPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation"), lineMapEffectPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Animation"), lineMapEffectPane); } //不透明度 private JPanel createPointAlphaPane() { pointAlphaPane = new UINumberDragPane(0, 100); - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha"), pointAlphaPane); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Report_Alpha"), pointAlphaPane); } private JPanel createPointEffectPane() { pointEffectPane = new VanChartEffectPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation"), pointEffectPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Animation"), pointEffectPane); } private JPanel createMarkerComPane() { - markerTypeCom = new UIComboBox(MARKER_TYPES); + markerTypeCom = new UIComboBox(COMPATIBLE_MARKER_TYPES); + anchorMarkerPane = new VanChartMapAnchorMarkerPane(); commonMarkerPane = new VanChartMapScatterMarkerPane(); commonMarkerPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); bubblePane = new VanChartBubblePane() { @@ -396,31 +464,34 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { }; imageMarkerPane = new VanChartImageMarkerPane(); - final JPanel[] panes = new JPanel[]{new JPanel(), commonMarkerPane, bubblePane, imageMarkerPane}; - final CardLayout cardLayout = new CardLayout(); - final JPanel cardPane = new JPanel(cardLayout) { + final JPanel[] panes = new JPanel[]{new JPanel(), anchorMarkerPane, commonMarkerPane, bubblePane, imageMarkerPane}; + + markerTypeLayout = new CardLayout(); + markerContentPane = new JPanel(markerTypeLayout) { @Override public Dimension getPreferredSize() { - return panes[markerTypeCom.getSelectedIndex()].getPreferredSize(); + int index = MapMarkerType.parse((String) markerTypeCom.getSelectedItem()).ordinal(); + + return panes[index].getPreferredSize(); } }; - for (int i = 0, len = MARKER_TYPES.length; i < len; i++) { - cardPane.add(panes[i], MARKER_TYPES[i]); + for (int i = 0, len = COMPATIBLE_MARKER_TYPES.length; i < len; i++) { + markerContentPane.add(panes[i], COMPATIBLE_MARKER_TYPES[i]); } markerTypeCom.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - cardLayout.show(cardPane, MARKER_TYPES[markerTypeCom.getSelectedIndex()]); + markerTypeLayout.show(markerContentPane, (String) markerTypeCom.getSelectedItem()); } }); - JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Point_Style"), markerTypeCom); + JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Point_Style"), markerTypeCom); JPanel markerPane = new JPanel(new BorderLayout(0, 6)); markerPane.add(northPane, BorderLayout.NORTH); - markerPane.add(cardPane, BorderLayout.CENTER); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); + markerPane.add(markerContentPane, BorderLayout.CENTER); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); } private JPanel createCustomPane(Plot plot) { @@ -500,8 +571,9 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } public void populateBean(Plot plot) { - if (plot != null && plot instanceof VanChartMapPlot) { + if (plot instanceof VanChartMapPlot) { if (markerTypeCom != null) { + checkMarkerComboboxModel(((VanChartMapPlot) plot)); markerTypeCom.setSelectedItem(((VanChartMapPlot) plot).getMapMarkerType().toLocalString()); } if (nullValueColorBox != null) { @@ -524,9 +596,10 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } public void updateBean(Plot plot) { - if (plot != null && plot instanceof VanChartMapPlot) { + if (plot instanceof VanChartMapPlot) { if (markerTypeCom != null) { - ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parseInt(markerTypeCom.getSelectedIndex())); + ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parse((String) markerTypeCom.getSelectedItem())); + checkMarkerComboboxModel((VanChartMapPlot) plot); } if (nullValueColorBox != null) { //TODO Bjorn 地图空值背景自动 @@ -587,6 +660,10 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); + + if (anchorMarkerPane != null) { + anchorMarkerPane.populateBean(attrMarker); + } if (commonMarkerPane != null) { commonMarkerPane.populateBean(attrMarker); } @@ -669,11 +746,16 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); defaultAttr.remove(attrBubble); if (markerTypeCom != null) { - if (markerTypeCom.getSelectedIndex() == 1) { + String selected = (String) markerTypeCom.getSelectedItem(); + MapMarkerType markerType = MapMarkerType.parse(selected); + + if (markerType == MapMarkerType.ANCHOR) { + defaultAttr.addDataSeriesCondition(anchorMarkerPane.updateBean()); + } else if (markerType == MapMarkerType.COMMON) { defaultAttr.addDataSeriesCondition(commonMarkerPane.updateBean()); - } else if (markerTypeCom.getSelectedIndex() == 2) { + } else if (markerType == MapMarkerType.BUBBLE) { defaultAttr.addDataSeriesCondition(bubblePane.updateBean()); - } else if (markerTypeCom.getSelectedIndex() == 3) { + } else if (markerType == MapMarkerType.IMAGE) { defaultAttr.addDataSeriesCondition(imageMarkerPane.updateBean()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapConditionAttrContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapConditionAttrContentPane.java index a29a6dd03..b659aee19 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapConditionAttrContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapConditionAttrContentPane.java @@ -9,6 +9,7 @@ import com.fr.plugin.chart.type.MapType; import com.fr.van.chart.designer.other.VanChartConditionAttrContentPane; import com.fr.van.chart.map.designer.VanMapAreaAndPointGroupPane; import com.fr.van.chart.map.designer.VanMapAreaPointAndLineGroupPane; +import com.fr.van.chart.map.designer.other.condition.pane.VanChartAnchorPointMapConditionPane; import com.fr.van.chart.map.designer.other.condition.pane.VanChartBubblePointMapConditionPane; import com.fr.van.chart.map.designer.other.condition.pane.VanChartCommonPointMapConditionPane; import com.fr.van.chart.map.designer.other.condition.pane.VanChartDefaultPointMapConditionPane; @@ -99,6 +100,8 @@ public class VanChartMapConditionAttrContentPane extends VanChartConditionAttrCo private Class getPointMapConditionClassPane(VanChartMapPlot plot) { MapMarkerType mapMarkerType = plot.getMapMarkerType(); switch (mapMarkerType){ + case ANCHOR: + return VanChartAnchorPointMapConditionPane.class; case COMMON: return VanChartCommonPointMapConditionPane.class; case BUBBLE: diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/item/VanChartAnchorMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/item/VanChartAnchorMarkerConditionPane.java new file mode 100644 index 000000000..fd8dc9669 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/item/VanChartAnchorMarkerConditionPane.java @@ -0,0 +1,42 @@ +package com.fr.van.chart.map.designer.other.condition.item; + +import com.fr.chart.base.DataSeriesCondition; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.base.VanChartAttrMarker; +import com.fr.van.chart.designer.other.condition.item.AbstractNormalMultiLineConditionPane; +import com.fr.van.chart.map.designer.style.series.VanChartMapAnchorMarkerPane; + +import javax.swing.JPanel; + +public class VanChartAnchorMarkerConditionPane extends AbstractNormalMultiLineConditionPane { + private VanChartMapAnchorMarkerPane anchorMarkerPane; + + public VanChartAnchorMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + protected String getItemLabelString() { + return Toolkit.i18nText("Fine-Design_Chart_Marker"); + } + + protected JPanel initContentPane() { + anchorMarkerPane = new VanChartMapAnchorMarkerPane(); + return anchorMarkerPane; + } + + public String nameForPopupMenuItem() { + return Toolkit.i18nText("Fine-Design_Chart_Marker"); + } + + public void populate(DataSeriesCondition condition) { + if (condition instanceof VanChartAttrMarker) { + anchorMarkerPane.populateBean((VanChartAttrMarker) condition); + } + } + + public DataSeriesCondition update() { + return anchorMarkerPane.updateBean(); + } +} + diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartAnchorPointMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartAnchorPointMapConditionPane.java new file mode 100644 index 000000000..aba352a2d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartAnchorPointMapConditionPane.java @@ -0,0 +1,26 @@ +package com.fr.van.chart.map.designer.other.condition.pane; + +import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.attr.EffectHelper; +import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrFloatColor; +import com.fr.plugin.chart.base.VanChartAttrMarker; +import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; +import com.fr.van.chart.map.designer.other.condition.item.VanChartAnchorMarkerConditionPane; + +public class VanChartAnchorPointMapConditionPane extends VanChartMapConditionPane { + + public VanChartAnchorPointMapConditionPane(Plot plot) { + super(plot); + } + + protected void addDiffAction() { + classPaneMap.put(VanChartAttrMarker.class, new VanChartAnchorMarkerConditionPane(this)); + if (addLabelOrEffectAction()) { + addLabelAction(); + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); + classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getScatterPlotDefaultEffect())); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java new file mode 100644 index 000000000..b6f43aa21 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java @@ -0,0 +1,64 @@ +package com.fr.van.chart.map.designer.style.series; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.plugin.chart.base.VanChartAttrMarker; +import com.fr.plugin.chart.marker.type.MarkerType; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +public class VanChartMapAnchorMarkerPane extends BasicBeanPane { + + private UISpinner anchorSize; + + public VanChartMapAnchorMarkerPane() { + anchorSize = new UISpinner(0, Double.MAX_VALUE, 0.1, 12); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Size")), anchorSize} + }; + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; + double[] row = {p}; + double[] col = {f, e}; + + JPanel content = TableLayoutHelper.createTableLayoutPane(components, row, col); + content.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); + + this.setLayout(new BorderLayout()); + this.add(content, BorderLayout.CENTER); + } + + public void populateBean(VanChartAttrMarker marker) { + if (marker == null) { + marker = new VanChartAttrMarker(); + } + + marker.setCommon(false); + + this.anchorSize.setValue(marker.getAnchorSize()); + } + + public VanChartAttrMarker updateBean() { + VanChartAttrMarker marker = new VanChartAttrMarker(); + + marker.setCommon(false); + marker.setMarkerType(MarkerType.MARKER_AUTO); + marker.setAnchorSize(this.anchorSize.getValue()); + + return marker; + } + + protected String title4PopupWindow() { + return "anchorMarker"; + } +} From b3e8ee29d5a79e13705d6510cc545c3739b45d3c Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Tue, 22 Dec 2020 10:19:04 +0800 Subject: [PATCH 38/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9populate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/style/series/VanChartMapAnchorMarkerPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java index b6f43aa21..458de4a18 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java @@ -41,10 +41,10 @@ public class VanChartMapAnchorMarkerPane extends BasicBeanPane Date: Tue, 22 Dec 2020 11:17:28 +0800 Subject: [PATCH 39/51] =?UTF-8?q?=E6=A2=B3=E7=90=86=E5=A4=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A8=A1=E5=BC=8F=E4=B8=AD=E7=9A=84=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../van/chart/map/VanChartMapSeriesPane.java | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index 62b5bb489..db257de3d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -178,10 +178,10 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { GUICoreUtils.setEnabled(pointEffectPane, !largeModel); } - checkMarkerComboboxModel((VanChartMapPlot) plot); - + VanChartMapPlot mapPlot = (VanChartMapPlot) plot; + refreshMarkerComboboxModel(mapPlot); if (largeModel) { - checkLargeModelPlotSelectedItem(); + checkLargeModelPlotSelectedItem(mapPlot); } } @@ -194,33 +194,21 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } } - private void checkMarkerComboboxModel(VanChartMapPlot plot) { - if (markerTypeCom == null) { - return; - } - - if (shouldRefreshComboboxModel(plot)) { - - refreshMarkerTypeComboboxModel(plot); - - markerTypeCom.setSelectedItem(plot.getMapMarkerType().toLocalString()); - if (markerTypeLayout != null && markerContentPane != null) { - markerTypeLayout.show(markerContentPane, plot.getMapMarkerType().toLocalString()); - } - } - } - - private void checkLargeModelPlotSelectedItem() { - MapMarkerType selectedType = (MapMarkerType) markerTypeCom.getSelectedItem(); + private void checkLargeModelPlotSelectedItem(VanChartMapPlot plot) { + String selected = plot.getMapMarkerType().toLocalString(); - if (ComparatorUtils.equals(MapMarkerType.IMAGE.toLocalString(), selectedType)) { + if (ComparatorUtils.equals(MapMarkerType.IMAGE.toLocalString(), selected)) { markerTypeCom.setSelectedItem(MapMarkerType.COMMON.toLocalString()); } else { - markerTypeCom.setSelectedItem(selectedType); + markerTypeCom.setSelectedItem(selected); } } private boolean shouldRefreshComboboxModel(VanChartMapPlot plot) { + if (markerTypeCom == null) { + return false; + } + MapMarkerType selectedType = plot.getMapMarkerType(); DefaultComboBoxModel model = (DefaultComboBoxModel) markerTypeCom.getModel(); @@ -231,7 +219,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { return model.getIndexOf(MapMarkerType.DEFAULT.toLocalString()) > -1; } - private void refreshMarkerTypeComboboxModel(VanChartMapPlot plot) { + private void refreshMarkerComboboxModel(VanChartMapPlot plot) { if (largeModel(plot)) { if (plot.getMapMarkerType() == MapMarkerType.DEFAULT) { @@ -247,6 +235,13 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { markerTypeCom.setModel(new DefaultComboBoxModel<>(MARKER_TYPES)); } } + + String selected = plot.getMapMarkerType().toLocalString(); + + markerTypeCom.setSelectedItem(selected); + if (markerTypeLayout != null && markerContentPane != null) { + markerTypeLayout.show(markerContentPane, selected); + } } @Override @@ -572,9 +567,15 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { public void populateBean(Plot plot) { if (plot instanceof VanChartMapPlot) { + VanChartMapPlot mapPlot = (VanChartMapPlot) plot; + if (markerTypeCom != null) { - checkMarkerComboboxModel(((VanChartMapPlot) plot)); - markerTypeCom.setSelectedItem(((VanChartMapPlot) plot).getMapMarkerType().toLocalString()); + + if (shouldRefreshComboboxModel(mapPlot)) { + refreshMarkerComboboxModel(mapPlot); + } + + markerTypeCom.setSelectedItem(mapPlot.getMapMarkerType().toLocalString()); } if (nullValueColorBox != null) { //TODO Bjorn 地图空值背景自动 @@ -585,11 +586,11 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); checkNullValueButton();*/ - nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); + nullValueColorBox.setSelectObject(mapPlot.getNullValueColor()); } //大数据模式 恢复用注释。下面3行删除。 if (lineMapLargeDataModelGroup != null) { - lineMapLargeDataModelGroup.setSelectedItem(((VanChartMapPlot) plot).getLineMapDataProcessor()); + lineMapLargeDataModelGroup.setSelectedItem(mapPlot.getLineMapDataProcessor()); } } super.populateBean(plot); @@ -597,18 +598,23 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { public void updateBean(Plot plot) { if (plot instanceof VanChartMapPlot) { + VanChartMapPlot mapPlot = (VanChartMapPlot) plot; + if (markerTypeCom != null) { - ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parse((String) markerTypeCom.getSelectedItem())); - checkMarkerComboboxModel((VanChartMapPlot) plot); + mapPlot.setMapMarkerType(MapMarkerType.parse((String) markerTypeCom.getSelectedItem())); + + if (shouldRefreshComboboxModel(mapPlot)) { + refreshMarkerComboboxModel(mapPlot); + } } if (nullValueColorBox != null) { //TODO Bjorn 地图空值背景自动 //((VanChartMapPlot) plot).setAutoNullValue(nullValueAuto.getSelectedIndex() == 0); - ((VanChartMapPlot) plot).setNullValueColor(nullValueColorBox.getSelectObject()); + mapPlot.setNullValueColor(nullValueColorBox.getSelectObject()); } //大数据模式 恢复用注释。下面3行删除。 if (lineMapLargeDataModelGroup != null) { - ((VanChartMapPlot) plot).setLineMapDataProcessor(lineMapLargeDataModelGroup.getSelectedItem()); + mapPlot.setLineMapDataProcessor(lineMapLargeDataModelGroup.getSelectedItem()); } } super.updateBean(plot); From bb555ecedcfbd94eb0f7cdbdb10410204717f4b8 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 22 Dec 2020 15:54:06 +0800 Subject: [PATCH 40/51] =?UTF-8?q?REPORT-45558=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=9F=8B=E7=82=B9=E3=80=91process=E8=A1=A8reuseCmptLi?= =?UTF-8?q?st=E5=AD=97=E6=AE=B5=E5=87=86=E7=A1=AE=E6=80=A7=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/info/JFormProcessInfo.java | 45 +++++++++++++------ .../template/info/JFormProcessInfoTest.java | 33 ++++++++++++-- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java index 180215a24..c8d52dae7 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java @@ -10,7 +10,10 @@ import com.fr.form.main.WidgetUtil; import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditorProvider; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WLayout; @@ -18,7 +21,6 @@ import com.fr.general.ComparatorUtils; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.report.cell.DefaultTemplateCellElement; - import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -94,23 +96,40 @@ public class JFormProcessInfo extends TemplateProcessInfo
{ private boolean hasTestECReport() { ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases(); for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) { - FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); - Iterator it = elementCase.cellIterator(); - if (!it.hasNext()) { + if (isTestECReport(elementCaseEditorProvider)) { return true; } - while (it.hasNext()) { - DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); - Object value = ce.getValue(); - if (isTestCell(value, ce.getStyle())) { - return true; - } - } - } return false; } + private boolean isTestECReport(ElementCaseEditorProvider elementCaseEditorProvider) { + FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); + if (!isTestElementCaseEditor((ElementCaseEditor) elementCaseEditorProvider)) { + return false; + } + Iterator it = elementCase.cellIterator(); + if (!it.hasNext()) { + return true; + } + while (it.hasNext()) { + DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); + Object value = ce.getValue(); + if (!isTestCell(value, ce.getStyle())) { + return false; + } + } + return true; + } + + private boolean isTestElementCaseEditor(ElementCaseEditor editor) { + return editor.getToolBars().length == 0 && editor.getListenerSize() == 0 + && ComparatorUtils.equals(editor.getBorderStyle(), new LayoutBorderStyle()) + && ComparatorUtils.equals(editor.getMargin(), new PaddingMargin()) + && editor.getBackground() == null; + + } + private boolean hasTestChart() { final boolean[] hasTestChart = {false}; Form.traversalWidget(this.template.getContainer(), new WidgetGather() { @@ -226,7 +245,7 @@ public class JFormProcessInfo extends TemplateProcessInfo { private void addComponentRemoveInfo(JSONObject jsonObject) { String componentID = jsonObject.getString("componentID"); - if (componentID == null){ + if (componentID == null) { return; } JSONObject info = componentProcessInfoMap.get(componentID); diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java index 663be8758..04327d354 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.template.info; +import com.fr.base.background.ColorBackground; import com.fr.chart.chartattr.ChartCollection; import com.fr.form.main.Form; import com.fr.form.ui.CardSwitchButton; @@ -21,6 +22,8 @@ import com.fr.report.worksheet.FormElementCase; import org.junit.Assert; import org.junit.Test; +import java.awt.Color; + /** * Created by kerry on 2020-05-08 */ @@ -35,14 +38,36 @@ public class JFormProcessInfoTest { wFitLayout.addWidget(editor); form.setContainer(wFitLayout); JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); - boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); - Assert.assertTrue(result1); + boolean result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); elementCase.addCellElement(new DefaultTemplateCellElement()); - boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); - Assert.assertTrue(result2); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); + + DefaultTemplateCellElement templateCellElement = new DefaultTemplateCellElement(); + templateCellElement.setValue(123); + + elementCase.addCellElement(templateCellElement); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertFalse(result); + + elementCase.removeCellElement(templateCellElement); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); + + editor.setBackground(ColorBackground.getInstance(Color.WHITE)); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertFalse(result); + + + editor.setBackground(null); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); } + + @Test public void testHasTestChart() { Form form = new Form(); From 8eec120925afadc3200340e0a86dc18984ef23c5 Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 22 Dec 2020 17:28:49 +0800 Subject: [PATCH 41/51] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginOperateUtils.java | 2 +- .../test/java/com/fr/design/extra/PluginOperateUtilsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 46683e0a0..499254aeb 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -231,7 +231,7 @@ public class PluginOperateUtils { else if (pluginMarker instanceof PluginMarkerAdapter) { return ((PluginMarkerAdapter) pluginMarker).getPluginName(); } - return pluginMarker == null ? null : pluginMarker.getPluginID(); + return pluginMarker == null ? StringUtils.EMPTY : pluginMarker.getPluginID(); } public static String getSwitchedInfo(PluginTaskResult result) { diff --git a/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java index 887cde43e..bc81cb2c3 100644 --- a/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java +++ b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java @@ -92,7 +92,7 @@ public class PluginOperateUtilsTest { EasyMock.replay(pluginContext); - Assert.assertNull(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get()); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), ""); Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext"); Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1"); Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); From 25de90af700a821b76bd0a44e4b1e3810802aa98 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Tue, 22 Dec 2020 21:28:58 +0800 Subject: [PATCH 42/51] =?UTF-8?q?=E6=A0=87=E8=AE=B0=E7=82=B9=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../map/designer/style/series/VanChartMapAnchorMarkerPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java index 458de4a18..d4c1f477b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java @@ -19,7 +19,7 @@ public class VanChartMapAnchorMarkerPane extends BasicBeanPane Date: Wed, 23 Dec 2020 13:38:26 +0800 Subject: [PATCH 43/51] =?UTF-8?q?REPORT-44644=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=8E=A5=E5=8F=A3=E5=BC=80=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/TemplateTreePane.java | 14 +++++- .../fr/design/fun/LocalResourceProvider.java | 43 +++++++++++++++++++ .../fun/TemplateTreeDefineProcessor.java | 19 ++++++++ .../impl/AbstractLocalResourceProvider.java | 23 ++++++++++ .../AbstractTemplateTreeDefineProcessor.java | 24 +++++++++++ .../DesignerFrameFileDealerPane.java | 36 +++++++++++++++- 6 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 5041cc34a..8c731e1f0 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -4,7 +4,9 @@ package com.fr.design.file; import com.fr.base.FRContext; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.fun.TemplateTreeDefineProcessor; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; @@ -27,8 +29,8 @@ import com.fr.workspace.server.lock.TplOperator; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; -import javax.swing.UIManager; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; @@ -87,6 +89,16 @@ public class TemplateTreePane extends JPanel implements FileOperations { } } + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isRightMouseButton(e)) { + TemplateTreeDefineProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TemplateTreeDefineProcessor.XML_TAG); + if (processor != null) { + processor.rightClickAction(e); + } + } + } + @Override public void mouseReleased(MouseEvent e) { if (toolBarStateChangeListener != null) { diff --git a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java new file mode 100644 index 000000000..482acd941 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java @@ -0,0 +1,43 @@ +package com.fr.design.fun; + +import com.fr.file.filetree.FileNodes; +import com.fr.stable.fun.mark.Immutable; +import com.fr.workspace.resource.WorkResource; +import com.fr.workspace.server.lock.TplOperator; + +/** + * 本地资源操作插件接口 + * + * @author hades + * @version 10.0 + * Created by hades on 2020/12/22 + */ +public interface LocalResourceProvider extends Immutable { + + String XML_TAG = "LocalResourceProvider"; + + int CURRENT_LEVEL = 1; + + /** + * eg: FineWorkResource + * + * @return 目录/文件的操作方式 + */ + WorkResource createResource(); + + + /** + * eg: LocalFileNodes + * + * @return 构建目录树的方式 + */ + FileNodes createFileNodes(); + + /** + * eg:LocalTplOperator + * + * 模板操作 关闭/打开等操作 + */ + TplOperator createTplOperator(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java b/designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java new file mode 100644 index 000000000..cfa5bcecb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java @@ -0,0 +1,19 @@ +package com.fr.design.fun; + +import com.fr.stable.fun.mark.Immutable; +import java.awt.event.MouseEvent; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/14 + */ +public interface TemplateTreeDefineProcessor extends Immutable { + + String XML_TAG = "TemplateTreeDefineProcessor"; + + int CURRENT_LEVEL = 1; + + void rightClickAction(MouseEvent mouseEvent); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java new file mode 100644 index 000000000..ebefc2ba6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java @@ -0,0 +1,23 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.LocalResourceProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/22 + */ +@API(level = LocalResourceProvider.CURRENT_LEVEL) +public abstract class AbstractLocalResourceProvider implements LocalResourceProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public int layerIndex() { + return DEFAULT_LAYER_INDEX; + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java new file mode 100644 index 000000000..eba101aad --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java @@ -0,0 +1,24 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.TemplateTreeDefineProcessor; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/21 + */ +@API(level = TemplateTreeDefineProcessor.CURRENT_LEVEL) +public abstract class AbstractTemplateTreeDefineProcessor implements TemplateTreeDefineProcessor { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public int layerIndex() { + return DEFAULT_LAYER_INDEX; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 4f59032dc..e019e31b4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -17,8 +17,8 @@ import com.fr.design.file.FileToolbarStateChangeListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; +import com.fr.design.fun.LocalResourceProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; @@ -34,10 +34,13 @@ import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; +import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; +import com.fr.file.filetree.FileNodes; +import com.fr.file.filetree.LocalFileNodes; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; @@ -46,6 +49,8 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -53,6 +58,11 @@ import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; +import com.fr.workspace.engine.base.FineObjectPool; +import com.fr.workspace.engine.resource.FineWorkResource; +import com.fr.workspace.resource.WorkResource; +import com.fr.workspace.server.lock.LocalTplOperator; +import com.fr.workspace.server.lock.TplOperator; import javax.swing.BorderFactory; import javax.swing.JDialog; import javax.swing.JOptionPane; @@ -98,6 +108,30 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt return context.contain(PluginModule.ExtraDesign, ShortCut.TEMPLATE_TREE); } }); + PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); + + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { + @Override + public void on(PluginEvent event) { + FineObjectPool.getInstance().getLocalPool().put(WorkResource.class, FineWorkResource.getInstance()); + FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); + FineObjectPool.getInstance().getLocalPool().put(TplOperator.class, new LocalTplOperator()); + UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); + } + }, filter); + + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() { + @Override + public void on(PluginEvent event) { + LocalResourceProvider provider = ExtraDesignClassManager.getInstance().getSingle(LocalResourceProvider.XML_TAG); + if (provider != null) { + FineObjectPool.getInstance().getLocalPool().put(WorkResource.class, provider.createResource()); + FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, provider.createFileNodes()); + FineObjectPool.getInstance().getLocalPool().put(TplOperator.class, provider.createTplOperator()); + UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); + } + } + }, filter); } private List otherToolbarStateChangeListeners = new ArrayList<>(); From b48bf4fb84682061a4338ab8239bc29ede0178d3 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Dec 2020 17:04:32 +0800 Subject: [PATCH 44/51] =?UTF-8?q?REPORT-44644=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=8E=A5=E5=8F=A3=E5=BC=80=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MutilTempalteTabPane.java | 4 +- .../com/fr/design/file/ResourceManager.java | 67 +++++++++++++++++++ .../com/fr/design/file/ResourceOperation.java | 62 +++++++++++++++++ .../com/fr/design/file/TemplateTreePane.java | 6 +- .../file/impl/DefaultResourceOperation.java | 48 +++++++++++++ .../fr/design/fun/LocalResourceProvider.java | 17 ++--- .../DesignerFrameFileDealerPane.java | 24 ------- .../com/fr/design/mainframe/JTemplate.java | 3 +- .../main/java/com/fr/file/FileNodeFILE.java | 16 ++--- 9 files changed, 193 insertions(+), 54 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/file/ResourceManager.java create mode 100644 designer-base/src/main/java/com/fr/design/file/ResourceOperation.java create mode 100644 designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 69aee1b50..4a4a4f734 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -18,8 +18,6 @@ import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.third.javax.annotation.Nonnull; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.lock.TplOperator; import javax.swing.BorderFactory; import javax.swing.ButtonModel; @@ -707,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent { // 只有是环境内的文件,才执行释放锁 if (file != null && file.isEnvFile()) { // release lock - WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); + ResourceManager.getInstance().getOperation().closeTpl(file.getPath()); } } diff --git a/designer-base/src/main/java/com/fr/design/file/ResourceManager.java b/designer-base/src/main/java/com/fr/design/file/ResourceManager.java new file mode 100644 index 000000000..5fe6896e9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/ResourceManager.java @@ -0,0 +1,67 @@ +package com.fr.design.file; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.file.impl.DefaultResourceOperation; +import com.fr.design.fun.LocalResourceProvider; +import com.fr.design.mainframe.DesignerFrameFileDealerPane; +import com.fr.design.ui.util.UIUtil; +import com.fr.file.filetree.FileNodes; +import com.fr.file.filetree.LocalFileNodes; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; +import com.fr.workspace.WorkContext; +import com.fr.workspace.engine.base.FineObjectPool; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/23 + */ +public class ResourceManager { + + private static final ResourceManager INSTANCE = new ResourceManager(); + + private ResourceOperation operation = new DefaultResourceOperation(); + + private ResourceManager() { + PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); + + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { + @Override + public void on(PluginEvent event) { + registerOperation(new DefaultResourceOperation()); + FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); + UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); + } + }, filter); + + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() { + @Override + public void on(PluginEvent event) { + LocalResourceProvider provider = ExtraDesignClassManager.getInstance().getSingle(LocalResourceProvider.XML_TAG); + if (provider != null && WorkContext.getCurrent().isLocal()) { + registerOperation(provider.createResourceOperation()); + FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, provider.createFileNodes()); + UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); + } + } + }, filter); + } + + public static ResourceManager getInstance() { + return INSTANCE; + } + + private void registerOperation(ResourceOperation operation) { + this.operation = operation; + } + + public ResourceOperation getOperation() { + return this.operation; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/file/ResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/ResourceOperation.java new file mode 100644 index 000000000..29834cf60 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/ResourceOperation.java @@ -0,0 +1,62 @@ +package com.fr.design.file; + +import com.fr.common.annotations.Open; +import com.fr.file.FILE; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/23 + */ +@Open +public interface ResourceOperation { + + /** + * 读取模板 + * @param path + * @return + * @throws Exception + */ + InputStream readTpl(String path) throws Exception; + + /** + * 保存模板 + * @param file + * @return + * @throws Exception + */ + OutputStream saveTpl(FILE file) throws Exception; + + /** + * 删除某个目录/某个模板 + * @param file + * @return + */ + boolean delete(FILE file); + + /** + * 关闭模板 + * @param path + * @return + */ + boolean closeTpl(String path); + + /** + * 重命名模板/路径 + * @param from + * @param to + * @return + */ + boolean rename(String from, String to); + + /** + * 创建工作目录 + * @param path + * @return + */ + boolean mkdir(String path); + + +} diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 8c731e1f0..d6b50ab7c 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -194,7 +194,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public boolean mkdir(String path) { - return WorkContext.getWorkResource().createDirectory(path); + return ResourceManager.getInstance().getOperation().mkdir(path); } /** @@ -337,7 +337,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (node instanceof FileNode) { FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); if (nodeFILE.exists()) { - if (WorkContext.getCurrent().get(TplOperator.class).delete(nodeFILE.getPath())) { + if (ResourceManager.getInstance().getOperation().delete(nodeFILE)) { HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); } else { success = false; @@ -439,7 +439,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { try { // 接收的是WEB-INF下的路径 - return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); + return ResourceManager.getInstance().getOperation().rename(from, to); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java new file mode 100644 index 000000000..b06520319 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java @@ -0,0 +1,48 @@ +package com.fr.design.file.impl; + +import com.fr.design.file.ResourceOperation; +import com.fr.file.FILE; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.lock.TplOperator; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/23 + */ +public class DefaultResourceOperation implements ResourceOperation { + + @Override + public InputStream readTpl(String path) throws Exception { + return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); + } + + @Override + public OutputStream saveTpl(FILE file) throws Exception { + return file.asOutputStream(); + } + + @Override + public boolean closeTpl(String path) { + return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); + } + + @Override + public boolean delete(FILE file) { + return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath()); + } + + @Override + public boolean rename(String from, String to) { + return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); + } + + @Override + public boolean mkdir(String path) { + return WorkContext.getWorkResource().createDirectory(path); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java index 482acd941..afc8ad545 100644 --- a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java @@ -1,9 +1,8 @@ package com.fr.design.fun; +import com.fr.design.file.ResourceOperation; import com.fr.file.filetree.FileNodes; import com.fr.stable.fun.mark.Immutable; -import com.fr.workspace.resource.WorkResource; -import com.fr.workspace.server.lock.TplOperator; /** * 本地资源操作插件接口 @@ -19,12 +18,11 @@ public interface LocalResourceProvider extends Immutable { int CURRENT_LEVEL = 1; /** - * eg: FineWorkResource + * eg: DefaultResourceOperation * - * @return 目录/文件的操作方式 + * @return 目录/模板的各种操作 */ - WorkResource createResource(); - + ResourceOperation createResourceOperation(); /** * eg: LocalFileNodes @@ -33,11 +31,4 @@ public interface LocalResourceProvider extends Immutable { */ FileNodes createFileNodes(); - /** - * eg:LocalTplOperator - * - * 模板操作 关闭/打开等操作 - */ - TplOperator createTplOperator(); - } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index e019e31b4..50c61cda2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -108,30 +108,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt return context.contain(PluginModule.ExtraDesign, ShortCut.TEMPLATE_TREE); } }); - PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); - - PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { - @Override - public void on(PluginEvent event) { - FineObjectPool.getInstance().getLocalPool().put(WorkResource.class, FineWorkResource.getInstance()); - FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); - FineObjectPool.getInstance().getLocalPool().put(TplOperator.class, new LocalTplOperator()); - UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); - } - }, filter); - - PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() { - @Override - public void on(PluginEvent event) { - LocalResourceProvider provider = ExtraDesignClassManager.getInstance().getSingle(LocalResourceProvider.XML_TAG); - if (provider != null) { - FineObjectPool.getInstance().getLocalPool().put(WorkResource.class, provider.createResource()); - FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, provider.createFileNodes()); - FineObjectPool.getInstance().getLocalPool().put(TplOperator.class, provider.createTplOperator()); - UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); - } - } - }, filter); } private List otherToolbarStateChangeListeners = new ArrayList<>(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index eb191383f..929519b18 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -24,6 +24,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.ResourceManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; @@ -813,7 +814,7 @@ public abstract class JTemplate> return false; } try { - this.getTarget().export(editingFILE.asOutputStream()); + this.getTarget().export(ResourceManager.getInstance().getOperation().saveTpl(editingFILE)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index b033d229b..4b388be36 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -2,6 +2,7 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; +import com.fr.design.file.ResourceManager; import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.file.NodeAuthProcessor; @@ -22,10 +23,8 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.resource.WorkResourceTempRenameStream; -import com.fr.workspace.server.lock.TplOperator; import javax.swing.*; -import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; @@ -379,14 +378,11 @@ public class FileNodeFILE implements FILE { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - InputStream in = new ByteArrayInputStream( - WorkContext.getCurrent().get(TplOperator.class).readAndLockFile( - StableUtils.pathJoin( - ProjectConstants.REPORTLETS_NAME, - envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1) - ) - ) - ); + InputStream in = ResourceManager.getInstance().getOperation().readTpl( + StableUtils.pathJoin( + ProjectConstants.REPORTLETS_NAME, + envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1) + )); return envPath.endsWith(".cpt") || envPath.endsWith(".frm") ? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(FineEncryptUtils.decode(in))) : in; From 1454cc104f42f93e3a2a747e6792a2166e8122b7 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 23 Dec 2020 17:28:19 +0800 Subject: [PATCH 45/51] =?UTF-8?q?REPORT-40684=20=E7=BB=98=E5=88=B6?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=BE=85=E5=8A=A9=E7=BA=BF=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E5=89=8D=E9=80=82=E9=85=8D=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=EF=BC=8C=E5=8E=BB=E9=99=A4=E5=90=88=E5=B9=B6=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E4=BD=BF=E7=94=A8=E8=83=8C=E6=99=AF=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E8=BE=85=E5=8A=A9=E7=BA=BF=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/grid/GridUI.java | 331 ++++++++++++------ 1 file changed, 233 insertions(+), 98 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 5f5476511..711ecee83 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -49,6 +49,7 @@ import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; import com.fr.stable.AssistUtils; import com.fr.third.antlr.ANTLRException; +import com.fr.third.guava.collect.HashMultimap; import javax.swing.JComponent; import javax.swing.UIManager; @@ -73,6 +74,7 @@ import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Objects; public class GridUI extends ComponentUI { @@ -91,6 +93,7 @@ public class GridUI extends ComponentUI { protected List paintCellElementList = new ArrayList(); protected List paintCellElementRectangleList = new ArrayList(); protected List paginateLineList = new ArrayList(); // 分页线 + protected HashMultimap mergeCellElementTable = HashMultimap.create(); // 为了画白色的背景. protected static Background WHITE_Backgorund = ColorBackground.getInstance(Color.WHITE); // CellElementPainter @@ -247,7 +250,7 @@ public class GridUI extends ComponentUI { - reportSettings.getFooterHeight().toPixD(resolution); } - private void paintGridLine(Graphics g, Grid grid, double realWidth, double realHeight, + private void paintGridLine(Graphics g, Grid grid, TemplateElementCase report, double realWidth, double realHeight, int resolution) { Graphics2D g2d = (Graphics2D) g; @@ -257,22 +260,51 @@ public class GridUI extends ComponentUI { // 分页线 paginateLineList.clear(); + // 合并单元格 + mergeCellElementTable.clear(); boolean isShowVerticalPaginateLine = grid.getPaginateLineShowType() == Grid.MULTIPLE_PAGINATE_LINE; boolean isShowHorizontalPaginateLine = grid.getPaginateLineShowType() != Grid.NO_PAGINATE_LINE; - new DrawVerticalLineHelper(grid.getVerticalBeginValue(), verticalEndValue, - grid.isShowGridLine(), isShowVerticalPaginateLine, rowHeightList, paperPaintHeight, - paginateLineList, realWidth, resolution).iterateStart2End(g2d); + Iterator cells = report.intersect(grid.getHorizontalBeginValue(), grid.getVerticalBeginValue(), + horizontalEndValue - grid.getHorizontalBeginValue(), verticalEndValue - grid.getVerticalBeginValue()); + while (cells.hasNext()) { + TemplateCellElement cellElement = (TemplateCellElement) cells.next(); + if (cellElement == null) { + continue; + } + int columnSpan = cellElement.getColumnSpan(); + int rowSpan = cellElement.getRowSpan(); + if (columnSpan > 1 || rowSpan > 1) { + for (int c = 0; c < columnSpan - 1; c++) { + for (int r = 0; r < rowSpan; r++) { + mergeCellElementTable.put(CellPosition.value(cellElement.getRow() + r, cellElement.getColumn() + c), CellPosition.RIGHT); + } + } + for (int r = 0; r < rowSpan - 1; r++) { + for (int c = 0; c < columnSpan; c++) { + mergeCellElementTable.put(CellPosition.value(cellElement.getRow() + r, cellElement.getColumn() + c), CellPosition.BOTTOM); + } + } + } + } + GridRange gridRange = GridRange.range(grid.getHorizontalBeginValue(), horizontalEndValue, grid.getVerticalBeginValue(), verticalEndValue) + .rangeList(rowHeightList, columnWidthList) + .realSize(realWidth, realHeight); + + new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), + isShowVerticalPaginateLine, paperPaintHeight, + paginateLineList, resolution).iterateStart2End(g2d); - new DrawHorizontalLineHelper(grid.getHorizontalBeginValue(), horizontalEndValue, - grid.isShowGridLine(), isShowHorizontalPaginateLine, columnWidthList, paperPaintWidth, - paginateLineList, realHeight, resolution).iterateStart2End(g2d); + new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), + isShowHorizontalPaginateLine, paperPaintWidth, + paginateLineList, resolution).iterateStart2End(g2d); } /** * 最后处理 */ + @Override public void finalize() { try { super.finalize(); @@ -285,80 +317,34 @@ public class GridUI extends ComponentUI { } private static abstract class DrawLineHelper { - private int startIndex; - private int endIndex; + protected GridRange gridRange; - private boolean showGridLine; - private boolean showPaginateLine; + protected boolean showGridLine; + protected boolean showPaginateLine; - private DynamicUnitList sizeList; - private double paperPaintSize; + protected double paperPaintSize; - private List paginateLineList; + protected List paginateLineList; Line2D tmpLine2D = new Line2D.Double(0, 0, 0, 0); - private int resolution; + protected int resolution; - private static final double THRESHOLD = 1.0E-4D; + protected static final double THRESHOLD = 1.0E-4D; - DrawLineHelper(int startIndex, int endIndex, boolean showGridLine, - boolean showPaginateLine, DynamicUnitList sizeList, double paperPaintSize, + DrawLineHelper(GridRange gridRange, boolean showGridLine, + boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - this.startIndex = startIndex; - this.endIndex = endIndex; + this.gridRange = gridRange; this.showGridLine = showGridLine; this.showPaginateLine = showPaginateLine; - this.sizeList = sizeList; this.paperPaintSize = paperPaintSize; this.paginateLineList = paginateLineList; this.resolution = resolution; } - protected void iterateStart2End(Graphics2D g2d) { - float tmpSize = 0, paperSumSize = 0, sumSize = 0; - for (int i = 0; i <= endIndex; i++) { - // denny: 开始 - if (i == 0) { - i = startIndex; - - // denny: 增加从0到Grid左边被hide的列宽 - for (int k = 0; k < startIndex; k++) { - tmpSize = sizeList.get(k).toPixF(resolution); - - paperSumSize += tmpSize; - if (paperSumSize >= paperPaintSize) { - paperSumSize = tmpSize; - } - } - } - - // adjust height. - tmpSize = sizeList.get(i).toPixF(resolution); - paperSumSize += tmpSize; - - if (showGridLine) {// paint line. - setLine2D((int) sumSize); - g2d.draw(tmpLine2D); - } - - // paint paper margin line. - if (showPaginateLine && paperSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) sumSize)); - paperSumSize = tmpSize; - } - - sumSize += tmpSize; - } - - // paint 最后一个横线.. - if (showGridLine) { - drawLastLine(g2d, (int) sumSize); - } - } - - protected abstract void setLine2D(int sumSize); + protected abstract void iterateStart2End(Graphics2D g2d); protected abstract Line2D.Double getPaginateLine2D(int sumSize); @@ -366,14 +352,12 @@ public class GridUI extends ComponentUI { } private class DrawVerticalLineHelper extends DrawLineHelper { - private double realWidth; - DrawVerticalLineHelper(int startIndex, int endIndex, boolean showGridLine, - boolean showPaginateLine, DynamicUnitList unitSizeList, double paperPaintSize, - List paginateLineList, double realWidth, int resolution) { - super(startIndex, endIndex, showGridLine, showPaginateLine, unitSizeList, + DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, + boolean showPaginateLine, double paperPaintSize, + List paginateLineList, int resolution) { + super(gridRange, showGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); - this.realWidth = realWidth; } @Override @@ -382,25 +366,58 @@ public class GridUI extends ComponentUI { } @Override - protected void setLine2D(int sumHeight) { - tmpLine2D.setLine(0, sumHeight, realWidth, sumHeight); + protected void drawLastLine(Graphics2D g2d, int sumHeight) { + GraphHelper.drawLine(g2d, 0, sumHeight, gridRange.realWidth, sumHeight); } @Override - protected void drawLastLine(Graphics2D g2d, int sumHeight) { - GraphHelper.drawLine(g2d, 0, sumHeight, realWidth, sumHeight); + protected void iterateStart2End(Graphics2D g2d) { + float rowHeight, paperYAxisSumSize = 0, yAxisSumSize = 0; + for (int i = 0; i <= gridRange.yEndIndex; i++) { + if (i == 0) { + i = gridRange.yBeginIndex; + for (int k = 0; k < gridRange.yBeginIndex; k++) { + rowHeight = gridRange.rowHeightList.get(k).toPixF(resolution); + + paperYAxisSumSize += rowHeight; + if (paperYAxisSumSize >= paperPaintSize) { + paperYAxisSumSize = rowHeight; + } + } + } + rowHeight = gridRange.rowHeightList.get(i).toPixF(resolution); + paperYAxisSumSize += rowHeight; + if (showGridLine) { + float columnWidth, xAxisSumSize = 0; + for (int j = gridRange.xBeginIndex; j <= gridRange.xEndIndex; j++) { + columnWidth = gridRange.columnWidthList.get(j).toPixF(resolution); + if (!mergeCellElementTable.get(CellPosition.value(i - 1, j)).contains(CellPosition.BOTTOM)) { + tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize + columnWidth, yAxisSumSize); + g2d.draw(tmpLine2D); + } + xAxisSumSize += columnWidth; + } + } + if (showPaginateLine && paperYAxisSumSize - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) yAxisSumSize)); + paperYAxisSumSize = rowHeight; + } + yAxisSumSize += rowHeight; + } + // paint 最后一个横线.. + if (showGridLine) { + drawLastLine(g2d, (int) yAxisSumSize); + } } } private class DrawHorizontalLineHelper extends DrawLineHelper { - private double realHeight; - DrawHorizontalLineHelper(int startIndex, int endIndex, boolean showGridLine, - boolean showPaginateLine, DynamicUnitList unitSizeList, double paperPaintSize, - List paginateLineList, double realHeight, int resolution) { - super(startIndex, endIndex, showGridLine, showPaginateLine, unitSizeList, + DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, + boolean showPaginateLine, double paperPaintSize, + List paginateLineList, int resolution) { + super(gridRange, showGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); - this.realHeight = realHeight; } @Override @@ -409,13 +426,47 @@ public class GridUI extends ComponentUI { } @Override - protected void setLine2D(int sumWidth) { - tmpLine2D.setLine(sumWidth, 0, sumWidth, realHeight); + protected void drawLastLine(Graphics2D g2d, int sumWidth) { + GraphHelper.drawLine(g2d, sumWidth, 0, sumWidth, gridRange.realHeight); } @Override - protected void drawLastLine(Graphics2D g2d, int sumWidth) { - GraphHelper.drawLine(g2d, sumWidth, 0, sumWidth, realHeight); + protected void iterateStart2End(Graphics2D g2d) { + float columnWidth, paperXAxisSumSize = 0, xAxisSumSize = 0; + for (int i = 0; i <= gridRange.xEndIndex; i++) { + if (i == 0) { + i = gridRange.xBeginIndex; + for (int k = 0; k < gridRange.xBeginIndex; k++) { + columnWidth = gridRange.columnWidthList.get(k).toPixF(resolution); + paperXAxisSumSize += columnWidth; + if (paperXAxisSumSize >= paperPaintSize) { + paperXAxisSumSize = columnWidth; + } + } + } + columnWidth = gridRange.columnWidthList.get(i).toPixF(resolution); + paperXAxisSumSize += columnWidth; + if (showGridLine) { + float rowHeight, yAxisSumSize = 0; + for (int j = gridRange.yBeginIndex; j <= gridRange.yEndIndex; j++) { + rowHeight = gridRange.rowHeightList.get(j).toPixF(resolution); + if (!mergeCellElementTable.get(CellPosition.value(j, i - 1)).contains(CellPosition.RIGHT)) { + tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize, yAxisSumSize + rowHeight); + g2d.draw(tmpLine2D); + } + yAxisSumSize += rowHeight; + } + } + if (showPaginateLine && paperXAxisSumSize - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) xAxisSumSize)); + paperXAxisSumSize = columnWidth; + } + xAxisSumSize += columnWidth; + } + // paint 最后一个横线.. + if (showGridLine) { + drawLastLine(g2d, (int) xAxisSumSize); + } } } @@ -482,18 +533,6 @@ public class GridUI extends ComponentUI { // peter:tmpRectangle2D_3只是一个临时的Rectangle2D,由于后面不少地方需要用到这个矩形 this.cell_back_rect.setRect(0, 0, this.tmpRectangle.getWidth() - 1, this.tmpRectangle.getHeight() - 1.5); - // peter:对于合并的单元格,需要先白色的背景来清除背景. - if (tmpCellElement.getColumnSpan() > 1 || tmpCellElement.getRowSpan() > 1) { - // REPORT-23492 要看下是否设置了纸张背景 如果设置了按照背景来画 - ReportSettingsProvider reportSettings = getReportSettings(report); - Background currentBackground = reportSettings.getBackground(); - if (currentBackground != null) { - currentBackground.paint(g2d, this.cell_back_rect); - } else { - WHITE_Backgorund.paint(g2d, this.cell_back_rect); - } - //daniel:上面这里就有问题了啊....报表的背景在这个之前画的 会覆盖报表背景....不过只是设计器中看到预览浏览没问题 - } // peter:将这个元素添加到需要paint的元素列表当中去,留着画边框线.. paintCellElementList.add(tmpCellElement); paintCellElementRectangleList.add(this.tmpRectangle.clone()); @@ -1093,8 +1132,7 @@ public class GridUI extends ComponentUI { this.paintBackground(g2d, grid, elementCase, resolution); // 画Grid Line - this.paintGridLine(g2d, grid, realWidth, realHeight, resolution); - + this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution); // peter:添上线程的支持,有时候,paint元素的时候,可能会有元素被删除了. // 需要先清除画Border需要的元素. paintCellElementList.clear(); @@ -1277,4 +1315,101 @@ public class GridUI extends ComponentUI { paginateLineList.add(new Line2D.Double(0, sumHeight, width, sumHeight)); } } + + /** + * 描述单元格位置的POJO + */ + private static class CellPosition { + public final static int TOP = 0; + public static final int LEFT = 1; + public final static int BOTTOM = 2; + public static final int RIGHT = 4; + public int x; + public int y; + + public CellPosition(int x, int y) { + this.x = x; + this.y = y; + } + + public static CellPosition value(int x, int y) { + return new CellPosition(x, y); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CellPosition that = (CellPosition) o; + return x == that.x && y == that.y; + } + + @Override + public int hashCode() { + return Objects.hash(x, y); + } + } + + /** + * 描述表格范围的POJO + * x轴为水平方向,对应的宽度表为列宽列表 + * y轴为垂直方向,对应的宽度表为行高列表 + */ + private static class GridRange { + + public int xBeginIndex; + public int xEndIndex; + public int yBeginIndex; + public int yEndIndex; + double realWidth; + double realHeight; + /** + * 行高列表,对应y方向线段 + */ + public DynamicUnitList rowHeightList; + + /** + * 列宽列表,对应x方向线段 + */ + public DynamicUnitList columnWidthList; + + public GridRange(int xBeginIndex, int xEndIndex, int yBeginIndex, int yEndIndex) { + this.xBeginIndex = xBeginIndex; + this.xEndIndex = xEndIndex; + this.yBeginIndex = yBeginIndex; + this.yEndIndex = yEndIndex; + } + + /** + * 设置行高列宽列表 + * + * @param rowHeightList 行高列表 + * @param columnWidthList 列宽列表 + */ + public GridRange rangeList(DynamicUnitList rowHeightList, DynamicUnitList columnWidthList) { + this.rowHeightList = rowHeightList; + this.columnWidthList = columnWidthList; + return this; + } + + /** + * 设置表格真实宽高 + * + * @param realWidth 宽度 + * @param realHeight 高度 + */ + public GridRange realSize(double realWidth, double realHeight) { + this.realWidth = realWidth; + this.realHeight = realHeight; + return this; + } + + public static GridRange range(int xBeginIndex, int xEndIndex, int yBeginIndex, int yEndIndex) { + return new GridRange(xBeginIndex, xEndIndex, yBeginIndex, yEndIndex); + } + } } From c9def50757e53e37103732e90de2d94b618d236d Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Dec 2020 17:45:29 +0800 Subject: [PATCH 46/51] =?UTF-8?q?REPORT-44644=20fix=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListCache.java | 15 +++++++++++- .../fr/design/file/MutilTempalteTabPane.java | 2 +- ....java => TemplateFileResourceManager.java} | 24 +++++++------------ ...ava => TemplateFileResourceOperation.java} | 12 ++++++---- .../com/fr/design/file/TemplateTreePane.java | 7 +++--- ...DefaultTemplateFileResourceOperation.java} | 10 ++++---- .../fr/design/fun/LocalResourceProvider.java | 4 ++-- .../DesignerFrameFileDealerPane.java | 12 ---------- .../com/fr/design/mainframe/JTemplate.java | 5 ++-- .../main/java/com/fr/file/FileNodeFILE.java | 4 ++-- 10 files changed, 45 insertions(+), 50 deletions(-) rename designer-base/src/main/java/com/fr/design/file/{ResourceManager.java => TemplateFileResourceManager.java} (77%) rename designer-base/src/main/java/com/fr/design/file/{ResourceOperation.java => TemplateFileResourceOperation.java} (74%) rename designer-base/src/main/java/com/fr/design/file/impl/{DefaultResourceOperation.java => DefaultTemplateFileResourceOperation.java} (75%) diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 763ffcd1f..154caa32b 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -23,6 +23,7 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; +import java.util.LinkedHashMap; import javax.swing.SwingUtilities; import java.io.ByteArrayOutputStream; import java.util.ArrayList; @@ -44,6 +45,9 @@ public class HistoryTemplateListCache implements CallbackEvent { private List> historyList; private JTemplate editingTemplate; + // 插件stop时的已经打开的模板xml byte缓存 插件重新run时 重新加载 + private final Map cacheMap = new LinkedHashMap<>(); + public static HistoryTemplateListCache getInstance() { return Holder.INSTANCE; } @@ -74,7 +78,11 @@ public class HistoryTemplateListCache implements CallbackEvent { selected.fireJTemplateClosed(); selected.stopEditing(); try { - historyList.remove(contains(selected)); + int index = contains(selected); + historyList.remove(index); + if (stashFILEMap != null) { + stashFILEMap.remove(index); + } selected.getEditingFILE().closeTemplate(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); @@ -422,6 +430,7 @@ public class HistoryTemplateListCache implements CallbackEvent { /** * 重新载入当前模板,刷新数据/对象 */ + @Deprecated public void reloadCurrentTemplate() { JTemplate jt = getCurrentEditingTemplate(); boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); @@ -441,4 +450,8 @@ public class HistoryTemplateListCache implements CallbackEvent { } }); } + + public void stashByName() { + + } } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 4a4a4f734..3ad4c401a 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -705,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent { // 只有是环境内的文件,才执行释放锁 if (file != null && file.isEnvFile()) { // release lock - ResourceManager.getInstance().getOperation().closeTpl(file.getPath()); + TemplateFileResourceManager.getOperation().closeTemplate(file.getPath()); } } diff --git a/designer-base/src/main/java/com/fr/design/file/ResourceManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java similarity index 77% rename from designer-base/src/main/java/com/fr/design/file/ResourceManager.java rename to designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java index 5fe6896e9..775584732 100644 --- a/designer-base/src/main/java/com/fr/design/file/ResourceManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java @@ -1,7 +1,7 @@ package com.fr.design.file; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.file.impl.DefaultResourceOperation; +import com.fr.design.file.impl.DefaultTemplateFileResourceOperation; import com.fr.design.fun.LocalResourceProvider; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.ui.util.UIUtil; @@ -21,19 +21,17 @@ import com.fr.workspace.engine.base.FineObjectPool; * @version 10.0 * Created by hades on 2020/12/23 */ -public class ResourceManager { +public class TemplateFileResourceManager { - private static final ResourceManager INSTANCE = new ResourceManager(); + private static TemplateFileResourceOperation OPERATION = new DefaultTemplateFileResourceOperation(); - private ResourceOperation operation = new DefaultResourceOperation(); - - private ResourceManager() { + private TemplateFileResourceManager() { PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { @Override public void on(PluginEvent event) { - registerOperation(new DefaultResourceOperation()); + registerOperation(new DefaultTemplateFileResourceOperation()); FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); } @@ -52,16 +50,12 @@ public class ResourceManager { }, filter); } - public static ResourceManager getInstance() { - return INSTANCE; - } - - private void registerOperation(ResourceOperation operation) { - this.operation = operation; + private static void registerOperation(TemplateFileResourceOperation operation) { + OPERATION = operation; } - public ResourceOperation getOperation() { - return this.operation; + public static TemplateFileResourceOperation getOperation() { + return OPERATION; } } diff --git a/designer-base/src/main/java/com/fr/design/file/ResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java similarity index 74% rename from designer-base/src/main/java/com/fr/design/file/ResourceOperation.java rename to designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java index 29834cf60..5b1ba9c89 100644 --- a/designer-base/src/main/java/com/fr/design/file/ResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java @@ -6,12 +6,14 @@ import java.io.InputStream; import java.io.OutputStream; /** + * 模板资源操作,可操作模板及模板目录 + * * @author hades * @version 10.0 * Created by hades on 2020/12/23 */ @Open -public interface ResourceOperation { +public interface TemplateFileResourceOperation { /** * 读取模板 @@ -19,7 +21,7 @@ public interface ResourceOperation { * @return * @throws Exception */ - InputStream readTpl(String path) throws Exception; + InputStream readTemplate(String path) throws Exception; /** * 保存模板 @@ -27,7 +29,7 @@ public interface ResourceOperation { * @return * @throws Exception */ - OutputStream saveTpl(FILE file) throws Exception; + OutputStream saveTemplate(FILE file) throws Exception; /** * 删除某个目录/某个模板 @@ -41,7 +43,7 @@ public interface ResourceOperation { * @param path * @return */ - boolean closeTpl(String path); + boolean closeTemplate(String path); /** * 重命名模板/路径 @@ -52,7 +54,7 @@ public interface ResourceOperation { boolean rename(String from, String to); /** - * 创建工作目录 + * 创建目录 * @param path * @return */ diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index d6b50ab7c..f54fd8eeb 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -25,7 +25,6 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; -import com.fr.workspace.server.lock.TplOperator; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -194,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public boolean mkdir(String path) { - return ResourceManager.getInstance().getOperation().mkdir(path); + return TemplateFileResourceManager.getOperation().mkdir(path); } /** @@ -337,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (node instanceof FileNode) { FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); if (nodeFILE.exists()) { - if (ResourceManager.getInstance().getOperation().delete(nodeFILE)) { + if (TemplateFileResourceManager.getOperation().delete(nodeFILE)) { HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); } else { success = false; @@ -439,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { try { // 接收的是WEB-INF下的路径 - return ResourceManager.getInstance().getOperation().rename(from, to); + return TemplateFileResourceManager.getOperation().rename(from, to); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java similarity index 75% rename from designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java rename to designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java index b06520319..e72d78fca 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java @@ -1,6 +1,6 @@ package com.fr.design.file.impl; -import com.fr.design.file.ResourceOperation; +import com.fr.design.file.TemplateFileResourceOperation; import com.fr.file.FILE; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; @@ -13,20 +13,20 @@ import java.io.OutputStream; * @version 10.0 * Created by hades on 2020/12/23 */ -public class DefaultResourceOperation implements ResourceOperation { +public class DefaultTemplateFileResourceOperation implements TemplateFileResourceOperation { @Override - public InputStream readTpl(String path) throws Exception { + public InputStream readTemplate(String path) throws Exception { return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); } @Override - public OutputStream saveTpl(FILE file) throws Exception { + public OutputStream saveTemplate(FILE file) throws Exception { return file.asOutputStream(); } @Override - public boolean closeTpl(String path) { + public boolean closeTemplate(String path) { return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); } diff --git a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java index afc8ad545..51b36d916 100644 --- a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun; -import com.fr.design.file.ResourceOperation; +import com.fr.design.file.TemplateFileResourceOperation; import com.fr.file.filetree.FileNodes; import com.fr.stable.fun.mark.Immutable; @@ -22,7 +22,7 @@ public interface LocalResourceProvider extends Immutable { * * @return 目录/模板的各种操作 */ - ResourceOperation createResourceOperation(); + TemplateFileResourceOperation createResourceOperation(); /** * eg: LocalFileNodes diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 50c61cda2..83120e4fb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -18,7 +18,6 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.TemplateTreePane; -import com.fr.design.fun.LocalResourceProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; @@ -34,13 +33,10 @@ import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; -import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; -import com.fr.file.filetree.FileNodes; -import com.fr.file.filetree.LocalFileNodes; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; @@ -49,8 +45,6 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.plugin.observer.PluginEventType; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -58,17 +52,11 @@ import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; -import com.fr.workspace.engine.base.FineObjectPool; -import com.fr.workspace.engine.resource.FineWorkResource; -import com.fr.workspace.resource.WorkResource; -import com.fr.workspace.server.lock.LocalTplOperator; -import com.fr.workspace.server.lock.TplOperator; import javax.swing.BorderFactory; import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingConstants; -import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 929519b18..dbf61e8b5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -3,7 +3,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.base.ScreenResolution; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; @@ -24,7 +23,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.ResourceManager; +import com.fr.design.file.TemplateFileResourceManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; @@ -814,7 +813,7 @@ public abstract class JTemplate> return false; } try { - this.getTarget().export(ResourceManager.getInstance().getOperation().saveTpl(editingFILE)); + this.getTarget().export(TemplateFileResourceManager.getOperation().saveTemplate(editingFILE)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 4b388be36..ac109606f 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -2,7 +2,7 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; -import com.fr.design.file.ResourceManager; +import com.fr.design.file.TemplateFileResourceManager; import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.file.NodeAuthProcessor; @@ -378,7 +378,7 @@ public class FileNodeFILE implements FILE { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - InputStream in = ResourceManager.getInstance().getOperation().readTpl( + InputStream in = TemplateFileResourceManager.getOperation().readTemplate( StableUtils.pathJoin( ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1) From 60cd56fc1343bc91e2cd1c40ff0ecae45ebba626 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Dec 2020 17:54:01 +0800 Subject: [PATCH 47/51] =?UTF-8?q?REPORT-44644=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/TemplateFileResourceOperation.java | 9 ++++++++- .../file/impl/DefaultTemplateFileResourceOperation.java | 5 +++++ .../src/main/java/com/fr/file/FileNodeFILE.java | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java index 5b1ba9c89..f3e813c92 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java @@ -46,13 +46,20 @@ public interface TemplateFileResourceOperation { boolean closeTemplate(String path); /** - * 重命名模板/路径 + * 重命名模板/目录 * @param from * @param to * @return */ boolean rename(String from, String to); + /** + * 模板/目录是否存在 + * @param path + * @return + */ + boolean exist(String path); + /** * 创建目录 * @param path diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java index e72d78fca..88a3f8564 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java @@ -40,6 +40,11 @@ public class DefaultTemplateFileResourceOperation implements TemplateFileResourc return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); } + @Override + public boolean exist(String path) { + return WorkContext.getWorkResource().exist(path); + } + @Override public boolean mkdir(String path) { return WorkContext.getWorkResource().createDirectory(path); diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index ac109606f..3e8178b2d 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -323,7 +323,7 @@ public class FileNodeFILE implements FILE { } try { - return WorkContext.getWorkResource().exist(node.getEnvPath()); + return TemplateFileResourceManager.getOperation().exist(node.getEnvPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; From 8ff603736dd99190aaa05cdbc436f285db502f10 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Dec 2020 19:20:42 +0800 Subject: [PATCH 48/51] =?UTF-8?q?REPORT-44644=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListCache.java | 9 +-------- .../fr/design/file/MutilTempalteTabPane.java | 2 +- ...ceOperation.java => TemplateResource.java} | 2 +- ...ager.java => TemplateResourceManager.java} | 19 ++++++++++++------- .../com/fr/design/file/TemplateTreePane.java | 6 +++--- ...ion.java => AbstractTemplateResource.java} | 5 +++-- .../file/impl/DefaultTemplateResource.java | 10 ++++++++++ .../fr/design/fun/LocalResourceProvider.java | 4 ++-- .../com/fr/design/mainframe/JTemplate.java | 4 ++-- .../main/java/com/fr/file/FileNodeFILE.java | 6 +++--- 10 files changed, 38 insertions(+), 29 deletions(-) rename designer-base/src/main/java/com/fr/design/file/{TemplateFileResourceOperation.java => TemplateResource.java} (96%) rename designer-base/src/main/java/com/fr/design/file/{TemplateFileResourceManager.java => TemplateResourceManager.java} (79%) rename designer-base/src/main/java/com/fr/design/file/impl/{DefaultTemplateFileResourceOperation.java => AbstractTemplateResource.java} (90%) create mode 100644 designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 154caa32b..ba4a88c4c 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -45,9 +45,6 @@ public class HistoryTemplateListCache implements CallbackEvent { private List> historyList; private JTemplate editingTemplate; - // 插件stop时的已经打开的模板xml byte缓存 插件重新run时 重新加载 - private final Map cacheMap = new LinkedHashMap<>(); - public static HistoryTemplateListCache getInstance() { return Holder.INSTANCE; } @@ -78,11 +75,7 @@ public class HistoryTemplateListCache implements CallbackEvent { selected.fireJTemplateClosed(); selected.stopEditing(); try { - int index = contains(selected); - historyList.remove(index); - if (stashFILEMap != null) { - stashFILEMap.remove(index); - } + historyList.remove(contains(selected)); selected.getEditingFILE().closeTemplate(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 3ad4c401a..269918448 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -705,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent { // 只有是环境内的文件,才执行释放锁 if (file != null && file.isEnvFile()) { // release lock - TemplateFileResourceManager.getOperation().closeTemplate(file.getPath()); + TemplateResourceManager.getResource().closeTemplate(file.getPath()); } } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/TemplateResource.java similarity index 96% rename from designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java rename to designer-base/src/main/java/com/fr/design/file/TemplateResource.java index f3e813c92..f394822d6 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateResource.java @@ -13,7 +13,7 @@ import java.io.OutputStream; * Created by hades on 2020/12/23 */ @Open -public interface TemplateFileResourceOperation { +public interface TemplateResource { /** * 读取模板 diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java similarity index 79% rename from designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java rename to designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java index 775584732..384b1a3e1 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java @@ -1,7 +1,7 @@ package com.fr.design.file; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.file.impl.DefaultTemplateFileResourceOperation; +import com.fr.design.file.impl.DefaultTemplateResource; import com.fr.design.fun.LocalResourceProvider; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.ui.util.UIUtil; @@ -21,17 +21,19 @@ import com.fr.workspace.engine.base.FineObjectPool; * @version 10.0 * Created by hades on 2020/12/23 */ -public class TemplateFileResourceManager { +public class TemplateResourceManager { - private static TemplateFileResourceOperation OPERATION = new DefaultTemplateFileResourceOperation(); + private static final TemplateResource DEFAULT_OPERATION = new DefaultTemplateResource(); - private TemplateFileResourceManager() { + private static TemplateResource OPERATION = DEFAULT_OPERATION; + + static { PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { @Override public void on(PluginEvent event) { - registerOperation(new DefaultTemplateFileResourceOperation()); + registerOperation(new DefaultTemplateResource()); FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); } @@ -50,11 +52,14 @@ public class TemplateFileResourceManager { }, filter); } - private static void registerOperation(TemplateFileResourceOperation operation) { + private static void registerOperation(TemplateResource operation) { OPERATION = operation; } - public static TemplateFileResourceOperation getOperation() { + public static TemplateResource getResource() { + if (OPERATION == null) { + return DEFAULT_OPERATION; + } return OPERATION; } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index f54fd8eeb..0fc3ca728 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -193,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public boolean mkdir(String path) { - return TemplateFileResourceManager.getOperation().mkdir(path); + return TemplateResourceManager.getResource().mkdir(path); } /** @@ -336,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (node instanceof FileNode) { FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); if (nodeFILE.exists()) { - if (TemplateFileResourceManager.getOperation().delete(nodeFILE)) { + if (TemplateResourceManager.getResource().delete(nodeFILE)) { HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); } else { success = false; @@ -438,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { try { // 接收的是WEB-INF下的路径 - return TemplateFileResourceManager.getOperation().rename(from, to); + return TemplateResourceManager.getResource().rename(from, to); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java similarity index 90% rename from designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java rename to designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java index 88a3f8564..acf785dd4 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java @@ -1,6 +1,7 @@ package com.fr.design.file.impl; -import com.fr.design.file.TemplateFileResourceOperation; + +import com.fr.design.file.TemplateResource; import com.fr.file.FILE; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; @@ -13,7 +14,7 @@ import java.io.OutputStream; * @version 10.0 * Created by hades on 2020/12/23 */ -public class DefaultTemplateFileResourceOperation implements TemplateFileResourceOperation { +public class AbstractTemplateResource implements TemplateResource { @Override public InputStream readTemplate(String path) throws Exception { diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java new file mode 100644 index 000000000..125f1a9f3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java @@ -0,0 +1,10 @@ +package com.fr.design.file.impl; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/23 + */ +public class DefaultTemplateResource extends AbstractTemplateResource { + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java index 51b36d916..56a98a235 100644 --- a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun; -import com.fr.design.file.TemplateFileResourceOperation; +import com.fr.design.file.TemplateResource; import com.fr.file.filetree.FileNodes; import com.fr.stable.fun.mark.Immutable; @@ -22,7 +22,7 @@ public interface LocalResourceProvider extends Immutable { * * @return 目录/模板的各种操作 */ - TemplateFileResourceOperation createResourceOperation(); + TemplateResource createResourceOperation(); /** * eg: LocalFileNodes diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index dbf61e8b5..5cfd7a13d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -23,7 +23,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateFileResourceManager; +import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; @@ -813,7 +813,7 @@ public abstract class JTemplate> return false; } try { - this.getTarget().export(TemplateFileResourceManager.getOperation().saveTemplate(editingFILE)); + this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 3e8178b2d..d096faf8a 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -2,7 +2,7 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; -import com.fr.design.file.TemplateFileResourceManager; +import com.fr.design.file.TemplateResourceManager; import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.file.NodeAuthProcessor; @@ -323,7 +323,7 @@ public class FileNodeFILE implements FILE { } try { - return TemplateFileResourceManager.getOperation().exist(node.getEnvPath()); + return TemplateResourceManager.getResource().exist(node.getEnvPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; @@ -378,7 +378,7 @@ public class FileNodeFILE implements FILE { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - InputStream in = TemplateFileResourceManager.getOperation().readTemplate( + InputStream in = TemplateResourceManager.getResource().readTemplate( StableUtils.pathJoin( ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1) From 88c455a958c885ec1f6125139a9a050166de3672 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Dec 2020 19:22:47 +0800 Subject: [PATCH 49/51] =?UTF-8?q?REPORT-44644=20fix=E6=97=A0=E7=94=A8impor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/file/HistoryTemplateListCache.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index ba4a88c4c..7b13c94a0 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -2,7 +2,6 @@ package com.fr.design.file; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.io.BaseBook; -import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.data.DesignTableDataManager; @@ -23,8 +22,6 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; -import java.util.LinkedHashMap; -import javax.swing.SwingUtilities; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Collections; @@ -423,7 +420,6 @@ public class HistoryTemplateListCache implements CallbackEvent { /** * 重新载入当前模板,刷新数据/对象 */ - @Deprecated public void reloadCurrentTemplate() { JTemplate jt = getCurrentEditingTemplate(); boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); @@ -444,7 +440,4 @@ public class HistoryTemplateListCache implements CallbackEvent { }); } - public void stashByName() { - - } } From d9a770f847fa6d88d350f870080fec6904f2e8d5 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 24 Dec 2020 10:23:14 +0800 Subject: [PATCH 50/51] =?UTF-8?q?REPORT-44644=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=8E=A5=E5=8F=A3=E5=BC=80=E6=94=BE=20fix=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=B1=82=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/impl/AbstractTemplateResource.java | 37 +--------------- .../file/impl/DefaultTemplateResource.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java index acf785dd4..cb76792a1 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java @@ -14,41 +14,6 @@ import java.io.OutputStream; * @version 10.0 * Created by hades on 2020/12/23 */ -public class AbstractTemplateResource implements TemplateResource { - - @Override - public InputStream readTemplate(String path) throws Exception { - return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); - } - - @Override - public OutputStream saveTemplate(FILE file) throws Exception { - return file.asOutputStream(); - } - - @Override - public boolean closeTemplate(String path) { - return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); - } - - @Override - public boolean delete(FILE file) { - return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath()); - } - - @Override - public boolean rename(String from, String to) { - return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); - } - - @Override - public boolean exist(String path) { - return WorkContext.getWorkResource().exist(path); - } - - @Override - public boolean mkdir(String path) { - return WorkContext.getWorkResource().createDirectory(path); - } +public abstract class AbstractTemplateResource implements TemplateResource { } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java index 125f1a9f3..8c54cc8cc 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java @@ -1,5 +1,12 @@ package com.fr.design.file.impl; +import com.fr.file.FILE; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.lock.TplOperator; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; + /** * @author hades * @version 10.0 @@ -7,4 +14,39 @@ package com.fr.design.file.impl; */ public class DefaultTemplateResource extends AbstractTemplateResource { + @Override + public InputStream readTemplate(String path) throws Exception { + return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); + } + + @Override + public OutputStream saveTemplate(FILE file) throws Exception { + return file.asOutputStream(); + } + + @Override + public boolean closeTemplate(String path) { + return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); + } + + @Override + public boolean delete(FILE file) { + return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath()); + } + + @Override + public boolean rename(String from, String to) { + return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); + } + + @Override + public boolean exist(String path) { + return WorkContext.getWorkResource().exist(path); + } + + @Override + public boolean mkdir(String path) { + return WorkContext.getWorkResource().createDirectory(path); + } + } From acab6692f6f1ba426156af2f23f74fc45dd6f72b Mon Sep 17 00:00:00 2001 From: Lanlan Date: Thu, 24 Dec 2020 11:02:27 +0800 Subject: [PATCH 51/51] =?UTF-8?q?REPORT-45460=20=E5=B8=86=E8=BD=AF?= =?UTF-8?q?=E5=B8=82=E5=9C=BA=E5=9B=BD=E9=99=85=E5=8C=96=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/extra/PluginOperateUtils.java | 7 +++++++ .../design/extra/exe/GetPluginFromStoreExecutor.java | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 801b4e369..d86873525 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -128,6 +128,10 @@ public class PluginOperateUtils { } public static void dealParams(StringBuilder url, String category, String seller, String fee, String scope) { + dealParams(url, category, seller, fee, StringUtils.EMPTY); + } + + public static void dealParams(StringBuilder url, String category, String seller, String fee, String scope, String language) { if (StringUtils.isNotBlank(category)) { url.append("cid=").append(category.split("-")[1]); } else { @@ -169,6 +173,9 @@ public class PluginOperateUtils { url.append("&scope=").append(StringUtils.EMPTY); } } + if (StringUtils.isNotBlank(language)) { + url.append("&language=").append(language.split("-")[1]); + } } public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) { diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java index 3bf7b2cb3..b3d66d510 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -21,19 +21,26 @@ public class GetPluginFromStoreExecutor implements Executor { private String seller; private String fee; private String scope; + private String language; public GetPluginFromStoreExecutor(JSONObject info) { this.category = info.optString("categories"); this.fee = info.optString("fee"); this.seller = info.optString("seller"); this.scope = info.optString("scope"); + this.language = info.optString("language"); } public GetPluginFromStoreExecutor(String category, String seller, String fee, String scope) { + this(category, seller, fee, scope, StringUtils.EMPTY); + } + + public GetPluginFromStoreExecutor(String category, String seller, String fee, String scope, String language) { this.category = category; this.seller = seller; this.fee = fee; this.scope = scope; + this.language = language; } @Override @@ -53,7 +60,7 @@ public class GetPluginFromStoreExecutor implements Executor { @Override public void run(Process process) { String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.plist"); - boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope); + boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope) & StringUtils.isEmpty(language); if (getRecommend) { result = PluginOperateUtils.getRecommendPlugins(); return; @@ -62,7 +69,7 @@ public class GetPluginFromStoreExecutor implements Executor { if (StringUtils.isNotBlank(plistUrl)) { StringBuilder url = new StringBuilder(); url.append(plistUrl).append("?"); - PluginOperateUtils.dealParams(url, category, seller, fee, scope); + PluginOperateUtils.dealParams(url, category, seller, fee, scope, language); try { HttpClient httpClient = new HttpClient(url.toString()); httpClient.asGet();