Browse Source

Merge pull request #142 in BA/design from ~GARYTU/design:master to master

* commit '3449016840c30f15809288f55099bccc9a6921fa':
  提示框简化,更简洁了
  1. 重写了自己的model来在set属性值之前进行判断并给出弹窗提示; 2. 继承DoubleEditor来实现兼容弹窗显示效果的控件,复原之前基础控件的所有更改。
  基础控件类抽取需要的代码单独作一个方法,在子类中重写
  重载输入框的光标事件方法,不管是光标移出还是按下回车(enter),会立即触发表单移动端高度属性的setter方法,并给出弹窗提示。
master
superman 9 years ago
parent
commit
3c33e65201
  1. 25
      designer_base/src/com/fr/design/mainframe/widget/editors/FormattedEditor.java
  2. 10
      designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java
  3. 59
      designer_form/src/com/fr/design/gui/xtable/ReportAppPropertyGroupModel.java
  4. 31
      designer_form/src/com/fr/design/mainframe/widget/editors/RefinedDoubleEditor.java

25
designer_base/src/com/fr/design/mainframe/widget/editors/FormattedEditor.java

@ -4,6 +4,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.text.Format;
import java.text.ParseException;
@ -32,17 +33,21 @@ public class FormattedEditor extends AbstractPropertyEditor {
textField = new JFormattedTextField(format);
panel.add(textField, BorderLayout.CENTER);
textField.setBorder(null);
textField.addKeyListener(new KeyAdapter() {
textField.addKeyListener(createKeyListener());
}
protected KeyListener createKeyListener() {
return new KeyAdapter() {
public void keyReleased(KeyEvent e) {
try {
textField.commitEdit();
} catch (ParseException e1) {
return;
}
firePropertyChanged();
}
});
public void keyReleased(KeyEvent e) {
try {
textField.commitEdit();
} catch (ParseException e1) {
return;
}
firePropertyChanged();
}
};
}
@Override

10
designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java

@ -7,11 +7,11 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.gui.itable.PropertyGroup;
import com.fr.design.gui.xtable.PropertyGroupModel;
import com.fr.design.gui.xtable.ReportAppPropertyGroupModel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.DoubleEditor;
import com.fr.design.mainframe.WidgetPropertyPane;;
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor;
import com.fr.design.mainframe.widget.editors.RefinedDoubleEditor;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.general.Inter;
@ -65,7 +65,7 @@ public class ElementCasePropertyTable extends AbstractPropertyTable{
protected CRPropertyDescriptor[] revealHeightLimit() throws IntrospectionException {
CRPropertyDescriptor heightLimitProperty = new CRPropertyDescriptor("heightPercent", this.xCreator.toData().getClass())
.setEditorClass(DoubleEditor.class)
.setEditorClass(RefinedDoubleEditor.class)
.setI18NName(Inter.getLocText("Form-EC_heightpercent"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced");
ArrayList<CRPropertyDescriptor> defaultList = (ArrayList<CRPropertyDescriptor>) createNonListenerProperties();
@ -91,7 +91,7 @@ public class ElementCasePropertyTable extends AbstractPropertyTable{
}
groups.add(new PropertyGroup(new PropertyGroupModel(Inter.getLocText("FR-Designer_Fit-App"), xCreator, propertyTableEditor, designer)));
groups.add(new PropertyGroup(new ReportAppPropertyGroupModel(Inter.getLocText("FR-Designer_Fit-App"), xCreator, propertyTableEditor, designer)));
TableModel model = new BeanTableModel();
setModel(model);

59
designer_form/src/com/fr/design/gui/xtable/ReportAppPropertyGroupModel.java

@ -0,0 +1,59 @@
package com.fr.design.gui.xtable;
import com.fr.base.FRContext;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.general.Inter;
import java.lang.reflect.Method;
import com.fr.general.ComparatorUtils;
import com.fr.report.stable.FormConstants;
import javax.swing.*;
public class ReportAppPropertyGroupModel extends PropertyGroupModel {
private static final double MAX_HEIGHT = 0.8;
public ReportAppPropertyGroupModel(String name, XCreator creator, CRPropertyDescriptor[] propArray,
FormDesigner designer) {
super(name, creator, propArray, designer);
}
@Override
public boolean setValue(Object value, int row, int column) {
double state = 0;
if (column == 0) {
return false;
}
if (value instanceof Double) {
state = (Double) value;
}
try {
Method m = properties[row].getWriteMethod();
if (state > MAX_HEIGHT) {
//弹窗提示
JOptionPane.showMessageDialog(null,
Inter.getLocText("FR-Designer_Mobile-Warning"),
Inter.getLocText("FR-Designer_Tooltips"),
JOptionPane.PLAIN_MESSAGE);
return false;
}
m.invoke(dealCreatorData(), value);
//属性名称为控件名时,单独处理下
if(ComparatorUtils.equals(FormConstants.NAME, properties[row].getName())){
creator.resetCreatorName(value.toString());
}
properties[row].firePropertyChanged();
return true;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return false;
}
}
private Object dealCreatorData() {
return creator.getPropertyDescriptorCreator().toData();
}
}

31
designer_form/src/com/fr/design/mainframe/widget/editors/RefinedDoubleEditor.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe.widget.editors;
import javax.swing.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.text.ParseException;
public class RefinedDoubleEditor extends DoubleEditor {
private JFormattedTextField textField;
public RefinedDoubleEditor() {
super();
textField = (JFormattedTextField) super.getCustomEditor();
}
@Override
public KeyListener createKeyListener() {
return new KeyAdapter() {
public void keyReleased(KeyEvent e) {
try {
textField.commitEdit();
return;
} catch (ParseException e1) {
}
}
};
}
}
Loading…
Cancel
Save