From ce9b3c71b0cdaf6f004417d957f3b3160c4fd2ef Mon Sep 17 00:00:00 2001 From: Maksim Date: Mon, 9 Dec 2019 15:49:45 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=BB=BA=E7=AB=8Bsocket=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 167 +++++++++++------- 1 file changed, 104 insertions(+), 63 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 e2b13b1adf..8ce0bdcec4 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 @@ -13,7 +13,6 @@ import com.fr.report.RemoteDesignConstants; import com.fr.serialization.SerializerHelper; import com.fr.stable.ArrayUtils; import com.fr.third.apache.log4j.spi.LoggingEvent; -import com.fr.third.guava.base.Optional; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; @@ -36,28 +35,19 @@ public class DesignerSocketIO { Disconnecting } - private static Optional socketIO = Optional.absent(); + private static Socket socket = null; private static Status status = Status.Disconnected; + //维护一个当前工作环境的uri列表 + private static String[] uri; + //维护一个关于uri列表的计数器 + private static int count; - private static final Emitter.Listener printLog = new Emitter.Listener() { - @Override - public void call(Object... objects) { - if (ArrayUtils.isNotEmpty(objects)) { - try { - LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]); - DesignerLogger.log(event); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - } - }; public static void close() { - if (socketIO.isPresent()) { + if (socket != null) { status = Status.Disconnecting; - socketIO.get().close(); - socketIO = Optional.absent(); + socket.close(); + socket = null; } } @@ -66,57 +56,42 @@ public class DesignerSocketIO { if (current.isLocal()) { return; } + //每当更换工作环境,更新uri列表,同时更新计数器count try { - String[] uri = getSocketUri(current); - socketIO = Optional.of(IO.socket(new URI(uri[0]))); - socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog); - socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() { - @Override - public void call(Object... objects) { - assert objects != null && objects.length == 1; - String param = (String) objects[0]; - EventDispatcher.fire(RemoteConfigEvent.EDIT, param); - } - }); - socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { - @Override - public void call(Object... objects) { - /* - * todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上,切换成心跳断开之后进行提醒, - * socketio 只用推日志和通知配置变更 - */ - if (status != Status.Disconnecting) { - try { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - JOptionPane.showMessageDialog( - DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), - UIManager.getString("OptionPane.messageDialogTitle"), - JOptionPane.ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); - EnvChangeEntrance.getInstance().chooseEnv(); - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - status = Status.Disconnected; - } - }); - socketIO.get().connect(); - status = Status.Connected; + uri = getSocketUri(); + } catch (IOException e) { + e.printStackTrace(); + } + count = 0; + //建立socket并注册监听 + CreateSocket(); + } + + private static void CreateSocket(){ + //根据uri和计数器建立连接,并注册监听 + try { + if(count Date: Mon, 9 Dec 2019 16:39:15 +0800 Subject: [PATCH 2/7] return --- .../fr/design/mainframe/socketio/DesignerSocketIO.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 8ce0bdcec4..92f7e9771c 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 @@ -60,14 +60,14 @@ public class DesignerSocketIO { try { uri = getSocketUri(); } catch (IOException e) { - e.printStackTrace(); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } count = 0; //建立socket并注册监听 - CreateSocket(); + createSocket(); } - private static void CreateSocket(){ + private static void createSocket(){ //根据uri和计数器建立连接,并注册监听 try { if(count Date: Mon, 9 Dec 2019 16:40:25 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= 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 92f7e9771c..057eb6de9e 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 @@ -138,7 +138,7 @@ public class DesignerSocketIO { @Override public void call(Object... objects) { /* - * todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上,切换成心跳断开之后进行提醒, + * todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上,切换成心跳断开之后进行提醒, * socket 只用推日志和通知配置变更 */ if (status != Status.Disconnecting) { From 1838a00cd0012b9c391c35e16b16c6b8bdc53cc3 Mon Sep 17 00:00:00 2001 From: Maksim Date: Mon, 2 Mar 2020 21:21:32 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=AC=E6=9C=88=E4=B8=8D=E5=86=8D=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 27 ++++++++- .../fr/design/env/DesignerWorkspaceInfo.java | 3 + .../env/LocalDesignerWorkspaceInfo.java | 5 ++ .../env/RemoteDesignerWorkspaceInfo.java | 13 +++++ .../write/submit/CheckServiceDialog.java | 54 ++++++++++++++---- .../fr/design/images/warnings/warning5.png | Bin 0 -> 3095 bytes 6 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png 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 124ace0b01..9a368f3429 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -43,7 +43,11 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.lang.reflect.Method; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Set; @@ -240,7 +244,7 @@ public class EnvChangeEntrance { textBuilder.append(descriptionOfCN).append("\n"); } String areaText = textBuilder.toString(); - CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); + CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), selectedEnv, areaText, localBranch, remoteBranch); dialog.setVisible(true); } } @@ -249,12 +253,29 @@ public class EnvChangeEntrance { /** * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 - * 2、一个月内不弹出是否勾选(这里预留,还未实际增加) + * 2、一个月内不弹出是否勾选 * @param selectedEnv 选择的环境 * @return */ private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){ - return selectedEnv.getType() == DesignerWorkspaceType.Remote; + if(selectedEnv.getType() == DesignerWorkspaceType.Remote){ + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + //获取记录的时间 + Date remindTime = format.parse(selectedEnv.getRemindTime()); + calendar.setTime(remindTime); + //获取一个月后的时间 + calendar.add(Calendar.MONTH,1); + //与当前时间作对比,然后判断是否提示 + if(new Date().after(calendar.getTime())){ + return true; + } + } catch (ParseException e) { + return true; + } + } + return false; } /** diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java index 2e5cc9f8c0..ccc98bfe37 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java @@ -10,6 +10,9 @@ public interface DesignerWorkspaceInfo extends XMLable { String getPath(); + //获取提醒时间,用于判断是否做服务检测 + String getRemindTime(); + WorkspaceConnectionInfo getConnection(); boolean checkValid(); 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 19b0857818..ef1f420d62 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 @@ -43,6 +43,11 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return path; } + @Override + public String getRemindTime() { + return null; + } + @Override public WorkspaceConnectionInfo getConnection() { return null; diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 9d2af66cf1..af0b8a01c0 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -13,6 +13,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private String name; + private String remindTime; + private WorkspaceConnectionInfo connection; public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { @@ -45,11 +47,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return connection; } + public void setRemindTime(String remindTime){ + this.remindTime = remindTime; + } + + @Override + public String getRemindTime(){ + return remindTime; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); + this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -69,6 +81,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); + writer.attr("remindTime", remindTime); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); diff --git a/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java index 3797c0f8a2..c88fa1fd99 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java @@ -1,10 +1,14 @@ package com.fr.design.write.submit; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; +import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import javax.swing.BorderFactory; @@ -18,6 +22,9 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; /** * @author: Maksim @@ -28,30 +35,33 @@ public class CheckServiceDialog extends JDialog implements ActionListener { private JPanel topPanel; private JPanel centerPanel; private JPanel bottomPanel; + private UICheckBox remindBox; + private DesignerWorkspaceInfo selectEnv; - public CheckServiceDialog(Frame parent, String areaText, String localBranch, String remoteBranch){ + public CheckServiceDialog(Frame parent, DesignerWorkspaceInfo selectEnv, String areaText, String localBranch, String remoteBranch){ super(parent,true); + this.selectEnv = selectEnv; //上面的标签面板 topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel imagePanel = new JPanel(); - Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning4.png"); + Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png"); JLabel imageLabel = new JLabel(); imageLabel.setIcon(icon); imagePanel.add(imageLabel); - imagePanel.setPreferredSize(new Dimension(100,80)); + imagePanel.setPreferredSize(new Dimension(110,80)); JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); FRFont font = FRFont.getInstance(); font = font.applySize(15).applyStyle(1); JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Inconsistency")); label.setFont(font); - label.setPreferredSize(new Dimension(500,30)); - JLabel label2 = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") - + localBranch + "/" + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch); - label2.setPreferredSize(new Dimension(500,20)); + label.setPreferredSize(new Dimension(600,30)); + JLabel label2 = new JLabel(""+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + + localBranch + "/" + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+""); + label2.setPreferredSize(new Dimension(600,30)); JLabel label3 = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update")); - label3.setPreferredSize(new Dimension(500,20)); + label3.setPreferredSize(new Dimension(500,30)); verticalPanel.add(label); verticalPanel.add(label2); @@ -73,9 +83,13 @@ public class CheckServiceDialog extends JDialog implements ActionListener { centerPanel.add(checkArea,BorderLayout.CENTER); //下面的按钮面板 + remindBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remind_Show")); + remindBox.addActionListener(remindCheckboxListener); UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm")); - JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - buttonPanel.add(okButton); + JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); + buttonPanel.add(remindBox, BorderLayout.WEST); + buttonPanel.add(okButton,BorderLayout.EAST); okButton.addActionListener(this ); bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); bottomPanel.add(buttonPanel); @@ -86,7 +100,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(600, 500)); + this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US)? 700:600, 500)); GUICoreUtils.centerWindow(this); } @@ -94,4 +108,22 @@ public class CheckServiceDialog extends JDialog implements ActionListener { public void actionPerformed(ActionEvent e) { this.dispose(); } + + + private ActionListener remindCheckboxListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean needRemind = remindBox.isSelected(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String remindTime = format.format(new Date()); + if(needRemind){ + //前面做过验证,一定是远程环境,直接强转 + ((RemoteDesignerWorkspaceInfo)selectEnv).setRemindTime(remindTime); + }else { + ((RemoteDesignerWorkspaceInfo)selectEnv).setRemindTime(""); + } + } + }; + } diff --git a/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png b/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png new file mode 100644 index 0000000000000000000000000000000000000000..059206e0cc3393c10dd4a29ff1933df00be28ad2 GIT binary patch literal 3095 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 literal 0 HcmV?d00001 From ae73305f84e4dde3b2cc85c565fccb831fb2d4b4 Mon Sep 17 00:00:00 2001 From: Maksim Date: Mon, 2 Mar 2020 21:25:04 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 167 +++++++----------- 1 file changed, 63 insertions(+), 104 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 63bc3d999b..e2b13b1adf 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 @@ -13,6 +13,7 @@ import com.fr.report.RemoteDesignConstants; import com.fr.serialization.SerializerHelper; import com.fr.stable.ArrayUtils; import com.fr.third.apache.log4j.spi.LoggingEvent; +import com.fr.third.guava.base.Optional; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; @@ -35,19 +36,28 @@ public class DesignerSocketIO { Disconnecting } - private static Socket socket = null; + private static Optional socketIO = Optional.absent(); private static Status status = Status.Disconnected; - //维护一个当前工作环境的uri列表 - private static String[] uri; - //维护一个关于uri列表的计数器 - private static int count; + private static final Emitter.Listener printLog = new Emitter.Listener() { + @Override + public void call(Object... objects) { + if (ArrayUtils.isNotEmpty(objects)) { + try { + LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]); + DesignerLogger.log(event); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + }; public static void close() { - if (socket != null) { + if (socketIO.isPresent()) { status = Status.Disconnecting; - socket.close(); - socket = null; + socketIO.get().close(); + socketIO = Optional.absent(); } } @@ -56,42 +66,57 @@ public class DesignerSocketIO { if (current.isLocal()) { return; } - //每当更换工作环境,更新uri列表,同时更新计数器count - try { - uri = getSocketUri(); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - count = 0; - //建立socket并注册监听 - createSocket(); - } - - private static void createSocket(){ - //根据uri和计数器建立连接,并注册监听 try { - if(count Date: Mon, 2 Mar 2020 21:27:45 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 167 +++++++++++------- 1 file changed, 104 insertions(+), 63 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 e2b13b1adf..63bc3d999b 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 @@ -13,7 +13,6 @@ import com.fr.report.RemoteDesignConstants; import com.fr.serialization.SerializerHelper; import com.fr.stable.ArrayUtils; import com.fr.third.apache.log4j.spi.LoggingEvent; -import com.fr.third.guava.base.Optional; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; @@ -36,28 +35,19 @@ public class DesignerSocketIO { Disconnecting } - private static Optional socketIO = Optional.absent(); + private static Socket socket = null; private static Status status = Status.Disconnected; + //维护一个当前工作环境的uri列表 + private static String[] uri; + //维护一个关于uri列表的计数器 + private static int count; - private static final Emitter.Listener printLog = new Emitter.Listener() { - @Override - public void call(Object... objects) { - if (ArrayUtils.isNotEmpty(objects)) { - try { - LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]); - DesignerLogger.log(event); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - } - }; public static void close() { - if (socketIO.isPresent()) { + if (socket != null) { status = Status.Disconnecting; - socketIO.get().close(); - socketIO = Optional.absent(); + socket.close(); + socket = null; } } @@ -66,57 +56,42 @@ public class DesignerSocketIO { if (current.isLocal()) { return; } + //每当更换工作环境,更新uri列表,同时更新计数器count try { - String[] uri = getSocketUri(current); - socketIO = Optional.of(IO.socket(new URI(uri[0]))); - socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog); - socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() { - @Override - public void call(Object... objects) { - assert objects != null && objects.length == 1; - String param = (String) objects[0]; - EventDispatcher.fire(RemoteConfigEvent.EDIT, param); - } - }); - socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { - @Override - public void call(Object... objects) { - /* - * todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上,切换成心跳断开之后进行提醒, - * socketio 只用推日志和通知配置变更 - */ - if (status != Status.Disconnecting) { - try { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - JOptionPane.showMessageDialog( - DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), - UIManager.getString("OptionPane.messageDialogTitle"), - JOptionPane.ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); - EnvChangeEntrance.getInstance().chooseEnv(); - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - status = Status.Disconnected; - } - }); - socketIO.get().connect(); - status = Status.Connected; + uri = getSocketUri(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + count = 0; + //建立socket并注册监听 + createSocket(); + } + + private static void createSocket(){ + //根据uri和计数器建立连接,并注册监听 + try { + if(count Date: Tue, 3 Mar 2020 10:43:52 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E6=9D=A5=E5=A4=84=E7=90=86=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E4=BA=8E=E4=BC=A0=E5=85=A5=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 +- .../design/write/submit/CheckServiceDialog.java | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) 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 9a368f3429..eca98c8bea 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -244,7 +244,7 @@ public class EnvChangeEntrance { textBuilder.append(descriptionOfCN).append("\n"); } String areaText = textBuilder.toString(); - CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), selectedEnv, areaText, localBranch, remoteBranch); + CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); dialog.setVisible(true); } } diff --git a/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java index c88fa1fd99..a5f5d752b2 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java @@ -1,6 +1,6 @@ package com.fr.design.write.submit; -import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.DesignerEnvManager; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -36,11 +36,9 @@ public class CheckServiceDialog extends JDialog implements ActionListener { private JPanel centerPanel; private JPanel bottomPanel; private UICheckBox remindBox; - private DesignerWorkspaceInfo selectEnv; - public CheckServiceDialog(Frame parent, DesignerWorkspaceInfo selectEnv, String areaText, String localBranch, String remoteBranch){ + public CheckServiceDialog(Frame parent, String areaText, String localBranch, String remoteBranch){ super(parent,true); - this.selectEnv = selectEnv; //上面的标签面板 topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel imagePanel = new JPanel(); @@ -114,15 +112,12 @@ public class CheckServiceDialog extends JDialog implements ActionListener { @Override public void actionPerformed(ActionEvent e) { - boolean needRemind = remindBox.isSelected(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String remindTime = format.format(new Date()); - if(needRemind){ - //前面做过验证,一定是远程环境,直接强转 - ((RemoteDesignerWorkspaceInfo)selectEnv).setRemindTime(remindTime); - }else { - ((RemoteDesignerWorkspaceInfo)selectEnv).setRemindTime(""); - } + //环境已切换,通过当前环境获取,一定是远程环境 + String currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); + RemoteDesignerWorkspaceInfo currentEnv = (RemoteDesignerWorkspaceInfo)DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentEnvName); + currentEnv.setRemindTime(remindBox.isSelected()? remindTime : ""); } };