From cc38bcedc53298e45a82278d581327e4d8f89a18 Mon Sep 17 00:00:00 2001 From: xiqiu Date: Mon, 23 Aug 2021 15:49:20 +0800 Subject: [PATCH 1/9] =?UTF-8?q?REPORT-57643=20=20=E8=B0=83=E6=95=B4combobo?= =?UTF-8?q?x=E7=9A=84=E5=A4=A7=E5=B0=8F(feature=E6=B2=A1=E6=9C=89=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=88=B0realease=EF=BC=8C=E6=89=8B=E5=8A=A8=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E4=B8=80=E6=B3=A2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/JDBCDefPane.java | 26 ++++++++++++-- .../fr/design/gui/icombobox/UIComboBoxUI.java | 34 +++++++++++++++++-- .../design/gui/icontainer/UIScrollPane.java | 13 +++++-- 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 334958124..aaa02f9af 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -7,6 +7,7 @@ import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombobox.UIComboBoxUI; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; @@ -32,6 +33,8 @@ import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.plaf.ComboBoxUI; +import javax.swing.plaf.basic.ComboPopup; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -275,8 +278,9 @@ public class JDBCDefPane extends JPanel { } dbtypeComboBox.addActionListener(dbtypeActionListener); dbtypeComboBox.setMaximumRowCount(10); - driverLoaderBox = new UIComboBox(); + driverLoaderBox = new SpecialUIComboBox(); refreshDriverLoader(); + driverLoaderBox.setPreferredSize(new Dimension(200, driverLoaderBox.getPreferredSize().height)); driverLoaderBox.setEditable(false); driverManageBox = new UIComboBox(); refreshDriverManage(true); @@ -350,7 +354,7 @@ public class JDBCDefPane extends JPanel { odbcTipsPane.add(driverManageLabel); odbcTipsPane.add(odbcTipsLink); JPanel driverComboBoxAndTips = new JPanel(new BorderLayout()); - JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 5, 0); normalFlowInnerContainer_s_pane.add(driverManageBox); normalFlowInnerContainer_s_pane.add(driverComboBox); normalFlowInnerContainer_s_pane.add(driverLoaderBox); @@ -717,4 +721,22 @@ public class JDBCDefPane extends JPanel { private String driver; private String url; } + + private static class SpecialUIComboBox extends UIComboBox { + + @Override + public ComboBoxUI getUIComboBoxUI() { + return new SpecialUIComboBoxUI(); + } + } + + private static class SpecialUIComboBoxUI extends UIComboBoxUI { + + @Override + public ComboPopup createPopup() { + return createHorizontalNeverUIComboPopUp(); + } + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java index f15bbc52a..d4de4e850 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java @@ -10,12 +10,26 @@ import com.fr.stable.Constants; import com.fr.stable.StringUtils; import sun.swing.DefaultLookup; -import javax.swing.*; +import javax.swing.AbstractButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ScrollPaneConstants; +import javax.swing.UIManager; import javax.swing.plaf.ButtonUI; import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.ComboPopup; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -159,6 +173,10 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { return new UIComboPopup(comboBox); } + protected ComboPopup createHorizontalNeverUIComboPopUp() { + return new HorizontalNeverUIComboPopup(comboBox); + } + private void setRollover(boolean isRollover) { if (this.isRollover != isRollover) { this.isRollover = isRollover; @@ -270,4 +288,16 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { } } + + private class HorizontalNeverUIComboPopup extends UIComboPopup { + + public HorizontalNeverUIComboPopup(JComboBox comboBox) { + super(comboBox); + } + + @Override + protected JScrollPane createScroller() { + return new UIScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java index a14c10f3c..55ba64b0e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java @@ -3,8 +3,11 @@ package com.fr.design.gui.icontainer; import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; -import javax.swing.*; -import java.awt.*; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import java.awt.Color; +import java.awt.Component; /** * @author zhou @@ -16,7 +19,11 @@ public class UIScrollPane extends JScrollPane { private static final int INCREAMENT = 30; public UIScrollPane(Component c) { - super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + this(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } + + public UIScrollPane(Component c, int vertical, int horizontal) { + super(c, vertical, horizontal); this.setHorizontalScrollBar(createHorizontalScrollBar()); this.getVerticalScrollBar().setUnitIncrement(INCREAMENT); this.getVerticalScrollBar().setBlockIncrement(INCREAMENT); From 2607d356b9993dae5e32aab09b9876cfb498dff3 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 24 Aug 2021 10:42:34 +0800 Subject: [PATCH 2/9] =?UTF-8?q?REPORT-56047=20=E8=AE=BE=E8=AE=A1=E5=99=A81?= =?UTF-8?q?1.0=E9=80=82=E9=85=8D=E5=86=85=E5=AE=B9=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B010.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 6 ++-- .../env/LocalDesignerWorkspaceInfo.java | 29 ++++++++++++++++++- .../main/java/com/fr/env/RemoteEnvPane.java | 4 +-- ...er.java => WorkspaceExceptionHandler.java} | 25 ++++++++++------ .../com/fr/env/jarVersion.properties | 1 + .../module/DesignerWorkspaceProvider.java | 1 - 6 files changed, 50 insertions(+), 16 deletions(-) rename designer-base/src/main/java/com/fr/env/handler/{RemoteDesignExceptionHandler.java => WorkspaceExceptionHandler.java} (72%) create mode 100644 designer-base/src/main/resources/com/fr/env/jarVersion.properties 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 98c079ee2..6881c8445 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -20,7 +20,7 @@ import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; -import com.fr.env.handler.RemoteDesignExceptionHandler; +import com.fr.env.handler.WorkspaceExceptionHandler; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; @@ -139,7 +139,7 @@ public class EnvChangeEntrance { pluginErrorRemind(); } catch (Exception exception) { // 失败的处理 - RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); + WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } TemplateTreePane.getInstance().refreshDockingView(); @@ -436,7 +436,7 @@ public class EnvChangeEntrance { } }); if (e != null) { - RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo); + WorkspaceExceptionHandler.getInstance().handleInStart(e, workspaceInfo); } envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index ef1f420d6..6bb8ec37a 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -1,18 +1,37 @@ package com.fr.design.env; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; +import com.fr.locale.InterProviderFactory; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.exception.MainVersionNotMatchException; import java.io.File; +import java.util.Properties; /** * Created by juhaoyu on 2018/6/15. */ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - + + private static final String REPORT_ENGINE_KEY = "report-engine-key"; + private static final String REPORT_ENGINE_JAR; + private static final String PROP_PATH = "/com/fr/env/jarVersion.properties"; + + static { + Properties properties = new Properties(); + try { + properties.load(LocalDesignerWorkspaceInfo.class.getResourceAsStream(PROP_PATH)); + } catch (Exception ignored) { + } + REPORT_ENGINE_JAR = properties.getProperty(REPORT_ENGINE_KEY, "default.jar"); + } + private String name; private String path; @@ -86,6 +105,14 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return false; } + File engineLib = new File(StableUtils.pathJoin(this.path, ProjectConstants.LIB_NAME, REPORT_ENGINE_JAR)); + // 非安装版本允许自由切换 + boolean notExistLib = !ComparatorUtils.equals(GeneralUtils.readFullBuildNO(), InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build")) + && !engineLib.exists(); + if (notExistLib) { + throw new MainVersionNotMatchException(); + } + return true; } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 17dc72dba..56f90e804 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -21,7 +21,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.scrollruler.ModLineBorder; -import com.fr.env.handler.RemoteDesignExceptionHandler; +import com.fr.env.handler.WorkspaceExceptionHandler; import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; import com.fr.workspace.WorkContext; @@ -596,7 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane { } } catch (Exception e) { dialog.dispose(); - RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv); + WorkspaceExceptionHandler.getInstance().handleInTest(e, remoteEnv); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); diff --git a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java similarity index 72% rename from designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java rename to designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java index 7e6154eee..367cd6bbb 100644 --- a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java @@ -1,5 +1,6 @@ package com.fr.env.handler; +import com.fr.base.exception.ExceptionDescriptor; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; @@ -11,6 +12,7 @@ import com.fr.env.handler.impl.CommonHandler; import com.fr.env.handler.impl.ExecutionHandler; import com.fr.env.handler.impl.UnexpectedHandler; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; import javax.swing.UIManager; @@ -23,11 +25,11 @@ import static javax.swing.JOptionPane.ERROR_MESSAGE; * @version 10.0 * Created by hades on 2021/8/5 */ -public class RemoteDesignExceptionHandler { +public class WorkspaceExceptionHandler { - private static final RemoteDesignExceptionHandler INSTANCE = new RemoteDesignExceptionHandler(); + private static final WorkspaceExceptionHandler INSTANCE = new WorkspaceExceptionHandler(); - public static RemoteDesignExceptionHandler getInstance() { + public static WorkspaceExceptionHandler getInstance() { return INSTANCE; } @@ -35,7 +37,7 @@ public class RemoteDesignExceptionHandler { private final List> switchList = new ArrayList<>(); - private RemoteDesignExceptionHandler() { + private WorkspaceExceptionHandler() { // 要保证顺序 testList.add(new CancelHandler()); testList.add(new ExecutionHandler()); @@ -65,11 +67,15 @@ public class RemoteDesignExceptionHandler { public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) { if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), - Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); + if (e instanceof ExceptionDescriptor) { + new CommonHandler(true).handle(new RefWrapper(e, StringUtils.EMPTY)); + } else { + FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), + Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); + } return; } handle(e, switchList, workspaceInfo); @@ -78,6 +84,7 @@ public class RemoteDesignExceptionHandler { public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + new CommonHandler(false).handle(new RefWrapper(e, StringUtils.EMPTY)); return; } handle(e, testList, workspaceInfo); diff --git a/designer-base/src/main/resources/com/fr/env/jarVersion.properties b/designer-base/src/main/resources/com/fr/env/jarVersion.properties new file mode 100644 index 000000000..8619fca7c --- /dev/null +++ b/designer-base/src/main/resources/com/fr/env/jarVersion.properties @@ -0,0 +1 @@ +report-engine-key=fine-report-engine-10.0.jar \ No newline at end of file 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 d5b6cdb63..0035e1e60 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 @@ -9,7 +9,6 @@ import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.versioncheck.VersionCheckUtils; -import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; From 1973d1796492b151db7209193114aa44be892e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 24 Aug 2021 11:47:47 +0800 Subject: [PATCH 3/9] =?UTF-8?q?REPORT-57202=20FR11=E4=B8=80=E8=BD=AE?= =?UTF-8?q?=E5=9B=9E=E5=BD=92-=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=BA=B8=E5=BC=A0=E5=A4=A7=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/report/PageSetupPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java b/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java index 668700a95..3074bb009 100644 --- a/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java @@ -779,7 +779,7 @@ public class PageSetupPane extends BasicPane { //使用科学计数法显示长度的时候,限制纵向显示长度为9位 if (h_str.contains(E)) { String str1 = h_str.substring(h_str.indexOf(E)); - String str2 = h_str.substring(0, 9 - str1.length()); + String str2 = h_str.substring(0, Math.min(h_str.length(), 9) - str1.length()); h_str = str2 + str1; } else if (h_str.indexOf(CoreConstants.DOT) > 0) { h_str = h_str.substring(0, h_str.indexOf(CoreConstants.DOT) + 2); From 42c40af36d92b538948fbd6059f38b5b1e042ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 24 Aug 2021 15:13:44 +0800 Subject: [PATCH 4/9] =?UTF-8?q?CHART-20312=20=E5=9B=BE=E8=A1=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=8C=89=E9=92=AE=E5=A4=B1=E7=84=A6=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/chart/gui/ChartTypePane.java | 25 +++++++++++++++---- .../chart/gui/type/ChartImagePane.java | 1 + 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index ac0bfcb57..e93f0023b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -25,17 +25,19 @@ import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** * 图表 属性表, 类型选择 界面. @@ -99,6 +101,19 @@ public class ChartTypePane extends AbstractChartAttrPane { buttonPane.setEditingChartPane(chartTypeComBox); + buttonPane.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + buttonPane.requestFocus(); + } + }); + + chartTypeComBox.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + content.requestFocus(); + } + }); return content; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java index 584d7fd1d..e8ef8714d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java @@ -72,6 +72,7 @@ public class ChartImagePane extends ChartSelectDemoPane { }else{ this.isDoubleClicked = false; } + this.requestFocus(); super.mouseClicked(e); } From e95103a9418292c7161f0b402bfbc84ca0479990 Mon Sep 17 00:00:00 2001 From: xiqiu Date: Tue, 24 Aug 2021 16:31:13 +0800 Subject: [PATCH 5/9] =?UTF-8?q?REPORT-57979=20=20=E5=89=8D=E9=9D=A2=3D?= =?UTF-8?q?=E8=B5=8B=E5=80=BC=E4=BA=86=EF=BC=8Cset=E6=B2=A1=E6=84=8F?= =?UTF-8?q?=E4=B9=89=EF=BC=8C=E5=88=A0=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/data/datapane/connect/JDBCDefPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index aaa02f9af..5a8c13889 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -511,7 +511,6 @@ public class JDBCDefPane extends JPanel { this.dbtypeComboBox.setSelectedItem(OTHER_DB); } } - this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); // jdbcDatabase.getDriverSource() 只会是空或者是有值,但是为了保险起见,还是应该做个处理 String driverSource = jdbcDatabase.getDriverSource(); if (driverSource == null) { From f5d21272b7599292b0fa770ee907c04ec0ce5277 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 20 Aug 2021 10:04:16 +0800 Subject: [PATCH 6/9] =?UTF-8?q?REPORT-55048=20https=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=97=B6=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=8A=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=8E=A8=E9=80=81=E8=BF=87=E6=9D=A5=E7=9A=84eventhrea?= =?UTF-8?q?d=E7=BA=BF=E7=A8=8B=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 124 +++++++++++++++--- 1 file changed, 103 insertions(+), 21 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 157ce6f98..c1e994bdc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -5,29 +5,39 @@ import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.loghandler.DesignerLogger; import com.fr.design.ui.util.UIUtil; -import com.fr.event.Event; import com.fr.event.EventDispatcher; -import com.fr.event.Listener; +import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.report.RemoteDesignConstants; import com.fr.serialization.SerializerHelper; import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; import com.fr.third.apache.log4j.spi.LoggingEvent; +import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier; +import com.fr.third.org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import com.fr.third.org.apache.http.ssl.SSLContexts; +import com.fr.web.WebSocketConfig; +import com.fr.web.socketio.WebSocketProtocol; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; -import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.server.socket.SocketInfoOperator; import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; +import java.io.File; +import java.io.FileInputStream; +import java.security.KeyStore; import java.util.Arrays; +import javax.net.ssl.SSLContext; import javax.swing.*; import java.io.IOException; import java.net.URI; @@ -37,26 +47,14 @@ import java.util.TimerTask; public class DesignerSocketIO { - - static { - EventDispatcher.listen(WorkspaceEvent.LostConnect, new Listener() { - @Override - public void on(Event event, Workspace param) { - // 远程设计websocket不支持wss 所以断开无法提醒 - // 使用远程设计的心跳断开来提醒断开 - if (DesignerEnvManager.getEnvManager().isHttps()) { - showConnectionLostDialog(); - } - } - }); - } - enum Status { Connected, Disconnected, Disconnecting } + private static final String HTTPS = "https"; + private static final String HTTP = "http"; private static Socket socket = null; private static Status status = Status.Disconnected; private static Timer disConnectHintTimer = null; @@ -65,6 +63,8 @@ public class DesignerSocketIO { private static String[] uri; //维护一个关于uri列表的计数器 private static int count; + // 当前webSocket选择的协议 + private static String currentProtocol; public static void close() { @@ -95,7 +95,7 @@ public class DesignerSocketIO { //根据uri和计数器建立连接,并注册监听 try { if (count < uri.length) { - socket = IO.socket(new URI(uri[count])); + socket = IO.socket(new URI(uri[count]), createOptions()); socket.on(WorkspaceConstants.WS_LOGRECORD, printLog); socket.on(WorkspaceConstants.CONFIG_MODIFY, modifyConfig); socket.on(Socket.EVENT_CONNECT_ERROR, failRetry); @@ -112,15 +112,54 @@ public class DesignerSocketIO { } } + private static IO.Options createOptions() { + IO.Options options = new IO.Options(); + try { + if (ComparatorUtils.equals(currentProtocol, HTTPS)) { + options.sslContext = getSSLContext(); + options.hostnameVerifier = NoopHostnameVerifier.INSTANCE; + options.secure = true; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return options; + } + + private static SSLContext getSSLContext() throws Exception { + String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); + DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); + WorkspaceConnectionInfo connection = info.getConnection(); + String certPath = connection.getCertPath(); + String certSecretKey = connection.getCertSecretKey(); + if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { + return SSLContexts.createDefault(); + } + KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); + try (FileInputStream keystore = new FileInputStream(new File(certPath))) { + trustStore.load(keystore, certSecretKey.toCharArray()); + } + return SSLContexts.custom() + .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()) + .build(); + } + private static String[] getSocketUri() throws IOException { Workspace current = WorkContext.getCurrent(); URL url = new URL(current.getPath()); Integer[] ports = current.get(SocketInfoOperator.class).getPort(); WorkspaceConnection connection = current.getConnection(); + // 服务器配置https webSocket可能是wss也可能是ws webSocket的协议可以单独配置 + WebSocketProtocol webSocketProtocol = WebSocketConfig.getInstance().getProtocol(); + currentProtocol = webSocketProtocol == WebSocketProtocol.PLAIN ? HTTP : HTTPS; + if (WebSocketConfig.getInstance().isUsingProxy()) { + // 如果配置了代理服务器跟随服务器协议 + currentProtocol = url.getProtocol(); + } String[] result = new String[ports.length]; for (int i = 0; i < ports.length; i++) { result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s", - url.getProtocol(), + currentProtocol, url.getHost(), ports[i], WorkspaceConstants.WS_NAMESPACE, @@ -129,6 +168,7 @@ public class DesignerSocketIO { RemoteDesignConstants.USER_LOCK_ID, connection.getId()); } + FineLoggerFactory.getLogger().error("Available ports: {}, current Protocol: {}", Arrays.toString(ports), currentProtocol); return result; } @@ -136,7 +176,7 @@ public class DesignerSocketIO { private static final Emitter.Listener failRetry = new Emitter.Listener() { @Override public void call(Object... args) { - FineLoggerFactory.getLogger().warn("failed args: {}", Arrays.toString(args)); + printLog(args, PrintEventLogImpl.WARN, "failed args: {}"); status = Status.Disconnecting; socket.close(); count++; @@ -183,7 +223,7 @@ public class DesignerSocketIO { * todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上,切换成心跳断开之后进行提醒, * socket 只用推日志和通知配置变更 */ - FineLoggerFactory.getLogger().error("disConnected args: {}", Arrays.toString(objects)); + printLog(objects, PrintEventLogImpl.ERROR, "disConnected args: {}"); if (status != Status.Disconnecting) { showConnectionLostDialog(); } @@ -226,4 +266,46 @@ public class DesignerSocketIO { } }; + private static void printLog(Object[] objects, PrintEventLog printEventLog, String prefix) { + for (Object object : objects) { + if (object instanceof Throwable) { + Throwable throwable = (Throwable) object; + printEventLog.printThrowable(throwable.getMessage(), throwable); + } else { + printEventLog.print(prefix, object); + } + } + } + + interface PrintEventLog { + void printThrowable(String s, Throwable throwable); + void print(String s, Object ...object); + } + + enum PrintEventLogImpl implements PrintEventLog { + ERROR { + @Override + public void printThrowable(String s, Throwable throwable) { + FineLoggerFactory.getLogger().error(s, throwable); + } + + @Override + public void print(String s, Object... object) { + FineLoggerFactory.getLogger().error(s, object); + } + }, + + WARN { + @Override + public void printThrowable(String s, Throwable throwable) { + FineLoggerFactory.getLogger().warn(s, throwable); + } + + @Override + public void print(String s, Object... object) { + FineLoggerFactory.getLogger().warn(s, object); + } + }; + } + } From 23bab19229ad582e5739fbd05eaf445d8dd3a480 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 24 Aug 2021 18:43:38 +0800 Subject: [PATCH 7/9] =?UTF-8?q?REPORT-55048=20https=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=97=B6=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=8A=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=8E=A8=E9=80=81=E8=BF=87=E6=9D=A5=E7=9A=84eventhrea?= =?UTF-8?q?d=E7=BA=BF=E7=A8=8B=E6=97=A5=E5=BF=97=20fix=20npe=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 ++ .../env/DesignerWorkspaceInfoContext.java | 20 +++++++++++++++++++ .../mainframe/socketio/DesignerSocketIO.java | 15 +++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.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 6881c8445..cd9c835f3 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -8,6 +8,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteWorkspace; @@ -105,6 +106,7 @@ public class EnvChangeEntrance { private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); try { diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java new file mode 100644 index 000000000..ba8a5b09f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java @@ -0,0 +1,20 @@ +package com.fr.design.env; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/24 + */ +public class DesignerWorkspaceInfoContext { + + private static DesignerWorkspaceInfo workspaceInfo; + + public static DesignerWorkspaceInfo getWorkspaceInfo() { + return workspaceInfo; + } + + public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) { + DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index c1e994bdc..5f3e57b26 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -6,6 +6,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.loghandler.DesignerLogger; @@ -127,9 +128,7 @@ public class DesignerSocketIO { } private static SSLContext getSSLContext() throws Exception { - String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); - WorkspaceConnectionInfo connection = info.getConnection(); + WorkspaceConnectionInfo connection = getConnectionInfo(); String certPath = connection.getCertPath(); String certSecretKey = connection.getCertSecretKey(); if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { @@ -144,6 +143,16 @@ public class DesignerSocketIO { .build(); } + private static WorkspaceConnectionInfo getConnectionInfo() { + if (DesignerWorkspaceInfoContext.getWorkspaceInfo() == null) { + String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); + DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); + return info.getConnection(); + } else { + return DesignerWorkspaceInfoContext.getWorkspaceInfo().getConnection(); + } + } + private static String[] getSocketUri() throws IOException { Workspace current = WorkContext.getCurrent(); URL url = new URL(current.getPath()); From 0c7550a04b73379be262b05708c35f392cfe16bd Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 24 Aug 2021 18:45:19 +0800 Subject: [PATCH 8/9] =?UTF-8?q?REPORT-57490=20websocket=E6=96=AD=E5=BC=80?= =?UTF-8?q?=E6=97=B6=E5=BC=B9=E7=AA=97=E4=BD=8D=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/socketio/DesignerSocketIO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 5f3e57b26..648d7cdde 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -248,7 +248,7 @@ public class DesignerSocketIO { private static void showConnectionLostDialog() { try { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { FineJOptionPane.showMessageDialog( From 9992d53bf2b5f226ed5a6f6087affd04edb9c25f Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 24 Aug 2021 19:48:29 +0800 Subject: [PATCH 9/9] =?UTF-8?q?REPORT-55048=20fix=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 648d7cdde..782c7f35d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -161,10 +161,6 @@ public class DesignerSocketIO { // 服务器配置https webSocket可能是wss也可能是ws webSocket的协议可以单独配置 WebSocketProtocol webSocketProtocol = WebSocketConfig.getInstance().getProtocol(); currentProtocol = webSocketProtocol == WebSocketProtocol.PLAIN ? HTTP : HTTPS; - if (WebSocketConfig.getInstance().isUsingProxy()) { - // 如果配置了代理服务器跟随服务器协议 - currentProtocol = url.getProtocol(); - } String[] result = new String[ports.length]; for (int i = 0; i < ports.length; i++) { result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s", @@ -279,7 +275,7 @@ public class DesignerSocketIO { for (Object object : objects) { if (object instanceof Throwable) { Throwable throwable = (Throwable) object; - printEventLog.printThrowable(throwable.getMessage(), throwable); + printEventLog.printThrowable(throwable); } else { printEventLog.print(prefix, object); } @@ -287,15 +283,15 @@ public class DesignerSocketIO { } interface PrintEventLog { - void printThrowable(String s, Throwable throwable); + void printThrowable(Throwable throwable); void print(String s, Object ...object); } enum PrintEventLogImpl implements PrintEventLog { ERROR { @Override - public void printThrowable(String s, Throwable throwable) { - FineLoggerFactory.getLogger().error(s, throwable); + public void printThrowable(Throwable throwable) { + FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable); } @Override @@ -306,8 +302,8 @@ public class DesignerSocketIO { WARN { @Override - public void printThrowable(String s, Throwable throwable) { - FineLoggerFactory.getLogger().warn(s, throwable); + public void printThrowable(Throwable throwable) { + FineLoggerFactory.getLogger().warn(throwable.getMessage(), throwable); } @Override