From 1484cfcbac7d81be4fc09d03dc8898c8f8d381f2 Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 10 Mar 2021 18:06:56 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-48999=20=E5=A1=AB=E6=8A=A5-=E5=A1=AB?= =?UTF-8?q?=E6=8A=A5=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE-=E5=A1=AB?= =?UTF-8?q?=E6=8A=A5=E5=B1=9E=E6=80=A7=E5=BF=AB=E6=8D=B7=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E4=BF=AE=E6=94=B9=E6=97=A0?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/report/WriteShortCutsPane.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/WriteShortCutsPane.java b/designer-realize/src/main/java/com/fr/design/report/WriteShortCutsPane.java index 8cf891b92..f48061d33 100644 --- a/designer-realize/src/main/java/com/fr/design/report/WriteShortCutsPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/WriteShortCutsPane.java @@ -8,6 +8,8 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.general.ComparatorUtils; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerAdaptor; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -140,7 +142,13 @@ public class WriteShortCutsPane extends JPanel{ nextRowString = temp; switchColRow(); - ServerPreferenceConfig.getInstance().setWriteShortCuts(ComparatorUtils.equals(nextColString, "Tab")); + Configurations.update(new WorkerAdaptor(ServerPreferenceConfig.class) { + + @Override + public void run() { + ServerPreferenceConfig.getInstance().setWriteShortCuts(ComparatorUtils.equals(nextColString, "Tab")); + } + }); } }; From b0e298f3cd314db63a0124b64b035734a0b63282 Mon Sep 17 00:00:00 2001 From: lucian Date: Thu, 24 Mar 2022 09:44:46 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-68161=20=E5=A1=AB=E6=8A=A5-=E6=A8=A1?= =?UTF-8?q?=E6=9D=BFweb=E5=B1=9E=E6=80=A7-=E5=88=87=E6=8D=A2=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=EF=BC=8C=E7=BC=96=E8=BE=91=E8=A1=8C=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=AE=BE=E7=BD=AE=E7=9A=84=E7=82=B9=E5=87=BB=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/webattr/WriteToolBarPane.java | 1 + .../main/java/com/fr/design/webattr/WriteWebSettingPane.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java index 25ba62708..cdf4f206b 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java @@ -160,6 +160,7 @@ public class WriteToolBarPane extends AbstractEditToolBarPane { colorButton.setColor(webWrite.getSelectedColor()); } else { colorBox.setSelected(false); + colorButton.setEnabled(false); } if (webWrite.getSheetPosition() == Constants.TOP) { diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java index 6636c2214..dd93281ac 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java @@ -108,6 +108,7 @@ public class WriteWebSettingPane extends WebSettingPane { protected void setDefault() { super.setDefault(); colorBox.setSelected(false); + colorButton.setEnabled(false); bottomRadioButton.setSelected(true); leftRadioButton.setSelected(true); unloadCheck.setSelected(true); @@ -125,6 +126,7 @@ public class WriteWebSettingPane extends WebSettingPane { colorButton.setColor(webWrite.getSelectedColor()); } else { colorBox.setSelected(false); + colorButton.setEnabled(false); } if (webWrite.getSheetPosition() == Constants.TOP) { From f746d3b29939f847e7d2e3b9b8fdc31eef2ed710 Mon Sep 17 00:00:00 2001 From: rinoux Date: Mon, 28 Mar 2022 16:06:07 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-68607=20=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=85=A8=E9=87=8F=E4=BF=9D=E5=AD=98=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=A2=9E=E9=87=8F=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/data/MapCompareUtils.java | 51 +++++++++++++++++++ .../datapane/connect/ConnectionListPane.java | 37 ++++++++++---- 2 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java diff --git a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java new file mode 100644 index 000000000..0d7bc6b44 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java @@ -0,0 +1,51 @@ +package com.fr.design.data; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author rinoux + * @version 10.0 + * Created by rinoux on 2022/3/28 + */ +public final class MapCompareUtils { + + + /** + * 对比两个map 查找出相比orig,other中有哪些是新增的、删除的或者被修改的,并分别进行处理 + * + * @param orig 原始map + * @param other 参考的新map + * @param eventHandler 有区别时的事件处理器 + * @param K + * @param V + */ + public static void contrastMapEntries(Map orig, Map other, EventHandler eventHandler) { + + Map copiedOrig = new LinkedHashMap<>(orig); + + other.forEach((k, v) -> { + V existedV = copiedOrig.remove(k); + if (existedV != null) { + if (!v.equals(existedV)) { + eventHandler.on(EntryEventKind.UPDATED, k, v); + } + } else { + eventHandler.on(EntryEventKind.ADDED, k, v); + } + }); + + copiedOrig.forEach((k, v) -> eventHandler.on(EntryEventKind.REMOVED, k, v)); + } + + + public interface EventHandler { + void on(EntryEventKind entryEventKind, K k, V v); + } + + public enum EntryEventKind { + ADDED, + REMOVED, + UPDATED; + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index daa408ab6..c0d23ed46 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -4,6 +4,7 @@ import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.data.MapCompareUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.fun.ConnectionProvider; import com.fr.design.gui.controlpane.JListControlPane; @@ -14,6 +15,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.file.ConnectionConfig; import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; +import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; @@ -23,6 +25,7 @@ import javax.swing.SwingUtilities; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -34,7 +37,8 @@ import java.util.UUID; public class ConnectionListPane extends JListControlPane implements ConnectionShowPane { public static final String TITLE_NAME = Toolkit.i18nText("Fine-Design_Basic_Server_Define_Data_Connection"); private boolean isNamePermitted = true; - private HashMap renameMap = new HashMap(); + private final HashMap renameMap = new HashMap<>(); + private final Map populatedConnectionsSnapshot = new LinkedHashMap<>(); public ConnectionListPane() { renameMap.clear(); @@ -138,11 +142,16 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh */ public void populate(ConnectionConfig connectionConfig) { List nameObjectList = new ArrayList(); + populatedConnectionsSnapshot.clear(); for (Map.Entry entry : connectionConfig.getConnections().entrySet()) { nameObjectList.add(new NameObject(entry.getKey(), entry.getValue())); + try { + populatedConnectionsSnapshot.put(entry.getKey(), (Connection) entry.getValue().clone()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } } this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); - } /** @@ -151,15 +160,21 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh public void update(ConnectionConfig connectionConfig) { // Nameable[]居然不能强转成NameObject[],一定要这么写... Nameable[] res = this.update(); - NameObject[] res_array = new NameObject[res.length]; - java.util.Arrays.asList(res).toArray(res_array); - - connectionConfig.removeAllConnection(); - - for (int i = 0; i < res_array.length; i++) { - NameObject nameObject = res_array[i]; - connectionConfig.addConnection(nameObject.getName(), (Connection) nameObject.getObject()); - } + Map updatedMap = new LinkedHashMap<>(); + Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> updatedMap.put(no.getName(), (Connection) no.getObject())); + + MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { + switch (entryEventKind) { + case REMOVED: + connectionConfig.removeConnection(s); + break; + case ADDED: + case UPDATED: + connectionConfig.addConnection(s, connection); + default: + break; + } + }); } @Override From 24f93e7d99efab056e834e30c91890bb2680b885 Mon Sep 17 00:00:00 2001 From: rinoux Date: Mon, 28 Mar 2022 16:13:43 +0800 Subject: [PATCH 4/7] updated --- .../com/fr/design/data/MapCompareUtils.java | 4 +- .../fr/design/data/MapCompareUtilsTest.java | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java diff --git a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java index 0d7bc6b44..f7492aefc 100644 --- a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java +++ b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java @@ -1,5 +1,7 @@ package com.fr.design.data; +import org.jetbrains.annotations.NotNull; + import java.util.LinkedHashMap; import java.util.Map; @@ -20,7 +22,7 @@ public final class MapCompareUtils { * @param K * @param V */ - public static void contrastMapEntries(Map orig, Map other, EventHandler eventHandler) { + public static void contrastMapEntries(@NotNull Map orig, @NotNull Map other, @NotNull EventHandler eventHandler) { Map copiedOrig = new LinkedHashMap<>(orig); diff --git a/designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java b/designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java new file mode 100644 index 000000000..1f1e60e2b --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java @@ -0,0 +1,57 @@ +package com.fr.design.data; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author rinoux + * @version 10.0 + * Created by rinoux on 2022/3/28 + */ +public class MapCompareUtilsTest { + + @Test + public void contrastMapEntries() { + + + Map orig = new LinkedHashMap<>(); + + orig.put("aaa", "aaa"); + orig.put("bbb", "bbb"); + orig.put("ccc", "ccc"); + orig.put("ddd", "ddd"); + + + Map other = new LinkedHashMap<>(); + + other.put("aaa", "111"); + other.put("bbb", "bbb"); + other.put("ccc", "ccc"); + other.put("eee", "eee"); + + + MapCompareUtils.contrastMapEntries(orig, other, new MapCompareUtils.EventHandler() { + @Override + public void on(MapCompareUtils.EntryEventKind entryEventKind, String s, String s2) { + switch (entryEventKind) { + case UPDATED: + Assert.assertEquals(s, "aaa"); + Assert.assertEquals(s2, "111"); + break; + case REMOVED: + Assert.assertEquals(s, "ddd"); + break; + case ADDED: + Assert.assertEquals(s, "eee"); + Assert.assertEquals(s2, "eee"); + break; + default: + Assert.fail(); + } + } + }); + } +} \ No newline at end of file From d4c4c857965f918e62cce3afd8f8642610ed58e9 Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 2 Apr 2022 13:10:04 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-69009=20mac=E6=96=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=8BgetSelectedFiles=E6=96=B9=E6=B3=95=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ifilechooser/SwingFileChooser.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/SwingFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/SwingFileChooser.java index 942c3430c..47abaa8b6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/SwingFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/SwingFileChooser.java @@ -32,7 +32,11 @@ class SwingFileChooser implements FileChooserProvider { @Override public File[] getSelectedFiles() { - return fileChooser.getSelectedFiles(); + if (ArrayUtils.isNotEmpty(fileChooser.getSelectedFiles())) { + return fileChooser.getSelectedFiles(); + } else { + return new File[]{fileChooser.getSelectedFile()}; + } } @Override From 5bf9bfa9743f7c3bffad75ad60776a8d5c8dad82 Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 2 Apr 2022 17:34:03 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-68443=20=E8=81=9A=E5=90=88=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E6=8A=A5=E8=A1=A8=E5=9D=97=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E4=B9=9F=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/poly/creator/ECBlockPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java b/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java index bbf91f640..7ec7d1a6d 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java @@ -56,7 +56,7 @@ public class ECBlockPane extends PolyElementCasePane { @Override public void selectionChanged(SelectionEvent e) { - if (!isEditable() && !DesignModeContext.isAuthorityEditing()) { + if (!isEditable()) { return; } if (DesignModeContext.isAuthorityEditing()) { From 85dc33334e6009f491ebf6336833ddbd2d5d81be Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 6 Apr 2022 16:13:38 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-69229=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=81=B6=E5=8F=91=E5=90=AF=E5=8A=A8=E4=B8=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/DesignerFrame.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 798441c53..86e64d2ed 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -356,7 +356,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void fireDesignerOpened() { for (DesignerOpenedListener listener : designerOpenedListenerList) { - listener.designerOpened(); + // 捕获下异常 避免造成启动过程监听触发异常导致设计器闪退 + try { + listener.designerOpened(); + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } } designerOpened = true;