Browse Source

REPORT-40216 数据集-数据库数据集-复制数据集并修改名称后,单元格中的原数据集会被自动修改

feature/big-screen
Yyming 4 years ago
parent
commit
978a217774
  1. 5
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 36
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java
  4. 5
      designer-base/src/main/java/com/fr/design/object/NameObject.java
  5. 24
      designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java

5
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -97,7 +97,7 @@ public abstract class DesignTableDataManager {
*/
private static void fireDsChanged() {
fireDsChanged(globalDsListeners);
for (Iterator<Entry<String, List<ChangeListener>>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext();) {
for (Iterator<Entry<String, List<ChangeListener>>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext(); ) {
List<ChangeListener> dsListeners = entryIterator.next().getValue();
fireDsChanged(dsListeners);
}
@ -190,6 +190,7 @@ public abstract class DesignTableDataManager {
}
dsListeners.add(l);
}
/**
* 获取数据源source中dsName的所有字段
*
@ -280,7 +281,7 @@ public abstract class DesignTableDataManager {
Entry<String, TableDataWrapper> entry = entryIt.next();
list.add(entry.getKey());
}
return list.toArray(new String[list.size()]);
return list.toArray(new String[0]);
}
/**

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

@ -7,6 +7,7 @@ import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ilist.ListModelElement;
@ -34,7 +35,7 @@ import java.util.Map;
*/
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController {
private boolean isNamePermitted = true;
private Map<String, String> dsNameChangedMap = new HashMap<String, String>();
private Map<String, String> dsNameChangedMap = new HashMap<>();
public TableDataPaneListPane() {
super();
@ -43,17 +44,23 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override
public void propertyChange() {
isNamePermitted = true;
String tempName = getEditingName();
if (ComparatorUtils.equals(tempName, selectedName)) {
//说明双击之后又取消了,啥也不用做
return;
}
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
String[] allDSNames = DesignTableDataManager.getAllDSNames(source);
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
Object editingType = getEditingType();
if (!BasicTableDataUtils.checkName(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
setIllegalIndex(editingIndex);
rename(selectedName, NameInspector.ILLEGAL_NAME_HOLDER);
return;
}
@ -65,11 +72,11 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
Toolkit.i18nText("Fine-Design_Report_Alert"),
JOptionPane.WARNING_MESSAGE);
setIllegalIndex(editingIndex);
rename(selectedName, NameInspector.ILLEGAL_NAME_HOLDER);
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
boolean isRepeated = isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName);
if (isRepeated) {
isNamePermitted = false;
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", tempName));
@ -81,11 +88,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
setIllegalIndex(editingIndex);
}
if (nameableList.getSelectedValue() instanceof ListModelElement) {
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper;
if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
rename(selected.getName(), tempName);
}
rename(selectedName, isRepeated ? NameInspector.ILLEGAL_NAME_HOLDER : tempName);
}
}
});
@ -93,6 +96,13 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override
public void rename(String oldName, String newName) {
//如果a改成了b,b又被改成了c,就认为是a改成了c
for (Map.Entry<String, String> entry : dsNameChangedMap.entrySet()) {
if (StringUtils.equals(oldName, entry.getValue())) {
oldName = entry.getKey();
}
}
dsNameChangedMap.put(oldName, newName);
}
@ -192,7 +202,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
}
}
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
populate(nameObjectList.toArray(new NameObject[0]));
}
/**
@ -212,7 +222,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
nameObjectList.add(new NameObject(name, ProcedureConfig.getInstance().getProcedure(name)));
}
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
populate(nameObjectList.toArray(new NameObject[0]));
}
@Override
@ -220,7 +230,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
tableDataConfig.removeAllTableData();
ProcedureConfig.getInstance().removeAllProcedure();
Nameable[] tableDataArray = this.update();
Map<String,TableData> tableDataMap = new LinkedHashMap<String,TableData>();
Map<String, TableData> tableDataMap = new LinkedHashMap<String, TableData>();
for (int i = 0; i < tableDataArray.length; i++) {
NameObject nameObject = (NameObject) tableDataArray[i];
tableDataMap.put(nameObject.getName(), (TableData) nameObject.getObject());

2
designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java

@ -65,7 +65,7 @@ class ListControlPaneHelper {
res.add(((ListModelElement) listModel.getElementAt(i)).wrapper);
}
return res.toArray(new Nameable[res.size()]);
return res.toArray(new Nameable[0]);
}
/**

5
designer-base/src/main/java/com/fr/design/object/NameObject.java

@ -2,6 +2,7 @@ package com.fr.design.object;
import com.fr.base.BaseUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils;
/**
*
@ -60,10 +61,10 @@ public class NameObject<T> {
return "Name:" + this.getName() + "\tObject:" + this.getObject();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({ "rawtypes"})
public Object clone() throws CloneNotSupportedException {
NameObject newNameObject = (NameObject)super.clone();
newNameObject.object = BaseUtils.cloneObject(this.object);
newNameObject.object = StableUtils.cloneObject(this.object);
return newNameObject;
}

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

@ -0,0 +1,24 @@
package com.fr.design.data.datapane;
import org.junit.Test;
import java.util.Map;
import static org.junit.Assert.*;
/**
* @author Yyming
* @version 10.0
* Created by Yyming on 2020/9/29
*/
public class TableDataPaneListPaneTest {
@Test
public void rename() {
TableDataPaneListPane listPane = new TableDataPaneListPane();
listPane.rename("111", "222");
listPane.rename("222", "333");
Map<String, String> dsNameChangedMap = listPane.getDsNameChangedMap();
assertEquals(1, dsNameChangedMap.size());
}
}
Loading…
Cancel
Save