From fb0c6563df4a55407c60c7b1d6e8f2f020cac64e Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 20 Aug 2021 10:04:16 +0800 Subject: [PATCH 1/8] =?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 157ce6f980..c1e994bdc4 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 d76702ffbede459508c2a24519bb4dbf299db209 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 20 Aug 2021 13:52:52 +0800 Subject: [PATCH 2/8] =?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 349503bd72..810a71e856 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 ef5917765f1faa805a5ce4897f803bd2046258df Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 26 Aug 2021 16:43:03 +0800 Subject: [PATCH 3/8] =?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 --- .../src/main/java/com/fr/grid/GridUI.java | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 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 10934a7cc4..af640c94fc 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -10,12 +10,15 @@ import com.fr.base.background.ColorBackground; import com.fr.base.background.ImageFileBackground; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.vcs.DesignerMode; +import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; import com.fr.design.roleAuthority.ReportAndFSManagePane; +import com.fr.design.unit.UnitConvertUtil; import com.fr.general.Background; import com.fr.general.ComparatorUtils; import com.fr.grid.selection.CellSelection; @@ -48,6 +51,7 @@ import com.fr.stable.Constants; import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; import com.fr.stable.AssistUtils; +import com.fr.stable.unit.UNIT; import com.fr.third.antlr.ANTLRException; import com.fr.third.guava.collect.HashMultimap; @@ -372,41 +376,41 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float rowHeight, paperYAxisSumSize = 0, yAxisSumSize = 0; + UNIT rowHeight, paperYAxisSumSize = FU.getInstance(0), yAxisSumSize = FU.getInstance(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) { + rowHeight = gridRange.rowHeightList.get(k); + paperYAxisSumSize = paperYAxisSumSize.add(rowHeight); + if (paperYAxisSumSize.toPixF(resolution) >= paperPaintSize) { paperYAxisSumSize = rowHeight; } } } - rowHeight = gridRange.rowHeightList.get(i).toPixF(resolution); - paperYAxisSumSize += rowHeight; + + rowHeight = gridRange.rowHeightList.get(i); + paperYAxisSumSize = paperYAxisSumSize.add(rowHeight); if (showGridLine) { - float columnWidth, xAxisSumSize = 0; + UNIT columnWidth, xAxisSumSize = FU.getInstance(0); for (int j = gridRange.xBeginIndex; j <= gridRange.xEndIndex; j++) { - columnWidth = gridRange.columnWidthList.get(j).toPixF(resolution); + columnWidth = gridRange.columnWidthList.get(j); if (!mergeCellElementTable.get(CellPosition.value(i - 1, j)).contains(CellPosition.BOTTOM)) { - tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize + columnWidth, yAxisSumSize); + tmpLine2D.setLine(xAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution), xAxisSumSize.add(columnWidth).toPixF(resolution), yAxisSumSize.toPixF(resolution)); g2d.draw(tmpLine2D); } - xAxisSumSize += columnWidth; + xAxisSumSize = xAxisSumSize.add(columnWidth); } } - if (showPaginateLine && paperYAxisSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) yAxisSumSize)); + if (showPaginateLine && paperYAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) yAxisSumSize.toPixF(resolution))); paperYAxisSumSize = rowHeight; } - yAxisSumSize += rowHeight; + yAxisSumSize = yAxisSumSize.add(rowHeight); } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) yAxisSumSize); + drawLastLine(g2d, (int) yAxisSumSize.toPixF(resolution)); } } } @@ -432,40 +436,40 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float columnWidth, paperXAxisSumSize = 0, xAxisSumSize = 0; + UNIT columnWidth, paperXAxisSumSize = FU.getInstance(0), xAxisSumSize = FU.getInstance(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) { + columnWidth = gridRange.columnWidthList.get(k); + paperXAxisSumSize = paperXAxisSumSize.add(columnWidth); + if (paperXAxisSumSize.toPixF(resolution) >= paperPaintSize) { paperXAxisSumSize = columnWidth; } } } - columnWidth = gridRange.columnWidthList.get(i).toPixF(resolution); - paperXAxisSumSize += columnWidth; + columnWidth = gridRange.columnWidthList.get(i); + paperXAxisSumSize = paperXAxisSumSize.add(columnWidth); if (showGridLine) { - float rowHeight, yAxisSumSize = 0; + UNIT rowHeight, yAxisSumSize = FU.getInstance(0); for (int j = gridRange.yBeginIndex; j <= gridRange.yEndIndex; j++) { - rowHeight = gridRange.rowHeightList.get(j).toPixF(resolution); + rowHeight = gridRange.rowHeightList.get(j); if (!mergeCellElementTable.get(CellPosition.value(j, i - 1)).contains(CellPosition.RIGHT)) { - tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize, yAxisSumSize + rowHeight); + tmpLine2D.setLine(xAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution), xAxisSumSize.toPixF(resolution), yAxisSumSize.add(rowHeight).toPixF(resolution)); g2d.draw(tmpLine2D); } - yAxisSumSize += rowHeight; + yAxisSumSize = yAxisSumSize.add(rowHeight); } } - if (showPaginateLine && paperXAxisSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) xAxisSumSize)); + if (showPaginateLine && paperXAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) xAxisSumSize.toPixF(resolution))); paperXAxisSumSize = columnWidth; } - xAxisSumSize += columnWidth; + xAxisSumSize = xAxisSumSize.add(columnWidth); } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) xAxisSumSize); + drawLastLine(g2d, (int) xAxisSumSize.toPixF(resolution)); } } } From 438d2cb8e772a9ae7040e6bdc8cce6e4df3df516 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 1 Sep 2021 11:28:13 +0800 Subject: [PATCH 4/8] =?UTF-8?q?REPORT-58200=20=E5=88=9D=E6=AC=A1=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=9A=8410.0=E8=AE=BE=E8=AE=A1=E5=99=A8=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9B=AE=E5=BD=95=E4=B8=8B=E4=BC=9A=E7=94=9F?= =?UTF-8?q?=E6=88=90.finereport80=E7=BC=93=E5=AD=98=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/DesignerEnvManager.java | 3 --- 1 file changed, 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 7242b22950..9c23dcc51a 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -390,9 +390,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } File envHome = new File(userHome + File.separator + "." + ProductConstants.APP_NAME + version); - if (!envHome.exists()) { - StableUtils.mkdirs(envHome); - } return envHome.getAbsolutePath(); } From fb1d0f8d578143bb3f60ecab452b5031d71f46ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 3 Sep 2021 16:23:16 +0800 Subject: [PATCH 5/8] =?UTF-8?q?REPORT-58588=20FR11-=E4=BA=8C=E8=BD=AE?= =?UTF-8?q?=E5=9B=9E=E5=BD=92-=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=A0=8F-=E7=A4=BE=E5=8C=BA-=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E8=B7=B3=E8=BD=AC=E5=9C=B0=E5=9D=80=E7=9A=84?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=9D=A2=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/help/TutorialAction.java | 5 +++++ .../java/com/fr/design/login/AbstractDesignerSSO.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index cf4f02f405..86237e0597 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,5 +1,6 @@ package com.fr.design.actions.help; +import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; import com.fr.general.CloudCenter; @@ -30,6 +31,10 @@ public class TutorialAction extends AbstractDesignerSSO { return CloudCenter.getInstance().acquireUrlByKind(createDocKey()); } + public String getOffLineWarnMessage() { + return Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg"); + } + // 生成帮助文档 sitecenter key, help.zh_CN.10 protected String createDocKey() { String locale = GeneralContext.getLocale().toString(); diff --git a/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java b/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java index 2662198bbc..f38fc1d08c 100644 --- a/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java +++ b/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java @@ -6,6 +6,9 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.BrowseUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.Map; @@ -21,6 +24,10 @@ public abstract class AbstractDesignerSSO extends UpdateAction { public void actionPerformed(ActionEvent event) { String url = getJumpUrl(); if (!DesignerLoginUtils.isOnline()) { + String message = getOffLineWarnMessage(); + if (StringUtils.isNotEmpty(message)) { + FineLoggerFactory.getLogger().warn(message); + } BrowseUtils.browser(url); return; } @@ -47,4 +54,8 @@ public abstract class AbstractDesignerSSO extends UpdateAction { } public abstract String getJumpUrl(); + + public String getOffLineWarnMessage() { + return StringUtils.EMPTY; + } } From 1b7f5cf7761e9ad8c0c37926fe3a23e5fa3b4aa8 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 8 Sep 2021 17:31:07 +0800 Subject: [PATCH 6/8] =?UTF-8?q?REPORT-58227=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=20=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=89=93=E5=BC=80=E7=9A=84=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 48 ++++++++++++++-- .../connect/ItemEditableComboBoxPanel.java | 55 ++++++++++++++----- 2 files changed, 84 insertions(+), 19 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index b5bc39e4eb..f656105265 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -25,6 +25,7 @@ import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -39,7 +40,16 @@ import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; -import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.Collections; +import java.util.concurrent.CancellationException; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.SwingWorker; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.PopupMenuEvent; @@ -50,7 +60,6 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -70,6 +79,9 @@ import java.util.concurrent.FutureTask; * @since 2012-7-11下午4:49:39 */ public class ChoosePane extends BasicBeanPane implements Refreshable, Previewable, Prepare4DataSourceChange { + + private static final List PENDING_CONTENT = new ArrayList<>(Collections.singletonList(Toolkit.i18nText("Fine-Design_Basic_Loading") + "...")); + private static final double COLUMN_SIZE = 24; /** @@ -91,6 +103,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha private SwingWorker populateWorker; + private SwingWorker, Void> initWorker; + private PopupMenuListener popupMenuListener = new PopupMenuListener() { @Override @@ -213,10 +227,34 @@ public class ChoosePane extends BasicBeanPane implements Refresha @SuppressWarnings("unchecked") protected void initDsNameComboBox() { + if (initWorker != null && !initWorker.isDone()) { + initWorker.cancel(true); + } dsNameComboBox.setRefreshingModel(true); - FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections()); - dsNameComboBox.setModel(dsNameComboBoxModel); - dsNameComboBox.setRefreshingModel(false); + dsNameComboBox.setModel(new FilterableComboBoxModel(PENDING_CONTENT)); + initWorker = new SwingWorker, Void>() { + + @Override + protected List doInBackground() throws Exception { + return getHasAuthConnections(); + } + + @Override + protected void done() { + try { + FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(get()); + String selected = dsNameComboBox.getSelectedItem(); + dsNameComboBox.setModel(dsNameComboBoxModel); + dsNameComboBox.setSelectedItem(selected); + dsNameComboBox.setRefreshingModel(false); + } catch (Exception e) { + if (!(e instanceof CancellationException)) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + }; + initWorker.execute(); } protected void initComponentsLayout(PreviewLabel previewLabel, int labelSize) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java index f06d1405b8..248d3318c9 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java @@ -3,12 +3,19 @@ package com.fr.design.data.datapane.connect; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import javax.swing.*; -import java.awt.*; +import com.fr.log.FineLoggerFactory; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.Iterator; +import java.util.concurrent.CancellationException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import javax.swing.SwingWorker; public abstract class ItemEditableComboBoxPanel extends JPanel { /** @@ -16,6 +23,8 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { */ private static final long serialVersionUID = 1L; + private static final String PENDING = Toolkit.i18nText("Fine-Design_Basic_Loading") + "..."; + protected static final Object EMPTY = new Object() { public String toString() { return ""; @@ -26,6 +35,8 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { protected UIButton editButton; protected UIButton refreshButton; + private SwingWorker, Void> refreshWorker; + public ItemEditableComboBoxPanel() { super(); @@ -75,26 +86,42 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { * 刷新itemComboBox的内容 */ protected void refreshItems() { - // 记录原来选中的Item,重新加载后需要再次选中 - Object lastSelectedItem = itemComboBox.getSelectedItem(); + + if (refreshWorker != null && !refreshWorker.isDone()) { + refreshWorker.cancel(true); + } DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); model.removeAllElements(); // 先加EMPTY,再加items model.addElement(EMPTY); + model.addElement(PENDING); - java.util.Iterator itemIt = items(); - while(itemIt.hasNext()) { - model.addElement(itemIt.next()); - } + refreshWorker = new SwingWorker, Void>() { + @Override + protected Iterator doInBackground() throws Exception { + return items(); + } - // 再次选中之前选中的Item - int idx = model.getIndexOf(lastSelectedItem); - if(idx < 0) { - idx = 0; - } - itemComboBox.setSelectedIndex(idx); + @Override + protected void done() { + try { + Iterator itemIt = get(); + model.removeElement(PENDING); + while(itemIt.hasNext()) { + model.addElement(itemIt.next()); + } + itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); + } catch (Exception e) { + if (!(e instanceof CancellationException)) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + } + }; + refreshWorker.execute(); } /* From 5e001197e8ef32559e5b499a5c55a7f08636b4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 9 Sep 2021 16:36:18 +0800 Subject: [PATCH 7/8] =?UTF-8?q?REPORT-59099=20=E7=BB=99=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=9A=84=E7=BD=91=E5=9D=80=E8=A1=A5=E4=B8=8A?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/actions/help/TutorialAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index 86237e0597..f1094d3315 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -28,7 +28,7 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind(createDocKey()); + return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com"); } public String getOffLineWarnMessage() { From 5f1200d94ee31235018556e66ef032779b5ae1dd Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 10 Sep 2021 18:29:38 +0800 Subject: [PATCH 8/8] =?UTF-8?q?REPORT-58252=20=E6=8A=A5=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E8=A1=8C=E5=88=97=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=90=8E=E7=9A=84=E5=BC=A5=E8=A1=A5=E6=96=B9?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 表单报表块缩略图中去掉表格行列标志后,需要提供给用户一个仅通过缩略图确定表格内容区域位置的方案。 讨论后的方案为表格缩略图中不出现内容区域外的网格线,用户从而可以直接通过缩略图通过网格线的尺寸和位置 来确定内容区域的大小和位置. 【改动思路】 同上 --- .../form/FormElementCaseDesigner.java | 3 ++ .../src/main/java/com/fr/grid/Grid.java | 10 ++++ .../src/main/java/com/fr/grid/GridUI.java | 50 ++++++++++++++----- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 2dd3dbbb7f..5be6362a4d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -152,10 +152,13 @@ public class FormElementCaseDesigner Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; if (grid != null) { boolean oldTranslucent = grid.isTranslucent(); + boolean oldShowExtraGridLine = grid.isShowExtraGridLine(); // 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景 grid.setTranslucent(true); + grid.setShowExtraGridLine(false); grid.paint(g2d); grid.setTranslucent(oldTranslucent); + grid.setShowExtraGridLine(oldShowExtraGridLine); } } catch (Exception e) { diff --git a/designer-realize/src/main/java/com/fr/grid/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index b55f60bb53..80147f3e57 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -136,6 +136,8 @@ public class Grid extends BaseGridComponent { // 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充 private boolean isTranslucent = false; + // 是否绘制单元格内容区之外的网格线 + private boolean showExtraGridLine = true; public Grid(int resolution) { this.resolution = resolution; @@ -1469,4 +1471,12 @@ public class Grid extends BaseGridComponent { public void setTranslucent(boolean translucent) { isTranslucent = translucent; } + + public boolean isShowExtraGridLine() { + return showExtraGridLine; + } + + public void setShowExtraGridLine(boolean showExtraGridLine) { + this.showExtraGridLine = showExtraGridLine; + } } 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 af640c94fc..ba51d6d64a 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -292,15 +292,25 @@ public class GridUI extends ComponentUI { } } } - GridRange gridRange = GridRange.range(grid.getHorizontalBeginValue(), horizontalEndValue, grid.getVerticalBeginValue(), verticalEndValue) + int xBeginIndex = grid.getHorizontalBeginValue(); + int xEndIndex = horizontalEndValue; + int yBeginIndex = grid.getVerticalBeginValue(); + int yEndIndex = verticalEndValue; + if (!grid.isShowExtraGridLine()) { + xBeginIndex = 0; + xEndIndex = Math.max(0, report.getColumnCount() - 1); + yBeginIndex = 0; + yEndIndex = Math.max(0, report.getRowCount() - 1); + } + GridRange gridRange = GridRange.range(xBeginIndex, xEndIndex, yBeginIndex, yEndIndex) .rangeList(rowHeightList, columnWidthList) .realSize(realWidth, realHeight); - new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), + new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), grid.isShowExtraGridLine(), isShowVerticalPaginateLine, paperPaintHeight, paginateLineList, resolution).iterateStart2End(g2d); - new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), + new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), grid.isShowExtraGridLine(), isShowHorizontalPaginateLine, paperPaintWidth, paginateLineList, resolution).iterateStart2End(g2d); } @@ -324,6 +334,7 @@ public class GridUI extends ComponentUI { protected GridRange gridRange; protected boolean showGridLine; + protected boolean showExtraGridLine; protected boolean showPaginateLine; protected double paperPaintSize; @@ -336,11 +347,12 @@ public class GridUI extends ComponentUI { protected static final double THRESHOLD = 1.0E-4D; - DrawLineHelper(GridRange gridRange, boolean showGridLine, + DrawLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { this.gridRange = gridRange; this.showGridLine = showGridLine; + this.showExtraGridLine = showExtraGridLine; this.showPaginateLine = showPaginateLine; this.paperPaintSize = paperPaintSize; @@ -357,10 +369,10 @@ public class GridUI extends ComponentUI { private class DrawVerticalLineHelper extends DrawLineHelper { - DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, + DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, showPaginateLine, + super(gridRange, showGridLine, showExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -376,7 +388,7 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - UNIT rowHeight, paperYAxisSumSize = FU.getInstance(0), yAxisSumSize = FU.getInstance(0); + UNIT rowHeight, paperYAxisSumSize = FU.getInstance(0), maxXAxisSumSize = FU.getInstance(0), yAxisSumSize = FU.getInstance(0); for (int i = 0; i <= gridRange.yEndIndex; i++) { if (i == 0) { i = gridRange.yBeginIndex; @@ -401,6 +413,9 @@ public class GridUI extends ComponentUI { } xAxisSumSize = xAxisSumSize.add(columnWidth); } + if (xAxisSumSize.toPixF(resolution) > maxXAxisSumSize.toPixF(resolution)) { + maxXAxisSumSize = xAxisSumSize; + } } if (showPaginateLine && paperYAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { paginateLineList.add(getPaginateLine2D((int) yAxisSumSize.toPixF(resolution))); @@ -410,17 +425,21 @@ public class GridUI extends ComponentUI { } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) yAxisSumSize.toPixF(resolution)); + if (showExtraGridLine) { + drawLastLine(g2d, (int) yAxisSumSize.toPixF(resolution)); + } else { + GraphHelper.drawLine(g2d, 0, yAxisSumSize.toPixF(resolution), maxXAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution)); + } } } } private class DrawHorizontalLineHelper extends DrawLineHelper { - DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, + DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, showPaginateLine, + super(gridRange, showGridLine, showExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -436,7 +455,7 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - UNIT columnWidth, paperXAxisSumSize = FU.getInstance(0), xAxisSumSize = FU.getInstance(0); + UNIT columnWidth, paperXAxisSumSize = FU.getInstance(0), maxYAxisSumSize = FU.getInstance(0), xAxisSumSize = FU.getInstance(0); for (int i = 0; i <= gridRange.xEndIndex; i++) { if (i == 0) { i = gridRange.xBeginIndex; @@ -460,6 +479,9 @@ public class GridUI extends ComponentUI { } yAxisSumSize = yAxisSumSize.add(rowHeight); } + if (yAxisSumSize.toPixF(resolution) > maxYAxisSumSize.toPixF(resolution)) { + maxYAxisSumSize = yAxisSumSize; + } } if (showPaginateLine && paperXAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { paginateLineList.add(getPaginateLine2D((int) xAxisSumSize.toPixF(resolution))); @@ -469,7 +491,11 @@ public class GridUI extends ComponentUI { } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) xAxisSumSize.toPixF(resolution)); + if (showExtraGridLine) { + drawLastLine(g2d, (int) xAxisSumSize.toPixD(resolution)); + } else { + GraphHelper.drawLine(g2d, xAxisSumSize.toPixF(resolution), 0, xAxisSumSize.toPixF(resolution), maxYAxisSumSize.toPixF(resolution)); + } } } }