Browse Source

Pull request #6426: REPORT-58584 FR11-二轮回归-设计器菜单栏-服务器-控件管理-预定义控件重名时没有提示

Merge in DESIGN/design from ~FANGLEI/design10.0:release/11.0 to release/11.0

* commit '13e54b514ebd25548e19dd8280592d704cde4c1c':
  REPORT-58584 FR11-二轮回归-设计器菜单栏-服务器-控件管理-预定义控件重名时没有提示
  REPORT-58584
  REPORT-58584
  REPORT-58584 FR11-二轮回归-设计器菜单栏-服务器-控件管理-预定义控件重名时没有提示
bugfix/11.0
fanglei 3 years ago
parent
commit
f0ed9ba1a3
  1. 55
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  2. 36
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  3. 52
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  4. 36
      designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java
  5. 16
      designer-realize/src/main/java/com/fr/design/widget/WidgetConfigPane.java

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

@ -9,7 +9,6 @@ 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;
@ -25,18 +24,18 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.third.org.apache.commons.collections4.MapUtils;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* TableDataList Pane.
@ -52,15 +51,12 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override
public void propertyChange() {
isNamePermitted = true;
String tempName = getEditingName();
if (ComparatorUtils.equals(tempName, selectedName)) {
//说明双击之后又取消了,啥也不用做
if (!checkName()) {
isNamePermitted = false;
return;
}
Set<String> allDSNames = DesignTableDataManager.getGlobalDataSet().keySet();
String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY;
String tempName = getEditingName();
Object editingType = getEditingType();
if (!BasicTableDataUtils.checkName(tempName)) {
@ -70,35 +66,36 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
return;
}
if (StringUtils.isEmpty(tempName)) {
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);
setIllegalIndex(editingIndex);
return;
}
boolean isRepeated = isNameRepeated(new Collection[]{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));
setIllegalIndex(editingIndex);
} else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) {
if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips"));
setIllegalIndex(editingIndex);
return;
}
if (nameableList.getSelectedValue() instanceof ListModelElement) {
rename(selectedName, isRepeated ? NameInspector.ILLEGAL_NAME_HOLDER : tempName);
rename(selectedName, tempName);
}
}
});
}
@Override
public String getEmptyNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips");
}
@Override
public String getDuplicatedNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", getEditingName());
}
@Override
public Collection getExtraItemsToCheckNameRepeat() {
return DesignTableDataManager.getGlobalDataSet().keySet();
}
@Override
public void rename(String oldName, String newName) {
//如果a改成了b,b又被改成了c,就认为是a改成了c

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

@ -7,7 +7,6 @@ import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
@ -15,21 +14,18 @@ import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.i18n.Toolkit;
import com.fr.event.EventDispatcher;
import com.fr.file.ConnectionConfig;
import com.fr.general.ComparatorUtils;
import com.fr.file.ConnectionOperator;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.third.org.apache.commons.collections4.MapUtils;
import com.fr.workspace.WorkContext;
import com.fr.file.ConnectionOperator;
import java.awt.Window;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -48,32 +44,24 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
this.addEditingListener(new PropertyChangeAdapter() {
public void propertyChange() {
isNamePermitted = true;
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Empty_Name"));
setIllegalIndex(editingIndex);
if (!checkName()) {
isNamePermitted = false;
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeated(new List[]{Arrays.asList(allListNames)}, tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
String message = Toolkit.i18nText("Fine-Design_Basic_Connection_Duplicate_Name", tempName);
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message);
setIllegalIndex(editingIndex);
rename(selectedName, getEditingName());
}
if (isNamePermitted && !ComparatorUtils.equals(tempName, selectedName)) {
rename(selectedName, tempName);
});
}
}
});
@Override
public String getEmptyNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Connection_Empty_Name");
}
@Override
public String getDuplicatedNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Connection_Duplicate_Name", getEditingName());
}
protected void rename(String oldName, String newName) {
//如果a改成了b,b又被改成了c,就认为是a改成了c

52
designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java

@ -1,10 +1,12 @@
package com.fr.design.gui.controlpane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils;
@ -12,6 +14,7 @@ import com.fr.general.IOUtils;
import com.fr.invoke.Reflect;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.DefaultListCellRenderer;
@ -23,12 +26,16 @@ 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.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider {
private static final String LIST_NAME = "JControl_List";
@ -424,4 +431,47 @@ public abstract class JListControlPane extends JControlPane implements ListContr
}
public boolean checkName() {
String tempName = getEditingName();
if (ComparatorUtils.equals(tempName, selectedName)) {
return false;
}
if (StringUtils.isEmpty(tempName)) {
nameableList.stopEditing();
showWarningDialog(getEmptyNameTip());
setIllegalIndex(editingIndex);
return false;
}
String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY;
if (isNameRepeated(new Collection[]{getExtraItemsToCheckNameRepeat(), Arrays.asList(allListNames)}, tempName)) {
nameableList.stopEditing();
showWarningDialog(getDuplicatedNameTip());
setIllegalIndex(editingIndex);
return false;
}
return true;
}
public String getEmptyNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des");
}
public String getDuplicatedNameTip() {
return StringUtils.EMPTY;
}
public Collection getExtraItemsToCheckNameRepeat() {
return new ArrayList();
}
private void showWarningDialog(String tip) {
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(JListControlPane.this),
tip,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE);
}
}

36
designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java

@ -2,20 +2,16 @@ package com.fr.design.parameter;
import com.fr.base.Parameter;
import com.fr.base.ParameterConfig;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.NameableSelfCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import java.util.Arrays;
import java.util.List;
import java.util.Collection;
public class ParameterArrayPane extends JListControlPane {
@ -29,27 +25,25 @@ public class ParameterArrayPane extends JListControlPane {
this.addModNameActionListener((index, oldName, newName) -> populateSelectedValue());
this.addEditingListener(new PropertyChangeAdapter() {
public void propertyChange() {
Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters();
String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name"));
setIllegalIndex(editingIndex);
return;
checkName();
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this),
Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name"));
setIllegalIndex(editingIndex);
});
}
@Override
public String getEmptyNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name");
}
});
@Override
public String getDuplicatedNameTip() {
return Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name");
}
@Override
public Collection getExtraItemsToCheckNameRepeat() {
return Arrays.asList(ParameterConfig.getInstance().getGlobalParameters());
}
@Override
protected String title4PopupWindow() {

16
designer-realize/src/main/java/com/fr/design/widget/WidgetConfigPane.java

@ -4,11 +4,13 @@ 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.core.WidgetConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.UserDefinedWidgetConfig;
import com.fr.form.ui.WidgetConfig;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
import com.fr.stable.core.PropertyChangeAdapter;
import java.util.ArrayList;
import java.util.Iterator;
@ -19,6 +21,20 @@ import java.util.List;
*/
public class WidgetConfigPane extends JListControlPane {
public WidgetConfigPane() {
super();
this.addEditingListener(new PropertyChangeAdapter() {
public void propertyChange() {
checkName();
}
});
}
@Override
public String getDuplicatedNameTip() {
return Toolkit.i18nText("Fine_Design_Predefine_Widget_Name_Duplicated");
}
/**
* 创建用户自定义widget组件
*

Loading…
Cancel
Save