Browse Source

REPORT-27998 bugfix

feature/big-screen
Java.Edge 5 years ago
parent
commit
9a68b44324
  1. 19
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java
  2. 35
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

19
designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java

@ -183,29 +183,12 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) {
try {
return new NameObject(this.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance());
return new NameObject(helper.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public String createUnrepeatedName(String prefix) {
int count = 1;
while (isDsNameRepeated(prefix + count)) {
count++;
}
return prefix + count;
}
private boolean isDsNameRepeated(String name) {
if (allDSNames == null) {
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
allDSNames = DesignTableDataManager.getAllDSNames(source);
}
return ArrayUtils.contains(allDSNames, name);
}
@Override
public int hashCode() {
return menuName == null ? 0 : menuName.hashCode();

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

@ -14,6 +14,7 @@ import com.fr.file.ProcedureConfig;
import com.fr.file.TableDataConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
@ -133,36 +134,28 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
return super.createUnrepeatedName(prefix);
}
String[] allDsNames = DesignTableDataManager.getAllDSNames(source);
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = 1;
while (isDsNameRepeated(prefix + count, allDsNames)) {
count++;
}
return prefix + count;
}
private boolean isDsNameRepeated(String name, String[] allDsNames) {
DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) {
all[i] = ((ListModelElement) model.get(i)).wrapper;
}
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = all.length + 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) {
repeated = true;
break;
if (ComparatorUtils.equals(nameable.getName(), name)) {
return true;
}
}
for (String dsname : allDsNames) {
if (ComparatorUtils.equals(dsname, name_test)) {
repeated = true;
break;
}
}
if (!repeated) {
return name_test;
}
count++;
}
return ArrayUtils.contains(allDsNames, name);
}
@Override

Loading…
Cancel
Save