Browse Source

Pull request #6046: REPORT-59952&REPORT-60057&REPORT-60139 解决打开空白模板和布局模板有差异的一类问题

Merge in DESIGN/design from ~FANGLEI/design10.0:feature/x to feature/x

* commit 'b4abd422c9aee5195b9819c94fb8b71019a3521a':
  REPORT-59952&REPORT-60057&REPORT-60139 解决pr中的问题
  REPORT-59952&REPORT-60057&REPORT-60139 解决pr中的问题
  REPORT-59952&REPORT-60057&REPORT-60139 解决打开空白模板和布局模板有差异的一类问题
research/11.0
fanglei 3 years ago
parent
commit
5ec6c09ebe
  1. 11
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  2. 69
      designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java

11
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -6,7 +6,6 @@ import com.fr.base.Parameter;
import com.fr.base.Releasable;
import com.fr.base.extension.FileExtension;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.iofile.attr.TemplateLayoutIdAttrMark;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme;
@ -117,7 +116,6 @@ import java.util.List;
public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form>, Releasable {
private static final String FORM_CARD = "FORM";
private static final String ELEMENTCASE_CARD = "ELEMENTCASE";
private static final String EMPTY_FORM_LAYOUTID = "9ebf6aff-ad53-45a9-a175-9633f4162a3a";
private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD};
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
@ -138,8 +136,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
protected int index = FORM_TAB;
public JForm() {
super(new Form(new WBorderLayout("form")), "Form");
initEmptyFormLayoutId();
this(new Form(new WBorderLayout("form")));
}
public JForm(Form form) {
@ -154,12 +151,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
super(form, file);
}
private void initEmptyFormLayoutId() {
Form form = this.getTarget();
form.addAttrMark(new TemplateLayoutIdAttrMark(EMPTY_FORM_LAYOUTID));
form.setLayoutId(EMPTY_FORM_LAYOUTID);
}
@Override
protected void addPane(PropertyItemPaneProvider provider) {

69
designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java

@ -1,5 +1,6 @@
package com.fr.design.widget.ui.designer;
import com.fr.base.iofile.attr.TemplateLayoutIdAttrMark;
import com.fr.design.border.UITitledMatteBorder;
import com.fr.design.designer.beans.PredefinedLayout;
import com.fr.design.designer.beans.models.NewFormModel;
@ -15,6 +16,11 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.OccupiedLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
@ -43,6 +49,8 @@ import java.util.List;
import java.util.Map;
public class NewFormPane extends BasicPane {
private static final String EMPTY_FORM_LAYOUTID = "9ebf6aff-ad53-45a9-a175-9633f4162a3a";
private NewFormModel newFormModel;
private UIDialog dialog;
private PredefinedLayoutPane selectedLayoutPane = null;
@ -276,19 +284,66 @@ public class NewFormPane extends BasicPane {
private void newForm(String path) {
BaseJForm jForm;
try {
if (StringUtils.isNotEmpty(path)) {
Form form = new Form();
form.readStream(NewFormPane.class.getResourceAsStream(path));
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class);
} else {
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class);
}
Form form = initEmptyBodyForm();
initLayoutInfo(form, path);
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class);
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) jForm);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private Form initEmptyBodyForm() {
WFitLayout body = new WFitLayout();
WBorderLayout borderLayout = new WBorderLayout("form");
borderLayout.addCenter(body);
return new Form(borderLayout);
}
/**
* 通过布局文件的位置初始化Form对象的布局信息
*
* @param form 新建的form对象
* @param path 布局文件位置
* @throws Exception
*/
private void initLayoutInfo(Form form, String path) throws Exception {
if (isNewEmptyForm(path)) {
initEmptyFormLayoutId(form);
} else {
Form layoutTemplate = new Form();
layoutTemplate.readStream(NewFormPane.class.getResourceAsStream(path));
if (layoutTemplate.getBody() != null && layoutTemplate.getBody() instanceof WFitLayout) {
WFitLayout layoutTemplateBody = (WFitLayout) layoutTemplate.getBody();
WFitLayout body = (WFitLayout) form.getBody();
body.setMargin(layoutTemplateBody.getMargin());
body.setCompInterval(layoutTemplateBody.getCompInterval());
for (int i = 0; i < layoutTemplateBody.getWidgetCount(); i++) {
Widget boundsWidget = layoutTemplateBody.getWidget(i);
if (boundsWidget != null && boundsWidget instanceof BoundsWidget) {
Widget widget = ((BoundsWidget) boundsWidget).getWidget();
if (widget != null && widget instanceof OccupiedLayout) {
body.addWidget((Widget) boundsWidget.clone());
}
}
}
form.setLayoutId(layoutTemplate.getLayoutId());
}
}
}
private void initEmptyFormLayoutId(Form form) {
form.addAttrMark(new TemplateLayoutIdAttrMark(EMPTY_FORM_LAYOUTID));
form.setLayoutId(EMPTY_FORM_LAYOUTID);
}
private boolean isNewEmptyForm(String layoutTemplatePath) {
return StringUtils.isEmpty(layoutTemplatePath);
}
private void setSelectedLayoutPane(PredefinedLayoutPane layoutPane) {
if (selectedLayoutPane != layoutPane) {
if (selectedLayoutPane != null) {

Loading…
Cancel
Save