From 8a5bf2b69d6a1d3819f5f8448f1bec87891ef933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 10 Sep 2021 14:20:27 +0800 Subject: [PATCH 1/2] fix conflict --- .../gui/controlpane/JListControlPane.java | 4 +- .../com/fr/design/gui/ilist/JNameEdList.java | 23 ++++---- .../design/module/ChartPreStyleListPane.java | 54 ++++++++++++++++++- 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index f119c55cd..82cba758b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -23,12 +23,12 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.util.Collection; import java.awt.BorderLayout; 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"; @@ -335,7 +335,7 @@ public abstract class JListControlPane extends JControlPane implements ListContr getHelper().checkButtonEnabled(); } - private class NameableListCellRenderer extends + protected class NameableListCellRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java index 0efa74cec..4c530c0fc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java @@ -1,25 +1,22 @@ package com.fr.design.gui.ilist; import com.fr.design.gui.NameInspector; +import com.fr.design.gui.itextfield.UITextField; import com.fr.general.GeneralUtils; import com.fr.general.NameObject; -import com.fr.base.Utils; -import com.fr.design.gui.itextfield.UITextField; - import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.*; +import javax.swing.ListModel; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; -import java.awt.*; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Vector; +import java.awt.Component; +import java.awt.Rectangle; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; public class JNameEdList extends UIList implements CellEditorListener { private static final int ICON_WIDTH = 20; @@ -38,6 +35,8 @@ public class JNameEdList extends UIList implements CellEditorListener { */ private String oldName; + private boolean replaceEmptyName = true; + public JNameEdList(ListModel dataModel) { super(dataModel); } @@ -70,6 +69,10 @@ public class JNameEdList extends UIList implements CellEditorListener { return this.editable; } + public void setReplaceEmptyName(boolean replaceEmptyName) { + this.replaceEmptyName = replaceEmptyName; + } + public void setNameShouldNumber(boolean isNameShouldNumber) { this.isNameShouldNumber = isNameShouldNumber; } @@ -301,7 +304,7 @@ public class JNameEdList extends UIList implements CellEditorListener { ListCellEditor editor = getCellEditor(); if (editor != null && editorComp != null) { Object value = editor.getCellEditorValue(); - String name = StringUtils.isBlank(value.toString()) ? oldName : value.toString(); + String name = StringUtils.isBlank(value.toString()) && replaceEmptyName ? oldName : value.toString(); setNameAt(name, editingIndex); removeComp(); doAfterStopEditing(); diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java index 433c7dfd0..906e11784 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java @@ -4,16 +4,28 @@ import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; import com.fr.base.Utils; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ShortCut4JControlPane; + +import com.fr.design.gui.ilist.JNameEdList; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.i18n.Toolkit; import com.fr.design.menu.ShortCut; +import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; - +import com.fr.stable.StringUtils; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; /** * @author Bjorn @@ -22,6 +34,46 @@ import java.util.Iterator; */ public class ChartPreStyleListPane extends JListControlPane { + ChartPreStyleManagerPane chartPreStyleManagerPane; + + public ChartPreStyleListPane(ChartPreStyleManagerPane chartPreStyleManagerPane) { + super(); + this.chartPreStyleManagerPane = chartPreStyleManagerPane; + initListener(); + addModNameActionListener((int index, String oldName, String newName) -> { + if (ComparatorUtils.equals(oldName, newName)) { + return; + } + String[] allNames = nameableList.getAllNames(); + allNames[index] = StringUtils.EMPTY; + if (StringUtils.isEmpty(newName)) { + showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Empty_Name_Tip")); + nameableList.setNameAt(oldName, index); + return; + } + if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) { + showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Exist_Name_Tip", newName)); + nameableList.setNameAt(oldName, index); + return; + } + populateSelectedValue(); + }); + } + + private void showTipDialog(String content) { + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ChartPreStyleListPane.this), + content, + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + } + + @Override + protected JNameEdList createJNameList() { + JNameEdList jNameList = super.createJNameList(); + jNameList.setReplaceEmptyName(false); + return jNameList; + } + /** * 创建有名字的creator * From 9ba583990f806bdba2cee7c8e4cb83e13053fa01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 10 Sep 2021 14:31:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/gui/controlpane/JListControlPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index 82cba758b..2955801f7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -335,7 +335,7 @@ public abstract class JListControlPane extends JControlPane implements ListContr getHelper().checkButtonEnabled(); } - protected class NameableListCellRenderer extends + private class NameableListCellRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value,