Browse Source

Pull request #1752: MOBILE-27532 单选/复选按钮组自适应高度

Merge in DESIGN/design from ~DREW/design:release/10.0 to release/10.0

* commit '4c101df6e9b362b60b6f7634778e4caf85af1b6a':
  代码简化
  MOBILE-27532 单选/复选按钮组自适应高度
feature/big-screen
drew 4 years ago
parent
commit
d19d36276d
  1. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XCheckBoxGroup.java
  2. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XRadioGroup.java
  3. 32
      designer-form/src/main/java/com/fr/design/designer/properties/mobile/ButtonGroupPropertyUI.java
  4. 83
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ButtonGroupDefinePane.java

7
designer-form/src/main/java/com/fr/design/designer/creator/XCheckBoxGroup.java

@ -3,7 +3,9 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.design.designer.properties.mobile.ButtonGroupPropertyUI;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.editors.DictionaryEditor; import com.fr.design.mainframe.widget.editors.DictionaryEditor;
@ -87,4 +89,9 @@ public class XCheckBoxGroup extends XFieldEditor {
protected String getIconName() { protected String getIconName() {
return "checkbox_group_16.png"; return "checkbox_group_16.png";
} }
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[] {new ButtonGroupPropertyUI(this)};
}
} }

7
designer-form/src/main/java/com/fr/design/designer/creator/XRadioGroup.java

@ -12,6 +12,8 @@ import javax.swing.ButtonGroup;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import com.fr.design.designer.properties.mobile.ButtonGroupPropertyUI;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.editors.DictionaryEditor; import com.fr.design.mainframe.widget.editors.DictionaryEditor;
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor; import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor;
@ -83,4 +85,9 @@ public class XRadioGroup extends XFieldEditor {
protected String getIconName() { protected String getIconName() {
return "button_group_16.png"; return "button_group_16.png";
} }
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[] {new ButtonGroupPropertyUI(this)};
}
} }

32
designer-form/src/main/java/com/fr/design/designer/properties/mobile/ButtonGroupPropertyUI.java

@ -0,0 +1,32 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XFieldEditor;
import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.widget.ui.designer.mobile.ButtonGroupDefinePane;
public class ButtonGroupPropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator;
public ButtonGroupPropertyUI(XFieldEditor xButtonGroupEditor) {
this.xCreator = xButtonGroupEditor;
}
@Override
public AbstractPropertyTable createWidgetAttrTable() {
return null;
}
@Override
public BasicPane createWidgetAttrPane() {
return new ButtonGroupDefinePane(xCreator);
}
@Override
public String tableTitle() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr");
}
}

83
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ButtonGroupDefinePane.java

@ -0,0 +1,83 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.frpane.AttributeChangeListener;
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.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.ButtonGroup;
import javax.swing.*;
import java.awt.*;
public class ButtonGroupDefinePane extends MobileWidgetDefinePane {
private XCreator xCreator; // 当前选中控件的xCreator
private UISpinner maxShowRowsSpinner;
public ButtonGroupDefinePane(XCreator xCreator) {
this.xCreator = xCreator;
}
@Override
public void initPropertyGroups(Object source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel maxShowRowsLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design-Mobile_Max_Show_Rows"), SwingConstants.LEFT);
this.maxShowRowsSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 5);
Component[][] components = new Component[][]{
new Component[] {maxShowRowsLabel, maxShowRowsSpinner}
};
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {p,f};
int[][] rowCount = {{1, 1}};
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
panelWrapper.add(panel, BorderLayout.NORTH);
UIExpandablePane folderPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, panelWrapper);
this.add(folderPane, BorderLayout.NORTH);
this.repaint();
}
private void bindListeners2Widgets() {
reInitAllListeners();
AttributeChangeListener changeListener = new AttributeChangeListener() {
@Override
public void attributeChange() {
update();
}
};
this.addAttributeChangeListener(changeListener);
}
/**
* 后台初始化所有事件.
*/
private void reInitAllListeners() {
initListener(this);
}
@Override
public void populate(FormDesigner designer) {
ButtonGroup buttonGroup = (ButtonGroup)xCreator.toData();
this.maxShowRowsSpinner.setValue(buttonGroup.getMaxShowRows());
// 数据 populate 完成后,再设置监听
this.bindListeners2Widgets();
}
@Override
public void update() {
ButtonGroup buttonGroup = (ButtonGroup)xCreator.toData();
buttonGroup.setMaxShowRows((int) maxShowRowsSpinner.getValue());
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来
}
}
Loading…
Cancel
Save