diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index bce63d642..f1758f068 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/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>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext();) { + for (Iterator>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext(); ) { List 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 entry = entryIt.next(); list.add(entry.getKey()); } - return list.toArray(new String[list.size()]); + return list.toArray(new String[0]); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java index 8c09eb303..29e704f48 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/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 dsNameChangedMap = new HashMap(); + private Map dsNameChangedMap = new HashMap<>(); public TableDataPaneListPane() { super(); @@ -43,11 +44,16 @@ 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(); + allListNames[editingIndex] = StringUtils.EMPTY; + Object editingType = getEditingType(); if (!BasicTableDataUtils.checkName(tempName)) { @@ -61,15 +67,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData isNamePermitted = false; nameableList.stopEditing(); FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), - Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"), - Toolkit.i18nText("Fine-Design_Report_Alert"), - JOptionPane.WARNING_MESSAGE); + Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"), + Toolkit.i18nText("Fine-Design_Report_Alert"), + JOptionPane.WARNING_MESSAGE); setIllegalIndex(editingIndex); 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 +86,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 +94,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 entry : dsNameChangedMap.entrySet()) { + if (StringUtils.equals(oldName, entry.getValue())) { + oldName = entry.getKey(); + } + } + dsNameChangedMap.put(oldName, newName); } @@ -148,7 +156,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData String[] allDsNames = DesignTableDataManager.getAllDSNames(source); // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. - int count = 1; + int count = 1; while (isDsNameRepeated(prefix + count, allDsNames)) { count++; } @@ -192,7 +200,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } } - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + populate(nameObjectList.toArray(new NameObject[0])); } /** @@ -209,10 +217,10 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } while (procedurenameIt.hasNext()) { String name = procedurenameIt.next(); - nameObjectList.add(new NameObject(name, ProcedureConfig.getInstance().getProcedure(name))); + 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 +228,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData tableDataConfig.removeAllTableData(); ProcedureConfig.getInstance().removeAllProcedure(); Nameable[] tableDataArray = this.update(); - Map tableDataMap = new LinkedHashMap(); + Map tableDataMap = new LinkedHashMap(); for (int i = 0; i < tableDataArray.length; i++) { NameObject nameObject = (NameObject) tableDataArray[i]; tableDataMap.put(nameObject.getName(), (TableData) nameObject.getObject()); diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java index 0d12772d3..76255d96b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java +++ b/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]); } /** diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java index 9ce63abe3..f806ded06 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java @@ -25,10 +25,20 @@ import com.fr.general.FRFont; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JFrame; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Vector; @@ -67,11 +77,20 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse private UIToggleButton subPane; private JPanel linePane; private int italic_bold; + /** + * LeftPane和RightPane之间的间隙,也是fontSizeStyleComboBox与fontSizeComboBox之间的间隙,之前的默认值为VGAP_LARGE + */ + private int hGapBetweenLeftPaneAndRightPane = LayoutConstants.VGAP_LARGE; public FRFontPane() { this.initComponents(); } + public FRFontPane(int hGapBetweenLeftPaneAndRightPane) { + this.hGapBetweenLeftPaneAndRightPane = hGapBetweenLeftPaneAndRightPane; + this.initComponents(); + } + public static void main(String[] args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -345,7 +364,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse private JPanel createPane() { JPanel createPane = new JPanel(new BorderLayout()); createPane.add(fontNameComboBox, BorderLayout.NORTH); - JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, hGapBetweenLeftPaneAndRightPane, LayoutConstants.VGAP_LARGE); jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); createPane.add(jPanel, BorderLayout.CENTER); return createPane; diff --git a/designer-base/src/main/java/com/fr/design/object/NameObject.java b/designer-base/src/main/java/com/fr/design/object/NameObject.java index 818de9d57..c7dc3811c 100644 --- a/designer-base/src/main/java/com/fr/design/object/NameObject.java +++ b/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 { 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; } diff --git a/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java b/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java new file mode 100644 index 000000000..b47ea8e95 --- /dev/null +++ b/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 dsNameChangedMap = listPane.getDsNameChangedMap(); + assertEquals(1, dsNameChangedMap.size()); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java index d4ebf74ee..1c30b1a55 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer; import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.foldablepane.UIExpandablePane; @@ -58,7 +59,8 @@ public class LabelDefinePane extends AbstractDataModify