From 87546555fbe5179c7275a4269fb865c83ce9f888 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 5 Sep 2019 10:37:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/component/present/DictionaryPane.java | 87 +++++++++++++++++++ .../design/ui/container/DictionaryPane.java | 10 --- .../api/design/work/EncoderCellRenderer.java | 15 ---- .../api/design/work/{ => form}/Item.java | 2 +- .../form/basic}/AccessiblePropertyEditor.java | 2 +- .../work/form/basic/EncoderCellRenderer.java | 53 +++++++++++ .../form/basic}/ItemCellEditor.java | 2 +- .../basic}/UneditableAccessibleEditor.java | 2 +- .../form}/container/AbstractDataModify.java | 2 +- .../form}/container/XLayoutContainer.java | 2 +- .../creator}/CustomWriteAbleRepeatEditor.java | 2 +- .../form/creator}/XFieldEditor.java | 2 +- .../work/form/editors/StringEditor.java | 14 +++ .../form/editors}/WidgetValueEditor.java | 4 +- .../form}/macro/XCreatorConstants.java | 3 +- 15 files changed, 166 insertions(+), 36 deletions(-) create mode 100644 src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java delete mode 100644 src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java rename src/main/java/com/fanruan/api/design/work/{ => form}/Item.java (84%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/basic}/AccessiblePropertyEditor.java (89%) create mode 100644 src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/basic}/ItemCellEditor.java (87%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/basic}/UneditableAccessibleEditor.java (88%) rename src/main/java/com/fanruan/api/design/{ui => work/form}/container/AbstractDataModify.java (81%) rename src/main/java/com/fanruan/api/design/{ui => work/form}/container/XLayoutContainer.java (89%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/creator}/CustomWriteAbleRepeatEditor.java (85%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/creator}/XFieldEditor.java (87%) create mode 100644 src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/editors}/WidgetValueEditor.java (82%) rename src/main/java/com/fanruan/api/design/{ => work/form}/macro/XCreatorConstants.java (83%) diff --git a/src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java b/src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java new file mode 100644 index 0000000..c956bae --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java @@ -0,0 +1,87 @@ +package com.fanruan.api.design.ui.component.present; + + +import com.fanruan.api.design.DesignKit; +import com.fr.data.Dictionary; +import com.fr.data.impl.DynamicSQLDict; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.data.DataCreatorUI; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.present.dict.CustomDictPane; +import com.fr.design.present.dict.DatabaseDictPane; +import com.fr.design.present.dict.FormulaDictPane; +import com.fr.design.present.dict.TableDataDictPane; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 数据字典容器,获取数据字典 + */ +public class DictionaryPane extends UIComboBoxPane implements DataCreatorUI { + private TableDataDictPane tableDataDictPane; + + @Override + protected void initLayout() { + this.setLayout(new BorderLayout(0, 4)); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + int[][] rowCount = {{1, 1}, {1, 1}}; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(DesignKit.i18nText("Fine-Design_Basic_Type_Set"), UILabel.LEFT), jcb}, + new Component[]{null, null} + }; + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_HUGER, LayoutConstants.VGAP_MEDIUM); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return DesignKit.i18nText("Fine-Design_Form_DS_Dictionary"); + } + + @Override + public JComponent toSwingComponent() { + return this; + } + + @Override + public void populateBean(Dictionary ob) { + for (int i = 0; i < this.cards.size(); i++) { + FurtherBasicBeanPane pane = cards.get(i); + if (pane.accept(ob)) { + pane.populateBean(ob); + jcb.setSelectedIndex(i); + } else { + pane.reset(); + } + } + if (ob instanceof DynamicSQLDict) { + jcb.setSelectedIndex(1); + tableDataDictPane.populateBean((DynamicSQLDict) ob); + } + } + + @Override + protected List> initPaneList() { + List> paneList = new ArrayList>(); + paneList.add(new DatabaseDictPane()); + paneList.add(tableDataDictPane = new TableDataDictPane()); + paneList.add(new CustomDictPane()); + paneList.add(new FormulaDictPane()); + return paneList; + } +} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java b/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java deleted file mode 100644 index 806d275..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/9/4 - * 数据字典容器,获取数据字典 - */ -public class DictionaryPane extends com.fr.design.present.dict.DictionaryPane { -} diff --git a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java deleted file mode 100644 index d5f617c..0000000 --- a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.design.work; - -import com.fr.design.designer.properties.Encoder; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/9/4 - * 根据控件属性渲染单元格 - */ -public class EncoderCellRenderer extends com.fr.design.mainframe.widget.renderer.EncoderCellRenderer { - public EncoderCellRenderer(Encoder encoder) { - super(encoder); - } -} diff --git a/src/main/java/com/fanruan/api/design/work/Item.java b/src/main/java/com/fanruan/api/design/work/form/Item.java similarity index 84% rename from src/main/java/com/fanruan/api/design/work/Item.java rename to src/main/java/com/fanruan/api/design/work/form/Item.java index 34e1707..3011f7e 100644 --- a/src/main/java/com/fanruan/api/design/work/Item.java +++ b/src/main/java/com/fanruan/api/design/work/form/Item.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.work; +package com.fanruan.api.design.work.form; /** * @author Kalven diff --git a/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java similarity index 89% rename from src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java rename to src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java index edcafb0..94f56c7 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.basic; import com.fr.design.mainframe.widget.accessibles.AccessibleEditor; diff --git a/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java new file mode 100644 index 0000000..7655a22 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java @@ -0,0 +1,53 @@ +package com.fanruan.api.design.work.form.basic; + +import com.fr.design.designer.properties.Encoder; +import com.fr.design.mainframe.widget.renderer.GenericCellRenderer; + +import java.awt.*; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 根据控件属性渲染单元格 + */ +public class EncoderCellRenderer extends GenericCellRenderer { + + private static int LEFT = 1; + protected Encoder encoder; + protected Object value; + + public EncoderCellRenderer(Encoder encoder) { + this.encoder = encoder; + } + + @Override + public void paint(Graphics g) { + int width = getWidth(); + int height = getHeight(); + g.setColor(getBackground()); + g.fillRect(0, 0, width, height); + + int x = LEFT; + g.setColor(getForeground()); + + FontMetrics fm = g.getFontMetrics(); + int y = ((height - fm.getHeight()) / 2) + fm.getAscent(); + String txt = getValueText(); + if (txt != null) { + g.drawString(txt, x, y); + } + if (getBorder() != null) { + getBorder().paintBorder(this, g, 0, 0, width, height); + } + } + + @Override + public void setValue(Object value) { + this.value = value; + } + + private String getValueText() { + return encoder.encode(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/ItemCellEditor.java similarity index 87% rename from src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java rename to src/main/java/com/fanruan/api/design/work/form/basic/ItemCellEditor.java index 53bf002..ae11f90 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/ItemCellEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.basic; import com.fr.design.designer.properties.items.Item; diff --git a/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/UneditableAccessibleEditor.java similarity index 88% rename from src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java rename to src/main/java/com/fanruan/api/design/work/form/basic/UneditableAccessibleEditor.java index d7fc5bf..879e2ff 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/UneditableAccessibleEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.basic; import com.fr.design.designer.properties.Encoder; diff --git a/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java b/src/main/java/com/fanruan/api/design/work/form/container/AbstractDataModify.java similarity index 81% rename from src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java rename to src/main/java/com/fanruan/api/design/work/form/container/AbstractDataModify.java index e437411..2567a2b 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java +++ b/src/main/java/com/fanruan/api/design/work/form/container/AbstractDataModify.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.container; +package com.fanruan.api.design.work.form.container; /** * 抽象数据定义,实现数据可序列化 diff --git a/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java b/src/main/java/com/fanruan/api/design/work/form/container/XLayoutContainer.java similarity index 89% rename from src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java rename to src/main/java/com/fanruan/api/design/work/form/container/XLayoutContainer.java index 8a70c03..21cd772 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java +++ b/src/main/java/com/fanruan/api/design/work/form/container/XLayoutContainer.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.container; +package com.fanruan.api.design.work.form.container; import com.fr.form.ui.container.WLayout; diff --git a/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java b/src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java similarity index 85% rename from src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java rename to src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java index 2218085..28aeaca 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.creator; /** * 允许自定义值的、允许直接编辑的、带重复的 --- 下拉框 下拉复选框 下拉树 diff --git a/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java b/src/main/java/com/fanruan/api/design/work/form/creator/XFieldEditor.java similarity index 87% rename from src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java rename to src/main/java/com/fanruan/api/design/work/form/creator/XFieldEditor.java index ad42005..53afb63 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/creator/XFieldEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.creator; import com.fr.form.ui.FieldEditor; diff --git a/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java b/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java new file mode 100644 index 0000000..08551c4 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java @@ -0,0 +1,14 @@ +package com.fanruan.api.design.work.form.editors; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-05 + * 字符串编辑器 + */ +public class StringEditor extends com.fr.design.mainframe.widget.editors.StringEditor { + + public StringEditor() { + super(); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java b/src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java similarity index 82% rename from src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java rename to src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java index 2bc46ab..0c77e46 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java @@ -1,10 +1,10 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.editors; /** * @author Kalven * @version 10.0 * Created by Kalven on 2019/9/4 - * 控件值的编辑器 + * 控件值编辑器 */ public class WidgetValueEditor extends com.fr.design.mainframe.widget.editors.WidgetValueEditor { diff --git a/src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java b/src/main/java/com/fanruan/api/design/work/form/macro/XCreatorConstants.java similarity index 83% rename from src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java rename to src/main/java/com/fanruan/api/design/work/form/macro/XCreatorConstants.java index ea51fa8..8596304 100644 --- a/src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java +++ b/src/main/java/com/fanruan/api/design/work/form/macro/XCreatorConstants.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.macro; +package com.fanruan.api.design.work.form.macro; /** * 存放XCreator的常量 @@ -7,5 +7,6 @@ package com.fanruan.api.design.macro; * Created by Kalven on 2019/9/3 */ public class XCreatorConstants { + public static final String PROPERTY_CATEGORY = com.fr.design.form.util.XCreatorConstants.PROPERTY_CATEGORY; }