From 7b44b4629b020ad2e1ac602cd1117535e47fca48 Mon Sep 17 00:00:00 2001 From: kerry Date: Sat, 30 Sep 2017 11:19:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/BasicSetVisiblePropertyPane.java | 50 +++++++++++++++++++ .../ui/FormBasicWidgetPropertyPane.java | 47 ++++------------- .../widget/ui/FormWidgetCardPane.java | 23 +++++---- .../ui/WidgetBasicPropertyPaneFactory.java | 21 ++++++++ .../widget/ui/designer/WidgetDefinePane.java | 8 --- 5 files changed, 94 insertions(+), 55 deletions(-) create mode 100644 designer_form/src/com/fr/design/mainframe/widget/ui/BasicSetVisiblePropertyPane.java create mode 100644 designer_form/src/com/fr/design/mainframe/widget/ui/WidgetBasicPropertyPaneFactory.java diff --git a/designer_form/src/com/fr/design/mainframe/widget/ui/BasicSetVisiblePropertyPane.java b/designer_form/src/com/fr/design/mainframe/widget/ui/BasicSetVisiblePropertyPane.java new file mode 100644 index 0000000000..e67bfc8bab --- /dev/null +++ b/designer_form/src/com/fr/design/mainframe/widget/ui/BasicSetVisiblePropertyPane.java @@ -0,0 +1,50 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.Widget; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by kerry on 2017/9/30. + */ +public class BasicSetVisiblePropertyPane extends FormBasicPropertyPane { + private UICheckBox visibleCheckBox; + + public BasicSetVisiblePropertyPane() { + initComponent(); + } + + protected void initComponent() { + JPanel pane2 = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); + pane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + UICheckBox otherOtherConfig = createOtherConfig(); + if(otherOtherConfig != null){ + pane2.add(otherOtherConfig); + } + visibleCheckBox = new UICheckBox(Inter.getLocText("Widget-Visible"), true); + visibleCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + pane2.add(visibleCheckBox); + this.add(pane2, BorderLayout.CENTER); + } + + public UICheckBox createOtherConfig(){ + return null; + } + + public void populate(Widget widget) { + super.populate(widget); + visibleCheckBox.setSelected(widget.isVisible()); + } + + public void update(Widget widget) { + super.update(widget); + widget.setVisible(visibleCheckBox.isSelected()); + } + + +} diff --git a/designer_form/src/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java b/designer_form/src/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java index 4ab334d49c..d6aa882960 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java +++ b/designer_form/src/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java @@ -1,42 +1,24 @@ package com.fr.design.mainframe.widget.ui; -import com.fr.design.designer.creator.XCreator; import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.layout.FRGUIPaneFactory; import com.fr.form.ui.Widget; import com.fr.general.Inter; - import javax.swing.BorderFactory; -import javax.swing.JPanel; -import java.awt.BorderLayout; /** * Created by ibm on 2017/7/26. */ -public class FormBasicWidgetPropertyPane extends FormBasicPropertyPane { +public class FormBasicWidgetPropertyPane extends BasicSetVisiblePropertyPane { private UICheckBox enableCheckBox; - private UICheckBox visibleCheckBox; - private XCreator xCreator; - public FormBasicWidgetPropertyPane (XCreator xCreator){ - this.xCreator = xCreator; - initOtherPane(); + public FormBasicWidgetPropertyPane() { + super(); } - protected void initOtherPane() { - JPanel pane2 = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - pane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - if(xCreator.supportSetEnable()){ - enableCheckBox = new UICheckBox(Inter.getLocText("Enabled"), true); - enableCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); - pane2.add(enableCheckBox); - } - if(xCreator.supportSetVisible()){ - visibleCheckBox = new UICheckBox(Inter.getLocText("Widget-Visible"), true); - visibleCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); - pane2.add(visibleCheckBox); - } - this.add(pane2, BorderLayout.CENTER); + public UICheckBox createOtherConfig() { + enableCheckBox = new UICheckBox(Inter.getLocText("Enabled"), true); + enableCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + return enableCheckBox; } @Override @@ -46,22 +28,13 @@ public class FormBasicWidgetPropertyPane extends FormBasicPropertyPane { public void populate(Widget widget) { super.populate(widget); - if(xCreator.supportSetEnable()){ - enableCheckBox.setSelected(widget.isEnabled()); - } - if(xCreator.supportSetVisible()){ - visibleCheckBox.setSelected(widget.isVisible()); - } + enableCheckBox.setSelected(widget.isEnabled()); + } public void update(Widget widget) { super.update(widget); - if(xCreator.supportSetEnable()){ - widget.setEnabled(enableCheckBox.isSelected()); - } - if(xCreator.supportSetVisible()){ - widget.setVisible(visibleCheckBox.isSelected()); - } + widget.setEnabled(enableCheckBox.isSelected()); } } 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 54b6877a5c..b621b1a7fb 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 @@ -109,6 +109,8 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { private void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + XCreator innerCreator = getXCreatorDedicated(); + final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); BasicScrollPane basicScrollPane = new BasicScrollPane() { @Override @@ -127,21 +129,20 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { } }; this.add(basicScrollPane, BorderLayout.CENTER); + attriCardPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.add(attriCardPane, BorderLayout.CENTER); + jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - XCreator innerCreator = getXCreatorDedicated(); + if(FormWidgetDefinePaneFactoryBase.isWidget(innerCreator.toData())){ + return; + } - widgetPropertyPane = new FormBasicWidgetPropertyPane(innerCreator); + widgetPropertyPane = WidgetBasicPropertyPaneFactory.createBasicPropertyPane(innerCreator); UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), 280, 20, widgetPropertyPane); jPanel.add(uiExpandablePane, BorderLayout.NORTH); - attriCardPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - - jPanel.add(attriCardPane, BorderLayout.CENTER); - this.listener = new AttributeChangeListener() { @Override public void attributeChange() { @@ -194,7 +195,9 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { innerWidget = crBoundsWidget.getWidget(); } currentEditorDefinePane.populateBean(innerWidget); - widgetPropertyPane.populate(innerWidget); + if(widgetPropertyPane != null){ + widgetPropertyPane.populate(innerWidget); + } reinitAllListeners(); this.addAttributeChangeListener(listener); } @@ -203,7 +206,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 != null) { widgetPropertyPane.update(widget); xCreator.resetCreatorName(widget.getWidgetName()); designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); diff --git a/designer_form/src/com/fr/design/mainframe/widget/ui/WidgetBasicPropertyPaneFactory.java b/designer_form/src/com/fr/design/mainframe/widget/ui/WidgetBasicPropertyPaneFactory.java new file mode 100644 index 0000000000..db98069094 --- /dev/null +++ b/designer_form/src/com/fr/design/mainframe/widget/ui/WidgetBasicPropertyPaneFactory.java @@ -0,0 +1,21 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.designer.creator.XCreator; + +/** + * Created by kerry on 2017/9/30. + */ +public class WidgetBasicPropertyPaneFactory { + + public static FormBasicPropertyPane createBasicPropertyPane(XCreator xCreator){ + if(xCreator.supportSetVisible() && xCreator.supportSetEnable()){ + return new FormBasicWidgetPropertyPane(); + } + if(xCreator.supportSetVisible()){ + return new BasicSetVisiblePropertyPane(); + }else{ + return new FormBasicPropertyPane(); + } + + } +} 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 index f582fdd323..5bc9691daf 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java @@ -8,7 +8,6 @@ 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; @@ -31,13 +30,6 @@ public class WidgetDefinePane extends AbstractDataModify { 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); }