From ce9b3c71b0cdaf6f004417d957f3b3160c4fd2ef Mon Sep 17 00:00:00 2001 From: Maksim Date: Mon, 9 Dec 2019 15:49:45 +0800 Subject: [PATCH 1/9] =?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 e2b13b1ad..8ce0bdcec 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/9] 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 8ce0bdcec..92f7e9771 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/9] =?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 92f7e9771..057eb6de9 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 8b7302459583ab5acd89ff2b0d346e4d65b268dd Mon Sep 17 00:00:00 2001 From: shine Date: Mon, 2 Mar 2020 14:35:31 +0800 Subject: [PATCH 4/9] =?UTF-8?q?CHART-12810=20//=E5=88=A0=E9=99=A4=E7=9A=84?= =?UTF-8?q?tab=E9=9D=9E=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81,=20=E5=8E=9F?= =?UTF-8?q?=E4=B8=BA=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81=E7=9A=84tab?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E9=80=89=E4=B8=AD=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/chart/gui/ChartTypeButtonPane.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 1fbb87c42..4d7673b3e 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -503,6 +503,13 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (this.isSelected()) { indexList.get(0).setSelected(true); changeCollectionSelected(indexList.get(0).getButtonName()); + } else {//删除的tab非选中状态, 原为选中状态的tab保持选中不变 + for (ChartChangeButton button : indexList) { + if (button.isSelected()) { + changeCollectionSelected(button.getButtonName()); + break; + } + } } } From 1838a00cd0012b9c391c35e16b16c6b8bdc53cc3 Mon Sep 17 00:00:00 2001 From: Maksim Date: Mon, 2 Mar 2020 21:21:32 +0800 Subject: [PATCH 5/9] =?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 124ace0b0..9a368f342 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 2e5cc9f8c..ccc98bfe3 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 19b085781..ef1f420d6 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 9d2af66cf..af0b8a01c 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 3797c0f8a..c88fa1fd9 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 6/9] =?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 63bc3d999..e2b13b1ad 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 7/9] =?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 e2b13b1ad..63bc3d999 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 8/9] =?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 9a368f342..eca98c8be 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 c88fa1fd9..a5f5d752b 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 : ""); } }; From ff7e4b8cc2dcda07f27d2a8c20390d81872bb3b2 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 3 Mar 2020 15:53:06 +0800 Subject: [PATCH 9/9] =?UTF-8?q?MOBILE-25437=20=E6=B7=BB=E5=8A=A0=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E5=BF=AB=E9=80=9F=E5=AE=9A=E4=BD=8D=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E5=8A=9F=E8=83=BD=E4=BE=A7=E8=BE=B9=E6=A0=8F=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/MobileBookMarkStyleDefinePane.java | 6 +- .../mobile/ui/MobileBookMarkStylePane.java | 16 +- ...arMobileBookMarkStyleCustomDefinePane.java | 387 ++++++++++++++++++ .../SidebarMobileBookMarkStyleProvider.java | 30 ++ 4 files changed, 436 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java index 0a480d99a..7812e8f32 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java @@ -30,11 +30,15 @@ public class MobileBookMarkStyleDefinePane extends BasicBeanPane { + public static final int LEFT_PANEL_WIDTH = 140; + public static final int LEFT_PANEL_HEIGHT = 565; + public static final int RIGHT_PANEL_WIDTH = 510; + public static final int RIGHT_PANEL_HEIGHT = 565; + public static ListCellRenderer renderer = new DefaultListCellRenderer() { @Override @@ -48,6 +55,7 @@ public class MobileBookMarkStylePane extends BasicBeanPane private void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.listModel = new DefaultListModel<>(); this.card = new CardLayout(); this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane(); @@ -79,14 +87,16 @@ public class MobileBookMarkStylePane extends BasicBeanPane } }); JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + leftPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); leftPanel.add(bookMarkList, BorderLayout.CENTER); - leftPanel.setPreferredSize(new Dimension(100, 500)); + leftPanel.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, LEFT_PANEL_HEIGHT)); this.add(leftPanel, BorderLayout.WEST); } private void initRightPanel() { JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - centerPane.setPreferredSize(new Dimension(500, 500)); + centerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + centerPane.setPreferredSize(new Dimension(RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT)); centerPane.add(rightPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER); } @@ -94,10 +104,12 @@ public class MobileBookMarkStylePane extends BasicBeanPane private List getMobileBookMarkStyleProvider() { DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider(); + SidebarMobileBookMarkStyleProvider sidebarMobileBookMarkStyleProvider = new SidebarMobileBookMarkStyleProvider(); Set mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray( MobileBookMarkStyleProvider.XML_TAG); List list = new ArrayList<>(); list.add(defaultMobileBookMarkStyleProvider); + list.add(sidebarMobileBookMarkStyleProvider); list.addAll(mobileBookMarkStyleProviders); return Collections.unmodifiableList(list); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java new file mode 100644 index 000000000..79bab33df --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java @@ -0,0 +1,387 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UnsignedIntUISpinner; +import com.fr.design.gui.style.FRFontPane; +import com.fr.design.gui.style.NumberDragBar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.form.ui.mobile.impl.SidebarMobileBookMarkStyle; +import com.fr.stable.CoreConstants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * @author Starryi + * @version 10.0 + * Created by Starryi on 2020/02/28 + */ +public class SidebarMobileBookMarkStyleCustomDefinePane extends BasicBeanPane { + private static final long serialVersionUID = 1L; + + private static final int COLUMN_WIDTH = 160; + + private UnsignedIntUISpinner buttonWidthSpinner; + private UnsignedIntUISpinner buttonHeightSpinner; + private UnsignedIntUISpinner buttonGapSpinner; + private UnsignedIntUISpinner buttonBorderRadiusSpinner; + + private ColorSelectBox normalBackgroundColorBox; + private NumberDragBar normalOpacityDragBar; + private UnsignedIntUISpinner normalOpacitySpinner; + private LineComboBox normalBorderWidthComBox; + private ColorSelectBox normalBorderColorBox; + private UIComboBox normalFontNameComboBox; + private UIComboBox normalFontSizeComboBox; + private UIColorButton normalFontColorButton; + private UIToggleButton normalFontItalicButton; + private UIToggleButton normalFontBoldButton; + + private ColorSelectBox selectedBackgroundColorBox; + private NumberDragBar selectedOpacityDragBar; + private UnsignedIntUISpinner selectedOpacitySpinner; + private LineComboBox selectedBorderWidthComBox; + private ColorSelectBox selectedBorderColorBox; + private UIComboBox selectedFontNameComboBox; + private UIComboBox selectedFontSizeComboBox; + private UIColorButton selectedFontColorButton; + private UIToggleButton selectedFontItalicButton; + private UIToggleButton selectedFontBoldButton; + + private SidebarMobileBookMarkStyle DEFAULT_STYLE = new SidebarMobileBookMarkStyle(); + + public SidebarMobileBookMarkStyleCustomDefinePane() { + this.initComponent(); + } + + private void initComponent() { + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + + this.add(this.createNavButtonStylePanel()); + this.add(this.createNormalStateStylePanel()); + this.add(this.createSelectedStateStylePanel()); + } + + private JPanel createNavButtonStylePanel() { + + buttonWidthSpinner = new UnsignedIntUISpinner(20, 150, 1, DEFAULT_STYLE.getWidth()); + buttonHeightSpinner = new UnsignedIntUISpinner(20, 100, 1, DEFAULT_STYLE.getHeight()); + buttonGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getGap()); + buttonBorderRadiusSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getBorderRadius()); + + UILabel sizeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Size") + ":", + SwingConstants.RIGHT); + JPanel sizePane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + sizePane.add(buttonWidthSpinner); + sizePane.add(buttonHeightSpinner); + + JPanel sizeTipsPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Width"), + SwingConstants.CENTER)); + sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Height"), + SwingConstants.CENTER)); + + UILabel gapLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Gap") + ":", + SwingConstants.RIGHT); + UILabel borderRadiusLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Border_Radius") + ":", + SwingConstants.RIGHT); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {p, COLUMN_WIDTH}; + double[] verticalGaps = {0, 10, 10}; + + JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{ + {sizeLabel, sizePane}, + {null, sizeTipsPane}, + {gapLabel, buttonGapSpinner}, + {borderRadiusLabel, buttonBorderRadiusSpinner}, + }, rowSize, columnSize, 5, verticalGaps); + + navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Style"), + Color.decode("#2F8EF1"))); + containerPane.add(navButtonSettingsPanel); + + return containerPane; + } + + private JPanel createNormalStateStylePanel() { + double p = TableLayout.PREFERRED; + + normalBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH); + normalBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getBackgroundColor()); + normalOpacityDragBar = new NumberDragBar(0, 100); + normalOpacityDragBar.setValue(DEFAULT_STYLE.getOpacity()); + normalOpacityDragBar.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + normalOpacitySpinner.setValue(normalOpacityDragBar.getValue()); + } + }); + normalOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getOpacity()); + normalOpacitySpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + normalOpacityDragBar.setValue((int) normalOpacitySpinner.getValue()); + } + }); + normalBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + normalBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getBorderWidth()); + normalBorderColorBox = new ColorSelectBox(COLUMN_WIDTH); + normalBorderColorBox.setSelectObject(DEFAULT_STYLE.getBorderColor()); + normalFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + normalFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily()); + normalFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + normalFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getFontSize()); + normalFontColorButton = new UIColorButton(); + normalFontColorButton.setColor(DEFAULT_STYLE.getFontColor()); + normalFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + normalFontItalicButton.setSelected(DEFAULT_STYLE.isFontItalic()); + normalFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + normalFontBoldButton.setSelected(DEFAULT_STYLE.isFontBold()); + + JPanel opacityPane = new JPanel(new BorderLayout(0, 0)); + JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + jp.add(normalOpacityDragBar); + jp.add(normalOpacitySpinner); + opacityPane.add(jp, BorderLayout.CENTER); + + JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{normalFontSizeComboBox, normalFontColorButton, normalFontItalicButton, normalFontBoldButton}}, + new double[]{p}, + new double[]{p, p, p, p}, + 0, 5 + ); + + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {p, COLUMN_WIDTH, p}; + + JPanel normalStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT), + normalBackgroundColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT), + opacityPane, + new UILabel("%") + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT), + normalBorderWidthComBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT), + normalBorderColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT), + normalFontNameComboBox, + fontExtraPane + } + }, rowSize, columnSize, 5, 10); + normalStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder( + GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Normal_Style"), + Color.decode("#2F8EF1")) + ); + containerPane.add(normalStateStyleSettingsPanel); + + return containerPane; + } + + private JPanel createSelectedStateStylePanel() { + double p = TableLayout.PREFERRED; + + selectedBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH); + selectedBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBackgroundColor()); + selectedOpacityDragBar = new NumberDragBar(0, 100); + selectedOpacityDragBar.setValue(DEFAULT_STYLE.getSelectedOpacity()); + selectedOpacityDragBar.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + selectedOpacitySpinner.setValue(selectedOpacityDragBar.getValue()); + } + }); + selectedOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getSelectedOpacity()); + selectedOpacitySpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + selectedOpacityDragBar.setValue((int) selectedOpacitySpinner.getValue()); + } + }); + selectedBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + selectedBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getSelectedBorderWidth()); + selectedBorderColorBox = new ColorSelectBox(COLUMN_WIDTH); + selectedBorderColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBorderColor()); + selectedFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + selectedFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily()); + selectedFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + selectedFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontSize()); + selectedFontColorButton = new UIColorButton(); + selectedFontColorButton.setColor(DEFAULT_STYLE.getSelectedFontColor()); + selectedFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + selectedFontItalicButton.setSelected(DEFAULT_STYLE.isSelectedFontItalic()); + selectedFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + selectedFontBoldButton.setSelected(DEFAULT_STYLE.isSelectedFontBold()); + + JPanel opacityPane = new JPanel(new BorderLayout(0, 0)); + JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + jp.add(selectedOpacityDragBar); + jp.add(selectedOpacitySpinner); + opacityPane.add(jp, BorderLayout.CENTER); + + JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{selectedFontSizeComboBox, selectedFontColorButton, selectedFontItalicButton, selectedFontBoldButton}}, + new double[]{p}, + new double[]{p, p, p, p}, + 0, 5 + ); + + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {p, COLUMN_WIDTH, p}; + + JPanel selectedStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT), + selectedBackgroundColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT), + opacityPane, + new UILabel("%") + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT), + selectedBorderWidthComBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT), + selectedBorderColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT), + selectedFontNameComboBox, + fontExtraPane + } + }, rowSize, columnSize, 5, 10); + selectedStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder( + GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Selected_Style"), + Color.decode("#2F8EF1")) + ); + containerPane.add(selectedStateStyleSettingsPanel); + + return containerPane; + } + + @Override + public void populateBean(MobileBookMarkStyle ob) { + SidebarMobileBookMarkStyle style = null; + if (ob instanceof SidebarMobileBookMarkStyle) { + style = (SidebarMobileBookMarkStyle) ob; + } + if (style == null) { + return; + } + + buttonWidthSpinner.setValue(style.getWidth()); + buttonHeightSpinner.setValue(style.getHeight()); + buttonGapSpinner.setValue(style.getGap()); + buttonBorderRadiusSpinner.setValue(style.getBorderRadius()); + + normalBackgroundColorBox.setSelectObject(style.getBackgroundColor()); + normalOpacityDragBar.setValue(style.getOpacity()); + normalOpacitySpinner.setValue(style.getOpacity()); + normalBorderWidthComBox.setSelectedLineStyle(style.getBorderWidth()); + normalBorderColorBox.setSelectObject(style.getBorderColor()); + normalFontNameComboBox.setSelectedItem(style.getFontFamily()); + normalFontSizeComboBox.setSelectedItem(style.getFontSize()); + normalFontColorButton.setColor(style.getFontColor()); + normalFontItalicButton.setSelected(style.isFontItalic()); + normalFontBoldButton.setSelected(style.isFontBold()); + + selectedBackgroundColorBox.setSelectObject(style.getSelectedBackgroundColor()); + selectedOpacityDragBar.setValue(style.getSelectedOpacity()); + selectedOpacitySpinner.setValue(style.getSelectedOpacity()); + selectedBorderWidthComBox.setSelectedLineStyle(style.getSelectedBorderWidth()); + selectedBorderColorBox.setSelectObject(style.getSelectedBorderColor()); + selectedFontNameComboBox.setSelectedItem(style.getSelectedFontFamily()); + selectedFontSizeComboBox.setSelectedItem(style.getSelectedFontSize()); + selectedFontColorButton.setColor(style.getSelectedFontColor()); + selectedFontItalicButton.setSelected(style.isSelectedFontItalic()); + selectedFontBoldButton.setSelected(style.isSelectedFontBold()); + } + + @Override + public MobileBookMarkStyle updateBean() { + SidebarMobileBookMarkStyle style = new SidebarMobileBookMarkStyle(); + + style.setWidth((int) buttonWidthSpinner.getValue()); + style.setHeight((int) buttonHeightSpinner.getValue()); + style.setGap((int) buttonGapSpinner.getValue()); + style.setBorderRadius((int) buttonBorderRadiusSpinner.getValue()); + + if (normalBackgroundColorBox.getSelectObject() != null) { + style.setBackgroundColor(normalBackgroundColorBox.getSelectObject()); + } + style.setOpacity((int) normalOpacitySpinner.getValue()); + style.setBorderWidth(normalBorderWidthComBox.getSelectedLineStyle()); + style.setBorderColor(normalBorderColorBox.getSelectObject()); + if (normalFontNameComboBox.getSelectedItem() != null) { + style.setFontFamily((String) normalFontNameComboBox.getSelectedItem()); + } + if (normalFontSizeComboBox.getSelectedItem() != null) { + style.setFontSize((Integer) normalFontSizeComboBox.getSelectedItem()); + } + style.setFontColor(normalFontColorButton.getColor()); + style.setFontItalic(normalFontItalicButton.isSelected()); + style.setFontBold(normalFontBoldButton.isSelected()); + + if (selectedBackgroundColorBox.getSelectObject() != null) { + style.setSelectedBackgroundColor(selectedBackgroundColorBox.getSelectObject()); + } + style.setSelectedOpacity((int) selectedOpacitySpinner.getValue()); + style.setSelectedBorderWidth(selectedBorderWidthComBox.getSelectedLineStyle()); + style.setSelectedBorderColor(selectedBorderColorBox.getSelectObject()); + if (selectedFontNameComboBox.getSelectedItem() != null) { + style.setSelectedFontFamily((String) selectedFontNameComboBox.getSelectedItem()); + } + if (selectedFontSizeComboBox.getSelectedItem() != null) { + style.setSelectedFontSize((Integer) selectedFontSizeComboBox.getSelectedItem()); + } + style.setSelectedFontColor(selectedFontColorButton.getColor()); + style.setSelectedFontItalic(selectedFontItalicButton.isSelected()); + style.setSelectedFontBold(selectedFontBoldButton.isSelected()); + + return style; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java new file mode 100644 index 000000000..7c9202f3f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileBookMarkStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.form.ui.mobile.impl.SidebarMobileBookMarkStyle; + +/** + * @author Starryi + * @version 10.0 + * Created by Starryi on 2020/02/28 + */ +public class SidebarMobileBookMarkStyleProvider extends AbstractMobileBookMarkStyleProvider { + + @Override + public Class classForMobileBookMarkStyle() { + return SidebarMobileBookMarkStyle.class; + } + + @Override + public Class> classForMobileBookMarkStyleAppearance() { + return SidebarMobileBookMarkStyleCustomDefinePane.class; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar"); + } +}