From 419aa4419527ea4a66402062e0c6cad7c719ca43 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 28 Sep 2017 14:53:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-4850=20[9.0=E6=8F=92=E4=BB=B6]?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=8E=A7=E4=BB=B6=E5=B1=9E=E6=80=A7=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=80=82=E9=85=8D=E6=96=B0=E7=89=88=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../creator/CRPropertyDescriptor.java | 38 +++++---- .../accessibles/BaseAccessibleEditor.java | 11 ++- .../designer/beans/ComponentAdapter.java | 7 ++ .../component/CompositeComponentAdapter.java | 45 +++++++++-- .../creator/CRPropertyDescriptorPane.java | 78 +++++++++++++++---- .../designer/creator/PropertyGroupPane.java | 54 +++++++++---- .../designer/creator/XWidgetCreator.java | 2 +- .../widget/ui/FormWidgetCardPane.java | 6 +- .../FormWidgetDefinePaneFactoryBase.java | 10 +-- .../ui/designer/AbstractDataModify.java | 12 +++ .../widget/ui/designer/WidgetDefinePane.java | 72 +++++++++++++++++ 11 files changed, 273 insertions(+), 62 deletions(-) create mode 100644 designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java diff --git a/designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java b/designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java index 3155653243..e4729f0709 100644 --- a/designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java +++ b/designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java @@ -15,14 +15,15 @@ import java.beans.PropertyDescriptor; */ public final class CRPropertyDescriptor extends PropertyDescriptor { public static final String RENDERER = "renderer"; - - private PropertyChangeAdapter l; - + private boolean isSubProperty = false; + + private PropertyChangeAdapter l; + public CRPropertyDescriptor(String name, Class beanClass) throws IntrospectionException { super(name, beanClass); } - public CRPropertyDescriptor(String name, Class beanClass, String readMethod, String writeMethod) throws IntrospectionException{ + public CRPropertyDescriptor(String name, Class beanClass, String readMethod, String writeMethod) throws IntrospectionException { super(name, beanClass, readMethod, writeMethod); } @@ -33,17 +34,17 @@ public final class CRPropertyDescriptor extends PropertyDescriptor { } return this; } - - public CRPropertyDescriptor setPropertyChangeListener(PropertyChangeAdapter l) { - this.l = l; - return this; - } - public void firePropertyChanged() { - if (l != null) { - l.propertyChange(); - } - } + public CRPropertyDescriptor setPropertyChangeListener(PropertyChangeAdapter l) { + this.l = l; + return this; + } + + public void firePropertyChanged() { + if (l != null) { + l.propertyChange(); + } + } public CRPropertyDescriptor setEditorClass(Class clazz) { this.setPropertyEditorClass(clazz); @@ -59,4 +60,13 @@ public final class CRPropertyDescriptor extends PropertyDescriptor { this.setDisplayName(displayName); return this; } + + public CRPropertyDescriptor setSubLevel(boolean isSubProperty) { + this.isSubProperty = isSubProperty; + return this; + } + + public boolean isSubLevel() { + return isSubProperty; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java index c2a1893d32..5343b20f1c 100644 --- a/designer_base/src/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import com.fr.design.constants.UIConstants; +import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import javax.swing.JComponent; import javax.swing.JOptionPane; @@ -64,7 +65,15 @@ public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor } protected ITextComponent createTextField() { - return new TextField(); + return new TextField() { + public void registerChangeListener(UIObserverListener listener) { + return; + } + + public boolean shouldResponseChangeListener() { + return false; + } + }; } private void initComponents() { diff --git a/designer_form/src/com/fr/design/designer/beans/ComponentAdapter.java b/designer_form/src/com/fr/design/designer/beans/ComponentAdapter.java index 58a5206c2b..3caffb33a0 100644 --- a/designer_form/src/com/fr/design/designer/beans/ComponentAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/ComponentAdapter.java @@ -9,6 +9,7 @@ import javax.swing.JPopupMenu; import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.events.DesignerEditor; +import com.fr.design.designer.creator.PropertyGroupPane; /** * 组件适配器接口 @@ -40,6 +41,12 @@ public interface ComponentAdapter { */ ArrayList getXCreatorPropertyModel(); + /** + * 为当前组件创建描述各属性pane, 分组返回 + * @return ArrayList + */ + ArrayList getXCreatorPropertyPane(); + /** * 提供双击设计器的编辑器 * @param bean 鼠标双击的被设计组件 diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java index 12bd2515f8..9ddad66409 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java @@ -7,6 +7,7 @@ import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.actions.ChangeNameAction; import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.creator.CRPropertyDescriptor; +import com.fr.design.designer.creator.PropertyGroupPane; import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XCreator; import com.fr.design.form.util.XCreatorConstants; @@ -90,6 +91,30 @@ public class CompositeComponentAdapter implements ComponentAdapter { private ArrayList createPropertyGroupModels(CRPropertyDescriptor[] properties) { HashMap> maps = new HashMap>(); + ArrayList groupNames = getGroupNames(properties, maps); + ArrayList groups = new ArrayList(); + for (String groupName : groupNames) { + ArrayList groupProperties = maps.get(groupName); + PropertyGroupModel groupModel = new PropertyGroupModel(groupName, xCreator, groupProperties + .toArray(new CRPropertyDescriptor[0]), designer); + groups.add(groupModel); + } + return groups; + } + + private ArrayList createPropertyGroupPanes(CRPropertyDescriptor[] properties) { + HashMap> maps = new HashMap>(); + ArrayList groupNames = getGroupNames(properties, maps); + ArrayList groups = new ArrayList(); + for (String groupName : groupNames) { + ArrayList groupProperties = maps.get(groupName); + PropertyGroupPane propertyGroupPane = new PropertyGroupPane(groupProperties.toArray(new CRPropertyDescriptor[0]), xCreator, groupName); + groups.add(propertyGroupPane); + } + return groups; + } + + private ArrayList getGroupNames(CRPropertyDescriptor[] properties, HashMap> maps ){ ArrayList groupNames = new ArrayList(); for (CRPropertyDescriptor property : properties) { String groupName = (String) property.getValue(XCreatorConstants.PROPERTY_CATEGORY); @@ -108,14 +133,7 @@ public class CompositeComponentAdapter implements ComponentAdapter { groupProperties.add(property); } adjustGroupNamesPosition(groupNames); - ArrayList groups = new ArrayList(); - for (String groupName : groupNames) { - ArrayList groupProperties = maps.get(groupName); - PropertyGroupModel groupModel = new PropertyGroupModel(groupName, xCreator, groupProperties - .toArray(new CRPropertyDescriptor[0]), designer); - groups.add(groupModel); - } - return groups; + return groupNames; } public void adjustGroupNamesPosition(ArrayList groupNames){ @@ -138,6 +156,17 @@ public class CompositeComponentAdapter implements ComponentAdapter { return groupModels; } + @Override + public ArrayList getXCreatorPropertyPane() { + ArrayList groupModels = new ArrayList(); + CRPropertyDescriptor[] properties; + properties = getCalculateCreatorProperties(); + ArrayList groups = createPropertyGroupPanes(properties); +// Collections.sort(groups); + groupModels.addAll(groups); + return groupModels; + } + /** * 自适应布局中放置文本框等用的scaleLayout和报表块、图表块支持的标题控件用的titleLayout时 * 控件树处只显示父容器,但是控件属性还是为自身的 diff --git a/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java b/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java index 5940291b45..b3d7983100 100644 --- a/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java +++ b/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java @@ -1,13 +1,19 @@ package com.fr.design.designer.creator; import com.fr.base.FRContext; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.xtable.TableUtils; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor; import com.fr.design.mainframe.widget.editors.StringEditor; import com.fr.form.ui.Widget; - -import java.awt.*; +import com.fr.general.ComparatorUtils; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyEditor; @@ -20,6 +26,7 @@ public class CRPropertyDescriptorPane { private CRPropertyDescriptor crPropertyDescriptor; private XCreator xCreator; private PropertyEditor propertyEditor; + private boolean isPopulate = true; public CRPropertyDescriptorPane(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator) { this.crPropertyDescriptor = crPropertyDescriptor; @@ -27,7 +34,19 @@ public class CRPropertyDescriptorPane { } public Component[] createTableLayoutComponent() { - return new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), initEditorComponent(crPropertyDescriptor, xCreator)}; + Component component = initEditorComponent(crPropertyDescriptor, xCreator); + if (component instanceof UICheckBox) { + ((UICheckBox) component).setText(crPropertyDescriptor.getDisplayName()); + return new Component[]{component, null}; + } + if (crPropertyDescriptor.isSubLevel()) { + JPanel subPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), component}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1); + subPanel.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, 0, 0)); + return new Component[]{subPanel, null}; + } + return new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), component}; + } private Component initEditorComponent(CRPropertyDescriptor crPropertyDescriptor, final XCreator xCreator) { @@ -35,22 +54,40 @@ public class CRPropertyDescriptorPane { try { // 如果已有的编辑器就生成对应的component Class editorClass = crPropertyDescriptor.getPropertyEditorClass(); + ExtendedPropertyEditor editor = null; if (editorClass != null) { - propertyEditor = initExtendEditor(crPropertyDescriptor, xCreator); - component = propertyEditor.getCustomEditor(); + editor = (ExtendedPropertyEditor) crPropertyDescriptor.createPropertyEditor(xCreator.toData()); + if (editor == null) { + Class propType = crPropertyDescriptor.getPropertyType(); + editor = TableUtils.getPropertyEditorClass(propType).newInstance(); + } + } else { Class propType = crPropertyDescriptor.getPropertyType(); - Class defaultEditorClass = TableUtils.getPropertyEditorClass(propType); + Class defaultEditorClass = TableUtils.getPropertyEditorClass(propType); if (defaultEditorClass == null) { defaultEditorClass = StringEditor.class; } - propertyEditor = defaultEditorClass.newInstance(); - component = propertyEditor.getCustomEditor(); + editor = defaultEditorClass.newInstance(); } - propertyEditor.addPropertyChangeListener(new PropertyChangeListener() { + propertyEditor = editor; + component = propertyEditor.getCustomEditor(); + final ExtendedPropertyEditor extendEditor = editor; + + extendEditor.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { + if (isPopulate) { + return; + } + if (ComparatorUtils.equals(extendEditor.getValue(), getValue(xCreator.toData()))) { + return; + } update(xCreator.toData()); + if (extendEditor.refreshInTime()) { + WidgetPropertyPane.getInstance().refreshDockingView(); + } + } }); } catch (Exception e) { @@ -71,19 +108,34 @@ public class CRPropertyDescriptorPane { public void populate(Widget widget) { try { - Method m = crPropertyDescriptor.getReadMethod(); - Object value = m.invoke(widget); + isPopulate = true; + Object value = getValue(widget); propertyEditor.setValue(value); + isPopulate = false; } catch (Exception e) { - + FRContext.getLogger().error(e.getMessage(), e); } } + public Object getValue(Widget widget) { + try { + Method m = crPropertyDescriptor.getReadMethod(); + Object value = m.invoke(widget); + return value; + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + return null; + } + } + public void update(Widget widget) { try { + Object value = propertyEditor.getValue(); Method m = crPropertyDescriptor.getWriteMethod(); - m.invoke(widget, propertyEditor.getValue()); + m.invoke(widget, value); + + crPropertyDescriptor.firePropertyChanged(); } catch (Exception e) { } diff --git a/designer_form/src/com/fr/design/designer/creator/PropertyGroupPane.java b/designer_form/src/com/fr/design/designer/creator/PropertyGroupPane.java index 9033426959..890595ffec 100644 --- a/designer_form/src/com/fr/design/designer/creator/PropertyGroupPane.java +++ b/designer_form/src/com/fr/design/designer/creator/PropertyGroupPane.java @@ -8,8 +8,12 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.FreeButton; import com.fr.form.ui.Widget; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; /** * Created by kerry on 2017/9/7. @@ -18,6 +22,16 @@ public class PropertyGroupPane extends BasicPane { private CRPropertyDescriptor[] crPropertyDescriptors; private CRPropertyDescriptorPane[] crPropertyDescriptorPanes; private XCreator xCreator; + private String groupName; + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + public PropertyGroupPane(CRPropertyDescriptor[] crPropertyDescriptors, XCreator xCreator) { this.crPropertyDescriptors = crPropertyDescriptors; @@ -26,6 +40,12 @@ public class PropertyGroupPane extends BasicPane { initComponent(); } + + public PropertyGroupPane(CRPropertyDescriptor[] crPropertyDescriptors, XCreator xCreator, String groupName) { + this(crPropertyDescriptors, xCreator); + this.groupName = groupName; + } + public void initComponent() { int count = crPropertyDescriptors.length; crPropertyDescriptorPanes = new CRPropertyDescriptorPane[count]; @@ -40,8 +60,8 @@ public class PropertyGroupPane extends BasicPane { this.add(panel, BorderLayout.CENTER); } - public void populate(Widget widget){ - for(int i = 0; i< crPropertyDescriptorPanes.length; i++){ + public void populate(Widget widget) { + for (int i = 0; i < crPropertyDescriptorPanes.length; i++) { crPropertyDescriptorPanes[i].populate(widget); } } @@ -52,19 +72,19 @@ public class PropertyGroupPane extends BasicPane { } public static void main(String[] args) { - try{ - XCreator xCreator = new XButton(new FreeButton(),new Dimension(100, 100)); - PropertyGroupPane propertyGroupPane = new PropertyGroupPane(xCreator.supportedDescriptor(), xCreator); - JFrame jf = new JFrame("jFrame"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(propertyGroupPane, BorderLayout.CENTER); - jf.setSize(439, 400); - jf.setVisible(true); - }catch (Exception e){ - FRContext.getLogger().error(e.getMessage()); - } + try { + XCreator xCreator = new XButton(new FreeButton(), new Dimension(100, 100)); + PropertyGroupPane propertyGroupPane = new PropertyGroupPane(xCreator.supportedDescriptor(), xCreator); + JFrame jf = new JFrame("jFrame"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(new BorderLayout()); + content.add(propertyGroupPane, BorderLayout.CENTER); + jf.setSize(439, 400); + jf.setVisible(true); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage()); + } } diff --git a/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java b/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java index 21ff4ed20c..c1d9d950aa 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java @@ -57,7 +57,7 @@ public abstract class XWidgetCreator extends XCreator { }), new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName") .setI18NName(Inter.getLocText("FR-Designer_Label_Name")) - .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Advanced") + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") }; } diff --git a/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 0bc744e51c..166ac74e80 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -156,7 +156,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { private void initDefinePane() { currentEditorDefinePane = null; XCreator creator = getXCreatorDedicated(); - FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, creator.toData(), new Operator() { + FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, designer, creator.toData(), new Operator() { @Override public void did(DataCreatorUI ui, String cardName) { //todo @@ -170,7 +170,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { currentEditorDefinePane = definePane; } - private XCreator getXCreatorDedicated(){ + private XCreator getXCreatorDedicated() { boolean dedicateLayout = xCreator.acceptType(XWScaleLayout.class) && xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator() || xCreator.acceptType(XWTitleLayout.class); return dedicateLayout ? (XCreator) xCreator.getComponent(0) : xCreator; } @@ -205,7 +205,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { public void updateCreator() { currentEditorDefinePane.setGlobalName(getGlobalName()); Widget widget = currentEditorDefinePane.updateBean(); - if(ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Widget_Name"))){ + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Widget_Name"))) { widgetPropertyPane.update(widget); xCreator.resetCreatorName(widget.getWidgetName()); designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); diff --git a/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java b/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java index 7c39755491..8fba8220f8 100644 --- a/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java +++ b/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java @@ -3,6 +3,8 @@ package com.fr.design.widget; import com.fr.base.FRContext; import com.fr.design.designer.creator.XCreator; import com.fr.design.gui.core.WidgetConstants; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.widget.ui.designer.WidgetDefinePane; import com.fr.design.parameter.RootDesignDefinePane; import com.fr.design.widget.ui.designer.*; import com.fr.design.widget.ui.designer.layout.*; @@ -11,7 +13,6 @@ import com.fr.form.ui.*; import com.fr.form.ui.container.*; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; -import com.fr.general.Inter; import com.fr.stable.bridge.BridgeMark; import com.fr.stable.bridge.StableFactory; @@ -66,8 +67,6 @@ public class FormWidgetDefinePaneFactoryBase { defineMap.put(WCardLayout.class, new Appearance(WCardLayoutDefinePane.class, "wCardLayout")); defineMap.put(Label.class, new Appearance(LabelDefinePane.class, "label")); defineMap.put(WTabFitLayout.class, new Appearance(WTabFitLayoutDefinePane.class, "wTabFitLayout")); - //todo 添加扩展控件接口 -// defineMap.putAll(getOtherWidgetOptionMap()); } @@ -76,10 +75,11 @@ public class FormWidgetDefinePaneFactoryBase { } - public static RN createWidgetDefinePane(XCreator creator, Widget widget, Operator operator) { + public static RN createWidgetDefinePane(XCreator creator, FormDesigner designer, Widget widget, Operator operator) { Appearance dn = defineMap.get(widget.getClass()); if(dn == null){ - dn = new Appearance(DefaultWidgetDefinePane.class, "default"); + WidgetDefinePane widgetDefinePane = new WidgetDefinePane(creator, designer); + return new RN(widgetDefinePane, widgetDefinePane.title4PopupWindow()); } DataModify definePane = null; try { diff --git a/designer_form/src/com/fr/design/widget/ui/designer/AbstractDataModify.java b/designer_form/src/com/fr/design/widget/ui/designer/AbstractDataModify.java index 3aca5f00a7..36c6531c95 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/AbstractDataModify.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/AbstractDataModify.java @@ -3,6 +3,7 @@ package com.fr.design.widget.ui.designer; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.creator.XCreator; +import com.fr.design.mainframe.FormDesigner; import com.fr.design.widget.DataModify; import javax.swing.JComponent; @@ -13,18 +14,29 @@ import javax.swing.JComponent; */ public abstract class AbstractDataModify extends BasicBeanPane implements DataModify { protected XCreator creator; + protected FormDesigner designer; protected String globalName; public AbstractDataModify(XCreator xCreator){ this.creator = xCreator; } + + public AbstractDataModify(XCreator xCreator, FormDesigner designer){ + this.creator = xCreator; + this.designer = designer; + } @Override public DataCreatorUI dataUI() { return null; } + @Override + public String title4PopupWindow() { + return creator.createDefaultName(); + } + @Override public JComponent toSwingComponent() { return this; diff --git a/designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java new file mode 100644 index 0000000000..f582fdd323 --- /dev/null +++ b/designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java @@ -0,0 +1,72 @@ +package com.fr.design.widget.ui.designer; + +import com.fr.design.designer.beans.AdapterBus; +import com.fr.design.designer.beans.ComponentAdapter; +import com.fr.design.designer.creator.PropertyGroupPane; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.Widget; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.util.ArrayList; + +/** + * Created by kerry on 2017/9/27. + */ +public class WidgetDefinePane extends AbstractDataModify { + private ArrayList groupPanes; + private static final int START_INDEX = 1; + + public WidgetDefinePane(XCreator source, FormDesigner designer) { + super(source, designer); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + initComponent(source, designer); + } + + public void initComponent(XCreator source, FormDesigner designer) { + ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, source); + groupPanes = adapter.getXCreatorPropertyPane(); + //todo 留着做兼容,以后删掉 + for (int i = 0; i < groupPanes.size(); i++) { + if (ComparatorUtils.equals(groupPanes.get(i).getGroupName(), "Form-Basic_Properties")) { + groupPanes.remove(i); + } + } + + this.add(createCenterPane(START_INDEX), BorderLayout.CENTER); + } + + private JPanel createCenterPane(int index) { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + if (index != groupPanes.size()) { + jPanel.add(createExpandPane(groupPanes.get(index - 1)), BorderLayout.NORTH); + jPanel.add(createCenterPane(index + 1), BorderLayout.CENTER); + } else { + jPanel.add(createExpandPane(groupPanes.get(index - 1)), BorderLayout.CENTER); + } + return jPanel; + } + + + public JPanel createExpandPane(PropertyGroupPane propertyGroupPane) { + JPanel jPanel = new UIExpandablePane(Inter.getLocText(propertyGroupPane.getGroupName()), 280, 24, propertyGroupPane); + return jPanel; + } + + + public void populateBean(Widget ob) { + for (int i = 0; i < groupPanes.size(); i++) { + groupPanes.get(i).populate(ob); + } + } + + public Widget updateBean() { + return creator.toData(); + } + +} From daea83652112f1829d4791fa2e74a1ae9fcd61f2 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 28 Sep 2017 14:54:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E6=95=88?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/CRPropertyDescriptorPane.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java b/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java index b3d7983100..da0f4d9bcb 100644 --- a/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java +++ b/designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java @@ -95,17 +95,7 @@ public class CRPropertyDescriptorPane { } return component; } - - private PropertyEditor initExtendEditor(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator) throws Exception { - ExtendedPropertyEditor editor = (ExtendedPropertyEditor) crPropertyDescriptor.createPropertyEditor(xCreator.toData()); - if (editor == null) { - Class propType = crPropertyDescriptor.getPropertyType(); - editor = TableUtils.getPropertyEditorClass(propType).newInstance(); - } - - return editor; - } - + public void populate(Widget widget) { try { isPopulate = true;