Browse Source

REPORT-31475 问题修复

feature/big-screen
kerry 5 years ago
parent
commit
8c6d591ffb
  1. 20
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java
  2. 3
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  3. 22
      designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java
  4. 4
      designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java

20
designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java

@ -7,7 +7,10 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
@ -24,13 +27,20 @@ public abstract class ComponentOperate implements TemplateOperate {
private Widget widget;
public ComponentOperate(Widget widget) {
if (widget.acceptType(WTitleLayout.class)) {
this.widget = ((WTitleLayout) widget).getBodyBoundsWidget().getWidget();
}else {
this.widget = widget;
}
Widget innerWidget = widget;
if (innerWidget.acceptType(WScaleLayout.class)) {
Widget crBoundsWidget = ((WScaleLayout) innerWidget).getBoundsWidget();
innerWidget = ((CRBoundsWidget) crBoundsWidget).getWidget();
} else if (innerWidget.acceptType(WTitleLayout.class)) {
CRBoundsWidget crBoundsWidget = ((WTitleLayout) innerWidget).getBodyBoundsWidget();
innerWidget = crBoundsWidget.getWidget();
} else if (innerWidget.acceptType(WCardMainBorderLayout.class)){
innerWidget = ((WCardMainBorderLayout) widget).getCardPart();
}
this.widget = innerWidget;
}
@Override
public JSONObject toJSONObject() {
JSONObject jo = new JSONObject();

3
designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

@ -226,6 +226,9 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID");
if (componentID == null){
return;
}
JSONObject info = componentProcessInfoMap.get(componentID);
if (info == null) {
info = jsonObject;

22
designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java

@ -5,11 +5,15 @@ import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.FreeButton;
import com.fr.form.ui.TextEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import org.junit.Assert;
@ -23,7 +27,7 @@ import java.awt.Rectangle;
public class ComponentCreateOperateTest {
@Test
public void testConstructor(){
public void testConstructor() {
ElementCaseEditor caseEditor = new ElementCaseEditor();
caseEditor.setWidgetName("report0");
caseEditor.setWidgetID("xxxx0");
@ -32,6 +36,22 @@ public class ComponentCreateOperateTest {
ComponentOperate componentOperate0 = new ComponentCreateOperate(caseEditor);
ComponentOperate componentOperate1 = new ComponentCreateOperate(wTitleLayout);
ComparatorUtils.equals(componentOperate0.toJSONObject(), componentOperate1.toJSONObject());
WScaleLayout scaleLayout = new WScaleLayout();
TextEditor textEditor = new TextEditor();
scaleLayout.addWidget(new CRBoundsWidget(textEditor, new Rectangle()));
ComponentOperate componentOperate3 = new ComponentCreateOperate(scaleLayout);
ComponentOperate componentOperate4 = new ComponentCreateOperate(textEditor);
ComparatorUtils.equals(componentOperate3.toJSONObject(), componentOperate4.toJSONObject());
WCardMainBorderLayout wCardMainBorderLayout = new WCardMainBorderLayout();
WCardLayout wCardLayout = new WCardLayout();
wCardMainBorderLayout.addCenter(wCardLayout);
ComponentOperate componentOperate5 = new ComponentCreateOperate(wCardMainBorderLayout);
ComponentOperate componentOperate6 = new ComponentCreateOperate(wCardLayout);
ComparatorUtils.equals(componentOperate5.toJSONObject(), componentOperate6.toJSONObject());
}
@Test

4
designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java

@ -143,6 +143,10 @@ public class JFormProcessInfoTest {
JSONArray ja = jFormProcessInfo.getComponentsInfo();
Assert.assertEquals(2, ja.size());
Reflect.on(jFormProcessInfo).call("addComponentCreateInfo", new ComponentCreateOperate(button1).toJSONObject());
FreeButton button3 = new FreeButton();
Reflect.on(jFormProcessInfo).call("addComponentRemoveInfo", new ComponentDeleteOperate(button3).toJSONObject());
Assert.assertEquals(1, jFormProcessInfo.getComponentsInfo().size());
ja = jFormProcessInfo.getComponentsInfo();
Assert.assertEquals(0, ja.size());

Loading…
Cancel
Save