Browse Source

REPORT-14914 移动端支持FRM边距等设置

research/10.0
zack 6 years ago
parent
commit
eb31c0b231
  1. 15
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  2. 26
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  3. 22
      designer-form/src/main/java/com/fr/design/designer/properties/mobile/BodyFitMobilePropertyUI.java
  4. 13
      designer-form/src/main/java/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java
  5. 16
      designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java
  6. 18
      designer-form/src/main/java/com/fr/design/widget/ui/designer/XmlRelationedBasicPane.java
  7. 42
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java
  8. 62
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyFitMobileDefinePane.java
  9. 42
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java
  10. 21
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java
  11. 57
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java
  12. 45
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentAdvancePane.java
  13. 71
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentLayoutIntervalPane.java

15
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -92,6 +92,18 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
}
public void setValue(double value) {
setValue(value, true);
}
/**
* 赋值但不触发保存,只是展现,一般是populate的时候用
* @param value
*/
public void setValueWithoutEvent(double value) {
setValue(value, false);
}
public void setValue(double value, boolean fireStateChange) {
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName);
}
@ -102,9 +114,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
}
this.value = value;
setTextField(value);
if (fireStateChange) {
fireStateChanged();
}
}
protected void setTextField(double value){
textField.getDocument().removeDocumentListener(docListener);

26
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -1,21 +1,11 @@
package com.fr.design.designer.creator;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI;
import com.fr.design.designer.properties.mobile.BodyFitMobilePropertyUI;
import com.fr.design.form.layout.FRFitLayout;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormArea;
@ -24,17 +14,25 @@ import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.general.FRLogger;
import com.fr.general.FRScreen;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.stable.ArrayUtils;
import edu.emory.mathcs.backport.java.util.Arrays;
import javax.swing.JOptionPane;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@ -1209,7 +1207,7 @@ public class XWFitLayout extends XLayoutContainer {
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)};
return new WidgetPropertyUIProvider[]{ new BodyFitMobilePropertyUI(this)};
}
@Override

22
designer-form/src/main/java/com/fr/design/designer/properties/mobile/BodyFitMobilePropertyUI.java

@ -0,0 +1,22 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.dialog.BasicPane;
import com.fr.design.widget.ui.designer.mobile.BodyFitMobileDefinePane;
/**
* 自适应对应body对应的移动端属性
*/
public class BodyFitMobilePropertyUI extends BodyMobilePropertyUI {
public BodyFitMobilePropertyUI(XLayoutContainer xwFitLayout) {
super(xwFitLayout);
}
@Override
public BasicPane createWidgetAttrPane() {
return new BodyFitMobileDefinePane(getxCreator());
}
}

13
designer-form/src/main/java/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java

