From fb0c6563df4a55407c60c7b1d6e8f2f020cac64e Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 20 Aug 2021 10:04:16 +0800 Subject: [PATCH 1/7] =?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 9c52e84c6c7ba3e3777a6d302d609a5b088f170e Mon Sep 17 00:00:00 2001 From: xiqiu Date: Fri, 20 Aug 2021 10:45:57 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-57643=20=20=20=E8=B0=83=E6=95=B4comb?= =?UTF-8?q?obox=E7=9A=84=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/JDBCDefPane.java | 24 ++++++++++++- .../fr/design/gui/icombobox/UIComboBoxUI.java | 34 +++++++++++++++++-- .../design/gui/icontainer/UIScrollPane.java | 13 +++++-- 3 files changed, 65 insertions(+), 6 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..022323f19 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); @@ -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 d76702ffbede459508c2a24519bb4dbf299db209 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 20 Aug 2021 13:52:52 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-56602=20=E9=A1=B5=E9=9D=A2=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E7=BA=B8=E5=BC=A0=E5=A4=A7=E5=B0=8F=E4=B8=8E?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E5=88=86=E9=A1=B5=E7=B2=BE=E5=BA=A6=E4=B8=8D?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grid/AbstractGridHeaderMouseHandler.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java index 349503bd7..810a71e85 100644 --- a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java @@ -152,13 +152,11 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { private ScrollAction PRESS_ACTION = new ScrollAction() { @Override public boolean run(MouseEvent evt, int index, double tmpSize1, double tmpSize2, int tmpIncreaseSize, int oldEndValueSize, ElementCase report, DynamicUnitList sizeList) { -// int resolution = ScreenResolution.getScreenResolution(); - if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) { dragType = GridUtils.DRAG_CELL_SIZE; isDragPermited = true; dragIndex = index; - showToolTip(evt, createToolTipString(sizeList.get(dragIndex).toPixD(resolution), sizeList.getRangeValue(0, dragIndex + 1).toPixD(resolution))); + showToolTip(evt, createToolTipString(sizeList.get(dragIndex), sizeList.getRangeValue(0, dragIndex + 1))); return true; } if (between(evt, tmpSize1, tmpSize2)) { @@ -302,21 +300,18 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { protected abstract void resetGridSelectionBySelect(int index, ElementCasePane ePane); - private String createToolTipString(double doubleValue, double totalDoubleValue) { + private String createToolTipString(UNIT unitValue, UNIT totalUnitValue) { int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); -// int resolution = ScreenResolution.getScreenResolution(); - FU ulen = FU.valueOfPix((int) doubleValue, resolution); - FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution); ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); String unit = lengthUNIT.unitText(); - double len = lengthUNIT.unit2Value4Scale(ulen); - double tlen = lengthUNIT.unit2Value4Scale(tulen); + double len = lengthUNIT.unit2Value4Scale(unitValue); + double tlen = lengthUNIT.unit2Value4Scale(totalUnitValue); StringBuilder sb = new StringBuilder(); sb.append(String.format("%.2f", new Double(len))) .append('/').append(String.format("%.2f", new Double(tlen))) .append(unit).append('(') - .append((int)(doubleValue)).append('/') - .append((int)(totalDoubleValue)) + .append((int)(unitValue.toPixD(resolution))).append('/') + .append((int)(totalUnitValue.toPixD(resolution))) .append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px")) .append(')'); return sb.toString(); @@ -416,8 +411,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { iterateScrollBar(ePane, evt, DRAG_ACTION); DynamicUnitList sizeList = getSizeList(report); -// int resolution = ScreenResolution.getScreenResolution(); - this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex).toPixD(resolution), sizeList.getRangeValue(0, dragIndex + 1).toPixD(resolution))); + this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex), sizeList.getRangeValue(0, dragIndex + 1))); } ePane.repaint(); From 8c01a5ed490f704e6e2765010d299aadcaebf70b Mon Sep 17 00:00:00 2001 From: xiqiu Date: Fri, 20 Aug 2021 14:00:09 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-57643=20=20=E6=94=B9=E4=B8=AA?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/data/datapane/connect/JDBCDefPane.java | 2 +- 1 file changed, 1 insertion(+), 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 022323f19..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 @@ -354,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); From 2e4770f9549b74a3c824a1b3ae4be8bf920c2bfb Mon Sep 17 00:00:00 2001 From: shine Date: Fri, 20 Aug 2021 14:06:46 +0800 Subject: [PATCH 5/7] =?UTF-8?q?CHART-20319=20fix:=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=9B=BE=E8=A1=A8=E6=B2=A1=E6=9C=89=E8=B6=85?= =?UTF-8?q?=E9=93=BE=E7=AD=89=E7=95=8C=E9=9D=A2=E5=BC=95=E8=B5=B7npe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/custom/other/VanChartCustomInteractivePane.java | 3 +++ .../van/chart/designer/other/VanChartInteractivePane.java | 7 ++++++- .../map/designer/other/VanChartMapInteractivePane.java | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java index 8aab51b3f..82a62f02c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java @@ -44,6 +44,9 @@ public class VanChartCustomInteractivePane extends VanChartInteractivePane { @Override protected void updateHyperlink(Plot plot){ + if (hyperlinkPane == null) { + return; + } hyperlinkPane.updateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index c97f3a8ec..78be16ad5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -685,7 +685,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } protected void updateHyperlink(Plot plot) { - superLink.update(plot); + if (superLink != null) { + superLink.update(plot); + } } private void updateChartTools(VanChart chart) { @@ -734,6 +736,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private void updateAutoRefresh(VanChart chart) { + if (autoRefreshPane == null) { + return; + } RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); if (refreshMoreLabel == null) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java index a6ede0df7..1d49fd834 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java @@ -35,6 +35,9 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo @Override protected void updateHyperlink(Plot plot) { + if (hyperlinkPane == null) { + return; + } hyperlinkPane.updateBean(plot); } From 8c9c959a30f845da6dcd67c027cd028c35b72530 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Sat, 21 Aug 2021 09:35:16 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-57776=20=E6=96=87=E4=BB=B6=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E6=9B=BF=E6=8D=A2-=E4=B8=BBjar=E9=87=8C?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E8=A2=AB=E5=88=A0=E9=99=A4=E5=90=8E=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E4=BA=86=E5=85=B6=E4=BB=96=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/ifilechooser/AbstractFileChooser.java | 104 ++++++++++++ .../gui/ifilechooser/UINativeFileChooser.java | 155 ++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java new file mode 100644 index 000000000..b9a70557d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java @@ -0,0 +1,104 @@ +package com.fr.design.gui.ifilechooser; + +import javax.swing.filechooser.FileFilter; +import java.awt.*; +import java.io.File; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/31 + */ +@Deprecated +public abstract class AbstractFileChooser { + + /** + * 返回当前目录 + * + */ + public abstract File getCurrentDirectory(); + + /** + * 返回当前的文件选择过滤器 + * + */ + public abstract FileFilter getFileFilter(); + + /** + * 返回选择的文件 + * + */ + public abstract File getSelectedFile(); + + /** + * 多文件选择模式下 返回选择的多个文件 + * + */ + public abstract File[] getSelectedFiles(); + + /** + * 是否可以选择多个文件 + * + */ + public abstract boolean isMultiSelectionEnabled(); + + /** + * 设置当前选择的目录 + * + */ + public abstract void setCurrentDirectory(File dir); + + /** + * 设置左上角标题 + * + */ + public abstract void setDialogTitle(String title); + + /** + * 设置当前的文件过滤器 + * + */ + public abstract void setFileFilter(final T filter); + + /** + * 设置文件选择器模式 + * + * JFileChooser.FILES_ONLY + * JFileChooser.DIRECTORIES_ONLY + * JFileChooser.FILES_AND_DIRECTORIES + */ + public abstract void setFileSelectionMode(E selectionMode); + + /** + * 设置是否允许选择多个文件 + * + */ + public abstract void setMultiSelectionEnabled(boolean multiple); + + /** + * 设置选择的文件 用于showSaveDialog + * + */ + public abstract void setSelectedFile(File file); + + /** + * 弹出文件选择器 打开文件 + * + */ + public abstract int showOpenDialog(Component parent); + + /** + * 弹出文件选择器 保存文件 + * + */ + public abstract int showSaveDialog(Component parent); + + + /** + * https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4031440 + * + * 设置文件名后缀 起到文件过滤的作用 形如 "*.jpg;*.jpeg" + * + */ + public abstract void setExtensionFilter(String file); +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java new file mode 100644 index 000000000..025edcf08 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java @@ -0,0 +1,155 @@ +package com.fr.design.gui.ifilechooser; + +import com.fr.design.gui.ifilechooser.AbstractFileChooser; +import com.fr.design.mainframe.DesignerContext; +import com.fr.stable.os.OperatingSystem; + +import javax.swing.*; +import javax.swing.filechooser.FileFilter; +import java.awt.*; +import java.io.File; +import java.io.FilenameFilter; + + +/** + * 系统原生风格的文件选择器 + * + * jdk问题: + * https://bugs.openjdk.java.net/browse/JDK-4811090 不支持文件扩展选择 + * https://stackoverflow.com/questions/40713398/filter-not-working-in-filedialog windows下 setFilenameFilter不work + * + * @author hades + * @version 10.0 + * Created by hades on 2020/3/31 + */ +@Deprecated +public class UINativeFileChooser extends AbstractFileChooser { + + private final FileDialog fileDialog; + private FileFilter fileFilter; + private int selectionMode; + + public UINativeFileChooser(File file) { + fileDialog = new FileDialog(DesignerContext.getDesignerFrame()); + if (file != null) { + fileDialog.setDirectory(file.getAbsolutePath()); + fileDialog.setFile(file.toString()); + } + } + + public UINativeFileChooser() { + this(null); + } + + @Override + public File getCurrentDirectory() { + return new File(fileDialog.getDirectory()); + } + + @Override + public FileFilter getFileFilter() { + return fileFilter; + } + + @Override + public File getSelectedFile() { + return new File(fileDialog.getDirectory() + fileDialog.getFile()); + } + + @Override + public File[] getSelectedFiles() { + return fileDialog.getFiles(); + } + + @Override + public boolean isMultiSelectionEnabled() { + return fileDialog.isMultipleMode(); + } + + @Override + public void setCurrentDirectory(File f) { + fileDialog.setDirectory(f.toString()); + } + + @Override + public void setDialogTitle(String title) { + fileDialog.setTitle(title); + } + + @Override + public void setFileFilter(final FileFilter cff) { + FilenameFilter filter = new FilenameFilter() { + @Override + public boolean accept(File Directory, String fileName) { + return cff.accept(new File(Directory.getAbsolutePath() + fileName)); + } + }; + fileDialog.setFilenameFilter(filter); + fileFilter = cff; + } + + @Override + public void setFileSelectionMode(Integer selectionMode) { + this.selectionMode = selectionMode; + } + + @Override + public void setMultiSelectionEnabled(boolean multiple) { + fileDialog.setMultipleMode(multiple); + } + + @Override + public void setSelectedFile(File file) { + fileDialog.setDirectory(file.getAbsolutePath()); + fileDialog.setFile(file.getName()); + } + + @Override + public int showOpenDialog(Component parent) { + boolean appleProperty = OperatingSystem.isMacos() && selectionMode == JFileChooser.DIRECTORIES_ONLY; + if (appleProperty) { + System.setProperty("apple.awt.fileDialogForDirectories", "true"); + } + try { + fileDialog.setLocale(JComponent.getDefaultLocale()); + fileDialog.setMode(FileDialog.LOAD); + fileDialog.setVisible(true); + return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION; + } finally { + if (appleProperty) { + System.setProperty("apple.awt.fileDialogForDirectories", "false"); + } + } + } + + @Override + public int showSaveDialog(Component parent) { + fileDialog.setLocale(JComponent.getDefaultLocale()); + fileDialog.setMode(FileDialog.SAVE); + fileDialog.setVisible(true); + return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION; + } + + @Override + public void setExtensionFilter(String file) { + fileDialog.setFile(file); + } + + /** + * 确认本地文件选择器是否支持选择模式 + * @param selectionMode 选择模式 + * @return 是否支持选择模式 + */ + public static boolean supportsSelectionMode(int selectionMode) { + switch (selectionMode) { + case JFileChooser.FILES_AND_DIRECTORIES: + return false; + case JFileChooser.DIRECTORIES_ONLY: + return OperatingSystem.isMacos(); + case JFileChooser.FILES_ONLY: + default: + return true; + } + } + +} From 193e07f62bf1f4d9cd95f1de3c3b16455f25ea78 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Sat, 21 Aug 2021 10:22:45 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-55696=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E7=89=88=E6=9C=AC=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97=E5=9C=A8=E9=9D=9E?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E4=B8=8B=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/env/CheckServiceDialog.java | 7 ++++--- .../resources/com/fr/design/i18n/dimension_en.properties | 4 +++- .../com/fr/design/i18n/dimension_ja_JP.properties | 4 +++- .../com/fr/design/i18n/dimension_ko_KR.properties | 4 +++- .../resources/com/fr/design/i18n/dimension_zh.properties | 4 +++- .../com/fr/design/i18n/dimension_zh_TW.properties | 4 +++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index a921a0322..032f16a76 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -5,6 +5,7 @@ import com.fr.design.RestartHelper; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -113,10 +114,10 @@ public class CheckServiceDialog extends JDialog implements ActionListener { font = font.applySize(15).applyStyle(1); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Branch_Inconsistency")); label.setFont(font); - label.setPreferredSize(new Dimension(650, 30)); + label.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.detail.label")); UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Inconsistency_Risk")); - label2.setPreferredSize(new Dimension(600, 30)); + label2.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.detail.label")); verticalPanel.add(label); verticalPanel.add(label2); @@ -201,7 +202,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener { 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)); + this.setSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.detail.dialog")); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties index bd26abb1b..dd33c6a6a 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -4,4 +4,6 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280 com.fr.design.report.ReportColumnsPane=800*600 com.fr.env.RemoteEnvPane.dialog=458*132 -com.fr.design.version.check.dialog=490*95 \ No newline at end of file +com.fr.design.version.check.dialog=490*95 +com.fr.design.version.detail.label=750*30 +com.fr.design.version.detail.dialog=900*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties index 5a0cb009e..b67a913e7 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties @@ -3,4 +3,6 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280 com.fr.env.RemoteEnvPane.dialog=458*132 -com.fr.design.version.check.dialog=430*95 \ No newline at end of file +com.fr.design.version.check.dialog=430*95 +com.fr.design.version.detail.label=650*30 +com.fr.design.version.detail.dialog=800*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties index 17a8209db..862580eed 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties @@ -3,4 +3,6 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 com.fr.env.RemoteEnvPane.dialog=458*132 -com.fr.design.version.check.dialog=450*95 \ No newline at end of file +com.fr.design.version.check.dialog=450*95 +com.fr.design.version.detail.label=700*30 +com.fr.design.version.detail.dialog=850*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index 1c5f50cca..5a325b16b 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -4,4 +4,6 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 com.fr.env.RemoteEnvPane.dialog=308*132 -com.fr.design.version.check.dialog=230*95 \ No newline at end of file +com.fr.design.version.check.dialog=230*95 +com.fr.design.version.detail.label=450*30 +com.fr.design.version.detail.dialog=600*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties index fcbcb8c52..1be37f9c7 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties @@ -3,4 +3,6 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 com.fr.env.RemoteEnvPane.dialog=308*132 -com.fr.design.version.check.dialog=230*95 \ No newline at end of file +com.fr.design.version.check.dialog=230*95 +com.fr.design.version.detail.label=450*30 +com.fr.design.version.detail.dialog=600*500 \ No newline at end of file