From 658e5912b06b62df1b11e28bf12f469960474f77 Mon Sep 17 00:00:00 2001 From: Lee Date: Thu, 28 Apr 2016 19:48:54 +0800 Subject: [PATCH 01/41] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=B5=84?= =?UTF-8?q?=E8=AE=AF=E6=A1=86=E5=85=BC=E5=AE=B9=EF=BC=8C=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E8=AE=AF=E6=A1=86=E6=8E=A5=E5=8F=97=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/mainframe/bbs/bbs.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/bbs.properties b/designer/src/com/fr/design/mainframe/bbs/bbs.properties index 44db03d46..0a387ef9e 100644 --- a/designer/src/com/fr/design/mainframe/bbs/bbs.properties +++ b/designer/src/com/fr/design/mainframe/bbs/bbs.properties @@ -16,4 +16,4 @@ USER2=\u963F\u8FEA(\u8C22\u8FEA) USER3=bingjie(\u5F20\u8BB0\u82B1) USER4=\u6D77\u7EF5\u5B9D\u5B9D(\u90DD\u6B63) VERIFY_URL=http://www.finereporthelp.com:8081/bbs/ReportServer?op=bbs&cmd=verify -UPDATE_INFO_URL=http://bbs.finereport.com/source/plugin/infor/infor.html +UPDATE_INFO_URL=http://bbs.finereport.com/source/plugin/infor/newinfor.html From 05c3e3b86ea4c41185e4f610bcb54e88967291af Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 16 May 2016 23:51:36 +0800 Subject: [PATCH 02/41] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD=E5=B7=B2?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=EF=BC=8C=E6=89=8B=E6=9C=BA=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E9=AB=98=E5=BA=A6=E7=9A=84=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E6=B5=8B=E8=AF=95=E5=8F=AF=E8=A1=8C=E3=80=82=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=AB=98=E5=BA=A6=E6=AF=94=EF=BC=9A0.75=EF=BC=8875%?= =?UTF-8?q?=EF=BC=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/designer/creator/XElementCase.java | 103 ++++++++++++------ 1 file changed, 69 insertions(+), 34 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XElementCase.java b/designer_form/src/com/fr/design/designer/creator/XElementCase.java index 32af5487a..c0c859f1f 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -7,9 +7,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.widget.editors.BooleanEditor; -import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; -import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; +import com.fr.design.mainframe.widget.editors.*; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.form.FormElementCaseContainerProvider; @@ -53,37 +51,74 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme * @return 返回组件属性值 * @throws IntrospectionException 异常 */ - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - - CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{ - new CRPropertyDescriptor("widgetName", this.data.getClass()) - .setI18NName(Inter.getLocText("Form-Widget_Name")), - new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( - WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName( - Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") - .setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - initStyle(); - } - }), - new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) - .setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Layout_Padding")) - .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("showToolBar", this.data.getClass()).setEditorClass(BooleanEditor.class) - .setI18NName(Inter.getLocText("Form-EC_toolbar")) - .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - - }; - - FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getPropertyTableEditor(); - if (processor == null){ - return propertyTableEditor; - } - PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass()); - return (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraEditor); - } + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + CRPropertyDescriptor[] crp = ((ElementCaseEditor) data).isHeightRestrict() ? revealHeightLimit() : getDefault(); + FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getPropertyTableEditor(); + if (processor == null) { + return crp; + } + PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass()); + return (CRPropertyDescriptor[]) ArrayUtils.addAll(crp, extraEditor); + } + + protected CRPropertyDescriptor createNonListenerProperties(int i) throws IntrospectionException { + CRPropertyDescriptor[] propertyTableEditor = { + new CRPropertyDescriptor("widgetName", this.data.getClass()) + .setI18NName(Inter.getLocText("Form-Widget_Name")), + new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( + WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName( + Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) + .setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Layout_Padding")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("showToolBar", this.data.getClass()).setEditorClass(BooleanEditor.class) + .setI18NName(Inter.getLocText("Form-EC_toolbar")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("heightRestrict", this.data.getClass()).setEditorClass(InChangeBooleanEditor.class) + .setI18NName(Inter.getLocText("Form-EC_heightrestrict")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("heightPercent", this.data.getClass()).setEditorClass(DoubleEditor.class) + .setI18NName(Inter.getLocText("Form-EC_heightpercent")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") + }; + return propertyTableEditor[i]; + } + + protected CRPropertyDescriptor[] revealHeightLimit() throws IntrospectionException { + return new CRPropertyDescriptor[] { + createNonListenerProperties(0), + createNonListenerProperties(1). + setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + initStyle(); + } + }), + createNonListenerProperties(2), + createNonListenerProperties(3), + createNonListenerProperties(4), + createNonListenerProperties(5) + }; + } + + protected CRPropertyDescriptor[] getDefault() throws IntrospectionException { + return new CRPropertyDescriptor[] { + createNonListenerProperties(0), + createNonListenerProperties(1). + setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + initStyle(); + } + }), + createNonListenerProperties(2), + createNonListenerProperties(3), + createNonListenerProperties(4) + }; + } + @Override protected String getIconName() { From e294105982aa64bd6ac0189f01480050f1daa943 Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 16 May 2016 23:56:48 +0800 Subject: [PATCH 03/41] =?UTF-8?q?=E4=B8=8A=E4=B8=8A=E6=AC=A1=E5=AF=B9?= =?UTF-8?q?=E8=B5=84=E8=AE=AF=E6=A1=86=E7=9A=84=E6=9B=B4=E6=94=B9=E6=92=A4?= =?UTF-8?q?=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/mainframe/bbs/bbs.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/bbs.properties b/designer/src/com/fr/design/mainframe/bbs/bbs.properties index 0a387ef9e..44db03d46 100644 --- a/designer/src/com/fr/design/mainframe/bbs/bbs.properties +++ b/designer/src/com/fr/design/mainframe/bbs/bbs.properties @@ -16,4 +16,4 @@ USER2=\u963F\u8FEA(\u8C22\u8FEA) USER3=bingjie(\u5F20\u8BB0\u82B1) USER4=\u6D77\u7EF5\u5B9D\u5B9D(\u90DD\u6B63) VERIFY_URL=http://www.finereporthelp.com:8081/bbs/ReportServer?op=bbs&cmd=verify -UPDATE_INFO_URL=http://bbs.finereport.com/source/plugin/infor/newinfor.html +UPDATE_INFO_URL=http://bbs.finereport.com/source/plugin/infor/infor.html From 301628c23b6d9d5afc157c517c9d743022c138bc Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 17 May 2016 09:24:13 +0800 Subject: [PATCH 04/41] =?UTF-8?q?=E7=A7=BB=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/report/ExcelExportPane.java | 1 - designer/src/com/fr/design/report/ReportExportAttrPane.java | 1 - designer_base/src/com/fr/design/fun/ExportAttrTabProvider.java | 1 + .../src/com/fr/design/{fun => report}/AbstractExportPane.java | 2 +- 4 files changed, 2 insertions(+), 3 deletions(-) rename designer_base/src/com/fr/design/{fun => report}/AbstractExportPane.java (88%) diff --git a/designer/src/com/fr/design/report/ExcelExportPane.java b/designer/src/com/fr/design/report/ExcelExportPane.java index f2b699f3b..3bd7378c9 100644 --- a/designer/src/com/fr/design/report/ExcelExportPane.java +++ b/designer/src/com/fr/design/report/ExcelExportPane.java @@ -4,7 +4,6 @@ package com.fr.design.report; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import com.fr.design.fun.AbstractExportPane; import com.fr.design.gui.ilable.UILabel; import javax.swing.*; diff --git a/designer/src/com/fr/design/report/ReportExportAttrPane.java b/designer/src/com/fr/design/report/ReportExportAttrPane.java index 93a690bb9..f3df79528 100644 --- a/designer/src/com/fr/design/report/ReportExportAttrPane.java +++ b/designer/src/com/fr/design/report/ReportExportAttrPane.java @@ -4,7 +4,6 @@ import javax.swing.*; import com.fr.design.ExtraDesignClassManager; import com.fr.design.dialog.BasicPane; -import com.fr.design.fun.AbstractExportPane; import com.fr.design.fun.ExportAttrTabProvider; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.general.Inter; diff --git a/designer_base/src/com/fr/design/fun/ExportAttrTabProvider.java b/designer_base/src/com/fr/design/fun/ExportAttrTabProvider.java index d16db4ea1..7a7161531 100644 --- a/designer_base/src/com/fr/design/fun/ExportAttrTabProvider.java +++ b/designer_base/src/com/fr/design/fun/ExportAttrTabProvider.java @@ -1,5 +1,6 @@ package com.fr.design.fun; +import com.fr.design.report.AbstractExportPane; import com.fr.stable.fun.Level; import javax.swing.*; diff --git a/designer_base/src/com/fr/design/fun/AbstractExportPane.java b/designer_base/src/com/fr/design/report/AbstractExportPane.java similarity index 88% rename from designer_base/src/com/fr/design/fun/AbstractExportPane.java rename to designer_base/src/com/fr/design/report/AbstractExportPane.java index bb585a02d..efbde8d37 100644 --- a/designer_base/src/com/fr/design/fun/AbstractExportPane.java +++ b/designer_base/src/com/fr/design/report/AbstractExportPane.java @@ -1,4 +1,4 @@ -package com.fr.design.fun; +package com.fr.design.report; import com.fr.design.dialog.BasicPane; From d5e6b3fcdf9403945f398a8a4a6c9af3aa8a639d Mon Sep 17 00:00:00 2001 From: Lee Date: Tue, 17 May 2016 10:17:21 +0800 Subject: [PATCH 05/41] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB?= =?UTF-8?q?=E6=80=A7=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/designer/creator/XElementCase.java | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XElementCase.java b/designer_form/src/com/fr/design/designer/creator/XElementCase.java index c0c859f1f..0e45b426d 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -23,6 +23,8 @@ import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; +import java.util.ArrayList; +import java.util.List; public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ private UILabel imageLable; @@ -61,13 +63,20 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return (CRPropertyDescriptor[]) ArrayUtils.addAll(crp, extraEditor); } - protected CRPropertyDescriptor createNonListenerProperties(int i) throws IntrospectionException { + protected List createNonListenerProperties() throws IntrospectionException { CRPropertyDescriptor[] propertyTableEditor = { new CRPropertyDescriptor("widgetName", this.data.getClass()) .setI18NName(Inter.getLocText("Form-Widget_Name")), new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName( - Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"). + setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + initStyle(); + } + }), new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) .setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Layout_Padding")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), @@ -76,47 +85,32 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), new CRPropertyDescriptor("heightRestrict", this.data.getClass()).setEditorClass(InChangeBooleanEditor.class) .setI18NName(Inter.getLocText("Form-EC_heightrestrict")) - .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("heightPercent", this.data.getClass()).setEditorClass(DoubleEditor.class) - .setI18NName(Inter.getLocText("Form-EC_heightpercent")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") }; - return propertyTableEditor[i]; + + List defaultList = new ArrayList<>(); + + for (CRPropertyDescriptor propertyDescriptor : propertyTableEditor) { + defaultList.add(propertyDescriptor); + } + return defaultList; } protected CRPropertyDescriptor[] revealHeightLimit() throws IntrospectionException { - return new CRPropertyDescriptor[] { - createNonListenerProperties(0), - createNonListenerProperties(1). - setPropertyChangeListener(new PropertyChangeAdapter() { + CRPropertyDescriptor heightLimitProperty = new CRPropertyDescriptor("heightPercent", this.data.getClass()) + .setEditorClass(DoubleEditor.class) + .setI18NName(Inter.getLocText("Form-EC_heightpercent")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"); - @Override - public void propertyChange() { - initStyle(); - } - }), - createNonListenerProperties(2), - createNonListenerProperties(3), - createNonListenerProperties(4), - createNonListenerProperties(5) - }; + ArrayList defaultList = (ArrayList) createNonListenerProperties(); + defaultList.add(heightLimitProperty); + + return defaultList.toArray(new CRPropertyDescriptor[defaultList.size()]); } protected CRPropertyDescriptor[] getDefault() throws IntrospectionException { - return new CRPropertyDescriptor[] { - createNonListenerProperties(0), - createNonListenerProperties(1). - setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - initStyle(); - } - }), - createNonListenerProperties(2), - createNonListenerProperties(3), - createNonListenerProperties(4) - }; + ArrayList defaultList = (ArrayList) createNonListenerProperties(); + return defaultList.toArray(new CRPropertyDescriptor[defaultList.size()]); } From 3b4d25b2ab2414cc4e781cb72e482016d0ad7b3b Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Tue, 17 May 2016 12:59:43 +0800 Subject: [PATCH 06/41] =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/ReportMobileAttrAction.java | 74 +++++++++++ .../com/fr/design/mainframe/JWorkBook.java | 3 +- .../report/mobile/MobileRadioGroupPane.java | 118 ++++++++++++++++++ .../report/mobile/ReportMobileAttrPane.java | 62 +++++++++ .../com/fr/design/images/m_report/mobile.png | Bin 0 -> 928 bytes .../fr/design/designer/creator/XCreator.java | 10 ++ .../design/designer/creator/XElementCase.java | 8 +- .../designer/creator/XWTitleLayout.java | 13 +- .../mobile/ElementCasePropertyTable.java | 68 ++++++++++ .../mobile/ElementCasePropertyUI.java | 29 +++++ .../mobile/MobileFitAlignmentItems.java | 25 ++++ .../properties/mobile/MobileFitEditor.java | 50 ++++++++ .../properties/mobile/MobileFitRender.java | 10 ++ .../properties/mobile/MobileFitWrapper.java | 9 ++ .../design/gui/xtable/PropertyGroupModel.java | 4 + .../design/mainframe/WidgetPropertyPane.java | 43 +++++-- 16 files changed, 508 insertions(+), 18 deletions(-) create mode 100644 designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java create mode 100644 designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java create mode 100644 designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java create mode 100644 designer_base/src/com/fr/design/images/m_report/mobile.png create mode 100644 designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java create mode 100644 designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java create mode 100644 designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java create mode 100644 designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java create mode 100644 designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java create mode 100644 designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java diff --git a/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java b/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java new file mode 100644 index 000000000..3248370ef --- /dev/null +++ b/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java @@ -0,0 +1,74 @@ +package com.fr.design.actions.report; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.JWorkBookAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JWorkBook; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.report.mobile.ReportMobileAttrPane; +import com.fr.general.Inter; +import com.fr.main.TemplateWorkBook; +import com.fr.report.mobile.ElementCaseMobileAttr; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * 设置cpt在移动端的一些属性, 包括自适应以及以后可能加展示区域之类的东西. + * + * Created by Administrator on 2016/5/12/0012. + */ +public class ReportMobileAttrAction extends JWorkBookAction{ + + public ReportMobileAttrAction(JWorkBook jwb) { + super(jwb); + this.setMenuKeySet(REPORT_APP_ATTR); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/mobile.png")); + } + + /** + * 执行动作 + * + * @return 是否执行成功 + */ + public void actionPerformed(ActionEvent evt) { + final JWorkBook jwb = getEditingComponent(); + if (jwb == null) { + return; + } + final TemplateWorkBook wbTpl = jwb.getTarget(); + ElementCaseMobileAttr mobileAttr = wbTpl.getReportMobileAttr(); + + final ReportMobileAttrPane mobileAttrPane = new ReportMobileAttrPane(); + mobileAttrPane.populateBean(mobileAttr); + BasicDialog dialog = mobileAttrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + wbTpl.setReportMobileAttr(mobileAttrPane.updateBean()); + jwb.fireTargetModified(); + } + }); + dialog.setVisible(true); + } + + private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'P'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_Mobile-Attr"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index d3e63782d..1455ee011 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -7,10 +7,10 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.ExitAuthorityEditAction; -import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.export.*; import com.fr.design.actions.report.ReportExportAttrAction; +import com.fr.design.actions.report.ReportMobileAttrAction; import com.fr.design.actions.report.ReportParameterAction; import com.fr.design.actions.report.ReportWebAttrAction; import com.fr.design.constants.UIConstants; @@ -478,6 +478,7 @@ public class JWorkBook extends JTemplate { new ReportWebAttrAction(this), new ReportExportAttrAction(this), new ReportParameterAction(this), + new ReportMobileAttrAction(this), new NameSeparator(Inter.getLocText("Utils-Current_Sheet")), }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); } diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java new file mode 100644 index 000000000..85cee58e8 --- /dev/null +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -0,0 +1,118 @@ +package com.fr.design.report.mobile; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.base.mobile.MobileFitAttrState; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Administrator on 2016/5/16/0016. + */ +public class MobileRadioGroupPane extends BasicBeanPane{ + + private List radioButtons = new ArrayList(); + + public MobileRadioGroupPane(String title) { + initComponents(title); + } + + private void initComponents(String title) { + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {p, p, p, p, p}; + + UIRadioButton defaultRadio = new UIRadioButton(MobileFitAttrState.DEFAULT.description()); + defaultRadio.setSelected(true); + UIRadioButton horizonRadio = new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()); + UIRadioButton verticalRadio = new UIRadioButton(MobileFitAttrState.VERTICAL.description()); + UIRadioButton notFitRadio = new UIRadioButton(MobileFitAttrState.NONE.description()); + + addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(title), defaultRadio, horizonRadio, verticalRadio, notFitRadio} + }; + JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); + + this.add(fitOpsPane); + } + + private void addToButtonGroup(UIRadioButton... radios) { + ButtonGroup buttonGroup = new ButtonGroup(); + for (UIRadioButton radio : radios) { + radioButtons.add(radio); + buttonGroup.add(radio); + } + } + + /** + * 设置按钮状态 + */ + public void setEnabled(boolean enabled) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.setEnabled(enabled); + } + } + + /** + * 获取当前选中的按钮index + * + * @return 按钮index + */ + public int getSelectRadioIndex() { + for (int i = 0, len = radioButtons.size(); i < len; i++) { + if (radioButtons.get(i).isSelected()) { + return i; + } + } + + return 0; + } + + /** + * 选中指定index的按钮 + */ + public void selectIndexButton(int index) { + if (index < 0 || index > radioButtons.size() - 1) { + return; + } + + UIRadioButton button = radioButtons.get(index); + button.setSelected(true); + } + + /** + * 给所有的按钮加上监听 + */ + public void addActionListener(ActionListener actionListener) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.addActionListener(actionListener); + } + } + + @Override + public void populateBean(MobileFitAttrState ob) { + selectIndexButton(ob.getState()); + } + + @Override + public MobileFitAttrState updateBean() { + int index = getSelectRadioIndex(); + return MobileFitAttrState.parse(index); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} diff --git a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java new file mode 100644 index 000000000..67f0ab825 --- /dev/null +++ b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java @@ -0,0 +1,62 @@ +package com.fr.design.report.mobile; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Inter; +import com.fr.report.mobile.ElementCaseMobileAttr; +import com.fr.base.mobile.MobileFitAttrState; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by Administrator on 2016/5/12/0012. + */ +public class ReportMobileAttrPane extends BasicBeanPane{ + + //横屏设置面板 + private MobileRadioGroupPane horizionPane; + //竖屏设置面板 + private MobileRadioGroupPane verticalPane; + + public ReportMobileAttrPane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow()); + + JPanel fitOpsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + horizionPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Horizontal")); + verticalPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Vertical")); + fitOpsPane.add(horizionPane, BorderLayout.NORTH); + fitOpsPane.add(verticalPane, BorderLayout.SOUTH); + + borderPane.add(fitOpsPane); + this.add(borderPane); + } + + @Override + public void populateBean(ElementCaseMobileAttr ob) { + if (ob == null) { + ob = new ElementCaseMobileAttr(); + } + + horizionPane.populateBean(ob.getHorziontalAttr()); + verticalPane.populateBean(ob.getVerticalAttr()); + } + + @Override + public ElementCaseMobileAttr updateBean() { + MobileFitAttrState horizonState = horizionPane.updateBean(); + MobileFitAttrState verticalState = verticalPane.updateBean(); + + return new ElementCaseMobileAttr(horizonState, verticalState); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Fit-App"); + } +} diff --git a/designer_base/src/com/fr/design/images/m_report/mobile.png b/designer_base/src/com/fr/design/images/m_report/mobile.png new file mode 100644 index 0000000000000000000000000000000000000000..69600f5154465877e70b70fb83597d6ecea2ef8d GIT binary patch literal 928 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>P#=1J2l)T-B#IQDo7|%2C!a7=KuP~pm)>g5 zS>0K?|Lx3HkXT+Bc`bMO+Nx43dW2{FKbJN{|K}$cBcl*Q11m!dD^p8| zhFz~O>H{_Sfov$wPb(=;EJ|hY%uP&B^-WCAOwLv?)3eaC&^0tr2sAWPsIV}LH#1Ry zS#M~mkWo@nV5P5LUS6)33DO0`KwWzIMd_?Ob4-CIOMpxc$tcZDva)i?PcF?(%`368 z3IHlCW-wg-e>cc>WHn&Bt*ks!Gt)Cl7>rEKULJOl1ga57G6$+AJTs*v1Ei$NNW=xG zL=s7fZ)R?4No7GQ1K3si1$pWAo5K9i%<&BYs$wuSwzM!bHU?5FonEX4DiK05CpfbT z7~Fbh-cC+m7kcFaWuuT}LxVgS(lT>Wfgzxuk)N9i3WuWn{1R|@q$UE)%C y=qIP->1O7p>%j$+^Yn|0lJyM@P0S1-q=C5}(3y$f8DfC8FnGH9xvX(); + CRPropertyDescriptor[] propertyTableEditor = null; + try { + propertyTableEditor = new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("horziontalAttr", this.xCreator.toData().getClass()).setEditorClass(MobileFitEditor.class) + .setRendererClass(MobileFitRender.class) + .setI18NName(Inter.getLocText("FR-Designer_Mobile-Horizontal")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit-App")), + new CRPropertyDescriptor("verticalAttr", this.xCreator.toData().getClass()).setEditorClass(MobileFitEditor.class) + .setRendererClass(MobileFitRender.class) + .setI18NName(Inter.getLocText("FR-Designer_Mobile-Vertical")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit-App")) + + }; + } catch (IntrospectionException e) { + FRContext.getLogger().error(e.getMessage()); + } + + + groups.add(new PropertyGroup(new PropertyGroupModel(Inter.getLocText("FR-Designer_Fit-App"), xCreator, propertyTableEditor, designer))); + + TableModel model = new BeanTableModel(); + setModel(model); + this.repaint(); + } + + @Override + public void firePropertyEdit() { + } + + public void populate(FormDesigner designer) { + this.designer = designer; + initPropertyGroups(this.designer.getTarget()); + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java new file mode 100644 index 000000000..5e7721a2e --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java @@ -0,0 +1,29 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XElementCase; +import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.general.Inter; + +/** + * Created by Administrator on 2016/5/16/0016. + */ +public class ElementCasePropertyUI extends AbstractWidgetPropertyUIProvider{ + + private XCreator xCreator; + + public ElementCasePropertyUI(XElementCase xElementCase) { + this.xCreator = xElementCase; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return new ElementCasePropertyTable(xCreator); + } + + @Override + public String tableTitle() { + return Inter.getLocText("FR-Designer_Mobile-Attr"); + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java new file mode 100644 index 000000000..094249bf5 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java @@ -0,0 +1,25 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.base.mobile.MobileFitAttrState; +import com.fr.design.designer.properties.items.Item; +import com.fr.design.designer.properties.items.ItemProvider; + +public class MobileFitAlignmentItems implements ItemProvider{ + + private static Item[] VALUE_ITEMS; + + static { + MobileFitAttrState[] allStates = MobileFitAttrState.values(); + int len = allStates.length; + VALUE_ITEMS = new Item[len]; + for (int i = 0; i < len ; i++) { + VALUE_ITEMS[i] = new Item(allStates[i].description(), allStates[i]); + } + } + + @Override + public Item[] getItems() { + return VALUE_ITEMS; + } + +} diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java new file mode 100644 index 000000000..6591b9059 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java @@ -0,0 +1,50 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.properties.items.Item; +import com.fr.design.designer.properties.items.ItemProvider; +import com.fr.design.mainframe.widget.editors.ComboEditor; + +import java.util.Vector; + +public class MobileFitEditor extends ComboEditor{ + public MobileFitEditor() { + this(new MobileFitAlignmentItems()); + } + + public MobileFitEditor(ItemProvider provider) { + this(provider.getItems()); + } + + public MobileFitEditor(Item[] items) { + super(items); + } + + public MobileFitEditor(Vector items) { + super(items); + } + + @Override + public void setValue(Object value) { + if (value == null) { + return; + } + + Item item = new Item(value.toString(), value); + comboBox.setSelectedItem(item); + } + + @Override + public Object getValue() { + Item item = (Item) comboBox.getSelectedItem(); + return item.getValue(); + } + + /** + * 是否立即刷新 + * @return 是或者否 + */ + @Override + public boolean refreshInTime() { + return false; + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java new file mode 100644 index 000000000..6f560e4e3 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java @@ -0,0 +1,10 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; + +public class MobileFitRender extends EncoderCellRenderer{ + + public MobileFitRender(){ + super(new MobileFitWrapper()); + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java new file mode 100644 index 000000000..164bcc5c0 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java @@ -0,0 +1,9 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.properties.ItemWrapper; + +public class MobileFitWrapper extends ItemWrapper{ + public MobileFitWrapper(){ + super(new MobileFitAlignmentItems()); + } +} diff --git a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java index 926cbcaa6..143176553 100644 --- a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java +++ b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java @@ -133,6 +133,10 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel { editors[row].stopCellEditing(); } else { setValue(extendEditor.getValue(), row, 1); + + if (designer == null) { + return; + } if ("widgetName".equals(properties[row].getName())) { designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RENAMED); } else { diff --git a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java index d0d011328..57087597e 100644 --- a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java @@ -1,23 +1,23 @@ package com.fr.design.mainframe; -import java.awt.BorderLayout; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.*; - import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.designer.beans.events.DesignerEditListener; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.properties.EventPropertyTable; +import com.fr.design.designer.properties.WidgetPropertyTable; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.frpane.UITabbedPane; -import com.fr.general.Inter; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.designer.beans.events.DesignerEditListener; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.properties.EventPropertyTable; -import com.fr.design.designer.properties.WidgetPropertyTable; +import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; /** * 控件属性表Docking @@ -88,7 +88,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper tabbedPane.addTab(Inter.getLocText("Form-Properties"), psp); tabbedPane.addTab(Inter.getLocText("Form-Events"), esp); - WidgetPropertyUIProvider[] widgetAttrProviders = ExtraDesignClassManager.getInstance().getWidgetAttrProviders(); + WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); widgetPropertyTables.add(propertyTable); @@ -106,6 +106,25 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper } } + /** + * 获取当前控件扩展的属性tab + * 来源有两个: + * 1, 各个控件从各自的Xcreator里扩展; + * 2, 所有的控件从插件里扩展. + * + * @return 扩展的tab + */ + private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() { + FormSelection selection = designer.getSelectionModel().getSelection(); + WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null; + if (selection != null && selection.getSelectedCreator() != null) { + embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); + } + WidgetPropertyUIProvider[] widgetAttrProviders = ExtraDesignClassManager.getInstance().getWidgetAttrProviders(); + widgetAttrProviders = (WidgetPropertyUIProvider[]) ArrayUtils.addAll(embeddedPropertyUIProviders, widgetAttrProviders); + return widgetAttrProviders; + } + public void setEditingFormDesigner(BaseFormDesigner editor) { FormDesigner fd = (FormDesigner) editor; super.setEditingFormDesigner(fd); From eefa01daaefdafd974dd9aaa8ca5a5d104810434 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 17 May 2016 14:29:17 +0800 Subject: [PATCH 07/41] =?UTF-8?q?=20=E5=8D=95=E5=85=83=E6=A0=BCTag?= =?UTF-8?q?=E5=A2=9E=E9=87=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/fun/ExportToolBarProvider.java | 13 ++----------- .../com/fr/design/fun/GlobalListenerProvider.java | 6 +++++- .../src/com/fr/design/fun/HighlightProvider.java | 6 +----- .../design/fun/ServerTableDataDefineProvider.java | 3 +-- .../com/fr/design/fun/TableDataDefineProvider.java | 14 +++++++------- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java b/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java index d09817401..c2c560260 100644 --- a/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java +++ b/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java @@ -6,9 +6,6 @@ import javax.swing.*; /** * 导出菜单设计器端拓展,用于控制该菜单是否在web端显示 - * @author focus - * @date Jul 2, 2015 - * @since 8.0 */ public interface ExportToolBarProvider extends Level{ @@ -16,8 +13,6 @@ public interface ExportToolBarProvider extends Level{ int CURRENT_LEVEL = 1; - - /** * * 用于添加 控制web端是否显示该菜单的checkbox的面板 @@ -28,16 +23,12 @@ public interface ExportToolBarProvider extends Level{ JPanel updateCenterPane(JPanel pane); /** - * 根据xml里面存的web段按钮显示状态更新对应的checkbox - * + * 更新界面 */ void populate(); /** - * 根据checkbox控制web段菜单是否显示 - * - * @return + * 保存界面设置 */ void update(); - } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/GlobalListenerProvider.java b/designer_base/src/com/fr/design/fun/GlobalListenerProvider.java index 87e3f99ee..7fbd9b371 100644 --- a/designer_base/src/com/fr/design/fun/GlobalListenerProvider.java +++ b/designer_base/src/com/fr/design/fun/GlobalListenerProvider.java @@ -7,6 +7,7 @@ import java.awt.event.AWTEventListener; /** * Created by zack on 2015/8/17. + * 全局事件监听 */ public interface GlobalListenerProvider extends Level{ @@ -14,6 +15,9 @@ public interface GlobalListenerProvider extends Level{ int CURRENT_LEVEL = 1; - + /** + * 返回一个AWT监听事件给系统注册 + * @return AWT监听事件 + */ AWTEventListener listener(); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/HighlightProvider.java b/designer_base/src/com/fr/design/fun/HighlightProvider.java index 596134073..ebee36932 100644 --- a/designer_base/src/com/fr/design/fun/HighlightProvider.java +++ b/designer_base/src/com/fr/design/fun/HighlightProvider.java @@ -5,10 +5,7 @@ import com.fr.design.condition.ConditionAttributesPane; import com.fr.stable.fun.Level; /** - * @author richie - * @date 2015-03-26 - * @since 8.0 - * 条件属性接口 + * 条件属性界面设计接口 */ public interface HighlightProvider extends Level{ @@ -16,7 +13,6 @@ public interface HighlightProvider extends Level{ int CURRENT_LEVEL = 1; - /** * 条件属性的实现类 * @return 实现类 diff --git a/designer_base/src/com/fr/design/fun/ServerTableDataDefineProvider.java b/designer_base/src/com/fr/design/fun/ServerTableDataDefineProvider.java index 63d8d6221..5b38cae35 100644 --- a/designer_base/src/com/fr/design/fun/ServerTableDataDefineProvider.java +++ b/designer_base/src/com/fr/design/fun/ServerTableDataDefineProvider.java @@ -7,6 +7,5 @@ package com.fr.design.fun; */ public interface ServerTableDataDefineProvider extends TableDataDefineProvider { - public static final String XML_TAG = "ServerTableDataDefineProvider"; - + String XML_TAG = "ServerTableDataDefineProvider"; } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/TableDataDefineProvider.java b/designer_base/src/com/fr/design/fun/TableDataDefineProvider.java index 8eb835903..4ddfa9a95 100644 --- a/designer_base/src/com/fr/design/fun/TableDataDefineProvider.java +++ b/designer_base/src/com/fr/design/fun/TableDataDefineProvider.java @@ -11,7 +11,7 @@ import com.fr.stable.fun.Level; */ public interface TableDataDefineProvider extends Level { - public static final String XML_TAG = "TableDataDefineProvider"; + String XML_TAG = "TableDataDefineProvider"; int CURRENT_LEVEL = 1; @@ -19,35 +19,35 @@ public interface TableDataDefineProvider extends Level { * 自定义的数据集设置界面所对应的数据集类型 * @return 数据集的类型 */ - public Class classForTableData(); + Class classForTableData(); /** * 自定义数据集设置界面所对应的初始化数据集类型,在一种数据集有多个实现的时候有效 * @return 数据集类型 */ - public Class classForInitTableData(); + Class classForInitTableData(); /** * 自定义的数据集设置界面所对应的界面类型 * @return 数据集界面类型 */ - public Class appearanceForTableData(); + Class appearanceForTableData(); /** * 自定义数据集设置界面在菜单上的现实名字 * @return 名字 */ - public String nameForTableData(); + String nameForTableData(); /** * 自定义数据集在新建的时候名字前缀 * @return 名字前缀 */ - public String prefixForTableData(); + String prefixForTableData(); /** * 自定义数据集在菜单上现实的图标 * @return 图标 */ - public String iconPathForTableData(); + String iconPathForTableData(); } \ No newline at end of file From cef2c42140903950f7268ce89c5c3fa20a5edae8 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 17 May 2016 17:27:47 +0800 Subject: [PATCH 08/41] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=EF=BC=8C?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=95=B0=E6=8D=AE=E9=9B=86=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/designer.iml | 1 + .../present/ConditionAttributesGroupPane.java | 4 +- .../com/fr/design/present/StyleArrayPane.java | 4 +- .../report/share/ConfusionManagerPane.java | 4 +- .../fr/design/widget/WidgetConfigPane.java | 4 +- designer_base/designer_base.iml | 2 +- .../fr/design/ExtraDesignClassManager.java | 16 +- .../data/datapane/ReportTableDataPane.java | 24 +- .../data/datapane/TableDataListPane.java | 6 +- .../data/datapane/TableDataTreePane.java | 4 +- .../datapane/connect/ConnectionListPane.java | 4 +- .../tabledatapane/ProcedureListPane.java | 4 +- .../tabledatapane/TableDataManagerPane.java | 36 +- .../design/formula/FunctionManagerPane.java | 4 +- ...essor.java => TableDataPaneProcessor.java} | 11 +- ...ssor.java => AbstractTDPaneProcessor.java} | 4 +- .../design/gui/controlpane/JControlPane.java | 1273 ++++------------- .../gui/controlpane/JListControlPane.java | 1028 +++++++++++++ .../gui/controlpane/ObjectJControlPane.java | 2 +- .../design/gui/frpane/HyperlinkGroupPane.java | 4 +- .../design/parameter/ParameterArrayPane.java | 4 +- designer_base/src/com/fr/env/EnvListPane.java | 4 +- .../com/fr/design/chart/ChartControlPane.java | 4 +- .../design/chart/axis/ChartAlertLinePane.java | 4 +- .../SeriesCondition/DataSeriesAttrPane.java | 4 +- .../SeriesCondition/TrendLineControlPane.java | 4 +- .../com/fr/design/mainframe/MapArrayPane.java | 2 +- .../module/ChartPreStyleManagerPane.java | 4 +- 28 files changed, 1370 insertions(+), 1099 deletions(-) rename designer_base/src/com/fr/design/fun/{TableDataTreePaneProcessor.java => TableDataPaneProcessor.java} (60%) rename designer_base/src/com/fr/design/fun/impl/{AbstractTDTreePaneProcessor.java => AbstractTDPaneProcessor.java} (55%) create mode 100644 designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java diff --git a/designer/designer.iml b/designer/designer.iml index c798a6fe0..276f91e81 100644 --- a/designer/designer.iml +++ b/designer/designer.iml @@ -17,5 +17,6 @@ + \ No newline at end of file diff --git a/designer/src/com/fr/design/present/ConditionAttributesGroupPane.java b/designer/src/com/fr/design/present/ConditionAttributesGroupPane.java index 0632fe01d..5cfcb6261 100644 --- a/designer/src/com/fr/design/present/ConditionAttributesGroupPane.java +++ b/designer/src/com/fr/design/present/ConditionAttributesGroupPane.java @@ -6,7 +6,7 @@ import java.util.List; import com.fr.base.FRContext; import com.fr.general.NameObject; import com.fr.design.condition.HighLightConditionAttributesPane; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.general.Inter; @@ -15,7 +15,7 @@ import com.fr.report.cell.cellattr.highlight.Highlight; import com.fr.report.cell.cellattr.highlight.HighlightGroup; import com.fr.stable.Nameable; -public class ConditionAttributesGroupPane extends JControlPane { +public class ConditionAttributesGroupPane extends JListControlPane { @Override public NameableCreator[] createNameableCreators() { diff --git a/designer/src/com/fr/design/present/StyleArrayPane.java b/designer/src/com/fr/design/present/StyleArrayPane.java index 6107da1b7..061107462 100644 --- a/designer/src/com/fr/design/present/StyleArrayPane.java +++ b/designer/src/com/fr/design/present/StyleArrayPane.java @@ -2,7 +2,7 @@ package com.fr.design.present; import com.fr.base.Style; import com.fr.design.gui.controlpane.AbstractNameableCreator; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.gui.ilist.ListModelElement; @@ -18,7 +18,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class StyleArrayPane extends JControlPane { +public class StyleArrayPane extends JListControlPane { /** * Constructor. diff --git a/designer/src/com/fr/design/report/share/ConfusionManagerPane.java b/designer/src/com/fr/design/report/share/ConfusionManagerPane.java index eac62da91..89b3dbb9e 100644 --- a/designer/src/com/fr/design/report/share/ConfusionManagerPane.java +++ b/designer/src/com/fr/design/report/share/ConfusionManagerPane.java @@ -10,7 +10,7 @@ import java.util.List; import com.fr.data.TableDataSource; import com.fr.data.impl.EmbeddedTableData; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ShortCut4JControlPane; @@ -23,7 +23,7 @@ import com.fr.general.NameObject; * * @date: 2015-3-9-上午9:10:20 */ -public class ConfusionManagerPane extends JControlPane { +public class ConfusionManagerPane extends JListControlPane { /** * 获取当前面板的编辑对象 diff --git a/designer/src/com/fr/design/widget/WidgetConfigPane.java b/designer/src/com/fr/design/widget/WidgetConfigPane.java index a362af72f..78088920f 100644 --- a/designer/src/com/fr/design/widget/WidgetConfigPane.java +++ b/designer/src/com/fr/design/widget/WidgetConfigPane.java @@ -1,6 +1,6 @@ package com.fr.design.widget; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.core.WidgetConstants; @@ -17,7 +17,7 @@ import java.util.List; /** * Widget配置面板 */ -public class WidgetConfigPane extends JControlPane { +public class WidgetConfigPane extends JListControlPane { /** * 创建用户自定义widget组件 diff --git a/designer_base/designer_base.iml b/designer_base/designer_base.iml index 9f8c89a0b..15ff9cc8c 100644 --- a/designer_base/designer_base.iml +++ b/designer_base/designer_base.iml @@ -1,7 +1,7 @@ - + diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index 76d5d88af..a11ff53a6 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -126,7 +126,7 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private DesignerEnvProcessor envProcessor; - private TableDataTreePaneProcessor tableDataTreePaneProcessor; + private TableDataPaneProcessor tableDataPaneProcessor; private Set elementUIProviders; @@ -134,13 +134,13 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private Set exportAttrTabProviders; - public TableDataTreePaneProcessor getTableDataTreePaneProcessor() { - return tableDataTreePaneProcessor; + public TableDataPaneProcessor getTableDataPaneProcessor() { + return tableDataPaneProcessor; } - public void setTableDataSourceOPProcessor(Level level, PluginSimplify simplify) { - validAPILevel(level, TableDataTreePaneProcessor.CURRENT_LEVEL, simplify.getPluginName()); - tableDataTreePaneProcessor = (TableDataTreePaneProcessor) level; + public void setTableDataPaneProcessor(Level level, PluginSimplify simplify) { + validAPILevel(level, TableDataPaneProcessor.CURRENT_LEVEL, simplify.getPluginName()); + tableDataPaneProcessor = (TableDataPaneProcessor) level; } public DesignerEnvProcessor getEnvProcessor() { @@ -858,8 +858,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi addSupportDesignApps(impl, simplify); } else if (tagName.equals(DesignerEnvProcessor.XML_TAG)) { setEnvProcessor(impl, simplify); - } else if (tagName.equals(TableDataTreePaneProcessor.XML_TAG)) { - setTableDataSourceOPProcessor(impl, simplify); + } else if (tagName.equals(TableDataPaneProcessor.XML_TAG)) { + setTableDataPaneProcessor(impl, simplify); } else if (tagName.equals(ElementUIProvider.MARK_STRING)) { addElementUIProvider(impl, simplify); } else if (tagName.equals(WidgetPropertyUIProvider.XML_TAG)) { diff --git a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java index e62aaa530..003a478b1 100644 --- a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java @@ -4,6 +4,9 @@ package com.fr.design.data.datapane; import com.fr.data.TableDataSource; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.TableDataPaneProcessor; +import com.fr.design.gui.controlpane.JControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.layout.FRGUIPaneFactory; @@ -19,19 +22,24 @@ import java.util.Map; * 创建于2011-6-14 */ public class ReportTableDataPane extends LoadingBasicPane { - private TableDataListPane tdListPane; + private JControlPane tdPane; @Override protected void initComponents(JPanel container) { container.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.tdListPane = new TableDataListPane() { + TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); + JControlPane pane = null; + if (paneProcessor != null) { + pane = paneProcessor.createServerTableDataPane(); + } + tdPane = pane == null ? new TableDataListPane() { @Override public NameableCreator[] createNameableCreators() { return TableDataCreatorProducer.getInstance().createReportTableDataCreator(); } - }; - container.add(tdListPane, BorderLayout.CENTER); + } : pane; + container.add(tdPane, BorderLayout.CENTER); } @Override @@ -40,11 +48,11 @@ public class ReportTableDataPane extends LoadingBasicPane { } public void populate(TableDataSource tds) { - tdListPane.populate(tds); + tdPane.populate(tds); } public void update(TableDataSource tds) { - tdListPane.update(tds); + tdPane.update(tds); } /** @@ -53,10 +61,10 @@ public class ReportTableDataPane extends LoadingBasicPane { * @throws Exception 异常 */ public void checkValid() throws Exception { - this.tdListPane.checkValid(); + this.tdPane.checkValid(); } public Map getDsNameChangedMap() { - return tdListPane.getDsNameChangedMap(); + return tdPane.getDsNameChangedMap(); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java b/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java index 8de293f29..5c641d515 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java @@ -4,7 +4,7 @@ import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ilist.ListModelElement; import com.fr.file.DatasourceManagerProvider; @@ -21,9 +21,7 @@ import java.util.*; /** * TableDataList Pane. */ -public class TableDataListPane extends JControlPane { - private Map dsNameChangedMap = new HashMap(); - private boolean isNamePermitted = true; +public class TableDataListPane extends JListControlPane { public TableDataListPane() { super(); diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index 106578362..fcaa7c6e7 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -14,7 +14,7 @@ import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.fun.TableDataTreePaneProcessor; +import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; @@ -47,7 +47,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { public synchronized static BasicTableDataTreePane getInstance(DesignModelAdapter tc) { - TableDataTreePaneProcessor treePaneProcessor = ExtraDesignClassManager.getInstance().getTableDataTreePaneProcessor(); + TableDataPaneProcessor treePaneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); if (treePaneProcessor != null) { return treePaneProcessor.createTableDataTreePane(tc); } diff --git a/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java index 1d5dd260a..725a65ad3 100644 --- a/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -4,7 +4,7 @@ import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.file.DatasourceManagerProvider; @@ -22,7 +22,7 @@ import java.util.*; /** * Connection List Pane. */ -public class ConnectionListPane extends JControlPane { +public class ConnectionListPane extends JListControlPane { public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection"); private boolean isNamePermitted = true; private HashMap renameMap = new HashMap(); diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureListPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureListPane.java index 5f5651628..636bc4b76 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureListPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureListPane.java @@ -3,7 +3,7 @@ package com.fr.design.data.tabledata.tabledatapane; import com.fr.data.TableDataSource; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ilist.ListModelElement; @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class ProcedureListPane extends JControlPane { +public class ProcedureListPane extends JListControlPane { public ProcedureListPane() { super(); this.addEditingListner(new PropertyChangeAdapter() { diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java index 55f975e38..0ff2ec881 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java @@ -1,7 +1,10 @@ package com.fr.design.data.tabledata.tabledatapane; import com.fr.base.FRContext; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.data.datapane.TableDataListPane; +import com.fr.design.fun.TableDataPaneProcessor; +import com.fr.design.gui.controlpane.JControlPane; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -18,7 +21,7 @@ import java.util.Map; public class TableDataManagerPane extends LoadingBasicPane { private UITextField tableDataTextField; - private TableDataListPane tableDataListPane; + private JControlPane tableDataPane; @Override protected void initComponents(JPanel container) { @@ -36,13 +39,18 @@ public class TableDataManagerPane extends LoadingBasicPane { this.tableDataTextField = new UITextField(); tableDataPathPane.add(tableDataTextField, BorderLayout.CENTER); this.tableDataTextField.setEditable(false); - tableDataListPane = new TableDataListPane(){ - protected void rename(String oldName,String newName){ - super.rename(oldName,newName); - renameConnection(oldName, newName); - } - }; - container.add(tableDataListPane, BorderLayout.CENTER); + TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); + JControlPane pane = null; + if (paneProcessor != null) { + pane = paneProcessor.createServerTableDataPane(); + } + tableDataPane = pane == null ? new TableDataListPane() { + protected void rename(String oldName, String newName) { + super.rename(oldName, newName); + renameConnection(oldName, newName); + } + } : pane; + container.add(tableDataPane, BorderLayout.CENTER); } @@ -51,7 +59,7 @@ public class TableDataManagerPane extends LoadingBasicPane { * @return 是则返回true */ public boolean isNamePermitted(){ - return tableDataListPane.isNamePermitted(); + return tableDataPane.isNamePermitted(); } /** @@ -59,7 +67,7 @@ public class TableDataManagerPane extends LoadingBasicPane { * @throws Exception 异常 */ public void checkValid() throws Exception { - tableDataListPane.checkValid(); + tableDataPane.checkValid(); } @Override @@ -70,15 +78,15 @@ public class TableDataManagerPane extends LoadingBasicPane { public void populate(DatasourceManagerProvider datasourceManager) { this.tableDataTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME + File.separator + datasourceManager.fileName()); - this.tableDataListPane.populate(datasourceManager); + this.tableDataPane.populate(datasourceManager); } public void update(DatasourceManagerProvider datasourceManager) { - this.tableDataListPane.update(datasourceManager); + this.tableDataPane.update(datasourceManager); } public Map getDsChangedNameMap () { - return this.tableDataListPane.getDsNameChangedMap(); + return this.tableDataPane.getDsNameChangedMap(); } /** @@ -87,6 +95,6 @@ public class TableDataManagerPane extends LoadingBasicPane { * @param index 选中项的序列号 */ public void setSelectedIndex(int index) { - this.tableDataListPane.setSelectedIndex(index); + this.tableDataPane.setSelectedIndex(index); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/formula/FunctionManagerPane.java b/designer_base/src/com/fr/design/formula/FunctionManagerPane.java index 4af0c2799..fd41df325 100644 --- a/designer_base/src/com/fr/design/formula/FunctionManagerPane.java +++ b/designer_base/src/com/fr/design/formula/FunctionManagerPane.java @@ -6,7 +6,7 @@ import com.fr.design.data.tabledata.tabledatapane.ClassNameSelectPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ibutton.UIButton; @@ -97,7 +97,7 @@ public class FunctionManagerPane extends BasicPane { /** * CellRenderer. */ - class FunctionControlPane extends JControlPane { + class FunctionControlPane extends JListControlPane { public FunctionControlPane() { super(); diff --git a/designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java similarity index 60% rename from designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java rename to designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java index 1789c2ca2..f1f4ac218 100644 --- a/designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java +++ b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java @@ -2,6 +2,7 @@ package com.fr.design.fun; import com.fr.design.DesignModelAdapter; import com.fr.design.data.BasicTableDataTreePane; +import com.fr.design.gui.controlpane.JControlPane; import com.fr.stable.fun.Level; /** @@ -10,8 +11,8 @@ import com.fr.stable.fun.Level; * Date: 2016/4/18 * Time: 9:04 */ -public interface TableDataTreePaneProcessor extends Level { - String XML_TAG = "TableDataTreePaneProcessor"; +public interface TableDataPaneProcessor extends Level { + String XML_TAG = "TableDataPaneProcessor"; int CURRENT_LEVEL = 1; /** @@ -20,4 +21,10 @@ public interface TableDataTreePaneProcessor extends Level { */ BasicTableDataTreePane createTableDataTreePane(DesignModelAdapter tc); + /** + * 服务器数据集面板(模板数据集面板) + * @return 服务器数据集面板 + */ + JControlPane createServerTableDataPane(); + } diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractTDTreePaneProcessor.java b/designer_base/src/com/fr/design/fun/impl/AbstractTDPaneProcessor.java similarity index 55% rename from designer_base/src/com/fr/design/fun/impl/AbstractTDTreePaneProcessor.java rename to designer_base/src/com/fr/design/fun/impl/AbstractTDPaneProcessor.java index 635739a07..e5f591a65 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractTDTreePaneProcessor.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractTDPaneProcessor.java @@ -1,13 +1,13 @@ package com.fr.design.fun.impl; -import com.fr.design.fun.TableDataTreePaneProcessor; +import com.fr.design.fun.TableDataPaneProcessor; /** * Coder: zack * Date: 2016/4/18 * Time: 10:30 */ -public abstract class AbstractTDTreePaneProcessor implements TableDataTreePaneProcessor { +public abstract class AbstractTDPaneProcessor implements TableDataPaneProcessor { @Override public int currentAPILevel() { return CURRENT_LEVEL; diff --git a/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java index e58a13615..615cee6a0 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java @@ -1,1026 +1,247 @@ -package com.fr.design.gui.controlpane; - -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; -import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; -import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; -import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; -import com.fr.design.actions.UpdateAction; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itoolbar.UIToolbar; -import com.fr.design.gui.ilist.JNameEdList; -import com.fr.design.gui.ilist.ListModelElement; -import com.fr.design.gui.ilist.ModNameActionListener; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.menu.*; -import com.fr.design.dialog.BasicPane; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.stable.ArrayUtils; -import com.fr.stable.Nameable; -import com.fr.stable.core.PropertyChangeAdapter; -import com.fr.design.utils.gui.GUICoreUtils; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Comparator; - -public abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper { - public static final String LIST_NAME = "JControl_List"; - private static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 - - private ShortCut4JControlPane[] shorts; - private NameableCreator[] creators; - protected JNameEdList nameableList; - protected JControlUpdatePane controlUpdatePane; - - private ToolBarDef toolbarDef; - private UIToolbar toolBar; - - // peter:这是整体的一个cardLayout Pane - private CardLayout cardLayout; - private JPanel cardPane; - protected int editingIndex; - protected String selectedName; - private boolean isNameRepeated = false; - - public JControlPane() { - this.initComponentPane(); - } - - /** - * 生成添加按钮的NameableCreator - * @return 按钮的NameableCreator - */ - public abstract NameableCreator[] createNameableCreators(); - - protected void initComponentPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.creators = this.createNameableCreators(); - this.controlUpdatePane = new JControlUpdatePane(); - - // p: edit card layout - this.cardLayout = new CardLayout(); - cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - cardPane.setLayout(this.cardLayout); - // p:选择的Label - UILabel selectLabel = new UILabel(); - cardPane.add(selectLabel, "SELECT"); - cardPane.add(controlUpdatePane, "EDIT"); - // SplitPane - JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); - mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); - mainSplitPane.setOneTouchExpandable(true); - - this.add(mainSplitPane, BorderLayout.CENTER); - mainSplitPane.setDividerLocation(getLeftPreferredSize()); - this.checkButtonEnabled(); - } - - - protected JPanel getLeftPane(){ - // LeftPane - JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - initNameList(leftPane); - - shorts = this.createShortcuts(); - if (ArrayUtils.isEmpty(shorts)) { - return leftPane; - } - - toolbarDef = new ToolBarDef(); - for (ShortCut4JControlPane sj : shorts) { - toolbarDef.addShortCut(sj.getShortCut()); - } - toolBar = ToolBarDef.createJToolBar(); - toolbarDef.updateToolBar(toolBar); - leftPane.add(toolBar, BorderLayout.NORTH); - return leftPane; - } - - - private void initNameList(JPanel leftPane) { - nameableList = createJNameList(); - nameableList.setName(LIST_NAME); - leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); - - - nameableList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - nameableList.addMouseListener(listMouseListener); - nameableList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - // richie:避免多次update和populate大大降低效率 - if (!evt.getValueIsAdjusting()) { - // shoc 切换的时候加检验 - if (hasInvalid(false)) { - return; - } - JControlPane.this.controlUpdatePane.update(); - JControlPane.this.controlUpdatePane.populate(); - JControlPane.this.checkButtonEnabled(); - } - } - }); - } - - public JNameEdList createJNameList() { - JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) { - protected void doAfterLostFocus() { - JControlPane.this.updateControlUpdatePane(); - } - }; - nameEdList.setCellRenderer(new NameableListCellRenderer()); - return nameEdList; - } - - public void updateControlUpdatePane() { - controlUpdatePane.update(); - } - - protected void doWhenPopulate(BasicBeanPane beanPane){ - - } - - protected int getLeftPreferredSize() { - return shorts.length * SHORT_WIDTH; - } - - protected ShortCut4JControlPane[] createShortcuts() { - return new ShortCut4JControlPane[]{ - addItemShortCut(), - removeItemShortCut(), - copyItemShortCut(), - moveUpItemShortCut(), - moveDownItemShortCut(), - sortItemShortCut() - }; - } - - protected ShortCut4JControlPane addItemShortCut() { - ShortCut addItemShortCut; - if (creators.length == 1) { - addItemShortCut = new AddItemUpdateAction(creators); - } else { - addItemShortCut = new AddItemMenuDef(creators); - } - return new AbsoluteEnableShortCut(addItemShortCut); - } - - protected ShortCut4JControlPane removeItemShortCut() { - return new NormalEnableShortCut(new RemoveItemAction()); - } - - protected ShortCut4JControlPane copyItemShortCut() { - return new NormalEnableShortCut(new CopyItemAction()); - } - - protected ShortCut4JControlPane moveUpItemShortCut() { - return new NormalEnableShortCut(new MoveUpItemAction()); - } - - protected ShortCut4JControlPane moveDownItemShortCut() { - return new NormalEnableShortCut(new MoveDownItemAction()); - } - - protected ShortCut4JControlPane sortItemShortCut() { - return new NormalEnableShortCut(new SortItemAction()); - } - - public void setNameListEditable(boolean editable) { - this.nameableList.setEditable(editable); - } - - public Nameable[] update() { - java.util.List res = new java.util.ArrayList(); - this.controlUpdatePane.update(); - DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); - for (int i = 0, len = listModel.getSize(); i < len; i++) { - res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); - } - - return res.toArray(new Nameable[res.size()]); - } - - public void populate(Nameable[] nameableArray) { - DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); - listModel.removeAllElements(); - if (ArrayUtils.isEmpty(nameableArray)) { - return; - } - - for (Nameable aNameableArray : nameableArray) { - listModel.addElement(new ListModelElement(aNameableArray)); - } - - if (listModel.size() > 0) { - this.nameableList.setSelectedIndex(0); - } - this.checkButtonEnabled(); - } - - /** - * 添加名字改变时的listener - * - * @param l 名字改变时的监听 - */ - public void addModNameActionListener(ModNameActionListener l) { - this.nameableList.addModNameActionListener(l); - } - - /** - * 添加Editinglistener - * - * @param l 监听 - */ - public void addEditingListner(PropertyChangeAdapter l) { - this.nameableList.addEditingListner(l); - } - - /* - * 刷新当前的选中的UpdatePane - */ - protected void populateSelectedValue() { - JControlPane.this.controlUpdatePane.populate(); - } - - /** - * 根据name,选中JNameEdList中的item - */ - public void setSelectedName(String name) { - DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); - for (int i = 0, len = listModel.getSize(); i < len; i++) { - Nameable item = ((ListModelElement) listModel.getElementAt(i)).wrapper; - if (ComparatorUtils.equals(name, item.getName())) { - this.nameableList.setSelectedIndex(i); - break; - } - } - } - - public String getEditingName() { - return this.nameableList.getEditingName(); - } - - public Object getEditingType() { - return this.nameableList.getAllTypes()[editingIndex]; - } - - public void setWarnigText(int index) { - this.nameableList.setWarnigText(index); - } - - /** - * 获取选中的名字 - */ - public String getSelectedName() { - ListModelElement el = (ListModelElement) this.nameableList.getSelectedValue(); - - return el == null ? null : el.wrapper.getName(); - } - - /** - * 刷新 NameableCreator - * - * @param creators 生成器 - */ - public void refreshNameableCreator(NameableCreator[] creators) { - this.creators = creators; - shorts = this.createShortcuts(); - toolbarDef.clearShortCuts(); - for (ShortCut4JControlPane sj : shorts) { - toolbarDef.addShortCut(sj.getShortCut()); - } - - toolbarDef.updateToolBar(toolBar); - toolBar.validate(); - toolBar.repaint(); - this.repaint(); - } - - protected boolean isNameRepeted(java.util.List[] list, String name) { - for (int i = 0; i < list.length; i++) { - if (list[i].contains(name)) { - isNameRepeated = true; - return true; - } - } - isNameRepeated = false; - return false; - } - - /** - * 名字是否重复 - * @return 重复则返回true - */ - public boolean isNameRepeated() { - return isNameRepeated; - } - - /** - * 添加 Nameable - * - * @param nameable 添加的Nameable - * @param index 序号 - */ - public void addNameable(Nameable nameable, int index) { - JNameEdList nameEdList = JControlPane.this.nameableList; - DefaultListModel model = (DefaultListModel) nameEdList.getModel(); - - ListModelElement el = new ListModelElement(nameable); - model.add(index, el); - nameableList.setSelectedIndex(index); - nameableList.ensureIndexIsVisible(index); - - nameEdList.repaint(); - } - - /** - * 是否重命名 - * @return 是则true - */ - public boolean isContainsRename() { - String rename = Inter.getLocText("FR-Please_Rename") + "!"; - String[] names = this.nameableList.getAllNames(); - for (int i = names.length - 1; i >= 0; i--) { - if (ComparatorUtils.equals(names[i], rename)) { - return true; - } - } - return false; - } - - protected DefaultListModel getModel() { - return (DefaultListModel) JControlPane.this.nameableList.getModel(); - } - - private String createUnrepeatedCopyName(String suffix) { - DefaultListModel model = this.getModel(); - String[] names = new String[model.getSize()]; - for (int i = 0; i < model.size(); i++) { - names[i] = ((ListModelElement) model.get(i)).wrapper.getName(); - } - String lastName = "CopyOf" + suffix; - while (ArrayUtils.contains(names, lastName)) { - lastName = "CopyOf" + lastName; - } - return lastName; - } - - - /** - * 生成不重复的名字 - * - * @param prefix 名字前缀 - * @return 名字 - */ - public String createUnrepeatedName(String prefix) { - DefaultListModel model = this.getModel(); - Nameable[] all = new Nameable[model.getSize()]; - for (int i = 0; i < model.size(); i++) { - all[i] = ((ListModelElement) model.get(i)).wrapper; - } - // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. - int count = all.length + 1; - while (true) { - String name_test = prefix + count; - boolean repeated = false; - for (int i = 0, len = model.size(); i < len; i++) { - Nameable nameable = all[i]; - if (ComparatorUtils.equals(nameable.getName(), name_test)) { - repeated = true; - break; - } - } - - if (!repeated) { - return name_test; - } - - count++; - } - } - - /** - * 增加项的UpdateAction - */ - protected class AddItemUpdateAction extends UpdateAction { - final NameableCreator creator; - - public AddItemUpdateAction(NameableCreator[] creators) { - this.creator = creators[0]; - this.setName(Inter.getLocText("FR-Action_Add")); - this.setMnemonic('A'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); - } - - public void actionPerformed(ActionEvent e) { - Nameable nameable = creator.createNameable(JControlPane.this); - - JControlPane.this.addNameable(nameable, getModel().getSize()); - } - } - - /* - * 增加项的MenuDef - */ - protected class AddItemMenuDef extends MenuDef { - public AddItemMenuDef(NameableCreator[] creators) { - this.setName(Inter.getLocText("FR-Action_Add")); - this.setMnemonic('A'); - this.setIconPath("/com/fr/design/images/control/addPopup.png"); - wrapActionListener(creators); - } - - private void wrapActionListener(NameableCreator[] creators) { - for (final NameableCreator creator : creators) { - if (!whetherAdd(creator.menuName())){ - continue; - } - boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || - ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Relation_TableData")) || ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Multi_Dimensional_Database")); - if (isTrue) { - this.addShortCut(new LineSeparator()); - } - this.addShortCut(new UpdateAction() { - { - this.setName(creator.menuName()); - Icon icon = creator.menuIcon(); - if (icon != null) { - this.setSmallIcon(icon); - } - } - - public void actionPerformed(ActionEvent e) { - if (hasInvalid(true)) { - return; - } - - Nameable nameable = creator.createNameable(JControlPane.this); - - JControlPane.this.addNameable(nameable, getModel().getSize()); - } - }); - } - } - - private boolean whetherAdd(String itemName){ - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate == null) { - return false; - } - //先屏蔽掉这个,之后还有别的 - String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; - for (String name : names){ - if(!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)){ - return false; - } - } - String formName = Inter.getLocText("Hyperlink-Form_link"); - return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); - } - } - - /* - * 移除item - */ - private class RemoveItemAction extends UpdateAction { - public RemoveItemAction() { - this.setName(Inter.getLocText("FR-Action_Remove")); - this.setMnemonic('R'); - this.setSmallIcon(BaseUtils - .readIcon("/com/fr/base/images/cell/control/remove.png")); - } - - public void actionPerformed(ActionEvent evt) { - try { - JControlPane.this.nameableList.getCellEditor() - .stopCellEditing(); - } catch (Exception ignored) { - } - // bug:在选中一个NameObject并删除,会遗留下Name. - doBeforeRemove(); - if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities - .getWindowAncestor(JControlPane.this), nameableList)) { - checkButtonEnabled(); - doAfterRemove(); - } - } - } - - /* - * CopyItem - */ - private class CopyItemAction extends UpdateAction { - public CopyItemAction() { - this.setName(Inter.getLocText("FR-Action_Copy")); - this.setMnemonic('C'); - this.setSmallIcon(BaseUtils - .readIcon("/com/fr/base/images/cell/control/copy.png")); - } - - public void actionPerformed(ActionEvent evt) { - // p:选中的值. - ListModelElement selectedValue = (ListModelElement) nameableList.getSelectedValue(); - if (selectedValue == null) { - return; - } - - controlUpdatePane.update(); - - Nameable selectedNameable = selectedValue.wrapper; - - // p: 用反射机制实现 - try { - Nameable newNameable = (Nameable) BaseUtils.cloneObject(selectedNameable); - newNameable.setName(createUnrepeatedCopyName(selectedNameable.getName())); - - JControlPane.this.addNameable(newNameable, nameableList.getSelectedIndex() + 1); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - } - - /* - * 上移Item - */ - private class MoveUpItemAction extends UpdateAction { - public MoveUpItemAction() { - this.setName(Inter.getLocText("Utils-Move_Up")); - this.setMnemonic('U'); - this.setSmallIcon(BaseUtils - .readIcon("/com/fr/design/images/control/up.png")); - } - - public void actionPerformed(ActionEvent evt) { - int selectedIndex = nameableList.getSelectedIndex(); - if (selectedIndex == -1) { - return; - } - - // 上移 - if (selectedIndex > 0) { - DefaultListModel listModel = (DefaultListModel) nameableList - .getModel(); - - Object selecteObj1 = listModel.get(selectedIndex - 1); - listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); - listModel.set(selectedIndex, selecteObj1); - - nameableList.setSelectedIndex(selectedIndex - 1); - nameableList.ensureIndexIsVisible(selectedIndex - 1); - } - } - } - - /* - * 下移Item - */ - private class MoveDownItemAction extends UpdateAction { - public MoveDownItemAction() { - this.setName(Inter.getLocText("Utils-Move_Down")); - this.setMnemonic('D'); - this.setSmallIcon(BaseUtils - .readIcon("/com/fr/design/images/control/down.png")); - } - - public void actionPerformed(ActionEvent evt) { - int selectedIndex = nameableList.getSelectedIndex(); - if (selectedIndex == -1) { - return; - } - - if (selectedIndex < nameableList.getModel().getSize() - 1) { - DefaultListModel listModel = (DefaultListModel) nameableList - .getModel(); - - Object selecteObj1 = listModel.get(selectedIndex + 1); - listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); - listModel.set(selectedIndex, selecteObj1); - - nameableList.setSelectedIndex(selectedIndex + 1); - nameableList.ensureIndexIsVisible(selectedIndex + 1); - } - } - } - - private class SortItemAction extends UpdateAction { - private boolean isAtoZ = false; - - public SortItemAction() { - this.setName(Inter.getLocText("FR-Action_Sort")); - this.setMnemonic('S'); - this.setSmallIcon(BaseUtils - .readIcon("/com/fr/design/images/control/sortAsc.png")); - } - - public void actionPerformed(ActionEvent evt) { - // p:选中的值. - Object selectedValue = nameableList.getSelectedValue(); - - DefaultListModel listModel = (DefaultListModel) nameableList - .getModel(); - Nameable[] nameableArray = new Nameable[listModel.getSize()]; - if (nameableArray.length <= 0) { - return; - } - - for (int i = 0; i < listModel.getSize(); i++) { - nameableArray[i] = ((ListModelElement) listModel.getElementAt(i)).wrapper; - } - - // p:排序. - if (isAtoZ) { - Comparator nameableComparator = new Comparator() { - public int compare(Nameable o1, Nameable o2) { - return -ComparatorUtils.compare(o1.getName(), o2 - .getName()); - } - }; - isAtoZ = !isAtoZ; - Arrays.sort(nameableArray, nameableComparator); - } else { - Comparator nameableComparator = new Comparator() { - public int compare(Nameable o1, Nameable o2) { - return ComparatorUtils.compare(o1.getName(), o2 - .getName()); - } - }; - isAtoZ = !isAtoZ; - Arrays.sort(nameableArray, nameableComparator); - } - - for (int i = 0; i < nameableArray.length; i++) { - listModel.set(i, new ListModelElement(nameableArray[i])); - } - - // p:需要选中以前的那个值. - if (selectedValue != null) { - nameableList.setSelectedValue(selectedValue, true); - } - - checkButtonEnabled(); - // p:需要repaint. - nameableList.repaint(); - } - } - - /* - * JNameEdList的鼠标事件 - */ - private MouseListener listMouseListener = new MouseAdapter() { - public void mouseReleased(MouseEvent evt) { - nameableList.stopEditing(); - if (evt.getClickCount() >= 2 - && SwingUtilities.isLeftMouseButton(evt)) { - editingIndex = nameableList.getSelectedIndex(); - selectedName = nameableList.getNameAt(editingIndex); - nameableList.editItemAt(nameableList.getSelectedIndex()); - } - // peter:处理右键的弹出菜单 - if (!SwingUtilities.isRightMouseButton(evt)) { - return; - } - - // peter: 注意,在checkButtonEnabled()方法里面,设置了所有的Action的Enabled. - checkButtonEnabled(); - - // p:右键菜单. - JPopupMenu popupMenu = new JPopupMenu(); - - for (ShortCut4JControlPane sj : shorts) { - sj.getShortCut().intoJPopupMenu(popupMenu); - } - - // peter: 只有弹出菜单有子菜单的时候,才需要弹出来. - GUICoreUtils.showPopupMenu(popupMenu, nameableList, evt.getX() - 1, - evt.getY() - 1); - } - - public void mouseMoved(MouseEvent e) { - - } - }; - - /** - * 检查按钮可用状态 Check button enabled. - */ - public void checkButtonEnabled() { - int selectedIndex = nameableList.getSelectedIndex(); - if (selectedIndex == -1) { - this.cardLayout.show(cardPane, "SELECT"); - } else { - this.cardLayout.show(cardPane, "EDIT"); - } - for (ShortCut4JControlPane sj : this.shorts) { - sj.checkEnable(); - } - } - - protected void doBeforeRemove(){ - - } - - protected void doAfterRemove(){ - - } - - public NameableCreator[] creators() { - return creators == null ? new NameableCreator[0] : creators; - } - - /* - * Nameable的ListCellRenerer - */ - private class NameableListCellRenderer extends - DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, - cellHasFocus); - - if (value instanceof ListModelElement) { - Nameable wrappee = ((ListModelElement) value).wrapper; - this.setText(((ListModelElement) value).wrapper.getName()); - - boolean iconSet = false; - for (NameableCreator creator : JControlPane.this.creators) { - if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) { - this.setIcon(creator.menuIcon()); - this.setToolTipText(creator.createTooltip()); - iconSet = true; - break; - } - } - if (!iconSet) { - this.setIcon(BaseUtils.readIcon("/com/fr/base/images/oem/cpt.png")); - } - } - - return this; - } - } - - public class AbsoluteEnableShortCut extends ShortCut4JControlPane { - public AbsoluteEnableShortCut(ShortCut shortCut) { - this.shortCut = shortCut; - } - - /** - * 检查是否可用 - */ - public void checkEnable() { - this.shortCut.setEnabled(true); - } - } - - public class NormalEnableShortCut extends ShortCut4JControlPane { - public NormalEnableShortCut(ShortCut shortCut) { - this.shortCut = shortCut; - } - - /** - * 检查是否可用 - */ - public void checkEnable() { - this.shortCut.setEnabled(getModel() - .getSize() > 0 - && JControlPane.this.nameableList.getSelectedIndex() != -1); - } - } - - public class SortEnableShortCut extends ShortCut4JControlPane { - public SortEnableShortCut(ShortCut shortCut) { - this.shortCut = shortCut; - } - - /** - * 检查是否可用 - */ - @Override - public void checkEnable() { - this.shortCut.setEnabled(getModel().getSize() > 1); - } - - } - - public class MoveUpEnableShortCut extends ShortCut4JControlPane { - public MoveUpEnableShortCut(ShortCut shortCut) { - this.shortCut = shortCut; - } - - /** - * 检查是否可用 - */ - @Override - public void checkEnable() { - this.shortCut.setEnabled(getModel().getSize() > 1 - && JControlPane.this.nameableList.getSelectedIndex() > 0); - } - - } - - public class MoveDownEnableShortCut extends ShortCut4JControlPane { - public MoveDownEnableShortCut(ShortCut shortCut) { - this.shortCut = shortCut; - } - - /** - * 检查是否可用 - */ - @Override - public void checkEnable() { - this.shortCut.setEnabled(getModel().getSize() > 1 - && JControlPane.this.nameableList.getSelectedIndex() < JControlPane.this.nameableList.getModel().getSize() - 1); - } - - } - - private class JControlUpdatePane extends JPanel { - private CardLayout card; - private JPanel cardPane; - private BasicBeanPane[] updatePanes; - - private ListModelElement elEditing; - - public JControlUpdatePane() { - initUpdatePane(); - } - - private void initUpdatePane() { - if (creators == null) { - return; - } - card = new CardLayout(); - cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - cardPane.setLayout(card); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.add(cardPane); - int len = creators.length; - updatePanes = new BasicBeanPane[len]; - } - - public void populate() { - ListModelElement el = (ListModelElement) JControlPane.this.nameableList.getSelectedValue(); - if (el == null) { - return; - } - - elEditing = el; - - for (int i = 0, len = updatePanes.length; i < len; i++) { - Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); - if (ob2Populate != null) { - if (updatePanes[i] == null) { - if (isMulti(creators[i].getUpdatePane()) || isTree(creators[i].getUpdatePane())) { - updatePanes[i] = createPaneByCreators(creators[i], el.wrapper.getName()); - } else { - updatePanes[i] = createPaneByCreators(creators[i]); - } - cardPane.add(updatePanes[i], String.valueOf(i)); - } - card.show(cardPane, String.valueOf(i)); - updatePanes[i].populateBean(ob2Populate); - doWhenPopulate(updatePanes[i]); - break; - } - } - } - - public boolean isMulti(Class _class){ - return ComparatorUtils.equals(_class, GlobalMultiTDTableDataPane.class) || ComparatorUtils.equals(_class, MultiTDTableDataPane.class); - } - - public boolean isTree(Class _class){ - return ComparatorUtils.equals(_class, GlobalTreeTableDataPane.class) || ComparatorUtils.equals(_class, TreeTableDataPane.class); - } - - public void update() { - for (int i = 0; i < updatePanes.length; i++) { - BasicBeanPane pane = updatePanes[i]; - - if (pane != null && pane.isVisible()) { - Object bean = pane.updateBean(); - if (i < JControlPane.this.creators.length) { - JControlPane.this.creators[i].saveUpdatedBean(elEditing, bean); - } - } - } - } - - public void checkValid() throws Exception { - if (updatePanes != null) { - for (int i = 0; i < updatePanes.length; i++) { - if (updatePanes[i] != null) { - updatePanes[i].checkValid(); - } - } - } - } - } - - protected BasicBeanPane createPaneByCreators(NameableCreator creator) { - try { - return creator.getUpdatePane().newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - protected BasicBeanPane createPaneByCreators(NameableCreator creator, String string) { - Constructor constructor = null; - try { - constructor = creator.getUpdatePane().getDeclaredConstructor(new Class[]{String.class}); - constructor.setAccessible(true); - return (BasicBeanPane) constructor.newInstance(string); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - - } - - // 选项添加个数有限制等情况下 要求能控制快捷按钮的状态 - protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) { - if (this.toolbarDef.getShortCutCount() > shortCutIndex) { - ShortCut sc = this.toolbarDef.getShortCut(shortCutIndex); - if (sc instanceof AddItemMenuDef) { - AddItemMenuDef am = (AddItemMenuDef) sc; - if (am.getShortCutCount() > itemIndex) { - am.getShortCut(itemIndex).setEnabled(enabled); - } - } - } - } - - /** - * 检查是否符合规范 - * - * @throws Exception - */ - public void checkValid() throws Exception { - this.controlUpdatePane.checkValid(); - } - - private int getInValidIndex() { - BasicBeanPane[] p = controlUpdatePane.updatePanes; - if (p != null) { - for (int i = 0; i < p.length; i++) { - if (p[i] != null) { - try { - p[i].checkValid(); - } catch (Exception e) { - return i; - } - } - } - } - return -1; - } - - private boolean hasInvalid(boolean isAdd) { - int idx = JControlPane.this.getInValidIndex(); - if (isAdd || nameableList.getSelectedIndex() != idx) { - try { - checkValid(); - } catch (Exception exp) { - JOptionPane.showMessageDialog(JControlPane.this, exp.getMessage()); - nameableList.setSelectedIndex(idx); - return true; - } - } - return false; - } - - - /** - * 设置选中项 - * - * @param index 选中项的序列号 - */ - public void setSelectedIndex(int index) { - nameableList.setSelectedIndex(index); - } -} \ No newline at end of file +package com.fr.design.gui.controlpane; + +import com.fr.data.TableDataSource; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.menu.ToolBarDef; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.file.DatasourceManagerProvider; +import com.fr.stable.ArrayUtils; +import com.fr.stable.Nameable; + +import javax.swing.*; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +/** + * Coder: zack + * Date: 2016/5/17 + * Time: 15:07 + */ +public abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper { + private static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 + + private ShortCut4JControlPane[] shorts; + private NameableCreator[] creators; + protected JPanel controlUpdatePane; + + private ToolBarDef toolbarDef; + private UIToolbar toolBar; + + // peter:这是整体的一个cardLayout Pane + private CardLayout cardLayout; + private JPanel cardPane; + protected String selectedName; + protected boolean isNamePermitted = true; + protected Map dsNameChangedMap = new HashMap(); + private boolean isNameRepeated = false; + + public JControlPane() { + this.initComponentPane(); + } + + /** + * 生成添加按钮的NameableCreator + * + * @return 按钮的NameableCreator + */ + public abstract NameableCreator[] createNameableCreators(); + + protected void initComponentPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.creators = this.createNameableCreators(); + this.controlUpdatePane = new JPanel(); + + // p: edit card layout + this.cardLayout = new CardLayout(); + cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + cardPane.setLayout(this.cardLayout); + // p:选择的Label + UILabel selectLabel = new UILabel(); + cardPane.add(selectLabel, "SELECT"); + cardPane.add(controlUpdatePane, "EDIT"); + // SplitPane + JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); + mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); + mainSplitPane.setOneTouchExpandable(true); + + this.add(mainSplitPane, BorderLayout.CENTER); + mainSplitPane.setDividerLocation(getLeftPreferredSize()); + this.checkButtonEnabled(); + } + + + protected JPanel getLeftPane() { + // LeftPane + JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + init(leftPane); + + shorts = this.createShortcuts(); + if (ArrayUtils.isEmpty(shorts)) { + return leftPane; + } + + toolbarDef = new ToolBarDef(); + for (ShortCut4JControlPane sj : shorts) { + toolbarDef.addShortCut(sj.getShortCut()); + } + toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + leftPane.add(toolBar, BorderLayout.NORTH); + return leftPane; + } + + /** + * 初始化 + */ + protected void init(JPanel leftPane) { + + } + + protected int getLeftPreferredSize() { + return shorts.length * SHORT_WIDTH; + } + + public Map getDsNameChangedMap() { + return dsNameChangedMap; + } + + public void setDsNameChangedMap(Map dsNameChangedMap) { + this.dsNameChangedMap = dsNameChangedMap; + } + + protected ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + addItemShortCut(), + removeItemShortCut(), + copyItemShortCut(), + moveUpItemShortCut(), + moveDownItemShortCut(), + sortItemShortCut() + }; + } + + protected abstract ShortCut4JControlPane addItemShortCut(); + + protected abstract ShortCut4JControlPane removeItemShortCut(); + + protected abstract ShortCut4JControlPane copyItemShortCut(); + + protected abstract ShortCut4JControlPane moveUpItemShortCut(); + + protected abstract ShortCut4JControlPane moveDownItemShortCut(); + + protected abstract ShortCut4JControlPane sortItemShortCut(); + + public void setNameListEditable(boolean editable) { + } + + public abstract Nameable[] update(); + + + public void populate(Nameable[] nameableArray) { + } + + public void update(DatasourceManagerProvider datasourceManager) { + } + + public void populate(DatasourceManagerProvider datasourceManager) { + } + + public void populate(TableDataSource tds) { + } + + public void update(TableDataSource tds) { + } + + + /** + * 根据name,选中JNameEdList中的item + */ + public void setSelectedName(String name) { + } + + /** + * 获取选中的名字 + */ + public abstract String getSelectedName(); + + /** + * 名字是否重复 + * + * @return 重复则返回true + */ + public boolean isNameRepeated() { + return isNameRepeated; + } + + /** + * 名字是否允许 + * + * @return 是则返回true + */ + public boolean isNamePermitted() { + return isNamePermitted; + } + + /** + * 是否重命名 + * + * @return 是则true + */ + public abstract boolean isContainsRename(); + + /** + * 生成不重复的名字 + * + * @param prefix 名字前缀 + * @return 名字 + */ + public abstract String createUnrepeatedName(String prefix); + + + /** + * 检查按钮可用状态 Check button enabled. + */ + public void checkButtonEnabled() { + } + + protected void doBeforeRemove() { + + } + + protected void doAfterRemove() { + + } + + public NameableCreator[] creators() { + return creators == null ? new NameableCreator[0] : creators; + } + + /** + * 检查是否符合规范 + * + * @throws Exception + */ + public void checkValid() throws Exception { + } + + protected abstract boolean hasInvalid(boolean isAdd); + + /** + * 设置选中项 + * + * @param index 选中项的序列号 + */ + public void setSelectedIndex(int index) { + } + + + protected void rename(String oldName, String newName) { + dsNameChangedMap.put(oldName, newName); + } +} diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java new file mode 100644 index 000000000..debfc0a39 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -0,0 +1,1028 @@ +package com.fr.design.gui.controlpane; + +import com.fr.base.BaseUtils; +import com.fr.base.FRContext; +import com.fr.design.actions.UpdateAction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; +import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; +import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; +import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ilist.JNameEdList; +import com.fr.design.gui.ilist.ListModelElement; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.LineSeparator; +import com.fr.design.menu.MenuDef; +import com.fr.design.menu.ShortCut; +import com.fr.design.menu.ToolBarDef; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; +import com.fr.stable.Nameable; +import com.fr.stable.core.PropertyChangeAdapter; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.Comparator; + +public abstract class JListControlPane extends JControlPane { + public static final String LIST_NAME = "JControl_List"; + private static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 + + private ShortCut4JControlPane[] shorts; + private NameableCreator[] creators; + protected JNameEdList nameableList; + protected JControlUpdatePane controlUpdatePane; + + private ToolBarDef toolbarDef; + private UIToolbar toolBar; + + // peter:这是整体的一个cardLayout Pane + private CardLayout cardLayout; + private JPanel cardPane; + protected int editingIndex; + protected String selectedName; + private boolean isNameRepeated = false; + + public JListControlPane() { + this.initComponentPane(); + } + + /** + * 生成添加按钮的NameableCreator + * @return 按钮的NameableCreator + */ + public abstract NameableCreator[] createNameableCreators(); + + protected void initComponentPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.creators = this.createNameableCreators(); + this.controlUpdatePane = new JControlUpdatePane(); + + // p: edit card layout + this.cardLayout = new CardLayout(); + cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + cardPane.setLayout(this.cardLayout); + // p:选择的Label + UILabel selectLabel = new UILabel(); + cardPane.add(selectLabel, "SELECT"); + cardPane.add(controlUpdatePane, "EDIT"); + // SplitPane + JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); + mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); + mainSplitPane.setOneTouchExpandable(true); + + this.add(mainSplitPane, BorderLayout.CENTER); + mainSplitPane.setDividerLocation(getLeftPreferredSize()); + this.checkButtonEnabled(); + } + + + protected JPanel getLeftPane(){ + // LeftPane + JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + initNameList(leftPane); + + shorts = this.createShortcuts(); + if (ArrayUtils.isEmpty(shorts)) { + return leftPane; + } + + toolbarDef = new ToolBarDef(); + for (ShortCut4JControlPane sj : shorts) { + toolbarDef.addShortCut(sj.getShortCut()); + } + toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + leftPane.add(toolBar, BorderLayout.NORTH); + return leftPane; + } + + + private void initNameList(JPanel leftPane) { + nameableList = createJNameList(); + nameableList.setName(LIST_NAME); + leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); + + + nameableList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + nameableList.addMouseListener(listMouseListener); + nameableList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + // richie:避免多次update和populate大大降低效率 + if (!evt.getValueIsAdjusting()) { + // shoc 切换的时候加检验 + if (hasInvalid(false)) { + return; + } + JListControlPane.this.controlUpdatePane.update(); + JListControlPane.this.controlUpdatePane.populate(); + JListControlPane.this.checkButtonEnabled(); + } + } + }); + } + + public JNameEdList createJNameList() { + JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) { + protected void doAfterLostFocus() { + JListControlPane.this.updateControlUpdatePane(); + } + }; + nameEdList.setCellRenderer(new NameableListCellRenderer()); + return nameEdList; + } + + public void updateControlUpdatePane() { + controlUpdatePane.update(); + } + + protected void doWhenPopulate(BasicBeanPane beanPane){ + + } + + protected int getLeftPreferredSize() { + return shorts.length * SHORT_WIDTH; + } + + protected ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + addItemShortCut(), + removeItemShortCut(), + copyItemShortCut(), + moveUpItemShortCut(), + moveDownItemShortCut(), + sortItemShortCut() + }; + } + + protected ShortCut4JControlPane addItemShortCut() { + ShortCut addItemShortCut; + if (creators.length == 1) { + addItemShortCut = new AddItemUpdateAction(creators); + } else { + addItemShortCut = new AddItemMenuDef(creators); + } + return new AbsoluteEnableShortCut(addItemShortCut); + } + + protected ShortCut4JControlPane removeItemShortCut() { + return new NormalEnableShortCut(new RemoveItemAction()); + } + + protected ShortCut4JControlPane copyItemShortCut() { + return new NormalEnableShortCut(new CopyItemAction()); + } + + protected ShortCut4JControlPane moveUpItemShortCut() { + return new NormalEnableShortCut(new MoveUpItemAction()); + } + + protected ShortCut4JControlPane moveDownItemShortCut() { + return new NormalEnableShortCut(new MoveDownItemAction()); + } + + protected ShortCut4JControlPane sortItemShortCut() { + return new NormalEnableShortCut(new SortItemAction()); + } + + public void setNameListEditable(boolean editable) { + this.nameableList.setEditable(editable); + } + + public Nameable[] update() { + java.util.List res = new java.util.ArrayList(); + this.controlUpdatePane.update(); + DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); + for (int i = 0, len = listModel.getSize(); i < len; i++) { + res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); + } + + return res.toArray(new Nameable[res.size()]); + } + + public void populate(Nameable[] nameableArray) { + DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); + listModel.removeAllElements(); + if (ArrayUtils.isEmpty(nameableArray)) { + return; + } + + for (Nameable aNameableArray : nameableArray) { + listModel.addElement(new ListModelElement(aNameableArray)); + } + + if (listModel.size() > 0) { + this.nameableList.setSelectedIndex(0); + } + this.checkButtonEnabled(); + } + + /** + * 添加名字改变时的listener + * + * @param l 名字改变时的监听 + */ + public void addModNameActionListener(ModNameActionListener l) { + this.nameableList.addModNameActionListener(l); + } + + /** + * 添加Editinglistener + * + * @param l 监听 + */ + public void addEditingListner(PropertyChangeAdapter l) { + this.nameableList.addEditingListner(l); + } + + /* + * 刷新当前的选中的UpdatePane + */ + protected void populateSelectedValue() { + JListControlPane.this.controlUpdatePane.populate(); + } + + /** + * 根据name,选中JNameEdList中的item + */ + public void setSelectedName(String name) { + DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); + for (int i = 0, len = listModel.getSize(); i < len; i++) { + Nameable item = ((ListModelElement) listModel.getElementAt(i)).wrapper; + if (ComparatorUtils.equals(name, item.getName())) { + this.nameableList.setSelectedIndex(i); + break; + } + } + } + + public String getEditingName() { + return this.nameableList.getEditingName(); + } + + public Object getEditingType() { + return this.nameableList.getAllTypes()[editingIndex]; + } + + public void setWarnigText(int index) { + this.nameableList.setWarnigText(index); + } + + /** + * 获取选中的名字 + */ + public String getSelectedName() { + ListModelElement el = (ListModelElement) this.nameableList.getSelectedValue(); + + return el == null ? null : el.wrapper.getName(); + } + + /** + * 刷新 NameableCreator + * + * @param creators 生成器 + */ + public void refreshNameableCreator(NameableCreator[] creators) { + this.creators = creators; + shorts = this.createShortcuts(); + toolbarDef.clearShortCuts(); + for (ShortCut4JControlPane sj : shorts) { + toolbarDef.addShortCut(sj.getShortCut()); + } + + toolbarDef.updateToolBar(toolBar); + toolBar.validate(); + toolBar.repaint(); + this.repaint(); + } + + protected boolean isNameRepeted(java.util.List[] list, String name) { + for (int i = 0; i < list.length; i++) { + if (list[i].contains(name)) { + isNameRepeated = true; + return true; + } + } + isNameRepeated = false; + return false; + } + + /** + * 名字是否重复 + * @return 重复则返回true + */ + public boolean isNameRepeated() { + return isNameRepeated; + } + + /** + * 添加 Nameable + * + * @param nameable 添加的Nameable + * @param index 序号 + */ + public void addNameable(Nameable nameable, int index) { + JNameEdList nameEdList = JListControlPane.this.nameableList; + DefaultListModel model = (DefaultListModel) nameEdList.getModel(); + + ListModelElement el = new ListModelElement(nameable); + model.add(index, el); + nameableList.setSelectedIndex(index); + nameableList.ensureIndexIsVisible(index); + + nameEdList.repaint(); + } + + /** + * 是否重命名 + * @return 是则true + */ + public boolean isContainsRename() { + String rename = Inter.getLocText("FR-Please_Rename") + "!"; + String[] names = this.nameableList.getAllNames(); + for (int i = names.length - 1; i >= 0; i--) { + if (ComparatorUtils.equals(names[i], rename)) { + return true; + } + } + return false; + } + + protected DefaultListModel getModel() { + return (DefaultListModel) JListControlPane.this.nameableList.getModel(); + } + + private String createUnrepeatedCopyName(String suffix) { + DefaultListModel model = this.getModel(); + String[] names = new String[model.getSize()]; + for (int i = 0; i < model.size(); i++) { + names[i] = ((ListModelElement) model.get(i)).wrapper.getName(); + } + String lastName = "CopyOf" + suffix; + while (ArrayUtils.contains(names, lastName)) { + lastName = "CopyOf" + lastName; + } + return lastName; + } + + + /** + * 生成不重复的名字 + * + * @param prefix 名字前缀 + * @return 名字 + */ + public String createUnrepeatedName(String prefix) { + DefaultListModel model = this.getModel(); + Nameable[] all = new Nameable[model.getSize()]; + for (int i = 0; i < model.size(); i++) { + all[i] = ((ListModelElement) model.get(i)).wrapper; + } + // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. + int count = all.length + 1; + while (true) { + String name_test = prefix + count; + boolean repeated = false; + for (int i = 0, len = model.size(); i < len; i++) { + Nameable nameable = all[i]; + if (ComparatorUtils.equals(nameable.getName(), name_test)) { + repeated = true; + break; + } + } + + if (!repeated) { + return name_test; + } + + count++; + } + } + + /** + * 增加项的UpdateAction + */ + protected class AddItemUpdateAction extends UpdateAction { + final NameableCreator creator; + + public AddItemUpdateAction(NameableCreator[] creators) { + this.creator = creators[0]; + this.setName(Inter.getLocText("FR-Action_Add")); + this.setMnemonic('A'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); + } + + public void actionPerformed(ActionEvent e) { + Nameable nameable = creator.createNameable(JListControlPane.this); + + JListControlPane.this.addNameable(nameable, getModel().getSize()); + } + } + + /* + * 增加项的MenuDef + */ + protected class AddItemMenuDef extends MenuDef { + public AddItemMenuDef(NameableCreator[] creators) { + this.setName(Inter.getLocText("FR-Action_Add")); + this.setMnemonic('A'); + this.setIconPath("/com/fr/design/images/control/addPopup.png"); + wrapActionListener(creators); + } + + private void wrapActionListener(NameableCreator[] creators) { + for (final NameableCreator creator : creators) { + if (!whetherAdd(creator.menuName())){ + continue; + } + boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || + ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Relation_TableData")) || ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Multi_Dimensional_Database")); + if (isTrue) { + this.addShortCut(new LineSeparator()); + } + this.addShortCut(new UpdateAction() { + { + this.setName(creator.menuName()); + Icon icon = creator.menuIcon(); + if (icon != null) { + this.setSmallIcon(icon); + } + } + + public void actionPerformed(ActionEvent e) { + if (hasInvalid(true)) { + return; + } + + Nameable nameable = creator.createNameable(JListControlPane.this); + + JListControlPane.this.addNameable(nameable, getModel().getSize()); + } + }); + } + } + + private boolean whetherAdd(String itemName){ + JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jTemplate == null) { + return false; + } + //先屏蔽掉这个,之后还有别的 + String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; + for (String name : names){ + if(!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)){ + return false; + } + } + String formName = Inter.getLocText("Hyperlink-Form_link"); + return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); + } + } + + /* + * 移除item + */ + private class RemoveItemAction extends UpdateAction { + public RemoveItemAction() { + this.setName(Inter.getLocText("FR-Action_Remove")); + this.setMnemonic('R'); + this.setSmallIcon(BaseUtils + .readIcon("/com/fr/base/images/cell/control/remove.png")); + } + + public void actionPerformed(ActionEvent evt) { + try { + JListControlPane.this.nameableList.getCellEditor() + .stopCellEditing(); + } catch (Exception ignored) { + } + // bug:在选中一个NameObject并删除,会遗留下Name. + doBeforeRemove(); + if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities + .getWindowAncestor(JListControlPane.this), nameableList)) { + checkButtonEnabled(); + doAfterRemove(); + } + } + } + + /* + * CopyItem + */ + private class CopyItemAction extends UpdateAction { + public CopyItemAction() { + this.setName(Inter.getLocText("FR-Action_Copy")); + this.setMnemonic('C'); + this.setSmallIcon(BaseUtils + .readIcon("/com/fr/base/images/cell/control/copy.png")); + } + + public void actionPerformed(ActionEvent evt) { + // p:选中的值. + ListModelElement selectedValue = (ListModelElement) nameableList.getSelectedValue(); + if (selectedValue == null) { + return; + } + + controlUpdatePane.update(); + + Nameable selectedNameable = selectedValue.wrapper; + + // p: 用反射机制实现 + try { + Nameable newNameable = (Nameable) BaseUtils.cloneObject(selectedNameable); + newNameable.setName(createUnrepeatedCopyName(selectedNameable.getName())); + + JListControlPane.this.addNameable(newNameable, nameableList.getSelectedIndex() + 1); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + } + } + + /* + * 上移Item + */ + private class MoveUpItemAction extends UpdateAction { + public MoveUpItemAction() { + this.setName(Inter.getLocText("Utils-Move_Up")); + this.setMnemonic('U'); + this.setSmallIcon(BaseUtils + .readIcon("/com/fr/design/images/control/up.png")); + } + + public void actionPerformed(ActionEvent evt) { + int selectedIndex = nameableList.getSelectedIndex(); + if (selectedIndex == -1) { + return; + } + + // 上移 + if (selectedIndex > 0) { + DefaultListModel listModel = (DefaultListModel) nameableList + .getModel(); + + Object selecteObj1 = listModel.get(selectedIndex - 1); + listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); + listModel.set(selectedIndex, selecteObj1); + + nameableList.setSelectedIndex(selectedIndex - 1); + nameableList.ensureIndexIsVisible(selectedIndex - 1); + } + } + } + + /* + * 下移Item + */ + private class MoveDownItemAction extends UpdateAction { + public MoveDownItemAction() { + this.setName(Inter.getLocText("Utils-Move_Down")); + this.setMnemonic('D'); + this.setSmallIcon(BaseUtils + .readIcon("/com/fr/design/images/control/down.png")); + } + + public void actionPerformed(ActionEvent evt) { + int selectedIndex = nameableList.getSelectedIndex(); + if (selectedIndex == -1) { + return; + } + + if (selectedIndex < nameableList.getModel().getSize() - 1) { + DefaultListModel listModel = (DefaultListModel) nameableList + .getModel(); + + Object selecteObj1 = listModel.get(selectedIndex + 1); + listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); + listModel.set(selectedIndex, selecteObj1); + + nameableList.setSelectedIndex(selectedIndex + 1); + nameableList.ensureIndexIsVisible(selectedIndex + 1); + } + } + } + + private class SortItemAction extends UpdateAction { + private boolean isAtoZ = false; + + public SortItemAction() { + this.setName(Inter.getLocText("FR-Action_Sort")); + this.setMnemonic('S'); + this.setSmallIcon(BaseUtils + .readIcon("/com/fr/design/images/control/sortAsc.png")); + } + + public void actionPerformed(ActionEvent evt) { + // p:选中的值. + Object selectedValue = nameableList.getSelectedValue(); + + DefaultListModel listModel = (DefaultListModel) nameableList + .getModel(); + Nameable[] nameableArray = new Nameable[listModel.getSize()]; + if (nameableArray.length <= 0) { + return; + } + + for (int i = 0; i < listModel.getSize(); i++) { + nameableArray[i] = ((ListModelElement) listModel.getElementAt(i)).wrapper; + } + + // p:排序. + if (isAtoZ) { + Comparator nameableComparator = new Comparator() { + public int compare(Nameable o1, Nameable o2) { + return -ComparatorUtils.compare(o1.getName(), o2 + .getName()); + } + }; + isAtoZ = !isAtoZ; + Arrays.sort(nameableArray, nameableComparator); + } else { + Comparator nameableComparator = new Comparator() { + public int compare(Nameable o1, Nameable o2) { + return ComparatorUtils.compare(o1.getName(), o2 + .getName()); + } + }; + isAtoZ = !isAtoZ; + Arrays.sort(nameableArray, nameableComparator); + } + + for (int i = 0; i < nameableArray.length; i++) { + listModel.set(i, new ListModelElement(nameableArray[i])); + } + + // p:需要选中以前的那个值. + if (selectedValue != null) { + nameableList.setSelectedValue(selectedValue, true); + } + + checkButtonEnabled(); + // p:需要repaint. + nameableList.repaint(); + } + } + + /* + * JNameEdList的鼠标事件 + */ + private MouseListener listMouseListener = new MouseAdapter() { + public void mouseReleased(MouseEvent evt) { + nameableList.stopEditing(); + if (evt.getClickCount() >= 2 + && SwingUtilities.isLeftMouseButton(evt)) { + editingIndex = nameableList.getSelectedIndex(); + selectedName = nameableList.getNameAt(editingIndex); + nameableList.editItemAt(nameableList.getSelectedIndex()); + } + // peter:处理右键的弹出菜单 + if (!SwingUtilities.isRightMouseButton(evt)) { + return; + } + + // peter: 注意,在checkButtonEnabled()方法里面,设置了所有的Action的Enabled. + checkButtonEnabled(); + + // p:右键菜单. + JPopupMenu popupMenu = new JPopupMenu(); + + for (ShortCut4JControlPane sj : shorts) { + sj.getShortCut().intoJPopupMenu(popupMenu); + } + + // peter: 只有弹出菜单有子菜单的时候,才需要弹出来. + GUICoreUtils.showPopupMenu(popupMenu, nameableList, evt.getX() - 1, + evt.getY() - 1); + } + + public void mouseMoved(MouseEvent e) { + + } + }; + + /** + * 检查按钮可用状态 Check button enabled. + */ + public void checkButtonEnabled() { + int selectedIndex = nameableList.getSelectedIndex(); + if (selectedIndex == -1) { + this.cardLayout.show(cardPane, "SELECT"); + } else { + this.cardLayout.show(cardPane, "EDIT"); + } + for (ShortCut4JControlPane sj : this.shorts) { + sj.checkEnable(); + } + } + + protected void doBeforeRemove(){ + + } + + protected void doAfterRemove(){ + + } + + public NameableCreator[] creators() { + return creators == null ? new NameableCreator[0] : creators; + } + + /* + * Nameable的ListCellRenerer + */ + private class NameableListCellRenderer extends + DefaultListCellRenderer { + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, + cellHasFocus); + + if (value instanceof ListModelElement) { + Nameable wrappee = ((ListModelElement) value).wrapper; + this.setText(((ListModelElement) value).wrapper.getName()); + + boolean iconSet = false; + for (NameableCreator creator : JListControlPane.this.creators) { + if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) { + this.setIcon(creator.menuIcon()); + this.setToolTipText(creator.createTooltip()); + iconSet = true; + break; + } + } + if (!iconSet) { + this.setIcon(BaseUtils.readIcon("/com/fr/base/images/oem/cpt.png")); + } + } + + return this; + } + } + + public class AbsoluteEnableShortCut extends ShortCut4JControlPane { + public AbsoluteEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + public void checkEnable() { + this.shortCut.setEnabled(true); + } + } + + public class NormalEnableShortCut extends ShortCut4JControlPane { + public NormalEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + public void checkEnable() { + this.shortCut.setEnabled(getModel() + .getSize() > 0 + && JListControlPane.this.nameableList.getSelectedIndex() != -1); + } + } + + public class SortEnableShortCut extends ShortCut4JControlPane { + public SortEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + @Override + public void checkEnable() { + this.shortCut.setEnabled(getModel().getSize() > 1); + } + + } + + public class MoveUpEnableShortCut extends ShortCut4JControlPane { + public MoveUpEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + @Override + public void checkEnable() { + this.shortCut.setEnabled(getModel().getSize() > 1 + && JListControlPane.this.nameableList.getSelectedIndex() > 0); + } + + } + + public class MoveDownEnableShortCut extends ShortCut4JControlPane { + public MoveDownEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + @Override + public void checkEnable() { + this.shortCut.setEnabled(getModel().getSize() > 1 + && JListControlPane.this.nameableList.getSelectedIndex() < JListControlPane.this.nameableList.getModel().getSize() - 1); + } + + } + + private class JControlUpdatePane extends JPanel { + private CardLayout card; + private JPanel cardPane; + private BasicBeanPane[] updatePanes; + + private ListModelElement elEditing; + + public JControlUpdatePane() { + initUpdatePane(); + } + + private void initUpdatePane() { + if (creators == null) { + return; + } + card = new CardLayout(); + cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + cardPane.setLayout(card); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(cardPane); + int len = creators.length; + updatePanes = new BasicBeanPane[len]; + } + + public void populate() { + ListModelElement el = (ListModelElement) JListControlPane.this.nameableList.getSelectedValue(); + if (el == null) { + return; + } + + elEditing = el; + + for (int i = 0, len = updatePanes.length; i < len; i++) { + Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); + if (ob2Populate != null) { + if (updatePanes[i] == null) { + if (isMulti(creators[i].getUpdatePane()) || isTree(creators[i].getUpdatePane())) { + updatePanes[i] = createPaneByCreators(creators[i], el.wrapper.getName()); + } else { + updatePanes[i] = createPaneByCreators(creators[i]); + } + cardPane.add(updatePanes[i], String.valueOf(i)); + } + card.show(cardPane, String.valueOf(i)); + updatePanes[i].populateBean(ob2Populate); + doWhenPopulate(updatePanes[i]); + break; + } + } + } + + public boolean isMulti(Class _class){ + return ComparatorUtils.equals(_class, GlobalMultiTDTableDataPane.class) || ComparatorUtils.equals(_class, MultiTDTableDataPane.class); + } + + public boolean isTree(Class _class){ + return ComparatorUtils.equals(_class, GlobalTreeTableDataPane.class) || ComparatorUtils.equals(_class, TreeTableDataPane.class); + } + + public void update() { + for (int i = 0; i < updatePanes.length; i++) { + BasicBeanPane pane = updatePanes[i]; + + if (pane != null && pane.isVisible()) { + Object bean = pane.updateBean(); + if (i < JListControlPane.this.creators.length) { + JListControlPane.this.creators[i].saveUpdatedBean(elEditing, bean); + } + } + } + } + + public void checkValid() throws Exception { + if (updatePanes != null) { + for (int i = 0; i < updatePanes.length; i++) { + if (updatePanes[i] != null) { + updatePanes[i].checkValid(); + } + } + } + } + } + + protected BasicBeanPane createPaneByCreators(NameableCreator creator) { + try { + return creator.getUpdatePane().newInstance(); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + protected BasicBeanPane createPaneByCreators(NameableCreator creator, String string) { + Constructor constructor = null; + try { + constructor = creator.getUpdatePane().getDeclaredConstructor(new Class[]{String.class}); + constructor.setAccessible(true); + return (BasicBeanPane) constructor.newInstance(string); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + + } + + // 选项添加个数有限制等情况下 要求能控制快捷按钮的状态 + protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) { + if (this.toolbarDef.getShortCutCount() > shortCutIndex) { + ShortCut sc = this.toolbarDef.getShortCut(shortCutIndex); + if (sc instanceof AddItemMenuDef) { + AddItemMenuDef am = (AddItemMenuDef) sc; + if (am.getShortCutCount() > itemIndex) { + am.getShortCut(itemIndex).setEnabled(enabled); + } + } + } + } + + /** + * 检查是否符合规范 + * + * @throws Exception + */ + public void checkValid() throws Exception { + this.controlUpdatePane.checkValid(); + } + + private int getInValidIndex() { + BasicBeanPane[] p = controlUpdatePane.updatePanes; + if (p != null) { + for (int i = 0; i < p.length; i++) { + if (p[i] != null) { + try { + p[i].checkValid(); + } catch (Exception e) { + return i; + } + } + } + } + return -1; + } + + protected boolean hasInvalid(boolean isAdd) { + int idx = JListControlPane.this.getInValidIndex(); + if (isAdd || nameableList.getSelectedIndex() != idx) { + try { + checkValid(); + } catch (Exception exp) { + JOptionPane.showMessageDialog(JListControlPane.this, exp.getMessage()); + nameableList.setSelectedIndex(idx); + return true; + } + } + return false; + } + + + /** + * 设置选中项 + * + * @param index 选中项的序列号 + */ + public void setSelectedIndex(int index) { + nameableList.setSelectedIndex(index); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/ObjectJControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/ObjectJControlPane.java index fb944b93b..69fe1d642 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/ObjectJControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/ObjectJControlPane.java @@ -11,7 +11,7 @@ import com.fr.design.beans.BasicBeanPane; * @author zhou * @since 2012-4-5上午9:29:20 */ -public abstract class ObjectJControlPane extends JControlPane { +public abstract class ObjectJControlPane extends JListControlPane { private Object object; public ObjectJControlPane() { diff --git a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java index fe1412772..b7992e60e 100644 --- a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -4,7 +4,7 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.HyperlinkPluginAction; import com.fr.design.actions.UpdateAction; import com.fr.design.fun.HyperlinkProvider; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; @@ -25,7 +25,7 @@ import java.util.List; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-6-25 上午11:17:57 */ -public class HyperlinkGroupPane extends JControlPane { +public class HyperlinkGroupPane extends JListControlPane { /** * 生成添加按钮的NameableCreator diff --git a/designer_base/src/com/fr/design/parameter/ParameterArrayPane.java b/designer_base/src/com/fr/design/parameter/ParameterArrayPane.java index 5a36ece13..223c93078 100644 --- a/designer_base/src/com/fr/design/parameter/ParameterArrayPane.java +++ b/designer_base/src/com/fr/design/parameter/ParameterArrayPane.java @@ -2,7 +2,7 @@ package com.fr.design.parameter; import com.fr.base.ConfigManager; import com.fr.base.Parameter; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableSelfCreator; import com.fr.design.gui.controlpane.UnrepeatedNameHelper; @@ -18,7 +18,7 @@ import javax.swing.*; import java.util.Arrays; import java.util.List; -public class ParameterArrayPane extends JControlPane { +public class ParameterArrayPane extends JListControlPane { /** * Constructor. */ diff --git a/designer_base/src/com/fr/env/EnvListPane.java b/designer_base/src/com/fr/env/EnvListPane.java index a59d6ba91..0f8121582 100644 --- a/designer_base/src/com/fr/env/EnvListPane.java +++ b/designer_base/src/com/fr/env/EnvListPane.java @@ -41,7 +41,7 @@ import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.InformationWarnPane; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ipasswordfield.UIPassWordField; @@ -63,7 +63,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; -public class EnvListPane extends JControlPane { +public class EnvListPane extends JListControlPane { public EnvListPane() { super(); addEditingListner(new PropertyChangeAdapter() { diff --git a/designer_chart/src/com/fr/design/chart/ChartControlPane.java b/designer_chart/src/com/fr/design/chart/ChartControlPane.java index 390d780fb..1ac74dbea 100644 --- a/designer_chart/src/com/fr/design/chart/ChartControlPane.java +++ b/designer_chart/src/com/fr/design/chart/ChartControlPane.java @@ -3,7 +3,7 @@ package com.fr.design.chart; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.layout.FRGUIPaneFactory; @@ -18,7 +18,7 @@ import java.util.HashMap; * 管理图表类型Pane * @author kunsnat: ChartComponent移出. */ -public class ChartControlPane extends JControlPane { +public class ChartControlPane extends JListControlPane { private static final long serialVersionUID = 7336270815128413184L; public ChartControlPane() { diff --git a/designer_chart/src/com/fr/design/chart/axis/ChartAlertLinePane.java b/designer_chart/src/com/fr/design/chart/axis/ChartAlertLinePane.java index 28a06e22a..e6bde825a 100644 --- a/designer_chart/src/com/fr/design/chart/axis/ChartAlertLinePane.java +++ b/designer_chart/src/com/fr/design/chart/axis/ChartAlertLinePane.java @@ -4,14 +4,14 @@ import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.stable.Nameable; import com.fr.chart.chartattr.ChartAlertValue; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import java.util.ArrayList; import java.util.List; -public class ChartAlertLinePane extends JControlPane { +public class ChartAlertLinePane extends JListControlPane { public NameableCreator[] createNameableCreators() { return new NameableCreator[]{ diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/DataSeriesAttrPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/DataSeriesAttrPane.java index 7fb006c84..a5f8b6d0a 100644 --- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/DataSeriesAttrPane.java +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/DataSeriesAttrPane.java @@ -7,7 +7,7 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.design.chart.series.SeriesCondition.impl.DataSeriesConditionPaneFactory; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; @@ -20,7 +20,7 @@ import java.util.List; * * @see DataSeriesConditionPane */ -public class DataSeriesAttrPane extends JControlPane { +public class DataSeriesAttrPane extends JListControlPane { private static final long serialVersionUID = -7265389532959632525L; private Plot plot; diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/TrendLineControlPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/TrendLineControlPane.java index 583d2c3bd..b59c5df6b 100644 --- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/TrendLineControlPane.java +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/TrendLineControlPane.java @@ -5,14 +5,14 @@ import com.fr.general.NameObject; import com.fr.stable.Nameable; import com.fr.chart.base.AttrTrendLine; import com.fr.chart.base.ConditionTrendLine; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import java.util.ArrayList; import java.util.List; -public class TrendLineControlPane extends JControlPane { +public class TrendLineControlPane extends JListControlPane { public NameableCreator[] createNameableCreators() { return new NameableCreator[] { diff --git a/designer_chart/src/com/fr/design/mainframe/MapArrayPane.java b/designer_chart/src/com/fr/design/mainframe/MapArrayPane.java index 14926e71c..3dd189d30 100644 --- a/designer_chart/src/com/fr/design/mainframe/MapArrayPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MapArrayPane.java @@ -32,7 +32,7 @@ import java.util.List; * Date: 14/12/3 * Time: 上午10:00 */ -public class MapArrayPane extends JControlPane { +public class MapArrayPane extends JListControlPane { private static final int LEFT_WIDTH = 180; private static final Color LINE_COLOR = new Color(176, 176, 176); private static final int TOP_GAP = 5; diff --git a/designer_chart/src/com/fr/design/module/ChartPreStyleManagerPane.java b/designer_chart/src/com/fr/design/module/ChartPreStyleManagerPane.java index 5d1b246d4..87d9577bd 100644 --- a/designer_chart/src/com/fr/design/module/ChartPreStyleManagerPane.java +++ b/designer_chart/src/com/fr/design/module/ChartPreStyleManagerPane.java @@ -4,7 +4,7 @@ import com.fr.base.ChartPreStyleManagerProvider; import com.fr.base.ChartPreStyleServerManager; import com.fr.base.Utils; import com.fr.chart.base.ChartPreStyle; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.mainframe.DesignerContext; @@ -22,7 +22,7 @@ import java.util.Iterator; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-8-21 下午02:33:48 */ -public class ChartPreStyleManagerPane extends JControlPane { +public class ChartPreStyleManagerPane extends JListControlPane { @Override /** From f5e26549e5ba933e817ddbb9281d8ac47f56c0dc Mon Sep 17 00:00:00 2001 From: fr_shine Date: Tue, 17 May 2016 17:44:48 +0800 Subject: [PATCH 09/41] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/SeriesNameUseFieldNamePane.java | 18 +++++-- .../table/SeriesNameUseFieldValuePane.java | 47 ++++++++++++++----- .../data/table/SeriesTypeUseComboxPane.java | 12 ++++- 3 files changed, 59 insertions(+), 18 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java index 8e6784d92..f9258bc81 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java @@ -89,15 +89,25 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane { @Override protected List> initPaneList() { - nameFieldValuePane = new SeriesNameUseFieldValuePane(); - nameFieldNamePane = new SeriesNameUseFieldNamePane(); + nameFieldValuePane = createValuePane(); + nameFieldNamePane = createNamePane(); List> paneList = new ArrayList>(); paneList.add(nameFieldValuePane); paneList.add(nameFieldNamePane); return paneList; } + protected SeriesNameUseFieldValuePane createValuePane() { + return new SeriesNameUseFieldValuePane(); + } + + protected SeriesNameUseFieldNamePane createNamePane() { + return new SeriesNameUseFieldNamePane(); + } + public void populateBean(ChartCollection ob, boolean isNeedSummary) { this.isNeedSummary = isNeedSummary; TopDefinitionProvider definition = ob.getSelectedChart().getFilterDefinition(); From 34b1582c04bf6ddb076e65c7f3beda726e0fcc7e Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 18 May 2016 09:28:09 +0800 Subject: [PATCH 10/41] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=BF=99=E8=BE=B9?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E6=95=B4=E7=90=86=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataListPane.java | 1 + .../design/gui/controlpane/JControlPane.java | 115 ++++++++++-------- .../gui/controlpane/JListControlPane.java | 87 +++++-------- 3 files changed, 92 insertions(+), 111 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java b/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java index 5c641d515..d3a226520 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java @@ -22,6 +22,7 @@ import java.util.*; * TableDataList Pane. */ public class TableDataListPane extends JListControlPane { + private boolean isNamePermitted = true; public TableDataListPane() { super(); diff --git a/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java index 615cee6a0..f577d3cc8 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java @@ -22,22 +22,18 @@ import java.util.Map; * Time: 15:07 */ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper { - private static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 - - private ShortCut4JControlPane[] shorts; - private NameableCreator[] creators; + protected static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 protected JPanel controlUpdatePane; + protected Map dsNameChangedMap = new HashMap(); + protected ShortCut4JControlPane[] shorts; + protected NameableCreator[] creators; + protected ToolBarDef toolbarDef; - private ToolBarDef toolbarDef; - private UIToolbar toolBar; - + protected UIToolbar toolBar; // peter:这是整体的一个cardLayout Pane - private CardLayout cardLayout; - private JPanel cardPane; - protected String selectedName; - protected boolean isNamePermitted = true; - protected Map dsNameChangedMap = new HashMap(); - private boolean isNameRepeated = false; + protected CardLayout cardLayout; + + protected JPanel cardPane; public JControlPane() { this.initComponentPane(); @@ -53,7 +49,7 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe protected void initComponentPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.creators = this.createNameableCreators(); - this.controlUpdatePane = new JPanel(); + this.controlUpdatePane = createControlUpdatePane(); // p: edit card layout this.cardLayout = new CardLayout(); @@ -73,6 +69,7 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe this.checkButtonEnabled(); } + protected abstract JPanel createControlUpdatePane(); protected JPanel getLeftPane() { // LeftPane @@ -95,6 +92,55 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe return leftPane; } + + public ShortCut4JControlPane[] getShorts() { + return shorts; + } + + public void setShorts(ShortCut4JControlPane[] shorts) { + this.shorts = shorts; + } + + public NameableCreator[] getCreators() { + return creators; + } + + public void setCreators(NameableCreator[] creators) { + this.creators = creators; + } + + public ToolBarDef getToolbarDef() { + return toolbarDef; + } + + public void setToolbarDef(ToolBarDef toolbarDef) { + this.toolbarDef = toolbarDef; + } + + public UIToolbar getToolBar() { + return toolBar; + } + + public void setToolBar(UIToolbar toolBar) { + this.toolBar = toolBar; + } + + public CardLayout getCardLayout() { + return cardLayout; + } + + public void setCardLayout(CardLayout cardLayout) { + this.cardLayout = cardLayout; + } + + public JPanel getCardPane() { + return cardPane; + } + + public void setCardPane(JPanel cardPane) { + this.cardPane = cardPane; + } + /** * 初始化 */ @@ -158,52 +204,15 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe public void update(TableDataSource tds) { } - - /** - * 根据name,选中JNameEdList中的item - */ - public void setSelectedName(String name) { - } - - /** - * 获取选中的名字 - */ - public abstract String getSelectedName(); - - /** - * 名字是否重复 - * - * @return 重复则返回true - */ - public boolean isNameRepeated() { - return isNameRepeated; - } - /** * 名字是否允许 * - * @return 是则返回true + * @return 默认返回true */ public boolean isNamePermitted() { - return isNamePermitted; + return true; } - /** - * 是否重命名 - * - * @return 是则true - */ - public abstract boolean isContainsRename(); - - /** - * 生成不重复的名字 - * - * @param prefix 名字前缀 - * @return 名字 - */ - public abstract String createUnrepeatedName(String prefix); - - /** * 检查按钮可用状态 Check button enabled. */ diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java index debfc0a39..cd32fde56 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -10,11 +10,9 @@ import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ModNameActionListener; -import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.LineSeparator; @@ -43,19 +41,8 @@ import java.util.Comparator; public abstract class JListControlPane extends JControlPane { public static final String LIST_NAME = "JControl_List"; - private static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 - private ShortCut4JControlPane[] shorts; - private NameableCreator[] creators; protected JNameEdList nameableList; - protected JControlUpdatePane controlUpdatePane; - - private ToolBarDef toolbarDef; - private UIToolbar toolBar; - - // peter:这是整体的一个cardLayout Pane - private CardLayout cardLayout; - private JPanel cardPane; protected int editingIndex; protected String selectedName; private boolean isNameRepeated = false; @@ -64,38 +51,20 @@ public abstract class JListControlPane extends JControlPane { this.initComponentPane(); } + protected JPanel createControlUpdatePane() { + return new JControlUpdatePane(); + } + /** * 生成添加按钮的NameableCreator + * * @return 按钮的NameableCreator */ public abstract NameableCreator[] createNameableCreators(); - protected void initComponentPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.creators = this.createNameableCreators(); - this.controlUpdatePane = new JControlUpdatePane(); - - // p: edit card layout - this.cardLayout = new CardLayout(); - cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - cardPane.setLayout(this.cardLayout); - // p:选择的Label - UILabel selectLabel = new UILabel(); - cardPane.add(selectLabel, "SELECT"); - cardPane.add(controlUpdatePane, "EDIT"); - // SplitPane - JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); - mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); - mainSplitPane.setOneTouchExpandable(true); - - this.add(mainSplitPane, BorderLayout.CENTER); - mainSplitPane.setDividerLocation(getLeftPreferredSize()); - this.checkButtonEnabled(); - } - - protected JPanel getLeftPane(){ - // LeftPane + protected JPanel getLeftPane() { + // LeftPane JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); initNameList(leftPane); @@ -132,8 +101,8 @@ public abstract class JListControlPane extends JControlPane { if (hasInvalid(false)) { return; } - JListControlPane.this.controlUpdatePane.update(); - JListControlPane.this.controlUpdatePane.populate(); + ((JControlUpdatePane) JListControlPane.this.controlUpdatePane).update(); + ((JControlUpdatePane) JListControlPane.this.controlUpdatePane).populate(); JListControlPane.this.checkButtonEnabled(); } } @@ -151,15 +120,15 @@ public abstract class JListControlPane extends JControlPane { } public void updateControlUpdatePane() { - controlUpdatePane.update(); + ((JControlUpdatePane) controlUpdatePane).update(); } - protected void doWhenPopulate(BasicBeanPane beanPane){ + protected void doWhenPopulate(BasicBeanPane beanPane) { } protected int getLeftPreferredSize() { - return shorts.length * SHORT_WIDTH; + return shorts.length * JControlPane.SHORT_WIDTH; } protected ShortCut4JControlPane[] createShortcuts() { @@ -209,7 +178,7 @@ public abstract class JListControlPane extends JControlPane { public Nameable[] update() { java.util.List res = new java.util.ArrayList(); - this.controlUpdatePane.update(); + ((JControlUpdatePane) this.controlUpdatePane).update(); DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); for (int i = 0, len = listModel.getSize(); i < len; i++) { res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); @@ -257,7 +226,7 @@ public abstract class JListControlPane extends JControlPane { * 刷新当前的选中的UpdatePane */ protected void populateSelectedValue() { - JListControlPane.this.controlUpdatePane.populate(); + ((JControlUpdatePane) JListControlPane.this.controlUpdatePane).populate(); } /** @@ -327,7 +296,8 @@ public abstract class JListControlPane extends JControlPane { /** * 名字是否重复 - * @return 重复则返回true + * + * @return 重复则返回true */ public boolean isNameRepeated() { return isNameRepeated; @@ -353,6 +323,7 @@ public abstract class JListControlPane extends JControlPane { /** * 是否重命名 + * * @return 是则true */ public boolean isContainsRename() { @@ -450,7 +421,7 @@ public abstract class JListControlPane extends JControlPane { private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { - if (!whetherAdd(creator.menuName())){ + if (!whetherAdd(creator.menuName())) { continue; } boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || @@ -480,15 +451,15 @@ public abstract class JListControlPane extends JControlPane { } } - private boolean whetherAdd(String itemName){ + private boolean whetherAdd(String itemName) { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate == null) { - return false; + return false; } //先屏蔽掉这个,之后还有别的 String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; - for (String name : names){ - if(!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)){ + for (String name : names) { + if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { return false; } } @@ -542,7 +513,7 @@ public abstract class JListControlPane extends JControlPane { return; } - controlUpdatePane.update(); + ((JControlUpdatePane) controlUpdatePane).update(); Nameable selectedNameable = selectedValue.wrapper; @@ -734,11 +705,11 @@ public abstract class JListControlPane extends JControlPane { } } - protected void doBeforeRemove(){ + protected void doBeforeRemove() { } - protected void doAfterRemove(){ + protected void doAfterRemove() { } @@ -904,11 +875,11 @@ public abstract class JListControlPane extends JControlPane { } } - public boolean isMulti(Class _class){ + public boolean isMulti(Class _class) { return ComparatorUtils.equals(_class, GlobalMultiTDTableDataPane.class) || ComparatorUtils.equals(_class, MultiTDTableDataPane.class); } - public boolean isTree(Class _class){ + public boolean isTree(Class _class) { return ComparatorUtils.equals(_class, GlobalTreeTableDataPane.class) || ComparatorUtils.equals(_class, TreeTableDataPane.class); } @@ -983,11 +954,11 @@ public abstract class JListControlPane extends JControlPane { * @throws Exception */ public void checkValid() throws Exception { - this.controlUpdatePane.checkValid(); + ((JControlUpdatePane) this.controlUpdatePane).checkValid(); } private int getInValidIndex() { - BasicBeanPane[] p = controlUpdatePane.updatePanes; + BasicBeanPane[] p = ((JControlUpdatePane) controlUpdatePane).updatePanes; if (p != null) { for (int i = 0; i < p.length; i++) { if (p[i] != null) { From 7c80cb51a24eb0fd19452838c2049f74e27950c2 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 18 May 2016 11:37:45 +0800 Subject: [PATCH 11/41] =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E9=9D=A2=E6=9D=BF=E5=A4=84=E7=90=86=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=92=8Cjcontrolpane?= =?UTF-8?q?=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/ReportTableDataPane.java | 9 +- .../datapane/TableDataPaneController.java | 62 +++ ...stPane.java => TableDataPaneListPane.java} | 523 +++++++++--------- .../tabledatapane/TableDataManagerPane.java | 14 +- .../fr/design/fun/TableDataPaneProcessor.java | 4 +- .../design/gui/controlpane/JControlPane.java | 174 +++--- .../gui/controlpane/JListControlPane.java | 82 +-- 7 files changed, 418 insertions(+), 450 deletions(-) create mode 100644 designer_base/src/com/fr/design/data/datapane/TableDataPaneController.java rename designer_base/src/com/fr/design/data/datapane/{TableDataListPane.java => TableDataPaneListPane.java} (93%) diff --git a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java index 003a478b1..339a227a4 100644 --- a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java @@ -6,7 +6,6 @@ package com.fr.design.data.datapane; import com.fr.data.TableDataSource; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.TableDataPaneProcessor; -import com.fr.design.gui.controlpane.JControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.layout.FRGUIPaneFactory; @@ -22,24 +21,24 @@ import java.util.Map; * 创建于2011-6-14 */ public class ReportTableDataPane extends LoadingBasicPane { - private JControlPane tdPane; + private TableDataPaneController tdPane; @Override protected void initComponents(JPanel container) { container.setLayout(FRGUIPaneFactory.createBorderLayout()); TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); - JControlPane pane = null; + TableDataPaneController pane = null; if (paneProcessor != null) { pane = paneProcessor.createServerTableDataPane(); } - tdPane = pane == null ? new TableDataListPane() { + tdPane = pane == null ? new TableDataPaneListPane() { @Override public NameableCreator[] createNameableCreators() { return TableDataCreatorProducer.getInstance().createReportTableDataCreator(); } } : pane; - container.add(tdPane, BorderLayout.CENTER); + container.add(tdPane.getPanel(), BorderLayout.CENTER); } @Override diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataPaneController.java b/designer_base/src/com/fr/design/data/datapane/TableDataPaneController.java new file mode 100644 index 000000000..ed29702c4 --- /dev/null +++ b/designer_base/src/com/fr/design/data/datapane/TableDataPaneController.java @@ -0,0 +1,62 @@ +package com.fr.design.data.datapane; + +import com.fr.data.TableDataSource; +import com.fr.file.DatasourceManagerProvider; + +import javax.swing.*; +import java.util.Map; + +/** + * Coder: zack + * Date: 2016/5/18 + * Time: 10:13 + */ +public interface TableDataPaneController { + /** + * 获取数据集名字变更集合 + * + * @return + */ + Map getDsNameChangedMap(); + + /** + * 数据集重命名 + * + * @param oldName + * @param newName + */ + void rename(String oldName, String newName); + + /** + * 是否合法 + * @throws Exception + */ + void checkValid() throws Exception; + + /** + * 名字是否允许 + * @return + */ + boolean isNamePermitted(); + + void populate(DatasourceManagerProvider datasourceManagerProvider); + + void update(DatasourceManagerProvider datasourceManagerProvider); + + void populate(TableDataSource datasourceManagerProvider); + + void update(TableDataSource datasourceManagerProvider); + + /** + * 设置选中项 + * @param index + */ + void setSelectedIndex(int index); + + /** + * 返回当前数据集面板 + * @return + */ + JPanel getPanel(); + +} diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java similarity index 93% rename from designer_base/src/com/fr/design/data/datapane/TableDataListPane.java rename to designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java index d3a226520..7b24195e3 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -1,260 +1,265 @@ -package com.fr.design.data.datapane; - -import com.fr.base.TableData; -import com.fr.data.TableDataSource; -import com.fr.data.impl.storeproc.StoreProcedure; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.gui.controlpane.JListControlPane; -import com.fr.design.gui.controlpane.NameableCreator; -import com.fr.design.gui.ilist.ListModelElement; -import com.fr.file.DatasourceManagerProvider; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.general.NameObject; -import com.fr.stable.Nameable; -import com.fr.stable.StringUtils; -import com.fr.stable.core.PropertyChangeAdapter; - -import javax.swing.*; -import java.util.*; - -/** - * TableDataList Pane. - */ -public class TableDataListPane extends JListControlPane { - private boolean isNamePermitted = true; - - public TableDataListPane() { - super(); - dsNameChangedMap.clear(); - this.addEditingListner(new PropertyChangeAdapter() { - @Override - public void propertyChange() { - isNamePermitted = true; - TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); - String[] allDSNames = DesignTableDataManager.getAllDSNames(source); - String[] allListNames = nameableList.getAllNames(); - allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; - String tempName = getEditingName(); - Object editingType = getEditingType(); - if (StringUtils.isEmpty(tempName)) { - String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"}; - String[] sign = new String[]{",", "!"}; - isNamePermitted = false; - nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(warning, sign)); - setWarnigText(editingIndex); - return; - } - - if (!ComparatorUtils.equals(tempName, selectedName) - && isNameRepeted(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { - String[] waning = new String[]{"already_exists", "TableData", "Please_Rename"}; - String[] sign = new String[]{"", tempName + ",", "!"}; - isNamePermitted = false; - nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(waning, sign)); - setWarnigText(editingIndex); - } else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) { - String[] datasource_underline = new String[]{"Datasource-Stored_Procedure", "Name", "can_not_include_underline"}; - String[] sign = new String[]{"", "", "!"}; - isNamePermitted = false; - nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(datasource_underline, sign)); - setWarnigText(editingIndex); - } - if (nameableList.getSelectedValue() instanceof ListModelElement) { - Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; - if (!ComparatorUtils.equals(tempName, selected.getName())) { - rename(selected.getName(), tempName); - - } - } - } - }); - } - - protected void rename(String oldName, String newName) { - dsNameChangedMap.put(oldName, newName); - } - - /** - * 名字是否允许 - * - * @return 是/否 - */ - public boolean isNamePermitted() { - return isNamePermitted; - } - - - /** - * 检查按钮可用状态 Check button enabled. - */ - public void checkButtonEnabled() { - super.checkButtonEnabled(); - isNamePermitted = !isContainsRename(); - } - - private boolean isIncludeUnderline(String name) { - return ComparatorUtils.equals(name.indexOf(StoreProcedure.SPLIT), -1) ? false : true; - } - - /** - * 创建服务器数据集所需要的NameableCreator数组 - * - * @return 数组 - */ - public NameableCreator[] createNameableCreators() { - return TableDataCreatorProducer.getInstance().createServerTableDataCreator(); - } - - - // 只能保证当前模板不重名了 - - /** - * 新建不重名的面板 - * - * @param prefix 前缀字符 - * @return 生成的名字 - */ - @Override - public String createUnrepeatedName(String prefix) { - TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); - if (source == null) { - return super.createUnrepeatedName(prefix); - } - String[] allDsNames = DesignTableDataManager.getAllDSNames(source); - DefaultListModel model = this.getModel(); - Nameable[] all = new Nameable[model.getSize()]; - for (int i = 0; i < model.size(); i++) { - all[i] = ((ListModelElement) model.get(i)).wrapper; - } - // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. - int count = all.length + 1; - while (true) { - String name_test = prefix + count; - boolean repeated = false; - for (int i = 0, len = model.size(); i < len; i++) { - Nameable nameable = all[i]; - if (ComparatorUtils.equals(nameable.getName(), name_test)) { - repeated = true; - break; - } - } - for (String dsname : allDsNames) { - if (ComparatorUtils.equals(dsname, name_test)) { - repeated = true; - break; - } - } - - if (!repeated) { - return name_test; - } - - count++; - } - } - - @Override - protected String title4PopupWindow() { - return "TableData"; - } - - /** - * Populate. - */ - public void populate(TableDataSource tds) { - List nameObjectList = new ArrayList(); - - Iterator tableDataNameIterator = tds.getTableDataNameIterator(); - while (tableDataNameIterator.hasNext()) { - String tableDataName = (String) tableDataNameIterator.next(); - TableData tableData = tds.getTableData(tableDataName); - - if (tableData != null) { - nameObjectList.add(new NameObject(tableDataName, tableData)); - } - } - - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); - } - - /** - * Populate. - */ - public void populate(DatasourceManagerProvider datasourceManager) { - Iterator nameIt = datasourceManager.getTableDataNameIterator(); - Iterator procedurenameIt = datasourceManager.getProcedureNameIterator(); - List nameObjectList = new ArrayList(); - while (nameIt.hasNext()) { - String name = nameIt.next(); - nameObjectList.add(new NameObject(name, datasourceManager.getTableData(name))); - } - while (procedurenameIt.hasNext()) { - String name = procedurenameIt.next(); - nameObjectList.add(new NameObject(name, datasourceManager.getProcedureByName(name))); - } - - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); - } - - public void update(DatasourceManagerProvider datasourceManager) { - datasourceManager.clearAllTableData(); - datasourceManager.clearAllProcedure(); - Nameable[] tableDataArray = this.update(); - for (int i = 0; i < tableDataArray.length; i++) { - NameObject nameObject = (NameObject) tableDataArray[i]; - datasourceManager.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); - } - } - - public void update(TableDataSource tds) { - tds.clearAllTableData(); - - Nameable[] tableDataArray = this.update(); - for (int i = 0; i < tableDataArray.length; i++) { - NameObject nameObject = (NameObject) tableDataArray[i]; - tds.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); - } - } - - /** - * 判断数据集是否重名 - */ - public void checkValid() throws Exception { - List exsitTableDataNameList = new ArrayList(); - // _denny: 判断是否有重复的数据集名 - checkRepeatedDSName(exsitTableDataNameList); - - Nameable[] tableDataArray = this.update(); - for (int i = 0; i < tableDataArray.length; i++) { - NameObject nameObject = (NameObject) tableDataArray[i]; - - if (exsitTableDataNameList.contains(nameObject.getName())) { - String[] waring = new String[]{"TableData", "Error_TableDataNameRepeat"}; - String[] sign = new String[]{": " + nameObject.getName()}; - throw new Exception(Inter.getLocText(waring, sign)); - } - - exsitTableDataNameList.add(nameObject.getName()); - } - } - - protected void checkRepeatedDSName(List exsitTableDataNameList) { - } - - /** - * 在JJControlPane的左侧Tree里面选中某一Item - * - * @param name 被选择的Item名称 - */ - public void selectName(String name) { - this.setSelectedName(name); - } - - public Map getDsNameChangedMap() { - return this.dsNameChangedMap; - } +package com.fr.design.data.datapane; + +import com.fr.base.TableData; +import com.fr.data.TableDataSource; +import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.gui.controlpane.JListControlPane; +import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.ilist.ListModelElement; +import com.fr.file.DatasourceManagerProvider; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.general.NameObject; +import com.fr.stable.Nameable; +import com.fr.stable.StringUtils; +import com.fr.stable.core.PropertyChangeAdapter; + +import javax.swing.*; +import java.util.*; + +/** + * TableDataList Pane. + */ +public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController { + private boolean isNamePermitted = true; + private Map dsNameChangedMap = new HashMap(); + + public TableDataPaneListPane() { + super(); + dsNameChangedMap.clear(); + this.addEditingListner(new PropertyChangeAdapter() { + @Override + public void propertyChange() { + isNamePermitted = true; + TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); + String[] allDSNames = DesignTableDataManager.getAllDSNames(source); + String[] allListNames = nameableList.getAllNames(); + allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; + String tempName = getEditingName(); + Object editingType = getEditingType(); + if (StringUtils.isEmpty(tempName)) { + String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"}; + String[] sign = new String[]{",", "!"}; + isNamePermitted = false; + nameableList.stopEditing(); + JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(warning, sign)); + setWarnigText(editingIndex); + return; + } + + if (!ComparatorUtils.equals(tempName, selectedName) + && isNameRepeted(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { + String[] waning = new String[]{"already_exists", "TableData", "Please_Rename"}; + String[] sign = new String[]{"", tempName + ",", "!"}; + isNamePermitted = false; + nameableList.stopEditing(); + JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(waning, sign)); + setWarnigText(editingIndex); + } else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) { + String[] datasource_underline = new String[]{"Datasource-Stored_Procedure", "Name", "can_not_include_underline"}; + String[] sign = new String[]{"", "", "!"}; + isNamePermitted = false; + nameableList.stopEditing(); + JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(datasource_underline, sign)); + setWarnigText(editingIndex); + } + if (nameableList.getSelectedValue() instanceof ListModelElement) { + Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; + if (!ComparatorUtils.equals(tempName, selected.getName())) { + rename(selected.getName(), tempName); + + } + } + } + }); + } + + public void rename(String oldName, String newName) { + dsNameChangedMap.put(oldName, newName); + } + + /** + * 名字是否允许 + * + * @return 是/否 + */ + public boolean isNamePermitted() { + return isNamePermitted; + } + + + /** + * 检查按钮可用状态 Check button enabled. + */ + public void checkButtonEnabled() { + super.checkButtonEnabled(); + isNamePermitted = !isContainsRename(); + } + + private boolean isIncludeUnderline(String name) { + return ComparatorUtils.equals(name.indexOf(StoreProcedure.SPLIT), -1) ? false : true; + } + + /** + * 创建服务器数据集所需要的NameableCreator数组 + * + * @return 数组 + */ + public NameableCreator[] createNameableCreators() { + return TableDataCreatorProducer.getInstance().createServerTableDataCreator(); + } + + + // 只能保证当前模板不重名了 + + /** + * 新建不重名的面板 + * + * @param prefix 前缀字符 + * @return 生成的名字 + */ + @Override + public String createUnrepeatedName(String prefix) { + TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); + if (source == null) { + return super.createUnrepeatedName(prefix); + } + String[] allDsNames = DesignTableDataManager.getAllDSNames(source); + DefaultListModel model = this.getModel(); + Nameable[] all = new Nameable[model.getSize()]; + for (int i = 0; i < model.size(); i++) { + all[i] = ((ListModelElement) model.get(i)).wrapper; + } + // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. + int count = all.length + 1; + while (true) { + String name_test = prefix + count; + boolean repeated = false; + for (int i = 0, len = model.size(); i < len; i++) { + Nameable nameable = all[i]; + if (ComparatorUtils.equals(nameable.getName(), name_test)) { + repeated = true; + break; + } + } + for (String dsname : allDsNames) { + if (ComparatorUtils.equals(dsname, name_test)) { + repeated = true; + break; + } + } + + if (!repeated) { + return name_test; + } + + count++; + } + } + + @Override + protected String title4PopupWindow() { + return "TableData"; + } + + /** + * Populate. + */ + public void populate(TableDataSource tds) { + List nameObjectList = new ArrayList(); + + Iterator tableDataNameIterator = tds.getTableDataNameIterator(); + while (tableDataNameIterator.hasNext()) { + String tableDataName = (String) tableDataNameIterator.next(); + TableData tableData = tds.getTableData(tableDataName); + + if (tableData != null) { + nameObjectList.add(new NameObject(tableDataName, tableData)); + } + } + + populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + } + + /** + * Populate. + */ + public void populate(DatasourceManagerProvider datasourceManager) { + Iterator nameIt = datasourceManager.getTableDataNameIterator(); + Iterator procedurenameIt = datasourceManager.getProcedureNameIterator(); + List nameObjectList = new ArrayList(); + while (nameIt.hasNext()) { + String name = nameIt.next(); + nameObjectList.add(new NameObject(name, datasourceManager.getTableData(name))); + } + while (procedurenameIt.hasNext()) { + String name = procedurenameIt.next(); + nameObjectList.add(new NameObject(name, datasourceManager.getProcedureByName(name))); + } + + populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + } + + public void update(DatasourceManagerProvider datasourceManager) { + datasourceManager.clearAllTableData(); + datasourceManager.clearAllProcedure(); + Nameable[] tableDataArray = this.update(); + for (int i = 0; i < tableDataArray.length; i++) { + NameObject nameObject = (NameObject) tableDataArray[i]; + datasourceManager.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); + } + } + + public void update(TableDataSource tds) { + tds.clearAllTableData(); + + Nameable[] tableDataArray = this.update(); + for (int i = 0; i < tableDataArray.length; i++) { + NameObject nameObject = (NameObject) tableDataArray[i]; + tds.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); + } + } + + /** + * 判断数据集是否重名 + */ + public void checkValid() throws Exception { + List exsitTableDataNameList = new ArrayList(); + // _denny: 判断是否有重复的数据集名 + checkRepeatedDSName(exsitTableDataNameList); + + Nameable[] tableDataArray = this.update(); + for (int i = 0; i < tableDataArray.length; i++) { + NameObject nameObject = (NameObject) tableDataArray[i]; + + if (exsitTableDataNameList.contains(nameObject.getName())) { + String[] waring = new String[]{"TableData", "Error_TableDataNameRepeat"}; + String[] sign = new String[]{": " + nameObject.getName()}; + throw new Exception(Inter.getLocText(waring, sign)); + } + + exsitTableDataNameList.add(nameObject.getName()); + } + } + + protected void checkRepeatedDSName(List exsitTableDataNameList) { + } + + /** + * 在JJControlPane的左侧Tree里面选中某一Item + * + * @param name 被选择的Item名称 + */ + public void selectName(String name) { + this.setSelectedName(name); + } + + public Map getDsNameChangedMap() { + return this.dsNameChangedMap; + } + + public JPanel getPanel() { + return this; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java index 0ff2ec881..b2c8427af 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java @@ -2,9 +2,9 @@ package com.fr.design.data.tabledata.tabledatapane; import com.fr.base.FRContext; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.data.datapane.TableDataListPane; +import com.fr.design.data.datapane.TableDataPaneController; +import com.fr.design.data.datapane.TableDataPaneListPane; import com.fr.design.fun.TableDataPaneProcessor; -import com.fr.design.gui.controlpane.JControlPane; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -21,7 +21,7 @@ import java.util.Map; public class TableDataManagerPane extends LoadingBasicPane { private UITextField tableDataTextField; - private JControlPane tableDataPane; + private TableDataPaneController tableDataPane; @Override protected void initComponents(JPanel container) { @@ -40,17 +40,17 @@ public class TableDataManagerPane extends LoadingBasicPane { tableDataPathPane.add(tableDataTextField, BorderLayout.CENTER); this.tableDataTextField.setEditable(false); TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); - JControlPane pane = null; + TableDataPaneController pane = null; if (paneProcessor != null) { pane = paneProcessor.createServerTableDataPane(); } - tableDataPane = pane == null ? new TableDataListPane() { - protected void rename(String oldName, String newName) { + tableDataPane = pane == null ? new TableDataPaneListPane() { + public void rename(String oldName, String newName) { super.rename(oldName, newName); renameConnection(oldName, newName); } } : pane; - container.add(tableDataPane, BorderLayout.CENTER); + container.add(tableDataPane.getPanel(), BorderLayout.CENTER); } diff --git a/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java index f1f4ac218..dd4c8068a 100644 --- a/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java +++ b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java @@ -2,7 +2,7 @@ package com.fr.design.fun; import com.fr.design.DesignModelAdapter; import com.fr.design.data.BasicTableDataTreePane; -import com.fr.design.gui.controlpane.JControlPane; +import com.fr.design.data.datapane.TableDataPaneController; import com.fr.stable.fun.Level; /** @@ -25,6 +25,6 @@ public interface TableDataPaneProcessor extends Level { * 服务器数据集面板(模板数据集面板) * @return 服务器数据集面板 */ - JControlPane createServerTableDataPane(); + TableDataPaneController createServerTableDataPane(); } diff --git a/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java index f577d3cc8..53dfc54af 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JControlPane.java @@ -1,20 +1,16 @@ package com.fr.design.gui.controlpane; -import com.fr.data.TableDataSource; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.ToolBarDef; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.file.DatasourceManagerProvider; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import javax.swing.*; import java.awt.*; -import java.util.HashMap; -import java.util.Map; /** * Coder: zack @@ -24,12 +20,12 @@ import java.util.Map; public abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper { protected static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30 protected JPanel controlUpdatePane; - protected Map dsNameChangedMap = new HashMap(); - protected ShortCut4JControlPane[] shorts; - protected NameableCreator[] creators; - protected ToolBarDef toolbarDef; - protected UIToolbar toolBar; + private ShortCut4JControlPane[] shorts; + private NameableCreator[] creators; + private ToolBarDef toolbarDef; + + private UIToolbar toolBar; // peter:这是整体的一个cardLayout Pane protected CardLayout cardLayout; @@ -46,6 +42,50 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe */ public abstract NameableCreator[] createNameableCreators(); + public ShortCut4JControlPane[] getShorts() { + return shorts; + } + + public void setShorts(ShortCut4JControlPane[] shorts) { + this.shorts = shorts; + } + + public void setCreators(NameableCreator[] creators) { + this.creators = creators; + } + + public ToolBarDef getToolbarDef() { + return toolbarDef; + } + + public void setToolbarDef(ToolBarDef toolbarDef) { + this.toolbarDef = toolbarDef; + } + + public UIToolbar getToolBar() { + return toolBar; + } + + public void setToolBar(UIToolbar toolBar) { + this.toolBar = toolBar; + } + + public CardLayout getCardLayout() { + return cardLayout; + } + + public void setCardLayout(CardLayout cardLayout) { + this.cardLayout = cardLayout; + } + + public JPanel getCardPane() { + return cardPane; + } + + public void setCardPane(JPanel cardPane) { + this.cardPane = cardPane; + } + protected void initComponentPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.creators = this.createNameableCreators(); @@ -75,7 +115,7 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe // LeftPane JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - init(leftPane); + initLeftPane(leftPane); shorts = this.createShortcuts(); if (ArrayUtils.isEmpty(shorts)) { @@ -92,59 +132,10 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe return leftPane; } - - public ShortCut4JControlPane[] getShorts() { - return shorts; - } - - public void setShorts(ShortCut4JControlPane[] shorts) { - this.shorts = shorts; - } - - public NameableCreator[] getCreators() { - return creators; - } - - public void setCreators(NameableCreator[] creators) { - this.creators = creators; - } - - public ToolBarDef getToolbarDef() { - return toolbarDef; - } - - public void setToolbarDef(ToolBarDef toolbarDef) { - this.toolbarDef = toolbarDef; - } - - public UIToolbar getToolBar() { - return toolBar; - } - - public void setToolBar(UIToolbar toolBar) { - this.toolBar = toolBar; - } - - public CardLayout getCardLayout() { - return cardLayout; - } - - public void setCardLayout(CardLayout cardLayout) { - this.cardLayout = cardLayout; - } - - public JPanel getCardPane() { - return cardPane; - } - - public void setCardPane(JPanel cardPane) { - this.cardPane = cardPane; - } - /** - * 初始化 + * 初始化左边面板 */ - protected void init(JPanel leftPane) { + protected void initLeftPane(JPanel leftPane) { } @@ -152,13 +143,6 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe return shorts.length * SHORT_WIDTH; } - public Map getDsNameChangedMap() { - return dsNameChangedMap; - } - - public void setDsNameChangedMap(Map dsNameChangedMap) { - this.dsNameChangedMap = dsNameChangedMap; - } protected ShortCut4JControlPane[] createShortcuts() { return new ShortCut4JControlPane[]{ @@ -183,36 +167,12 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe protected abstract ShortCut4JControlPane sortItemShortCut(); - public void setNameListEditable(boolean editable) { - } - public abstract Nameable[] update(); public void populate(Nameable[] nameableArray) { } - public void update(DatasourceManagerProvider datasourceManager) { - } - - public void populate(DatasourceManagerProvider datasourceManager) { - } - - public void populate(TableDataSource tds) { - } - - public void update(TableDataSource tds) { - } - - /** - * 名字是否允许 - * - * @return 默认返回true - */ - public boolean isNamePermitted() { - return true; - } - /** * 检查按钮可用状态 Check button enabled. */ @@ -220,37 +180,33 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe } protected void doBeforeRemove() { - } protected void doAfterRemove() { - } public NameableCreator[] creators() { return creators == null ? new NameableCreator[0] : creators; } - /** - * 检查是否符合规范 - * - * @throws Exception - */ - public void checkValid() throws Exception { - } - protected abstract boolean hasInvalid(boolean isAdd); /** - * 设置选中项 + * 刷新 NameableCreator * - * @param index 选中项的序列号 + * @param creators 生成器 */ - public void setSelectedIndex(int index) { - } - + public void refreshNameableCreator(NameableCreator[] creators) { + this.creators = creators; + shorts = this.createShortcuts(); + toolbarDef.clearShortCuts(); + for (ShortCut4JControlPane sj : shorts) { + toolbarDef.addShortCut(sj.getShortCut()); + } - protected void rename(String oldName, String newName) { - dsNameChangedMap.put(oldName, newName); + toolbarDef.updateToolBar(toolBar); + toolBar.validate(); + toolBar.repaint(); + this.repaint(); } } diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java index cd32fde56..70bacecda 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -63,29 +63,7 @@ public abstract class JListControlPane extends JControlPane { public abstract NameableCreator[] createNameableCreators(); - protected JPanel getLeftPane() { - // LeftPane - JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - initNameList(leftPane); - - shorts = this.createShortcuts(); - if (ArrayUtils.isEmpty(shorts)) { - return leftPane; - } - - toolbarDef = new ToolBarDef(); - for (ShortCut4JControlPane sj : shorts) { - toolbarDef.addShortCut(sj.getShortCut()); - } - toolBar = ToolBarDef.createJToolBar(); - toolbarDef.updateToolBar(toolBar); - leftPane.add(toolBar, BorderLayout.NORTH); - return leftPane; - } - - - private void initNameList(JPanel leftPane) { + protected void initLeftPane(JPanel leftPane) { nameableList = createJNameList(); nameableList.setName(LIST_NAME); leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); @@ -127,23 +105,9 @@ public abstract class JListControlPane extends JControlPane { } - protected int getLeftPreferredSize() { - return shorts.length * JControlPane.SHORT_WIDTH; - } - - protected ShortCut4JControlPane[] createShortcuts() { - return new ShortCut4JControlPane[]{ - addItemShortCut(), - removeItemShortCut(), - copyItemShortCut(), - moveUpItemShortCut(), - moveDownItemShortCut(), - sortItemShortCut() - }; - } - protected ShortCut4JControlPane addItemShortCut() { ShortCut addItemShortCut; + NameableCreator[] creators = creators(); if (creators.length == 1) { addItemShortCut = new AddItemUpdateAction(creators); } else { @@ -264,25 +228,6 @@ public abstract class JListControlPane extends JControlPane { return el == null ? null : el.wrapper.getName(); } - /** - * 刷新 NameableCreator - * - * @param creators 生成器 - */ - public void refreshNameableCreator(NameableCreator[] creators) { - this.creators = creators; - shorts = this.createShortcuts(); - toolbarDef.clearShortCuts(); - for (ShortCut4JControlPane sj : shorts) { - toolbarDef.addShortCut(sj.getShortCut()); - } - - toolbarDef.updateToolBar(toolBar); - toolBar.validate(); - toolBar.repaint(); - this.repaint(); - } - protected boolean isNameRepeted(java.util.List[] list, String name) { for (int i = 0; i < list.length; i++) { if (list[i].contains(name)) { @@ -676,7 +621,7 @@ public abstract class JListControlPane extends JControlPane { // p:右键菜单. JPopupMenu popupMenu = new JPopupMenu(); - for (ShortCut4JControlPane sj : shorts) { + for (ShortCut4JControlPane sj : getShorts()) { sj.getShortCut().intoJPopupMenu(popupMenu); } @@ -694,13 +639,14 @@ public abstract class JListControlPane extends JControlPane { * 检查按钮可用状态 Check button enabled. */ public void checkButtonEnabled() { + int selectedIndex = nameableList.getSelectedIndex(); if (selectedIndex == -1) { this.cardLayout.show(cardPane, "SELECT"); } else { this.cardLayout.show(cardPane, "EDIT"); } - for (ShortCut4JControlPane sj : this.shorts) { + for (ShortCut4JControlPane sj : getShorts()) { sj.checkEnable(); } } @@ -713,10 +659,6 @@ public abstract class JListControlPane extends JControlPane { } - public NameableCreator[] creators() { - return creators == null ? new NameableCreator[0] : creators; - } - /* * Nameable的ListCellRenerer */ @@ -732,7 +674,7 @@ public abstract class JListControlPane extends JControlPane { this.setText(((ListModelElement) value).wrapper.getName()); boolean iconSet = false; - for (NameableCreator creator : JListControlPane.this.creators) { + for (NameableCreator creator : JListControlPane.this.creators()) { if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) { this.setIcon(creator.menuIcon()); this.setToolTipText(creator.createTooltip()); @@ -836,6 +778,7 @@ public abstract class JListControlPane extends JControlPane { } private void initUpdatePane() { + NameableCreator[] creators = creators(); if (creators == null) { return; } @@ -855,6 +798,7 @@ public abstract class JListControlPane extends JControlPane { } elEditing = el; + NameableCreator[] creators = creators(); for (int i = 0, len = updatePanes.length; i < len; i++) { Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); @@ -884,13 +828,14 @@ public abstract class JListControlPane extends JControlPane { } public void update() { + NameableCreator[] creators = creators(); for (int i = 0; i < updatePanes.length; i++) { BasicBeanPane pane = updatePanes[i]; if (pane != null && pane.isVisible()) { Object bean = pane.updateBean(); - if (i < JListControlPane.this.creators.length) { - JListControlPane.this.creators[i].saveUpdatedBean(elEditing, bean); + if (i < creators.length) { + creators[i].saveUpdatedBean(elEditing, bean); } } } @@ -937,8 +882,9 @@ public abstract class JListControlPane extends JControlPane { // 选项添加个数有限制等情况下 要求能控制快捷按钮的状态 protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) { - if (this.toolbarDef.getShortCutCount() > shortCutIndex) { - ShortCut sc = this.toolbarDef.getShortCut(shortCutIndex); + ToolBarDef toolbarDef = getToolbarDef(); + if (toolbarDef.getShortCutCount() > shortCutIndex) { + ShortCut sc = toolbarDef.getShortCut(shortCutIndex); if (sc instanceof AddItemMenuDef) { AddItemMenuDef am = (AddItemMenuDef) sc; if (am.getShortCutCount() > itemIndex) { From 282b7302671fa2e819e1f219aefea2538d96037f Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 18 May 2016 12:47:56 +0800 Subject: [PATCH 12/41] =?UTF-8?q?=E5=8A=A0=E4=B8=8Aoverride?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataPaneListPane.java | 10 ++++++++ .../gui/controlpane/JListControlPane.java | 24 ++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java index 7b24195e3..76a199d04 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -224,6 +224,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData /** * 判断数据集是否重名 */ + @Override public void checkValid() throws Exception { List exsitTableDataNameList = new ArrayList(); // _denny: 判断是否有重复的数据集名 @@ -262,4 +263,13 @@ public class TableDataPaneListPane extends JListControlPane implements TableData public JPanel getPanel() { return this; } + + /** + * 设置选中项 + * + * @param index 选中项的序列号 + */ + public void setSelectedIndex(int index) { + nameableList.setSelectedIndex(index); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java index 70bacecda..f6ff9c1ed 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -63,6 +63,7 @@ public abstract class JListControlPane extends JControlPane { public abstract NameableCreator[] createNameableCreators(); + @Override protected void initLeftPane(JPanel leftPane) { nameableList = createJNameList(); nameableList.setName(LIST_NAME); @@ -89,6 +90,7 @@ public abstract class JListControlPane extends JControlPane { public JNameEdList createJNameList() { JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) { + @Override protected void doAfterLostFocus() { JListControlPane.this.updateControlUpdatePane(); } @@ -151,6 +153,7 @@ public abstract class JListControlPane extends JControlPane { return res.toArray(new Nameable[res.size()]); } + @Override public void populate(Nameable[] nameableArray) { DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); listModel.removeAllElements(); @@ -602,6 +605,7 @@ public abstract class JListControlPane extends JControlPane { * JNameEdList的鼠标事件 */ private MouseListener listMouseListener = new MouseAdapter() { + @Override public void mouseReleased(MouseEvent evt) { nameableList.stopEditing(); if (evt.getClickCount() >= 2 @@ -638,6 +642,7 @@ public abstract class JListControlPane extends JControlPane { /** * 检查按钮可用状态 Check button enabled. */ + @Override public void checkButtonEnabled() { int selectedIndex = nameableList.getSelectedIndex(); @@ -651,19 +656,12 @@ public abstract class JListControlPane extends JControlPane { } } - protected void doBeforeRemove() { - - } - - protected void doAfterRemove() { - - } - /* * Nameable的ListCellRenerer */ private class NameableListCellRenderer extends DefaultListCellRenderer { + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, @@ -899,6 +897,7 @@ public abstract class JListControlPane extends JControlPane { * * @throws Exception */ + @Override public void checkValid() throws Exception { ((JControlUpdatePane) this.controlUpdatePane).checkValid(); } @@ -933,13 +932,4 @@ public abstract class JListControlPane extends JControlPane { return false; } - - /** - * 设置选中项 - * - * @param index 选中项的序列号 - */ - public void setSelectedIndex(int index) { - nameableList.setSelectedIndex(index); - } } \ No newline at end of file From 909b4b1a0bd7fd2d357f6b4fded0681ff041a8c8 Mon Sep 17 00:00:00 2001 From: xiaohu Date: Wed, 18 May 2016 15:04:15 +0800 Subject: [PATCH 13/41] =?UTF-8?q?=E6=95=B8=E6=93=9A=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/MeterPlotTableDataContentPane.java | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java index 5ea4e8fe6..22deb5101 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java @@ -49,14 +49,7 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane double[] columnSize = { p,f}; double[] rowSize = { p, p,p,p,p,p,p,p, p}; - Component[][] components = new Component[][]{ - new Component[]{new BoldFontTextLabel(METER_NAME, SwingConstants.RIGHT), nameBox}, - new Component[]{new BoldFontTextLabel(METER_VALUE, SwingConstants.RIGHT), valueBox}, - new Component[]{new JSeparator(), null}, - new Component[]{new BoldFontTextLabel(Inter.getLocText("Chart-Data_Filter"))}, - new Component[]{filterPane, null} - - } ; + Component[][] components = createComponents(); JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); this.add(panel,BorderLayout.CENTER); @@ -65,7 +58,17 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane valueBox.addItemListener(tooltipListener); } - protected void refreshBoxListWithSelectTableData(List list) { + private Component[][] createComponents() { + return new Component[][]{ + new Component[]{new BoldFontTextLabel(METER_NAME, SwingConstants.RIGHT), getNameComponent()}, + new Component[]{new BoldFontTextLabel(METER_VALUE, SwingConstants.RIGHT), valueBox}, + new Component[]{new JSeparator(), null}, + new Component[]{new BoldFontTextLabel(Inter.getLocText("Chart-Data_Filter"))}, + new Component[]{filterPane, null} + }; + } + + protected void refreshBoxListWithSelectTableData(List list) { refreshBoxItems(nameBox, list); refreshBoxItems(valueBox, list); } @@ -84,14 +87,19 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane public void populateBean(ChartCollection ob) { if(ob != null && ob.getSelectedChart().getFilterDefinition() instanceof MeterTableDefinition) { MeterTableDefinition meter = (MeterTableDefinition)ob.getSelectedChart().getFilterDefinition(); - - nameBox.setSelectedItem(meter.getName()); + + populateNameComponent(meter.getName()); + valueBox.setSelectedItem(meter.getValue()); filterPane.populateBean(ob); } } - /** + protected void populateNameComponent(String name) { + nameBox.setSelectedItem(name); + } + + /** * 保存界面属性. */ public void updateBean(ChartCollection ob) { @@ -99,13 +107,18 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane MeterTableDefinition meter = new MeterTableDefinition(); ob.getSelectedChart().setFilterDefinition(meter); - meter.setName(Utils.objectToString(nameBox.getSelectedItem())); + updateNameComponent(meter); + meter.setValue(Utils.objectToString(valueBox.getSelectedItem())); filterPane.updateBean(ob); } } - /** + protected void updateNameComponent(MeterTableDefinition meter) { + meter.setName(Utils.objectToString(nameBox.getSelectedItem())); + } + + /** * 重新布局整个面板 */ public void redoLayoutPane(){ @@ -113,4 +126,7 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane } + protected Component getNameComponent() { + return nameBox; + } } \ No newline at end of file From b6433715ba84e504e5224e2f4c42ed2060570406 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 18 May 2016 15:08:54 +0800 Subject: [PATCH 14/41] =?UTF-8?q?=E5=8A=A0override?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataPaneListPane.java | 11 +++++++++ .../gui/controlpane/JListControlPane.java | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java index 76a199d04..90d6ca5df 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -75,6 +75,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData }); } + @Override public void rename(String oldName, String newName) { dsNameChangedMap.put(oldName, newName); } @@ -84,6 +85,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData * * @return 是/否 */ + @Override public boolean isNamePermitted() { return isNamePermitted; } @@ -92,6 +94,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData /** * 检查按钮可用状态 Check button enabled. */ + @Override public void checkButtonEnabled() { super.checkButtonEnabled(); isNamePermitted = !isContainsRename(); @@ -106,6 +109,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData * * @return 数组 */ + @Override public NameableCreator[] createNameableCreators() { return TableDataCreatorProducer.getInstance().createServerTableDataCreator(); } @@ -166,6 +170,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData /** * Populate. */ + @Override public void populate(TableDataSource tds) { List nameObjectList = new ArrayList(); @@ -185,6 +190,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData /** * Populate. */ + @Override public void populate(DatasourceManagerProvider datasourceManager) { Iterator nameIt = datasourceManager.getTableDataNameIterator(); Iterator procedurenameIt = datasourceManager.getProcedureNameIterator(); @@ -201,6 +207,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); } + @Override public void update(DatasourceManagerProvider datasourceManager) { datasourceManager.clearAllTableData(); datasourceManager.clearAllProcedure(); @@ -211,6 +218,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } } + @Override public void update(TableDataSource tds) { tds.clearAllTableData(); @@ -256,10 +264,12 @@ public class TableDataPaneListPane extends JListControlPane implements TableData this.setSelectedName(name); } + @Override public Map getDsNameChangedMap() { return this.dsNameChangedMap; } + @Override public JPanel getPanel() { return this; } @@ -269,6 +279,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData * * @param index 选中项的序列号 */ + @Override public void setSelectedIndex(int index) { nameableList.setSelectedIndex(index); } diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java index f6ff9c1ed..3ed10c3b1 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -51,6 +51,7 @@ public abstract class JListControlPane extends JControlPane { this.initComponentPane(); } + @Override protected JPanel createControlUpdatePane() { return new JControlUpdatePane(); } @@ -60,6 +61,7 @@ public abstract class JListControlPane extends JControlPane { * * @return 按钮的NameableCreator */ + @Override public abstract NameableCreator[] createNameableCreators(); @@ -107,6 +109,7 @@ public abstract class JListControlPane extends JControlPane { } + @Override protected ShortCut4JControlPane addItemShortCut() { ShortCut addItemShortCut; NameableCreator[] creators = creators(); @@ -118,22 +121,27 @@ public abstract class JListControlPane extends JControlPane { return new AbsoluteEnableShortCut(addItemShortCut); } + @Override protected ShortCut4JControlPane removeItemShortCut() { return new NormalEnableShortCut(new RemoveItemAction()); } + @Override protected ShortCut4JControlPane copyItemShortCut() { return new NormalEnableShortCut(new CopyItemAction()); } + @Override protected ShortCut4JControlPane moveUpItemShortCut() { return new NormalEnableShortCut(new MoveUpItemAction()); } + @Override protected ShortCut4JControlPane moveDownItemShortCut() { return new NormalEnableShortCut(new MoveDownItemAction()); } + @Override protected ShortCut4JControlPane sortItemShortCut() { return new NormalEnableShortCut(new SortItemAction()); } @@ -142,6 +150,7 @@ public abstract class JListControlPane extends JControlPane { this.nameableList.setEditable(editable); } + @Override public Nameable[] update() { java.util.List res = new java.util.ArrayList(); ((JControlUpdatePane) this.controlUpdatePane).update(); @@ -309,6 +318,7 @@ public abstract class JListControlPane extends JControlPane { * @param prefix 名字前缀 * @return 名字 */ + @Override public String createUnrepeatedName(String prefix) { DefaultListModel model = this.getModel(); Nameable[] all = new Nameable[model.getSize()]; @@ -349,6 +359,7 @@ public abstract class JListControlPane extends JControlPane { this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); } + @Override public void actionPerformed(ActionEvent e) { Nameable nameable = creator.createNameable(JListControlPane.this); @@ -386,6 +397,7 @@ public abstract class JListControlPane extends JControlPane { } } + @Override public void actionPerformed(ActionEvent e) { if (hasInvalid(true)) { return; @@ -427,6 +439,7 @@ public abstract class JListControlPane extends JControlPane { .readIcon("/com/fr/base/images/cell/control/remove.png")); } + @Override public void actionPerformed(ActionEvent evt) { try { JListControlPane.this.nameableList.getCellEditor() @@ -454,6 +467,7 @@ public abstract class JListControlPane extends JControlPane { .readIcon("/com/fr/base/images/cell/control/copy.png")); } + @Override public void actionPerformed(ActionEvent evt) { // p:选中的值. ListModelElement selectedValue = (ListModelElement) nameableList.getSelectedValue(); @@ -488,6 +502,7 @@ public abstract class JListControlPane extends JControlPane { .readIcon("/com/fr/design/images/control/up.png")); } + @Override public void actionPerformed(ActionEvent evt) { int selectedIndex = nameableList.getSelectedIndex(); if (selectedIndex == -1) { @@ -520,6 +535,7 @@ public abstract class JListControlPane extends JControlPane { .readIcon("/com/fr/design/images/control/down.png")); } + @Override public void actionPerformed(ActionEvent evt) { int selectedIndex = nameableList.getSelectedIndex(); if (selectedIndex == -1) { @@ -550,6 +566,7 @@ public abstract class JListControlPane extends JControlPane { .readIcon("/com/fr/design/images/control/sortAsc.png")); } + @Override public void actionPerformed(ActionEvent evt) { // p:选中的值. Object selectedValue = nameableList.getSelectedValue(); @@ -568,6 +585,7 @@ public abstract class JListControlPane extends JControlPane { // p:排序. if (isAtoZ) { Comparator nameableComparator = new Comparator() { + @Override public int compare(Nameable o1, Nameable o2) { return -ComparatorUtils.compare(o1.getName(), o2 .getName()); @@ -577,6 +595,7 @@ public abstract class JListControlPane extends JControlPane { Arrays.sort(nameableArray, nameableComparator); } else { Comparator nameableComparator = new Comparator() { + @Override public int compare(Nameable o1, Nameable o2) { return ComparatorUtils.compare(o1.getName(), o2 .getName()); @@ -634,6 +653,7 @@ public abstract class JListControlPane extends JControlPane { evt.getY() - 1); } + @Override public void mouseMoved(MouseEvent e) { } @@ -697,6 +717,7 @@ public abstract class JListControlPane extends JControlPane { /** * 检查是否可用 */ + @Override public void checkEnable() { this.shortCut.setEnabled(true); } @@ -710,6 +731,7 @@ public abstract class JListControlPane extends JControlPane { /** * 检查是否可用 */ + @Override public void checkEnable() { this.shortCut.setEnabled(getModel() .getSize() > 0 @@ -918,6 +940,7 @@ public abstract class JListControlPane extends JControlPane { return -1; } + @Override protected boolean hasInvalid(boolean isAdd) { int idx = JListControlPane.this.getInValidIndex(); if (isAdd || nameableList.getSelectedIndex() != idx) { From 758bc577759910f30098d4d8237a06c0f7666920 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 18 May 2016 15:36:32 +0800 Subject: [PATCH 15/41] =?UTF-8?q?=E8=83=8C=E6=99=AF=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/webattr/ReportWebAttrPane.java | 3 +- .../fr/design/ExtraDesignClassManager.java | 44 + .../design/fun/BackgroundQuickUIProvider.java | 22 + .../fr/design/fun/BackgroundUIProvider.java | 34 + .../AbstractBackgroundQuickUIProvider.java | 20 + .../impl/AbstractBackgroundUIProvider.java | 20 + ...tingPane.java => BackgroundQuickPane.java} | 64 +- ...ane.java => ColorBackgroundQuickPane.java} | 142 +-- ...ane.java => ImageBackgroundQuickPane.java} | 368 ++++---- ...Pane.java => NullBackgroundQuickPane.java} | 106 +-- ...e.java => PatternBackgroundQuickPane.java} | 420 ++++---- ...e.java => TextureBackgroundQuickPane.java} | 344 +++---- .../com/fr/design/style/AbstractPopBox.java | 6 +- .../background/BackgroundDetailPane.java | 18 + .../style/background/BackgroundFactory.java | 121 +++ .../style/background/BackgroundPane.java | 893 +----------------- .../background/BackgroundPane4Browser.java | 47 + .../background/BackgroundSelectPane.java | 5 +- .../style/background/BackgroundUIWrapper.java | 49 + ...tPane.java => GradientBackgroundPane.java} | 268 +++--- .../design/style/background/impl/BPane.java | 46 + .../background/impl/ColorBackgroundPane.java | 42 + .../background/impl/ImageBackgroundPane.java | 230 +++++ .../impl/ImageBackgroundPane4Browser.java | 25 + .../background/impl/NullBackgroundPane.java | 39 + .../impl/PatternBackgroundPane.java | 208 ++++ .../impl/PatternBackgroundPaneNoFore.java | 24 + .../impl/TextureBackgroundPane.java | 197 ++++ .../background/pattern/PatternSelectPane.java | 6 +- .../background/texture/TextureSelectPane.java | 6 +- .../gui/style/ChartBackgroundNoImagePane.java | 12 +- .../chart/gui/style/ChartBackgroundPane.java | 26 +- 32 files changed, 2119 insertions(+), 1736 deletions(-) create mode 100644 designer_base/src/com/fr/design/fun/BackgroundQuickUIProvider.java create mode 100644 designer_base/src/com/fr/design/fun/BackgroundUIProvider.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractBackgroundQuickUIProvider.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractBackgroundUIProvider.java rename designer_base/src/com/fr/design/mainframe/backgroundpane/{BackgroundSettingPane.java => BackgroundQuickPane.java} (83%) rename designer_base/src/com/fr/design/mainframe/backgroundpane/{ColorBackgroundPane.java => ColorBackgroundQuickPane.java} (91%) rename designer_base/src/com/fr/design/mainframe/backgroundpane/{ImageBackgroundPane.java => ImageBackgroundQuickPane.java} (93%) rename designer_base/src/com/fr/design/mainframe/backgroundpane/{NullBackgroundPane.java => NullBackgroundQuickPane.java} (89%) rename designer_base/src/com/fr/design/mainframe/backgroundpane/{PatternBackgroundPane.java => PatternBackgroundQuickPane.java} (92%) rename designer_base/src/com/fr/design/mainframe/backgroundpane/{TextureBackgroundPane.java => TextureBackgroundQuickPane.java} (94%) create mode 100644 designer_base/src/com/fr/design/style/background/BackgroundDetailPane.java create mode 100644 designer_base/src/com/fr/design/style/background/BackgroundFactory.java create mode 100644 designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java create mode 100644 designer_base/src/com/fr/design/style/background/BackgroundUIWrapper.java rename designer_base/src/com/fr/design/style/background/gradient/{GradientPane.java => GradientBackgroundPane.java} (93%) create mode 100644 designer_base/src/com/fr/design/style/background/impl/BPane.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/ColorBackgroundPane.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/NullBackgroundPane.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPane.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPaneNoFore.java create mode 100644 designer_base/src/com/fr/design/style/background/impl/TextureBackgroundPane.java diff --git a/designer/src/com/fr/design/webattr/ReportWebAttrPane.java b/designer/src/com/fr/design/webattr/ReportWebAttrPane.java index cd761199b..6330ee87f 100644 --- a/designer/src/com/fr/design/webattr/ReportWebAttrPane.java +++ b/designer/src/com/fr/design/webattr/ReportWebAttrPane.java @@ -10,6 +10,7 @@ import javax.swing.JPanel; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundPane4Browser; import com.fr.general.Inter; import com.fr.design.style.background.BackgroundPane; import com.fr.web.attr.ReportWebAttr; @@ -50,7 +51,7 @@ public class ReportWebAttrPane extends LoadingBasicPane { tabbedPane.add(Inter.getLocText("WEB-Write_Setting"), writeWeb = new WriteWebSettingPane()); tabbedPane.add(Inter.getLocText("M-Data_Analysis_Settings"), viewWeb = new ViewWebSettingPane()); - tabbedPane.addTab(Inter.getLocText("ReportServerP-Browser_Background"), backgroundPane = new BackgroundPane(true)); + tabbedPane.addTab(Inter.getLocText("ReportServerP-Browser_Background"), backgroundPane = new BackgroundPane4Browser()); tabbedPane.addTab(Inter.getLocText("ReportServerP-Import_Css"), cssPane = new WebCssPane()); tabbedPane.addTab(Inter.getLocText("ReportServerP-Import_JavaScript"), jsPane = new WebJsPane()); } diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index a11ff53a6..d67638167 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -134,6 +134,10 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private Set exportAttrTabProviders; + private Set backgroundQuickUIProviders; + + private Set backgroundUIProviders; + public TableDataPaneProcessor getTableDataPaneProcessor() { return tableDataPaneProcessor; } @@ -770,6 +774,36 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi exportAttrTabProviders.add((ExportAttrTabProvider) level); } + public BackgroundQuickUIProvider[] getBackgroundQuickUIProviders() { + if (backgroundQuickUIProviders == null) { + return new BackgroundQuickUIProvider[0]; + } + return backgroundQuickUIProviders.toArray(new BackgroundQuickUIProvider[backgroundQuickUIProviders.size()]); + } + + public void addBackgroundQuickUIProvider(Level level, PluginSimplify simplify) throws Exception { + if (backgroundQuickUIProviders == null) { + backgroundQuickUIProviders = new HashSet<>(); + } + validAPILevel(level, BackgroundQuickUIProvider.CURRENT_LEVEL, simplify.getPluginName()); + backgroundQuickUIProviders.add((BackgroundQuickUIProvider) level); + } + + public BackgroundUIProvider[] getBackgroundUIProviders() { + if (backgroundUIProviders == null) { + return new BackgroundUIProvider[0]; + } + return backgroundUIProviders.toArray(new BackgroundUIProvider[backgroundUIProviders.size()]); + } + + public void addBackgroundUIProvider(Level level, PluginSimplify simplify) throws Exception { + if (backgroundUIProviders == null) { + backgroundUIProviders = new HashSet<>(); + } + validAPILevel(level, BackgroundUIProvider.CURRENT_LEVEL, simplify.getPluginName()); + backgroundUIProviders.add((BackgroundUIProvider) level); + } + /** * 文件名 * @@ -824,6 +858,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi readWidgetRelated(tagName, impl, simplify); //数据集, 数据连接 readTableDataRelated(tagName, className, simplify); + // 样式相关的 + readStyleRelated(tagName, impl, simplify); if (tagName.equals(ParameterWidgetOptionProvider.XML_TAG)) { addParameterWidgetOption(impl, simplify); } else if (tagName.equals(PreviewProvider.MARK_STRING)) { @@ -898,6 +934,14 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi } } + private void readStyleRelated(String tagName, Level impl, PluginSimplify simplify) throws Exception { + if (tagName.equals(BackgroundQuickUIProvider.MARK_STRING)) { + addBackgroundQuickUIProvider(impl, simplify); + } else if (tagName.equals(BackgroundUIProvider.MARK_STRING)) { + addBackgroundUIProvider(impl, simplify); + } + } + /** * 写xml * diff --git a/designer_base/src/com/fr/design/fun/BackgroundQuickUIProvider.java b/designer_base/src/com/fr/design/fun/BackgroundQuickUIProvider.java new file mode 100644 index 000000000..257d257a3 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/BackgroundQuickUIProvider.java @@ -0,0 +1,22 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.stable.fun.Level; +import com.fr.stable.fun.Provider; + +/** + * Created by richie on 16/5/18. + * 背景设置界面接口,用于扩展设置更多类型的背景 + */ +public interface BackgroundQuickUIProvider extends Level, Provider { + + String MARK_STRING = "BackgroundQuickUIProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 背景设置界面 + * @return 设置界面 + */ + BackgroundQuickPane appearanceForBackground(); +} diff --git a/designer_base/src/com/fr/design/fun/BackgroundUIProvider.java b/designer_base/src/com/fr/design/fun/BackgroundUIProvider.java new file mode 100644 index 000000000..0ae87b9d7 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/BackgroundUIProvider.java @@ -0,0 +1,34 @@ +package com.fr.design.fun; + +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.general.Background; +import com.fr.stable.fun.Level; +import com.fr.stable.fun.Provider; + +/** + * Created by richie on 16/5/18. + */ +public interface BackgroundUIProvider extends Level, Provider { + + String MARK_STRING = "BackgroundUIProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 对应的背景具体类型 + * @return 背景 + */ + Class targetClass(); + + /** + * 背景设置界面 + * @return 界面 + */ + Class targetUIClass(); + + /** + * 标题 + * @return 在设计界面上这个选项的显示标题 + */ + String targetTitle(); +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractBackgroundQuickUIProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractBackgroundQuickUIProvider.java new file mode 100644 index 000000000..82da697c1 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractBackgroundQuickUIProvider.java @@ -0,0 +1,20 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.BackgroundQuickUIProvider; +import com.fr.stable.fun.impl.AbstractProvider; + +/** + * Created by richie on 16/5/18. + */ +public abstract class AbstractBackgroundQuickUIProvider extends AbstractProvider implements BackgroundQuickUIProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractBackgroundUIProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractBackgroundUIProvider.java new file mode 100644 index 000000000..ad95e3684 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractBackgroundUIProvider.java @@ -0,0 +1,20 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.BackgroundUIProvider; +import com.fr.stable.fun.impl.AbstractProvider; + +/** + * Created by richie on 16/5/18. + */ +public abstract class AbstractBackgroundUIProvider extends AbstractProvider implements BackgroundUIProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/BackgroundSettingPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java similarity index 83% rename from designer_base/src/com/fr/design/mainframe/backgroundpane/BackgroundSettingPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java index 82eafecb7..1b796c438 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/BackgroundSettingPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java @@ -1,33 +1,33 @@ -package com.fr.design.mainframe.backgroundpane; - -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.event.UIObserver; -import com.fr.general.Background; - -/** - * @author zhou - * @since 2012-5-29下午1:12:28 - */ -public abstract class BackgroundSettingPane extends BasicBeanPane implements UIObserver { - - public abstract boolean accept(Background background); - - @Override - public abstract void populateBean(Background background); - - @Override - public abstract Background updateBean(); - - @Override - public abstract String title4PopupWindow(); - - /** - * 组件是否需要响应添加的观察者事件 - * - * @return 如果需要响应观察者事件则返回true,否则返回false - */ - public boolean shouldResponseChangeListener() { - - return true; - } +package com.fr.design.mainframe.backgroundpane; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.event.UIObserver; +import com.fr.general.Background; + +/** + * @author zhou + * @since 2012-5-29下午1:12:28 + */ +public abstract class BackgroundQuickPane extends BasicBeanPane implements UIObserver { + + public abstract boolean accept(Background background); + + @Override + public abstract void populateBean(Background background); + + @Override + public abstract Background updateBean(); + + @Override + public abstract String title4PopupWindow(); + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + + return true; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/ColorBackgroundPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java similarity index 91% rename from designer_base/src/com/fr/design/mainframe/backgroundpane/ColorBackgroundPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java index 1b7fea0eb..f08b0a89b 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/ColorBackgroundPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java @@ -1,72 +1,72 @@ -package com.fr.design.mainframe.backgroundpane; - -import com.fr.base.background.ColorBackground; -import com.fr.design.event.UIObserverListener; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Background; -import com.fr.general.Inter; -import com.fr.design.style.color.NewColorSelectPane; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; - -/** - * @author zhou - * @since 2012-5-29下午1:12:14 - */ -public class ColorBackgroundPane extends BackgroundSettingPane { - - private NewColorSelectPane detailColorSelectPane; - - public ColorBackgroundPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - detailColorSelectPane = new NewColorSelectPane(); - this.add(detailColorSelectPane, BorderLayout.NORTH); - } - - public void populateBean(Background background) { - ColorBackground colorBackgroud = (ColorBackground) background; - this.detailColorSelectPane.setColor(colorBackgroud.getColor()); - } - - public Background updateBean() { - this.detailColorSelectPane.updateUsedColor(); - return ColorBackground.getInstance(this.detailColorSelectPane.getNotNoneColor()); - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - detailColorSelectPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - } - - @Override - /** - * 是否为ColorBackground 类型 - * - * @param background 背景 - * @return 同上 - * - */ - public boolean accept(Background background) { - return background instanceof ColorBackground; - } - - @Override - /** - * 窗口名称 - * @return 同上 - */ - public String title4PopupWindow() { - return Inter.getLocText("Color"); - } +package com.fr.design.mainframe.backgroundpane; + +import com.fr.base.background.ColorBackground; +import com.fr.design.event.UIObserverListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.Inter; +import com.fr.design.style.color.NewColorSelectPane; + +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * @author zhou + * @since 2012-5-29下午1:12:14 + */ +public class ColorBackgroundQuickPane extends BackgroundQuickPane { + + private NewColorSelectPane detailColorSelectPane; + + public ColorBackgroundQuickPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + detailColorSelectPane = new NewColorSelectPane(); + this.add(detailColorSelectPane, BorderLayout.NORTH); + } + + public void populateBean(Background background) { + ColorBackground colorBackgroud = (ColorBackground) background; + this.detailColorSelectPane.setColor(colorBackgroud.getColor()); + } + + public Background updateBean() { + this.detailColorSelectPane.updateUsedColor(); + return ColorBackground.getInstance(this.detailColorSelectPane.getNotNoneColor()); + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + detailColorSelectPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + } + + @Override + /** + * 是否为ColorBackground 类型 + * + * @param background 背景 + * @return 同上 + * + */ + public boolean accept(Background background) { + return background instanceof ColorBackground; + } + + @Override + /** + * 窗口名称 + * @return 同上 + */ + public String title4PopupWindow() { + return Inter.getLocText("Color"); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java similarity index 93% rename from designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index 7565d7d78..114b704c0 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java @@ -1,185 +1,185 @@ -package com.fr.design.mainframe.backgroundpane; - -import com.fr.base.BaseUtils; -import com.fr.base.Style; -import com.fr.base.background.ImageBackground; -import com.fr.design.constants.UIConstants; -import com.fr.design.border.UIRoundedBorder; -import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DesignerContext; -import com.fr.general.Background; -import com.fr.general.Inter; -import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; -import com.fr.design.style.background.image.ImageFileChooser; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; - -/** - * @author zhou - * @since 2012-5-29下午1:12:06 - */ -public class ImageBackgroundPane extends BackgroundSettingPane { - - private ImagePreviewPane previewPane; - private Style imageStyle = null; - private ChangeListener changeListener = null; - private ImageFileChooser imageFileChooser; - - private UIButtonGroup imageLayoutPane; - - public ImageBackgroundPane() { - this(true); - } - - public ImageBackgroundPane(boolean hasImageLayout) { - this.setLayout(new BorderLayout(0, 4)); - String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; - Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; - imageLayoutPane = new UIButtonGroup(nameArray, valueArray); - imageLayoutPane.setSelectedIndex(0); - - previewPane = new ImagePreviewPane(); - JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); - borderPane.setPreferredSize(new Dimension(0, 145)); - borderPane.add(previewPane, BorderLayout.CENTER); - this.add(borderPane, BorderLayout.NORTH); - previewPane.addChangeListener(imageSizeChangeListener); - - JPanel southPane = new JPanel(new BorderLayout(0, 4)); - JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - contentPane.add(southPane, BorderLayout.NORTH); - this.add(contentPane, BorderLayout.CENTER); - - JPanel selectFilePane = new JPanel(new GridLayout(0, 2)); - - UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); - selectFilePane.add(new JPanel()); - selectFilePane.add(selectPictureButton); - selectPictureButton.addActionListener(selectPictureActionListener); - - if(hasImageLayout){ - southPane.add(imageLayoutPane, BorderLayout.CENTER); - } - southPane.add(selectFilePane, BorderLayout.SOUTH); - - imageLayoutPane.addChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - previewPane.setImageStyle(imageStyle); - previewPane.repaint(); - } - }); - } - - /** - * Select picture. - */ - ActionListener selectPictureActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - if (imageFileChooser == null) { - imageFileChooser = new ImageFileChooser(); - imageFileChooser.setMultiSelectionEnabled(false); - } - int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - - previewPane.setImage(image); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - previewPane.setImageStyle(imageStyle); - previewPane.repaint(); - } else { - previewPane.setImage(null); - } - fireChagneListener(); - } - - } - }; - - public void populateBean(Background background) { - - ImageBackground imageBackground = (ImageBackground) background; - imageLayoutPane.setSelectedItem((byte) imageBackground.getLayout()); - Style.DEFAULT_STYLE.deriveImageLayout(imageBackground.getLayout()); - - previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); - previewPane.setImage(imageBackground.getImage()); - previewPane.repaint(); - } - - public Background updateBean() { - ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - imageBackground.setLayout(imageStyle.getImageLayout()); - return imageBackground; - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - changeListener = new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }; - imageLayoutPane.addChangeListener(changeListener); - } - - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - - ChangeListener imageSizeChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent evt) { - if (imageLayoutPane.getSelectedItem() != null) { - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - previewPane.setImageStyle(imageStyle); - previewPane.repaint(); - } - } - }; - - /** - * 判断是否是图片背景 - * @param background 背景 - * @return 判断是否是图片背景 - */ - public boolean accept(Background background) { - return background instanceof ImageBackground; - } - - /** - * 标题 - * @return 标题 - */ - public String title4PopupWindow() { - return Inter.getLocText("FR-Background_Image"); - } +package com.fr.design.mainframe.backgroundpane; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.design.constants.UIConstants; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.general.Background; +import com.fr.general.Inter; +import com.fr.stable.Constants; +import com.fr.stable.CoreGraphHelper; +import com.fr.design.style.background.image.ImageFileChooser; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +/** + * @author zhou + * @since 2012-5-29下午1:12:06 + */ +public class ImageBackgroundQuickPane extends BackgroundQuickPane { + + private ImagePreviewPane previewPane; + private Style imageStyle = null; + private ChangeListener changeListener = null; + private ImageFileChooser imageFileChooser; + + private UIButtonGroup imageLayoutPane; + + public ImageBackgroundQuickPane() { + this(true); + } + + public ImageBackgroundQuickPane(boolean hasImageLayout) { + this.setLayout(new BorderLayout(0, 4)); + String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; + Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; + imageLayoutPane = new UIButtonGroup(nameArray, valueArray); + imageLayoutPane.setSelectedIndex(0); + + previewPane = new ImagePreviewPane(); + JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + borderPane.setPreferredSize(new Dimension(0, 145)); + borderPane.add(previewPane, BorderLayout.CENTER); + this.add(borderPane, BorderLayout.NORTH); + previewPane.addChangeListener(imageSizeChangeListener); + + JPanel southPane = new JPanel(new BorderLayout(0, 4)); + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + contentPane.add(southPane, BorderLayout.NORTH); + this.add(contentPane, BorderLayout.CENTER); + + JPanel selectFilePane = new JPanel(new GridLayout(0, 2)); + + UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); + selectFilePane.add(new JPanel()); + selectFilePane.add(selectPictureButton); + selectPictureButton.addActionListener(selectPictureActionListener); + + if(hasImageLayout){ + southPane.add(imageLayoutPane, BorderLayout.CENTER); + } + southPane.add(selectFilePane, BorderLayout.SOUTH); + + imageLayoutPane.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + previewPane.setImageStyle(imageStyle); + previewPane.repaint(); + } + }); + } + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + if (imageFileChooser == null) { + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + + if (selectedFile != null && selectedFile.isFile()) { + Image image = BaseUtils.readImage(selectedFile.getPath()); + CoreGraphHelper.waitForImage(image); + + previewPane.setImage(image); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + previewPane.setImageStyle(imageStyle); + previewPane.repaint(); + } else { + previewPane.setImage(null); + } + fireChagneListener(); + } + + } + }; + + public void populateBean(Background background) { + + ImageBackground imageBackground = (ImageBackground) background; + imageLayoutPane.setSelectedItem((byte) imageBackground.getLayout()); + Style.DEFAULT_STYLE.deriveImageLayout(imageBackground.getLayout()); + + previewPane.setImageStyle(ImageBackgroundQuickPane.this.imageStyle); + previewPane.setImage(imageBackground.getImage()); + previewPane.repaint(); + } + + public Background updateBean() { + ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + imageBackground.setLayout(imageStyle.getImageLayout()); + return imageBackground; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + changeListener = new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }; + imageLayoutPane.addChangeListener(changeListener); + } + + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + ChangeListener imageSizeChangeListener = new ChangeListener() { + + public void stateChanged(ChangeEvent evt) { + if (imageLayoutPane.getSelectedItem() != null) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + previewPane.setImageStyle(imageStyle); + previewPane.repaint(); + } + } + }; + + /** + * 判断是否是图片背景 + * @param background 背景 + * @return 判断是否是图片背景 + */ + public boolean accept(Background background) { + return background instanceof ImageBackground; + } + + /** + * 标题 + * @return 标题 + */ + public String title4PopupWindow() { + return Inter.getLocText("FR-Background_Image"); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/NullBackgroundPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java similarity index 89% rename from designer_base/src/com/fr/design/mainframe/backgroundpane/NullBackgroundPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java index 6edd7c7fc..60d39ed2d 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/NullBackgroundPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java @@ -1,54 +1,54 @@ -package com.fr.design.mainframe.backgroundpane; - -import com.fr.design.event.UIObserverListener; -import com.fr.general.Background; -import com.fr.general.Inter; - -import java.awt.*; - -/** - * @author zhou - * @since 2012-5-29下午1:12:24 - */ -public class NullBackgroundPane extends BackgroundSettingPane { - - public Dimension getPreferredSize(){ - return new Dimension(0,0); - } - - public void populateBean(Background background) { - // do nothing. - } - - public Background updateBean() { - return null; - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - - } - - - /** - * 是否接受 - * @param background 背景 - * @return 是则返回true - */ - public boolean accept(Background background) { - return background == null; - } - - /** - * 名称 - * @return 名称 - */ - public String title4PopupWindow() { - return Inter.getLocText("Background-Null"); - } - +package com.fr.design.mainframe.backgroundpane; + +import com.fr.design.event.UIObserverListener; +import com.fr.general.Background; +import com.fr.general.Inter; + +import java.awt.*; + +/** + * @author zhou + * @since 2012-5-29下午1:12:24 + */ +public class NullBackgroundQuickPane extends BackgroundQuickPane { + + public Dimension getPreferredSize(){ + return new Dimension(0,0); + } + + public void populateBean(Background background) { + // do nothing. + } + + public Background updateBean() { + return null; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + + } + + + /** + * 是否接受 + * @param background 背景 + * @return 是则返回true + */ + public boolean accept(Background background) { + return background == null; + } + + /** + * 名称 + * @return 名称 + */ + public String title4PopupWindow() { + return Inter.getLocText("Background-Null"); + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java similarity index 92% rename from designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java index 7e3e15042..4e31405d1 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java @@ -1,211 +1,211 @@ -package com.fr.design.mainframe.backgroundpane; - -import com.fr.base.GraphHelper; -import com.fr.base.background.PatternBackground; -import com.fr.design.constants.UIConstants; -import com.fr.design.border.UIRoundedBorder; -import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Background; -import com.fr.general.Inter; -import com.fr.design.style.color.ColorSelectBox; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Rectangle2D; - -/** - * @author zhou - * @since 2012-5-29下午1:12:33 - */ -public class PatternBackgroundPane extends BackgroundSettingPane { - - private int patternIndex = 0; // pattern index. - private ColorSelectBox foregroundColorPane; - private ColorSelectBox backgroundColorPane; - private PatternButton[] patternButtonArray; - - public PatternBackgroundPane() { - this.setLayout(new BorderLayout(0, 4)); - - JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); - this.add(contentPane, BorderLayout.NORTH); - contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); - - JPanel typePane2 = new JPanel(); - contentPane.add(typePane2); - typePane2.setLayout(new GridLayout(0, 8, 1, 1)); - typePane2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); - ButtonGroup patternButtonGroup = new ButtonGroup(); - patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; - for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { - patternButtonArray[i] = new PatternButton(i); - patternButtonGroup.add(patternButtonArray[i]); - typePane2.add(patternButtonArray[i]); - } - - JPanel colorPane = new JPanel(new GridLayout(0, 2)); - foregroundColorPane = new ColorSelectBox(70); - backgroundColorPane = new ColorSelectBox(70); - foregroundColorPane.setSelectObject(Color.lightGray); - backgroundColorPane.setSelectObject(Color.black); - - colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane)); - colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane)); - this.add(colorPane, BorderLayout.CENTER); - foregroundColorPane.addSelectChangeListener(colorChangeListener); - backgroundColorPane.addSelectChangeListener(colorChangeListener); - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = 190; - return dim; - } - - private JPanel createLabelColorPane(String text, JComponent colorPane) { - JPanel labelColorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); - labelColorPane.add(new UILabel(text)); - labelColorPane.add(colorPane); - - return labelColorPane; - } - - public void populateBean(Background background) { - PatternBackground patternBackground = (PatternBackground) background; - int patternIndex = patternBackground.getPatternIndex(); - - if (patternIndex >= 0 && patternIndex < this.patternButtonArray.length) { - this.patternButtonArray[patternIndex].setSelected(true); - this.patternIndex = patternIndex; - } else { - this.patternIndex = 0; - } - - foregroundColorPane.setSelectObject(patternBackground.getForeground()); - backgroundColorPane.setSelectObject(patternBackground.getBackground()); - } - - public Background updateBean() { - return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); - } - - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - foregroundColorPane.addSelectChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - backgroundColorPane.addSelectChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - for (int i = 0, count = patternButtonArray.length; i < count; i ++) { - patternButtonArray[i].addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - } - } - - - // Foreground or Background changed. - ChangeListener colorChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent e) { - for (int i = 0; i < patternButtonArray.length; i++) { - patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); - patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); - } - - PatternBackgroundPane.this.repaint();// repaint - } - }; - - /** - * Pattern type button. - */ - class PatternButton extends JToggleButton implements ActionListener { - - public PatternButton(int pIndex) { - this.pIndex = pIndex; - this.addActionListener(this); - - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); - this.setBorder(null); - this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black); - } - - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); - - if (this.pIndex == patternIndex) {// it's selected. - g2d.setPaint(UIConstants.LINE_COLOR); - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); - } - } - - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 20); - } - - public void setPatternForeground(Color foreground) { - this.patternBackground.setForeground(foreground); - } - - public void setPatternBackground(Color background) { - this.patternBackground.setBackground(background); - } - - /** - * set Pattern index. - */ - public void actionPerformed(ActionEvent evt) { - PatternBackgroundPane.this.patternIndex = pIndex; - - fireChagneListener(); - PatternBackgroundPane.this.repaint();// repaint - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - - private int pIndex = 0; - private PatternBackground patternBackground; - } - - @Override - public boolean accept(Background background) { - return background instanceof PatternBackground; - } - - @Override - public String title4PopupWindow() { - return Inter.getLocText("Background-Pattern"); - } +package com.fr.design.mainframe.backgroundpane; + +import com.fr.base.GraphHelper; +import com.fr.base.background.PatternBackground; +import com.fr.design.constants.UIConstants; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.Inter; +import com.fr.design.style.color.ColorSelectBox; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Rectangle2D; + +/** + * @author zhou + * @since 2012-5-29下午1:12:33 + */ +public class PatternBackgroundQuickPane extends BackgroundQuickPane { + + private int patternIndex = 0; // pattern setIndex. + private ColorSelectBox foregroundColorPane; + private ColorSelectBox backgroundColorPane; + private PatternButton[] patternButtonArray; + + public PatternBackgroundQuickPane() { + this.setLayout(new BorderLayout(0, 4)); + + JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + this.add(contentPane, BorderLayout.NORTH); + contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + + JPanel typePane2 = new JPanel(); + contentPane.add(typePane2); + typePane2.setLayout(new GridLayout(0, 8, 1, 1)); + typePane2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); + ButtonGroup patternButtonGroup = new ButtonGroup(); + patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; + for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { + patternButtonArray[i] = new PatternButton(i); + patternButtonGroup.add(patternButtonArray[i]); + typePane2.add(patternButtonArray[i]); + } + + JPanel colorPane = new JPanel(new GridLayout(0, 2)); + foregroundColorPane = new ColorSelectBox(70); + backgroundColorPane = new ColorSelectBox(70); + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + + colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane)); + colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane)); + this.add(colorPane, BorderLayout.CENTER); + foregroundColorPane.addSelectChangeListener(colorChangeListener); + backgroundColorPane.addSelectChangeListener(colorChangeListener); + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = 190; + return dim; + } + + private JPanel createLabelColorPane(String text, JComponent colorPane) { + JPanel labelColorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + labelColorPane.add(new UILabel(text)); + labelColorPane.add(colorPane); + + return labelColorPane; + } + + public void populateBean(Background background) { + PatternBackground patternBackground = (PatternBackground) background; + int patternIndex = patternBackground.getPatternIndex(); + + if (patternIndex >= 0 && patternIndex < this.patternButtonArray.length) { + this.patternButtonArray[patternIndex].setSelected(true); + this.patternIndex = patternIndex; + } else { + this.patternIndex = 0; + } + + foregroundColorPane.setSelectObject(patternBackground.getForeground()); + backgroundColorPane.setSelectObject(patternBackground.getBackground()); + } + + public Background updateBean() { + return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); + } + + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + foregroundColorPane.addSelectChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + backgroundColorPane.addSelectChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + for (int i = 0, count = patternButtonArray.length; i < count; i ++) { + patternButtonArray[i].addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + } + } + + + // Foreground or Background changed. + ChangeListener colorChangeListener = new ChangeListener() { + + public void stateChanged(ChangeEvent e) { + for (int i = 0; i < patternButtonArray.length; i++) { + patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); + patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); + } + + PatternBackgroundQuickPane.this.repaint();// repaint + } + }; + + /** + * Pattern type button. + */ + class PatternButton extends JToggleButton implements ActionListener { + + public PatternButton(int pIndex) { + this.pIndex = pIndex; + this.addActionListener(this); + + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.setBorder(null); + this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black); + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + + if (this.pIndex == patternIndex) {// it's selected. + g2d.setPaint(UIConstants.LINE_COLOR); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + } + } + + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 20); + } + + public void setPatternForeground(Color foreground) { + this.patternBackground.setForeground(foreground); + } + + public void setPatternBackground(Color background) { + this.patternBackground.setBackground(background); + } + + /** + * set Pattern setIndex. + */ + public void actionPerformed(ActionEvent evt) { + PatternBackgroundQuickPane.this.patternIndex = pIndex; + + fireChagneListener(); + PatternBackgroundQuickPane.this.repaint();// repaint + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + private int pIndex = 0; + private PatternBackground patternBackground; + } + + @Override + public boolean accept(Background background) { + return background instanceof PatternBackground; + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText("Background-Pattern"); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java similarity index 94% rename from designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java index caff963d6..dcd386343 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java @@ -1,173 +1,173 @@ -package com.fr.design.mainframe.backgroundpane; - -import com.fr.base.GraphHelper; -import com.fr.base.background.TextureBackground; -import com.fr.design.constants.UIConstants; -import com.fr.design.border.UIRoundedBorder; -import com.fr.design.event.UIObserverListener; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Background; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Rectangle2D; - -public class TextureBackgroundPane extends BackgroundSettingPane { - - private TexturePaint texturePaint; - private TextureButton[] textureButtonArray; - - public TextureBackgroundPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); - JPanel contentPane = new JPanel(); - borderPane.add(contentPane, BorderLayout.NORTH); - this.add(borderPane, BorderLayout.NORTH); - contentPane.setLayout(new GridLayout(0, 8, 1, 1)); - contentPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); - borderPane.setPreferredSize(new Dimension(0, 145)); - ButtonGroup patternButtonGroup = new ButtonGroup(); - textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; - for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { - textureButtonArray[i] = new TextureButton(EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); - patternButtonGroup.add(textureButtonArray[i]); - contentPane.add(textureButtonArray[i]); - } - } - - public void populateBean(Background background) { - TextureBackground textureBackground = (TextureBackground) background; - - this.texturePaint = textureBackground.getTexturePaint(); - - - for (int i = 0; i < textureButtonArray.length; i++) { - if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { - textureButtonArray[i].setSelected(true); - break; - } - } - } - - public Background updateBean() { - if (this.texturePaint == null) { - textureButtonArray[0].doClick(); - } - return new TextureBackground(this.texturePaint); - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - for (int i = 0, count = textureButtonArray.length; i < count; i++) { - textureButtonArray[i].addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - } - } - - - /** - * Texture type button. - */ - class TextureButton extends JToggleButton implements ActionListener { - - private TexturePaint buttonTexturePaint; - - public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { - this.buttonTexturePaint = buttonTexturePaint; - this.setToolTipText(tooltip); - - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); - this.addActionListener(this); - this.setBorder(null); - } - - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - - g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); - - if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's - // selected. - g2d.setPaint(UIConstants.LINE_COLOR); - } else { - g2d.setPaint(null); - } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); - } - - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 20); - } - - public TexturePaint getTexturePaint() { - return this.buttonTexturePaint; - } - - /** - * set Pattern index. - */ - public void actionPerformed(ActionEvent evt) { - TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); - - fireChagneListener(); - TextureBackgroundPane.this.repaint(); // repaint. - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - } - - public static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{TextureBackground.NEWSPRINT_TEXTURE_PAINT, TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, - TextureBackground.PARCHMENT_TEXTURE_PAINT, TextureBackground.STATIONERY_TEXTURE_PAINT, TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, - TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, TextureBackground.GRANITE_TEXTURE_PAINT, - TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PURPLE_MESH_TEXTURE_PAINT, - TextureBackground.BOUQUET_TEXTURE_PAINT, TextureBackground.PAPYRUS_TEXTURE_PAINT, TextureBackground.CANVAS_TEXTURE_PAINT, TextureBackground.DENIM_TEXTURE_PAINT, - TextureBackground.WOVEN_MAT_TEXTURE_PAINT, TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, TextureBackground.PAPER_BAG_TEXTURE_PAINT, TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, - TextureBackground.SAND_TEXTURE_PAINT, TextureBackground.CORK_TEXTURE_PAINT, TextureBackground.WALNUT_TEXTURE_PAINT, TextureBackground.OAK_TEXTURE_PAINT, - TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; - private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{Inter.getLocText("BackgroundTexture-Newsprint"), Inter.getLocText("BackgroundTexture-RecycledPaper"), - Inter.getLocText("BackgroundTexture-Parchment"), Inter.getLocText("BackgroundTexture-Stationery"), Inter.getLocText("BackgroundTexture-GreenMarble"), - Inter.getLocText("BackgroundTexture-WhiteMarble"), Inter.getLocText("BackgroundTexture-BrownMarble"), Inter.getLocText("BackgroundTexture-Granite"), - Inter.getLocText("BackgroundTexture-BlueTissuePaper"), Inter.getLocText("BackgroundTexture-PinkTissuePaper"), Inter.getLocText("BackgroundTexture-PurpleMesh"), - Inter.getLocText("BackgroundTexture-Bouquet"), Inter.getLocText("BackgroundTexture-Papyrus"), Inter.getLocText("BackgroundTexture-Canvas"), - Inter.getLocText("BackgroundTexture-Denim"), Inter.getLocText("BackgroundTexture-WovenMat"), Inter.getLocText("BackgroundTexture-WaterDroplets"), - Inter.getLocText("BackgroundTexture-PaperBag"), Inter.getLocText("BackgroundTexture-FishFossil"), Inter.getLocText("BackgroundTexture-Sand"), - Inter.getLocText("BackgroundTexture-Cork"), Inter.getLocText("BackgroundTexture-Walnut"), Inter.getLocText("BackgroundTexture-Oak"), - Inter.getLocText("BackgroundTexture-MediumWood")}; - - @Override - public boolean accept(Background background) { - return background instanceof TextureBackground; - } - - @Override - public String title4PopupWindow() { - return Inter.getLocText("Background-Texture"); - } +package com.fr.design.mainframe.backgroundpane; + +import com.fr.base.GraphHelper; +import com.fr.base.background.TextureBackground; +import com.fr.design.constants.UIConstants; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.event.UIObserverListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Rectangle2D; + +public class TextureBackgroundQuickPane extends BackgroundQuickPane { + + private TexturePaint texturePaint; + private TextureButton[] textureButtonArray; + + public TextureBackgroundQuickPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + JPanel contentPane = new JPanel(); + borderPane.add(contentPane, BorderLayout.NORTH); + this.add(borderPane, BorderLayout.NORTH); + contentPane.setLayout(new GridLayout(0, 8, 1, 1)); + contentPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); + borderPane.setPreferredSize(new Dimension(0, 145)); + ButtonGroup patternButtonGroup = new ButtonGroup(); + textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; + for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { + textureButtonArray[i] = new TextureButton(EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); + patternButtonGroup.add(textureButtonArray[i]); + contentPane.add(textureButtonArray[i]); + } + } + + public void populateBean(Background background) { + TextureBackground textureBackground = (TextureBackground) background; + + this.texturePaint = textureBackground.getTexturePaint(); + + + for (int i = 0; i < textureButtonArray.length; i++) { + if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { + textureButtonArray[i].setSelected(true); + break; + } + } + } + + public Background updateBean() { + if (this.texturePaint == null) { + textureButtonArray[0].doClick(); + } + return new TextureBackground(this.texturePaint); + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + for (int i = 0, count = textureButtonArray.length; i < count; i++) { + textureButtonArray[i].addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + } + } + + + /** + * Texture type button. + */ + class TextureButton extends JToggleButton implements ActionListener { + + private TexturePaint buttonTexturePaint; + + public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { + this.buttonTexturePaint = buttonTexturePaint; + this.setToolTipText(tooltip); + + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.addActionListener(this); + this.setBorder(null); + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + + g2d.setPaint(this.buttonTexturePaint); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + + if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's + // selected. + g2d.setPaint(UIConstants.LINE_COLOR); + } else { + g2d.setPaint(null); + } + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + } + + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 20); + } + + public TexturePaint getTexturePaint() { + return this.buttonTexturePaint; + } + + /** + * set Pattern setIndex. + */ + public void actionPerformed(ActionEvent evt) { + TextureBackgroundQuickPane.this.texturePaint = this.getTexturePaint(); + + fireChagneListener(); + TextureBackgroundQuickPane.this.repaint(); // repaint. + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + } + + public static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{TextureBackground.NEWSPRINT_TEXTURE_PAINT, TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, + TextureBackground.PARCHMENT_TEXTURE_PAINT, TextureBackground.STATIONERY_TEXTURE_PAINT, TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, + TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, TextureBackground.GRANITE_TEXTURE_PAINT, + TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PURPLE_MESH_TEXTURE_PAINT, + TextureBackground.BOUQUET_TEXTURE_PAINT, TextureBackground.PAPYRUS_TEXTURE_PAINT, TextureBackground.CANVAS_TEXTURE_PAINT, TextureBackground.DENIM_TEXTURE_PAINT, + TextureBackground.WOVEN_MAT_TEXTURE_PAINT, TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, TextureBackground.PAPER_BAG_TEXTURE_PAINT, TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, + TextureBackground.SAND_TEXTURE_PAINT, TextureBackground.CORK_TEXTURE_PAINT, TextureBackground.WALNUT_TEXTURE_PAINT, TextureBackground.OAK_TEXTURE_PAINT, + TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; + private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{Inter.getLocText("BackgroundTexture-Newsprint"), Inter.getLocText("BackgroundTexture-RecycledPaper"), + Inter.getLocText("BackgroundTexture-Parchment"), Inter.getLocText("BackgroundTexture-Stationery"), Inter.getLocText("BackgroundTexture-GreenMarble"), + Inter.getLocText("BackgroundTexture-WhiteMarble"), Inter.getLocText("BackgroundTexture-BrownMarble"), Inter.getLocText("BackgroundTexture-Granite"), + Inter.getLocText("BackgroundTexture-BlueTissuePaper"), Inter.getLocText("BackgroundTexture-PinkTissuePaper"), Inter.getLocText("BackgroundTexture-PurpleMesh"), + Inter.getLocText("BackgroundTexture-Bouquet"), Inter.getLocText("BackgroundTexture-Papyrus"), Inter.getLocText("BackgroundTexture-Canvas"), + Inter.getLocText("BackgroundTexture-Denim"), Inter.getLocText("BackgroundTexture-WovenMat"), Inter.getLocText("BackgroundTexture-WaterDroplets"), + Inter.getLocText("BackgroundTexture-PaperBag"), Inter.getLocText("BackgroundTexture-FishFossil"), Inter.getLocText("BackgroundTexture-Sand"), + Inter.getLocText("BackgroundTexture-Cork"), Inter.getLocText("BackgroundTexture-Walnut"), Inter.getLocText("BackgroundTexture-Oak"), + Inter.getLocText("BackgroundTexture-MediumWood")}; + + @Override + public boolean accept(Background background) { + return background instanceof TextureBackground; + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText("Background-Texture"); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/AbstractPopBox.java b/designer_base/src/com/fr/design/style/AbstractPopBox.java index a9001b6b5..4630c51ae 100644 --- a/designer_base/src/com/fr/design/style/AbstractPopBox.java +++ b/designer_base/src/com/fr/design/style/AbstractPopBox.java @@ -2,7 +2,7 @@ package com.fr.design.style; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.style.background.BackgroundJComponent; -import com.fr.design.style.background.gradient.GradientPane; +import com.fr.design.style.background.gradient.GradientBackgroundPane; import com.fr.general.Background; import javax.swing.*; @@ -96,8 +96,8 @@ public abstract class AbstractPopBox extends JPanel { mouseClick(evt); } }; - if (!this.isWindowEventInit && SwingUtilities.getAncestorOfClass(GradientPane.class, this) != null) { - SwingUtilities.getAncestorOfClass(GradientPane.class, this).addMouseListener(parentMouseListener); + if (!this.isWindowEventInit && SwingUtilities.getAncestorOfClass(GradientBackgroundPane.class, this) != null) { + SwingUtilities.getAncestorOfClass(GradientBackgroundPane.class, this).addMouseListener(parentMouseListener); this.isWindowEventInit = true; } } diff --git a/designer_base/src/com/fr/design/style/background/BackgroundDetailPane.java b/designer_base/src/com/fr/design/style/background/BackgroundDetailPane.java new file mode 100644 index 000000000..694f2c8c1 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/BackgroundDetailPane.java @@ -0,0 +1,18 @@ +package com.fr.design.style.background; + +import com.fr.general.Background; + +import javax.swing.*; +import javax.swing.event.ChangeListener; + +/** + * Created by richie on 16/5/18. + */ +public abstract class BackgroundDetailPane extends JPanel { + + public abstract void populate(Background background); + + public abstract Background update() throws Exception; + + public abstract void addChangeListener(ChangeListener changeListener); +} diff --git a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java new file mode 100644 index 000000000..c41639c8a --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java @@ -0,0 +1,121 @@ +package com.fr.design.style.background; + + +import com.fr.base.background.*; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.BackgroundUIProvider; +import com.fr.design.style.background.gradient.GradientBackgroundPane; +import com.fr.design.style.background.impl.*; +import com.fr.general.Background; +import com.fr.general.Inter; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Created by richie on 16/5/18. + */ +public class BackgroundFactory { + + private static Map, BackgroundUIWrapper> map = new HashMap<>(); + private static Map, BackgroundUIWrapper> browser = new HashMap<>(); + + static { + registerUniversal(map); + registerImageBackground(map); + registerUniversal(browser); + registerBrowserImageBackground(browser); + registerExtra(map); + registerExtra(browser); + } + + private static void registerUniversal(Map, BackgroundUIWrapper> map) { + map.put(null, BackgroundUIWrapper.create() + .setType(NullBackgroundPane.class).setTitle(Inter.getLocText("Background-Null"))); + map.put(ColorBackground.class, BackgroundUIWrapper.create() + .setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("Color"))); + map.put(TextureBackground.class, BackgroundUIWrapper.create() + .setType(TextureBackgroundPane.class).setTitle(Inter.getLocText("Background-Texture"))); + map.put(PatternBackground.class, BackgroundUIWrapper.create() + .setType(PatternBackgroundPane.class).setTitle(Inter.getLocText("Background-Pattern"))); + map.put(GradientBackground.class, BackgroundUIWrapper.create() + .setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("Gradient-Color"))); + } + + private static void registerImageBackground(Map, BackgroundUIWrapper> map) { + map.put(ImageBackground.class, BackgroundUIWrapper.create() + .setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("Image"))); + } + + private static void registerBrowserImageBackground(Map, BackgroundUIWrapper> map) { + map.put(ImageBackground.class, BackgroundUIWrapper.create() + .setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("Image"))); + } + + private static void registerExtra(Map, BackgroundUIWrapper> map) { + for (BackgroundUIProvider provider : ExtraDesignClassManager.getInstance().getBackgroundUIProviders()) { + map.put(provider.targetClass(), BackgroundUIWrapper.create() + .setType(provider.targetUIClass()).setTitle(provider.targetTitle())); + } + } + + + public static Set> kindsOfKey() { + return map.keySet(); + } + + public static BackgroundUIWrapper getWrapper(Class category) { + return map.get(category); + } + + public static BackgroundDetailPane createIfAbsent(Class category) { + BackgroundUIWrapper wrapper = map.get(category); + return createByWrapper(wrapper); + } + + public static BackgroundDetailPane createIfAbsent(int index) { + for (BackgroundUIWrapper wrapper : map.values()) { + if (wrapper.getIndex() == index) { + return createByWrapper(wrapper); + } + } + return new NullBackgroundPane(); + } + + public static Set> browserKindsOfKey() { + return browser.keySet(); + } + + public static BackgroundUIWrapper getBrosweWrapper(Class category) { + return browser.get(category); + } + + public static BackgroundDetailPane createBrowserIfAbsent(Class category) { + BackgroundUIWrapper wrapper = browser.get(category); + return createByWrapper(wrapper); + } + + public static BackgroundDetailPane createBrowerIfAbsent(int index) { + for (BackgroundUIWrapper wrapper : browser.values()) { + if (wrapper.getIndex() == index) { + return createByWrapper(wrapper); + } + } + return new NullBackgroundPane(); + } + + private static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) { + Class clazz = wrapper.getType(); + if (clazz == null) { + clazz = NullBackgroundPane.class; + } + BackgroundDetailPane quickPane; + try { + quickPane = clazz.newInstance(); + } catch (Exception e) { + quickPane = new NullBackgroundPane(); + } + return quickPane; + } +} diff --git a/designer_base/src/com/fr/design/style/background/BackgroundPane.java b/designer_base/src/com/fr/design/style/background/BackgroundPane.java index 679a9a4a1..6a9c3d70f 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundPane.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundPane.java @@ -4,87 +4,32 @@ package com.fr.design.style.background; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GridLayout; -import java.awt.Image; -import java.awt.LayoutManager; -import java.awt.TexturePaint; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Rectangle2D; -import java.io.File; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.ButtonGroup; -import javax.swing.JFileChooser; +import java.util.HashMap; +import java.util.Map; import com.fr.design.gui.frpane.UITabbedPane; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JToggleButton; -import javax.swing.SwingConstants; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.base.GraphHelper; -import com.fr.base.Style; -import com.fr.base.background.ColorBackground; -import com.fr.base.background.GradientBackground; -import com.fr.base.background.ImageBackground; -import com.fr.base.background.PatternBackground; -import com.fr.base.background.TextureBackground; -import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.dialog.BasicPane; import com.fr.general.Background; -import com.fr.general.ComparatorUtils; +import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; -import com.fr.design.style.background.gradient.GradientPane; -import com.fr.design.style.background.image.ImageFileChooser; -import com.fr.design.style.background.image.ImagePreviewPane; -import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.style.color.DetailColorSelectPane; -import com.fr.design.utils.gui.GUICoreUtils; public class BackgroundPane extends BasicPane { - private static final int BACKGROUND_NULL = 0; - private static final int BACKGROUND_COLOR = 1; - private static final int BACKGROUND_TEXTURE = 2; - private static final int BACKGROUND_PATTERN = 3; - private static final int BACKGROUND_IMAGE = 4; - private static final int BACKGROUND_GRADIENT_COLOR = 5; - private UITabbedPane tabbedPane = null; - private NullBackgroundPane nullBackgroundPane = null; - private ColorBackgroundPane colorBackgroundPane = null; - private TextureBackgroundPane textureBackgroundPane = null; - private PatternBackgroundPane patternBackgroundPane = null; - private ImageBackgroundPane imageBackgroundPane = null; - private GradientPane gradientPane = null; + protected UITabbedPane tabbedPane = null; + private EventListenerList eventChangeList = new EventListenerList(); - private static boolean isBrowserBackgroundPane; + protected Map cacheMap = new HashMap<>(); - public BackgroundPane(){ - this(false); - } //需求说: 如果是浏览器背景, 隐藏掉几个button - public BackgroundPane(boolean isBrowserBackgroundPane) { - BackgroundPane.isBrowserBackgroundPane = isBrowserBackgroundPane; + public BackgroundPane() { this.initComponents(); this.setPreferredSize(new Dimension(400, 300)); } @@ -103,16 +48,21 @@ public class BackgroundPane extends BasicPane { tabbedPane = new UITabbedPane(); this.add(tabbedPane, BorderLayout.CENTER); - tabbedPane.addTab(Inter.getLocText("Background-Null"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); - tabbedPane.addTab(Inter.getLocText("Color"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); - tabbedPane.addTab(Inter.getLocText("Background-Texture"),FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); - tabbedPane.addTab(Inter.getLocText("Background-Pattern"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); - tabbedPane.addTab(Inter.getLocText("Image"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); - tabbedPane.addTab(Inter.getLocText("Gradient-Color"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + initTabPane(); + tabbedPane.addChangeListener(backgroundChangeListener); tabbedPane.setPreferredSize(new Dimension(200, 210)); } + protected void initTabPane() { + int index = 0; + for (Class key : BackgroundFactory.kindsOfKey()) { + BackgroundUIWrapper wrapper = BackgroundFactory.getWrapper(key); + wrapper.setIndex(index++); + tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + } + } + public void addChangeListener(ChangeListener changeListener) { eventChangeList.add(ChangeListener.class, changeListener); } @@ -138,86 +88,39 @@ public class BackgroundPane extends BasicPane { return Inter.getLocText("Background"); } - private NullBackgroundPane getNullBackgroundPane() { - if (this.nullBackgroundPane == null) { - this.nullBackgroundPane = new NullBackgroundPane(); - nullBackgroundPane.addChangeListener(backgroundChangeListener); - } - return this.nullBackgroundPane; - } - private ColorBackgroundPane getColorBackgroundPane() { - if (this.colorBackgroundPane == null) { - this.colorBackgroundPane = new ColorBackgroundPane(); - colorBackgroundPane.addChangeListener(backgroundChangeListener); + protected BackgroundDetailPane getTabItemPane(Background background, int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = BackgroundFactory.createIfAbsent(background == null ? null : background.getClass()); + quickPane.addChangeListener(backgroundChangeListener); + cacheMap.put(index, quickPane); } - return this.colorBackgroundPane; + tabbedPane.setComponentAt(index, quickPane); + tabbedPane.setSelectedIndex(index); + return quickPane; } - private TextureBackgroundPane getTextureBackgroundPane() { - if (this.textureBackgroundPane == null) { - this.textureBackgroundPane = new TextureBackgroundPane(); - textureBackgroundPane.addChangeListener(backgroundChangeListener); + protected BackgroundDetailPane getTabItemPaneByIndex(int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = BackgroundFactory.createIfAbsent(index); + tabbedPane.setComponentAt(index, quickPane); + cacheMap.put(index, quickPane); + quickPane.addChangeListener(backgroundChangeListener); } - return this.textureBackgroundPane; + return quickPane; } - private PatternBackgroundPane getPatternBackgroundPane() { - if (this.patternBackgroundPane == null) { - this.patternBackgroundPane = new PatternBackgroundPane(); - patternBackgroundPane.addChangeListener(backgroundChangeListener); - } - return this.patternBackgroundPane; - } - - private ImageBackgroundPane getImageBackgroundPane() { - if (this.imageBackgroundPane == null) { - this.imageBackgroundPane = new ImageBackgroundPane(); - imageBackgroundPane.addChangeListener(backgroundChangeListener); - } - return this.imageBackgroundPane; - } - - private GradientPane getGradientPane() { - if (this.gradientPane == null) { - this.gradientPane = new GradientPane(); - gradientPane.addChangeListener(backgroundChangeListener); - } - - return this.gradientPane; - } /** * Populate background. */ public void populate(Background background) { - if (background == null) { - tabbedPane.setComponentAt(0, this.getNullBackgroundPane()); - tabbedPane.setSelectedIndex(0); - nullBackgroundPane.populate(background); - } else { - if (background instanceof ColorBackground) { - tabbedPane.setComponentAt(1, this.getColorBackgroundPane()); - tabbedPane.setSelectedIndex(1); - colorBackgroundPane.populate(background); - } else if (background instanceof TextureBackground) { - tabbedPane.setComponentAt(2, this.getTextureBackgroundPane()); - tabbedPane.setSelectedIndex(2); - textureBackgroundPane.populate(background); - } else if (background instanceof PatternBackground) { - tabbedPane.setComponentAt(3, this.getPatternBackgroundPane()); - tabbedPane.setSelectedIndex(3); - patternBackgroundPane.populate(background); - } else if (background instanceof ImageBackground) { - tabbedPane.setComponentAt(4, this.getImageBackgroundPane()); - tabbedPane.setSelectedIndex(4); - imageBackgroundPane.populate(background); - } else if (background instanceof GradientBackground) { - tabbedPane.setComponentAt(5, this.getGradientPane()); - tabbedPane.setSelectedIndex(5); - gradientPane.populate(background); - } - } + BackgroundUIWrapper wrapper = BackgroundFactory.getWrapper(background == null ? null : background.getClass()); + int index = wrapper.getIndex(); + BackgroundDetailPane quickPane = getTabItemPane(background, index); + quickPane.populate(background); tabbedPane.doLayout(); tabbedPane.validate(); @@ -227,42 +130,19 @@ public class BackgroundPane extends BasicPane { * Update background. */ public Background update() { + int index = tabbedPane.getSelectedIndex(); + BackgroundDetailPane quickPane = getTabItemPaneByIndex(index); try { - Component selectComponent = tabbedPane.getSelectedComponent(); - if (selectComponent.getClass() == JPanel.class) {//需要初始化. - int selectedIndex = tabbedPane.getSelectedIndex(); - if (selectedIndex == BACKGROUND_NULL) { - selectComponent = this.getNullBackgroundPane(); - } else if (selectedIndex == BACKGROUND_COLOR) { - selectComponent = this.getColorBackgroundPane(); - } else if (selectedIndex == BACKGROUND_TEXTURE) { - selectComponent = this.getTextureBackgroundPane(); - } else if (selectedIndex == BACKGROUND_PATTERN) { - selectComponent = this.getPatternBackgroundPane(); - } else if (selectedIndex == BACKGROUND_IMAGE) { - selectComponent = this.getImageBackgroundPane(); - } else if (selectedIndex == BACKGROUND_GRADIENT_COLOR) { - selectComponent = this.getGradientPane(); - } - - tabbedPane.setComponentAt(selectedIndex, selectComponent); - } - - if (selectComponent instanceof BackgroundSettingPane) { - return ((BackgroundSettingPane) selectComponent).update(); - } else if (selectComponent instanceof GradientPane) { - return ((GradientPane) selectComponent).update(); - } + return quickPane.update(); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FRLogger.getLogger().error(e.getMessage(), e); } - return null; } /** * Change listener. */ - private ChangeListener backgroundChangeListener = new ChangeListener() { + protected ChangeListener backgroundChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent evt) { previewPane.setBackgroundObject(update()); @@ -271,687 +151,4 @@ public class BackgroundPane extends BasicPane { }; private BackgroundPreviewLabel previewPane = null; - public static abstract class BackgroundSettingPane extends JPanel { - - public abstract void populate(Background background); - - public abstract Background update() throws Exception; - - public abstract void addChangeListener(ChangeListener changeListener); - } - - /** - * Null background pane. - */ - private static class NullBackgroundPane extends BackgroundSettingPane { - - public NullBackgroundPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - UILabel centerLabel = new UILabel( - Inter.getLocText("Background-Background_is_NULL") + "..."); - this.add(centerLabel); - centerLabel.setHorizontalAlignment(SwingConstants.CENTER); - centerLabel.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); - } - - public void populate(Background background) { - // do nothing. - } - - public Background update() throws Exception { - return null; - } - - public void addChangeListener(ChangeListener changeListener) { - // do nothing. - } - } - - /** - * Color background pane. - */ - private static class ColorBackgroundPane extends BackgroundSettingPane { - - private DetailColorSelectPane detailColorSelectPane; - - public ColorBackgroundPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - detailColorSelectPane = new DetailColorSelectPane(); - this.add(detailColorSelectPane, BorderLayout.CENTER); - } - - public void populate(Background background) { - if (background instanceof ColorBackground) { - ColorBackground colorBackgroud = (ColorBackground) background; - this.detailColorSelectPane.populate(colorBackgroud.getColor()); - } else { - this.detailColorSelectPane.populate(Color.white); - } - } - - public Background update() throws Exception { - return ColorBackground.getInstance(this.detailColorSelectPane.update()); - } - - public void addChangeListener(ChangeListener changeListener) { - detailColorSelectPane.addChangeListener(changeListener); - } - } - - private static abstract class BPane extends BackgroundSettingPane { - BPane(int nColumn) { - this.initComponents(nColumn); - } - - private void initComponents(int nColumn) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); - - JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); - this.add(contentPane, BorderLayout.NORTH); -// contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); - - // type type. - - JPanel typePane=FRGUIPaneFactory.createTitledBorderPane(titleOfTypePane()); - contentPane.add(typePane); - JPanel typePane2 = new JPanel(); - typePane.add(typePane2); - typePane2.setLayout(layoutOfTypePane(nColumn)); - setChildrenOfTypePane(typePane2); - - setChildrenOfContentPane(contentPane); - } - - protected abstract String titleOfTypePane(); - protected abstract LayoutManager layoutOfTypePane(int nColumn); - protected abstract void setChildrenOfTypePane(JPanel typePane2); - protected void setChildrenOfContentPane(JPanel contentPane) {} - } - - /** - * Texture background pane. TODO kunsnat: 拆出去. 真特么的长.. - */ - public static class TextureBackgroundPane extends BPane { - - private TexturePaint texturePaint; - private TextureButton[] textureButtonArray; - - public TextureBackgroundPane() { - super(8);// 默认的. - } - - public TextureBackgroundPane(int colum) { - super(colum);// 自定义的. - } - - protected LayoutManager layoutOfTypePane(int nColumn) { - return FRGUIPaneFactory.createNColumnGridLayout(nColumn); - } - - protected String titleOfTypePane() { - return Inter.getLocText("Background-Texture"); - } - protected void setChildrenOfTypePane(JPanel typePane2) { - ButtonGroup patternButtonGroup = new ButtonGroup(); - textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; - for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { - textureButtonArray[i] = new TextureButton( - EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); - patternButtonGroup.add(textureButtonArray[i]); - typePane2.add(textureButtonArray[i]); - } - } - - public void populate(Background background) { - if (background instanceof TextureBackground) { - TextureBackground textureBackground = (TextureBackground) background; - - this.texturePaint = textureBackground.getTexturePaint(); - - for (int i = 0; i < textureButtonArray.length; i++) { - if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { - textureButtonArray[i].setSelected(true); - break; - } - } - } else { - this.textureButtonArray[0].setSelected(true); - this.texturePaint = textureButtonArray[0].getTexturePaint(); - } - } - - public Background update() throws Exception { - return new TextureBackground(this.texturePaint); - } - - public void addChangeListener(ChangeListener changeListener) { - for (int i = 0; i < this.textureButtonArray.length; i++) { - this.textureButtonArray[i].addChangeListener(changeListener); - } - } - - /** - * Texture type button. - */ - class TextureButton extends JToggleButton implements ActionListener { - - private TexturePaint buttonTexturePaint; - - public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { - this.buttonTexturePaint = buttonTexturePaint; - this.setToolTipText(tooltip); - - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); - this.addActionListener(this); - this.setBorder(null); - } - - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - - g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); - - if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's - // selected. - g2d.setPaint(Color.black); - } else { - g2d.setPaint(Color.gray); - } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); - } - - public Dimension getPreferredSize() { - return new Dimension(36, 32); - } - - public TexturePaint getTexturePaint() { - return this.buttonTexturePaint; - } - - /** - * set Pattern index. - */ - public void actionPerformed(ActionEvent evt) { - TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); - - fireChagneListener(); - TextureBackgroundPane.this.repaint(); // repaint. - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - } - } - - public static class PatternBackgroundPaneNoFore extends PatternBackgroundPane { - - public PatternBackgroundPaneNoFore(int nColumn) { - super(nColumn); - } - - // 重载 不加载两个前后按钮 - protected void setChildrenOfContentPane(JPanel contentPane) { - foregroundColorPane = new ColorSelectBox(80); - backgroundColorPane = new ColorSelectBox(80); - foregroundColorPane.setSelectObject(Color.lightGray); - backgroundColorPane.setSelectObject(Color.black); - } - } - - /** - * Pattern background pane. - */ - public static class PatternBackgroundPane extends BPane { - - private int patternIndex = 0; // pattern index. - protected ColorSelectBox foregroundColorPane; - protected ColorSelectBox backgroundColorPane; - private PatternButton[] patternButtonArray; - - public PatternBackgroundPane() { - super(12); - - foregroundColorPane.addSelectChangeListener(colorChangeListener); - backgroundColorPane.addSelectChangeListener(colorChangeListener); - } - - public PatternBackgroundPane(int nColumn) { - super(nColumn); - - if(foregroundColorPane != null) { - foregroundColorPane.addSelectChangeListener(colorChangeListener); - } - if(backgroundColorPane != null) { - backgroundColorPane.addSelectChangeListener(colorChangeListener); - } - } - - protected String titleOfTypePane() { - return Inter.getLocText("Background-Pattern"); - } - protected LayoutManager layoutOfTypePane(int nColumn) { - return FRGUIPaneFactory.createNColumnGridLayout(nColumn); - } - - protected void setChildrenOfTypePane(JPanel typePane2) { - ButtonGroup patternButtonGroup = new ButtonGroup(); - patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; - for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { - patternButtonArray[i] = new PatternButton(i); - patternButtonGroup.add(patternButtonArray[i]); - typePane2.add(patternButtonArray[i]); - } - } - - protected void setChildrenOfContentPane(JPanel contentPane) { - // colors - JPanel colorPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Colors")); - contentPane.add(colorPane); - - foregroundColorPane = new ColorSelectBox(80); - backgroundColorPane = new ColorSelectBox(80); - foregroundColorPane.setSelectObject(Color.lightGray); - backgroundColorPane.setSelectObject(Color.black); - - colorPane.add(Box.createHorizontalStrut(2)); - colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") - + ":", foregroundColorPane)); - - colorPane.add(Box.createHorizontalStrut(8)); - - colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") - + ":", backgroundColorPane)); - } - - private JPanel createLabelColorPane(String text, - ColorSelectBox colorPane) { - JPanel labelColorPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - labelColorPane.add(new UILabel(text)); - labelColorPane.add(colorPane); - - return labelColorPane; - } - - public void populate(Background background) { - if (background != null && background instanceof PatternBackground) { - PatternBackground patternBackground = (PatternBackground) background; - int patternIndex = patternBackground.getPatternIndex(); - - if (patternIndex >= 0 - && patternIndex < this.patternButtonArray.length) { - this.patternButtonArray[patternIndex].setSelected(true); - this.patternIndex = patternIndex; - } else { - this.patternIndex = 0; - } - - foregroundColorPane.setSelectObject(patternBackground.getForeground()); - backgroundColorPane.setSelectObject(patternBackground.getBackground()); - } else { - patternIndex = 0; - this.patternButtonArray[0].setSelected(true); - - foregroundColorPane.setSelectObject(Color.lightGray); - backgroundColorPane.setSelectObject(Color.black); - } - } - - public Background update() throws Exception { - return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); - } - - public void addChangeListener(ChangeListener changeListener) { - foregroundColorPane.addSelectChangeListener(changeListener); - backgroundColorPane.addSelectChangeListener(changeListener); - - for (int i = 0; i < this.patternButtonArray.length; i++) { - this.patternButtonArray[i].addChangeListener(changeListener); - } - } - // Foreground or Background changed. - ChangeListener colorChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent e) { - for (int i = 0; i < patternButtonArray.length; i++) { - patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); - patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); - } - - PatternBackgroundPane.this.repaint();// repaint - } - }; - - /** - * Pattern type button. - */ - class PatternButton extends JToggleButton implements ActionListener { - - public PatternButton(int pIndex) { - this.pIndex = pIndex; - this.addActionListener(this); - - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); - this.setBorder(null); - this.patternBackground = new PatternBackground(this.pIndex, - Color.lightGray, Color.black); - } - - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, - d.width - 1, d.height - 1)); - - if (this.pIndex == patternIndex) {// it's selected. - g2d.setPaint(new Color(255, 51, 0)); - } else { - g2d.setPaint(Color.gray); - } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); - } - - public Dimension getPreferredSize() { - return new Dimension(24, 24); - } - - public void setPatternForeground(Color foreground) { - this.patternBackground.setForeground(foreground); - } - - public void setPatternBackground(Color background) { - this.patternBackground.setBackground(background); - } - - /** - * set Pattern index. - */ - public void actionPerformed(ActionEvent evt) { - PatternBackgroundPane.this.patternIndex = pIndex; - - fireChagneListener(); - PatternBackgroundPane.this.repaint();// repaint - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - private int pIndex = 0; - private PatternBackground patternBackground; - } - } - - /** - * Image background pane. - */ - private static class ImageBackgroundPane extends BackgroundSettingPane { - - private ImagePreviewPane previewPane = null; - private Style imageStyle = null; - private ChangeListener changeListener = null; - private ImageFileChooser imageFileChooser = null; - private UILabel imageSizeLabel = new UILabel(); - - private JRadioButton defaultRadioButton = null; - private JRadioButton tiledRadioButton = null; - private JRadioButton extendRadioButton = null; - private JRadioButton adjustRadioButton = null; - - public ImageBackgroundPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - // preview pane - JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - this.add(previewContainerPane, BorderLayout.CENTER); - - JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preview")); - previewOwnerPane.setLayout(new BorderLayout()); - previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); - - - previewPane = new ImagePreviewPane(); - previewOwnerPane.add(new JScrollPane(previewPane)); - previewPane.addChangeListener(imageSizeChangeListener); - - JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - previewContainerPane.add(selectFilePane, BorderLayout.EAST); - selectFilePane.setBorder(BorderFactory.createEmptyBorder(8, 2, 4, 0)); - - UIButton selectPictureButton = new UIButton( - Inter.getLocText("Image-Select_Picture")); - selectFilePane.add(selectPictureButton, BorderLayout.NORTH); - selectPictureButton.setMnemonic('S'); - selectPictureButton.addActionListener(selectPictureActionListener); - JPanel layoutPane=FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); - selectFilePane.add(layoutPane, BorderLayout.CENTER); - - //布局 - defaultRadioButton = new UIRadioButton(Inter.getLocText("Default")); - tiledRadioButton = new UIRadioButton(Inter.getLocText("Image-Titled")); - extendRadioButton = new UIRadioButton(Inter.getLocText("Image-Extend")); - adjustRadioButton = new UIRadioButton(Inter.getLocText("Image-Adjust")); - - defaultRadioButton.addActionListener(layoutActionListener); - tiledRadioButton.addActionListener(layoutActionListener); - extendRadioButton.addActionListener(layoutActionListener); - adjustRadioButton.addActionListener(layoutActionListener); - - JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15)); - jp.add(defaultRadioButton); - jp.add(tiledRadioButton); - if(!isBrowserBackgroundPane){ - jp.add(extendRadioButton); - jp.add(adjustRadioButton); - } - layoutPane.add(jp); - - ButtonGroup layoutBG = new ButtonGroup(); - layoutBG.add(defaultRadioButton); - layoutBG.add(tiledRadioButton); - layoutBG.add(extendRadioButton); - layoutBG.add(adjustRadioButton); - - defaultRadioButton.setSelected(true); - - // init image file chooser. - imageFileChooser = new ImageFileChooser(); - imageFileChooser.setMultiSelectionEnabled(false); - } - /** - * Select picture. - */ - ActionListener selectPictureActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - int returnVal = imageFileChooser.showOpenDialog(ImageBackgroundPane.this); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - - previewPane.setImage(image); - setImageStyle(); - previewPane.setImageStyle(imageStyle); - previewPane.repaint(); - } else { - previewPane.setImage(null); - } - } - - fireChagneListener(); - } - }; - - private void setImageStyle(){ - if(tiledRadioButton.isSelected()){ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); - }else if(adjustRadioButton.isSelected()){ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); - }else if(extendRadioButton.isSelected()){ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); - }else{ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); - } - } - - ActionListener layoutActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - setImageStyle(); - changeImageStyle(); - } - - private void changeImageStyle() { - previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); - previewPane.repaint(); - } - }; - - public void populate(Background background) { - - if (background instanceof ImageBackground) { - ImageBackground imageBackground = (ImageBackground) background; - - if (imageBackground.getLayout() == Constants.IMAGE_CENTER) { - defaultRadioButton.setSelected(true); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); - }else if(imageBackground.getLayout() == Constants.IMAGE_EXTEND){ - extendRadioButton.setSelected(true); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); - }else if(imageBackground.getLayout() == Constants.IMAGE_ADJUST){ - adjustRadioButton.setSelected(true); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); - }else { - tiledRadioButton.setSelected(true); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); - } - - previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); - if (imageBackground.getImage() != null) { - previewPane.setImage(imageBackground.getImage()); - imageSizeLabel.setText(previewPane.getImage().getWidth(null) - + " X " + previewPane.getImage().getHeight(null)); - } - - if (imageBackground.getImage() != null) { - previewPane.setImage(imageBackground.getImage()); - } - } else { - previewPane.setImage(null); - tiledRadioButton.setSelected(true); - - imageSizeLabel.setText(""); - } - - fireChagneListener(); - } - - public Background update() throws Exception { - ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); - setImageStyle(); - imageBackground.setLayout(imageStyle.getImageLayout()); - return imageBackground; - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - ChangeListener imageSizeChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent evt) { - Image image = ((ImagePreviewPane) evt.getSource()).getImage(); - - if (image == null) { - imageSizeLabel.setText(""); - } else { - imageSizeLabel.setText(Inter.getLocText(new String[] {"Size", "px"}, new String[] {": " + image.getWidth(null) + "x" + image.getHeight(null)})); - } - } - }; - } - - public static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{ - TextureBackground.NEWSPRINT_TEXTURE_PAINT, - TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, - TextureBackground.PARCHMENT_TEXTURE_PAINT, - TextureBackground.STATIONERY_TEXTURE_PAINT, - TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, - TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, - TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, - TextureBackground.GRANITE_TEXTURE_PAINT, - TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, - TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, - TextureBackground.PURPLE_MESH_TEXTURE_PAINT, - TextureBackground.BOUQUET_TEXTURE_PAINT, - TextureBackground.PAPYRUS_TEXTURE_PAINT, - TextureBackground.CANVAS_TEXTURE_PAINT, - TextureBackground.DENIM_TEXTURE_PAINT, - TextureBackground.WOVEN_MAT_TEXTURE_PAINT, - TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, - TextureBackground.PAPER_BAG_TEXTURE_PAINT, - TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, - TextureBackground.SAND_TEXTURE_PAINT, - TextureBackground.CORK_TEXTURE_PAINT, - TextureBackground.WALNUT_TEXTURE_PAINT, - TextureBackground.OAK_TEXTURE_PAINT, - TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; - private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{ - Inter.getLocText("BackgroundTexture-Newsprint"), - Inter.getLocText("BackgroundTexture-RecycledPaper"), - Inter.getLocText("BackgroundTexture-Parchment"), - Inter.getLocText("BackgroundTexture-Stationery"), - Inter.getLocText("BackgroundTexture-GreenMarble"), - Inter.getLocText("BackgroundTexture-WhiteMarble"), - Inter.getLocText("BackgroundTexture-BrownMarble"), - Inter.getLocText("BackgroundTexture-Granite"), - Inter.getLocText("BackgroundTexture-BlueTissuePaper"), - Inter.getLocText("BackgroundTexture-PinkTissuePaper"), - Inter.getLocText("BackgroundTexture-PurpleMesh"), - Inter.getLocText("BackgroundTexture-Bouquet"), - Inter.getLocText("BackgroundTexture-Papyrus"), - Inter.getLocText("BackgroundTexture-Canvas"), - Inter.getLocText("BackgroundTexture-Denim"), - Inter.getLocText("BackgroundTexture-WovenMat"), - Inter.getLocText("BackgroundTexture-WaterDroplets"), - Inter.getLocText("BackgroundTexture-PaperBag"), - Inter.getLocText("BackgroundTexture-FishFossil"), - Inter.getLocText("BackgroundTexture-Sand"), - Inter.getLocText("BackgroundTexture-Cork"), - Inter.getLocText("BackgroundTexture-Walnut"), - Inter.getLocText("BackgroundTexture-Oak"), - Inter.getLocText("BackgroundTexture-MediumWood") - }; } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java b/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java new file mode 100644 index 000000000..490cb82e4 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java @@ -0,0 +1,47 @@ +package com.fr.design.style.background; + +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.Inter; + +/** + * Created by richie on 16/5/18. + */ +public class BackgroundPane4Browser extends BackgroundPane { + + public BackgroundPane4Browser() { + super(); + } + + protected void initTabPane() { + int index = 0; + for (Class key : BackgroundFactory.browserKindsOfKey()) { + BackgroundUIWrapper wrapper = BackgroundFactory.getWrapper(key); + wrapper.setIndex(index++); + tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + } + } + + protected BackgroundDetailPane getTabItemPane(Background background, int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = BackgroundFactory.createBrowserIfAbsent(background == null ? null : background.getClass()); + quickPane.addChangeListener(backgroundChangeListener); + cacheMap.put(index, quickPane); + } + tabbedPane.setComponentAt(index, quickPane); + tabbedPane.setSelectedIndex(index); + return quickPane; + } + + protected BackgroundDetailPane getTabItemPaneByIndex(int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = BackgroundFactory.createBrowerIfAbsent(index); + tabbedPane.setComponentAt(index, quickPane); + cacheMap.put(index, quickPane); + quickPane.addChangeListener(backgroundChangeListener); + } + return quickPane; + } +} diff --git a/designer_base/src/com/fr/design/style/background/BackgroundSelectPane.java b/designer_base/src/com/fr/design/style/background/BackgroundSelectPane.java index 0dc68a8a2..1262d2ab4 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundSelectPane.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundSelectPane.java @@ -13,7 +13,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.dialog.BasicPane; import com.fr.general.Background; import com.fr.general.Inter; -import com.fr.design.style.background.BackgroundPane.BackgroundSettingPane; /** * @author kunsnat E-mail:kunsnat@gmail.com @@ -26,9 +25,9 @@ public abstract class BackgroundSelectPane extends BasicPane { private Background background; private ArrayList listenerList = new ArrayList(); - public abstract BackgroundSettingPane getShowPane(double preWidth); + public abstract BackgroundDetailPane getShowPane(double preWidth); - protected void initBackgroundShowPane(final BackgroundSettingPane backgroundPane) { + protected void initBackgroundShowPane(final BackgroundDetailPane backgroundPane) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); backgroundPane.addChangeListener(new ChangeListener() { diff --git a/designer_base/src/com/fr/design/style/background/BackgroundUIWrapper.java b/designer_base/src/com/fr/design/style/background/BackgroundUIWrapper.java new file mode 100644 index 000000000..9502674a3 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/BackgroundUIWrapper.java @@ -0,0 +1,49 @@ +package com.fr.design.style.background; + +/** + * Created by richie on 16/5/18. + */ +public class BackgroundUIWrapper { + + public static BackgroundUIWrapper create() { + return new BackgroundUIWrapper(); + } + + private int index = -1; + private String title; + private Class clazz; + + private BackgroundUIWrapper() { + + } + + public Class getType() { + return clazz; + } + + public BackgroundUIWrapper setType(Class clazz) { + this.clazz = clazz; + return this; + } + + public String getTitle() { + return title; + } + + public BackgroundUIWrapper setTitle(String title) { + this.title = title; + return this; + } + + public int getIndex() { + return index; + } + + + public BackgroundUIWrapper setIndex(int index) { + if (this.index == -1) { + this.index = index; + } + return this; + } +} diff --git a/designer_base/src/com/fr/design/style/background/gradient/GradientPane.java b/designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java similarity index 93% rename from designer_base/src/com/fr/design/style/background/gradient/GradientPane.java rename to designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java index 232b7e225..9ab11eb14 100644 --- a/designer_base/src/com/fr/design/style/background/gradient/GradientPane.java +++ b/designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java @@ -1,135 +1,135 @@ -package com.fr.design.style.background.gradient; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.ButtonGroup; - -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import com.fr.base.background.GradientBackground; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Background; -import com.fr.general.Inter; -import com.fr.design.style.background.BackgroundPane.BackgroundSettingPane; - -/** - * 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 - * @author ben - */ -public class GradientPane extends BackgroundSettingPane { - private static final long serialVersionUID = -6854603990673031897L; - - private UIRadioButton left2right, top2bottom; - private GradientBar gradientBar; - private ChangeListener changeListener = null; - - public GradientPane() { - - // bug 5452 简化GradientPane - JPanel jpanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText(new String[]{"Gradient-Color", "Set"})); - jpanel.setPreferredSize(new Dimension(450, 320)); - jpanel.setLayout(new BorderLayout()); - - // neil:增加渐变色拖动条 - JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - JPanel blankJp = new JPanel(); - gradientBar = new GradientBar(4, 254); - blankJp.add(gradientBar); - UILabel jl = new UILabel(Inter.getLocText("Drag_to_select_gradient")); - jl.setHorizontalAlignment(SwingConstants.CENTER); - gradientPanel.add(jl, BorderLayout.NORTH); - gradientPanel.add(blankJp, BorderLayout.SOUTH); - jpanel.add(gradientPanel, BorderLayout.NORTH); - - JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - JPanel innercenterPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - centerPane.add(new UILabel(" ")); - centerPane.add(innercenterPane); - innercenterPane.add(new UILabel(Inter.getLocText("Gradient-Direction") + ":")); - - left2right = new UIRadioButton(Inter.getLocText("PageSetup-Landscape")); - innercenterPane.add(left2right); - left2right.setSelected(true); - left2right.addActionListener(reviewListener); - - top2bottom = new UIRadioButton(Inter.getLocText("PageSetup-Portrait")); - innercenterPane.add(top2bottom); - top2bottom.addActionListener(reviewListener); - - ButtonGroup toggle = new ButtonGroup(); - toggle.add(left2right); - toggle.add(top2bottom); - jpanel.add(centerPane, BorderLayout.CENTER); - - this.add(jpanel); - } - - - public void populate(Background background) { - if (!(background instanceof GradientBackground)) { - return; - } - GradientBackground bg = (GradientBackground) background; - this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); - this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); - if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { - left2right.setSelected(true); - } else { - top2bottom.setSelected(true); - } - if (bg.isUseCell()) { - return; - } - double startValue = (double) bg.getBeginPlace(); - double endValue = (double) bg.getFinishPlace(); - gradientBar.setStartValue(startValue); - gradientBar.setEndValue(endValue); - this.gradientBar.repaint(); - } - - public GradientBackground update() { - GradientBackground gb = new GradientBackground( - gradientBar.getSelectColorPointBtnP1().getColorInner(), - gradientBar.getSelectColorPointBtnP2().getColorInner()); - if (left2right.isSelected()) { - gb.setDirection(GradientBackground.LEFT2RIGHT); - } else { - gb.setDirection(GradientBackground.TOP2BOTTOM); - } - if (gradientBar.isOriginalPlace()) { - gb.setUseCell(true); - } else { - gb.setUseCell(false); - gb.setBeginPlace((float) gradientBar.getStartValue()); - gb.setFinishPlace((float) gradientBar.getEndValue()); - } - return gb; - } - - - ActionListener reviewListener = new ActionListener() { - public void actionPerformed(ActionEvent e) { - fireChagneListener(); - } - }; - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - gradientBar.addChangeListener(changeListener); - } - - public void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } +package com.fr.design.style.background.gradient; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ButtonGroup; + +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.fr.base.background.GradientBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.Inter; +import com.fr.design.style.background.BackgroundDetailPane; + +/** + * 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 + * @author ben + */ +public class GradientBackgroundPane extends BackgroundDetailPane { + private static final long serialVersionUID = -6854603990673031897L; + + private UIRadioButton left2right, top2bottom; + private GradientBar gradientBar; + private ChangeListener changeListener = null; + + public GradientBackgroundPane() { + + // bug 5452 简化GradientPane + JPanel jpanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText(new String[]{"Gradient-Color", "Set"})); + jpanel.setPreferredSize(new Dimension(450, 320)); + jpanel.setLayout(new BorderLayout()); + + // neil:增加渐变色拖动条 + JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel blankJp = new JPanel(); + gradientBar = new GradientBar(4, 254); + blankJp.add(gradientBar); + UILabel jl = new UILabel(Inter.getLocText("Drag_to_select_gradient")); + jl.setHorizontalAlignment(SwingConstants.CENTER); + gradientPanel.add(jl, BorderLayout.NORTH); + gradientPanel.add(blankJp, BorderLayout.SOUTH); + jpanel.add(gradientPanel, BorderLayout.NORTH); + + JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + JPanel innercenterPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + centerPane.add(new UILabel(" ")); + centerPane.add(innercenterPane); + innercenterPane.add(new UILabel(Inter.getLocText("Gradient-Direction") + ":")); + + left2right = new UIRadioButton(Inter.getLocText("PageSetup-Landscape")); + innercenterPane.add(left2right); + left2right.setSelected(true); + left2right.addActionListener(reviewListener); + + top2bottom = new UIRadioButton(Inter.getLocText("PageSetup-Portrait")); + innercenterPane.add(top2bottom); + top2bottom.addActionListener(reviewListener); + + ButtonGroup toggle = new ButtonGroup(); + toggle.add(left2right); + toggle.add(top2bottom); + jpanel.add(centerPane, BorderLayout.CENTER); + + this.add(jpanel); + } + + + public void populate(Background background) { + if (!(background instanceof GradientBackground)) { + return; + } + GradientBackground bg = (GradientBackground) background; + this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); + this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); + if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { + left2right.setSelected(true); + } else { + top2bottom.setSelected(true); + } + if (bg.isUseCell()) { + return; + } + double startValue = (double) bg.getBeginPlace(); + double endValue = (double) bg.getFinishPlace(); + gradientBar.setStartValue(startValue); + gradientBar.setEndValue(endValue); + this.gradientBar.repaint(); + } + + public GradientBackground update() { + GradientBackground gb = new GradientBackground( + gradientBar.getSelectColorPointBtnP1().getColorInner(), + gradientBar.getSelectColorPointBtnP2().getColorInner()); + if (left2right.isSelected()) { + gb.setDirection(GradientBackground.LEFT2RIGHT); + } else { + gb.setDirection(GradientBackground.TOP2BOTTOM); + } + if (gradientBar.isOriginalPlace()) { + gb.setUseCell(true); + } else { + gb.setUseCell(false); + gb.setBeginPlace((float) gradientBar.getStartValue()); + gb.setFinishPlace((float) gradientBar.getEndValue()); + } + return gb; + } + + + ActionListener reviewListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + fireChagneListener(); + } + }; + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + gradientBar.addChangeListener(changeListener); + } + + public void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/background/impl/BPane.java b/designer_base/src/com/fr/design/style/background/impl/BPane.java new file mode 100644 index 000000000..9a9805a5c --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/BPane.java @@ -0,0 +1,46 @@ +package com.fr.design.style.background.impl; + +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by richie on 16/5/18. + */ +public abstract class BPane extends BackgroundDetailPane { + + public BPane(int nColumn) { + this.initComponents(nColumn); + } + + private void initComponents(int nColumn) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + this.add(contentPane, BorderLayout.NORTH); +// contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + + // type type. + + JPanel typePane = FRGUIPaneFactory.createTitledBorderPane(titleOfTypePane()); + contentPane.add(typePane); + JPanel typePane2 = new JPanel(); + typePane.add(typePane2); + typePane2.setLayout(layoutOfTypePane(nColumn)); + setChildrenOfTypePane(typePane2); + + setChildrenOfContentPane(contentPane); + } + + protected abstract String titleOfTypePane(); + + protected abstract LayoutManager layoutOfTypePane(int nColumn); + + protected abstract void setChildrenOfTypePane(JPanel typePane2); + + protected void setChildrenOfContentPane(JPanel contentPane) { + } +} diff --git a/designer_base/src/com/fr/design/style/background/impl/ColorBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/ColorBackgroundPane.java new file mode 100644 index 000000000..effbe6328 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/ColorBackgroundPane.java @@ -0,0 +1,42 @@ +package com.fr.design.style.background.impl; + +import com.fr.base.background.ColorBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.color.DetailColorSelectPane; +import com.fr.general.Background; + +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * Color background pane. + */ +public class ColorBackgroundPane extends BackgroundDetailPane { + + private DetailColorSelectPane detailColorSelectPane; + + public ColorBackgroundPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + detailColorSelectPane = new DetailColorSelectPane(); + this.add(detailColorSelectPane, BorderLayout.CENTER); + } + + public void populate(Background background) { + if (background instanceof ColorBackground) { + ColorBackground colorBackgroud = (ColorBackground) background; + this.detailColorSelectPane.populate(colorBackgroud.getColor()); + } else { + this.detailColorSelectPane.populate(Color.white); + } + } + + public Background update() throws Exception { + return ColorBackground.getInstance(this.detailColorSelectPane.update()); + } + + public void addChangeListener(ChangeListener changeListener) { + detailColorSelectPane.addChangeListener(changeListener); + } +} diff --git a/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java new file mode 100644 index 000000000..62ad05485 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java @@ -0,0 +1,230 @@ +package com.fr.design.style.background.impl; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.general.Background; +import com.fr.general.Inter; +import com.fr.stable.Constants; +import com.fr.stable.CoreGraphHelper; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +/** + * Image background pane. + */ +public class ImageBackgroundPane extends BackgroundDetailPane { + + private ImagePreviewPane previewPane = null; + private Style imageStyle = null; + private ChangeListener changeListener = null; + private ImageFileChooser imageFileChooser = null; + private UILabel imageSizeLabel = new UILabel(); + + protected JRadioButton defaultRadioButton = null; + protected JRadioButton tiledRadioButton = null; + private JRadioButton extendRadioButton = null; + private JRadioButton adjustRadioButton = null; + + public ImageBackgroundPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + // preview pane + JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + this.add(previewContainerPane, BorderLayout.CENTER); + + JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preview")); + previewOwnerPane.setLayout(new BorderLayout()); + previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); + + + previewPane = new ImagePreviewPane(); + previewOwnerPane.add(new JScrollPane(previewPane)); + previewPane.addChangeListener(imageSizeChangeListener); + + JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + previewContainerPane.add(selectFilePane, BorderLayout.EAST); + selectFilePane.setBorder(BorderFactory.createEmptyBorder(8, 2, 4, 0)); + + UIButton selectPictureButton = new UIButton( + Inter.getLocText("Image-Select_Picture")); + selectFilePane.add(selectPictureButton, BorderLayout.NORTH); + selectPictureButton.setMnemonic('S'); + selectPictureButton.addActionListener(selectPictureActionListener); + JPanel layoutPane = FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); + selectFilePane.add(layoutPane, BorderLayout.CENTER); + + //布局 + defaultRadioButton = new UIRadioButton(Inter.getLocText("Default")); + tiledRadioButton = new UIRadioButton(Inter.getLocText("Image-Titled")); + extendRadioButton = new UIRadioButton(Inter.getLocText("Image-Extend")); + adjustRadioButton = new UIRadioButton(Inter.getLocText("Image-Adjust")); + + defaultRadioButton.addActionListener(layoutActionListener); + tiledRadioButton.addActionListener(layoutActionListener); + extendRadioButton.addActionListener(layoutActionListener); + adjustRadioButton.addActionListener(layoutActionListener); + + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15)); + for (JRadioButton button : imageLayoutButtons()) { + jp.add(button); + } + layoutPane.add(jp); + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(defaultRadioButton); + layoutBG.add(tiledRadioButton); + layoutBG.add(extendRadioButton); + layoutBG.add(adjustRadioButton); + + defaultRadioButton.setSelected(true); + + // init image file chooser. + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + + protected JRadioButton[] imageLayoutButtons() { + return new JRadioButton[]{ + defaultRadioButton, + tiledRadioButton, + extendRadioButton, + adjustRadioButton + }; + } + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser.showOpenDialog(ImageBackgroundPane.this); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + + if (selectedFile != null && selectedFile.isFile()) { + Image image = BaseUtils.readImage(selectedFile.getPath()); + CoreGraphHelper.waitForImage(image); + + previewPane.setImage(image); + setImageStyle(); + previewPane.setImageStyle(imageStyle); + previewPane.repaint(); + } else { + previewPane.setImage(null); + } + } + + fireChagneListener(); + } + }; + + private void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } + } + + ActionListener layoutActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + + private void changeImageStyle() { + previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); + previewPane.repaint(); + } + }; + + public void populate(Background background) { + + if (background instanceof ImageBackground) { + ImageBackground imageBackground = (ImageBackground) background; + + if (imageBackground.getLayout() == Constants.IMAGE_CENTER) { + defaultRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } else if (imageBackground.getLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else if (imageBackground.getLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else { + tiledRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } + + previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); + if (imageBackground.getImage() != null) { + previewPane.setImage(imageBackground.getImage()); + imageSizeLabel.setText(previewPane.getImage().getWidth(null) + + " X " + previewPane.getImage().getHeight(null)); + } + + if (imageBackground.getImage() != null) { + previewPane.setImage(imageBackground.getImage()); + } + } else { + previewPane.setImage(null); + tiledRadioButton.setSelected(true); + + imageSizeLabel.setText(""); + } + + fireChagneListener(); + } + + public Background update() throws Exception { + ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); + setImageStyle(); + imageBackground.setLayout(imageStyle.getImageLayout()); + return imageBackground; + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + ChangeListener imageSizeChangeListener = new ChangeListener() { + + public void stateChanged(ChangeEvent evt) { + Image image = ((ImagePreviewPane) evt.getSource()).getImage(); + + if (image == null) { + imageSizeLabel.setText(""); + } else { + imageSizeLabel.setText(Inter.getLocText(new String[]{"Size", "px"}, new String[]{": " + image.getWidth(null) + "x" + image.getHeight(null)})); + } + } + }; +} diff --git a/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java new file mode 100644 index 000000000..4d15f18ac --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java @@ -0,0 +1,25 @@ +package com.fr.design.style.background.impl; + +import com.fr.stable.ArrayUtils; + +import javax.swing.*; + +/** + * Created by richie on 16/5/18. + */ +public class ImageBackgroundPane4Browser extends ImageBackgroundPane { + + + public ImageBackgroundPane4Browser() { + super(); + } + + @Override + protected JRadioButton[] imageLayoutButtons() { + + return (JRadioButton[]) ArrayUtils.addAll(super.imageLayoutButtons(), new JRadioButton[] { + defaultRadioButton, + tiledRadioButton, + }); + } +} diff --git a/designer_base/src/com/fr/design/style/background/impl/NullBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/NullBackgroundPane.java new file mode 100644 index 000000000..ea108019a --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/NullBackgroundPane.java @@ -0,0 +1,39 @@ +package com.fr.design.style.background.impl; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Background; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.ChangeListener; + +/** + * Null background pane. + */ +public class NullBackgroundPane extends BackgroundDetailPane { + + public NullBackgroundPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + UILabel centerLabel = new UILabel( + Inter.getLocText("Background-Background_is_NULL") + "..."); + this.add(centerLabel); + centerLabel.setHorizontalAlignment(SwingConstants.CENTER); + centerLabel.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); + } + + public void populate(Background background) { + // do nothing. + } + + public Background update() throws Exception { + return null; + } + + public void addChangeListener(ChangeListener changeListener) { + // do nothing. + } +} diff --git a/designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPane.java new file mode 100644 index 000000000..a1481e6d6 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPane.java @@ -0,0 +1,208 @@ +package com.fr.design.style.background.impl; + +import com.fr.base.GraphHelper; +import com.fr.base.background.PatternBackground; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.general.Background; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Rectangle2D; + +/** + * Pattern background pane. + */ +public class PatternBackgroundPane extends BPane { + + private int patternIndex = 0; // pattern setIndex. + protected ColorSelectBox foregroundColorPane; + protected ColorSelectBox backgroundColorPane; + private PatternButton[] patternButtonArray; + + public PatternBackgroundPane() { + super(12); + + foregroundColorPane.addSelectChangeListener(colorChangeListener); + backgroundColorPane.addSelectChangeListener(colorChangeListener); + } + + public PatternBackgroundPane(int nColumn) { + super(nColumn); + + if(foregroundColorPane != null) { + foregroundColorPane.addSelectChangeListener(colorChangeListener); + } + if(backgroundColorPane != null) { + backgroundColorPane.addSelectChangeListener(colorChangeListener); + } + } + + protected String titleOfTypePane() { + return Inter.getLocText("Background-Pattern"); + } + protected LayoutManager layoutOfTypePane(int nColumn) { + return FRGUIPaneFactory.createNColumnGridLayout(nColumn); + } + + protected void setChildrenOfTypePane(JPanel typePane2) { + ButtonGroup patternButtonGroup = new ButtonGroup(); + patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; + for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { + patternButtonArray[i] = new PatternButton(i); + patternButtonGroup.add(patternButtonArray[i]); + typePane2.add(patternButtonArray[i]); + } + } + + protected void setChildrenOfContentPane(JPanel contentPane) { + // colors + JPanel colorPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Colors")); + contentPane.add(colorPane); + + foregroundColorPane = new ColorSelectBox(80); + backgroundColorPane = new ColorSelectBox(80); + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + + colorPane.add(Box.createHorizontalStrut(2)); + colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + + ":", foregroundColorPane)); + + colorPane.add(Box.createHorizontalStrut(8)); + + colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + + ":", backgroundColorPane)); + } + + private JPanel createLabelColorPane(String text, + ColorSelectBox colorPane) { + JPanel labelColorPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + labelColorPane.add(new UILabel(text)); + labelColorPane.add(colorPane); + + return labelColorPane; + } + + public void populate(Background background) { + if (background != null && background instanceof PatternBackground) { + PatternBackground patternBackground = (PatternBackground) background; + int patternIndex = patternBackground.getPatternIndex(); + + if (patternIndex >= 0 + && patternIndex < this.patternButtonArray.length) { + this.patternButtonArray[patternIndex].setSelected(true); + this.patternIndex = patternIndex; + } else { + this.patternIndex = 0; + } + + foregroundColorPane.setSelectObject(patternBackground.getForeground()); + backgroundColorPane.setSelectObject(patternBackground.getBackground()); + } else { + patternIndex = 0; + this.patternButtonArray[0].setSelected(true); + + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + } + } + + public Background update() throws Exception { + return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); + } + + public void addChangeListener(ChangeListener changeListener) { + foregroundColorPane.addSelectChangeListener(changeListener); + backgroundColorPane.addSelectChangeListener(changeListener); + + for (int i = 0; i < this.patternButtonArray.length; i++) { + this.patternButtonArray[i].addChangeListener(changeListener); + } + } + // Foreground or Background changed. + ChangeListener colorChangeListener = new ChangeListener() { + + public void stateChanged(ChangeEvent e) { + for (int i = 0; i < patternButtonArray.length; i++) { + patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); + patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); + } + + PatternBackgroundPane.this.repaint();// repaint + } + }; + + /** + * Pattern type button. + */ + class PatternButton extends JToggleButton implements ActionListener { + + public PatternButton(int pIndex) { + this.pIndex = pIndex; + this.addActionListener(this); + + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.setBorder(null); + this.patternBackground = new PatternBackground(this.pIndex, + Color.lightGray, Color.black); + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, + d.width - 1, d.height - 1)); + + if (this.pIndex == patternIndex) {// it's selected. + g2d.setPaint(new Color(255, 51, 0)); + } else { + g2d.setPaint(Color.gray); + } + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, + d.height - 1)); + } + + public Dimension getPreferredSize() { + return new Dimension(24, 24); + } + + public void setPatternForeground(Color foreground) { + this.patternBackground.setForeground(foreground); + } + + public void setPatternBackground(Color background) { + this.patternBackground.setBackground(background); + } + + /** + * set Pattern setIndex. + */ + public void actionPerformed(ActionEvent evt) { + PatternBackgroundPane.this.patternIndex = pIndex; + + fireChagneListener(); + PatternBackgroundPane.this.repaint();// repaint + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + private int pIndex = 0; + private PatternBackground patternBackground; + } +} diff --git a/designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPaneNoFore.java b/designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPaneNoFore.java new file mode 100644 index 000000000..79fdaf389 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/PatternBackgroundPaneNoFore.java @@ -0,0 +1,24 @@ +package com.fr.design.style.background.impl; + +import com.fr.design.style.color.ColorSelectBox; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by richie on 16/5/18. + */ +public class PatternBackgroundPaneNoFore extends PatternBackgroundPane { + + public PatternBackgroundPaneNoFore(int nColumn) { + super(nColumn); + } + + // 重载 不加载两个前后按钮 + protected void setChildrenOfContentPane(JPanel contentPane) { + foregroundColorPane = new ColorSelectBox(80); + backgroundColorPane = new ColorSelectBox(80); + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + } +} diff --git a/designer_base/src/com/fr/design/style/background/impl/TextureBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/TextureBackgroundPane.java new file mode 100644 index 000000000..9800675c1 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/impl/TextureBackgroundPane.java @@ -0,0 +1,197 @@ +package com.fr.design.style.background.impl; + +import com.fr.base.GraphHelper; +import com.fr.base.background.TextureBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Rectangle2D; + +/** + * Texture background pane. TODO kunsnat: 拆出去. 真特么的长.. + */ +public class TextureBackgroundPane extends BPane { + + private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{ + TextureBackground.NEWSPRINT_TEXTURE_PAINT, + TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, + TextureBackground.PARCHMENT_TEXTURE_PAINT, + TextureBackground.STATIONERY_TEXTURE_PAINT, + TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, + TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, + TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, + TextureBackground.GRANITE_TEXTURE_PAINT, + TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, + TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, + TextureBackground.PURPLE_MESH_TEXTURE_PAINT, + TextureBackground.BOUQUET_TEXTURE_PAINT, + TextureBackground.PAPYRUS_TEXTURE_PAINT, + TextureBackground.CANVAS_TEXTURE_PAINT, + TextureBackground.DENIM_TEXTURE_PAINT, + TextureBackground.WOVEN_MAT_TEXTURE_PAINT, + TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, + TextureBackground.PAPER_BAG_TEXTURE_PAINT, + TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, + TextureBackground.SAND_TEXTURE_PAINT, + TextureBackground.CORK_TEXTURE_PAINT, + TextureBackground.WALNUT_TEXTURE_PAINT, + TextureBackground.OAK_TEXTURE_PAINT, + TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; + + private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{ + Inter.getLocText("BackgroundTexture-Newsprint"), + Inter.getLocText("BackgroundTexture-RecycledPaper"), + Inter.getLocText("BackgroundTexture-Parchment"), + Inter.getLocText("BackgroundTexture-Stationery"), + Inter.getLocText("BackgroundTexture-GreenMarble"), + Inter.getLocText("BackgroundTexture-WhiteMarble"), + Inter.getLocText("BackgroundTexture-BrownMarble"), + Inter.getLocText("BackgroundTexture-Granite"), + Inter.getLocText("BackgroundTexture-BlueTissuePaper"), + Inter.getLocText("BackgroundTexture-PinkTissuePaper"), + Inter.getLocText("BackgroundTexture-PurpleMesh"), + Inter.getLocText("BackgroundTexture-Bouquet"), + Inter.getLocText("BackgroundTexture-Papyrus"), + Inter.getLocText("BackgroundTexture-Canvas"), + Inter.getLocText("BackgroundTexture-Denim"), + Inter.getLocText("BackgroundTexture-WovenMat"), + Inter.getLocText("BackgroundTexture-WaterDroplets"), + Inter.getLocText("BackgroundTexture-PaperBag"), + Inter.getLocText("BackgroundTexture-FishFossil"), + Inter.getLocText("BackgroundTexture-Sand"), + Inter.getLocText("BackgroundTexture-Cork"), + Inter.getLocText("BackgroundTexture-Walnut"), + Inter.getLocText("BackgroundTexture-Oak"), + Inter.getLocText("BackgroundTexture-MediumWood") + }; + + private TexturePaint texturePaint; + private TextureButton[] textureButtonArray; + + public TextureBackgroundPane() { + super(8);// 默认的. + } + + public TextureBackgroundPane(int colum) { + super(colum);// 自定义的. + } + + protected LayoutManager layoutOfTypePane(int nColumn) { + return FRGUIPaneFactory.createNColumnGridLayout(nColumn); + } + + protected String titleOfTypePane() { + return Inter.getLocText("Background-Texture"); + } + protected void setChildrenOfTypePane(JPanel typePane2) { + ButtonGroup patternButtonGroup = new ButtonGroup(); + textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; + for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { + textureButtonArray[i] = new TextureButton( + EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); + patternButtonGroup.add(textureButtonArray[i]); + typePane2.add(textureButtonArray[i]); + } + } + + public void populate(Background background) { + if (background instanceof TextureBackground) { + TextureBackground textureBackground = (TextureBackground) background; + + this.texturePaint = textureBackground.getTexturePaint(); + + for (int i = 0; i < textureButtonArray.length; i++) { + if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { + textureButtonArray[i].setSelected(true); + break; + } + } + } else { + this.textureButtonArray[0].setSelected(true); + this.texturePaint = textureButtonArray[0].getTexturePaint(); + } + } + + public Background update() throws Exception { + return new TextureBackground(this.texturePaint); + } + + public void addChangeListener(ChangeListener changeListener) { + for (int i = 0; i < this.textureButtonArray.length; i++) { + this.textureButtonArray[i].addChangeListener(changeListener); + } + } + + /** + * Texture type button. + */ + class TextureButton extends JToggleButton implements ActionListener { + + private TexturePaint buttonTexturePaint; + + public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { + this.buttonTexturePaint = buttonTexturePaint; + this.setToolTipText(tooltip); + + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.addActionListener(this); + this.setBorder(null); + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + + g2d.setPaint(this.buttonTexturePaint); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, + d.height - 1)); + + if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's + // selected. + g2d.setPaint(Color.black); + } else { + g2d.setPaint(Color.gray); + } + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, + d.height - 1)); + } + + public Dimension getPreferredSize() { + return new Dimension(36, 32); + } + + public TexturePaint getTexturePaint() { + return this.buttonTexturePaint; + } + + /** + * set Pattern setIndex. + */ + public void actionPerformed(ActionEvent evt) { + TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); + + fireChagneListener(); + TextureBackgroundPane.this.repaint(); // repaint. + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + } +} diff --git a/designer_base/src/com/fr/design/style/background/pattern/PatternSelectPane.java b/designer_base/src/com/fr/design/style/background/pattern/PatternSelectPane.java index b8f9ea384..47a352447 100644 --- a/designer_base/src/com/fr/design/style/background/pattern/PatternSelectPane.java +++ b/designer_base/src/com/fr/design/style/background/pattern/PatternSelectPane.java @@ -1,8 +1,8 @@ package com.fr.design.style.background.pattern; import com.fr.general.Inter; -import com.fr.design.style.background.BackgroundPane.BackgroundSettingPane; -import com.fr.design.style.background.BackgroundPane.PatternBackgroundPaneNoFore; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.impl.PatternBackgroundPaneNoFore; import com.fr.design.style.background.BackgroundSelectPane; @@ -20,7 +20,7 @@ public class PatternSelectPane extends BackgroundSelectPane { } @Override - public BackgroundSettingPane getShowPane(double preWidth) { + public BackgroundDetailPane getShowPane(double preWidth) { // 最少6个. 因为项目太多了. 会拉的很长 int column = Math.max((int)preWidth / 25, 6); return new PatternBackgroundPaneNoFore(column); diff --git a/designer_base/src/com/fr/design/style/background/texture/TextureSelectPane.java b/designer_base/src/com/fr/design/style/background/texture/TextureSelectPane.java index 86d36bbfb..ea7af5bc4 100644 --- a/designer_base/src/com/fr/design/style/background/texture/TextureSelectPane.java +++ b/designer_base/src/com/fr/design/style/background/texture/TextureSelectPane.java @@ -1,8 +1,8 @@ package com.fr.design.style.background.texture; import com.fr.general.Inter; -import com.fr.design.style.background.BackgroundPane.BackgroundSettingPane; -import com.fr.design.style.background.BackgroundPane.TextureBackgroundPane; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.impl.TextureBackgroundPane; import com.fr.design.style.background.BackgroundSelectPane; @@ -19,7 +19,7 @@ public class TextureSelectPane extends BackgroundSelectPane { initBackgroundShowPane(getShowPane(preWidth)); } - public BackgroundSettingPane getShowPane(double preWidth) { + public BackgroundDetailPane getShowPane(double preWidth) { // 计算合适的列. 至少4个. 最多8个. int column = Math.max((int)preWidth / 40, 4); return new TextureBackgroundPane(column); diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java index 447ba1107..532f0d216 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.chart.gui.style; -import com.fr.design.gui.style.GradientPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundPane; -import com.fr.design.mainframe.backgroundpane.NullBackgroundPane; +import com.fr.design.gui.style.GradientQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; /** * 背景界面, 无图片和纹理选项. @@ -16,8 +16,8 @@ public class ChartBackgroundNoImagePane extends ChartBackgroundPane { } protected void initList() { - paneList.add(new NullBackgroundPane()); - paneList.add(new ColorBackgroundPane()); - paneList.add(new GradientPane(CHART_GRADIENT_WIDTH)); + paneList.add(new NullBackgroundQuickPane()); + paneList.add(new ColorBackgroundQuickPane()); + paneList.add(new GradientQuickPane(CHART_GRADIENT_WIDTH)); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java index 7cbffadfd..ef6129710 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java @@ -4,13 +4,13 @@ import com.fr.chart.chartglyph.GeneralInfo; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.style.GradientPane; +import com.fr.design.gui.style.GradientQuickPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundPane; -import com.fr.design.mainframe.backgroundpane.ImageBackgroundPane; -import com.fr.design.mainframe.backgroundpane.NullBackgroundPane; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; import com.fr.design.dialog.BasicPane; import com.fr.general.Background; import com.fr.general.Inter; @@ -33,7 +33,7 @@ public class ChartBackgroundPane extends BasicPane{ private static final long serialVersionUID = 6955952013135176051L; private static final double ALPHA_V = 100.0; protected static final int CHART_GRADIENT_WIDTH = 150; - protected List paneList; + protected List paneList; private UIComboBox typeComboBox; private UINumberDragPane transparent; @@ -41,7 +41,7 @@ public class ChartBackgroundPane extends BasicPane{ public ChartBackgroundPane() { typeComboBox = new UIComboBox(); final CardLayout cardlayout = new CardLayout(); - paneList = new ArrayList(); + paneList = new ArrayList(); initList(); @@ -54,7 +54,7 @@ public class ChartBackgroundPane extends BasicPane{ } }; for (int i = 0; i < paneList.size(); i++) { - BackgroundSettingPane pane = paneList.get(i); + BackgroundQuickPane pane = paneList.get(i); typeComboBox.addItem(pane.title4PopupWindow()); centerPane.add(pane, pane.title4PopupWindow()); } @@ -89,10 +89,10 @@ public class ChartBackgroundPane extends BasicPane{ } protected void initList() { - paneList.add(new NullBackgroundPane()); - paneList.add(new ColorBackgroundPane()); - paneList.add(new ImageBackgroundPane()); - paneList.add(new GradientPane(CHART_GRADIENT_WIDTH)); + paneList.add(new NullBackgroundQuickPane()); + paneList.add(new ColorBackgroundQuickPane()); + paneList.add(new ImageBackgroundQuickPane()); + paneList.add(new GradientQuickPane(CHART_GRADIENT_WIDTH)); } /** @@ -127,7 +127,7 @@ public class ChartBackgroundPane extends BasicPane{ double alpha = attr.getAlpha() * ALPHA_V; transparent.populateBean(alpha); for (int i = 0; i < paneList.size(); i++) { - BackgroundSettingPane pane = paneList.get(i); + BackgroundQuickPane pane = paneList.get(i); if (pane.accept(background)) { pane.populateBean(background); typeComboBox.setSelectedIndex(i); From 8c543728f6e5dec9a9cd7ad943f29a5d53106daf Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 18 May 2016 17:09:06 +0800 Subject: [PATCH 16/41] =?UTF-8?q?=E5=BC=95=E7=94=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/style/BackgroundNoImagePane.java | 25 +- .../fr/design/gui/style/BackgroundPane.java | 291 +++++++++--------- .../gui/style/BackgroundSpecialPane.java | 28 +- .../GradientBackgroundQuickPane.java} | 243 ++++++++------- .../gui/style/ChartBackgroundNoImagePane.java | 4 +- .../chart/gui/style/ChartBackgroundPane.java | 8 +- 6 files changed, 294 insertions(+), 305 deletions(-) rename designer_base/src/com/fr/design/{gui/style/GradientPane.java => mainframe/backgroundpane/GradientBackgroundQuickPane.java} (91%) diff --git a/designer_base/src/com/fr/design/gui/style/BackgroundNoImagePane.java b/designer_base/src/com/fr/design/gui/style/BackgroundNoImagePane.java index 7e2680eef..00465d83e 100644 --- a/designer_base/src/com/fr/design/gui/style/BackgroundNoImagePane.java +++ b/designer_base/src/com/fr/design/gui/style/BackgroundNoImagePane.java @@ -1,10 +1,10 @@ package com.fr.design.gui.style; import com.fr.design.event.UIObserverListener; -import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundPane; -import com.fr.design.mainframe.backgroundpane.NullBackgroundPane; -import java.util.ArrayList; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; /** * Created with IntelliJ IDEA. @@ -18,8 +18,9 @@ public class BackgroundNoImagePane extends BackgroundPane{ super(); } - protected void initPaneList(){ - ColorBackgroundPane colorBackgroundPane = new ColorBackgroundPane(); + @Override + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane(); colorBackgroundPane.registerChangeListener(new UIObserverListener() { @Override @@ -27,7 +28,7 @@ public class BackgroundNoImagePane extends BackgroundPane{ fireStateChanged(); } }); - GradientPane gradientPane = new GradientPane(); + GradientBackgroundQuickPane gradientPane = new GradientBackgroundQuickPane(); gradientPane.registerChangeListener(new UIObserverListener() { @Override @@ -35,10 +36,10 @@ public class BackgroundNoImagePane extends BackgroundPane{ fireStateChanged(); } }); - paneList = new ArrayList(); - paneList.add(new NullBackgroundPane()); - paneList.add(colorBackgroundPane); - paneList.add(gradientPane); - + return new BackgroundQuickPane[]{ + new NullBackgroundQuickPane(), + colorBackgroundPane, + gradientPane + }; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/style/BackgroundPane.java b/designer_base/src/com/fr/design/gui/style/BackgroundPane.java index 8c03e6202..1bf6d7e4b 100644 --- a/designer_base/src/com/fr/design/gui/style/BackgroundPane.java +++ b/designer_base/src/com/fr/design/gui/style/BackgroundPane.java @@ -1,148 +1,145 @@ -package com.fr.design.gui.style; - -/* - * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. - */ - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Dimension; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import com.fr.base.Style; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundPane; -import com.fr.design.mainframe.backgroundpane.ImageBackgroundPane; -import com.fr.design.mainframe.backgroundpane.NullBackgroundPane; -import com.fr.design.mainframe.backgroundpane.PatternBackgroundPane; -import com.fr.design.mainframe.backgroundpane.TextureBackgroundPane; -import com.fr.general.Background; -import com.fr.general.Inter; - -/** - * - * @author zhou - * @since 2012-5-28下午6:22:09 - */ -public class BackgroundPane extends AbstractBasicStylePane { - - private UIComboBox typeComboBox; - - protected List paneList; - - public BackgroundPane() { - this.initComponents(); - } - - protected void initComponents() { - this.setLayout(new BorderLayout(0, 6)); - typeComboBox = new UIComboBox(); - final CardLayout cardlayout = new CardLayout(); - this.add(typeComboBox, BorderLayout.NORTH); - - initPaneList(); - final JPanel centerPane = new JPanel(cardlayout) { - @Override - public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度 - int index = typeComboBox.getSelectedIndex(); - return new Dimension(super.getPreferredSize().width, paneList.get(index).getPreferredSize().height); - } - }; - for (int i = 0; i < paneList.size(); i++) { - BackgroundSettingPane pane = paneList.get(i); - typeComboBox.addItem(pane.title4PopupWindow()); - centerPane.add(pane, pane.title4PopupWindow()); - } - this.add(centerPane, BorderLayout.CENTER); - typeComboBox.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - cardlayout.show(centerPane, (String)typeComboBox.getSelectedItem()); - fireStateChanged(); - } - }); - } - - protected void initPaneList(){ - paneList = new ArrayList(); - paneList.add(new NullBackgroundPane()); - paneList.add(new ColorBackgroundPane()); - paneList.add(new TextureBackgroundPane()); - paneList.add(new PatternBackgroundPane()); - paneList.add(new ImageBackgroundPane()); - paneList.add(new GradientPane()); - } - - /** - * 事件监听 - * @param changeListener 事件 - */ - public void addChangeListener(ChangeListener changeListener) { - listenerList.add(ChangeListener.class, changeListener); - } - - /** - */ - protected void fireStateChanged() { - Object[] listeners = listenerList.getListenerList(); - ChangeEvent e = null; - - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == ChangeListener.class) { - if (e == null) { - e = new ChangeEvent(this); - } - ((ChangeListener)listeners[i + 1]).stateChanged(e); - } - } - } - - /** - * 名称 - * @return 名称 - */ - public String title4PopupWindow() { - return Inter.getLocText("FR-Utils_Background"); - } - - /** - * Populate background. - */ - public void populateBean(Background background) { - for (int i = 0; i < paneList.size(); i++) { - BackgroundSettingPane pane = paneList.get(i); - if (pane.accept(background)) { - pane.populateBean(background); - typeComboBox.setSelectedIndex(i); - return; - } - } - } - - /** - * Update background. - */ - public Background update() { - return paneList.get(typeComboBox.getSelectedIndex()).updateBean(); - } - - @Override - public void populateBean(Style style) { - this.populateBean(style.getBackground()); - } - - @Override - public Style update(Style style) { - return style.deriveBackground(this.update()); - } - +package com.fr.design.gui.style; + +import com.fr.base.Style; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.BackgroundQuickUIProvider; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.mainframe.backgroundpane.*; +import com.fr.general.Background; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; + +/** + * @author zhou + * @since 2012-5-28下午6:22:09 + */ +public class BackgroundPane extends AbstractBasicStylePane { + + private UIComboBox typeComboBox; + + protected BackgroundQuickPane[] paneList; + + public BackgroundPane() { + this.initComponents(); + } + + protected void initComponents() { + this.setLayout(new BorderLayout(0, 6)); + typeComboBox = new UIComboBox(); + final CardLayout cardlayout = new CardLayout(); + this.add(typeComboBox, BorderLayout.NORTH); + + paneList = supportKindsOfBackgroundUI(); + + final JPanel centerPane = new JPanel(cardlayout) { + @Override + public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度 + int index = typeComboBox.getSelectedIndex(); + return new Dimension(super.getPreferredSize().width, paneList[index].getPreferredSize().height); + } + }; + for (BackgroundQuickPane pane : paneList) { + typeComboBox.addItem(pane.title4PopupWindow()); + centerPane.add(pane, pane.title4PopupWindow()); + } + this.add(centerPane, BorderLayout.CENTER); + typeComboBox.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); + fireStateChanged(); + } + }); + } + + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + java.util.List kinds = new ArrayList<>(); + kinds.add(new NullBackgroundQuickPane()); + kinds.add(new ColorBackgroundQuickPane()); + kinds.add(new TextureBackgroundQuickPane()); + kinds.add(new PatternBackgroundQuickPane()); + kinds.add(new ImageBackgroundQuickPane()); + kinds.add(new GradientBackgroundQuickPane()); + BackgroundQuickUIProvider[] providers = ExtraDesignClassManager.getInstance().getBackgroundQuickUIProviders(); + for (BackgroundQuickUIProvider provider : providers) { + kinds.add(provider.appearanceForBackground()); + + } + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); + } + + + /** + * 事件监听 + * + * @param changeListener 事件 + */ + public void addChangeListener(ChangeListener changeListener) { + listenerList.add(ChangeListener.class, changeListener); + } + + /** + */ + protected void fireStateChanged() { + Object[] listeners = listenerList.getListenerList(); + ChangeEvent e = null; + + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChangeListener.class) { + if (e == null) { + e = new ChangeEvent(this); + } + ((ChangeListener) listeners[i + 1]).stateChanged(e); + } + } + } + + /** + * 名称 + * + * @return 名称 + */ + public String title4PopupWindow() { + return Inter.getLocText("FR-Utils_Background"); + } + + /** + * Populate background. + */ + public void populateBean(Background background) { + for (int i = 0; i < paneList.length; i++) { + BackgroundQuickPane pane = paneList[i]; + if (pane.accept(background)) { + pane.populateBean(background); + typeComboBox.setSelectedIndex(i); + return; + } + } + } + + /** + * Update background. + */ + public Background update() { + return paneList[typeComboBox.getSelectedIndex()].updateBean(); + } + + @Override + public void populateBean(Style style) { + this.populateBean(style.getBackground()); + } + + @Override + public Style update(Style style) { + return style.deriveBackground(this.update()); + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/style/BackgroundSpecialPane.java b/designer_base/src/com/fr/design/gui/style/BackgroundSpecialPane.java index 59efe3a53..43c1d133c 100644 --- a/designer_base/src/com/fr/design/gui/style/BackgroundSpecialPane.java +++ b/designer_base/src/com/fr/design/gui/style/BackgroundSpecialPane.java @@ -1,12 +1,7 @@ package com.fr.design.gui.style; import com.fr.design.event.UIObserverListener; -import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundPane; -import com.fr.design.mainframe.backgroundpane.ImageBackgroundPane; -import com.fr.design.mainframe.backgroundpane.NullBackgroundPane; - -import java.util.ArrayList; +import com.fr.design.mainframe.backgroundpane.*; /** * Created with IntelliJ IDEA. @@ -20,8 +15,9 @@ public class BackgroundSpecialPane extends BackgroundPane{ super(); } - protected void initPaneList(){ - ColorBackgroundPane colorBackgroundPane = new ColorBackgroundPane(); + @Override + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane(); colorBackgroundPane.registerChangeListener(new UIObserverListener() { @Override @@ -29,7 +25,7 @@ public class BackgroundSpecialPane extends BackgroundPane{ fireStateChanged(); } }); - ImageBackgroundPane imageBackgroundPane = new ImageBackgroundPane(); + ImageBackgroundQuickPane imageBackgroundPane = new ImageBackgroundQuickPane(); imageBackgroundPane.registerChangeListener(new UIObserverListener() { @Override @@ -37,18 +33,18 @@ public class BackgroundSpecialPane extends BackgroundPane{ fireStateChanged(); } }); - GradientPane gradientPane = new GradientPane(); + GradientBackgroundQuickPane gradientPane = new GradientBackgroundQuickPane(); gradientPane.registerChangeListener(new UIObserverListener() { @Override public void doChange() { fireStateChanged(); } }); - paneList = new ArrayList(); - paneList.add(new NullBackgroundPane()); - paneList.add(colorBackgroundPane); - paneList.add(imageBackgroundPane); - paneList.add(gradientPane); - + return new BackgroundQuickPane[] { + new NullBackgroundQuickPane(), + colorBackgroundPane, + imageBackgroundPane, + gradientPane + }; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/style/GradientPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java similarity index 91% rename from designer_base/src/com/fr/design/gui/style/GradientPane.java rename to designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java index ed713ffe7..08ef9e61c 100644 --- a/designer_base/src/com/fr/design/gui/style/GradientPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java @@ -1,123 +1,122 @@ -package com.fr.design.gui.style; - -import com.fr.base.background.GradientBackground; -import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; -import com.fr.general.Background; -import com.fr.general.Inter; -import com.fr.design.style.background.gradient.GradientBar; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; - -/** - * @author zhou - * @since 2012-5-30上午10:36:21 - */ -public class GradientPane extends BackgroundSettingPane { - private static final long serialVersionUID = -6854603990673031897L; - - private static final int DEFAULT_GRADIENT_WIDTH = 185; - - private int gradientBarWidth = DEFAULT_GRADIENT_WIDTH; - - private GradientBar gradientBar; - private UIButtonGroup directionPane; - - public GradientPane() { - constructPane(); - } - - public GradientPane(int gradientBarWidth) { - this.gradientBarWidth = gradientBarWidth; - constructPane(); - } - - private void constructPane(){ - String[] textArray = {Inter.getLocText("Utils-Left_to_Right"), Inter.getLocText("Utils-Top_to_Bottom")}; - Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM}; - directionPane = new UIButtonGroup(textArray, valueArray); - directionPane.setSelectedIndex(0); - gradientBar = new GradientBar(4, this.gradientBarWidth); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p,}; - - Component[][] components = new Component[][]{ - new Component[]{gradientBar, null}, - new Component[]{new UILabel(Inter.getLocText("Gradient-Direction") + ":"), directionPane} - }; - JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.setLayout(new BorderLayout()); - this.add(Gradient, BorderLayout.CENTER); - } - - public void populateBean(Background background) { - GradientBackground bg = (GradientBackground) background; - this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); - this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); - directionPane.setSelectedItem(bg.getDirection()); - if (bg.isUseCell()) { - return; - } - double startValue = (double) bg.getBeginPlace(); - double endValue = (double) bg.getFinishPlace(); - gradientBar.setStartValue(startValue); - gradientBar.setEndValue(endValue); - if(this.gradientBar.getSelectColorPointBtnP1() != null && this.gradientBar.getSelectColorPointBtnP2() != null){ - this.gradientBar.getSelectColorPointBtnP1().setX(startValue); - this.gradientBar.getSelectColorPointBtnP2().setX(endValue); - } - this.gradientBar.repaint(); - } - - public GradientBackground updateBean() { - GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner()); - gb.setDirection(directionPane.getSelectedItem()); - if (gradientBar.isOriginalPlace()) { - gb.setUseCell(true); - } else { - gb.setUseCell(false); - gb.setBeginPlace((float) gradientBar.getStartValue()); - gb.setFinishPlace((float) gradientBar.getEndValue()); - } - return gb; - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - gradientBar.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - directionPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - } - - @Override - public boolean accept(Background background) { - return background instanceof GradientBackground; - } - - @Override - public String title4PopupWindow() { - return Inter.getLocText("Gradient-Color"); - } - +package com.fr.design.mainframe.backgroundpane; + +import com.fr.base.background.GradientBackground; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.gradient.GradientBar; +import com.fr.general.Background; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * @author zhou + * @since 2012-5-30上午10:36:21 + */ +public class GradientBackgroundQuickPane extends BackgroundQuickPane { + private static final long serialVersionUID = -6854603990673031897L; + + private static final int DEFAULT_GRADIENT_WIDTH = 185; + + private int gradientBarWidth = DEFAULT_GRADIENT_WIDTH; + + private GradientBar gradientBar; + private UIButtonGroup directionPane; + + public GradientBackgroundQuickPane() { + constructPane(); + } + + public GradientBackgroundQuickPane(int gradientBarWidth) { + this.gradientBarWidth = gradientBarWidth; + constructPane(); + } + + private void constructPane(){ + String[] textArray = {Inter.getLocText("Utils-Left_to_Right"), Inter.getLocText("Utils-Top_to_Bottom")}; + Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM}; + directionPane = new UIButtonGroup(textArray, valueArray); + directionPane.setSelectedIndex(0); + gradientBar = new GradientBar(4, this.gradientBarWidth); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p,}; + + Component[][] components = new Component[][]{ + new Component[]{gradientBar, null}, + new Component[]{new UILabel(Inter.getLocText("Gradient-Direction") + ":"), directionPane} + }; + JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(Gradient, BorderLayout.CENTER); + } + + public void populateBean(Background background) { + GradientBackground bg = (GradientBackground) background; + this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); + this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); + directionPane.setSelectedItem(bg.getDirection()); + if (bg.isUseCell()) { + return; + } + double startValue = (double) bg.getBeginPlace(); + double endValue = (double) bg.getFinishPlace(); + gradientBar.setStartValue(startValue); + gradientBar.setEndValue(endValue); + if(this.gradientBar.getSelectColorPointBtnP1() != null && this.gradientBar.getSelectColorPointBtnP2() != null){ + this.gradientBar.getSelectColorPointBtnP1().setX(startValue); + this.gradientBar.getSelectColorPointBtnP2().setX(endValue); + } + this.gradientBar.repaint(); + } + + public GradientBackground updateBean() { + GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner()); + gb.setDirection(directionPane.getSelectedItem()); + if (gradientBar.isOriginalPlace()) { + gb.setUseCell(true); + } else { + gb.setUseCell(false); + gb.setBeginPlace((float) gradientBar.getStartValue()); + gb.setFinishPlace((float) gradientBar.getEndValue()); + } + return gb; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + gradientBar.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + directionPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + } + + @Override + public boolean accept(Background background) { + return background instanceof GradientBackground; + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText("Gradient-Color"); + } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java index 532f0d216..439d2efe6 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundNoImagePane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.chart.gui.style; -import com.fr.design.gui.style.GradientQuickPane; import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; /** @@ -18,6 +18,6 @@ public class ChartBackgroundNoImagePane extends ChartBackgroundPane { protected void initList() { paneList.add(new NullBackgroundQuickPane()); paneList.add(new ColorBackgroundQuickPane()); - paneList.add(new GradientQuickPane(CHART_GRADIENT_WIDTH)); + paneList.add(new GradientBackgroundQuickPane(CHART_GRADIENT_WIDTH)); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java index ef6129710..13c4269e8 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartBackgroundPane.java @@ -4,13 +4,9 @@ import com.fr.chart.chartglyph.GeneralInfo; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.style.GradientQuickPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; -import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; -import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.*; import com.fr.design.dialog.BasicPane; import com.fr.general.Background; import com.fr.general.Inter; @@ -92,7 +88,7 @@ public class ChartBackgroundPane extends BasicPane{ paneList.add(new NullBackgroundQuickPane()); paneList.add(new ColorBackgroundQuickPane()); paneList.add(new ImageBackgroundQuickPane()); - paneList.add(new GradientQuickPane(CHART_GRADIENT_WIDTH)); + paneList.add(new GradientBackgroundQuickPane(CHART_GRADIENT_WIDTH)); } /** From 27086ced570966ac064185c04c67fde45a447ab1 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 18 May 2016 17:32:02 +0800 Subject: [PATCH 17/41] =?UTF-8?q?=E8=AF=AF=E5=88=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/datapane/connect/ConnectionListPane.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java index 725a65ad3..91d362a48 100644 --- a/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -150,4 +150,12 @@ public class ConnectionListPane extends JListControlPane { datasourceManager.putConnection(nameObject.getName(), (Connection) nameObject.getObject()); } } + /** + * 设置选中项 + * + * @param index 选中项的序列号 + */ + public void setSelectedIndex(int index) { + nameableList.setSelectedIndex(index); + } } \ No newline at end of file From 52336f6123c22191cc2f386542ba088439999db8 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 18 May 2016 17:44:02 +0800 Subject: [PATCH 18/41] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/TableDataPaneListPane.java | 10 ---------- .../data/datapane/connect/ConnectionListPane.java | 8 -------- .../fr/design/gui/controlpane/JListControlPane.java | 8 ++++++++ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java index 90d6ca5df..97240dd94 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -273,14 +273,4 @@ public class TableDataPaneListPane extends JListControlPane implements TableData public JPanel getPanel() { return this; } - - /** - * 设置选中项 - * - * @param index 选中项的序列号 - */ - @Override - public void setSelectedIndex(int index) { - nameableList.setSelectedIndex(index); - } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java index 91d362a48..725a65ad3 100644 --- a/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -150,12 +150,4 @@ public class ConnectionListPane extends JListControlPane { datasourceManager.putConnection(nameObject.getName(), (Connection) nameObject.getObject()); } } - /** - * 设置选中项 - * - * @param index 选中项的序列号 - */ - public void setSelectedIndex(int index) { - nameableList.setSelectedIndex(index); - } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java index 3ed10c3b1..dd91b7824 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -954,5 +954,13 @@ public abstract class JListControlPane extends JControlPane { } return false; } + /** + * 设置选中项 + * + * @param index 选中项的序列号 + */ + public void setSelectedIndex(int index) { + nameableList.setSelectedIndex(index); + } } \ No newline at end of file From 3d5b65368a5b1c017b76324d3ae6e37d22d27d66 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 18 May 2016 19:18:22 +0800 Subject: [PATCH 19/41] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E7=9A=84=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/designer.iml | 1 - designer_base/designer_base.iml | 2 +- .../com/fr/design/style/background/BackgroundFactory.java | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/designer/designer.iml b/designer/designer.iml index 276f91e81..c798a6fe0 100644 --- a/designer/designer.iml +++ b/designer/designer.iml @@ -17,6 +17,5 @@ - \ No newline at end of file diff --git a/designer_base/designer_base.iml b/designer_base/designer_base.iml index 15ff9cc8c..d20642b28 100644 --- a/designer_base/designer_base.iml +++ b/designer_base/designer_base.iml @@ -1,7 +1,7 @@ - + diff --git a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java index c41639c8a..c44752203 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java @@ -9,7 +9,7 @@ import com.fr.design.style.background.impl.*; import com.fr.general.Background; import com.fr.general.Inter; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -18,8 +18,8 @@ import java.util.Set; */ public class BackgroundFactory { - private static Map, BackgroundUIWrapper> map = new HashMap<>(); - private static Map, BackgroundUIWrapper> browser = new HashMap<>(); + private static Map, BackgroundUIWrapper> map = new LinkedHashMap<>(); + private static Map, BackgroundUIWrapper> browser = new LinkedHashMap<>(); static { registerUniversal(map); From 3d73fade2ddd1d5a69298a7042db6e94647aaf43 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 18 May 2016 19:21:06 +0800 Subject: [PATCH 20/41] =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=88=86=E7=B1=BBapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 10 ++++++ .../exe/GetPluginCategoriesExecutor.java | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 25d9c20cf..5c7c2e8a3 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -243,6 +243,16 @@ public class PluginWebBridge { new Thread(task).start(); } + /** + * 在线获取插件分类 + * + * @param callback 回调函数 + */ + public void getPluginCategories(final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new GetPluginCategoriesExecutor()); + new Thread(task).start(); + } + /** * 展示一个重启的对话框(少用,莫名其妙会有bug) * diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java new file mode 100644 index 000000000..81bdb8f8c --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java @@ -0,0 +1,35 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.Process; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; + +/** + * Created by vito on 16/5/16. + */ +public class GetPluginCategoriesExecutor implements Executor { + private String result = "[]"; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.category")); + result = httpClient.getResponseText(); + } + } + }; + } +} From 6c3c766fdc5cbbf8d8db5834b09ae647b1a8d16d Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 18 May 2016 19:23:38 +0800 Subject: [PATCH 21/41] =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E4=B8=80=E7=82=B9=E5=B0=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/style/background/BackgroundFactory.java | 2 +- .../fr/design/style/background/BackgroundPane4Browser.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java index c44752203..2706f81b1 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java @@ -96,7 +96,7 @@ public class BackgroundFactory { return createByWrapper(wrapper); } - public static BackgroundDetailPane createBrowerIfAbsent(int index) { + public static BackgroundDetailPane createBrowserIfAbsent(int index) { for (BackgroundUIWrapper wrapper : browser.values()) { if (wrapper.getIndex() == index) { return createByWrapper(wrapper); diff --git a/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java b/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java index 490cb82e4..705bbc2de 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java @@ -16,7 +16,7 @@ public class BackgroundPane4Browser extends BackgroundPane { protected void initTabPane() { int index = 0; for (Class key : BackgroundFactory.browserKindsOfKey()) { - BackgroundUIWrapper wrapper = BackgroundFactory.getWrapper(key); + BackgroundUIWrapper wrapper = BackgroundFactory.getBrosweWrapper(key); wrapper.setIndex(index++); tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); } @@ -37,7 +37,7 @@ public class BackgroundPane4Browser extends BackgroundPane { protected BackgroundDetailPane getTabItemPaneByIndex(int index) { BackgroundDetailPane quickPane = cacheMap.get(index); if (quickPane == null) { - quickPane = BackgroundFactory.createBrowerIfAbsent(index); + quickPane = BackgroundFactory.createBrowserIfAbsent(index); tabbedPane.setComponentAt(index, quickPane); cacheMap.put(index, quickPane); quickPane.addChangeListener(backgroundChangeListener); From a5929659051b1b0a56824d5f79c368a7802c36c6 Mon Sep 17 00:00:00 2001 From: fr_shine Date: Thu, 19 May 2016 11:50:31 +0800 Subject: [PATCH 22/41] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/gui/data/table/SeriesNameUseFieldNamePane.java | 6 +++++- .../chart/gui/data/table/SeriesNameUseFieldValuePane.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java index f9258bc81..b8fb5ae74 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java @@ -224,6 +224,10 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane data = seriesDataPane.updateBean(); diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java index a1eed2138..2d5099db4 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java @@ -278,7 +278,7 @@ public class SeriesNameUseFieldValuePane extends FurtherBasicBeanPane Date: Thu, 19 May 2016 18:35:15 +0800 Subject: [PATCH 23/41] =?UTF-8?q?=E5=8A=A0=E4=B8=AA=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java index dd4c8068a..3ed05bdf7 100644 --- a/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java +++ b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java @@ -25,6 +25,6 @@ public interface TableDataPaneProcessor extends Level { * 服务器数据集面板(模板数据集面板) * @return 服务器数据集面板 */ - TableDataPaneController createServerTableDataPane(); + TableDataPaneController createServerTableDataPane(DesignModelAdapter tc); } From e3a8cdd999aa1cf05db368c9c02deea0db3f23d8 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 20 May 2016 09:39:50 +0800 Subject: [PATCH 24/41] =?UTF-8?q?=E5=88=86=E7=BB=84=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=8A=8Aaction=E5=BC=80=E5=87=BA=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/data/datapane/ReportTableDataPane.java | 4 +++- .../tabledata/tabledatapane/TableDataManagerPane.java | 4 +++- .../src/com/fr/design/fun/TableDataPaneProcessor.java | 6 ++++++ .../com/fr/design/mainframe/toolbar/ToolBarMenuDock.java | 8 +++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java index 339a227a4..3b968f205 100644 --- a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java @@ -4,6 +4,7 @@ package com.fr.design.data.datapane; import com.fr.data.TableDataSource; +import com.fr.design.DesignModelAdapter; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.controlpane.NameableCreator; @@ -29,7 +30,8 @@ public class ReportTableDataPane extends LoadingBasicPane { TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); TableDataPaneController pane = null; if (paneProcessor != null) { - pane = paneProcessor.createServerTableDataPane(); + pane = paneProcessor.createServerTableDataPane(DesignModelAdapter.getCurrentModelAdapter() + ); } tdPane = pane == null ? new TableDataPaneListPane() { @Override diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java index b2c8427af..daf2ed1f5 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java @@ -1,6 +1,7 @@ package com.fr.design.data.tabledata.tabledatapane; import com.fr.base.FRContext; +import com.fr.design.DesignModelAdapter; import com.fr.design.ExtraDesignClassManager; import com.fr.design.data.datapane.TableDataPaneController; import com.fr.design.data.datapane.TableDataPaneListPane; @@ -42,7 +43,8 @@ public class TableDataManagerPane extends LoadingBasicPane { TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); TableDataPaneController pane = null; if (paneProcessor != null) { - pane = paneProcessor.createServerTableDataPane(); + pane = paneProcessor.createServerTableDataPane(DesignModelAdapter.getCurrentModelAdapter() + ); } tableDataPane = pane == null ? new TableDataPaneListPane() { public void rename(String oldName, String newName) { diff --git a/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java index 3ed05bdf7..06db5c974 100644 --- a/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java +++ b/designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java @@ -3,6 +3,7 @@ package com.fr.design.fun; import com.fr.design.DesignModelAdapter; import com.fr.design.data.BasicTableDataTreePane; import com.fr.design.data.datapane.TableDataPaneController; +import com.fr.design.menu.ShortCut; import com.fr.stable.fun.Level; /** @@ -27,4 +28,9 @@ public interface TableDataPaneProcessor extends Level { */ TableDataPaneController createServerTableDataPane(DesignModelAdapter tc); + /** + * 自定义服务器数据集菜单项 + * @return + */ + ShortCut createServerTDAction(); } diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index d0ecec9d6..ea8dd28e3 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -28,6 +28,7 @@ import com.fr.design.actions.server.PlatformManagerAction; import com.fr.design.actions.server.PluginManagerAction; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; +import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenu; @@ -263,7 +264,7 @@ public abstract class ToolBarMenuDock { if (!BaseUtils.isAuthorityEditing()) { menuDef.addShortCut( new ConnectionListAction(), - new GlobalTableDataAction() + createGlobalTDAction() ); } @@ -288,6 +289,11 @@ public abstract class ToolBarMenuDock { return menuDef; } + private ShortCut createGlobalTDAction() { + TableDataPaneProcessor processor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); + return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction(); + } + private boolean shouldShowPlugin() { return FRContext.isChineseEnv() || ComparatorUtils.equals(GeneralContext.getLocale(), Locale.TAIWAN); } From 959c9eb30cb067e33dbfa6326dc5f78b5f900977 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 20 May 2016 16:03:07 +0800 Subject: [PATCH 25/41] =?UTF-8?q?=E7=BB=99=E5=86=B3=E7=AD=96=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E5=92=8C=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E7=AD=89=E5=8A=A0=E4=B8=80=E4=B8=AA=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=9B=91=E5=90=AC,=E5=89=A9=E4=B8=8B=E7=9A=84=E4=BB=80?= =?UTF-8?q?=E4=B9=88=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=E7=AD=89=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/fun/ElementUIProvider.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/designer_base/src/com/fr/design/fun/ElementUIProvider.java b/designer_base/src/com/fr/design/fun/ElementUIProvider.java index e52721858..cb960564f 100644 --- a/designer_base/src/com/fr/design/fun/ElementUIProvider.java +++ b/designer_base/src/com/fr/design/fun/ElementUIProvider.java @@ -7,6 +7,7 @@ import com.fr.stable.fun.Level; /** * Created by richie on 16/4/25. + * 单元格元素和悬浮元素扩展,通过实现这个接口,可以在单元格中添加更多类型的元素. */ public interface ElementUIProvider extends Level { @@ -14,13 +15,33 @@ public interface ElementUIProvider extends Level { int CURRENT_LEVEL = 1; + /** + * 单元格元素编辑器 + * @return 编辑器 + */ Class targetCellEditorClass(); + /** + * 单元格内容 + * @return 单元格内容 + */ Class targetObjectClass(); + /** + * 右侧的快速编辑器 + * @return 编辑器 + */ QuickEditor quickEditor(); + /** + * 插件单元格元素 + * @return 插入操作类 + */ Class actionForInsertCellElement(); + /** + * 插入悬浮元素 + * @return 插入操作类 + */ Class actionForInsertFloatElement(); } From 0f54734d5afc7e9ba005c3d6df6e9def8caf5baf Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 20 May 2016 17:21:40 +0800 Subject: [PATCH 26/41] =?UTF-8?q?web=E5=B1=9E=E6=80=A7=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=89=93=E4=B8=8D=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/style/background/BackgroundFactory.java | 2 +- .../src/com/fr/design/style/background/BackgroundPane.java | 6 +++++- .../fr/design/style/background/BackgroundPane4Browser.java | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java index 2706f81b1..6dd04773a 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundFactory.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundFactory.java @@ -87,7 +87,7 @@ public class BackgroundFactory { return browser.keySet(); } - public static BackgroundUIWrapper getBrosweWrapper(Class category) { + public static BackgroundUIWrapper getBrowserWrapper(Class category) { return browser.get(category); } diff --git a/designer_base/src/com/fr/design/style/background/BackgroundPane.java b/designer_base/src/com/fr/design/style/background/BackgroundPane.java index 6a9c3d70f..07a1e2131 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundPane.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundPane.java @@ -117,7 +117,7 @@ public class BackgroundPane extends BasicPane { * Populate background. */ public void populate(Background background) { - BackgroundUIWrapper wrapper = BackgroundFactory.getWrapper(background == null ? null : background.getClass()); + BackgroundUIWrapper wrapper = getBackgroundUIWrapper(background); int index = wrapper.getIndex(); BackgroundDetailPane quickPane = getTabItemPane(background, index); quickPane.populate(background); @@ -126,6 +126,10 @@ public class BackgroundPane extends BasicPane { tabbedPane.validate(); } + protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { + return BackgroundFactory.getWrapper(background == null ? null : background.getClass()); + } + /** * Update background. */ diff --git a/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java b/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java index 705bbc2de..a1f06f065 100644 --- a/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java +++ b/designer_base/src/com/fr/design/style/background/BackgroundPane4Browser.java @@ -16,12 +16,16 @@ public class BackgroundPane4Browser extends BackgroundPane { protected void initTabPane() { int index = 0; for (Class key : BackgroundFactory.browserKindsOfKey()) { - BackgroundUIWrapper wrapper = BackgroundFactory.getBrosweWrapper(key); + BackgroundUIWrapper wrapper = BackgroundFactory.getBrowserWrapper(key); wrapper.setIndex(index++); tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); } } + protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { + return BackgroundFactory.getBrowserWrapper(background == null ? null : background.getClass()); + } + protected BackgroundDetailPane getTabItemPane(Background background, int index) { BackgroundDetailPane quickPane = cacheMap.get(index); if (quickPane == null) { From de842c99a39e330dc270219e1a075c159a93ae05 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 20 May 2016 17:26:32 +0800 Subject: [PATCH 27/41] =?UTF-8?q?=E8=BF=99=E4=B8=AA=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E5=88=A0=E6=8E=89=EF=BC=8C=E4=B8=8D=E9=9C=80=E8=A6=81=E5=81=9A?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=95=B0=E6=8D=AE=E9=9B=86=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/datapane/ReportTableDataPane.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java index 3b968f205..c9279ca42 100644 --- a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java @@ -4,9 +4,6 @@ package com.fr.design.data.datapane; import com.fr.data.TableDataSource; -import com.fr.design.DesignModelAdapter; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.layout.FRGUIPaneFactory; @@ -27,19 +24,13 @@ public class ReportTableDataPane extends LoadingBasicPane { @Override protected void initComponents(JPanel container) { container.setLayout(FRGUIPaneFactory.createBorderLayout()); - TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor(); - TableDataPaneController pane = null; - if (paneProcessor != null) { - pane = paneProcessor.createServerTableDataPane(DesignModelAdapter.getCurrentModelAdapter() - ); - } - tdPane = pane == null ? new TableDataPaneListPane() { + tdPane = new TableDataPaneListPane() { @Override public NameableCreator[] createNameableCreators() { return TableDataCreatorProducer.getInstance().createReportTableDataCreator(); } - } : pane; + }; container.add(tdPane.getPanel(), BorderLayout.CENTER); } From 263a699affa7c5d50b653851c34b2513db58a440 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 20 May 2016 17:27:16 +0800 Subject: [PATCH 28/41] d --- .../src/com/fr/design/data/datapane/ReportTableDataPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java index c9279ca42..d78ce45d7 100644 --- a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java @@ -31,7 +31,7 @@ public class ReportTableDataPane extends LoadingBasicPane { return TableDataCreatorProducer.getInstance().createReportTableDataCreator(); } }; - container.add(tdPane.getPanel(), BorderLayout.CENTER); + container.add(tdPane.getPanel(), BorderLayout.CENTER); } @Override From 5bf2b7faa3508d5a0379d47e1546f4a1970bd5cd Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 20 May 2016 17:29:44 +0800 Subject: [PATCH 29/41] d --- .../src/com/fr/design/data/datapane/ReportTableDataPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java index d78ce45d7..c9279ca42 100644 --- a/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java @@ -31,7 +31,7 @@ public class ReportTableDataPane extends LoadingBasicPane { return TableDataCreatorProducer.getInstance().createReportTableDataCreator(); } }; - container.add(tdPane.getPanel(), BorderLayout.CENTER); + container.add(tdPane.getPanel(), BorderLayout.CENTER); } @Override From e6295278f45261dcb041feaa54b3e18f5afa6459 Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 20 May 2016 17:44:43 +0800 Subject: [PATCH 30/41] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E8=BF=94=E5=9B=9E=E4=B8=80=E4=B8=AA=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=EF=BC=8C=E4=BE=9B=E7=95=8C=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=202=E3=80=81=E6=9B=B4=E6=96=B0=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=BC=B9=E5=87=BA=E4=B8=A4=E4=B8=AA=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 1 + .../design/extra/exe/UninstallExecutor.java | 6 +- .../extra/exe/UpdateOnlineExecutor.java | 112 +++++++++--------- 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 5c7c2e8a3..947104bf9 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -153,6 +153,7 @@ public class PluginWebBridge { * @param des 过滤文件描述 * @param filter 文件的后缀 * @return 选择的文件的路径 + * 这里换用JFileChooser会卡死,不知道为什么 */ public String showFileChooserWithFilter(String des, String filter) { FileChooser fileChooser = new FileChooser(); diff --git a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java index 3f0845a7a..d8fc7d9ec 100644 --- a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java @@ -16,6 +16,7 @@ import javax.swing.*; public class UninstallExecutor implements Executor { private String[] pluginIDs; + private String result = "undo"; public UninstallExecutor(String[] pluginIDs) { this.pluginIDs = pluginIDs; @@ -23,7 +24,7 @@ public class UninstallExecutor implements Executor { @Override public String getTaskFinishMessage() { - return "插件已卸载完毕,重启后生效"; + return result; } @Override @@ -32,7 +33,7 @@ public class UninstallExecutor implements Executor { new Command() { @Override public String getExecuteMessage() { - return "删除成功"; + return null; } @Override @@ -62,6 +63,7 @@ public class UninstallExecutor implements Executor { JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } + result = "done"; if (rv == JOptionPane.OK_OPTION) { RestartHelper.restart(); } diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java index 30fe07896..0d3a03fc1 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java @@ -10,6 +10,7 @@ import com.fr.design.extra.Process; import com.fr.general.Inter; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; +import com.fr.plugin.PluginVerifyException; import com.fr.stable.StringUtils; import javax.swing.*; @@ -43,44 +44,51 @@ public class UpdateOnlineExecutor implements Executor { @Override public void run(Process process) { - if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){ + if (StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())) { LoginCheckContext.fireLoginCheckListener(); } - if(StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())){ - for (int i = 0; i < pluginIDs.length; i++) { - Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); - String id = null; - if (plugin != null) { - id = plugin.getId(); - } - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - try { - PluginHelper.downloadPluginFile(id, username, password, new Process() { - @Override - public void process(Double integer) { + if (StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())) { + try { + for (int i = 0; i < pluginIDs.length; i++) { + try { + Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); + String id = null; + if (plugin != null) { + id = plugin.getId(); + } + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + PluginHelper.downloadPluginFile(id, username, password, new Process() { + @Override + public void process(Double integer) { + } + }); + updateFileFromDisk(PluginHelper.getDownloadTempFile()); + process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); + } catch (Exception e) { + if (e instanceof PluginVerifyException) { + throw (PluginVerifyException) e; } - }); - updateFileFromDisk(PluginHelper.getDownloadTempFile()); - process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FRContext.getLogger().error(e.getMessage()); + } } - } - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Update_Successful"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), - Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") - }, - null - ); - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Update_Successful"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), + Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") + }, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } catch (PluginVerifyException e) { + JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } @@ -88,26 +96,22 @@ public class UpdateOnlineExecutor implements Executor { }; } - private void updateFileFromDisk(File fileOnDisk) { - try { - Plugin plugin = PluginHelper.readPlugin(fileOnDisk); - if (plugin == null) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - return; - } - Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); - if (oldPlugin != null) { - String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); - PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { - @Override - public void done() { - } - }); - } else { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + private void updateFileFromDisk(File fileOnDisk) throws Exception { + Plugin plugin = PluginHelper.readPlugin(fileOnDisk); + if (plugin == null) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + return; + } + Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); + if (oldPlugin != null) { + String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); + PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { + @Override + public void done() { + } + }); + } else { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } From c573179143ccb976891ccc146515bcf492df359a Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 23 May 2016 09:13:05 +0800 Subject: [PATCH 31/41] =?UTF-8?q?catch=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/exe/UpdateOnlineExecutor.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java index 0d3a03fc1..fa295cd36 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java @@ -65,11 +65,10 @@ public class UpdateOnlineExecutor implements Executor { }); updateFileFromDisk(PluginHelper.getDownloadTempFile()); process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); + } catch (PluginVerifyException e) { + throw e; } catch (Exception e) { - if (e instanceof PluginVerifyException) { - throw (PluginVerifyException) e; - } - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } int rv = JOptionPane.showOptionDialog( From a41a51ddaef4bf40563f2e2d655372eee68bfa48 Mon Sep 17 00:00:00 2001 From: xiaohu Date: Mon, 23 May 2016 10:23:32 +0800 Subject: [PATCH 32/41] =?UTF-8?q?=E6=95=B8=E6=93=9A=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MeterPlotReportDataContentPane.java | 30 ++++++++++++++----- .../table/MeterPlotTableDataContentPane.java | 12 +++++--- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java index e4001079b..b785373bc 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java @@ -46,7 +46,7 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan double[] rowSize = { p, p, p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(CATENAME), singCatePane = new TinyFormulaPane()}, + new Component[]{new UILabel(CATENAME), getSingCatePane()}, new Component[]{new UILabel(NVALUE), singValuePane = new TinyFormulaPane()}, new Component[]{null, null} }; @@ -73,7 +73,7 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan MeterReportDefinition meterDefinition = (MeterReportDefinition)definition; if (meterDefinition.getName() != null) { - singCatePane.getUITextField().setText(meterDefinition.getName().toString()); + populateSingCatePane(meterDefinition.getName().toString()); } if (meterDefinition.getValue() != null) { singValuePane.getUITextField().setText(meterDefinition.getValue().toString()); @@ -82,13 +82,18 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan filterPane.populateBean(collection); } - - public void updateBean(ChartCollection collection) { + + protected void populateSingCatePane(String name) { + singCatePane.getUITextField().setText(name); + } + + public void updateBean(ChartCollection collection) { if (collection != null) { MeterReportDefinition meterDefinition = new MeterReportDefinition(); - - meterDefinition.setName(canBeFormula(singCatePane.getUITextField().getText())); + + updateSingCatePane(meterDefinition); + meterDefinition.setValue(canBeFormula(singValuePane.getUITextField().getText())); collection.getSelectedChart().setFilterDefinition(meterDefinition); @@ -96,10 +101,19 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan filterPane.updateBean(collection); } } - - @Override + + protected void updateSingCatePane(MeterReportDefinition meterDefinition) { + + meterDefinition.setName(canBeFormula(singCatePane.getUITextField().getText())); + + } + + @Override protected String[] columnNames() { return new String[]{"", ""}; } + protected Component getSingCatePane() { + return singCatePane = new TinyFormulaPane(); + } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java index 22deb5101..a12f4370a 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java @@ -88,15 +88,15 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane if(ob != null && ob.getSelectedChart().getFilterDefinition() instanceof MeterTableDefinition) { MeterTableDefinition meter = (MeterTableDefinition)ob.getSelectedChart().getFilterDefinition(); - populateNameComponent(meter.getName()); + populateNameComponent(meter); valueBox.setSelectedItem(meter.getValue()); filterPane.populateBean(ob); } } - protected void populateNameComponent(String name) { - nameBox.setSelectedItem(name); + protected void populateNameComponent(MeterTableDefinition meter) { + nameBox.setSelectedItem(meter.getName()); } /** @@ -104,7 +104,7 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane */ public void updateBean(ChartCollection ob) { if(ob != null) { - MeterTableDefinition meter = new MeterTableDefinition(); + MeterTableDefinition meter = getMeterTableDefinition(); ob.getSelectedChart().setFilterDefinition(meter); updateNameComponent(meter); @@ -114,6 +114,10 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane } } + protected MeterTableDefinition getMeterTableDefinition(){ + return new MeterTableDefinition(); + } + protected void updateNameComponent(MeterTableDefinition meter) { meter.setName(Utils.objectToString(nameBox.getSelectedItem())); } From 51bdaf47b6150f2155ab611c97b2bac6178f2a1f Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 24 May 2016 12:10:04 +0800 Subject: [PATCH 33/41] =?UTF-8?q?=E6=97=A0=E7=AA=97=E5=8F=A3=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginShopDialog.java | 10 ++++++++-- .../src/com/fr/design/extra/PluginWebBridge.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginShopDialog.java b/designer_base/src/com/fr/design/extra/PluginShopDialog.java index 01e966116..f2e1e93ec 100644 --- a/designer_base/src/com/fr/design/extra/PluginShopDialog.java +++ b/designer_base/src/com/fr/design/extra/PluginShopDialog.java @@ -4,17 +4,23 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; +import javafx.embed.swing.JFXPanel; +import javax.swing.*; import java.awt.*; /** * Created by vito on 16/4/18. */ public class PluginShopDialog extends UIDialog { - private static final Dimension DEFAULT_SHOP = new Dimension(900, 684); + private static final Dimension DEFAULT_SHOP = new Dimension(900, 700); public PluginShopDialog(Frame frame, BasicPane pane) { - super(frame, pane, false); + super(frame); + setUndecorated(true); + JPanel panel = (JPanel) getContentPane(); + panel.setLayout(new BorderLayout()); + add(pane, BorderLayout.CENTER); setSize(DEFAULT_SHOP); GUICoreUtils.centerWindow(this); setResizable(false); diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 947104bf9..07d37b86a 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -285,6 +285,16 @@ public class PluginWebBridge { } } + /** + * 窗口是否无装饰(判断是否使用系统标题栏) + */ + public boolean isCustomTitleBar() { + if (uiDialog != null) { + return uiDialog.isUndecorated(); + } + return false; + } + /** * 在本地浏览器里打开url * tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑) From 94dd5950dbf2c7103342f5d453f9fb4f557d9e87 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Tue, 24 May 2016 23:32:44 +0800 Subject: [PATCH 34/41] rt --- designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 27c2c1ec0..80f40cadf 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ReportWebWidgetConstants; import com.fr.design.webattr.ToolBarButton; import com.fr.design.webattr.ToolBarPane; import com.fr.form.ui.Button; import com.fr.form.ui.ToolBar; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.main.TemplateWorkBook; import com.fr.report.web.Location; import com.fr.report.web.ToolBarManager; import com.fr.report.web.WebContent; import com.fr.base.ConfigManagerProvider; import com.fr.stable.ArrayUtils; import com.fr.web.attr.ReportWebAttr; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.List; /** * Author : daisy * Date: 13-9-9 * Time: 下午4:58 */ public class AuthorityToolBarPane extends BasicBeanPane implements AuthorityEditToolBarComponent { private static final int SMALL_GAP = 13; private static final int GAP = 25; private static final int PRE_GAP = 9; private static final int COMBOX_WIDTH = 144; private static final String[] CHOOSEITEM = new String[]{Inter.getLocText("M-Page_Preview"), Inter.getLocText(new String[]{"Face_Write", "PageSetup-Page"}), Inter.getLocText("M-Data_Analysis")}; private UIComboBox choseComboBox; private ToolBarPane toolBarPane; private AuthorityEditToolBarPane authorityEditToolBarPane = null; private int selectedIndex = -1; private UILabel title = null; private MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (!toolBarPane.isEnabled()) { return; } java.util.List buttonlists = toolBarPane.getToolBarButtons(); int oldIndex = selectedIndex; selectedIndex = pressButtonIndex(e, buttonlists); //实现shift多选 if (e.isShiftDown()) { if (oldIndex == -1) { removeSelection(); ((ToolBarButton) e.getSource()).setSelected(true); } else { int max = oldIndex >= selectedIndex ? oldIndex : selectedIndex; int min = oldIndex <= selectedIndex ? oldIndex : selectedIndex; for (int i = min; i <= max; i++) { buttonlists.get(i).setSelected(true); } } } else if (!e.isControlDown()) { //实现单选 removeSelection(); if (selectedIndex != -1) { ((ToolBarButton) e.getSource()).setSelected(true); } } authorityEditToolBarPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); } }; private int pressButtonIndex(MouseEvent e, java.util.List buttonlists) { if (!(e.getSource() instanceof ToolBarButton)) { return -1; } ToolBarButton button = (ToolBarButton) e.getSource(); for (int i = 0; i < buttonlists.size(); i++) { if (ComparatorUtils.equals(button, buttonlists.get(i))) { return i; } } return -1; } /** * 去掉选择 */ public void removeSelection() { for (ToolBarButton button : toolBarPane.getToolBarButtons()) { button.setSelected(false); } } private ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { selectedIndex = -1; populateToolBarPane(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(AuthorityToolBarPane.this); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); } } }; public AuthorityToolBarPane() { this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 3)); this.setBorder(BorderFactory.createEmptyBorder(0, PRE_GAP, 0, 0)); title = new UILabel(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Choose_Role"})); title.setHorizontalAlignment(SwingConstants.CENTER); this.add(title, 0); choseComboBox = new UIComboBox(CHOOSEITEM) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = COMBOX_WIDTH; return dim; } }; choseComboBox.addItemListener(itemListener); //默认选择第一个 choseComboBox.setSelectedIndex(0); this.add(createGapPanel(SMALL_GAP)); this.add(choseComboBox); toolBarPane = new ToolBarPane(); toolBarPane.setBorder(null); toolBarPane.removeDefaultMouseListener(); this.add(createGapPanel(GAP)); this.add(toolBarPane); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(this); checkToolBarPaneEnable(); } private JPanel createGapPanel(final int gap) { return new JPanel() { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = gap; return dim; } }; } private void populateToolBarPane() { toolBarPane.removeAll(); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); toolBarPane.repaint(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); checkToolBarPaneEnable(); } /** * 使用普通用户远程设计时,如果工具栏使用的是“采用服务器设置”,则工具栏按钮为灰不可用 */ private void checkToolBarPaneEnable() { List toolBarButtons = toolBarPane.getToolBarButtons(); boolean isnotEnable = ComparatorUtils.equals(title.getText(), Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})) && !FRContext.getCurrentEnv().isRoot(); for (ToolBarButton button : toolBarButtons) { button.setEnabled(!isnotEnable); } toolBarPane.setEnabled(!isnotEnable); } /** * 更新权限工具栏面板 */ public void populateAuthority() { toolBarPane.repaint(); } private ReportWebAttr getReportWebAttr() { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return null; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); return wbTpl.getReportWebAttr(); } //将该报表的设置过权限的属性记录一下 public void setAuthorityWebAttr(Widget widget, boolean isSelected, String selectedRole) { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); ReportWebAttr rw = wbTpl.getReportWebAttr(); ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); //wbTpl.clear先清空 //再将所有的保存进去 //看是存在服务器还存在模板里面 if (choseComboBox.getSelectedIndex() == 0) { //分页 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebPage(), widget, isSelected, selectedRole); } } else if (choseComboBox.getSelectedIndex() == 1) { //填报 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebWrite(), widget, isSelected, selectedRole); } } else { //view if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebView(), widget, isSelected, selectedRole); } } try { FRContext.getCurrentEnv().writeResource(cm); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } private void dealWithWebContent(WebContent wc, Widget widget, boolean isSelected, String selectedRole) { ToolBarManager[] managers = wc.getToolBarManagers(); if (managers == null) { return; } for (int i = 0; i < managers.length; i++) { ToolBar tb = managers[i].getToolBar(); for (int j = 0; j < tb.getWidgetSize(); j++) { if (widget instanceof Button && tb.getWidget(j) instanceof Button) { if (ComparatorUtils.equals(((Button) widget).getIconName(), ((Button) tb.getWidget(j)).getIconName())) { if (!isSelected) { tb.getWidget(j).getWidgetPrivilegeControl().addInvisibleRole(selectedRole); } else { tb.getWidget(j).getWidgetPrivilegeControl().removeInvisibleRole(selectedRole); } } } } } wc.setToolBarManagers(managers); } public void populateBean(ReportWebAttr reportWebAttr) { this.remove(title); // 如果是空值就说明采用服务器配置了 if (reportWebAttr == null || this.getWebContent(reportWebAttr) == null) { title = new UILabel(Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})); populateServerSettings(); this.add(title, 0); return; } // 模板设置 T webContent = this.getWebContent(reportWebAttr); title = new UILabel(Inter.getLocText(new String[]{"the_template", "ReportServerP-Toolbar", "Choose_Role"})); this.add(title, 0); populate(webContent.getToolBarManagers()); } public ReportWebAttr updateBean() { return null; } public void populate(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } if (toolBarManager.length == 0) { return; } for (int i = 0; i < toolBarManager.length; i++) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.height = ToolBarMenuDock.PANLE_HEIGNT; return dim; } public void populateBean(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } for (int i = 0; i < toolBarManager.length; i++) { Location location = toolBarManager[i].getToolBarLocation(); if (location instanceof Location.Embed) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } } private void populateServerSettings() { ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); if (this.getWebContent(webAttr) != null) { populate(this.getWebContent(webAttr).getToolBarManagers()); } } protected String title4PopupWindow() { return null; } private T getWebContent(ReportWebAttr reportWebAttr) { if (choseComboBox.getSelectedIndex() == 0) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebPage(); } else if (choseComboBox.getSelectedIndex() == 1) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebWrite(); } else { return reportWebAttr == null ? null : (T) reportWebAttr.getWebView(); } } private void populateDefaultToolBarWidgets() { if (choseComboBox.getSelectedIndex() == 0) { ReportWebWidgetConstants.getPageToolBarInstance(); } else if (choseComboBox.getSelectedIndex() == 1) { ReportWebWidgetConstants.getWriteToolBarInstance(); } else { ReportWebWidgetConstants.getViewToolBarInstance(); } } private ToolBarManager getDefaultToolBarManager() { if (choseComboBox.getSelectedIndex() == 0) { return ToolBarManager.createDefaultToolBar(); } else if (choseComboBox.getSelectedIndex() == 1) { return ToolBarManager.createDefaultWriteToolBar(); } else { return ToolBarManager.createDefaultViewToolBar(); } } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.base.ConfigManager; import com.fr.base.ConfigManagerProvider; import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ReportWebWidgetConstants; import com.fr.design.webattr.ToolBarButton; import com.fr.design.webattr.ToolBarPane; import com.fr.form.ui.Button; import com.fr.form.ui.ToolBar; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.main.TemplateWorkBook; import com.fr.report.web.Location; import com.fr.report.web.ToolBarManager; import com.fr.report.web.WebContent; import com.fr.stable.ArrayUtils; import com.fr.web.attr.ReportWebAttr; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.List; /** * Author : daisy * Date: 13-9-9 * Time: 下午4:58 */ public class AuthorityToolBarPane extends BasicBeanPane implements AuthorityEditToolBarComponent { private static final int SMALL_GAP = 13; private static final int GAP = 25; private static final int PRE_GAP = 9; private static final int COMBOX_WIDTH = 144; private static final String[] CHOOSEITEM = new String[]{Inter.getLocText("M-Page_Preview"), Inter.getLocText(new String[]{"Face_Write", "PageSetup-Page"}), Inter.getLocText("M-Data_Analysis")}; private UIComboBox choseComboBox; private ToolBarPane toolBarPane; private AuthorityEditToolBarPane authorityEditToolBarPane = null; private int selectedIndex = -1; private UILabel title = null; private MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (!toolBarPane.isEnabled()) { return; } java.util.List buttonlists = toolBarPane.getToolBarButtons(); int oldIndex = selectedIndex; selectedIndex = pressButtonIndex(e, buttonlists); //实现shift多选 if (e.isShiftDown()) { if (oldIndex == -1) { removeSelection(); ((ToolBarButton) e.getSource()).setSelected(true); } else { int max = oldIndex >= selectedIndex ? oldIndex : selectedIndex; int min = oldIndex <= selectedIndex ? oldIndex : selectedIndex; for (int i = min; i <= max; i++) { buttonlists.get(i).setSelected(true); } } } else if (!e.isControlDown()) { //实现单选 removeSelection(); if (selectedIndex != -1) { ((ToolBarButton) e.getSource()).setSelected(true); } } authorityEditToolBarPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); } }; private int pressButtonIndex(MouseEvent e, java.util.List buttonlists) { if (!(e.getSource() instanceof ToolBarButton)) { return -1; } ToolBarButton button = (ToolBarButton) e.getSource(); for (int i = 0; i < buttonlists.size(); i++) { if (ComparatorUtils.equals(button, buttonlists.get(i))) { return i; } } return -1; } /** * 去掉选择 */ public void removeSelection() { for (ToolBarButton button : toolBarPane.getToolBarButtons()) { button.setSelected(false); } } private ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { selectedIndex = -1; populateToolBarPane(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(AuthorityToolBarPane.this); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); } } }; public AuthorityToolBarPane() { this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 3)); this.setBorder(BorderFactory.createEmptyBorder(0, PRE_GAP, 0, 0)); title = new UILabel(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Choose_Role"})); title.setHorizontalAlignment(SwingConstants.CENTER); this.add(title, 0); choseComboBox = new UIComboBox(CHOOSEITEM) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = COMBOX_WIDTH; return dim; } }; choseComboBox.addItemListener(itemListener); //默认选择第一个 choseComboBox.setSelectedIndex(0); this.add(createGapPanel(SMALL_GAP)); this.add(choseComboBox); toolBarPane = new ToolBarPane(); toolBarPane.setBorder(null); toolBarPane.removeDefaultMouseListener(); this.add(createGapPanel(GAP)); this.add(toolBarPane); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(this); checkToolBarPaneEnable(); } private JPanel createGapPanel(final int gap) { return new JPanel() { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = gap; return dim; } }; } private void populateToolBarPane() { toolBarPane.removeAll(); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); toolBarPane.repaint(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); checkToolBarPaneEnable(); } /** * 使用普通用户远程设计时,如果工具栏使用的是“采用服务器设置”,则工具栏按钮为灰不可用 */ private void checkToolBarPaneEnable() { List toolBarButtons = toolBarPane.getToolBarButtons(); boolean isnotEnable = ComparatorUtils.equals(title.getText(), Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})) && !FRContext.getCurrentEnv().isRoot(); for (ToolBarButton button : toolBarButtons) { button.setEnabled(!isnotEnable); } toolBarPane.setEnabled(!isnotEnable); } /** * 更新权限工具栏面板 */ public void populateAuthority() { toolBarPane.repaint(); } private ReportWebAttr getReportWebAttr() { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return null; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); return wbTpl.getReportWebAttr(); } //将该报表的设置过权限的属性记录一下 public void setAuthorityWebAttr(Widget widget, boolean isSelected, String selectedRole) { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); ReportWebAttr rw = wbTpl.getReportWebAttr(); ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); //wbTpl.clear先清空 //再将所有的保存进去 //看是存在服务器还存在模板里面 if (choseComboBox.getSelectedIndex() == 0) { //分页 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebPage(), widget, isSelected, selectedRole); } } else if (choseComboBox.getSelectedIndex() == 1) { //填报 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebWrite(), widget, isSelected, selectedRole); } } else { //view if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebView(), widget, isSelected, selectedRole); } } } private void dealWithWebContent(WebContent wc, Widget widget, boolean isSelected, String selectedRole) { ToolBarManager[] managers = wc.getToolBarManagers(); if (managers == null) { return; } for (int i = 0; i < managers.length; i++) { ToolBar tb = managers[i].getToolBar(); for (int j = 0; j < tb.getWidgetSize(); j++) { if (widget instanceof Button && tb.getWidget(j) instanceof Button) { if (ComparatorUtils.equals(((Button) widget).getIconName(), ((Button) tb.getWidget(j)).getIconName())) { if (!isSelected) { tb.getWidget(j).getWidgetPrivilegeControl().addInvisibleRole(selectedRole); } else { tb.getWidget(j).getWidgetPrivilegeControl().removeInvisibleRole(selectedRole); } } } } } wc.setToolBarManagers(managers); } public void populateBean(ReportWebAttr reportWebAttr) { this.remove(title); // 如果是空值就说明采用服务器配置了 if (reportWebAttr == null || this.getWebContent(reportWebAttr) == null) { title = new UILabel(Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})); populateServerSettings(); this.add(title, 0); return; } // 模板设置 T webContent = this.getWebContent(reportWebAttr); title = new UILabel(Inter.getLocText(new String[]{"the_template", "ReportServerP-Toolbar", "Choose_Role"})); this.add(title, 0); populate(webContent.getToolBarManagers()); } public ReportWebAttr updateBean() { return null; } public void populate(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } if (toolBarManager.length == 0) { return; } for (int i = 0; i < toolBarManager.length; i++) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.height = ToolBarMenuDock.PANLE_HEIGNT; return dim; } public void populateBean(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } for (int i = 0; i < toolBarManager.length; i++) { Location location = toolBarManager[i].getToolBarLocation(); if (location instanceof Location.Embed) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } } private void populateServerSettings() { ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); if (this.getWebContent(webAttr) != null) { populate(this.getWebContent(webAttr).getToolBarManagers()); } } protected String title4PopupWindow() { return null; } private T getWebContent(ReportWebAttr reportWebAttr) { if (choseComboBox.getSelectedIndex() == 0) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebPage(); } else if (choseComboBox.getSelectedIndex() == 1) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebWrite(); } else { return reportWebAttr == null ? null : (T) reportWebAttr.getWebView(); } } private void populateDefaultToolBarWidgets() { if (choseComboBox.getSelectedIndex() == 0) { ReportWebWidgetConstants.getPageToolBarInstance(); } else if (choseComboBox.getSelectedIndex() == 1) { ReportWebWidgetConstants.getWriteToolBarInstance(); } else { ReportWebWidgetConstants.getViewToolBarInstance(); } } private ToolBarManager getDefaultToolBarManager() { if (choseComboBox.getSelectedIndex() == 0) { return ToolBarManager.createDefaultToolBar(); } else if (choseComboBox.getSelectedIndex() == 1) { return ToolBarManager.createDefaultWriteToolBar(); } else { return ToolBarManager.createDefaultViewToolBar(); } } } \ No newline at end of file From e681fde3c279cf9253638b25a1817c1b36962a6d Mon Sep 17 00:00:00 2001 From: fr_shine Date: Thu, 26 May 2016 14:22:46 +0800 Subject: [PATCH 35/41] api level --- .../src/com/fr/design/chart/fun/IndependentChartUIProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java b/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java index e2afed994..a91914396 100644 --- a/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java +++ b/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java @@ -22,7 +22,7 @@ public interface IndependentChartUIProvider extends Level { String XML_TAG = "IndependentChartUIProvider"; - int CURRENT_API_LEVEL = 2; + int CURRENT_API_LEVEL = 3; /** * 图表的类型定义界面类型,就是属性表的第一个界面 From e4588625d90632b435a89b3c29df6151fa51f2b9 Mon Sep 17 00:00:00 2001 From: fr_shine Date: Thu, 26 May 2016 19:36:12 +0800 Subject: [PATCH 36/41] old plugin level --- .../fun/impl/AbstractIndependentChartUIWithAPILevel.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java index b1361b21f..ffe91cd0d 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java @@ -15,9 +15,13 @@ import com.fr.general.ComparatorUtils; * Created by Mitisky on 16/3/7. */ public abstract class AbstractIndependentChartUIWithAPILevel implements IndependentChartUIProvider { + private static final int OLD_PLUGIN_LEVEL = -2; + @Override + //以前的插件没有覆写这个方法,所以始终获取到-2,比当前level低,提示更新. + //新的插件编译进去的是当前LEVEL,当之后LEVEL增加,会比编译进去的LEVEL大,提示更新. public int currentAPILevel() { - return CURRENT_API_LEVEL; + return OLD_PLUGIN_LEVEL; } public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ From 0df8ff6097be91efefdc4a20546fc60325104016 Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 27 May 2016 14:40:52 +0800 Subject: [PATCH 37/41] =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/report/mobile/MobileRadioGroupPane.java | 4 ++-- .../src/com/fr/design/report/mobile/ReportMobileAttrPane.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java index 85cee58e8..9e6638926 100644 --- a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -1,11 +1,11 @@ package com.fr.design.report.mobile; +import com.fr.base.mobile.MobileFitAttrState; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.base.mobile.MobileFitAttrState; import com.fr.stable.StringUtils; import javax.swing.*; @@ -17,7 +17,7 @@ import java.util.List; /** * Created by Administrator on 2016/5/16/0016. */ -public class MobileRadioGroupPane extends BasicBeanPane{ +public class MobileRadioGroupPane extends BasicBeanPane { private List radioButtons = new ArrayList(); diff --git a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java index 67f0ab825..1cd04e8d0 100644 --- a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java +++ b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java @@ -1,10 +1,10 @@ package com.fr.design.report.mobile; +import com.fr.base.mobile.MobileFitAttrState; import com.fr.design.beans.BasicBeanPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.Inter; import com.fr.report.mobile.ElementCaseMobileAttr; -import com.fr.base.mobile.MobileFitAttrState; import javax.swing.*; import java.awt.*; @@ -12,7 +12,7 @@ import java.awt.*; /** * Created by Administrator on 2016/5/12/0012. */ -public class ReportMobileAttrPane extends BasicBeanPane{ +public class ReportMobileAttrPane extends BasicBeanPane { //横屏设置面板 private MobileRadioGroupPane horizionPane; From 9e607e097c683cdf2707ed181eb466343511d5a7 Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 27 May 2016 15:23:07 +0800 Subject: [PATCH 38/41] =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ExtraDesignClassManager.java | 97 +++++++------------ .../mobile/ElementCasePropertyTable.java | 2 +- .../mobile/ElementCasePropertyUI.java | 2 +- .../mobile/MobileFitAlignmentItems.java | 2 +- .../properties/mobile/MobileFitEditor.java | 2 +- .../properties/mobile/MobileFitRender.java | 2 +- .../properties/mobile/MobileFitWrapper.java | 2 +- .../design/gui/xtable/PropertyGroupModel.java | 88 ++++++++--------- 8 files changed, 86 insertions(+), 111 deletions(-) diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index f191827c5..009cff1c6 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -126,11 +126,13 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private DesignerEnvProcessor envProcessor; - private TableDataPaneProcessor tableDataPaneProcessor; + private TableDataTreePaneProcessor tableDataTreePaneProcessor; private Set elementUIProviders; - private Set widgetAttrProviders; + private Set widgetAttrProviders; + + private Set exportAttrTabProviders; private WidgetDesignHandler widgetDesignHandler; @@ -142,17 +144,13 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi widgetDesignHandler = (WidgetDesignHandler) level; } - private Set backgroundQuickUIProviders; - - private Set backgroundUIProviders; - - public TableDataPaneProcessor getTableDataPaneProcessor() { - return tableDataPaneProcessor; + public TableDataTreePaneProcessor getTableDataTreePaneProcessor() { + return tableDataTreePaneProcessor; } - public void setTableDataPaneProcessor(Level level, PluginSimplify simplify) { - validAPILevel(level, TableDataPaneProcessor.CURRENT_LEVEL, simplify.getPluginName()); - tableDataPaneProcessor = (TableDataPaneProcessor) level; + public void setTableDataSourceOPProcessor(Level level, PluginSimplify simplify) { + validAPILevel(level, TableDataTreePaneProcessor.CURRENT_LEVEL, simplify.getPluginName()); + tableDataTreePaneProcessor = (TableDataTreePaneProcessor) level; } public DesignerEnvProcessor getEnvProcessor() { @@ -752,49 +750,19 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi elementUIProviders.add((ElementUIProvider) level); } - public WidgetAttrProvider[] getWidgetAttrProviders() { + public WidgetPropertyUIProvider[] getWidgetAttrProviders() { if (widgetAttrProviders == null) { - return new WidgetAttrProvider[0]; + return new WidgetPropertyUIProvider[0]; } - return widgetAttrProviders.toArray(new WidgetAttrProvider[widgetAttrProviders.size()]); + return widgetAttrProviders.toArray(new WidgetPropertyUIProvider[widgetAttrProviders.size()]); } public void addWidgetAttrProvider(Level level, PluginSimplify simplify) throws Exception { if (widgetAttrProviders == null) { - widgetAttrProviders = new HashSet(); - } - validAPILevel(level, WidgetAttrProvider.CURRENT_LEVEL, simplify.getPluginName()); - widgetAttrProviders.add((WidgetAttrProvider) level); - } - - public BackgroundQuickUIProvider[] getBackgroundQuickUIProviders() { - if (backgroundQuickUIProviders == null) { - return new BackgroundQuickUIProvider[0]; - } - return backgroundQuickUIProviders.toArray(new BackgroundQuickUIProvider[backgroundQuickUIProviders.size()]); - } - - public void addBackgroundQuickUIProvider(Level level, PluginSimplify simplify) throws Exception { - if (backgroundQuickUIProviders == null) { - backgroundQuickUIProviders = new HashSet<>(); - } - validAPILevel(level, BackgroundQuickUIProvider.CURRENT_LEVEL, simplify.getPluginName()); - backgroundQuickUIProviders.add((BackgroundQuickUIProvider) level); - } - - public BackgroundUIProvider[] getBackgroundUIProviders() { - if (backgroundUIProviders == null) { - return new BackgroundUIProvider[0]; - } - return backgroundUIProviders.toArray(new BackgroundUIProvider[backgroundUIProviders.size()]); - } - - public void addBackgroundUIProvider(Level level, PluginSimplify simplify) throws Exception { - if (backgroundUIProviders == null) { - backgroundUIProviders = new HashSet<>(); + widgetAttrProviders = new HashSet(); } - validAPILevel(level, BackgroundUIProvider.CURRENT_LEVEL, simplify.getPluginName()); - backgroundUIProviders.add((BackgroundUIProvider) level); + validAPILevel(level, WidgetPropertyUIProvider.CURRENT_LEVEL, simplify.getPluginName()); + widgetAttrProviders.add((WidgetPropertyUIProvider) level); } /** @@ -851,8 +819,6 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi readWidgetRelated(tagName, impl, simplify); //数据集, 数据连接 readTableDataRelated(tagName, className, simplify); - // 样式相关的 - readStyleRelated(tagName, impl, simplify); if (tagName.equals(ParameterWidgetOptionProvider.XML_TAG)) { addParameterWidgetOption(impl, simplify); } else if (tagName.equals(PreviewProvider.MARK_STRING)) { @@ -887,14 +853,16 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi addSupportDesignApps(impl, simplify); } else if (tagName.equals(DesignerEnvProcessor.XML_TAG)) { setEnvProcessor(impl, simplify); - } else if (tagName.equals(TableDataPaneProcessor.XML_TAG)) { - setTableDataPaneProcessor(impl, simplify); + } else if (tagName.equals(TableDataTreePaneProcessor.XML_TAG)) { + setTableDataSourceOPProcessor(impl, simplify); } else if (tagName.equals(ElementUIProvider.MARK_STRING)) { addElementUIProvider(impl, simplify); - } else if (tagName.equals(WidgetAttrProvider.XML_TAG)) { - addWidgetAttrProvider(impl, simplify); } else if (tagName.equals(WidgetDesignHandler.XML_TAG)) { setWidgetDesignHandler(impl, simplify); + }else if (tagName.equals(WidgetPropertyUIProvider.XML_TAG)) { + addWidgetAttrProvider(impl, simplify); + } else if (tagName.equals(ExportAttrTabProvider.XML_TAG)) { + addExportAttrTabProvider(impl, simplify); } } catch (PluginInvalidLevelException e) { PluginMessage.remindUpdate(e.getMessage()); @@ -903,6 +871,21 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi } } + public ExportAttrTabProvider[] getExportAttrTabProviders() { + if (exportAttrTabProviders == null) { + return new ExportAttrTabProvider[0]; + } + return exportAttrTabProviders.toArray(new ExportAttrTabProvider[exportAttrTabProviders.size()]); + } + + public void addExportAttrTabProvider(Level level, PluginSimplify simplify) throws Exception { + if (exportAttrTabProviders == null) { + exportAttrTabProviders = new HashSet(); + } + validAPILevel(level, ExportAttrTabProvider.CURRENT_LEVEL, simplify.getPluginName()); + exportAttrTabProviders.add((ExportAttrTabProvider) level); + } + private void readTableDataRelated(String tagName, String className, PluginSimplify simplify) { if (tagName.equals(TableDataCreatorProvider.XML_TAG)) { setTableDataCreatorProvider(className); @@ -927,14 +910,6 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi } } - private void readStyleRelated(String tagName, Level impl, PluginSimplify simplify) throws Exception { - if (tagName.equals(BackgroundQuickUIProvider.MARK_STRING)) { - addBackgroundQuickUIProvider(impl, simplify); - } else if (tagName.equals(BackgroundUIProvider.MARK_STRING)) { - addBackgroundUIProvider(impl, simplify); - } - } - /** * 写xml * diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java index 7e37fefc3..06e2a520e 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java @@ -18,7 +18,7 @@ import java.util.ArrayList; /** * Created by Administrator on 2016/5/16/0016. */ -public class ElementCasePropertyTable extends AbstractPropertyTable{ +public class ElementCasePropertyTable extends AbstractPropertyTable { private XCreator xCreator; private FormDesigner designer; diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java index 5e7721a2e..ac0ba0094 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java @@ -9,7 +9,7 @@ import com.fr.general.Inter; /** * Created by Administrator on 2016/5/16/0016. */ -public class ElementCasePropertyUI extends AbstractWidgetPropertyUIProvider{ +public class ElementCasePropertyUI extends AbstractWidgetPropertyUIProvider { private XCreator xCreator; diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java index 094249bf5..552589b71 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java @@ -4,7 +4,7 @@ import com.fr.base.mobile.MobileFitAttrState; import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.ItemProvider; -public class MobileFitAlignmentItems implements ItemProvider{ +public class MobileFitAlignmentItems implements ItemProvider { private static Item[] VALUE_ITEMS; diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java index 6591b9059..97c6938fc 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java @@ -6,7 +6,7 @@ import com.fr.design.mainframe.widget.editors.ComboEditor; import java.util.Vector; -public class MobileFitEditor extends ComboEditor{ +public class MobileFitEditor extends ComboEditor { public MobileFitEditor() { this(new MobileFitAlignmentItems()); } diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java index 6f560e4e3..e8932459b 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java @@ -2,7 +2,7 @@ package com.fr.design.designer.properties.mobile; import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; -public class MobileFitRender extends EncoderCellRenderer{ +public class MobileFitRender extends EncoderCellRenderer { public MobileFitRender(){ super(new MobileFitWrapper()); diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java index 164bcc5c0..2e4c219b9 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java @@ -2,7 +2,7 @@ package com.fr.design.designer.properties.mobile; import com.fr.design.designer.properties.ItemWrapper; -public class MobileFitWrapper extends ItemWrapper{ +public class MobileFitWrapper extends ItemWrapper { public MobileFitWrapper(){ super(new MobileFitAlignmentItems()); } diff --git a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java index 143176553..8e8cadad1 100644 --- a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java +++ b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java @@ -17,16 +17,16 @@ import java.lang.reflect.Method; import java.util.ArrayList; public class PropertyGroupModel extends AbstractPropertyGroupModel { - - private FormDesigner designer; + + private FormDesigner designer; public PropertyGroupModel(String name, XCreator creator, CRPropertyDescriptor[] propArray, - FormDesigner designer) { - super(name, creator, propArray); - this.designer = designer; - } + FormDesigner designer) { + super(name, creator, propArray); + this.designer = designer; + } - @Override + @Override public Object getValue(int row, int column) { if (column == 0) { return properties[row].getDisplayName(); @@ -49,9 +49,9 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel { try { Method m = properties[row].getWriteMethod(); m.invoke(dealCreatorData(), value); - //属性名称为控件名时,单独处理下 + //属性名称为控件名时,单独处理下 if(ComparatorUtils.equals(FormConstants.NAME, properties[row].getName())){ - creator.resetCreatorName(value.toString()); + creator.resetCreatorName(value.toString()); } properties[row].firePropertyChanged(); return true; @@ -103,49 +103,49 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel { PROPERTIES.add("Properties"); PROPERTIES.add("Others"); } - + /** * 控件属性赋值和取值时,针对scale和title做下处理 * @return */ private Object dealCreatorData() { - return creator.getPropertyDescriptorCreator().toData(); + return creator.getPropertyDescriptorCreator().toData(); } - - @Override - protected void initEditor(final int row) throws Exception { - ExtendedPropertyEditor editor = (ExtendedPropertyEditor) properties[row].createPropertyEditor(dealCreatorData()); - if (editor == null) { - Class propType = properties[row].getPropertyType(); - editor = TableUtils.getPropertyEditorClass(propType).newInstance(); - } - if (editor != null) { - final ExtendedPropertyEditor extendEditor = editor; - editors[row] = new PropertyCellEditor(editor); - extendEditor.addPropertyChangeListener(new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if(ComparatorUtils.equals(extendEditor.getValue(),getValue(row,1))) { - return; - } - if (extendEditor.refreshInTime()) { - editors[row].stopCellEditing(); - } else { - setValue(extendEditor.getValue(), row, 1); + + @Override + protected void initEditor(final int row) throws Exception { + ExtendedPropertyEditor editor = (ExtendedPropertyEditor) properties[row].createPropertyEditor(dealCreatorData()); + if (editor == null) { + Class propType = properties[row].getPropertyType(); + editor = TableUtils.getPropertyEditorClass(propType).newInstance(); + } + if (editor != null) { + final ExtendedPropertyEditor extendEditor = editor; + editors[row] = new PropertyCellEditor(editor); + extendEditor.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if(ComparatorUtils.equals(extendEditor.getValue(),getValue(row,1))) { + return; + } + if (extendEditor.refreshInTime()) { + editors[row].stopCellEditing(); + } else { + setValue(extendEditor.getValue(), row, 1); if (designer == null) { return; } - if ("widgetName".equals(properties[row].getName())) { - designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RENAMED); - } else { - designer.fireTargetModified(); - } - designer.refreshDesignerUI(); - } - } - }); - } - } + if ("widgetName".equals(properties[row].getName())) { + designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RENAMED); + } else { + designer.fireTargetModified(); + } + designer.refreshDesignerUI(); + } + } + }); + } + } } \ No newline at end of file From b5588b54d37a1f82ab732c235ebf084e93319d12 Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 27 May 2016 15:23:44 +0800 Subject: [PATCH 39/41] 1 --- .../src/com/fr/design/gui/xtable/PropertyGroupModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java index 8e8cadad1..8918d857d 100644 --- a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java +++ b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java @@ -105,7 +105,7 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel { } /** - * 控件属性赋值和取值时,针对scale和title做下处理 + * 控件属性赋值和取值时,针对scale和title做下处理 * @return */ private Object dealCreatorData() { From b1c040aff4e7f7f63c33a227ce20cb6b21b4f064 Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 27 May 2016 15:23:53 +0800 Subject: [PATCH 40/41] 1 --- .../src/com/fr/design/gui/xtable/PropertyGroupModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java index 8918d857d..8e8cadad1 100644 --- a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java +++ b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java @@ -105,7 +105,7 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel { } /** - * 控件属性赋值和取值时,针对scale和title做下处理 + * 控件属性赋值和取值时,针对scale和title做下处理 * @return */ private Object dealCreatorData() { From 8ce32a4fffdb348e71f7a1d186a62245713b1d5c Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 27 May 2016 15:51:20 +0800 Subject: [PATCH 41/41] 1 --- .../src/com/fr/design/condition/LiteConditionPane.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer_base/src/com/fr/design/condition/LiteConditionPane.java b/designer_base/src/com/fr/design/condition/LiteConditionPane.java index 5c5eea0ff..a32a11239 100644 --- a/designer_base/src/com/fr/design/condition/LiteConditionPane.java +++ b/designer_base/src/com/fr/design/condition/LiteConditionPane.java @@ -517,6 +517,8 @@ public abstract class LiteConditionPane extends BasicBeanPa // formulaPane JPanel formulaPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // 95106 公式区域限定宽高, 显示两行即可, 在新窗口编辑. + formulaPane.setPreferredSize(new Dimension(450, 40)); formulaConditionPane.add(formulaPane, BorderLayout.CENTER); formulaPane.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 2)); formulaPane.add(GUICoreUtils.createBorderPane(new UILabel(Inter.getLocText("FR-Designer_LiteCondition_Formula") + "="), BorderLayout.NORTH), BorderLayout.WEST);