@ -1,8 +1,7 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable;
@ -16,19 +15,19 @@ public class BodyMobilePropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator;
public BodyMobilePropertyUI(XWFitLayout xwFitLayout) {
public BodyMobilePropertyUI(XLayoutContainer xwFitLayout) {
this.xCreator = xwFitLayout;
}
public BodyMobilePropertyUI(XWAbsoluteBodyLayout xwAbsoluteBodyLayout) {
this.xCreator = xwAbsoluteBodyLayout;
}
@Override
public AbstractPropertyTable createWidgetAttrTable() {
return null;
}
public XCreator getxCreator() {
return xCreator;
}
@Override
public BasicPane createWidgetAttrPane() {
return new BodyMobileDefinePane(xCreator);

16
designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java

@ -0,0 +1,16 @@
package com.fr.design.form.util;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.container.WFitLayout;
public class FormDesignerUtils {
/**
* body布局是否设置了手机重布局
*
* @param designer
* @return
*/
public static boolean isAppRelayout(FormDesigner designer) {
return ((WFitLayout) designer.getRootComponent().toData()).isAppRelayout();
}
}

18
designer-form/src/main/java/com/fr/design/widget/ui/designer/XmlRelationedBasicPane.java

@ -0,0 +1,18 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.dialog.BasicPane;
/**
* 有些控件在不同终端需要对相同的属性分别进行设置,基础设置面板是一样的但是映射到控件上的属性又是不一样的,为了重用面板,这边加上xmltag做区分
*/
public abstract class XmlRelationedBasicPane extends BasicPane{
private String xmlTag;
public XmlRelationedBasicPane(String xmlTag) {
this.xmlTag = xmlTag;
}
public String getXmlTag() {
return xmlTag;
}
}

42
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java

@ -21,22 +21,26 @@ import java.awt.Component;
/**
* Created by ibm on 2017/8/3.
*/
public class PaddingBoundPane extends BasicPane{
public class PaddingBoundPane extends BasicPane {
protected UISpinner top;
protected UISpinner bottom;
protected UISpinner left;
protected UISpinner right;
public PaddingBoundPane() {
initBoundPane();
initBoundPane(0, 0, 0, 0);
}
public void initBoundPane() {
public PaddingBoundPane(int top, int bottom, int left, int right) {
initBoundPane(top, bottom, left, right);
}
public void initBoundPane(int t, int b, int l, int r) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
top = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
bottom = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
left = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
right = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
top = new UISpinner(0, Integer.MAX_VALUE, 1, t);
bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b);
left = new UISpinner(0, Integer.MAX_VALUE, 1, l);
right = new UISpinner(0, Integer.MAX_VALUE, 1, r);
top.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
bottom.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
left.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
@ -45,12 +49,12 @@ public class PaddingBoundPane extends BasicPane{
label.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
label.setVerticalAlignment(SwingConstants.TOP);
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{label, createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1 );
new Component[]{label, createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1);
this.add(panel);
}
public JPanel createRightPane(){
public JPanel createRightPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
@ -75,20 +79,26 @@ public class PaddingBoundPane extends BasicPane{
}
public void update(RichStyleWidgetProvider marginWidget) {
marginWidget.setMargin(new PaddingMargin((int)top.getValue(), (int)left.getValue(), (int)bottom.getValue(), (int)right.getValue() ));
marginWidget.setMargin(updateBean());
}
public PaddingMargin updateBean() {
return new PaddingMargin((int) top.getValue(), (int) left.getValue(), (int) bottom.getValue(), (int) right.getValue());
}
@Override
protected String title4PopupWindow() {
return "PaddingBoundPane";
}
public void populate(RichStyleWidgetProvider marginWidget) {
PaddingMargin paddingMargin = marginWidget.getMargin();
top.setValue(paddingMargin.getTop());
bottom.setValue(paddingMargin.getBottom());
left.setValue(paddingMargin.getLeft());
right.setValue(paddingMargin.getRight());
populateBean(marginWidget.getMargin());
}
public void populateBean(PaddingMargin paddingMargin) {
top.setValueWithoutEvent(paddingMargin.getTop());
bottom.setValueWithoutEvent(paddingMargin.getBottom());
left.setValueWithoutEvent(paddingMargin.getLeft());
right.setValueWithoutEvent(paddingMargin.getRight());
}
}

62
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyFitMobileDefinePane.java

@ -0,0 +1,62 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.base.iofile.attr.FormBodyPaddingAttrMark;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.widget.ui.designer.mobile.component.MobileComponentAdvancePane;
import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane;
import com.fr.form.ui.RichStyleWidgetProvider;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* Created by plough on 2018/2/1.
*/
public class BodyFitMobileDefinePane extends BodyMobileDefinePane {
private MobileComponentAdvancePane advancePane;
private MobileComponentLayoutIntervalPane intervalPane;
public BodyFitMobileDefinePane(XCreator xCreator) {
super(xCreator);
}
@Override
public void initPropertyGroups(Object source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
setDesigner(WidgetPropertyPane.getInstance().getEditingFormDesigner());
this.add(createNorthPane(), BorderLayout.NORTH);
this.add(getMobileWidgetListPane(), BorderLayout.CENTER);
this.repaint();
}
private JPanel createNorthPane() {
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane();
advancePane = new MobileComponentAdvancePane(FormBodyPaddingAttrMark.XML_TAG);
intervalPane = new MobileComponentLayoutIntervalPane(FormBodyPaddingAttrMark.XML_TAG);
holder.add(getMobilePropertyPane(), BorderLayout.NORTH);
//高级
holder.add(advancePane, BorderLayout.CENTER);
//布局
holder.add(intervalPane, BorderLayout.SOUTH);
return holder;
}
@Override
public void populate(FormDesigner designer) {
super.populate(designer);
advancePane.populate((RichStyleWidgetProvider) getBodyCreator().toData());
intervalPane.populate((RichStyleWidgetProvider) getBodyCreator().toData());
}
@Override
public void update() {
super.update();
advancePane.update((RichStyleWidgetProvider) getBodyCreator().toData());
intervalPane.update((RichStyleWidgetProvider) getBodyCreator().toData());
}
}

42
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java

@ -3,19 +3,19 @@ package com.fr.design.widget.ui.designer.mobile;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.MobileWidgetListPane;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WSortLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.lang.reflect.Method;
/**
* Created by plough on 2018/2/1.
@ -31,6 +31,22 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
this.bodyCreator = xCreator;
}
public XCreator getBodyCreator() {
return bodyCreator;
}
public void setBodyCreator(XCreator bodyCreator) {
this.bodyCreator = bodyCreator;
}
public FormDesigner getDesigner() {
return designer;
}
public void setDesigner(FormDesigner designer) {
this.designer = designer;
}
@Override
public void initPropertyGroups(Object source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -41,7 +57,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
}
// 手机属性
private UIExpandablePane getMobilePropertyPane() {
public UIExpandablePane getMobilePropertyPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
appRelayoutCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_App_ReLayout"), true);
appRelayoutCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
@ -55,7 +71,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
}
// 控件顺序
private UIExpandablePane getMobileWidgetListPane() {
public UIExpandablePane getMobileWidgetListPane() {
mobileWidgetListPane = new MobileWidgetListPane(designer, (WSortLayout) bodyCreator.toData());
mobileWidgetListPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -81,25 +97,13 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
initListener(this);
}
// body是否开启手机重布局
private boolean isAppRelayout() {
boolean result = false;
try {
Method m = bodyCreator.toData().getClass().getMethod("isAppRelayout");
result = (boolean)m.invoke(bodyCreator.toData());
} catch (Exception e) {
// do nothing
}
return result;
}
private void setAppRelayout(boolean appRelayoutSeleted) {
if (appRelayoutSeleted == isAppRelayout()) {
if (appRelayoutSeleted == FormDesignerUtils.isAppRelayout(designer)) {
return;
}
try {
Method m = bodyCreator.toData().getClass().getMethod("setAppRelayout", boolean.class);
m.invoke(bodyCreator.toData(), appRelayoutSeleted);
((WFitLayout) designer.getRootComponent().toData()).setAppRelayout(appRelayoutSeleted);
} catch (Exception e) {
// do nothing
}
@ -108,7 +112,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
@Override
public void populate(FormDesigner designer) {
this.designer = designer;
appRelayoutCheck.setSelected(isAppRelayout());
appRelayoutCheck.setSelected(FormDesignerUtils.isAppRelayout(designer));
// 数据 populate 完成后,再设置监听
this.bindListeners2Widgets();

21
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java

@ -9,6 +9,7 @@ import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
@ -20,11 +21,14 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.container.WFitLayout;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@ -56,7 +60,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
JPanel mobileSettingsPane;
if (isInAbsoluteLayout()) {
mobileSettingsPane = getUnavailableTipPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout"));
} else if (!isAppRelayout()) {
} else if (!FormDesignerUtils.isAppRelayout(designer)) {
mobileSettingsPane = getUnavailableTipPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tip_Chart_Adaptivity_Unavailable"));
} else {
mobileSettingsPane = getMobileSettingsPane();
@ -76,11 +80,6 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
return false;
}
// body是否开启手机重布局
private boolean isAppRelayout() {
return ((WFitLayout)designer.getRootComponent().toData()).isAppRelayout();
}
private JPanel getUnavailableTipPane(String tipText) {
JPanel panel = new JPanel(new BorderLayout());
UILabel unavailableTipLabel = new UILabel();
@ -158,7 +157,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
this.bindListeners2Widgets();
this.addAttributeChangeListener(changeListener);
if (!isAppRelayout() || isInAbsoluteLayout()) {
if (!FormDesignerUtils.isAppRelayout(designer) || isInAbsoluteLayout()) {
return;
}

57
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java

@ -1,16 +1,23 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.base.iofile.attr.FormTabPaddingAttrMark;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor;
import com.fr.design.mainframe.widget.accessibles.MobileTemplateStylePane;
import com.fr.design.widget.ui.designer.mobile.component.MobileComponentAdvancePane;
import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
@ -20,8 +27,11 @@ import java.awt.Component;
public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane {
private XCreator xCreator;
private FormDesigner designer; // 当前设计器
private AccessibleTemplateStyleEditor templateStyleEditor;
private AttributeChangeListener changeListener;
private MobileComponentAdvancePane advancePane;
private MobileComponentLayoutIntervalPane intervalPane;
public TabMobileWidgetDefinePane(XCreator xCreator) {
this.xCreator = xCreator;
@ -36,6 +46,7 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane {
}
};
}
/**
* 后台初始化所有事件.
*/
@ -46,24 +57,62 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane {
@Override
public void initPropertyGroups(Object source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template"));
templateStyleEditor = new AccessibleTemplateStyleEditor(new MobileTemplateStylePane((WCardTagLayout) xCreator.toData()));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{label, templateStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
this.add(jPanel, BorderLayout.CENTER);
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{label, templateStyleEditor}, {new UILabel()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_LARGE);
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane();
holder.add(jPanel, BorderLayout.NORTH);
if (!shouldHidePadding()) {
advancePane = new MobileComponentAdvancePane(FormTabPaddingAttrMark.XML_TAG);
intervalPane = new MobileComponentLayoutIntervalPane(FormTabPaddingAttrMark.XML_TAG);
//高级
holder.add(advancePane, BorderLayout.CENTER);
//布局
holder.add(intervalPane, BorderLayout.SOUTH);
}
this.add(holder, BorderLayout.NORTH);
}
@Override
public void populate(FormDesigner designer) {
templateStyleEditor.setValue(((WCardTagLayout)xCreator.toData()).getMobileTemplateStyle());
templateStyleEditor.setValue(((WCardTagLayout) xCreator.toData()).getMobileTemplateStyle());
// 数据 populate 完成后,再设置监听
this.bindListeners2Widgets();
this.addAttributeChangeListener(changeListener);
if (advancePane != null) {//业务层面可以写成shouldHidePadding但是这样写应该性能差点
advancePane.populate((WCardTagLayout) xCreator.toData());
}
if (intervalPane != null) {
intervalPane.populate((WCardTagLayout) xCreator.toData());
}
}
@Override
public void update() {
((WCardTagLayout)xCreator.toData()).setMobileTemplateStyle((MobileTemplateStyle) templateStyleEditor.getValue());
((WCardTagLayout) xCreator.toData()).setMobileTemplateStyle((MobileTemplateStyle) templateStyleEditor.getValue());
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来
if (advancePane != null) {
advancePane.update((WCardTagLayout) xCreator.toData());
}
if (intervalPane != null) {
intervalPane.update((WCardTagLayout) xCreator.toData());
}
}
// body是否是绝对布局
private boolean isBodyAbsoluteRelayout() {
WFitLayout root = ((WFitLayout) designer.getRootComponent().toData());
return root.getBodyLayoutType() == WBodyLayoutType.ABSOLUTE;
}
/**
* 绝对布局且不勾选手机重布局 的时候不支持边距设置
*
* @return
*/
private boolean shouldHidePadding() {
return !FormDesignerUtils.isAppRelayout(designer) && isBodyAbsoluteRelayout();
}
}

45
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentAdvancePane.java

@ -0,0 +1,45 @@
package com.fr.design.widget.ui.designer.mobile.component;
import com.fr.base.iofile.attr.AttrMarkFactory;
import com.fr.base.iofile.attr.FormBodyPaddingAttrMark;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.ui.designer.XmlRelationedBasicPane;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.form.ui.RichStyleWidgetProvider;
import java.awt.BorderLayout;
/**
* 只有内边距设置的高级设置
*/
public class MobileComponentAdvancePane extends XmlRelationedBasicPane {
private PaddingBoundPane paddingBound;
public MobileComponentAdvancePane(String xmlTag) {
super(xmlTag);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
paddingBound = new PaddingBoundPane(FormBodyPaddingAttrMark.DEFAULT_SIZE, FormBodyPaddingAttrMark.DEFAULT_SIZE, FormBodyPaddingAttrMark.DEFAULT_SIZE, FormBodyPaddingAttrMark.DEFAULT_SIZE);
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, paddingBound);
this.add(advanceExpandablePane, BorderLayout.NORTH);
}
@Override
protected String title4PopupWindow() {
return "ComponentAdvancePane";
}
public void update(RichStyleWidgetProvider marginWidget) {
FormBodyPaddingAttrMark attrMark = marginWidget.getWidgetAttrMark(getXmlTag());
attrMark = attrMark == null ? (FormBodyPaddingAttrMark) AttrMarkFactory.createAttrMark(getXmlTag()) : attrMark;
attrMark.setPaddingMargin(paddingBound.updateBean());
marginWidget.addWidgetAttrMark(attrMark);
}
public void populate(RichStyleWidgetProvider marginWidget) {
FormBodyPaddingAttrMark attrMark = marginWidget.getWidgetAttrMark(getXmlTag());
if (attrMark != null) {
paddingBound.populateBean(attrMark.getPaddingMargin());
}
}
}

71
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentLayoutIntervalPane.java

@ -0,0 +1,71 @@
package com.fr.design.widget.ui.designer.mobile.component;
import com.fr.base.iofile.attr.AttrMarkFactory;
import com.fr.base.iofile.attr.FormBodyPaddingAttrMark;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.XmlRelationedBasicPane;
import com.fr.form.ui.RichStyleWidgetProvider;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* 只有组件间隔的布局设置
*/
public class MobileComponentLayoutIntervalPane extends XmlRelationedBasicPane {
private UISpinner componentIntervel;
public MobileComponentLayoutIntervalPane(String xmlTag) {
super(xmlTag);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval"));
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}};
componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, FormBodyPaddingAttrMark.DEFAULT_SIZE);
JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel);
Component[][] components = new Component[][]{
new Component[]{intervalLabel, componentIntervelPane}
};
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0));
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane();
holder.add(centerPane, BorderLayout.NORTH);
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, holder);
this.add(layoutExpandablePane, BorderLayout.NORTH);
}
@Override
protected String title4PopupWindow() {
return "ComponentIntervelPane";
}
public void update(RichStyleWidgetProvider marginWidget) {
FormBodyPaddingAttrMark attrMark = marginWidget.getWidgetAttrMark(getXmlTag());
attrMark = attrMark == null ? (FormBodyPaddingAttrMark) AttrMarkFactory.createAttrMark(getXmlTag()) : attrMark;
attrMark.setInterval((int) componentIntervel.getValue());
marginWidget.addWidgetAttrMark(attrMark);
}
public void populate(RichStyleWidgetProvider marginWidget) {
FormBodyPaddingAttrMark attrMark = marginWidget.getWidgetAttrMark(getXmlTag());
if (attrMark != null) {
componentIntervel.setValueWithoutEvent(attrMark.getInterval());
}
}
}
Loading…
Cancel
Save