Browse Source

REPORT-40969 数据集-数据库数据集-重命名有问题

feature/big-screen
Yyming 4 years ago
parent
commit
0b10a2d7d8
  1. 14
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  2. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  3. 2
      designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java

14
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -24,11 +24,13 @@ import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* TableDataList Pane. * TableDataList Pane.
@ -49,8 +51,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
//说明双击之后又取消了,啥也不用做 //说明双击之后又取消了,啥也不用做
return; return;
} }
TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); Set<String> allDSNames = DesignTableDataManager.getGlobalDataSet().keySet();
String[] allDSNames = DesignTableDataManager.getAllDSNames(source);
String[] allListNames = nameableList.getAllNames(); String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY; allListNames[editingIndex] = StringUtils.EMPTY;
@ -73,7 +74,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
setIllegalIndex(editingIndex); setIllegalIndex(editingIndex);
return; return;
} }
boolean isRepeated = isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName); boolean isRepeated = isNameRepeated(new Collection[]{allDSNames, Arrays.asList(allListNames)}, tempName);
if (isRepeated) { if (isRepeated) {
isNamePermitted = false; isNamePermitted = false;
nameableList.stopEditing(); nameableList.stopEditing();
@ -98,11 +99,16 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
for (Map.Entry<String, String> entry : dsNameChangedMap.entrySet()) { for (Map.Entry<String, String> entry : dsNameChangedMap.entrySet()) {
if (StringUtils.equals(oldName, entry.getValue())) { if (StringUtils.equals(oldName, entry.getValue())) {
oldName = entry.getKey(); oldName = entry.getKey();
break;
} }
} }
if (StringUtils.equals(oldName, newName)) {
//a -> b;b -> a,说明没改
dsNameChangedMap.remove(oldName);
} else {
dsNameChangedMap.put(oldName, newName); dsNameChangedMap.put(oldName, newName);
} }
}
/** /**
* 名字是否允许 * 名字是否允许

7
designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java

@ -27,6 +27,7 @@ import java.awt.Component;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.Collection;
public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider { public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider {
private static final String LIST_NAME = "JControl_List"; private static final String LIST_NAME = "JControl_List";
@ -190,9 +191,9 @@ public abstract class JListControlPane extends JControlPane implements ListContr
return getHelper().getSelectedName(); return getHelper().getSelectedName();
} }
protected boolean isNameRepeated(java.util.List[] list, String name) { protected boolean isNameRepeated(Collection[] collections, String name) {
for (int i = 0; i < list.length; i++) { for (int i = 0; i < collections.length; i++) {
if (list[i].contains(name)) { if (collections[i].contains(name)) {
isNameRepeated = true; isNameRepeated = true;
return true; return true;
} }

2
designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java

@ -20,5 +20,7 @@ public class TableDataPaneListPaneTest {
listPane.rename("222", "333"); listPane.rename("222", "333");
Map<String, String> dsNameChangedMap = listPane.getDsNameChangedMap(); Map<String, String> dsNameChangedMap = listPane.getDsNameChangedMap();
assertEquals(1, dsNameChangedMap.size()); assertEquals(1, dsNameChangedMap.size());
listPane.rename("333","111");
assertEquals(0, dsNameChangedMap.size());
} }
} }
Loading…
Cancel
Save