Browse Source

Pull request #2554: REPORT-40969 数据集-数据库数据集-重命名有问题

Merge in DESIGN/design from ~YYMING/design:release/10.0 to release/10.0

* commit '0b10a2d7d813ed7d9ec3270d7bf0973069be50b8':
  REPORT-40969 数据集-数据库数据集-重命名有问题
feature/big-screen
Yyming 4 years ago
parent
commit
5de30963b1
  1. 16
      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

16
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* TableDataList Pane.
@ -49,8 +51,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
//说明双击之后又取消了,啥也不用做
return;
}
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
String[] allDSNames = DesignTableDataManager.getAllDSNames(source);
Set<String> allDSNames = DesignTableDataManager.getGlobalDataSet().keySet();
String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY;
@ -73,7 +74,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
setIllegalIndex(editingIndex);
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) {
isNamePermitted = false;
nameableList.stopEditing();
@ -98,10 +99,15 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
for (Map.Entry<String, String> entry : dsNameChangedMap.entrySet()) {
if (StringUtils.equals(oldName, entry.getValue())) {
oldName = entry.getKey();
break;
}
}
dsNameChangedMap.put(oldName, newName);
if (StringUtils.equals(oldName, newName)) {
//a -> b;b -> a,说明没改
dsNameChangedMap.remove(oldName);
} else {
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.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Collection;
public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider {
private static final String LIST_NAME = "JControl_List";
@ -190,9 +191,9 @@ public abstract class JListControlPane extends JControlPane implements ListContr
return getHelper().getSelectedName();
}
protected boolean isNameRepeated(java.util.List[] list, String name) {
for (int i = 0; i < list.length; i++) {
if (list[i].contains(name)) {
protected boolean isNameRepeated(Collection[] collections, String name) {
for (int i = 0; i < collections.length; i++) {
if (collections[i].contains(name)) {
isNameRepeated = 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");
Map<String, String> dsNameChangedMap = listPane.getDsNameChangedMap();
assertEquals(1, dsNameChangedMap.size());
listPane.rename("333","111");
assertEquals(0, dsNameChangedMap.size());
}
}
Loading…
Cancel
Save