Browse Source

Merge pull request #8559 in DESIGN/design from release/10.0 to final/10.0

* commit 'f501af9b0b0484b220a0fdc8ca25a89d101e7582':
  REPORT-69229 设计器偶发启动不了
  REPORT-68443 聚合报表报表块单元格也可以进行权限编辑
  REPORT-69009 mac新系统下getSelectedFiles方法返回为空
  updated
  REPORT-68607 数据连接全量保存改为增量保存
  REPORT-68161 填报-模板web属性-切换设置时,编辑行背景设置的点击逻辑确认
  REPORT-48999 填报-填报属性设置-填报属性快捷设置远程设计修改无效
final/10.0
superman 3 years ago
parent
commit
e6120fc112
  1. 53
      designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java
  2. 35
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  3. 4
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/SwingFileChooser.java
  4. 5
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  5. 57
      designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java
  6. 2
      designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java

53
designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java

@ -0,0 +1,53 @@
package com.fr.design.data;
import org.jetbrains.annotations.NotNull;
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 查找出相比origother中有哪些是新增的删除的或者被修改的并分别进行处理
*
* @param orig 原始map
* @param other 参考的新map
* @param eventHandler 有区别时的事件处理器
* @param <K> K
* @param <V> V
*/
public static <K, V> void contrastMapEntries(@NotNull Map<K, V> orig, @NotNull Map<K, V> other, @NotNull EventHandler<K, V> eventHandler) {
Map<K, V> 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<K, V> {
void on(EntryEventKind entryEventKind, K k, V v);
}
public enum EntryEventKind {
ADDED,
REMOVED,
UPDATED;
}
}

35
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<String, String> renameMap = new HashMap<String, String>();
private final HashMap<String, String> renameMap = new HashMap<>();
private final Map<String, Connection> populatedConnectionsSnapshot = new LinkedHashMap<>();
public ConnectionListPane() {
renameMap.clear();
@ -138,11 +142,16 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
*/
public void populate(ConnectionConfig connectionConfig) {
List<NameObject> nameObjectList = new ArrayList<NameObject>();
populatedConnectionsSnapshot.clear();
for (Map.Entry<String, Connection> 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<String, Connection> 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

4
designer-base/src/main/java/com/fr/design/gui/ifilechooser/SwingFileChooser.java

@ -32,7 +32,11 @@ class SwingFileChooser implements FileChooserProvider {
@Override
public File[] getSelectedFiles() {
if (ArrayUtils.isNotEmpty(fileChooser.getSelectedFiles())) {
return fileChooser.getSelectedFiles();
} else {
return new File[]{fileChooser.getSelectedFile()};
}
}
@Override

5
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) {
// 捕获下异常 避免造成启动过程监听触发异常导致设计器闪退
try {
listener.designerOpened();
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
designerOpened = true;

57
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<String, String> orig = new LinkedHashMap<>();
orig.put("aaa", "aaa");
orig.put("bbb", "bbb");
orig.put("ccc", "ccc");
orig.put("ddd", "ddd");
Map<String, String> 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<String, String>() {
@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();
}
}
});
}
}

2
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()) {

Loading…
Cancel
Save