Browse Source

Pull request #5865: CHART-20642 图表预定义配色避免重名和空字符串名

Merge in DESIGN/design from ~BJORN/design:release/10.0 to release/10.0

* commit 'e999e3d776d25067396dc5c84091e0208f4e94e4':
  CHART-20642 图表预定义配色避免重名和空字符串名
zheng-1641779399395
Bjorn 3 years ago
parent
commit
4b54400f28
  1. 4
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  2. 23
      designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java
  3. 41
      designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java

4
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.SwingUtilities;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.util.Collection;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.Collection;
public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider { public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider {
private static final String LIST_NAME = "JControl_List"; private static final String LIST_NAME = "JControl_List";
@ -335,7 +335,7 @@ public abstract class JListControlPane extends JControlPane implements ListContr
getHelper().checkButtonEnabled(); getHelper().checkButtonEnabled();
} }
private class NameableListCellRenderer extends protected class NameableListCellRenderer extends
DefaultListCellRenderer { DefaultListCellRenderer {
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, public Component getListCellRendererComponent(JList list, Object value,

23
designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java

@ -1,25 +1,22 @@
package com.fr.design.gui.ilist; package com.fr.design.gui.ilist;
import com.fr.design.gui.NameInspector; import com.fr.design.gui.NameInspector;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.NameObject; 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.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.ListModel;
import javax.swing.event.CellEditorListener; import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent; 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.ArrayList;
import java.util.Vector; 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 { public class JNameEdList extends UIList implements CellEditorListener {
private static final int ICON_WIDTH = 20; private static final int ICON_WIDTH = 20;
@ -38,6 +35,8 @@ public class JNameEdList extends UIList implements CellEditorListener {
*/ */
private String oldName; private String oldName;
private boolean replaceEmptyName = true;
public JNameEdList(ListModel dataModel) { public JNameEdList(ListModel dataModel) {
super(dataModel); super(dataModel);
} }
@ -70,6 +69,10 @@ public class JNameEdList extends UIList implements CellEditorListener {
return this.editable; return this.editable;
} }
public void setReplaceEmptyName(boolean replaceEmptyName) {
this.replaceEmptyName = replaceEmptyName;
}
public void setNameShouldNumber(boolean isNameShouldNumber) { public void setNameShouldNumber(boolean isNameShouldNumber) {
this.isNameShouldNumber = isNameShouldNumber; this.isNameShouldNumber = isNameShouldNumber;
} }
@ -301,7 +304,7 @@ public class JNameEdList extends UIList implements CellEditorListener {
ListCellEditor editor = getCellEditor(); ListCellEditor editor = getCellEditor();
if (editor != null && editorComp != null) { if (editor != null && editorComp != null) {
Object value = editor.getCellEditorValue(); 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); setNameAt(name, editingIndex);
removeComp(); removeComp();
doAfterStopEditing(); doAfterStopEditing();

41
designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java

@ -4,19 +4,28 @@ import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.beans.BasicBeanPane; 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.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane; 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.gui.ilist.ModNameActionListener;
import com.fr.design.i18n.Toolkit;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.Nameable; 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.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
/** /**
* @author Bjorn * @author Bjorn
@ -31,6 +40,38 @@ public class ChartPreStyleListPane extends JListControlPane {
super(); super();
this.chartPreStyleManagerPane = chartPreStyleManagerPane; this.chartPreStyleManagerPane = chartPreStyleManagerPane;
initListener(); 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;
} }
/** /**

Loading…
Cancel
Save