Browse Source

REPORT-59952&REPORT-60057&REPORT-60139 解决pr中的问题

research/11.0
方磊 3 years ago
parent
commit
1f797aaf24
  1. 11
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  2. 61
      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.Releasable;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; 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.FormTheme;
import com.fr.base.theme.FormThemeConfig; import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme; 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 { public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form>, Releasable {
private static final String FORM_CARD = "FORM"; private static final String FORM_CARD = "FORM";
private static final String ELEMENTCASE_CARD = "ELEMENTCASE"; 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 String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD};
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60; 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; protected int index = FORM_TAB;
public JForm() { public JForm() {
super(new Form(new WBorderLayout("form")), "Form"); this(new Form(new WBorderLayout("form")));
initEmptyFormLayoutId();
} }
public JForm(Form form) { public JForm(Form form) {
@ -154,12 +151,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
super(form, file); super(form, file);
} }
private void initEmptyFormLayoutId() {
Form form = this.getTarget();
form.addAttrMark(new TemplateLayoutIdAttrMark(EMPTY_FORM_LAYOUTID));
form.setLayoutId(EMPTY_FORM_LAYOUTID);
}
@Override @Override
protected void addPane(PropertyItemPaneProvider provider) { protected void addPane(PropertyItemPaneProvider provider) {

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

@ -1,5 +1,6 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.base.iofile.attr.TemplateLayoutIdAttrMark;
import com.fr.design.border.UITitledMatteBorder; import com.fr.design.border.UITitledMatteBorder;
import com.fr.design.designer.beans.PredefinedLayout; import com.fr.design.designer.beans.PredefinedLayout;
import com.fr.design.designer.beans.models.NewFormModel; import com.fr.design.designer.beans.models.NewFormModel;
@ -15,7 +16,10 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.ui.container.WBorderLayout; 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.WFitLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -44,6 +48,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class NewFormPane extends BasicPane { public class NewFormPane extends BasicPane {
private static final String EMPTY_FORM_LAYOUTID = "9ebf6aff-ad53-45a9-a175-9633f4162a3a";
private NewFormModel newFormModel; private NewFormModel newFormModel;
private UIDialog dialog; private UIDialog dialog;
private PredefinedLayoutPane selectedLayoutPane = null; private PredefinedLayoutPane selectedLayoutPane = null;
@ -265,18 +271,59 @@ public class NewFormPane extends BasicPane {
private void newForm(String path) { private void newForm(String path) {
BaseJForm jForm; BaseJForm jForm;
try { try {
Form form = new Form(new WBorderLayout("form")); jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class);
if (StringUtils.isNotEmpty(path)) { Form form = (Form) jForm.getTarget();
form.readStream(NewFormPane.class.getResourceAsStream(path)); initLayoutInfo(form, path);
form = (Form) form.cloneAsLayoutTemplate();
}
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class);
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) jForm); DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) jForm);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
/**
* 通过布局文件的位置初始化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) { private void setSelectedLayoutPane(PredefinedLayoutPane layoutPane) {
if (selectedLayoutPane != layoutPane) { if (selectedLayoutPane != layoutPane) {
if (selectedLayoutPane != null) { if (selectedLayoutPane != null) {

Loading…
Cancel
Save