Browse Source

Pull request #2766: REPORT-39772 提示控件/组件名称不能为空

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

* commit 'f0ba8f9dac7b5faf320c9661e73e6e3d012d0920':
  REPORT-39772 提示控件/组件名称不能为空
  REPORT-39772 提示控件/组件名称不能为空
  REPORT-39772 提示控件/组件名称不能为空
  REPORT-39772 提示控件/组件名称不能为空
  REPORT-39772 提示控件/组件名称不能为空
feature/big-screen
ju.ju 4 years ago
parent
commit
9cd2195cac
  1. 30
      designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java
  2. 6
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

30
designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java

@ -6,15 +6,18 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.xtable.TableUtils; import com.fr.design.gui.xtable.TableUtils;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor; import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor;
import com.fr.design.mainframe.widget.editors.StringEditor; import com.fr.design.mainframe.widget.editors.StringEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Component; import java.awt.Component;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
@ -136,12 +139,37 @@ public class CRPropertyDescriptorPane {
try { try {
Object value = propertyEditor.getValue(); Object value = propertyEditor.getValue();
Method m = crPropertyDescriptor.getWriteMethod(); Method m = crPropertyDescriptor.getWriteMethod();
if (ComparatorUtils.equals(m.getName(), "setWidgetName")) {
if (!isWidgetNameValid(value, widget)) {
value = widget.getWidgetName();
}
}
m.invoke(widget, value); m.invoke(widget, value);
crPropertyDescriptor.firePropertyChanged(); crPropertyDescriptor.firePropertyChanged();
} catch (Exception e) { } catch (Exception e) {
} }
} }
/**
* 设置控件名之前校验一下不能为空不能重名
*/
private boolean isWidgetNameValid(Object value, Widget widget) {
String toSetWidgetName;
if (value != null) {
toSetWidgetName = value.toString();
} else {
return false;
}
String currentWidgetName = widget.getWidgetName();
boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName);
if (toSetWidgetName.isEmpty()) {
return false;
} else if (exist) {
//控件重名,弹出提示
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png"));
return false;
}
return true;
}
} }

6
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

@ -42,7 +42,6 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
/** /**
* Created by ibm on 2017/7/25. * Created by ibm on 2017/7/25.
*/ */
@ -219,7 +218,10 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
String toSetWidgetName = widgetNameField.getText(); String toSetWidgetName = widgetNameField.getText();
String currentWidgetName = widget.getWidgetName(); String currentWidgetName = widget.getWidgetName();
boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName);
if (exist) { if (toSetWidgetName.isEmpty()) {
widgetNameField.setText(currentWidgetName);
return;
} else if (exist) {
widgetNameField.setText(currentWidgetName); widgetNameField.setText(currentWidgetName);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png"));
return; return;

Loading…
Cancel
Save