|
|
@ -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) { |
|
|
|