From 978a2177746a8fc255128df991fa534ab49c4aa7 Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 29 Sep 2020 09:53:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-40216=20=E6=95=B0=E6=8D=AE=E9=9B=86-?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE=E9=9B=86-?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E6=95=B0=E6=8D=AE=E9=9B=86=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=90=8D=E7=A7=B0=E5=90=8E=EF=BC=8C=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E4=B8=AD=E7=9A=84=E5=8E=9F=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E8=87=AA=E5=8A=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 5 +- .../data/datapane/TableDataPaneListPane.java | 46 +++++++++++-------- .../controlpane/ListControlPaneHelper.java | 2 +- .../java/com/fr/design/object/NameObject.java | 5 +- .../datapane/TableDataPaneListPaneTest.java | 24 ++++++++++ 5 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java 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..df4a3911b 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,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; } @@ -61,15 +68,15 @@ 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); + 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 entry : dsNameChangedMap.entrySet()) { + if (StringUtils.equals(oldName, entry.getValue())) { + oldName = entry.getKey(); + } + } + dsNameChangedMap.put(oldName, newName); } @@ -148,7 +158,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 +202,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } } - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + populate(nameObjectList.toArray(new NameObject[0])); } /** @@ -209,10 +219,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 +230,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/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 From d3d2482a94b6062f60be2d36ee7ff3c871442944 Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 29 Sep 2020 10:05:59 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-40216=20=E7=94=A8=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E7=9A=84=E4=B8=8B=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/data/datapane/TableDataPaneListPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 df4a3911b..d7efbcce3 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 @@ -52,7 +52,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); String[] allDSNames = DesignTableDataManager.getAllDSNames(source); String[] allListNames = nameableList.getAllNames(); - allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; + allListNames[editingIndex] = StringUtils.EMPTY; Object editingType = getEditingType(); From 31214d65ac51dac489a9571e77c8af947a7a3a05 Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 29 Sep 2020 16:02:38 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-40216=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/data/datapane/TableDataPaneListPane.java | 2 -- 1 file changed, 2 deletions(-) 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 d7efbcce3..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 @@ -60,7 +60,6 @@ public class TableDataPaneListPane extends JListControlPane implements TableData isNamePermitted = false; nameableList.stopEditing(); setIllegalIndex(editingIndex); - rename(selectedName, NameInspector.ILLEGAL_NAME_HOLDER); return; } @@ -72,7 +71,6 @@ 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; } boolean isRepeated = isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName); From 816bb760e239d85a99c7dd3719edd85c16f37480 Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 9 Oct 2020 15:36:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-38514=20=E6=A0=87=E7=AD=BE=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=B1=9E=E6=80=A7=E7=95=8C=E9=9D=A2-?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E6=98=BE=E7=A4=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E3=80=91=E6=A0=87=E7=AD=BE=E5=B1=9E=E6=80=A7=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E8=B7=9F=E5=AD=97=E4=BD=93=E6=9C=89=E5=85=B3=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E5=9D=97=E7=94=B1FRFontPane=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E8=BF=99=E4=B8=AA=E7=95=8C=E9=9D=A2=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E7=9A=84fontSizeComboBox?= =?UTF-8?q?=E4=BC=9A=E5=B0=86=E6=8E=A5=E6=94=B6=E5=88=B0=E7=9A=84=E5=80=BC?= =?UTF-8?q?=E8=BD=AC=E5=8C=96=E4=B8=BA=E6=B5=AE=E7=82=B9=E6=95=B0=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E6=95=B4=E6=95=B0=EF=BC=8C=E5=8F=98=E6=88=90?= =?UTF-8?q?=E6=B5=AE=E7=82=B9=E6=95=B0=E4=B9=8B=E5=90=8E=E4=BC=9A=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF?= =?UTF-8?q?=E3=80=9117=E5=B9=B4Momeak=E7=9A=84=E4=B8=80=E4=B8=AA=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=EF=BC=88=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=89?= =?UTF-8?q?=E5=B0=86=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E4=BB=8E=E6=95=B4?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=B5=AE=E7=82=B9=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E8=80=83=E8=99=91=E5=88=B0=E8=BF=99=E4=B8=80=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E9=87=87=E5=8F=96=E6=94=B9=E5=9B=9E=E6=95=B4?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E4=BF=AE=E6=94=B9=E6=96=B9=E6=A1=88=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E6=98=AF=E5=B0=86fontSizeComboBox=E4=B8=8E=E5=89=8D?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=BB=84=E4=BB=B6=E4=B9=8B=E9=97=B4=E7=9A=84?= =?UTF-8?q?=E9=97=B4=E9=9A=99=E5=87=8F=E5=B0=8F=EF=BC=8CTableLayout?= =?UTF-8?q?=E4=B8=8BfontSizeComboBox=E5=B0=B1=E4=BC=9A=E8=A2=AB=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8B=89=E9=95=BF=EF=BC=8C=E6=8B=89=E9=95=BF=E5=90=8E?= =?UTF-8?q?=E8=83=BD=E5=A4=9F=E5=AE=8C=E6=95=B4=E6=98=BE=E7=A4=BA=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E5=A4=A7=E5=B0=8F=EF=BC=8C=E6=94=B9=E5=8A=A8=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E5=B7=B2=E7=BB=8F=E9=80=9A=E8=BF=87=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/style/FRFontPane.java | 25 ++++++++++++++++--- .../widget/ui/designer/LabelDefinePane.java | 4 ++- 2 files changed, 25 insertions(+), 4 deletions(-) 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-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