Browse Source

Merge pull request #798 in DESIGN/design from ~ZACK/design:feature/10.0 to feature/10.0

* commit '9498f198bc9a6ac4a0ae054554146d3a3bd5c01a':
  bugfix
  REPORT-14914 移动端支持FRM边距等设置
research/10.0
zack 6 years ago
parent
commit
406afebcd6
  1. 15
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  2. 22
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  3. 13
      designer-form/src/main/java/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java
  4. 28
      designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java
  5. 18
      designer-form/src/main/java/com/fr/design/widget/ui/designer/XmlRelationedBasicPane.java
  6. 42
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java
  7. 82
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java
  8. 21
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java
  9. 17
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetDefinePane.java
  10. 41
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java
  11. 45
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentAdvancePane.java
  12. 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);

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

@ -1,15 +1,5 @@
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;
@ -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;
/**

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);

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

@ -0,0 +1,28 @@
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();
}
/**
* body布局是否设置了绝对布局
*
* @param designer
* @return
*/
public static boolean isBodyAbsolute(FormDesigner designer) {
WFitLayout root = ((WFitLayout) designer.getRootComponent().toData());
return root.getBodyLayoutType() == com.fr.form.ui.container.WBodyLayoutType.ABSOLUTE;
}
}

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());
}
}

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

@ -1,21 +1,25 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.base.iofile.attr.FormBodyPaddingAttrMark;
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.design.widget.ui.designer.mobile.component.MobileComponentAdvancePane;
import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane;
import com.fr.form.ui.RichStyleWidgetProvider;
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.
@ -26,22 +30,40 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
private AttributeChangeListener changeListener;
private UICheckBox appRelayoutCheck;
private MobileWidgetListPane mobileWidgetListPane;
private MobileComponentAdvancePane advancePane;
private MobileComponentLayoutIntervalPane intervalPane;
public BodyMobileDefinePane(XCreator xCreator) {
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());
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
this.add(getMobilePropertyPane(), BorderLayout.NORTH);
this.add(createNorthPane(), BorderLayout.NORTH);
this.add(getMobileWidgetListPane(), BorderLayout.CENTER);
this.repaint();
}
// 手机属性
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 +77,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();
@ -64,6 +86,24 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane {
return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Order"), 280, 20, panelWrapper);
}
private JPanel createNorthPane() {
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane();
holder.add(getMobilePropertyPane(), BorderLayout.NORTH);
advancePane = new MobileComponentAdvancePane(FormBodyPaddingAttrMark.XML_TAG);
intervalPane = new MobileComponentLayoutIntervalPane(FormBodyPaddingAttrMark.XML_TAG);
//高级
holder.add(advancePane, BorderLayout.CENTER);
//布局
holder.add(intervalPane, BorderLayout.SOUTH);
advancePane.setVisible(!shouldHidePadding(designer));
intervalPane.setVisible(!shouldHidePadding(designer));
return holder;
}
private void bindListeners2Widgets() {
reInitAllListeners();
this.changeListener = new AttributeChangeListener() {
@ -81,25 +121,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,17 +136,31 @@ 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();
this.addAttributeChangeListener(changeListener);
advancePane.populate((RichStyleWidgetProvider) getBodyCreator().toData());
intervalPane.populate((RichStyleWidgetProvider) getBodyCreator().toData());
}
@Override
public void update() {
boolean appRelayout = appRelayoutCheck.isSelected();
setAppRelayout(appRelayoutCheck.isSelected());
boolean appPaddingVisible = appRelayout || !FormDesignerUtils.isBodyAbsolute(designer);
advancePane.setVisible(appPaddingVisible);
intervalPane.setVisible(appPaddingVisible);
mobileWidgetListPane.updateToDesigner();
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
if (advancePane.isVisible()) {
advancePane.update((RichStyleWidgetProvider) getBodyCreator().toData());
}
if (intervalPane.isVisible()) {
intervalPane.update((RichStyleWidgetProvider) getBodyCreator().toData());
}
}
}

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;
}

17
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetDefinePane.java

@ -1,5 +1,6 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.mainframe.FormDesigner;
@ -7,10 +8,10 @@ import javax.swing.*;
/**
* 所有移动端需要拓展的属性面板均继承此类
*
* <p>
* Created by fanglei on 2017/8/8.
*/
public abstract class MobileWidgetDefinePane extends AbstractAttrNoScrollPane{
public abstract class MobileWidgetDefinePane extends AbstractAttrNoScrollPane {
//初始化panel数据再repaint
public abstract void initPropertyGroups(Object source);
@ -28,11 +29,21 @@ public abstract class MobileWidgetDefinePane extends AbstractAttrNoScrollPane{
// 暂不需要此方法
@Override
protected void initContentPane() {}
protected void initContentPane() {
}
// 暂不需要此方法
@Override
protected JPanel createContentPane() {
return new JPanel();
}
/**
* 绝对布局且不勾选手机重布局 的时候不支持边距设置
*
* @return
*/
public boolean shouldHidePadding(FormDesigner designer) {
return !FormDesignerUtils.isAppRelayout(designer) && FormDesignerUtils.isBodyAbsolute(designer);
}
}

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

@ -1,5 +1,6 @@
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;
@ -9,8 +10,11 @@ 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.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
@ -20,8 +24,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 +43,7 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane {
}
};
}
/**
* 后台初始化所有事件.
*/
@ -46,24 +54,47 @@ 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(designer)) {
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());
}
}
}

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